From ab114eb606e25e7708dd6a936f87425081472dae Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Fri, 20 Oct 2017 20:42:11 +0200 Subject: [PATCH 1/8] Bump deps --- glide.lock | 49 +- vendor/github.com/Masterminds/sprig/date.go | 23 + .../github.com/Masterminds/sprig/date_test.go | 23 + vendor/github.com/Masterminds/sprig/dict.go | 10 +- .../github.com/Masterminds/sprig/dict_test.go | 17 +- vendor/github.com/Masterminds/sprig/doc.go | 5 + .../github.com/Masterminds/sprig/docs/date.md | 26 + .../Masterminds/sprig/docs/dicts.md | 4 +- .../Masterminds/sprig/docs/strings.md | 13 + .../github.com/Masterminds/sprig/functions.go | 13 +- .../github.com/Masterminds/sprig/strings.go | 4 + .../Masterminds/sprig/strings_test.go | 7 + vendor/github.com/aokoli/goutils/.travis.yml | 18 - vendor/github.com/aokoli/goutils/CHANGELOG.md | 8 - vendor/github.com/aokoli/goutils/README.md | 40 +- vendor/github.com/aokoli/goutils/appveyor.yml | 21 - .../aokoli/goutils/randomstringutils.go | 239 +- .../aokoli/goutils/randomstringutils_test.go | 53 +- .../github.com/aokoli/goutils/stringutils.go | 214 +- .../aokoli/goutils/stringutils_test.go | 52 +- vendor/github.com/aokoli/goutils/wordutils.go | 337 +- .../aokoli/goutils/wordutils_test.go | 121 +- .../docker/docker/.github/CODEOWNERS | 2 + vendor/github.com/docker/docker/.gitignore | 2 +- vendor/github.com/docker/docker/CHANGELOG.md | 4 +- .../github.com/docker/docker/CONTRIBUTING.md | 16 +- vendor/github.com/docker/docker/Dockerfile | 47 +- .../docker/docker/Dockerfile.aarch64 | 82 +- .../github.com/docker/docker/Dockerfile.armhf | 47 +- .../github.com/docker/docker/Dockerfile.e2e | 70 + .../docker/docker/Dockerfile.ppc64le | 51 +- .../github.com/docker/docker/Dockerfile.s390x | 51 +- .../docker/docker/Dockerfile.simple | 4 +- .../docker/docker/Dockerfile.windows | 4 +- vendor/github.com/docker/docker/Makefile | 18 +- vendor/github.com/docker/docker/TESTING.md | 71 + vendor/github.com/docker/docker/api/common.go | 54 - .../docker/docker/api/common_test.go | 77 - .../docker/docker/api/errdefs/defs.go | 54 + .../docker/docker/api/errdefs/doc.go | 8 + .../docker/docker/api/errdefs/is.go | 86 + .../docker/docker/api/errors/errors.go | 47 - .../docker/docker/api/errors/errors_test.go | 64 - .../docker/api/server/httputils/errors.go | 86 +- .../docker/api/server/httputils/form.go | 26 +- .../docker/api/server/httputils/httputils.go | 20 +- .../api/server/httputils/write_log_stream.go | 11 +- .../docker/api/server/middleware/version.go | 14 +- .../api/server/router/build/build_routes.go | 32 +- .../api/server/router/container/backend.go | 4 +- .../api/server/router/container/container.go | 12 +- .../router/container/container_routes.go | 53 +- .../api/server/router/container/copy.go | 20 +- .../api/server/router/container/exec.go | 14 +- .../docker/api/server/router/experimental.go | 16 +- .../api/server/router/image/image_routes.go | 32 +- .../api/server/router/network/filter.go | 12 +- .../server/router/network/network_routes.go | 28 +- .../server/router/session/session_routes.go | 17 +- .../api/server/router/swarm/cluster_routes.go | 52 +- .../docker/api/server/router/swarm/helpers.go | 3 +- .../api/server/router/system/system_routes.go | 13 +- .../docker/docker/api/server/server.go | 14 +- .../github.com/docker/docker/api/swagger.yaml | 1944 +- .../docker/docker/api/types/client.go | 2 +- .../docker/api/types/container/host_config.go | 39 +- .../docker/api/types/filters/example_test.go | 24 + .../docker/docker/api/types/filters/parse.go | 272 +- .../docker/api/types/filters/parse_test.go | 34 +- .../docker/docker/api/types/mount/mount.go | 4 +- .../docker/docker/api/types/time/timestamp.go | 4 +- .../docker/docker/builder/builder.go | 5 +- .../docker/builder/dockerfile/buildargs.go | 20 + .../docker/builder/dockerfile/builder.go | 239 +- .../docker/docker/builder/dockerfile/copy.go | 208 +- .../docker/builder/dockerfile/copy_test.go | 114 +- .../docker/builder/dockerfile/copy_unix.go | 20 +- .../docker/builder/dockerfile/copy_windows.go | 34 +- .../docker/builder/dockerfile/dispatchers.go | 727 +- .../builder/dockerfile/dispatchers_test.go | 437 +- .../builder/dockerfile/dispatchers_unix.go | 11 +- .../dockerfile/dispatchers_unix_test.go | 15 +- .../builder/dockerfile/dispatchers_windows.go | 52 +- .../dockerfile/dispatchers_windows_test.go | 48 +- .../docker/builder/dockerfile/errors.go | 15 + .../docker/builder/dockerfile/evaluator.go | 356 +- .../builder/dockerfile/evaluator_test.go | 170 +- .../builder/dockerfile/evaluator_unix.go | 9 - .../builder/dockerfile/evaluator_windows.go | 13 - .../docker/builder/dockerfile/imagecontext.go | 76 - .../dockerfile/{ => instructions}/bflag.go | 2 +- .../{ => instructions}/bflag_test.go | 10 +- .../dockerfile/instructions/commands.go | 396 + .../dockerfile/instructions/errors_unix.go | 9 + .../dockerfile/instructions/errors_windows.go | 27 + .../builder/dockerfile/instructions/parse.go | 635 + .../dockerfile/instructions/parse_test.go | 204 + .../dockerfile/{ => instructions}/support.go | 2 +- .../{ => instructions}/support_test.go | 2 +- .../docker/builder/dockerfile/internals.go | 251 +- .../builder/dockerfile/internals_test.go | 130 + .../builder/dockerfile/internals_unix.go | 42 - .../builder/dockerfile/internals_windows.go | 95 - .../dockerfile/internals_windows_test.go | 6 +- .../builder/dockerfile/mockbackend_test.go | 5 +- .../builder/dockerfile/parser/line_parsers.go | 2 +- .../builder/dockerfile/parser/parser.go | 4 +- .../docker/builder/fscache/fscache_test.go | 16 +- .../docker/builder/remotecontext/archive.go | 23 +- .../docker/builder/remotecontext/detect.go | 11 +- .../builder/remotecontext/detect_test.go | 12 +- .../docker/builder/remotecontext/errors.go | 75 + .../builder/remotecontext/lazycontext.go | 23 +- .../docker/builder/remotecontext/remote.go | 39 +- .../builder/remotecontext/remote_test.go | 9 +- .../docker/builder/remotecontext/tarsum.go | 25 +- .../docker/builder/remotecontext/tarsum.pb.go | 6 +- .../builder/remotecontext/tarsum_test.go | 2 +- .../docker/docker/client/checkpoint_list.go | 6 +- .../github.com/docker/docker/client/client.go | 82 +- .../docker/docker/client/client_mock_test.go | 8 + .../docker/docker/client/client_test.go | 63 +- .../docker/docker/client/config_inspect.go | 6 +- .../docker/docker/client/config_remove.go | 2 +- .../docker/docker/client/container_commit.go | 2 +- .../docker/docker/client/container_create.go | 2 +- .../docker/docker/client/container_inspect.go | 11 +- .../docker/docker/client/container_remove.go | 2 +- .../docker/client/container_remove_test.go | 16 +- .../github.com/docker/docker/client/errors.go | 201 +- .../github.com/docker/docker/client/hijack.go | 5 +- .../docker/docker/client/image_inspect.go | 6 +- .../docker/docker/client/image_remove.go | 4 +- .../docker/docker/client/image_remove_test.go | 13 +- .../docker/docker/client/image_search_test.go | 5 +- .../docker/docker/client/network_inspect.go | 6 +- .../docker/client/network_inspect_test.go | 13 +- .../docker/docker/client/network_remove.go | 2 +- .../docker/docker/client/node_inspect.go | 6 +- .../docker/docker/client/node_remove.go | 2 +- .../docker/docker/client/parse_logs.go | 41 - .../docker/docker/client/parse_logs_test.go | 36 - .../github.com/docker/docker/client/ping.go | 8 +- .../docker/docker/client/plugin_inspect.go | 6 +- .../docker/docker/client/plugin_remove.go | 2 +- .../docker/docker/client/request.go | 2 +- .../docker/docker/client/secret_inspect.go | 6 +- .../docker/docker/client/secret_remove.go | 2 +- .../docker/docker/client/service_create.go | 20 +- .../docker/docker/client/service_inspect.go | 6 +- .../docker/docker/client/service_remove.go | 2 +- .../docker/client/service_remove_test.go | 13 +- .../client/swarm_get_unlock_key_test.go | 2 +- .../docker/docker/client/task_inspect.go | 7 +- .../docker/docker/client/tlsconfig_clone.go | 11 + .../tlsconfig_clone_go17.go | 6 +- .../docker/docker/client/transport.go | 8 - .../docker/docker/client/volume_inspect.go | 16 +- .../docker/client/volume_inspect_test.go | 54 +- .../docker/docker/client/volume_remove.go | 2 +- .../docker/docker/cmd/dockerd/config.go | 17 +- .../docker/cmd/dockerd/config_solaris.go | 2 - .../docker/docker/cmd/dockerd/config_unix.go | 3 +- .../docker/docker/cmd/dockerd/daemon.go | 19 +- .../docker/cmd/dockerd/daemon_solaris.go | 13 - .../docker/docker/cmd/dockerd/daemon_test.go | 32 +- .../docker/cmd/dockerd/daemon_unix_test.go | 26 +- .../docker/cmd/dockerd/daemon_windows.go | 11 +- .../docker/docker/container/archive.go | 23 +- .../docker/docker/container/container.go | 56 +- .../docker/docker/container/container_unix.go | 103 +- .../docker/container/container_windows.go | 17 +- .../docker/docker/container/view.go | 5 +- .../contrib/docker-device-tool/device_tool.go | 9 - .../Syntaxes/Dockerfile.tmLanguage | 6 +- .../docker/docker/daemon/archive.go | 140 +- .../docker/docker/daemon/archive_unix.go | 4 +- .../github.com/docker/docker/daemon/attach.go | 16 +- .../github.com/docker/docker/daemon/build.go | 9 +- .../docker/docker/daemon/checkpoint.go | 6 +- .../docker/docker/daemon/cluster/cluster.go | 21 +- .../cluster/controllers/plugin/controller.go | 4 +- .../docker/daemon/cluster/convert/swarm.go | 3 +- .../docker/docker/daemon/cluster/errors.go | 114 + .../docker/daemon/cluster/executor/backend.go | 4 +- .../cluster/executor/container/adapter.go | 6 +- .../cluster/executor/container/attachment.go | 16 +- .../cluster/executor/container/container.go | 8 +- .../cluster/executor/container/controller.go | 6 +- .../cluster/executor/container/executor.go | 57 +- .../cluster/executor/container/health_test.go | 2 +- .../executor/container/validate_test.go | 3 +- .../docker/docker/daemon/cluster/helpers.go | 26 +- .../docker/daemon/cluster/listen_addr.go | 29 +- .../docker/docker/daemon/cluster/networks.go | 12 +- .../docker/docker/daemon/cluster/nodes.go | 3 +- .../docker/docker/daemon/cluster/services.go | 12 +- .../docker/docker/daemon/cluster/swarm.go | 25 +- .../docker/docker/daemon/config/config.go | 8 +- .../docker/daemon/config/config_solaris.go | 9 +- .../docker/daemon/config/config_test.go | 2 +- .../docker/daemon/config/config_unix.go | 25 + .../docker/daemon/config/config_unix_test.go | 33 +- .../docker/daemon/config/config_windows.go | 5 + .../docker/docker/daemon/config/opts.go | 22 + .../docker/docker/daemon/container.go | 53 +- .../docker/docker/daemon/container_linux.go | 2 +- .../docker/daemon/container_operations.go | 3 +- .../daemon/container_operations_unix.go | 65 +- .../github.com/docker/docker/daemon/create.go | 67 +- .../docker/docker/daemon/create_windows.go | 21 +- .../github.com/docker/docker/daemon/daemon.go | 61 +- .../docker/docker/daemon/daemon_solaris.go | 63 +- .../docker/docker/daemon/daemon_unix.go | 93 +- .../docker/docker/daemon/daemon_unix_test.go | 45 +- .../docker/docker/daemon/daemon_windows.go | 30 +- .../docker/docker/daemon/debugtrap_windows.go | 5 +- .../github.com/docker/docker/daemon/delete.go | 12 +- .../docker/docker/daemon/delete_test.go | 2 +- .../docker/daemon/discovery/discovery_test.go | 115 +- .../docker/docker/daemon/disk_usage.go | 3 +- .../github.com/docker/docker/daemon/errors.go | 211 +- .../github.com/docker/docker/daemon/exec.go | 14 +- .../docker/docker/daemon/exec/exec.go | 7 +- .../github.com/docker/docker/daemon/export.go | 10 +- .../docker/daemon/graphdriver/aufs/aufs.go | 85 +- .../daemon/graphdriver/aufs/aufs_test.go | 155 +- .../docker/daemon/graphdriver/btrfs/btrfs.go | 13 +- .../daemon/graphdriver/btrfs/btrfs_test.go | 4 +- .../graphdriver/devmapper/device_setup.go | 41 +- .../daemon/graphdriver/devmapper/deviceset.go | 70 +- .../daemon/graphdriver/devmapper/driver.go | 45 +- .../docker/daemon/graphdriver/driver.go | 3 +- .../daemon/graphdriver/driver_freebsd.go | 6 +- .../docker/daemon/graphdriver/driver_linux.go | 3 +- .../docker/daemon/graphdriver/fsdiff.go | 26 +- .../graphdriver/graphtest/graphbench_unix.go | 10 +- .../graphdriver/graphtest/graphtest_unix.go | 8 +- .../daemon/graphdriver/graphtest/testutil.go | 83 +- .../graphdriver/graphtest/testutil_unix.go | 23 +- .../docker/daemon/graphdriver/lcow/lcow.go | 626 +- .../daemon/graphdriver/lcow/lcow_svm.go | 373 + .../daemon/graphdriver/lcow/remotefs.go | 139 + .../daemon/graphdriver/lcow/remotefs_file.go | 211 + .../graphdriver/lcow/remotefs_filedriver.go | 123 + .../graphdriver/lcow/remotefs_pathdriver.go | 212 + .../docker/daemon/graphdriver/overlay/copy.go | 3 +- .../daemon/graphdriver/overlay/overlay.go | 24 +- .../daemon/graphdriver/overlay2/overlay.go | 21 +- .../docker/daemon/graphdriver/plugin.go | 10 - .../docker/docker/daemon/graphdriver/proxy.go | 7 +- .../register/register_devicemapper.go | 2 +- .../docker/daemon/graphdriver/vfs/driver.go | 16 +- .../daemon/graphdriver/windows/windows.go | 19 +- .../docker/daemon/graphdriver/zfs/zfs.go | 17 +- .../github.com/docker/docker/daemon/health.go | 5 +- .../github.com/docker/docker/daemon/image.go | 32 +- .../docker/docker/daemon/image_delete.go | 22 +- .../docker/docker/daemon/image_exporter.go | 4 +- .../docker/docker/daemon/image_history.go | 2 +- .../docker/docker/daemon/image_inspect.go | 2 +- .../docker/docker/daemon/image_pull.go | 8 +- .../docker/docker/daemon/image_push.go | 2 +- .../docker/docker/daemon/image_tag.go | 2 +- .../github.com/docker/docker/daemon/images.go | 10 +- .../github.com/docker/docker/daemon/import.go | 8 +- .../github.com/docker/docker/daemon/info.go | 8 +- .../docker/daemon/initlayer/setup_solaris.go | 4 +- .../docker/daemon/initlayer/setup_unix.go | 6 +- .../docker/daemon/initlayer/setup_windows.go | 3 +- .../docker/docker/daemon/inspect.go | 8 +- .../github.com/docker/docker/daemon/kill.go | 12 +- .../github.com/docker/docker/daemon/links.go | 8 +- .../github.com/docker/docker/daemon/list.go | 12 +- .../{pkg => daemon}/listeners/group_unix.go | 0 .../listeners/listeners_solaris.go | 0 .../listeners/listeners_unix.go | 2 +- .../listeners/listeners_windows.go | 0 .../daemon/logger/awslogs/cloudwatchlogs.go | 15 - .../logger/awslogs/cloudwatchlogs_test.go | 4 +- .../docker/docker/daemon/logger/factory.go | 2 +- .../docker/daemon/logger/jsonfilelog/read.go | 3 +- .../daemon/logger/logentries/logentries.go | 44 +- .../docker/docker/daemon/logger/logger.go | 12 +- .../daemon/logger/loggerutils/log_tag.go | 2 +- .../docker/docker/daemon/logger/ring.go | 1 - .../docker/daemon/logger/splunk/splunk.go | 8 +- .../daemon/logger/splunk/splunk_test.go | 28 +- .../logger}/templates/templates.go | 28 - .../daemon/logger/templates/templates_test.go | 18 + .../github.com/docker/docker/daemon/logs.go | 18 +- .../docker/docker/daemon/metrics.go | 4 +- .../docker/docker/daemon/monitor.go | 2 +- .../docker/docker/daemon/monitor_windows.go | 11 +- .../github.com/docker/docker/daemon/names.go | 13 +- .../docker/{api => daemon/names}/names.go | 2 +- .../docker/docker/daemon/network.go | 106 +- .../docker/docker/daemon/network/settings.go | 36 + .../docker/docker/daemon/oci_linux.go | 63 +- .../docker/docker/daemon/oci_solaris.go | 3 +- .../docker/docker/daemon/oci_windows.go | 215 +- .../github.com/docker/docker/daemon/pause.go | 2 +- .../github.com/docker/docker/daemon/prune.go | 6 +- .../github.com/docker/docker/daemon/reload.go | 4 +- .../docker/docker/daemon/reload_test.go | 27 +- .../github.com/docker/docker/daemon/rename.go | 11 +- .../github.com/docker/docker/daemon/resize.go | 2 +- .../github.com/docker/docker/daemon/search.go | 7 +- .../github.com/docker/docker/daemon/start.go | 90 +- .../docker/docker/daemon/start_unix.go | 5 +- .../docker/docker/daemon/start_windows.go | 219 +- .../docker/docker/daemon/stats/collector.go | 4 +- .../docker/docker/daemon/stats_unix.go | 5 +- .../github.com/docker/docker/daemon/stop.go | 11 +- .../{api/fixtures => daemon/testdata}/keyfile | 0 .../docker/docker/daemon/top_unix.go | 3 +- .../docker/docker/daemon/trustkey.go | 57 + .../docker/docker/daemon/trustkey_test.go | 72 + .../github.com/docker/docker/daemon/update.go | 15 +- .../docker/docker/daemon/volumes.go | 29 +- .../docker/docker/daemon/volumes_unit_test.go | 5 +- .../docker/docker/distribution/errors.go | 84 +- .../metadata/v2_metadata_service.go | 2 +- .../docker/docker/distribution/pull.go | 3 +- .../docker/docker/distribution/pull_v1.go | 6 +- .../docker/docker/distribution/pull_v2.go | 21 +- .../docker/distribution/pull_v2_test.go | 6 +- .../docker/docker/distribution/push_v1.go | 6 +- .../docker/docker/distribution/push_v2.go | 10 +- .../docker/distribution/registry_unit_test.go | 45 - .../docker/docker/docs/api/v1.18.md | 4 +- .../docker/docker/docs/api/v1.19.md | 4 +- .../docker/docker/docs/api/v1.20.md | 4 +- .../docker/docker/docs/api/v1.21.md | 2 +- .../docker/docker/docs/api/v1.22.md | 2 +- .../docker/docker/docs/api/v1.23.md | 2 +- .../docker/docker/docs/api/v1.24.md | 2 +- .../docker/docker/docs/api/version-history.md | 7 +- .../github.com/docker/docker/hack/README.md | 4 +- .../docker/hack/dockerfile/binaries-commits | 9 +- .../hack/dockerfile/install-binaries.sh | 48 +- .../agent/master/call.go | 6 +- .../agent/worker/worker.go | 2 +- vendor/github.com/docker/docker/hack/make.ps1 | 53 +- vendor/github.com/docker/docker/hack/make.sh | 26 +- .../docker/docker/hack/make/.ensure-emptyfs | 26 +- .../hack/make/.integration-daemon-setup | 2 +- .../hack/make/.integration-daemon-start | 32 +- .../docker/hack/make/.integration-daemon-stop | 11 +- .../hack/make/.integration-test-helpers | 132 +- .../hack/make/build-integration-test-binary | 13 +- .../docker/docker/hack/make/test-integration | 22 + .../docker/hack/make/test-integration-cli | 29 +- .../docker/hack/make/test-integration-shell | 2 + .../github.com/docker/docker/hack/release.sh | 2 +- .../docker/docker/hack/test/e2e-run.sh | 41 + .../github.com/docker/docker/hack/test/unit | 2 +- .../docker/docker/hack/validate/default | 5 +- .../hack/validate/deprecate-integration-cli | 25 + .../docker/docker/hack/validate/gofmt | 33 - .../docker/docker/hack/validate/gometalinter | 11 + .../docker/hack/validate/gometalinter.json | 26 + .../docker/docker/hack/validate/lint | 31 - .../docker/docker/hack/validate/vet | 32 - .../github.com/docker/docker/image/fs_test.go | 13 +- .../github.com/docker/docker/image/store.go | 12 +- .../docker/docker/image/store_test.go | 6 +- .../docker/docker/image/tarexport/load.go | 12 +- .../docker/integration-cli/check_test.go | 64 +- .../docker/integration-cli/cli/build/build.go | 2 +- .../cli/build/fakegit/fakegit.go | 2 + .../cli/build/fakestorage/fixtures.go | 39 +- .../cli/build/fakestorage/storage.go | 42 +- .../docker/docker/integration-cli/cli/cli.go | 37 +- .../docker/integration-cli/daemon/daemon.go | 87 +- .../integration-cli/daemon/daemon_swarm.go | 389 +- .../integration-cli/daemon/daemon_windows.go | 36 +- .../integration-cli/docker_api_attach_test.go | 12 +- .../integration-cli/docker_api_auth_test.go | 15 +- .../integration-cli/docker_api_build_test.go | 131 +- .../docker_api_containers_test.go | 1492 +- .../docker_api_containers_windows_test.go | 71 + .../integration-cli/docker_api_create_test.go | 126 +- .../docker_api_exec_resize_test.go | 15 +- .../integration-cli/docker_api_exec_test.go | 56 +- .../integration-cli/docker_api_images_test.go | 78 +- .../integration-cli/docker_api_info_test.go | 29 +- .../docker_api_inspect_test.go | 17 +- .../docker_api_inspect_unix_test.go | 10 +- .../docker_api_ipcmode_test.go | 222 + .../integration-cli/docker_api_logs_test.go | 11 +- .../docker_api_network_test.go | 19 +- .../integration-cli/docker_api_resize_test.go | 35 +- .../docker_api_session_test.go | 5 +- .../integration-cli/docker_api_stats_test.go | 16 +- .../docker_api_swarm_config_test.go | 23 +- .../docker_api_swarm_secret_test.go | 28 +- .../docker_api_swarm_service_test.go | 24 +- .../integration-cli/docker_api_swarm_test.go | 84 +- .../docker/integration-cli/docker_api_test.go | 33 +- .../docker_api_update_unix_test.go | 19 +- .../docker_api_version_test.go | 24 - .../docker_api_volumes_test.go | 80 +- .../integration-cli/docker_cli_attach_test.go | 4 +- .../docker_cli_attach_unix_test.go | 4 +- .../docker_cli_authz_plugin_v2_test.go | 16 +- .../docker_cli_authz_unix_test.go | 15 +- .../integration-cli/docker_cli_build_test.go | 50 +- .../docker_cli_build_unix_test.go | 27 +- .../docker_cli_by_digest_test.go | 4 +- .../integration-cli/docker_cli_commit_test.go | 2 +- .../docker_cli_config_ls_test.go | 1 + .../integration-cli/docker_cli_config_test.go | 150 - .../docker_cli_cp_from_container_test.go | 10 +- .../integration-cli/docker_cli_cp_test.go | 5 +- .../docker_cli_cp_to_container_test.go | 7 +- .../docker_cli_cp_utils_test.go | 6 +- .../integration-cli/docker_cli_create_test.go | 2 +- .../docker_cli_daemon_plugins_test.go | 2 +- .../integration-cli/docker_cli_daemon_test.go | 202 +- .../integration-cli/docker_cli_events_test.go | 32 +- .../docker_cli_events_unix_test.go | 29 +- .../integration-cli/docker_cli_exec_test.go | 21 +- .../docker_cli_experimental_test.go | 29 - .../docker_cli_export_import_test.go | 2 +- ...cker_cli_external_graphdriver_unix_test.go | 3 +- ...er_cli_external_volume_driver_unix_test.go | 1 + .../integration-cli/docker_cli_health_test.go | 9 +- .../integration-cli/docker_cli_help_test.go | 319 - .../integration-cli/docker_cli_images_test.go | 2 +- .../integration-cli/docker_cli_import_test.go | 7 +- .../integration-cli/docker_cli_info_test.go | 43 +- .../docker_cli_inspect_test.go | 5 +- .../integration-cli/docker_cli_kill_test.go | 12 +- .../integration-cli/docker_cli_links_test.go | 33 +- .../integration-cli/docker_cli_logs_test.go | 40 +- .../docker_cli_netmode_test.go | 4 +- .../docker_cli_network_unix_test.go | 61 +- .../docker_cli_plugins_logdriver_test.go | 15 +- .../docker_cli_plugins_test.go | 4 +- .../integration-cli/docker_cli_port_test.go | 38 +- .../integration-cli/docker_cli_proxy_test.go | 2 +- .../docker_cli_prune_unix_test.go | 17 +- .../integration-cli/docker_cli_ps_test.go | 134 +- .../docker_cli_pull_local_test.go | 2 +- .../integration-cli/docker_cli_pull_test.go | 19 +- .../docker_cli_pull_trusted_test.go | 2 +- .../integration-cli/docker_cli_push_test.go | 2 +- .../integration-cli/docker_cli_rename_test.go | 17 +- .../integration-cli/docker_cli_rmi_test.go | 2 +- .../integration-cli/docker_cli_run_test.go | 63 +- .../docker_cli_run_unix_test.go | 22 +- .../docker_cli_save_load_test.go | 46 +- .../docker_cli_save_load_unix_test.go | 2 +- .../docker_cli_service_logs_test.go | 20 +- .../integration-cli/docker_cli_stack_test.go | 206 - .../integration-cli/docker_cli_start_test.go | 4 +- .../integration-cli/docker_cli_swarm_test.go | 195 +- .../docker_cli_swarm_unix_test.go | 2 +- .../integration-cli/docker_cli_top_test.go | 4 +- .../integration-cli/docker_cli_update_test.go | 2 +- .../docker_cli_update_unix_test.go | 32 +- .../integration-cli/docker_cli_userns_test.go | 9 +- .../docker_cli_version_test.go | 58 - .../integration-cli/docker_cli_volume_test.go | 96 +- .../integration-cli/docker_cli_wait_test.go | 2 +- .../docker_deprecated_api_v124_test.go | 55 +- .../docker_deprecated_api_v124_unix_test.go | 2 +- .../docker_experimental_network_test.go | 8 +- .../docker_hub_pull_suite_test.go | 2 +- .../integration-cli/docker_utils_test.go | 44 +- .../integration-cli/environment/clean.go | 216 - .../environment/environment.go | 206 +- .../integration-cli/environment/protect.go | 12 - .../integration-cli/fixtures/load/frozen.go | 81 +- .../integration-cli/fixtures/plugin/plugin.go | 151 +- .../fixtures/plugin/plugin_linux.go | 157 - .../fixtures/plugin/plugin_unsuported.go | 19 - .../fixtures_linux_daemon_test.go | 16 +- .../docker/integration-cli/request/request.go | 53 +- .../requirement/requirement.go | 5 +- .../integration-cli/requirements_test.go | 71 +- .../integration-cli/requirements_unix_test.go | 26 +- .../integration-cli/trust_server_test.go | 2 +- .../docker/integration-cli/utils_test.go | 161 +- .../integration/container/create_test.go | 93 + .../docker/integration/container/main_test.go | 28 + .../docker/docker/integration/doc.go | 3 + .../docker/integration/service/create_test.go | 129 + .../integration/service/inspect_test.go | 148 + .../docker/integration/service/main_test.go | 30 + .../docker/integration/system/main_test.go | 28 + .../docker/integration/system/version_test.go | 24 + .../docker/integration/util/request/client.go | 15 + .../docker/internal/test/environment/clean.go | 176 + .../internal/test/environment/environment.go | 117 + .../internal/test/environment/protect.go | 208 + .../docker/internal/testutil/helpers.go | 13 + .../docker/docker/layer/empty_test.go | 6 + .../github.com/docker/docker/layer/layer.go | 5 +- .../docker/docker/layer/layer_store.go | 2 +- .../docker/docker/layer/layer_test.go | 42 +- .../docker/docker/layer/layer_windows.go | 17 +- .../docker/docker/layer/mount_test.go | 34 +- .../docker/docker/layer/mounted_layer.go | 3 +- .../docker/libcontainerd/client_linux.go | 5 +- .../docker/libcontainerd/client_solaris.go | 5 +- .../docker/libcontainerd/client_unix.go | 2 +- .../docker/libcontainerd/client_windows.go | 318 +- .../docker/libcontainerd/container_windows.go | 44 +- .../docker/libcontainerd/types_linux.go | 2 +- .../docker/libcontainerd/types_windows.go | 45 +- .../docker/libcontainerd/utils_linux.go | 2 +- .../docker/libcontainerd/utils_windows.go | 44 +- .../github.com/docker/docker/oci/defaults.go | 41 +- vendor/github.com/docker/docker/opts/env.go | 4 +- .../github.com/docker/docker/opts/env_test.go | 128 +- vendor/github.com/docker/docker/opts/opts.go | 21 +- .../docker/docker/opts/quotedstring.go | 2 +- .../docker/docker/pkg/archive/archive.go | 45 +- .../docker/pkg/archive/archive_linux_test.go | 100 +- .../docker/docker/pkg/archive/archive_test.go | 70 +- .../docker/docker/pkg/archive/archive_unix.go | 6 +- .../docker/pkg/archive/archive_unix_test.go | 223 +- .../docker/docker/pkg/archive/changes.go | 2 +- .../docker/pkg/archive/changes_linux.go | 2 +- .../docker/docker/pkg/archive/changes_test.go | 279 +- .../docker/docker/pkg/archive/changes_unix.go | 2 +- .../docker/docker/pkg/archive/copy.go | 61 +- .../docker/pkg/archive/copy_unix_test.go | 112 +- .../docker/docker/pkg/archive/wrap_test.go | 18 +- .../docker/docker/pkg/authorization/authz.go | 7 +- .../docker/pkg/chrootarchive/archive.go | 5 +- .../docker/docker/pkg/containerfs/archiver.go | 194 + .../docker/pkg/containerfs/containerfs.go | 87 + .../pkg/containerfs/containerfs_unix.go | 10 + .../pkg/containerfs/containerfs_windows.go | 15 + .../docker/pkg/devicemapper/devmapper.go | 7 +- .../docker/pkg/devicemapper/devmapper_log.go | 4 +- .../pkg/devicemapper/devmapper_wrapper.go | 1 - .../devmapper_wrapper_deferred_remove.go | 5 +- .../devicemapper/devmapper_wrapper_dynamic.go | 6 + .../docker/pkg/directory/directory_unix.go | 4 +- .../docker/docker/pkg/discovery/kv/kv_test.go | 2 - .../docker/docker/pkg/dmesg/dmesg_linux.go | 20 + .../docker/pkg/dmesg/dmesg_linux_test.go | 9 + .../docker/pkg/fileutils/fileutils_test.go | 2 +- .../docker/docker/pkg/ioutils/readers_test.go | 7 +- .../docker/pkg/jsonmessage/jsonmessage.go | 7 +- .../pkg/jsonmessage/jsonmessage_test.go | 5 +- .../docker/docker/pkg/locker/README.md | 6 +- .../docker/docker/pkg/loopback/ioctl.go | 10 +- .../docker/pkg/mount/mounter_solaris.go | 3 +- .../docker/pkg/plugins/discovery_unix_test.go | 3 + .../pkg/plugins/pluginrpc-gen/fixtures/foo.go | 6 - .../docker/docker/pkg/pools/pools_test.go | 21 +- .../docker/pkg/signal/signal_linux_test.go | 2 +- .../docker/pkg/signal/testfiles/main.go | 43 + .../docker/pkg/signal/trap_linux_test.go | 82 + .../pkg/streamformatter/streamwriter_test.go | 2 +- .../docker/pkg/system/events_windows.go | 85 - .../docker/docker/pkg/system/init_unix.go | 7 + .../docker/docker/pkg/system/init_windows.go | 5 +- .../docker/docker/pkg/system/path.go | 41 +- .../docker/docker/pkg/system/path_unix.go | 9 - .../docker/docker/pkg/system/path_windows.go | 33 - .../docker/pkg/system/path_windows_test.go | 25 +- .../docker/docker/pkg/system/stat_linux.go | 4 +- .../docker/pkg/system/stat_unix_test.go | 7 +- .../docker/docker/pkg/tarsum/tarsum_test.go | 27 +- .../docker/pkg/templates/templates_test.go | 88 - .../docker/docker/pkg/term/ascii.go | 2 +- .../docker/docker/pkg/term/ascii_test.go | 46 +- .../docker/docker/pkg/term/term_linux_test.go | 3 + .../docker/docker/pkg/term/termios_linux.go | 2 + .../docker/docker/pkg/term/winsize.go | 18 +- .../docker/pkg/testutil/cmd/command_test.go | 118 - .../docker/pkg/testutil/golden/golden.go | 28 - .../docker/docker/pkg/testutil/helpers.go | 33 - .../docker/pkg/testutil/tempfile/tempfile.go | 56 - .../docker/docker/pkg/testutil/utils.go | 218 - .../docker/docker/pkg/testutil/utils_test.go | 341 - .../docker/pkg/tlsconfig/tlsconfig_clone.go | 11 - .../docker/docker/plugin/backend_linux.go | 51 +- .../github.com/docker/docker/plugin/errors.go | 94 + .../plugin/executor/containerd/containerd.go | 77 + .../docker/docker/plugin/manager.go | 108 +- .../docker/docker/plugin/manager_linux.go | 45 +- .../github.com/docker/docker/plugin/store.go | 42 +- .../docker/docker/plugin/v2/plugin_linux.go | 2 +- .../docker/profiles/apparmor/apparmor.go | 4 +- .../docker/profiles/seccomp/default.json | 2 +- .../profiles/seccomp/seccomp_default.go | 2 +- .../github.com/docker/docker/project/ARM.md | 2 +- .../docker/docker/reference/errors.go | 25 + .../docker/docker/reference/store.go | 24 +- .../docker/docker/reference/store_test.go | 48 +- .../github.com/docker/docker/registry/auth.go | 60 +- .../docker/docker/registry/config.go | 41 +- .../docker/docker/registry/config_test.go | 63 +- .../docker/docker/registry/config_unix.go | 9 - .../docker/docker/registry/config_windows.go | 7 - .../docker/docker/registry/endpoint_v1.go | 6 +- .../docker/docker/registry/errors.go | 86 + .../docker/docker/registry/registry.go | 2 +- .../docker/registry/registry_mock_test.go | 2 +- .../docker/docker/registry/registry_test.go | 38 +- .../resumable/resumablerequestreader_test.go | 5 +- .../docker/docker/registry/service.go | 17 +- .../docker/docker/registry/service_v1_test.go | 5 +- .../docker/docker/registry/session.go | 14 +- .../docker/docker/runconfig/config.go | 35 +- .../docker/docker/runconfig/config_test.go | 60 +- .../docker/docker/runconfig/errors.go | 44 +- .../docker/docker/runconfig/hostconfig.go | 7 +- .../docker/runconfig/hostconfig_test.go | 67 +- vendor/github.com/docker/docker/vendor.conf | 25 +- .../github.com/Microsoft/go-winio/backup.go | 14 +- .../Microsoft/go-winio/backuptar/tar.go | 92 +- .../github.com/Microsoft/go-winio/ea.go | 137 + .../github.com/Microsoft/go-winio/file.go | 8 + .../github.com/Microsoft/go-winio/pipe.go | 4 +- .../github.com/Microsoft/hcsshim/container.go | 6 + .../Microsoft/hcsshim/hnspolicylist.go | 12 +- .../github.com/Microsoft/hcsshim/interface.go | 11 +- .../github.com/Microsoft/opengcs/LICENSE | 21 + .../github.com/Microsoft/opengcs/README.md | 14 + .../opengcs}/client/config.go | 11 +- .../opengcs}/client/createext4vhdx.go | 2 + .../opengcs}/client/hotaddvhd.go | 2 + .../opengcs}/client/hotremovevhd.go | 2 + .../opengcs}/client/layervhddetails.go | 0 .../opengcs}/client/process.go | 45 + .../opengcs}/client/tartovhd.go | 2 + .../opengcs}/client/unsupported.go | 0 .../opengcs}/client/utilities.go | 0 .../opengcs}/client/vhdtotar.go | 2 + .../Microsoft/opengcs/service/gcsutils/README | 4 + .../opengcs/service/gcsutils/remotefs/defs.go | 109 + .../service/gcsutils/remotefs/remotefs.go | 546 + .../service/gcsutils/remotefs/utils.go | 168 + .../containerd/api/grpc/types/api.pb.go | 347 +- .../containerd/api/grpc/types/api.proto | 2 + .../containerd/runtime/container.go | 3 +- .../containerd/runtime/container_linux.go | 22 +- .../containerd/containerd/runtime/process.go | 38 +- .../containerd/containerd/runtime/runtime.go | 26 +- .../containerd/containerd/specs/spec_linux.go | 2 +- .../containerd/containerd/vendor.conf | 33 + .../github.com/containerd/continuity/LICENSE | 202 + .../containerd/continuity/README.md | 74 + .../containerd/continuity/devices/devices.go | 5 + .../continuity/devices/devices_darwin.go | 15 + .../continuity/devices/devices_dummy.go | 23 + .../continuity/devices/devices_freebsd.go | 15 + .../continuity/devices/devices_linux.go | 15 + .../continuity/devices/devices_solaris.go | 18 + .../continuity/devices/devices_unix.go | 55 + .../continuity/devices/devices_windows.go | 11 + .../containerd/continuity/driver/driver.go | 162 + .../continuity/driver/driver_unix.go | 122 + .../continuity/driver/driver_windows.go | 21 + .../containerd/continuity/driver/utils.go | 74 + .../continuity/pathdriver/path_driver.go | 85 + .../containerd/continuity/sysx/asm.s | 10 + .../continuity/sysx/chmod_darwin.go | 18 + .../continuity/sysx/chmod_darwin_386.go | 25 + .../continuity/sysx/chmod_darwin_amd64.go | 25 + .../continuity/sysx/chmod_freebsd.go | 17 + .../continuity/sysx/chmod_freebsd_amd64.go | 25 + .../containerd/continuity/sysx/chmod_linux.go | 12 + .../continuity/sysx/chmod_solaris.go | 11 + .../containerd/continuity/sysx/copy_linux.go | 11 + .../continuity/sysx/copy_linux_386.go | 20 + .../continuity/sysx/copy_linux_amd64.go | 20 + .../continuity/sysx/copy_linux_arm.go | 20 + .../continuity/sysx/copy_linux_arm64.go | 20 + .../continuity/sysx/copy_linux_ppc64le.go | 20 + .../continuity/sysx/copy_linux_s390x.go | 20 + .../continuity/sysx/nodata_linux.go | 7 + .../continuity/sysx/nodata_solaris.go | 8 + .../containerd/continuity/sysx/nodata_unix.go | 9 + .../containerd/continuity/sysx/sys.go | 37 + .../continuity/sysx/sysnum_linux_386.go | 7 + .../continuity/sysx/sysnum_linux_amd64.go | 7 + .../continuity/sysx/sysnum_linux_arm.go | 7 + .../continuity/sysx/sysnum_linux_arm64.go | 7 + .../continuity/sysx/sysnum_linux_ppc64le.go | 7 + .../continuity/sysx/sysnum_linux_s390x.go | 7 + .../containerd/continuity/sysx/xattr.go | 67 + .../continuity/sysx/xattr_darwin.go | 71 + .../continuity/sysx/xattr_darwin_386.go | 111 + .../continuity/sysx/xattr_darwin_amd64.go | 111 + .../continuity/sysx/xattr_freebsd.go | 12 + .../containerd/continuity/sysx/xattr_linux.go | 61 + .../continuity/sysx/xattr_linux_386.go | 111 + .../continuity/sysx/xattr_linux_amd64.go | 111 + .../continuity/sysx/xattr_linux_arm.go | 111 + .../continuity/sysx/xattr_linux_arm64.go | 111 + .../continuity/sysx/xattr_linux_ppc64.go | 111 + .../continuity/sysx/xattr_linux_ppc64le.go | 111 + .../continuity/sysx/xattr_linux_s390x.go | 111 + .../continuity/sysx/xattr_solaris.go | 12 + .../continuity/sysx/xattr_unsupported.go | 44 + .../github.com/docker/libnetwork/agent.go | 15 +- .../docker/libnetwork/bitseq/sequence.go | 8 +- .../docker/libnetwork/common/caller.go | 29 + .../docker/libnetwork/config/config.go | 14 +- .../docker/libnetwork/diagnose/diagnose.go | 133 + .../libnetwork/drivers/ipvlan/ipvlan_setup.go | 2 +- .../drivers/macvlan/macvlan_setup.go | 2 +- .../libnetwork/drivers/overlay/joinleave.go | 7 +- .../libnetwork/drivers/overlay/ov_network.go | 18 +- .../libnetwork/drivers/overlay/ov_serf.go | 10 +- .../libnetwork/drivers/overlay/overlay.go | 24 +- .../libnetwork/drivers/overlay/peerdb.go | 161 +- .../drivers/solaris/overlay/ov_network.go | 4 +- .../drivers/solaris/overlay/overlay.go | 4 +- .../windows/overlay/joinleave_windows.go | 5 + .../windows/overlay/ov_endpoint_windows.go | 77 +- .../windows/overlay/ov_network_windows.go | 15 +- .../windows/overlay/overlay_windows.go | 2 +- .../drivers/windows/overlay/peerdb_windows.go | 6 +- .../libnetwork/drivers/windows/windows.go | 24 +- .../github.com/docker/libnetwork/endpoint.go | 18 +- .../docker/libnetwork/endpoint_info.go | 13 +- .../docker/libnetwork/ipam/allocator.go | 4 +- .../github.com/docker/libnetwork/ipvs/ipvs.go | 7 + .../docker/libnetwork/ipvs/netlink.go | 7 + .../docker/libnetwork/networkdb/broadcast.go | 3 +- .../docker/libnetwork/networkdb/cluster.go | 7 - .../docker/libnetwork/networkdb/delegate.go | 52 +- .../libnetwork/networkdb/event_delegate.go | 8 +- .../docker/libnetwork/networkdb/networkdb.go | 143 +- .../libnetwork/networkdb/networkdbdiagnose.go | 242 + .../docker/libnetwork/osl/interface_linux.go | 19 - .../docker/libnetwork/osl/namespace_linux.go | 16 + .../docker/libnetwork/osl/neigh_linux.go | 4 +- .../docker/libnetwork/osl/options_linux.go | 6 - .../docker/libnetwork/osl/sandbox.go | 12 +- .../portallocator/portallocator_freebsd.go | 42 + .../github.com/docker/libnetwork/resolver.go | 32 +- .../github.com/docker/libnetwork/sandbox.go | 29 +- .../docker/libnetwork/sandbox_dns_unix.go | 16 +- .../github.com/docker/libnetwork/service.go | 1 + .../docker/libnetwork/service_common.go | 4 +- .../docker/libnetwork/service_linux.go | 8 +- .../docker/libnetwork/service_windows.go | 141 +- .../docker/libnetwork/types/types.go | 4 +- .../github.com/docker/libnetwork/vendor.conf | 14 +- .../github.com/docker/swarmkit/api/README.md | 16 + .../github.com/docker/swarmkit/api/ca.pb.go | 311 +- .../github.com/docker/swarmkit/api/ca.proto | 6 +- .../docker/swarmkit/api/control.pb.go | 274 +- .../docker/swarmkit/api/control.proto | 8 +- .../docker/swarmkit/api/dispatcher.pb.go | 135 +- .../docker/swarmkit/api/dispatcher.proto | 6 +- .../github.com/docker/swarmkit/api/gen.go | 3 - .../docker/swarmkit/api/health.pb.go | 46 +- .../docker/swarmkit/api/health.proto | 2 +- .../docker/swarmkit/api/logbroker.pb.go | 130 +- .../docker/swarmkit/api/logbroker.proto | 2 +- .../docker/swarmkit/api/objects.pb.go | 259 +- .../docker/swarmkit/api/objects.proto | 16 +- .../github.com/docker/swarmkit/api/raft.pb.go | 131 +- .../github.com/docker/swarmkit/api/raft.proto | 6 +- .../docker/swarmkit/api/resource.pb.go | 58 +- .../docker/swarmkit/api/resource.proto | 4 +- .../docker/swarmkit/api/snapshot.pb.go | 69 +- .../docker/swarmkit/api/snapshot.proto | 4 +- .../docker/swarmkit/api/specs.pb.go | 738 +- .../docker/swarmkit/api/specs.proto | 22 +- .../docker/swarmkit/api/types.pb.go | 1123 +- .../docker/swarmkit/api/types.proto | 27 + .../docker/swarmkit/api/watch.pb.go | 156 +- .../docker/swarmkit/api/watch.proto | 8 +- .../github.com/docker/swarmkit/ca/config.go | 46 +- .../github.com/docker/swarmkit/ca/external.go | 44 +- .../github.com/docker/swarmkit/ca/server.go | 286 +- .../cnmallocator/networkallocator.go | 107 +- .../swarmkit/manager/allocator/network.go | 265 +- .../networkallocator/networkallocator.go | 25 +- .../manager/controlapi/ca_rotation.go | 7 +- .../swarmkit/manager/controlapi/cluster.go | 19 +- .../swarmkit/manager/controlapi/secret.go | 6 + .../swarmkit/manager/controlapi/server.go | 8 +- .../manager/dispatcher/assignments.go | 163 +- .../swarmkit/manager/dispatcher/dispatcher.go | 7 +- .../swarmkit/manager/drivers/secrets.go | 69 +- .../swarmkit/manager/logbroker/broker.go | 37 +- .../docker/swarmkit/manager/manager.go | 65 +- .../manager/orchestrator/global/global.go | 132 +- .../orchestrator/replicated/services.go | 2 +- .../manager/orchestrator/replicated/slot.go | 45 + .../manager/orchestrator/restart/restart.go | 187 +- .../swarmkit/manager/orchestrator/slot.go | 39 +- .../swarmkit/manager/orchestrator/task.go | 65 +- .../manager/orchestrator/taskinit/init.go | 75 +- .../orchestrator/taskreaper/task_reaper.go | 71 +- .../manager/orchestrator/update/updater.go | 10 +- .../swarmkit/manager/state/raft/raft.go | 96 +- .../swarmkit/manager/watchapi/server.go | 41 +- .../docker/swarmkit/manager/watchapi/watch.go | 9 + .../github.com/docker/swarmkit/node/node.go | 21 +- .../docker/swarmkit/protobuf/plugin/gen.go | 3 - .../swarmkit/protobuf/plugin/plugin.pb.go | 145 +- .../docker/swarmkit/template/context.go | 8 +- .../docker/swarmkit/template/expand.go | 14 +- .../docker/swarmkit/template/getter.go | 33 +- .../github.com/docker/swarmkit/vendor.conf | 23 +- .../gotestyourself/gotestyourself/LICENSE | 202 + .../gotestyourself/gotestyourself/README.md | 33 + .../gotestyourself/gotestyourself/fs/file.go | 81 + .../gotestyourself/gotestyourself/fs/ops.go | 94 + .../gotestyourself/icmd}/command.go | 67 +- .../gotestyourself/icmd/exitcode.go | 32 + .../gotestyourself/gotestyourself/icmd/ops.go | 4 + .../gotestyourself/poll/poll.go | 133 + .../gotestyourself/skip/skip.go | 133 + .../github.com/jhowardmsft/opengcs/LICENSE | 21 - .../github.com/opencontainers/runc/README.md | 34 +- .../runc/libcontainer/README.md | 108 +- .../runc/libcontainer/cgroups/stats.go | 2 + .../runc/libcontainer/cgroups/utils.go | 15 + .../{cgroup_unix.go => cgroup_linux.go} | 12 +- .../runc/libcontainer/configs/config.go | 1 + .../{config_unix.go => config_linux.go} | 2 - ...namespaces_unix.go => namespaces_linux.go} | 5 - .../configs/namespaces_syscall.go | 14 +- .../configs/namespaces_unsupported.go | 2 +- .../{devices_unix.go => devices_linux.go} | 48 +- .../devices/devices_unsupported.go | 2 +- .../runc/libcontainer/nsenter/nsexec.c | 20 +- .../runc/libcontainer/system/linux.go | 29 +- .../runc/libcontainer/system/proc.go | 120 +- .../runc/libcontainer/system/setns_linux.go | 40 - .../libcontainer/system/syscall_linux_386.go | 6 +- .../libcontainer/system/syscall_linux_64.go | 6 +- .../libcontainer/system/syscall_linux_arm.go | 6 +- .../runc/libcontainer/system/xattrs_linux.go | 88 +- .../runc/libcontainer/user/lookup.go | 15 - .../runc/libcontainer/user/lookup_unix.go | 16 + .../libcontainer/user/lookup_unsupported.go | 19 +- .../opencontainers/runc/vendor.conf | 10 +- .../opencontainers/runtime-spec/README.md | 12 +- .../runtime-spec/specs-go/config.go | 125 +- .../runtime-spec/specs-go/state.go | 2 +- .../runtime-spec/specs-go/version.go | 2 +- .../github.com/sirupsen/logrus/README.md | 3 +- .../github.com/sirupsen/logrus/entry.go | 1 + .../github.com/sirupsen/logrus/exported.go | 2 +- .../github.com/sirupsen/logrus/formatter.go | 2 +- .../sirupsen/logrus/json_formatter.go | 9 +- .../github.com/sirupsen/logrus/logger.go | 4 +- .../sirupsen/logrus/terminal_appengine.go | 10 - .../sirupsen/logrus/terminal_bsd.go | 6 +- .../sirupsen/logrus/terminal_linux.go | 6 +- .../sirupsen/logrus/terminal_notwindows.go | 28 - .../sirupsen/logrus/terminal_solaris.go | 21 - .../sirupsen/logrus/terminal_windows.go | 82 - .../sirupsen/logrus/text_formatter.go | 65 +- .../vendor}/golang.org/x/crypto/README.md | 0 .../x/crypto/curve25519/const_amd64.h | 0 .../x/crypto/curve25519/const_amd64.s | 20 + .../x/crypto/curve25519/cswap_amd64.s | 65 + .../x/crypto/curve25519/curve25519.go | 834 + .../golang.org/x/crypto/curve25519/doc.go | 23 + .../x/crypto/curve25519/freeze_amd64.s | 73 + .../x/crypto/curve25519/ladderstep_amd64.s | 1377 ++ .../x/crypto/curve25519/mont25519_amd64.go | 240 + .../x/crypto/curve25519/mul_amd64.s | 169 + .../x/crypto/curve25519/square_amd64.s | 132 + .../x/crypto/nacl/secretbox/secretbox.go | 2 +- .../golang.org/x/crypto/pkcs12/bmp-string.go | 2 +- .../golang.org/x/crypto/pkcs12/pkcs12.go | 4 + .../golang.org/x/crypto/poly1305/poly1305.go | 3 +- .../golang.org/x/crypto/poly1305/sum_amd64.go | 4 +- .../golang.org/x/crypto/poly1305/sum_amd64.s | 0 .../golang.org/x/crypto/poly1305/sum_arm.go | 6 +- .../golang.org/x/crypto/poly1305/sum_arm.s | 0 .../golang.org/x/crypto/poly1305/sum_ref.go | 1636 +- .../x/crypto/salsa20/salsa/salsa2020_amd64.s | 45 +- .../x/crypto/ssh/terminal/terminal.go | 951 + .../golang.org/x/crypto/ssh/terminal/util.go | 119 + .../x/crypto/ssh/terminal/util_bsd.go | 12 + .../x/crypto/ssh/terminal/util_linux.go | 10 + .../x/crypto/ssh/terminal/util_plan9.go | 58 + .../x/crypto/ssh/terminal/util_solaris.go | 0 .../x/crypto/ssh/terminal/util_windows.go | 155 + .../golang.org/x/sys/unix/asm_openbsd_arm.s | 29 + .../golang.org/x/sys/unix/cap_freebsd.go | 195 + .../vendor/golang.org/x/sys/unix/dev_linux.go | 42 + .../x/sys/unix/errors_freebsd_386.go | 227 + .../x/sys/unix/errors_freebsd_amd64.go | 227 + .../x/sys/unix/errors_freebsd_arm.go | 226 + .../vendor/golang.org/x/sys/unix/file_unix.go | 27 + .../vendor/golang.org/x/sys/unix/flock.go | 2 - .../golang.org/x/sys/unix/syscall_bsd.go | 31 +- .../golang.org/x/sys/unix/syscall_darwin.go | 65 +- .../x/sys/unix/syscall_darwin_amd64.go | 2 - .../x/sys/unix/syscall_dragonfly.go | 12 +- .../golang.org/x/sys/unix/syscall_freebsd.go | 64 +- .../golang.org/x/sys/unix/syscall_linux.go | 26 +- .../golang.org/x/sys/unix/syscall_netbsd.go | 6 +- .../golang.org/x/sys/unix/syscall_openbsd.go | 7 +- .../x/sys/unix/syscall_openbsd_arm.go | 44 + .../golang.org/x/sys/unix/syscall_solaris.go | 1 + .../x/sys/unix/zerrors_darwin_386.go | 103 +- .../x/sys/unix/zerrors_darwin_amd64.go | 103 +- .../x/sys/unix/zerrors_darwin_arm.go | 392 +- .../x/sys/unix/zerrors_darwin_arm64.go | 103 +- .../x/sys/unix/zerrors_freebsd_386.go | 2865 ++- .../x/sys/unix/zerrors_freebsd_amd64.go | 2871 ++- .../x/sys/unix/zerrors_freebsd_arm.go | 2860 ++- .../x/sys/unix/zerrors_linux_386.go | 24 + .../x/sys/unix/zerrors_linux_amd64.go | 24 + .../x/sys/unix/zerrors_linux_arm.go | 24 + .../x/sys/unix/zerrors_linux_arm64.go | 24 + .../x/sys/unix/zerrors_linux_mips.go | 24 + .../x/sys/unix/zerrors_linux_mips64.go | 24 + .../x/sys/unix/zerrors_linux_mips64le.go | 24 + .../x/sys/unix/zerrors_linux_mipsle.go | 24 + .../x/sys/unix/zerrors_linux_ppc64.go | 24 + .../x/sys/unix/zerrors_linux_ppc64le.go | 24 + .../x/sys/unix/zerrors_linux_s390x.go | 24 + .../x/sys/unix/zerrors_netbsd_arm.go | 3 + .../x/sys/unix/zerrors_openbsd_arm.go | 1586 ++ .../x/sys/unix/zsyscall_darwin_386.go | 329 +- .../x/sys/unix/zsyscall_darwin_amd64.go | 344 +- .../x/sys/unix/zsyscall_darwin_arm.go | 333 +- .../x/sys/unix/zsyscall_darwin_arm64.go | 329 +- .../x/sys/unix/zsyscall_dragonfly_amd64.go | 183 +- .../x/sys/unix/zsyscall_freebsd_386.go | 378 +- .../x/sys/unix/zsyscall_freebsd_amd64.go | 378 +- .../x/sys/unix/zsyscall_freebsd_arm.go | 378 +- .../x/sys/unix/zsyscall_linux_386.go | 26 + .../x/sys/unix/zsyscall_linux_amd64.go | 26 + .../x/sys/unix/zsyscall_linux_arm.go | 26 + .../x/sys/unix/zsyscall_linux_arm64.go | 26 + .../x/sys/unix/zsyscall_linux_mips.go | 26 + .../x/sys/unix/zsyscall_linux_mips64.go | 26 + .../x/sys/unix/zsyscall_linux_mips64le.go | 26 + .../x/sys/unix/zsyscall_linux_mipsle.go | 26 + .../x/sys/unix/zsyscall_linux_ppc64.go | 26 + .../x/sys/unix/zsyscall_linux_ppc64le.go | 26 + .../x/sys/unix/zsyscall_linux_s390x.go | 26 + .../x/sys/unix/zsyscall_netbsd_386.go | 185 +- .../x/sys/unix/zsyscall_netbsd_amd64.go | 185 +- .../x/sys/unix/zsyscall_netbsd_arm.go | 187 +- .../x/sys/unix/zsyscall_openbsd_386.go | 185 +- .../x/sys/unix/zsyscall_openbsd_amd64.go | 185 +- .../x/sys/unix/zsyscall_openbsd_arm.go | 1404 ++ .../x/sys/unix/zsyscall_solaris_amd64.go | 11 + .../x/sys/unix/zsysnum_darwin_arm.go | 110 +- .../x/sys/unix/zsysnum_darwin_arm64.go | 50 +- .../x/sys/unix/zsysnum_freebsd_386.go | 686 +- .../x/sys/unix/zsysnum_freebsd_amd64.go | 686 +- .../x/sys/unix/zsysnum_freebsd_arm.go | 686 +- .../x/sys/unix/zsysnum_netbsd_386.go | 1 + .../x/sys/unix/zsysnum_netbsd_amd64.go | 1 + .../x/sys/unix/zsysnum_netbsd_arm.go | 1 + .../x/sys/unix/zsysnum_openbsd_arm.go | 213 + .../x/sys/unix/ztypes_darwin_386.go | 19 +- .../x/sys/unix/ztypes_darwin_amd64.go | 14 +- .../x/sys/unix/ztypes_darwin_arm.go | 14 + .../x/sys/unix/ztypes_darwin_arm64.go | 14 + .../x/sys/unix/ztypes_dragonfly_amd64.go | 5 + .../x/sys/unix/ztypes_freebsd_386.go | 79 +- .../x/sys/unix/ztypes_freebsd_amd64.go | 75 +- .../x/sys/unix/ztypes_freebsd_arm.go | 87 +- .../golang.org/x/sys/unix/ztypes_linux_386.go | 16 + .../x/sys/unix/ztypes_linux_amd64.go | 16 + .../golang.org/x/sys/unix/ztypes_linux_arm.go | 16 + .../x/sys/unix/ztypes_linux_arm64.go | 16 + .../x/sys/unix/ztypes_linux_mips.go | 16 + .../x/sys/unix/ztypes_linux_mips64.go | 16 + .../x/sys/unix/ztypes_linux_mips64le.go | 16 + .../x/sys/unix/ztypes_linux_mipsle.go | 16 + .../x/sys/unix/ztypes_linux_ppc64.go | 16 + .../x/sys/unix/ztypes_linux_ppc64le.go | 16 + .../x/sys/unix/ztypes_linux_s390x.go | 16 + .../x/sys/unix/ztypes_netbsd_386.go | 5 + .../x/sys/unix/ztypes_netbsd_amd64.go | 5 + .../x/sys/unix/ztypes_netbsd_arm.go | 5 + .../x/sys/unix/ztypes_openbsd_386.go | 5 + .../x/sys/unix/ztypes_openbsd_amd64.go | 5 + .../x/sys/unix/ztypes_openbsd_arm.go | 439 + .../x/sys/windows/syscall_windows.go | 8 +- .../{ztypes_windows.go => types_windows.go} | 47 + ...es_windows_386.go => types_windows_386.go} | 0 ...indows_amd64.go => types_windows_amd64.go} | 0 .../x/sys/windows/zsyscall_windows.go | 88 +- .../docker/docker/volume/drivers/extpoint.go | 14 +- .../docker/docker/volume/lcow_parser.go | 35 + .../docker/docker/volume/linux_parser.go | 416 + .../docker/docker/volume/local/local.go | 76 +- .../github.com/docker/docker/volume/parser.go | 43 + .../docker/docker/volume/store/errors.go | 41 +- .../docker/docker/volume/store/store.go | 20 +- .../docker/docker/volume/store/store_unix.go | 4 +- .../docker/volume/store/store_windows.go | 4 +- .../docker/docker/volume/validate.go | 120 +- .../docker/docker/volume/validate_test.go | 40 +- ...ate_test_unix.go => validate_unix_test.go} | 0 ...st_windows.go => validate_windows_test.go} | 0 .../github.com/docker/docker/volume/volume.go | 154 +- .../docker/docker/volume/volume_copy.go | 4 +- .../docker/docker/volume/volume_copy_unix.go | 8 - .../docker/volume/volume_copy_windows.go | 6 - .../docker/docker/volume/volume_linux.go | 56 - .../docker/docker/volume/volume_linux_test.go | 51 - .../docker/volume/volume_propagation_linux.go | 47 - .../volume/volume_propagation_linux_test.go | 65 - .../volume/volume_propagation_unsupported.go | 24 - .../docker/docker/volume/volume_test.go | 445 +- .../docker/docker/volume/volume_unix.go | 136 +- .../docker/volume/volume_unsupported.go | 16 - .../docker/docker/volume/volume_windows.go | 199 +- .../docker/docker/volume/windows_parser.go | 456 + .../docker/libcompose/config/interpolation.go | 44 +- .../libcompose/config/interpolation_test.go | 56 + .../docker/libcompose/config/merge.go | 5 +- .../libcompose/docker/builder/builder.go | 2 + .../libcompose/docker/container/container.go | 18 +- .../libcompose/docker/service/service.go | 4 +- .../libcompose/project/options/types.go | 3 +- .../libcompose/project/project_containers.go | 5 + .../github.com/dustin/go-humanize/.travis.yml | 13 +- vendor/github.com/gin-gonic/gin/.travis.yml | 1 + vendor/github.com/gin-gonic/gin/README.md | 130 +- vendor/github.com/gin-gonic/gin/auth.go | 10 +- .../gin-gonic/gin/binding/binding.go | 11 +- .../gin/binding/default_validator.go | 5 + .../github.com/gin-gonic/gin/binding/form.go | 6 +- .../gin-gonic/gin/binding/validate_test.go | 42 + vendor/github.com/gin-gonic/gin/context.go | 50 +- vendor/github.com/gin-gonic/gin/deprecated.go | 2 +- vendor/github.com/gin-gonic/gin/errors.go | 6 +- .../gin/examples/app-engine/hello.go | 4 +- .../gin/examples/custom-validation/server.go | 45 + .../graceful-shutdown/close/server.go | 2 +- .../graceful-shutdown/server.go | 2 +- .../gin/examples/upload-file/multiple/main.go | 2 + .../gin/examples/upload-file/single/main.go | 2 + vendor/github.com/gin-gonic/gin/fs.go | 4 +- vendor/github.com/gin-gonic/gin/gin.go | 23 +- vendor/github.com/gin-gonic/gin/ginS/gins.go | 40 +- vendor/github.com/gin-gonic/gin/logger.go | 19 +- vendor/github.com/gin-gonic/gin/path.go | 4 +- vendor/github.com/gin-gonic/gin/recovery.go | 3 +- .../github.com/gin-gonic/gin/render/data.go | 2 +- .../gin-gonic/gin/response_writer.go | 6 +- .../github.com/gin-gonic/gin/routergroup.go | 18 +- .../github.com/gin-gonic/gin/routes_test.go | 26 +- vendor/github.com/gin-gonic/gin/tree.go | 2 +- vendor/github.com/gin-gonic/gin/utils.go | 2 +- .../gin-gonic/gin/vendor/vendor.json | 6 +- vendor/github.com/golang/protobuf/.gitignore | 5 +- vendor/github.com/golang/protobuf/Makefile | 7 +- vendor/github.com/golang/protobuf/README.md | 49 - .../golang/protobuf/_conformance/Makefile | 33 - .../protobuf/_conformance/conformance.go | 161 - .../conformance_proto/conformance.pb.go | 1886 -- .../conformance_proto/conformance.proto | 285 - .../golang/protobuf/descriptor/descriptor.go | 93 - .../protobuf/descriptor/descriptor_test.go | 32 - .../golang/protobuf/jsonpb/jsonpb.go | 470 +- .../golang/protobuf/jsonpb/jsonpb_test.go | 344 +- .../jsonpb/jsonpb_test_proto/Makefile | 2 +- .../jsonpb_test_proto/more_test_objects.pb.go | 136 +- .../jsonpb_test_proto/more_test_objects.proto | 11 - .../jsonpb_test_proto/test_objects.pb.go | 367 +- .../jsonpb_test_proto/test_objects.proto | 25 - .../github.com/golang/protobuf/proto/Makefile | 2 +- .../golang/protobuf/proto/all_test.go | 155 +- .../golang/protobuf/proto/any_test.go | 300 - .../github.com/golang/protobuf/proto/clone.go | 12 +- .../golang/protobuf/proto/clone_test.go | 33 - .../golang/protobuf/proto/decode.go | 133 +- .../golang/protobuf/proto/decode_test.go | 256 - .../golang/protobuf/proto/encode.go | 81 +- .../golang/protobuf/proto/encode_test.go | 83 - .../github.com/golang/protobuf/proto/equal.go | 34 +- .../golang/protobuf/proto/equal_test.go | 12 - .../golang/protobuf/proto/extensions.go | 228 +- .../golang/protobuf/proto/extensions_test.go | 108 +- .../github.com/golang/protobuf/proto/lib.go | 7 +- .../golang/protobuf/proto/map_test.go | 46 - .../golang/protobuf/proto/message_set.go | 43 +- .../golang/protobuf/proto/message_set_test.go | 8 +- .../golang/protobuf/proto/pointer_reflect.go | 7 +- .../golang/protobuf/proto/pointer_unsafe.go | 6 +- .../golang/protobuf/proto/properties.go | 64 +- .../protobuf/proto/proto3_proto/proto3.pb.go | 257 +- .../protobuf/proto/proto3_proto/proto3.proto | 19 - .../golang/protobuf/proto/proto3_test.go | 10 - .../golang/protobuf/proto/testdata/test.pb.go | 1180 +- .../golang/protobuf/proto/testdata/test.proto | 13 - .../github.com/golang/protobuf/proto/text.go | 181 +- .../golang/protobuf/proto/text_parser.go | 201 +- .../golang/protobuf/proto/text_parser_test.go | 147 +- .../protoc-gen-go/descriptor/descriptor.pb.go | 741 +- .../protoc-gen-go/generator/generator.go | 237 +- .../protoc-gen-go/generator/name_test.go | 29 - .../protoc-gen-go/{ => internal}/grpc/grpc.go | 33 +- .../protobuf/protoc-gen-go/link_grpc.go | 2 +- .../protoc-gen-go/plugin/plugin.pb.go | 55 +- .../protobuf/protoc-gen-go/testdata/Makefile | 3 +- .../protoc-gen-go/testdata/my_test/test.pb.go | 68 +- .../testdata/my_test/test.pb.go.golden | 68 +- .../protoc-gen-go/testdata/proto3.proto | 1 - .../github.com/golang/protobuf/ptypes/any.go | 136 - .../golang/protobuf/ptypes/any/any.pb.go | 155 - .../golang/protobuf/ptypes/any/any.proto | 140 - .../golang/protobuf/ptypes/any_test.go | 113 - .../github.com/golang/protobuf/ptypes/doc.go | 35 - .../golang/protobuf/ptypes/duration.go | 102 - .../protobuf/ptypes/duration/duration.pb.go | 114 - .../protobuf/ptypes/duration/duration.proto | 98 - .../golang/protobuf/ptypes/duration_test.go | 121 - .../golang/protobuf/ptypes/empty/empty.pb.go | 69 - .../golang/protobuf/ptypes/empty/empty.proto | 53 - .../golang/protobuf/ptypes/regen.sh | 66 - .../protobuf/ptypes/struct/struct.pb.go | 382 - .../protobuf/ptypes/struct/struct.proto | 96 - .../golang/protobuf/ptypes/timestamp.go | 125 - .../protobuf/ptypes/timestamp/timestamp.pb.go | 127 - .../protobuf/ptypes/timestamp/timestamp.proto | 111 - .../golang/protobuf/ptypes/timestamp_test.go | 138 - .../protobuf/ptypes/wrappers/wrappers.pb.go | 200 - .../protobuf/ptypes/wrappers/wrappers.proto | 119 - .../github.com/gopherjs/gopherjs/.gitignore | 2 - vendor/github.com/gopherjs/gopherjs/LICENSE | 24 - vendor/github.com/gopherjs/gopherjs/README.md | 140 - .../gopherjs/gopherjs/build/build.go | 779 - .../gopherjs/gopherjs/build/build_test.go | 199 - .../github.com/gopherjs/gopherjs/circle.yml | 129 - .../gopherjs/compiler/analysis/bool.go | 43 - .../gopherjs/compiler/analysis/break.go | 32 - .../gopherjs/compiler/analysis/escape.go | 70 - .../gopherjs/compiler/analysis/info.go | 254 - .../gopherjs/compiler/analysis/sideeffect.go | 37 - .../gopherjs/compiler/astutil/astutil.go | 48 - .../gopherjs/gopherjs/compiler/compiler.go | 293 - .../gopherjs/gopherjs/compiler/expressions.go | 1373 -- .../gopherjs/compiler/filter/assign.go | 106 - .../gopherjs/compiler/filter/incdecstmt.go | 39 - .../gopherjs/gopherjs/compiler/natives/doc.go | 8 - .../gopherjs/gopherjs/compiler/natives/fs.go | 29 - .../gopherjs/compiler/natives/fs_vfsdata.go | 848 - .../compiler/natives/src/bytes/bytes.go | 43 - .../compiler/natives/src/bytes/bytes_test.go | 11 - .../compiler/natives/src/crypto/rand/rand.go | 49 - .../compiler/natives/src/crypto/x509/x509.go | 14 - .../natives/src/crypto/x509/x509_test.go | 17 - .../src/database/sql/driver/driver_test.go | 32 - .../natives/src/debug/elf/elf_test.go | 9 - .../natives/src/encoding/json/stream_test.go | 9 - .../compiler/natives/src/fmt/fmt_test.go | 5 - .../natives/src/go/token/token_test.go | 11 - .../natives/src/internal/testenv/testenv.go | 26 - .../compiler/natives/src/io/io_test.go | 19 - .../compiler/natives/src/math/big/big.go | 40 - .../compiler/natives/src/math/big/big_test.go | 13 - .../compiler/natives/src/math/math.go | 238 - .../compiler/natives/src/math/math_test.go | 12 - .../natives/src/math/rand/rand_test.go | 13 - .../src/net/http/cookiejar/example_test.go | 14 - .../compiler/natives/src/net/http/fetch.go | 134 - .../compiler/natives/src/net/http/http.go | 113 - .../gopherjs/compiler/natives/src/net/net.go | 41 - .../gopherjs/compiler/natives/src/os/os.go | 32 - .../natives/src/reflect/example_test.go | 14 - .../compiler/natives/src/reflect/reflect.go | 1451 -- .../natives/src/reflect/reflect_test.go | 154 - .../compiler/natives/src/reflect/swapper.go | 29 - .../natives/src/regexp/regexp_test.go | 11 - .../natives/src/runtime/debug/debug.go | 14 - .../natives/src/runtime/pprof/pprof.go | 49 - .../compiler/natives/src/runtime/runtime.go | 201 - .../compiler/natives/src/strings/strings.go | 47 - .../natives/src/sync/atomic/atomic.go | 185 - .../natives/src/sync/atomic/atomic_test.go | 9 - .../compiler/natives/src/sync/cond.go | 41 - .../compiler/natives/src/sync/pool.go | 35 - .../compiler/natives/src/sync/sync.go | 43 - .../compiler/natives/src/sync/sync_test.go | 23 - .../compiler/natives/src/sync/waitgroup.go | 29 - .../compiler/natives/src/syscall/syscall.go | 60 - .../natives/src/syscall/syscall_unix.go | 115 - .../natives/src/syscall/syscall_windows.go | 100 - .../compiler/natives/src/testing/example.go | 70 - .../compiler/natives/src/testing/ioutil.go | 66 - .../natives/src/text/template/template.go | 3 - .../compiler/natives/src/time/time.go | 101 - .../compiler/natives/src/unicode/unicode.go | 28 - .../gopherjs/gopherjs/compiler/package.go | 801 - .../gopherjs/compiler/prelude/goroutines.go | 358 - .../gopherjs/compiler/prelude/jsmapping.go | 385 - .../gopherjs/compiler/prelude/numeric.go | 196 - .../gopherjs/compiler/prelude/prelude.go | 419 - .../gopherjs/compiler/prelude/types.go | 743 - .../gopherjs/gopherjs/compiler/statements.go | 784 - .../gopherjs/compiler/typesutil/typesutil.go | 19 - .../gopherjs/gopherjs/compiler/utils.go | 654 - .../github.com/neelance/astrewrite/LICENSE | 24 - .../neelance/astrewrite/simplify.go | 835 - .../gopherjs/compiler/vendor/vendor.json | 13 - .../gopherjs/compiler/version_check.go | 9 - .../gopherjs/gopherjs/doc/packages.md | 155 - .../gopherjs/gopherjs/doc/syscalls.md | 33 - vendor/github.com/gopherjs/gopherjs/js/js.go | 168 - .../gopherjs/gopherjs/js/js_test.go | 573 - .../gopherjs/node-syscall/binding.gyp | 8 - .../gopherjs/gopherjs/node-syscall/syscall.cc | 98 - .../gopherjs/gopherjs/nosync/mutex.go | 85 - .../gopherjs/gopherjs/nosync/once.go | 39 - .../gopherjs/gopherjs/nosync/pool.go | 63 - .../gopherjs/gopherjs/tests/alias_test.go | 77 - .../gopherjs/gopherjs/tests/copy_test.go | 133 - .../gopherjs/tests/deferblock_test.go | 42 - .../github.com/gopherjs/gopherjs/tests/doc.go | 2 - .../gopherjs/gopherjs/tests/gorepo_test.go | 24 - .../gopherjs/gopherjs/tests/goroutine_test.go | 142 - .../gopherjs/gopherjs/tests/lowlevel_test.go | 31 - .../gopherjs/gopherjs/tests/main/main.go | 7 - .../gopherjs/gopherjs/tests/main/main_test.go | 9 - .../gopherjs/gopherjs/tests/misc_test.go | 625 - .../gopherjs/tests/otherpkg/otherpkg.go | 3 - .../github.com/gopherjs/gopherjs/tests/run.go | 1189 -- .../tests/testdata/time_inexternalization.go | 19 - .../tests/testdata/time_inexternalization.out | 2 - .../tests/vendor/vendored/vendored.go | 3 - .../gopherjs/third_party/importer/export.go | 461 - .../gopherjs/third_party/importer/import.go | 453 - .../third_party/importer/predefined.go | 84 - vendor/github.com/gopherjs/gopherjs/tool.go | 925 - vendor/github.com/huandu/xstrings/convert.go | 17 +- .../huandu/xstrings/convert_test.go | 2 + .../github.com/json-iterator/go/.travis.yml | 1 + vendor/github.com/json-iterator/go/README.md | 2 + .../json-iterator/go/extra/fuzzy_decoder.go | 30 +- .../go/extra/fuzzy_decoder_test.go | 100 + .../json-iterator/go/feature_config.go | 35 +- .../json-iterator/go/feature_iter.go | 8 +- .../go/feature_iter_skip_strict.go | 2 +- .../json-iterator/go/feature_iter_string.go | 6 +- .../json-iterator/go/feature_json_number.go | 2 +- .../json-iterator/go/feature_reflect.go | 40 +- .../go/feature_reflect_extension.go | 10 +- .../go/feature_reflect_native.go | 116 +- .../go/feature_reflect_object.go | 12 +- .../go/feature_reflect_struct_decoder.go | 2 +- .../json-iterator/go/feature_stream_string.go | 2 + .../json-iterator/go/jsoniter_bool_test.go | 29 + .../go/jsoniter_customize_test.go | 62 +- .../go/jsoniter_enum_marshaler_test.go | 50 + .../json-iterator/go/jsoniter_int_test.go | 40 +- .../go/jsoniter_interface_test.go | 263 +- .../json-iterator/go/jsoniter_invalid_test.go | 32 + .../json-iterator/go/jsoniter_null_test.go | 33 +- .../go/jsoniter_raw_message_test.go | 14 + .../go/jsoniter_struct_decoder_test.go | 2 +- .../go/jsoniter_struct_encoder_test.go | 52 + .../output_tests/builtins/int64/json_test.go | 152 + .../go/output_tests/builtins/int64/types.go | 3 + .../map/int64/string/json_test.go | 152 + .../go/output_tests/map/int64/string/types.go | 3 + .../go/output_tests/slice/int64/json_test.go | 152 + .../go/output_tests/slice/int64/types.go | 3 + .../output_tests/struct/everything/types.go | 2 + .../go/output_tests/struct/int64/json_test.go | 152 + .../go/output_tests/struct/int64/types.go | 5 + vendor/github.com/jtolds/gls/context.go | 121 +- vendor/github.com/jtolds/gls/context_test.go | 46 +- vendor/github.com/jtolds/gls/gen_sym.go | 14 +- vendor/github.com/jtolds/gls/gid.go | 25 - vendor/github.com/jtolds/gls/stack_tags.go | 148 +- vendor/github.com/jtolds/gls/stack_tags_js.go | 75 - .../github.com/jtolds/gls/stack_tags_main.go | 30 - .../github.com/mattn/go-colorable/.travis.yml | 9 - .../github.com/mattn/go-colorable/README.md | 48 - .../go-colorable/_example/escape-seq/main.go | 16 - .../go-colorable/_example/logrus/main.go | 16 - .../mattn/go-colorable/_example/title/main.go | 14 - .../go-colorable/cmd/colorable/colorable.go | 12 - .../mattn/go-colorable/colorable_appengine.go | 29 - .../mattn/go-colorable/colorable_others.go | 30 - .../mattn/go-colorable/colorable_test.go | 83 - .../mattn/go-colorable/colorable_windows.go | 914 - .../mattn/go-colorable/noncolorable.go | 55 - .../mattn/{go-colorable => go-zglob}/LICENSE | 2 +- vendor/github.com/mgutz/ansi/README.md | 28 +- vendor/github.com/mgutz/ansi/ansi.go | 53 +- vendor/github.com/mgutz/ansi/ansi_test.go | 58 +- .../mgutz/ansi/cmd/ansi-mgutz/main.go | 4 +- vendor/github.com/mgutz/ansi/print.go | 33 +- vendor/github.com/shirou/gopsutil/README.rst | 2 +- .../shirou/gopsutil/cpu/cpu_linux_test.go | 40 + .../gopsutil/cpu/testdata/linux/424/proc/stat | 12 + .../cpu/testdata/linux/times_empty/proc/stat | 0 .../shirou/gopsutil/host/host_linux_mips.go | 43 + .../shirou/gopsutil/host/host_linux_mipsle.go | 43 + .../shirou/gopsutil/internal/common/common.go | 16 + .../gopsutil/internal/common/common_darwin.go | 9 +- .../internal/common/common_freebsd.go | 8 +- .../gopsutil/internal/common/common_linux.go | 8 +- .../internal/common/common_openbsd.go | 8 +- .../gopsutil/internal/common/common_test.go | 32 + .../shirou/gopsutil/process/process.go | 25 +- .../shirou/gopsutil/process/process_darwin.go | 4 + .../gopsutil/process/process_fallback.go | 3 + .../gopsutil/process/process_freebsd.go | 4 + .../shirou/gopsutil/process/process_linux.go | 145 +- .../gopsutil/process/process_openbsd.go | 4 + .../gopsutil/process/process_windows.go | 5 + .../smartystreets/assertions/.gitignore | 3 - .../smartystreets/assertions/.travis.yml | 6 +- .../smartystreets/assertions/CONTRIBUTING.md | 12 - .../smartystreets/assertions/LICENSE.md | 2 +- .../smartystreets/assertions/README.md | 29 +- .../assertions/assertions.goconvey | 3 + .../smartystreets/assertions/collections.go | 32 +- .../assertions/collections_test.go | 236 +- .../smartystreets/assertions/doc.go | 12 +- .../smartystreets/assertions/doc_test.go | 17 - .../smartystreets/assertions/equal_method.go | 79 - .../assertions/equal_method_test.go | 151 - .../smartystreets/assertions/equality.go | 46 +- .../smartystreets/assertions/equality_test.go | 342 +- .../smartystreets/assertions/filter.go | 8 - .../assertions/internal/Makefile | 30 +- .../assertions/internal/go-render/.travis.yml | 21 - .../assertions/internal/go-render/LICENSE | 27 - .../internal/go-render/PRESUBMIT.py | 109 - .../assertions/internal/go-render/README.md | 78 - .../assertions/internal/go-render/WATCHLISTS | 26 - .../internal/go-render/pre-commit-go.yml | 78 - .../internal/go-render/render/render.go | 477 - .../internal/oglematchers/all_of.go | 70 + .../internal/oglematchers/all_of_test.go | 110 + .../assertions/internal/oglematchers/any.go | 32 + .../internal/oglematchers/any_of_test.go | 139 + .../internal/oglematchers/any_test.go | 53 + .../internal/oglematchers/contains.go | 2 +- .../internal/oglematchers/contains_test.go | 233 + .../internal/oglematchers/deep_equals_test.go | 343 + .../internal/oglematchers/elements_are.go | 91 + .../oglematchers/elements_are_test.go | 208 + .../internal/oglematchers/equals_test.go | 3864 ++++ .../assertions/internal/oglematchers/error.go | 51 + .../internal/oglematchers/error_test.go | 92 + .../oglematchers/greater_or_equal_test.go | 1101 ++ .../oglematchers/greater_than_test.go | 1077 ++ .../internal/oglematchers/has_same_type_as.go | 37 + .../oglematchers/has_same_type_as_test.go | 181 + .../internal/oglematchers/has_substr.go | 46 + .../internal/oglematchers/has_substr_test.go | 93 + .../internal/oglematchers/identical_to.go | 134 + .../oglematchers/identical_to_test.go | 849 + .../oglematchers/less_or_equal_test.go | 1077 ++ .../internal/oglematchers/less_than_test.go | 1057 ++ .../internal/oglematchers/matches_regexp.go | 69 + .../oglematchers/matches_regexp_test.go | 92 + .../internal/oglematchers/new_matcher.go | 43 + .../internal/oglematchers/not_test.go | 108 + .../internal/oglematchers/panics.go | 74 + .../internal/oglematchers/panics_test.go | 141 + .../internal/oglematchers/pointee.go | 65 + .../internal/oglematchers/pointee_test.go | 152 + .../oglematchers/transform_description.go | 2 +- .../assertions/internal/oglemock/.gitignore | 5 + .../assertions/internal/oglemock/.travis.yml | 4 + .../assertions/internal/oglemock/LICENSE | 202 + .../assertions/internal/oglemock/README.md | 103 + .../assertions/internal/oglemock/action.go | 36 + .../internal/oglemock/controller.go | 480 + .../internal/oglemock/controller_test.go | 1249 ++ .../oglemock/createmock/createmock.go | 226 + .../oglemock/createmock/createmock_test.go | 215 + .../test_cases/golden.no_interfaces | 1 + .../createmock/test_cases/golden.no_package | 1 + .../test_cases/golden.unknown_interface | 1 + .../test_cases/golden.unknown_package | 1 + .../assertions/internal/oglemock/do_all.go | 53 + .../internal/oglemock/do_all_test.go | 90 + .../internal/oglemock/error_reporter.go | 29 + .../internal/oglemock/expectation.go | 59 + .../internal/oglemock/generate/generate.go | 329 + .../oglemock/generate/generate_test.go | 153 + .../complicated_pkg/complicated_pkg.go | 40 + .../test_cases/golden.complicated_pkg.go | 311 + .../generate/test_cases/golden.image.go | 238 + .../test_cases/golden.io_reader_writer.go | 127 + .../generate/test_cases/golden.renamed_pkg.go | 66 + .../test_cases/renamed_pkg/renamed_pkg.go | 24 + .../internal/oglemock/integration_test.go | 129 + .../internal/oglemock/internal_expectation.go | 180 + .../oglemock/internal_expectation_test.go | 265 + .../assertions/internal/oglemock/invoke.go | 73 + .../internal/oglemock/invoke_test.go | 110 + .../internal/oglemock/mock_object.go | 30 + .../assertions/internal/oglemock/return.go | 251 + .../internal/oglemock/return_test.go | 978 + .../internal/oglemock/sample/README.markdown | 6 + .../oglemock/sample/mock_io/mock_io.go | 71 + .../assertions/internal/oglemock/save_arg.go | 83 + .../internal/oglemock/save_arg_test.go | 132 + .../assertions/internal/ogletest/.gitignore | 5 + .../assertions/internal/ogletest/.travis.yml | 4 + .../assertions/internal/ogletest/LICENSE | 202 + .../assertions/internal/ogletest/README.md | 151 + .../internal/ogletest/assert_aliases.go | 70 + .../internal/ogletest/assert_that.go | 46 + .../assertions/internal/ogletest/doc.go | 51 + .../internal/ogletest/expect_aliases.go | 64 + .../internal/ogletest/expect_call.go | 59 + .../internal/ogletest/expect_that.go | 100 + .../internal/ogletest/expect_that_test.go | 168 + .../assertions/internal/ogletest/failure.go | 90 + .../internal/ogletest/integration_test.go | 265 + .../assertions/internal/ogletest/register.go | 86 + .../internal/ogletest/register_test_suite.go | 193 + .../assertions/internal/ogletest/run_tests.go | 354 + .../internal/ogletest/srcutil/docs.go | 5 + .../internal/ogletest/srcutil/methods.go | 65 + .../internal/ogletest/srcutil/methods_test.go | 107 + .../ogletest/test_cases/failing.test.go | 252 + .../ogletest/test_cases/filtered.test.go | 79 + .../ogletest/test_cases/golden.failing_test | 278 + .../ogletest/test_cases/golden.filtered_test | 24 + .../ogletest/test_cases/golden.mock_test | 25 + .../ogletest/test_cases/golden.no_cases_test | 6 + .../ogletest/test_cases/golden.panicking_test | 90 + .../ogletest/test_cases/golden.passing_test | 22 + .../ogletest/test_cases/golden.run_twice_test | 14 + .../ogletest/test_cases/golden.stop_test | 13 + .../test_cases/golden.unexported_test | 12 + .../internal/ogletest/test_cases/mock.test.go | 82 + .../test_cases/mock_image/mock_image.go | 115 + .../ogletest/test_cases/no_cases.test.go | 41 + .../ogletest/test_cases/panicking.test.go | 99 + .../ogletest/test_cases/passing.test.go | 120 + .../ogletest/test_cases/run_twice.test.go | 47 + .../internal/ogletest/test_cases/stop.test.go | 61 + .../ogletest/test_cases/unexported.test.go | 43 + .../assertions/internal/ogletest/test_info.go | 91 + .../assertions/internal/reqtrace/.gitignore | 24 + .../assertions/internal/reqtrace/LICENSE | 202 + .../assertions/internal/reqtrace/README.md | 53 + .../assertions/internal/reqtrace/reqtrace.go | 132 + .../internal/reqtrace/trace_state.go | 175 + .../smartystreets/assertions/messages.go | 8 +- .../smartystreets/assertions/panic_test.go | 67 +- .../smartystreets/assertions/quantity.go | 2 +- .../smartystreets/assertions/quantity_test.go | 214 +- .../smartystreets/assertions/serializer.go | 42 +- .../assertions/serializer_test.go | 24 +- .../smartystreets/assertions/should/should.go | 2 - .../smartystreets/assertions/strings_test.go | 148 +- .../smartystreets/assertions/time_test.go | 195 +- .../smartystreets/assertions/type.go | 34 +- .../smartystreets/assertions/type_test.go | 98 +- .../assertions/utilities_for_test.go | 65 +- .../smartystreets/goconvey/.gitattributes | 1 - .../smartystreets/goconvey/.travis.yml | 12 +- .../smartystreets/goconvey/CONTRIBUTING.md | 17 +- .../smartystreets/goconvey/LICENSE.md | 2 +- .../smartystreets/goconvey/README.md | 6 +- .../goconvey/convey/assertions.go | 2 - .../smartystreets/goconvey/convey/init.go | 17 +- .../goconvey/convey/reporting/init.go | 11 +- .../goconvey/convey/reporting/problems.go | 16 +- .../goconvey/convey/reporting/reports.go | 8 +- .../goconvey/convey/reporting/statistics.go | 39 +- .../smartystreets/goconvey/doc_test.go | 1 + .../smartystreets/goconvey/goconvey.go | 70 +- .../goconvey/web/client/composer.html | 6 +- .../goconvey/web/client/index.html | 51 +- .../web/client/resources/css/common.css | 8 +- .../client/resources/css/font-awesome.min.css | 5 + .../web/client/resources/css/themes/dark.css | 8 +- .../fonts/FontAwesome/FontAwesome.otf | Bin 0 -> 75188 bytes .../resources/fonts/FontAwesome/README.md | 100 - .../fonts/FontAwesome/css/font-awesome.css | 2086 --- .../fonts/FontAwesome/fontawesome-webfont.eot | Bin 0 -> 72449 bytes .../fonts/FontAwesome/fontawesome-webfont.svg | 504 + .../fonts/FontAwesome/fontawesome-webfont.ttf | Bin 0 -> 141564 bytes .../FontAwesome/fontawesome-webfont.woff | Bin 0 -> 83760 bytes .../fonts/FontAwesome/fonts/FontAwesome.otf | Bin 109688 -> 0 bytes .../FontAwesome/fonts/fontawesome-webfont.eot | Bin 70807 -> 0 bytes .../FontAwesome/fonts/fontawesome-webfont.svg | 655 - .../FontAwesome/fonts/fontawesome-webfont.ttf | Bin 142072 -> 0 bytes .../fonts/fontawesome-webfont.woff | Bin 83588 -> 0 bytes .../fonts/fontawesome-webfont.woff2 | Bin 66624 -> 0 bytes .../web/client/resources/js/composer.js | 24 +- .../web/client/resources/js/config.js | 4 +- .../web/client/resources/js/convey.js | 2 +- .../web/client/resources/js/goconvey.js | 231 +- .../resources/js/lib/diff-match-patch.min.js | 49 + .../resources/js/lib/diff_match_patch.js | 2193 --- .../resources/js/lib/jquery-2_1_0.min.js | 4 + .../js/lib/jquery-ui-1_10_3-custom.min.js | 5 + .../web/client/resources/js/lib/jquery-ui.js | 15008 --------------- .../client/resources/js/lib/jquery-ui.js.url | 1 - .../web/client/resources/js/lib/jquery.js | 9111 --------- .../web/client/resources/js/lib/jquery.js.url | 1 - .../js/lib/jquery.pretty-text-diff.js | 72 - .../js/lib/jquery.pretty-text-diff.js.url | 1 - .../js/lib/jquery.pretty-text-diff.min.js | 5 + .../client/resources/js/lib/jquery.tipsy.js | 194 - .../resources/js/lib/jquery.tipsy.js.url | 1 - .../resources/js/lib/jquery.tipsy.min.js | 5 + .../web/client/resources/js/lib/markup.js | 483 - .../web/client/resources/js/lib/markup.js.url | 1 - .../web/client/resources/js/lib/markup.min.js | 6 + .../web/client/resources/js/lib/moment.js | 3083 --- .../web/client/resources/js/lib/moment.js.url | 1 - .../web/client/resources/js/lib/moment.min.js | 6 + .../client/resources/js/lib/taboverride.js | 802 - .../resources/js/lib/taboverride.js.url | 1 - .../resources/js/lib/taboverride.min.js | 3 + .../web/client/resources/js/poller.js | 6 +- .../web/server/parser/packageParser.go | 1 - .../web/server/parser/package_parser_test.go | 86 - .../goconvey/web/server/system/shell.go | 4 +- .../goconvey/web/server/system/shell_test.go | 4 +- .../web/server/watch/imperative_shell.go | 14 +- .../goconvey/web/server/watch/integration.go | 6 +- .../web/server/watch/integration_test.go | 3 +- .../smartystreets/logging/.gitignore | 1 - .../smartystreets/logging/CONTRIBUTING.md | 12 - .../smartystreets/logging/LICENSE.md | 23 - .../smartystreets/logging/README.md | 143 - .../smartystreets/logging/logging.go | 206 - .../smartystreets/logging/logging_test.go | 73 - vendor/github.com/ugorji/go/codec/0doc.go | 34 +- vendor/github.com/ugorji/go/codec/README.md | 40 +- vendor/github.com/ugorji/go/codec/binc.go | 15 +- vendor/github.com/ugorji/go/codec/cbor.go | 12 +- .../github.com/ugorji/go/codec/codec_test.go | 327 +- .../ugorji/go/codec/codecgen/gen.go | 12 +- vendor/github.com/ugorji/go/codec/decode.go | 795 +- vendor/github.com/ugorji/go/codec/encode.go | 40 +- .../ugorji/go/codec/fast-path.generated.go | 15487 ++++++---------- .../ugorji/go/codec/fast-path.go.tmpl | 192 +- .../ugorji/go/codec/gen-dec-array.go.tmpl | 96 +- .../ugorji/go/codec/gen-dec-map.go.tmpl | 27 +- .../ugorji/go/codec/gen-helper.generated.go | 22 +- .../ugorji/go/codec/gen-helper.go.tmpl | 21 +- .../ugorji/go/codec/gen.generated.go | 123 +- vendor/github.com/ugorji/go/codec/gen.go | 111 +- ...de_go.go => goversion_arrayof_gte_go15.go} | 6 +- ...e_go14.go => goversion_arrayof_lt_go15.go} | 4 +- .../go/codec/goversion_makemap_gte_go19.go | 15 + .../go/codec/goversion_makemap_lt_go19.go | 12 + .../go/codec/goversion_unsupported_lt_go14.go | 17 + ...{gen_15.go => goversion_vendor_eq_go15.go} | 4 +- ...{gen_16.go => goversion_vendor_eq_go16.go} | 6 +- ...gen_17.go => goversion_vendor_gte_go17.go} | 4 +- .../go/codec/goversion_vendor_lt_go15.go | 8 + vendor/github.com/ugorji/go/codec/helper.go | 200 +- .../ugorji/go/codec/helper_internal.go | 21 - .../ugorji/go/codec/helper_not_unsafe.go | 125 +- .../ugorji/go/codec/helper_unsafe.go | 421 +- vendor/github.com/ugorji/go/codec/json.go | 705 +- .../ugorji/go/codec/mammoth-test.go.tmpl | 33 + .../ugorji/go/codec/mammoth_generated_test.go | 593 + vendor/github.com/ugorji/go/codec/msgpack.go | 17 +- vendor/github.com/ugorji/go/codec/noop.go | 5 +- vendor/github.com/ugorji/go/codec/prebuild.go | 3 - vendor/github.com/ugorji/go/codec/prebuild.sh | 205 - .../github.com/ugorji/go/codec/shared_test.go | 14 +- vendor/github.com/ugorji/go/codec/simple.go | 12 +- vendor/github.com/ugorji/go/codec/test.py | 6 +- vendor/github.com/ugorji/go/codec/tests.sh | 107 - vendor/github.com/ugorji/go/codec/time.go | 15 +- .../github.com/ugorji/go/codec/values_test.go | 13 +- vendor/github.com/ugorji/go/codec/xml.go | 426 + .../github.com/ugorji/go/codec/z_all_test.go | 135 + vendor/golang.org/x/crypto/AUTHORS | 2 +- vendor/golang.org/x/crypto/CONTRIBUTORS | 2 +- .../vendor => }/golang.org/x/crypto/README | 0 vendor/golang.org/x/crypto/acme/acme.go | 1054 -- vendor/golang.org/x/crypto/acme/acme_test.go | 1346 -- .../x/crypto/acme/autocert/autocert.go | 819 - .../x/crypto/acme/autocert/autocert_test.go | 606 - .../x/crypto/acme/autocert/cache.go | 130 - .../x/crypto/acme/autocert/cache_test.go | 58 - .../x/crypto/acme/autocert/example_test.go | 34 - .../x/crypto/acme/autocert/listener.go | 160 - .../x/crypto/acme/autocert/renewal.go | 124 - .../x/crypto/acme/autocert/renewal_test.go | 191 - .../x/crypto/acme/internal/acme/acme.go | 473 + .../x/crypto/acme/internal/acme/acme_test.go | 759 + .../x/crypto/acme/internal/acme/jws.go | 67 + .../x/crypto/acme/internal/acme/jws_test.go | 139 + .../crypto/acme/{ => internal/acme}/types.go | 186 +- vendor/golang.org/x/crypto/acme/jws.go | 153 - vendor/golang.org/x/crypto/acme/jws_test.go | 319 - vendor/golang.org/x/crypto/acme/types_test.go | 63 - vendor/golang.org/x/crypto/bcrypt/bcrypt.go | 7 +- .../golang.org/x/crypto/bcrypt/bcrypt_test.go | 17 - vendor/golang.org/x/crypto/blake2b/blake2b.go | 207 - .../x/crypto/blake2b/blake2bAVX2_amd64.go | 43 - .../x/crypto/blake2b/blake2bAVX2_amd64.s | 762 - .../x/crypto/blake2b/blake2b_amd64.go | 25 - .../x/crypto/blake2b/blake2b_amd64.s | 290 - .../x/crypto/blake2b/blake2b_generic.go | 179 - .../x/crypto/blake2b/blake2b_ref.go | 11 - .../x/crypto/blake2b/blake2b_test.go | 798 - vendor/golang.org/x/crypto/blake2b/blake2x.go | 177 - .../golang.org/x/crypto/blake2b/register.go | 32 - vendor/golang.org/x/crypto/blake2s/blake2s.go | 187 - .../x/crypto/blake2s/blake2s_386.go | 35 - .../golang.org/x/crypto/blake2s/blake2s_386.s | 460 - .../x/crypto/blake2s/blake2s_amd64.go | 40 - .../x/crypto/blake2s/blake2s_amd64.s | 463 - .../x/crypto/blake2s/blake2s_generic.go | 174 - .../x/crypto/blake2s/blake2s_ref.go | 17 - .../x/crypto/blake2s/blake2s_test.go | 1002 - vendor/golang.org/x/crypto/blake2s/blake2x.go | 178 - .../golang.org/x/crypto/blake2s/register.go | 21 - .../x/crypto/blowfish/blowfish_test.go | 2 +- vendor/golang.org/x/crypto/blowfish/cipher.go | 4 +- vendor/golang.org/x/crypto/blowfish/const.go | 2 +- vendor/golang.org/x/crypto/bn256/constants.go | 4 +- .../chacha20poly1305/chacha20poly1305.go | 83 - .../chacha20poly1305_amd64.go | 127 - .../chacha20poly1305/chacha20poly1305_amd64.s | 2714 --- .../chacha20poly1305_generic.go | 70 - .../chacha20poly1305_noasm.go | 15 - .../chacha20poly1305/chacha20poly1305_test.go | 182 - .../chacha20poly1305_vectors_test.go | 332 - .../internal/chacha20/chacha_generic.go | 199 - .../internal/chacha20/chacha_test.go | 33 - vendor/golang.org/x/crypto/cryptobyte/asn1.go | 604 - .../x/crypto/cryptobyte/asn1_test.go | 285 - .../golang.org/x/crypto/cryptobyte/builder.go | 255 - .../x/crypto/cryptobyte/cryptobyte_test.go | 379 - .../x/crypto/cryptobyte/example_test.go | 120 - .../golang.org/x/crypto/cryptobyte/string.go | 157 - .../x/crypto/curve25519/const_amd64.s | 6 +- .../x/crypto/curve25519/cswap_amd64.s | 131 +- .../x/crypto/curve25519/curve25519.go | 23 +- .../x/crypto/curve25519/curve25519_test.go | 10 - vendor/golang.org/x/crypto/curve25519/doc.go | 2 +- .../x/crypto/curve25519/freeze_amd64.s | 31 +- .../x/crypto/curve25519/ladderstep_amd64.s | 687 +- .../x/crypto/curve25519/mul_amd64.s | 46 +- .../x/crypto/curve25519/square_amd64.s | 31 +- vendor/golang.org/x/crypto/ed25519/ed25519.go | 6 +- .../x/crypto/ed25519/ed25519_test.go | 2 +- .../golang.org/x/crypto/md4/example_test.go | 20 - vendor/golang.org/x/crypto/nacl/box/box.go | 5 +- .../x/crypto/nacl/box/example_test.go | 95 - .../x/crypto/nacl/secretbox/example_test.go | 53 - .../x/crypto/nacl/secretbox/secretbox.go | 2 +- .../x/crypto/nacl/secretbox/secretbox_test.go | 63 - vendor/golang.org/x/crypto/ocsp/ocsp.go | 229 +- vendor/golang.org/x/crypto/ocsp/ocsp_test.go | 373 +- vendor/golang.org/x/crypto/openpgp/keys.go | 8 +- .../golang.org/x/crypto/openpgp/keys_test.go | 34 - .../x/crypto/openpgp/packet/packet.go | 2 + .../x/crypto/openpgp/packet/private_key.go | 20 +- .../crypto/openpgp/packet/private_key_test.go | 144 - .../x/crypto/openpgp/packet/public_key.go | 2 + .../x/crypto/openpgp/packet/public_key_v3.go | 1 + .../x/crypto/openpgp/packet/signature.go | 33 +- .../x/crypto/openpgp/packet/signature_test.go | 36 - .../openpgp/packet/symmetric_key_encrypted.go | 6 +- .../packet/symmetric_key_encrypted_test.go | 82 +- vendor/golang.org/x/crypto/openpgp/read.go | 2 +- vendor/golang.org/x/crypto/openpgp/write.go | 2 +- .../golang.org/x/crypto/openpgp/write_test.go | 4 +- vendor/golang.org/x/crypto/otr/otr.go | 7 - .../golang.org/x/crypto/pkcs12/bmp-string.go | 2 +- vendor/golang.org/x/crypto/pkcs12/pkcs12.go | 4 - .../x/crypto/poly1305/const_amd64.s | 0 .../golang.org/x/crypto/poly1305/poly1305.go | 3 +- .../x/crypto/poly1305/poly1305_amd64.s | 0 .../x/crypto/poly1305/poly1305_arm.s | 0 .../x/crypto/poly1305/poly1305_test.go | 73 - .../golang.org/x/crypto/poly1305/sum_amd64.go | 4 +- .../golang.org/x/crypto/poly1305/sum_arm.go | 6 +- .../golang.org/x/crypto/poly1305/sum_ref.go | 1636 +- .../x/crypto/salsa20/salsa/salsa2020_amd64.s | 45 +- .../x/crypto/salsa20/salsa/salsa20_amd64.go | 1 - .../x/crypto/salsa20/salsa/salsa_test.go | 19 - vendor/golang.org/x/crypto/salsa20/salsa20.go | 6 +- vendor/golang.org/x/crypto/scrypt/scrypt.go | 4 +- vendor/golang.org/x/crypto/sha3/keccakf.go | 2 - .../golang.org/x/crypto/sha3/keccakf_amd64.go | 13 - .../golang.org/x/crypto/sha3/keccakf_amd64.s | 390 - vendor/golang.org/x/crypto/sha3/sha3.go | 2 +- vendor/golang.org/x/crypto/sha3/sha3_test.go | 5 - .../golang.org/x/crypto/ssh/agent/client.go | 71 +- .../x/crypto/ssh/agent/client_test.go | 79 +- .../x/crypto/ssh/agent/example_test.go | 15 +- .../golang.org/x/crypto/ssh/agent/keyring.go | 53 +- .../x/crypto/ssh/agent/keyring_test.go | 4 +- .../golang.org/x/crypto/ssh/agent/server.go | 117 +- .../x/crypto/ssh/agent/server_test.go | 75 +- .../x/crypto/ssh/agent/testdata_test.go | 2 +- vendor/golang.org/x/crypto/ssh/certs.go | 36 +- vendor/golang.org/x/crypto/ssh/certs_test.go | 30 +- vendor/golang.org/x/crypto/ssh/channel.go | 6 +- vendor/golang.org/x/crypto/ssh/cipher.go | 66 +- vendor/golang.org/x/crypto/ssh/cipher_test.go | 70 +- vendor/golang.org/x/crypto/ssh/client.go | 62 +- vendor/golang.org/x/crypto/ssh/client_auth.go | 83 +- .../x/crypto/ssh/client_auth_test.go | 275 +- vendor/golang.org/x/crypto/ssh/client_test.go | 42 - vendor/golang.org/x/crypto/ssh/common.go | 33 +- vendor/golang.org/x/crypto/ssh/connection.go | 3 +- vendor/golang.org/x/crypto/ssh/doc.go | 3 - .../golang.org/x/crypto/ssh/example_test.go | 137 +- vendor/golang.org/x/crypto/ssh/handshake.go | 461 +- .../golang.org/x/crypto/ssh/handshake_test.go | 447 +- vendor/golang.org/x/crypto/ssh/kex.go | 38 +- vendor/golang.org/x/crypto/ssh/keys.go | 206 +- vendor/golang.org/x/crypto/ssh/keys_test.go | 80 +- .../x/crypto/ssh/knownhosts/knownhosts.go | 546 - .../crypto/ssh/knownhosts/knownhosts_test.go | 329 - vendor/golang.org/x/crypto/ssh/mac.go | 10 +- vendor/golang.org/x/crypto/ssh/mux.go | 4 +- vendor/golang.org/x/crypto/ssh/mux_test.go | 3 - vendor/golang.org/x/crypto/ssh/server.go | 142 +- vendor/golang.org/x/crypto/ssh/session.go | 53 +- .../golang.org/x/crypto/ssh/session_test.go | 18 +- vendor/golang.org/x/crypto/ssh/streamlocal.go | 115 - vendor/golang.org/x/crypto/ssh/tcpip.go | 198 +- .../x/crypto/ssh/terminal/terminal.go | 73 +- .../x/crypto/ssh/terminal/terminal_test.go | 59 - .../golang.org/x/crypto/ssh/terminal/util.go | 47 +- .../x/crypto/ssh/terminal/util_bsd.go | 6 +- .../x/crypto/ssh/terminal/util_linux.go | 9 +- .../x/crypto/ssh/terminal/util_windows.go | 132 +- .../golang.org/x/crypto/ssh/test/cert_test.go | 38 +- .../x/crypto/ssh/test/dial_unix_test.go | 128 - .../x/crypto/ssh/test/forward_unix_test.go | 62 +- .../x/crypto/ssh/test/session_test.go | 54 +- .../x/crypto/ssh/test/tcpip_test.go | 46 + .../x/crypto/ssh/test/test_unix_test.go | 29 +- .../x/crypto/ssh/test/testdata_test.go | 2 +- .../golang.org/x/crypto/ssh/testdata/keys.go | 120 - .../golang.org/x/crypto/ssh/testdata_test.go | 2 +- vendor/golang.org/x/crypto/ssh/transport.go | 50 +- vendor/golang.org/x/crypto/twofish/twofish.go | 2 +- .../x/crypto/twofish/twofish_test.go | 2 +- vendor/golang.org/x/crypto/xts/xts.go | 39 +- vendor/golang.org/x/crypto/xts/xts_test.go | 20 - .../go-playground/validator.v8/README.md | 70 +- .../go-playground/validator.v8/baked_in.go | 216 +- .../go-playground/validator.v8/cache.go | 280 +- .../go-playground/validator.v8/doc.go | 68 +- .../go-playground/validator.v8/util.go | 190 +- .../go-playground/validator.v8/validator.go | 447 +- .../validator.v8/validator_test.go | 527 +- vendor/gopkg.in/yaml.v2/LICENSE | 208 +- 1760 files changed, 90199 insertions(+), 126042 deletions(-) delete mode 100644 vendor/github.com/aokoli/goutils/.travis.yml delete mode 100644 vendor/github.com/aokoli/goutils/CHANGELOG.md delete mode 100644 vendor/github.com/aokoli/goutils/appveyor.yml create mode 100644 vendor/github.com/docker/docker/Dockerfile.e2e create mode 100644 vendor/github.com/docker/docker/TESTING.md delete mode 100644 vendor/github.com/docker/docker/api/common_test.go create mode 100644 vendor/github.com/docker/docker/api/errdefs/defs.go create mode 100644 vendor/github.com/docker/docker/api/errdefs/doc.go create mode 100644 vendor/github.com/docker/docker/api/errdefs/is.go delete mode 100644 vendor/github.com/docker/docker/api/errors/errors.go delete mode 100644 vendor/github.com/docker/docker/api/errors/errors_test.go create mode 100644 vendor/github.com/docker/docker/api/types/filters/example_test.go create mode 100644 vendor/github.com/docker/docker/builder/dockerfile/errors.go delete mode 100644 vendor/github.com/docker/docker/builder/dockerfile/evaluator_unix.go delete mode 100644 vendor/github.com/docker/docker/builder/dockerfile/evaluator_windows.go rename vendor/github.com/docker/docker/builder/dockerfile/{ => instructions}/bflag.go (99%) rename vendor/github.com/docker/docker/builder/dockerfile/{ => instructions}/bflag_test.go (96%) create mode 100644 vendor/github.com/docker/docker/builder/dockerfile/instructions/commands.go create mode 100644 vendor/github.com/docker/docker/builder/dockerfile/instructions/errors_unix.go create mode 100644 vendor/github.com/docker/docker/builder/dockerfile/instructions/errors_windows.go create mode 100644 vendor/github.com/docker/docker/builder/dockerfile/instructions/parse.go create mode 100644 vendor/github.com/docker/docker/builder/dockerfile/instructions/parse_test.go rename vendor/github.com/docker/docker/builder/dockerfile/{ => instructions}/support.go (96%) rename vendor/github.com/docker/docker/builder/dockerfile/{ => instructions}/support_test.go (98%) delete mode 100644 vendor/github.com/docker/docker/builder/dockerfile/internals_unix.go delete mode 100644 vendor/github.com/docker/docker/builder/dockerfile/internals_windows.go create mode 100644 vendor/github.com/docker/docker/builder/remotecontext/errors.go delete mode 100644 vendor/github.com/docker/docker/client/parse_logs.go delete mode 100644 vendor/github.com/docker/docker/client/parse_logs_test.go create mode 100644 vendor/github.com/docker/docker/client/tlsconfig_clone.go rename vendor/github.com/docker/docker/{pkg/tlsconfig => client}/tlsconfig_clone_go17.go (89%) create mode 100644 vendor/github.com/docker/docker/daemon/cluster/errors.go create mode 100644 vendor/github.com/docker/docker/daemon/config/opts.go create mode 100644 vendor/github.com/docker/docker/daemon/graphdriver/lcow/lcow_svm.go create mode 100644 vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs.go create mode 100644 vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs_file.go create mode 100644 vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs_filedriver.go create mode 100644 vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs_pathdriver.go rename vendor/github.com/docker/docker/{pkg => daemon}/listeners/group_unix.go (100%) rename vendor/github.com/docker/docker/{pkg => daemon}/listeners/listeners_solaris.go (100%) rename vendor/github.com/docker/docker/{pkg => daemon}/listeners/listeners_unix.go (98%) rename vendor/github.com/docker/docker/{pkg => daemon}/listeners/listeners_windows.go (100%) rename vendor/github.com/docker/docker/{pkg => daemon/logger}/templates/templates.go (65%) create mode 100644 vendor/github.com/docker/docker/daemon/logger/templates/templates_test.go rename vendor/github.com/docker/docker/{api => daemon/names}/names.go (96%) rename vendor/github.com/docker/docker/{api/fixtures => daemon/testdata}/keyfile (100%) create mode 100644 vendor/github.com/docker/docker/daemon/trustkey.go create mode 100644 vendor/github.com/docker/docker/daemon/trustkey_test.go mode change 100644 => 100755 vendor/github.com/docker/docker/hack/make/build-integration-test-binary create mode 100755 vendor/github.com/docker/docker/hack/make/test-integration create mode 100755 vendor/github.com/docker/docker/hack/test/e2e-run.sh create mode 100755 vendor/github.com/docker/docker/hack/validate/deprecate-integration-cli delete mode 100755 vendor/github.com/docker/docker/hack/validate/gofmt create mode 100755 vendor/github.com/docker/docker/hack/validate/gometalinter create mode 100644 vendor/github.com/docker/docker/hack/validate/gometalinter.json delete mode 100755 vendor/github.com/docker/docker/hack/validate/lint delete mode 100755 vendor/github.com/docker/docker/hack/validate/vet create mode 100644 vendor/github.com/docker/docker/integration-cli/docker_api_containers_windows_test.go create mode 100644 vendor/github.com/docker/docker/integration-cli/docker_api_ipcmode_test.go delete mode 100644 vendor/github.com/docker/docker/integration-cli/docker_api_version_test.go delete mode 100644 vendor/github.com/docker/docker/integration-cli/docker_cli_config_test.go delete mode 100644 vendor/github.com/docker/docker/integration-cli/docker_cli_experimental_test.go delete mode 100644 vendor/github.com/docker/docker/integration-cli/docker_cli_help_test.go delete mode 100644 vendor/github.com/docker/docker/integration-cli/docker_cli_stack_test.go delete mode 100644 vendor/github.com/docker/docker/integration-cli/docker_cli_version_test.go delete mode 100644 vendor/github.com/docker/docker/integration-cli/environment/clean.go delete mode 100644 vendor/github.com/docker/docker/integration-cli/environment/protect.go delete mode 100644 vendor/github.com/docker/docker/integration-cli/fixtures/plugin/plugin_linux.go delete mode 100644 vendor/github.com/docker/docker/integration-cli/fixtures/plugin/plugin_unsuported.go create mode 100644 vendor/github.com/docker/docker/integration/container/create_test.go create mode 100644 vendor/github.com/docker/docker/integration/container/main_test.go create mode 100644 vendor/github.com/docker/docker/integration/doc.go create mode 100644 vendor/github.com/docker/docker/integration/service/create_test.go create mode 100644 vendor/github.com/docker/docker/integration/service/inspect_test.go create mode 100644 vendor/github.com/docker/docker/integration/service/main_test.go create mode 100644 vendor/github.com/docker/docker/integration/system/main_test.go create mode 100644 vendor/github.com/docker/docker/integration/system/version_test.go create mode 100644 vendor/github.com/docker/docker/integration/util/request/client.go create mode 100644 vendor/github.com/docker/docker/internal/test/environment/clean.go create mode 100644 vendor/github.com/docker/docker/internal/test/environment/environment.go create mode 100644 vendor/github.com/docker/docker/internal/test/environment/protect.go create mode 100644 vendor/github.com/docker/docker/internal/testutil/helpers.go create mode 100644 vendor/github.com/docker/docker/pkg/containerfs/archiver.go create mode 100644 vendor/github.com/docker/docker/pkg/containerfs/containerfs.go create mode 100644 vendor/github.com/docker/docker/pkg/containerfs/containerfs_unix.go create mode 100644 vendor/github.com/docker/docker/pkg/containerfs/containerfs_windows.go create mode 100644 vendor/github.com/docker/docker/pkg/devicemapper/devmapper_wrapper_dynamic.go create mode 100644 vendor/github.com/docker/docker/pkg/dmesg/dmesg_linux.go create mode 100644 vendor/github.com/docker/docker/pkg/dmesg/dmesg_linux_test.go create mode 100644 vendor/github.com/docker/docker/pkg/signal/testfiles/main.go create mode 100644 vendor/github.com/docker/docker/pkg/signal/trap_linux_test.go delete mode 100644 vendor/github.com/docker/docker/pkg/system/events_windows.go create mode 100644 vendor/github.com/docker/docker/pkg/system/init_unix.go delete mode 100644 vendor/github.com/docker/docker/pkg/system/path_unix.go delete mode 100644 vendor/github.com/docker/docker/pkg/system/path_windows.go delete mode 100644 vendor/github.com/docker/docker/pkg/templates/templates_test.go delete mode 100644 vendor/github.com/docker/docker/pkg/testutil/cmd/command_test.go delete mode 100644 vendor/github.com/docker/docker/pkg/testutil/golden/golden.go delete mode 100644 vendor/github.com/docker/docker/pkg/testutil/helpers.go delete mode 100644 vendor/github.com/docker/docker/pkg/testutil/tempfile/tempfile.go delete mode 100644 vendor/github.com/docker/docker/pkg/testutil/utils.go delete mode 100644 vendor/github.com/docker/docker/pkg/testutil/utils_test.go delete mode 100644 vendor/github.com/docker/docker/pkg/tlsconfig/tlsconfig_clone.go create mode 100644 vendor/github.com/docker/docker/plugin/errors.go create mode 100644 vendor/github.com/docker/docker/plugin/executor/containerd/containerd.go create mode 100644 vendor/github.com/docker/docker/reference/errors.go create mode 100644 vendor/github.com/docker/docker/registry/errors.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/ea.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/LICENSE create mode 100644 vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/README.md rename vendor/github.com/docker/docker/vendor/github.com/{jhowardmsft/opengcs/gogcs => Microsoft/opengcs}/client/config.go (96%) rename vendor/github.com/docker/docker/vendor/github.com/{jhowardmsft/opengcs/gogcs => Microsoft/opengcs}/client/createext4vhdx.go (99%) rename vendor/github.com/docker/docker/vendor/github.com/{jhowardmsft/opengcs/gogcs => Microsoft/opengcs}/client/hotaddvhd.go (97%) rename vendor/github.com/docker/docker/vendor/github.com/{jhowardmsft/opengcs/gogcs => Microsoft/opengcs}/client/hotremovevhd.go (97%) rename vendor/github.com/docker/docker/vendor/github.com/{jhowardmsft/opengcs/gogcs => Microsoft/opengcs}/client/layervhddetails.go (100%) rename vendor/github.com/docker/docker/vendor/github.com/{jhowardmsft/opengcs/gogcs => Microsoft/opengcs}/client/process.go (71%) rename vendor/github.com/docker/docker/vendor/github.com/{jhowardmsft/opengcs/gogcs => Microsoft/opengcs}/client/tartovhd.go (98%) rename vendor/github.com/docker/docker/vendor/github.com/{jhowardmsft/opengcs/gogcs => Microsoft/opengcs}/client/unsupported.go (100%) rename vendor/github.com/docker/docker/vendor/github.com/{jhowardmsft/opengcs/gogcs => Microsoft/opengcs}/client/utilities.go (100%) rename vendor/github.com/docker/docker/vendor/github.com/{jhowardmsft/opengcs/gogcs => Microsoft/opengcs}/client/vhdtotar.go (99%) create mode 100644 vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/README create mode 100644 vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/defs.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/remotefs.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/utils.go create mode 100755 vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/vendor.conf create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/LICENSE create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/README.md create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_darwin.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_dummy.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_freebsd.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_linux.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_solaris.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_unix.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_windows.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/driver.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/driver_unix.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/driver_windows.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/utils.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/pathdriver/path_driver.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/asm.s create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_darwin.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_darwin_386.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_darwin_amd64.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_freebsd.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_freebsd_amd64.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_linux.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_solaris.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_386.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_amd64.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_arm.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_arm64.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_ppc64le.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_s390x.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/nodata_linux.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/nodata_solaris.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/nodata_unix.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sys.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_386.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_amd64.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_arm.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_arm64.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_ppc64le.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_s390x.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_darwin.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_darwin_386.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_darwin_amd64.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_freebsd.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_386.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_amd64.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_arm.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_arm64.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_ppc64.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_ppc64le.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_s390x.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_solaris.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_unsupported.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/common/caller.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/diagnose/diagnose.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/networkdbdiagnose.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/portallocator/portallocator_freebsd.go delete mode 100644 vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/gen.go delete mode 100644 vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/protobuf/plugin/gen.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/LICENSE create mode 100644 vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/README.md create mode 100644 vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/fs/file.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/fs/ops.go rename vendor/github.com/docker/docker/{pkg/testutil/cmd => vendor/github.com/gotestyourself/gotestyourself/icmd}/command.go (78%) create mode 100644 vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/icmd/exitcode.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/icmd/ops.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/poll/poll.go create mode 100644 vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/skip/skip.go delete mode 100644 vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/LICENSE rename vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/{cgroup_unix.go => cgroup_linux.go} (94%) rename vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/{config_unix.go => config_linux.go} (98%) rename vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/{namespaces_unix.go => namespaces_linux.go} (97%) rename vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/devices/{devices_unix.go => devices_linux.go} (71%) delete mode 100644 vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/setns_linux.go delete mode 100644 vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_appengine.go delete mode 100644 vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_notwindows.go delete mode 100644 vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_solaris.go delete mode 100644 vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_windows.go rename vendor/{ => github.com/docker/docker/vendor}/golang.org/x/crypto/README.md (100%) rename vendor/{ => github.com/docker/docker/vendor}/golang.org/x/crypto/curve25519/const_amd64.h (100%) create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/const_amd64.s create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/cswap_amd64.s create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/curve25519.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/doc.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/freeze_amd64.s create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/mont25519_amd64.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/mul_amd64.s create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/square_amd64.s rename vendor/{ => github.com/docker/docker/vendor}/golang.org/x/crypto/poly1305/sum_amd64.s (100%) rename vendor/{ => github.com/docker/docker/vendor}/golang.org/x/crypto/poly1305/sum_arm.s (100%) create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/terminal.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_linux.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_plan9.go rename vendor/{ => github.com/docker/docker/vendor}/golang.org/x/crypto/ssh/terminal/util_solaris.go (100%) create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/asm_openbsd_arm.s create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/cap_freebsd.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/dev_linux.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/errors_freebsd_386.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/errors_freebsd_arm.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/file_unix.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go create mode 100644 vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go rename vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/{ztypes_windows.go => types_windows.go} (96%) rename vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/{ztypes_windows_386.go => types_windows_386.go} (100%) rename vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/{ztypes_windows_amd64.go => types_windows_amd64.go} (100%) create mode 100644 vendor/github.com/docker/docker/volume/lcow_parser.go create mode 100644 vendor/github.com/docker/docker/volume/linux_parser.go create mode 100644 vendor/github.com/docker/docker/volume/parser.go rename vendor/github.com/docker/docker/volume/{validate_test_unix.go => validate_unix_test.go} (100%) rename vendor/github.com/docker/docker/volume/{validate_test_windows.go => validate_windows_test.go} (100%) delete mode 100644 vendor/github.com/docker/docker/volume/volume_copy_unix.go delete mode 100644 vendor/github.com/docker/docker/volume/volume_copy_windows.go delete mode 100644 vendor/github.com/docker/docker/volume/volume_linux.go delete mode 100644 vendor/github.com/docker/docker/volume/volume_linux_test.go delete mode 100644 vendor/github.com/docker/docker/volume/volume_propagation_linux.go delete mode 100644 vendor/github.com/docker/docker/volume/volume_propagation_linux_test.go delete mode 100644 vendor/github.com/docker/docker/volume/volume_propagation_unsupported.go delete mode 100644 vendor/github.com/docker/docker/volume/volume_unsupported.go create mode 100644 vendor/github.com/docker/docker/volume/windows_parser.go create mode 100644 vendor/github.com/gin-gonic/gin/examples/custom-validation/server.go delete mode 100644 vendor/github.com/golang/protobuf/_conformance/Makefile delete mode 100644 vendor/github.com/golang/protobuf/_conformance/conformance.go delete mode 100644 vendor/github.com/golang/protobuf/_conformance/conformance_proto/conformance.pb.go delete mode 100644 vendor/github.com/golang/protobuf/_conformance/conformance_proto/conformance.proto delete mode 100644 vendor/github.com/golang/protobuf/descriptor/descriptor.go delete mode 100644 vendor/github.com/golang/protobuf/descriptor/descriptor_test.go delete mode 100644 vendor/github.com/golang/protobuf/proto/any_test.go delete mode 100644 vendor/github.com/golang/protobuf/proto/decode_test.go delete mode 100644 vendor/github.com/golang/protobuf/proto/encode_test.go delete mode 100644 vendor/github.com/golang/protobuf/proto/map_test.go rename vendor/github.com/golang/protobuf/protoc-gen-go/{ => internal}/grpc/grpc.go (90%) delete mode 100644 vendor/github.com/golang/protobuf/ptypes/any.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/any/any.pb.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/any/any.proto delete mode 100644 vendor/github.com/golang/protobuf/ptypes/any_test.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/doc.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/duration.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/duration/duration.proto delete mode 100644 vendor/github.com/golang/protobuf/ptypes/duration_test.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/empty/empty.pb.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/empty/empty.proto delete mode 100755 vendor/github.com/golang/protobuf/ptypes/regen.sh delete mode 100644 vendor/github.com/golang/protobuf/ptypes/struct/struct.pb.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/struct/struct.proto delete mode 100644 vendor/github.com/golang/protobuf/ptypes/timestamp.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto delete mode 100644 vendor/github.com/golang/protobuf/ptypes/timestamp_test.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.pb.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.proto delete mode 100644 vendor/github.com/gopherjs/gopherjs/.gitignore delete mode 100644 vendor/github.com/gopherjs/gopherjs/LICENSE delete mode 100644 vendor/github.com/gopherjs/gopherjs/README.md delete mode 100644 vendor/github.com/gopherjs/gopherjs/build/build.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/build/build_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/circle.yml delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/analysis/bool.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/analysis/break.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/analysis/escape.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/analysis/info.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/analysis/sideeffect.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/astutil/astutil.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/compiler.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/expressions.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/filter/assign.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/filter/incdecstmt.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/doc.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/fs.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/fs_vfsdata.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/bytes/bytes.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/bytes/bytes_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/rand/rand.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/x509/x509.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/x509/x509_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/database/sql/driver/driver_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/debug/elf/elf_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/encoding/json/stream_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/fmt/fmt_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/go/token/token_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/internal/testenv/testenv.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/io/io_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/big/big.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/big/big_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/math.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/math_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/rand/rand_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/http/cookiejar/example_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/http/fetch.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/http/http.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/net.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/os/os.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/example_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/reflect.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/reflect_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/swapper.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/regexp/regexp_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/debug/debug.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/pprof/pprof.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/runtime.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/strings/strings.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/atomic/atomic.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/atomic/atomic_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/cond.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/pool.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/sync.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/sync_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/waitgroup.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/syscall/syscall.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/syscall/syscall_unix.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/syscall/syscall_windows.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/testing/example.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/testing/ioutil.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/text/template/template.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/time/time.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/natives/src/unicode/unicode.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/package.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/prelude/goroutines.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/prelude/jsmapping.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/prelude/numeric.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/prelude/prelude.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/prelude/types.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/statements.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/typesutil/typesutil.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/utils.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/vendor/github.com/neelance/astrewrite/LICENSE delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/vendor/github.com/neelance/astrewrite/simplify.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/vendor/vendor.json delete mode 100644 vendor/github.com/gopherjs/gopherjs/compiler/version_check.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/doc/packages.md delete mode 100644 vendor/github.com/gopherjs/gopherjs/doc/syscalls.md delete mode 100644 vendor/github.com/gopherjs/gopherjs/js/js.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/js/js_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/node-syscall/binding.gyp delete mode 100644 vendor/github.com/gopherjs/gopherjs/node-syscall/syscall.cc delete mode 100644 vendor/github.com/gopherjs/gopherjs/nosync/mutex.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/nosync/once.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/nosync/pool.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/alias_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/copy_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/deferblock_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/doc.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/gorepo_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/goroutine_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/lowlevel_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/main/main.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/main/main_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/misc_test.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/otherpkg/otherpkg.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/run.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.out delete mode 100644 vendor/github.com/gopherjs/gopherjs/tests/vendor/vendored/vendored.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/third_party/importer/export.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/third_party/importer/import.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/third_party/importer/predefined.go delete mode 100644 vendor/github.com/gopherjs/gopherjs/tool.go create mode 100644 vendor/github.com/json-iterator/go/jsoniter_enum_marshaler_test.go create mode 100644 vendor/github.com/json-iterator/go/jsoniter_struct_encoder_test.go create mode 100644 vendor/github.com/json-iterator/go/output_tests/builtins/int64/json_test.go create mode 100644 vendor/github.com/json-iterator/go/output_tests/builtins/int64/types.go create mode 100644 vendor/github.com/json-iterator/go/output_tests/map/int64/string/json_test.go create mode 100644 vendor/github.com/json-iterator/go/output_tests/map/int64/string/types.go create mode 100644 vendor/github.com/json-iterator/go/output_tests/slice/int64/json_test.go create mode 100644 vendor/github.com/json-iterator/go/output_tests/slice/int64/types.go create mode 100644 vendor/github.com/json-iterator/go/output_tests/struct/int64/json_test.go create mode 100644 vendor/github.com/json-iterator/go/output_tests/struct/int64/types.go delete mode 100644 vendor/github.com/jtolds/gls/gid.go delete mode 100644 vendor/github.com/jtolds/gls/stack_tags_js.go delete mode 100644 vendor/github.com/jtolds/gls/stack_tags_main.go delete mode 100644 vendor/github.com/mattn/go-colorable/.travis.yml delete mode 100644 vendor/github.com/mattn/go-colorable/README.md delete mode 100644 vendor/github.com/mattn/go-colorable/_example/escape-seq/main.go delete mode 100644 vendor/github.com/mattn/go-colorable/_example/logrus/main.go delete mode 100644 vendor/github.com/mattn/go-colorable/_example/title/main.go delete mode 100644 vendor/github.com/mattn/go-colorable/cmd/colorable/colorable.go delete mode 100644 vendor/github.com/mattn/go-colorable/colorable_appengine.go delete mode 100644 vendor/github.com/mattn/go-colorable/colorable_others.go delete mode 100644 vendor/github.com/mattn/go-colorable/colorable_test.go delete mode 100644 vendor/github.com/mattn/go-colorable/colorable_windows.go delete mode 100644 vendor/github.com/mattn/go-colorable/noncolorable.go rename vendor/github.com/mattn/{go-colorable => go-zglob}/LICENSE (96%) create mode 100644 vendor/github.com/shirou/gopsutil/cpu/cpu_linux_test.go create mode 100644 vendor/github.com/shirou/gopsutil/cpu/testdata/linux/424/proc/stat create mode 100755 vendor/github.com/shirou/gopsutil/cpu/testdata/linux/times_empty/proc/stat create mode 100644 vendor/github.com/shirou/gopsutil/host/host_linux_mips.go create mode 100644 vendor/github.com/shirou/gopsutil/host/host_linux_mipsle.go delete mode 100644 vendor/github.com/smartystreets/assertions/CONTRIBUTING.md create mode 100644 vendor/github.com/smartystreets/assertions/assertions.goconvey delete mode 100644 vendor/github.com/smartystreets/assertions/equal_method.go delete mode 100644 vendor/github.com/smartystreets/assertions/equal_method_test.go delete mode 100644 vendor/github.com/smartystreets/assertions/internal/go-render/.travis.yml delete mode 100644 vendor/github.com/smartystreets/assertions/internal/go-render/LICENSE delete mode 100644 vendor/github.com/smartystreets/assertions/internal/go-render/PRESUBMIT.py delete mode 100644 vendor/github.com/smartystreets/assertions/internal/go-render/README.md delete mode 100644 vendor/github.com/smartystreets/assertions/internal/go-render/WATCHLISTS delete mode 100644 vendor/github.com/smartystreets/assertions/internal/go-render/pre-commit-go.yml delete mode 100644 vendor/github.com/smartystreets/assertions/internal/go-render/render/render.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/any.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/any_of_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/any_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/contains_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/deep_equals_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/equals_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/error.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/error_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/less_than_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/not_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/panics.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/panics_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/.gitignore create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/.travis.yml create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/LICENSE create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/README.md create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/action.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/controller.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/controller_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_interfaces create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_package create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_interface create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_package create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/do_all.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/do_all_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/error_reporter.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/expectation.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg/complicated_pkg.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.complicated_pkg.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.image.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.io_reader_writer.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.renamed_pkg.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg/renamed_pkg.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/integration_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/invoke.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/invoke_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/mock_object.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/return.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/return_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/sample/README.markdown create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/sample/mock_io/mock_io.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/.gitignore create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/.travis.yml create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/LICENSE create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/README.md create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/assert_aliases.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/assert_that.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/doc.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/expect_aliases.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/expect_call.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/failure.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/integration_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/register.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/register_test_suite.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/run_tests.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/docs.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods_test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/failing.test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/filtered.test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.failing_test create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.filtered_test create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.mock_test create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.no_cases_test create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.panicking_test create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.passing_test create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.run_twice_test create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.stop_test create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.unexported_test create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock.test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock_image/mock_image.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/no_cases.test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/panicking.test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/passing.test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/run_twice.test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/stop.test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/unexported.test.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/ogletest/test_info.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/reqtrace/.gitignore create mode 100644 vendor/github.com/smartystreets/assertions/internal/reqtrace/LICENSE create mode 100644 vendor/github.com/smartystreets/assertions/internal/reqtrace/README.md create mode 100644 vendor/github.com/smartystreets/assertions/internal/reqtrace/reqtrace.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/reqtrace/trace_state.go delete mode 100644 vendor/github.com/smartystreets/goconvey/.gitattributes create mode 100644 vendor/github.com/smartystreets/goconvey/doc_test.go create mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/css/font-awesome.min.css create mode 100755 vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/FontAwesome.otf delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/README.md delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/css/font-awesome.css create mode 100755 vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.eot create mode 100755 vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.svg create mode 100755 vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.ttf create mode 100755 vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.woff delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/FontAwesome.otf delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/fontawesome-webfont.eot delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/fontawesome-webfont.svg delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/fontawesome-webfont.ttf delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/fontawesome-webfont.woff delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/fontawesome-webfont.woff2 create mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/diff-match-patch.min.js delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/diff_match_patch.js create mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery-2_1_0.min.js create mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery-ui-1_10_3-custom.min.js delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery-ui.js delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery-ui.js.url delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery.js delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery.js.url delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery.pretty-text-diff.js delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery.pretty-text-diff.js.url create mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery.pretty-text-diff.min.js delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery.tipsy.js delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery.tipsy.js.url create mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery.tipsy.min.js delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/markup.js delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/markup.js.url create mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/markup.min.js delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/moment.js delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/moment.js.url create mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/moment.min.js delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/taboverride.js delete mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/taboverride.js.url create mode 100644 vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/taboverride.min.js delete mode 100644 vendor/github.com/smartystreets/logging/.gitignore delete mode 100644 vendor/github.com/smartystreets/logging/CONTRIBUTING.md delete mode 100644 vendor/github.com/smartystreets/logging/LICENSE.md delete mode 100644 vendor/github.com/smartystreets/logging/README.md delete mode 100644 vendor/github.com/smartystreets/logging/logging.go delete mode 100644 vendor/github.com/smartystreets/logging/logging_test.go rename vendor/github.com/ugorji/go/codec/{decode_go.go => goversion_arrayof_gte_go15.go} (59%) rename vendor/github.com/ugorji/go/codec/{decode_go14.go => goversion_arrayof_lt_go15.go} (64%) create mode 100644 vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go create mode 100644 vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go create mode 100644 vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go rename vendor/github.com/ugorji/go/codec/{gen_15.go => goversion_vendor_eq_go15.go} (72%) rename vendor/github.com/ugorji/go/codec/{gen_16.go => goversion_vendor_eq_go16.go} (65%) rename vendor/github.com/ugorji/go/codec/{gen_17.go => goversion_vendor_gte_go17.go} (82%) create mode 100644 vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go create mode 100644 vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl create mode 100644 vendor/github.com/ugorji/go/codec/mammoth_generated_test.go delete mode 100644 vendor/github.com/ugorji/go/codec/prebuild.go delete mode 100755 vendor/github.com/ugorji/go/codec/prebuild.sh delete mode 100755 vendor/github.com/ugorji/go/codec/tests.sh create mode 100644 vendor/github.com/ugorji/go/codec/xml.go create mode 100644 vendor/github.com/ugorji/go/codec/z_all_test.go rename vendor/{github.com/docker/docker/vendor => }/golang.org/x/crypto/README (100%) delete mode 100644 vendor/golang.org/x/crypto/acme/acme.go delete mode 100644 vendor/golang.org/x/crypto/acme/acme_test.go delete mode 100644 vendor/golang.org/x/crypto/acme/autocert/autocert.go delete mode 100644 vendor/golang.org/x/crypto/acme/autocert/autocert_test.go delete mode 100644 vendor/golang.org/x/crypto/acme/autocert/cache.go delete mode 100644 vendor/golang.org/x/crypto/acme/autocert/cache_test.go delete mode 100644 vendor/golang.org/x/crypto/acme/autocert/example_test.go delete mode 100644 vendor/golang.org/x/crypto/acme/autocert/listener.go delete mode 100644 vendor/golang.org/x/crypto/acme/autocert/renewal.go delete mode 100644 vendor/golang.org/x/crypto/acme/autocert/renewal_test.go create mode 100644 vendor/golang.org/x/crypto/acme/internal/acme/acme.go create mode 100644 vendor/golang.org/x/crypto/acme/internal/acme/acme_test.go create mode 100644 vendor/golang.org/x/crypto/acme/internal/acme/jws.go create mode 100644 vendor/golang.org/x/crypto/acme/internal/acme/jws_test.go rename vendor/golang.org/x/crypto/acme/{ => internal/acme}/types.go (52%) delete mode 100644 vendor/golang.org/x/crypto/acme/jws.go delete mode 100644 vendor/golang.org/x/crypto/acme/jws_test.go delete mode 100644 vendor/golang.org/x/crypto/acme/types_test.go delete mode 100644 vendor/golang.org/x/crypto/blake2b/blake2b.go delete mode 100644 vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.go delete mode 100644 vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.s delete mode 100644 vendor/golang.org/x/crypto/blake2b/blake2b_amd64.go delete mode 100644 vendor/golang.org/x/crypto/blake2b/blake2b_amd64.s delete mode 100644 vendor/golang.org/x/crypto/blake2b/blake2b_generic.go delete mode 100644 vendor/golang.org/x/crypto/blake2b/blake2b_ref.go delete mode 100644 vendor/golang.org/x/crypto/blake2b/blake2b_test.go delete mode 100644 vendor/golang.org/x/crypto/blake2b/blake2x.go delete mode 100644 vendor/golang.org/x/crypto/blake2b/register.go delete mode 100644 vendor/golang.org/x/crypto/blake2s/blake2s.go delete mode 100644 vendor/golang.org/x/crypto/blake2s/blake2s_386.go delete mode 100644 vendor/golang.org/x/crypto/blake2s/blake2s_386.s delete mode 100644 vendor/golang.org/x/crypto/blake2s/blake2s_amd64.go delete mode 100644 vendor/golang.org/x/crypto/blake2s/blake2s_amd64.s delete mode 100644 vendor/golang.org/x/crypto/blake2s/blake2s_generic.go delete mode 100644 vendor/golang.org/x/crypto/blake2s/blake2s_ref.go delete mode 100644 vendor/golang.org/x/crypto/blake2s/blake2s_test.go delete mode 100644 vendor/golang.org/x/crypto/blake2s/blake2x.go delete mode 100644 vendor/golang.org/x/crypto/blake2s/register.go delete mode 100644 vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305.go delete mode 100644 vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.go delete mode 100644 vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.s delete mode 100644 vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_generic.go delete mode 100644 vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_noasm.go delete mode 100644 vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_test.go delete mode 100644 vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_vectors_test.go delete mode 100644 vendor/golang.org/x/crypto/chacha20poly1305/internal/chacha20/chacha_generic.go delete mode 100644 vendor/golang.org/x/crypto/chacha20poly1305/internal/chacha20/chacha_test.go delete mode 100644 vendor/golang.org/x/crypto/cryptobyte/asn1.go delete mode 100644 vendor/golang.org/x/crypto/cryptobyte/asn1_test.go delete mode 100644 vendor/golang.org/x/crypto/cryptobyte/builder.go delete mode 100644 vendor/golang.org/x/crypto/cryptobyte/cryptobyte_test.go delete mode 100644 vendor/golang.org/x/crypto/cryptobyte/example_test.go delete mode 100644 vendor/golang.org/x/crypto/cryptobyte/string.go delete mode 100644 vendor/golang.org/x/crypto/md4/example_test.go delete mode 100644 vendor/golang.org/x/crypto/nacl/box/example_test.go delete mode 100644 vendor/golang.org/x/crypto/nacl/secretbox/example_test.go rename vendor/{github.com/docker/docker/vendor => }/golang.org/x/crypto/poly1305/const_amd64.s (100%) rename vendor/{github.com/docker/docker/vendor => }/golang.org/x/crypto/poly1305/poly1305_amd64.s (100%) rename vendor/{github.com/docker/docker/vendor => }/golang.org/x/crypto/poly1305/poly1305_arm.s (100%) delete mode 100644 vendor/golang.org/x/crypto/sha3/keccakf_amd64.go delete mode 100644 vendor/golang.org/x/crypto/sha3/keccakf_amd64.s delete mode 100644 vendor/golang.org/x/crypto/ssh/knownhosts/knownhosts.go delete mode 100644 vendor/golang.org/x/crypto/ssh/knownhosts/knownhosts_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/streamlocal.go delete mode 100644 vendor/golang.org/x/crypto/ssh/test/dial_unix_test.go create mode 100644 vendor/golang.org/x/crypto/ssh/test/tcpip_test.go diff --git a/glide.lock b/glide.lock index e8efa8587..3b3a6c33c 100644 --- a/glide.lock +++ b/glide.lock @@ -1,8 +1,8 @@ hash: aec675fc4428e70de14f6436b259ae34adf78b246d8dd326116fc94ec135015c -updated: 2017-08-05T22:03:32.347691067+02:00 +updated: 2017-09-20T13:53:25.307325158+02:00 imports: - name: github.com/aokoli/goutils - version: 3391d3790d23d03408670993e957e8f408993c34 + version: 9c37978a95bd5c709a15883b6242714ea6709e64 - name: github.com/awalterschulze/gographviz version: 01fdca2df2c7f57917d029fc952cbf23f621101b subpackages: @@ -16,23 +16,23 @@ imports: - name: github.com/deckarep/gosx-notifier version: 61a88900fb062ed8c63828adf4d7b58463b61f78 - name: github.com/docker/docker - version: d4f6db83c21cfc6af54fffb1f13e8acb7199f96a + version: 7cbbbb95097f065757d38bcccdb1bbef81d10ddb subpackages: - api/types/strslice - name: github.com/docker/go-units version: 0dadbb0345b35ec7ef35e228dabb8de89a65bf52 - name: github.com/docker/libcompose - version: 1b708aac26a4fc6f9bff31728a8e3a252ef57dbd + version: b2c0c6e7006959f15d7d3f64a653a339a4b68ff3 subpackages: - yaml - name: github.com/dustin/go-humanize - version: 259d2a102b871d17f30e3cd9881a642961a1e486 + version: 79e699ccd02f240a1f1fbbdcee7e64c1c12e41aa - name: github.com/flynn/go-shlex version: 3f9db97f856818214da2e1057f8ad84803971cff - name: github.com/gin-contrib/sse version: 22d885f9ecc78bf4ee5d72b937e4bbcdc58e8cae - name: github.com/gin-gonic/gin - version: 81007d2ce0176f7a9ce52dd12e56edd7ef40e72c + version: 5afc5b19730118c9b8324fe9dd995d44ec65c81a subpackages: - binding - json @@ -42,7 +42,7 @@ imports: subpackages: - oleutil - name: github.com/golang/protobuf - version: 8ee79997227bf9b34611aee7946ae64735e6fd93 + version: 2402d76f3d41f928c7902a765dfc872356dd3aad subpackages: - proto - name: github.com/guelfey/go.dbus @@ -50,29 +50,27 @@ imports: - name: github.com/haklop/gnotifier version: 0de36badf60155d5953373ed432982b20c62fb91 - name: github.com/huandu/xstrings - version: 3959339b333561bf62a38b424fd41517c2c90f40 + version: d6590c0c31d16526217fa60fbd2067f7afcd78c5 - name: github.com/imdario/mergo version: 3e95a51e0639b4cf372f2ccf74c86749d747fbdc - name: github.com/json-iterator/go - version: 1cfa233923ea407d7f0c70d7a7d835030678e788 + version: fdfe0b9a69118ff692d6e1005e9de7e0cffb7d6b - name: github.com/Masterminds/semver version: 59c29afe1a994eacb71c833025ca7acf874bb1da - name: github.com/Masterminds/sprig - version: e039e20e500c2c025d9145be375e27cf42a94174 -- name: github.com/mattn/go-colorable - version: 6c0fd4aa6ec5818d5e3ea9e03ae436972a6c5a9a + version: 4c164950cd0a8d3724ddb78982e2c56dc7f47112 - name: github.com/mattn/go-isatty version: 57fdcb988a5c543893cc61bce354a6e24ab70022 - name: github.com/mattn/go-zglob - version: 95345c4e1c0ebc9d16a3284177f09360f4d20fab + version: 4ecb59231939b2e499b1f2fd8f075565977d2452 subpackages: - fastwalk - name: github.com/mgutz/ansi - version: 9520e82c474b0a04dd04f8a40959027271bab992 + version: c286dcecd19ff979eeb73ea444e479b903f2cfcb - name: github.com/satori/go.uuid version: 879c5887cd475cd7864858769793b2ceb0d44feb - name: github.com/shirou/gopsutil - version: 3aa2ffab12a1852644f6d33cd782f877272bf305 + version: 4c9fd1f200a4b10915b383ff2a5bb401b6710e87 subpackages: - cpu - host @@ -87,13 +85,13 @@ imports: - name: github.com/StackExchange/wmi version: ea383cf3ba6ec950874b8486cd72356d007c768f - name: github.com/ugorji/go - version: 5efa3251c7f7d05e5d9704a69a984ec9f1386a40 + version: 54210f4e076c57f351166f0ed60e67d3fca57a36 subpackages: - codec - name: github.com/urfave/cli version: 0bdeddeeb0f650497d603c4ad7b20cfe685682f6 - name: golang.org/x/crypto - version: 42ff06aea7c329876e5a0fe94acc96902accf0ad + version: 5bcd134fee4dd1475da17714aac19c0aa0142e2f subpackages: - pbkdf2 - scrypt @@ -112,26 +110,19 @@ imports: subpackages: - rate - name: gopkg.in/go-playground/validator.v8 - version: 5f1438d3fca68893a817e4a66806cea46a9e4ebf + version: c193cecd124b5cc722d7ee5538e945bdb3348435 - name: gopkg.in/yaml.v2 - version: 25c4ec802a7d637f88d584ab26798e94ad14c13b + version: eb3733d160e74a9c7e442f435eb3bea458e1d19f testImports: -- name: github.com/gopherjs/gopherjs - version: 2b1d432c8a82c9bff0b0baffaeb3ec6e92974112 - subpackages: - - js - name: github.com/jtolds/gls - version: 77f18212c9c7edc9bd6a33d383a7b545ce62f064 + version: 9a4a02dbe491bef4bab3c24fd9f3087d6c4c6690 - name: github.com/smartystreets/assertions - version: 3c7b29c4776a870a5983b38635e241a40a7e5422 + version: 01fedaa993c0a9f9aa55111501cd7c81a49e812e subpackages: - - internal/go-render/render - internal/oglematchers - name: github.com/smartystreets/goconvey - version: 9e8dc3f972df6c8fcc0375ef492c24d0bb204857 + version: 5bb9e117a1a4f1a1555a4d41cd233c79b1a5209f subpackages: - convey - convey/gotest - convey/reporting -- name: github.com/smartystreets/logging - version: ac3a674540761aa0b4382094ba4795f917e85c7f diff --git a/vendor/github.com/Masterminds/sprig/date.go b/vendor/github.com/Masterminds/sprig/date.go index dc5263f24..90bde0369 100644 --- a/vendor/github.com/Masterminds/sprig/date.go +++ b/vendor/github.com/Masterminds/sprig/date.go @@ -51,3 +51,26 @@ func dateModify(fmt string, date time.Time) time.Time { } return date.Add(d) } + +func dateAgo(date interface{}) string { + var t time.Time + + switch date := date.(type) { + default: + t = time.Now() + case time.Time: + t = date + case int64: + t = time.Unix(date, 0) + case int: + t = time.Unix(int64(date), 0) + } + // Drop resolution to seconds + duration := time.Since(t) / time.Second * time.Second + return duration.String() +} + +func toDate(fmt, str string) time.Time { + t, _ := time.ParseInLocation(fmt, str, time.Local) + return t +} diff --git a/vendor/github.com/Masterminds/sprig/date_test.go b/vendor/github.com/Masterminds/sprig/date_test.go index 8e98b8c9a..19fd40f27 100644 --- a/vendor/github.com/Masterminds/sprig/date_test.go +++ b/vendor/github.com/Masterminds/sprig/date_test.go @@ -2,6 +2,7 @@ package sprig import ( "testing" + "time" ) func TestHtmlDate(t *testing.T) { @@ -11,3 +12,25 @@ func TestHtmlDate(t *testing.T) { t.Error(err) } } + +func TestAgo(t *testing.T) { + tpl := "{{ ago .Time }}" + if err := runtv(tpl, "2m5s", map[string]interface{}{"Time": time.Now().Add(-125 * time.Second)}); err != nil { + t.Error(err) + } + + if err := runtv(tpl, "2h34m17s", map[string]interface{}{"Time": time.Now().Add(-(2*3600 + 34*60 + 17) * time.Second)}); err != nil { + t.Error(err) + } + + if err := runtv(tpl, "-4s", map[string]interface{}{"Time": time.Now().Add(5 * time.Second)}); err != nil { + t.Error(err) + } +} + +func TestToDate(t *testing.T) { + tpl := `{{toDate "2006-01-02" "2017-12-31" | date "02/01/2006"}}` + if err := runt(tpl, "31/12/2017"); err != nil { + t.Error(err) + } +} diff --git a/vendor/github.com/Masterminds/sprig/dict.go b/vendor/github.com/Masterminds/sprig/dict.go index 46692d15d..fabc736b0 100644 --- a/vendor/github.com/Masterminds/sprig/dict.go +++ b/vendor/github.com/Masterminds/sprig/dict.go @@ -75,10 +75,12 @@ func dict(v ...interface{}) map[string]interface{} { return dict } -func merge(dst map[string]interface{}, src map[string]interface{}) interface{} { - if err := mergo.Merge(&dst, src); err != nil { - // Swallow errors inside of a template. - return "" +func merge(dst map[string]interface{}, srcs ...map[string]interface{}) interface{} { + for _, src := range srcs { + if err := mergo.Merge(&dst, src); err != nil { + // Swallow errors inside of a template. + return "" + } } return dst } diff --git a/vendor/github.com/Masterminds/sprig/dict_test.go b/vendor/github.com/Masterminds/sprig/dict_test.go index 0206523e8..100dccca5 100644 --- a/vendor/github.com/Masterminds/sprig/dict_test.go +++ b/vendor/github.com/Masterminds/sprig/dict_test.go @@ -138,13 +138,20 @@ func TestCompact(t *testing.T) { func TestMerge(t *testing.T) { dict := map[string]interface{}{ - "src": map[string]interface{}{ + "src2": map[string]interface{}{ + "h": 10, + "i": "i", + "j": "j", + }, + "src1": map[string]interface{}{ "a": 1, "b": 2, "d": map[string]interface{}{ "e": "four", }, "g": []int{6, 7}, + "i": "aye", + "j": "jay", }, "dst": map[string]interface{}{ "a": "one", @@ -153,22 +160,26 @@ func TestMerge(t *testing.T) { "f": 5, }, "g": []int{8, 9}, + "i": "eye", }, } - tpl := `{{merge .dst .src}}` + tpl := `{{merge .dst .src1 .src2}}` _, err := runRaw(tpl, dict) if err != nil { t.Error(err) } expected := map[string]interface{}{ "a": "one", // key overridden - "b": 2, // merged from src + "b": 2, // merged from src1 "c": 3, // merged from dst "d": map[string]interface{}{ // deep merge "e": "four", "f": 5, }, "g": []int{8, 9}, // overridden - arrays are not merged + "h": 10, // merged from src2 + "i": "eye", // overridden twice + "j": "jay", // overridden and merged } assert.Equal(t, expected, dict["dst"]) } diff --git a/vendor/github.com/Masterminds/sprig/doc.go b/vendor/github.com/Masterminds/sprig/doc.go index 0eac8e27a..7b7eefd47 100644 --- a/vendor/github.com/Masterminds/sprig/doc.go +++ b/vendor/github.com/Masterminds/sprig/doc.go @@ -48,6 +48,10 @@ String Functions - randAlpha: Given a length, generate an alphabetic string - randAscii: Given a length, generate a random ASCII string (symbols included) - randNumeric: Given a length, generate a string of digits. + - swapcase: SwapCase swaps the case of a string using a word based algorithm. see https://godoc.org/github.com/Masterminds/goutils#SwapCase + - shuffle: Shuffle randomizes runes in a string and returns the result. It uses default random source in `math/rand` + - snakecase: convert all upper case characters in a string to underscore format. + - camelcase: convert all lower case characters behind underscores to upper case character - wrap: Force a line wrap at the given width. `wrap 80 "imagine a longer string"` - wrapWith: Wrap a line at the given length, but using 'sep' instead of a newline. `wrapWith 50, "
", $html` - contains: strings.Contains, but with the arguments switched: `contains substr str`. (This simplifies common pipelines) @@ -57,6 +61,7 @@ String Functions - squote: Wrap string(s) in double quotation marks, does not escape content. - cat: Concatenate strings, separating them by spaces. `cat $a $b $c`. - indent: Indent a string using space characters. `indent 4 "foo\nbar"` produces " foo\n bar" + - nindent: Indent a string using space characters and prepend a new line. `indent 4 "foo\nbar"` produces "\n foo\n bar" - replace: Replace an old with a new in a string: `$name | replace " " "-"` - plural: Choose singular or plural based on length: `len $fish | plural "one anchovy" "many anchovies"` - sha256sum: Generate a hex encoded sha256 hash of the input diff --git a/vendor/github.com/Masterminds/sprig/docs/date.md b/vendor/github.com/Masterminds/sprig/docs/date.md index 5e7209d82..9a4f67350 100644 --- a/vendor/github.com/Masterminds/sprig/docs/date.md +++ b/vendor/github.com/Masterminds/sprig/docs/date.md @@ -4,6 +4,20 @@ The current date/time. Use this in conjunction with other date functions. + +## ago + +The `ago` function returns duration from time.Now in seconds resolution. + +``` +ago .CreatedAt" +``` +returns in `time.Duration` String() format + +``` +2h34m7s +``` + ## date The `date` function formats a date. @@ -60,3 +74,15 @@ Same as htmlDate, but with a timezone. htmlDate (now) "UTC" ``` +## toDate + +`toDate` converts a string to a date. The first argument is the date layout and +the second the date string. If the string can't be convert it returns the zero +value. + +This is useful when you want to convert a string date to another format +(using pipe). The example below converts "2017-12-31" to "31/12/2017". + +``` +toDate "2006-01-02" "2017-12-31" | date "02/01/2006" +``` diff --git a/vendor/github.com/Masterminds/sprig/docs/dicts.md b/vendor/github.com/Masterminds/sprig/docs/dicts.md index fa110c678..54c9b0645 100644 --- a/vendor/github.com/Masterminds/sprig/docs/dicts.md +++ b/vendor/github.com/Masterminds/sprig/docs/dicts.md @@ -77,10 +77,10 @@ matching key out of a collection of dictionaries. ## merge -Merge two dictionaries into one, giving precedence to the dest dictionary: +Merge two or more dictionaries into one, giving precedence to the dest dictionary: ``` -$newdict := merge $dest $source +$newdict := merge $dest $source1 $source2 ``` This is a deep merge operation. diff --git a/vendor/github.com/Masterminds/sprig/docs/strings.md b/vendor/github.com/Masterminds/sprig/docs/strings.md index 03b4216d5..029ea0686 100644 --- a/vendor/github.com/Masterminds/sprig/docs/strings.md +++ b/vendor/github.com/Masterminds/sprig/docs/strings.md @@ -239,6 +239,19 @@ indent 4 $lots_of_text The above will indent every line of text by 4 space characters. +## nindent + +The `nindent` function is the same as the indent function, but prepends a new +line to the beginning of the string. This is useful when combined with an +action's trim preceding white space left delimiter, `{{-`. + +``` +nindent 4 $lots_of_text +``` + +The above will indent every line of text by 4 space characters and add a new +line to the beginning. + ## replace Perform simple string replacement. diff --git a/vendor/github.com/Masterminds/sprig/functions.go b/vendor/github.com/Masterminds/sprig/functions.go index c20175b25..555eece30 100644 --- a/vendor/github.com/Masterminds/sprig/functions.go +++ b/vendor/github.com/Masterminds/sprig/functions.go @@ -98,6 +98,8 @@ var genericMap = map[string]interface{}{ "htmlDateInZone": htmlDateInZone, "dateInZone": dateInZone, "dateModify": dateModify, + "ago": dateAgo, + "toDate": toDate, // Strings "abbrev": abbrev, @@ -137,6 +139,7 @@ var genericMap = map[string]interface{}{ "squote": squote, "cat": cat, "indent": indent, + "nindent": nindent, "replace": replace, "plural": plural, "sha256sum": sha256sum, @@ -263,10 +266,10 @@ var genericMap = map[string]interface{}{ "fail": func(msg string) (string, error) { return "", errors.New(msg) }, // Regex - "regexMatch": regexMatch, - "regexFindAll": regexFindAll, - "regexFind": regexFind, - "regexReplaceAll": regexReplaceAll, + "regexMatch": regexMatch, + "regexFindAll": regexFindAll, + "regexFind": regexFind, + "regexReplaceAll": regexReplaceAll, "regexReplaceAllLiteral": regexReplaceAllLiteral, - "regexSplit": regexSplit, + "regexSplit": regexSplit, } diff --git a/vendor/github.com/Masterminds/sprig/strings.go b/vendor/github.com/Masterminds/sprig/strings.go index 69bcd9854..f6afa2ff9 100644 --- a/vendor/github.com/Masterminds/sprig/strings.go +++ b/vendor/github.com/Masterminds/sprig/strings.go @@ -106,6 +106,10 @@ func indent(spaces int, v string) string { return pad + strings.Replace(v, "\n", "\n"+pad, -1) } +func nindent(spaces int, v string) string { + return "\n" + indent(spaces, v) +} + func replace(old, new, src string) string { return strings.Replace(src, old, new, -1) } diff --git a/vendor/github.com/Masterminds/sprig/strings_test.go b/vendor/github.com/Masterminds/sprig/strings_test.go index 742e6d74d..19c497159 100644 --- a/vendor/github.com/Masterminds/sprig/strings_test.go +++ b/vendor/github.com/Masterminds/sprig/strings_test.go @@ -201,6 +201,13 @@ func TestIndent(t *testing.T) { } } +func TestNindent(t *testing.T) { + tpl := `{{nindent 4 "a\nb\nc"}}` + if err := runt(tpl, "\n a\n b\n c"); err != nil { + t.Error(err) + } +} + func TestReplace(t *testing.T) { tpl := `{{"I Am Henry VIII" | replace " " "-"}}` if err := runt(tpl, "I-Am-Henry-VIII"); err != nil { diff --git a/vendor/github.com/aokoli/goutils/.travis.yml b/vendor/github.com/aokoli/goutils/.travis.yml deleted file mode 100644 index 4025e01ec..000000000 --- a/vendor/github.com/aokoli/goutils/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: go - -go: - - 1.6 - - 1.7 - - 1.8 - - tip - -script: - - go test -v - -notifications: - webhooks: - urls: - - https://webhooks.gitter.im/e/06e3328629952dabe3e0 - on_success: change # options: [always|never|change] default: always - on_failure: always # options: [always|never|change] default: always - on_start: never # options: [always|never|change] default: always diff --git a/vendor/github.com/aokoli/goutils/CHANGELOG.md b/vendor/github.com/aokoli/goutils/CHANGELOG.md deleted file mode 100644 index d700ec47f..000000000 --- a/vendor/github.com/aokoli/goutils/CHANGELOG.md +++ /dev/null @@ -1,8 +0,0 @@ -# 1.0.1 (2017-05-31) - -## Fixed -- #21: Fix generation of alphanumeric strings (thanks @dbarranco) - -# 1.0.0 (2014-04-30) - -- Initial release. diff --git a/vendor/github.com/aokoli/goutils/README.md b/vendor/github.com/aokoli/goutils/README.md index 163ffe72a..9d8a42df8 100644 --- a/vendor/github.com/aokoli/goutils/README.md +++ b/vendor/github.com/aokoli/goutils/README.md @@ -1,10 +1,7 @@ GoUtils =========== -[![Stability: Maintenance](https://masterminds.github.io/stability/maintenance.svg)](https://masterminds.github.io/stability/maintenance.html) -[![GoDoc](https://godoc.org/github.com/Masterminds/goutils?status.png)](https://godoc.org/github.com/Masterminds/goutils) [![Build Status](https://travis-ci.org/Masterminds/goutils.svg?branch=master)](https://travis-ci.org/Masterminds/goutils) [![Build status](https://ci.appveyor.com/api/projects/status/sc2b1ew0m7f0aiju?svg=true)](https://ci.appveyor.com/project/mattfarina/goutils) - -GoUtils provides users with utility functions to manipulate strings in various ways. It is a Go implementation of some +GoUtils provides users with utility functions to manipulate strings in various ways. It is a Go implementation of some string manipulation libraries of Java Apache Commons. GoUtils includes the following Java Apache Commons classes: * WordUtils * RandomStringUtils @@ -13,25 +10,25 @@ string manipulation libraries of Java Apache Commons. GoUtils includes the follo ## Installation If you have Go set up on your system, from the GOPATH directory within the command line/terminal, enter this: - go get github.com/Masterminds/goutils - + go get github.com/aokoli/goutils + If you do not have Go set up on your system, please follow the [Go installation directions from the documenation](http://golang.org/doc/install), and then follow the instructions above to install GoUtils. -## Documentation -GoUtils doc is available here: [![GoDoc](https://godoc.org/github.com/Masterminds/goutils?status.png)](https://godoc.org/github.com/Masterminds/goutils) +## Documentation +GoUtils doc is available here: [![GoDoc](https://godoc.org/github.com/aokoli/goutils?status.png)](https://godoc.org/github.com/aokoli/goutils) ## Usage The code snippets below show examples of how to use GoUtils. Some functions return errors while others do not. The first instance below, which does not return an error, is the `Initials` function (located within the `wordutils.go` file). package main - + import ( "fmt" - "github.com/Masterminds/goutils" + "github.com/aokoli/goutils" ) - + func main() { // EXAMPLE 1: A goutils function which returns no errors @@ -41,30 +38,35 @@ The code snippets below show examples of how to use GoUtils. Some functions retu Some functions return errors mainly due to illegal arguements used as parameters. The code example below illustrates how to deal with function that returns an error. In this instance, the function is the `Random` function (located within the `randomstringutils.go` file). package main - + import ( "fmt" - "github.com/Masterminds/goutils" + "github.com/aokoli/goutils" ) - + func main() { // EXAMPLE 2: A goutils function which returns an error rand1, err1 := goutils.Random (-1, 0, 0, true, true) - if err1 != nil { + if err1 != nil { fmt.Println(err1) // Prints out error message because -1 was entered as the first parameter in goutils.Random(...) } else { - fmt.Println(rand1) + fmt.Println(rand1) } } ## License -GoUtils is licensed under the Apache License, Version 2.0. Please check the LICENSE.txt file or visit http://www.apache.org/licenses/LICENSE-2.0 for a copy of the license. +GoUtils is licensed under the Apache License, Version 2.0. Please check the LICENSE.txt file or visit http://www.apache.org/licenses/LICENSE-2.0 for a copy of the license. ## Issue Reporting -Make suggestions or report issues using the Git issue tracker: https://github.com/Masterminds/goutils/issues +Make suggestions or report issues using the Git issue tracker: https://github.com/aokoli/goutils/issues ## Website -* [GoUtils webpage](http://Masterminds.github.io/goutils/) +* [GoUtils webpage](http://aokoli.github.io/goutils/) + +## Mailing List +Contact [okolialex@gmail.com](mailto:okolialex@mail.com) to be added to the mailing list. You will get updates on the +status of the project and the potential direction it will be heading. + diff --git a/vendor/github.com/aokoli/goutils/appveyor.yml b/vendor/github.com/aokoli/goutils/appveyor.yml deleted file mode 100644 index 657564a84..000000000 --- a/vendor/github.com/aokoli/goutils/appveyor.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: build-{build}.{branch} - -clone_folder: C:\gopath\src\github.com\Masterminds\goutils -shallow_clone: true - -environment: - GOPATH: C:\gopath - -platform: - - x64 - -build: off - -install: - - go version - - go env - -test_script: - - go test -v - -deploy: off diff --git a/vendor/github.com/aokoli/goutils/randomstringutils.go b/vendor/github.com/aokoli/goutils/randomstringutils.go index 1364e0caf..db395a0a1 100644 --- a/vendor/github.com/aokoli/goutils/randomstringutils.go +++ b/vendor/github.com/aokoli/goutils/randomstringutils.go @@ -16,17 +16,18 @@ limitations under the License. package goutils + import ( "fmt" + "unicode" "math" "math/rand" - "regexp" "time" - "unicode" ) -// RANDOM provides the time-based seed used to generate random numbers -var RANDOM = rand.New(rand.NewSource(time.Now().UnixNano())) + +// Provides the time-based seed used to generate random #s +var RANDOM = rand.New(rand.NewSource(time.Now().UnixNano())) /* RandomNonAlphaNumeric creates a random string whose length is the number of characters specified. @@ -39,10 +40,11 @@ Returns: string - the random string error - an error stemming from an invalid parameter within underlying function, RandomSeed(...) */ -func RandomNonAlphaNumeric(count int) (string, error) { - return RandomAlphaNumericCustom(count, false, false) +func RandomNonAlphaNumeric (count int) (string, error) { + return RandomAlphaNumericCustom(count, false, false) } + /* RandomAscii creates a random string whose length is the number of characters specified. Characters will be chosen from the set of characters whose ASCII value is between 32 and 126 (inclusive). @@ -55,9 +57,10 @@ Returns: error - an error stemming from an invalid parameter within underlying function, RandomSeed(...) */ func RandomAscii(count int) (string, error) { - return Random(count, 32, 127, false, false) + return Random(count, 32, 127, false, false) } + /* RandomNumeric creates a random string whose length is the number of characters specified. Characters will be chosen from the set of numeric characters. @@ -69,10 +72,11 @@ Returns: string - the random string error - an error stemming from an invalid parameter within underlying function, RandomSeed(...) */ -func RandomNumeric(count int) (string, error) { - return Random(count, 0, 0, false, true) +func RandomNumeric (count int) (string, error) { + return Random(count, 0, 0, false, true) } + /* RandomAlphabetic creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alpha-numeric characters as indicated by the arguments. @@ -86,10 +90,11 @@ Returns: string - the random string error - an error stemming from an invalid parameter within underlying function, RandomSeed(...) */ -func RandomAlphabetic(count int) (string, error) { - return Random(count, 0, 0, true, false) +func RandomAlphabetic (count int) (string, error) { + return Random(count, 0, 0, true, false) } + /* RandomAlphaNumeric creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alpha-numeric characters. @@ -101,25 +106,8 @@ Returns: string - the random string error - an error stemming from an invalid parameter within underlying function, RandomSeed(...) */ -func RandomAlphaNumeric(count int) (string, error) { - RandomString, err := Random(count, 0, 0, true, true) - if err != nil { - return "", fmt.Errorf("Error: %s", err) - } - match, err := regexp.MatchString("([0-9]+)", RandomString) - if err != nil { - panic(err) - } - - if !match { - //Get the position between 0 and the length of the string-1 to insert a random number - position := rand.Intn(count) - //Insert a random number between [0-9] in the position - RandomString = RandomString[:position] + string('0'+rand.Intn(10)) + RandomString[position+1:] - return RandomString, err - } - return RandomString, err - +func RandomAlphaNumeric (count int) (string, error) { + return Random(count, 0, 0, true, true) } /* @@ -133,15 +121,16 @@ Parameters: Returns: string - the random string - error - an error stemming from an invalid parameter within underlying function, RandomSeed(...) + error - an error stemming from an invalid parameter within underlying function, RandomSeed(...) */ -func RandomAlphaNumericCustom(count int, letters bool, numbers bool) (string, error) { - return Random(count, 0, 0, letters, numbers) +func RandomAlphaNumericCustom (count int, letters bool, numbers bool) (string, error) { + return Random(count, 0, 0, letters, numbers) } + /* Random creates a random string based on a variety of options, using default source of randomness. -This method has exactly the same semantics as RandomSeed(int, int, int, bool, bool, []char, *rand.Rand), but +This method has exactly the same semantics as RandomSeed(int, int, int, bool, bool, []char, *rand.Rand), but instead of using an externally supplied source of randomness, it uses the internal *rand.Rand instance. Parameters: @@ -154,16 +143,17 @@ Parameters: Returns: string - the random string - error - an error stemming from an invalid parameter within underlying function, RandomSeed(...) + error - an error stemming from an invalid parameter within underlying function, RandomSeed(...) */ -func Random(count int, start int, end int, letters bool, numbers bool, chars ...rune) (string, error) { - return RandomSeed(count, start, end, letters, numbers, chars, RANDOM) +func Random (count int, start int, end int, letters bool, numbers bool, chars ...rune) (string, error) { + return RandomSeed (count, start, end, letters, numbers, chars, RANDOM) } + /* RandomSeed creates a random string based on a variety of options, using supplied source of randomness. -If the parameters start and end are both 0, start and end are set to ' ' and 'z', the ASCII printable characters, will be used, -unless letters and numbers are both false, in which case, start and end are set to 0 and math.MaxInt32, respectively. +If the parameters start and end are both 0, start and end are set to ' ' and 'z', the ASCII printable characters, will be used, +unless letters and numbers are both false, in which case, start and end are set to 0 and math.MaxInt32, respectively. If chars is not nil, characters stored in chars that are between start and end are chosen. This method accepts a user-supplied *rand.Rand instance to use as a source of randomness. By seeding a single *rand.Rand instance with a fixed seed and using it for each call, the same random sequence of strings can be generated repeatedly and predictably. @@ -179,90 +169,91 @@ Parameters: Returns: string - the random string - error - an error stemming from invalid parameters: if count < 0; or the provided chars array is empty; or end <= start; or end > len(chars) + error - an error stemming from invalid parameters: if count < 0; or the provided chars array is empty; or end <= start; or end > len(chars) */ -func RandomSeed(count int, start int, end int, letters bool, numbers bool, chars []rune, random *rand.Rand) (string, error) { - - if count == 0 { - return "", nil - } else if count < 0 { - err := fmt.Errorf("randomstringutils illegal argument: Requested random string length %v is less than 0.", count) // equiv to err := errors.New("...") - return "", err - } - if chars != nil && len(chars) == 0 { - err := fmt.Errorf("randomstringutils illegal argument: The chars array must not be empty") - return "", err - } - - if start == 0 && end == 0 { - if chars != nil { - end = len(chars) - } else { - if !letters && !numbers { - end = math.MaxInt32 - } else { - end = 'z' + 1 - start = ' ' - } - } - } else { - if end <= start { - err := fmt.Errorf("randomstringutils illegal argument: Parameter end (%v) must be greater than start (%v)", end, start) - return "", err - } - - if chars != nil && end > len(chars) { - err := fmt.Errorf("randomstringutils illegal argument: Parameter end (%v) cannot be greater than len(chars) (%v)", end, len(chars)) - return "", err - } - } - - buffer := make([]rune, count) - gap := end - start - - // high-surrogates range, (\uD800-\uDBFF) = 55296 - 56319 - // low-surrogates range, (\uDC00-\uDFFF) = 56320 - 57343 - - for count != 0 { - count-- - var ch rune - if chars == nil { - ch = rune(random.Intn(gap) + start) - } else { - ch = chars[random.Intn(gap)+start] - } - - if letters && unicode.IsLetter(ch) || numbers && unicode.IsDigit(ch) || !letters && !numbers { - if ch >= 56320 && ch <= 57343 { // low surrogate range - if count == 0 { - count++ - } else { - // Insert low surrogate - buffer[count] = ch - count-- - // Insert high surrogate - buffer[count] = rune(55296 + random.Intn(128)) - } - } else if ch >= 55296 && ch <= 56191 { // High surrogates range (Partial) - if count == 0 { - count++ - } else { - // Insert low surrogate - buffer[count] = rune(56320 + random.Intn(128)) - count-- - // Insert high surrogate - buffer[count] = ch - } - } else if ch >= 56192 && ch <= 56319 { - // private high surrogate, skip it - count++ - } else { - // not one of the surrogates* - buffer[count] = ch - } - } else { - count++ - } - } - return string(buffer), nil +func RandomSeed (count int, start int, end int, letters bool, numbers bool, chars []rune, random *rand.Rand) (string, error) { + + if count == 0 { + return "", nil + } else if count < 0 { + err := fmt.Errorf("randomstringutils illegal argument: Requested random string length %v is less than 0.", count) // equiv to err := errors.New("...") + return "", err + } + if chars != nil && len(chars) == 0 { + err := fmt.Errorf("randomstringutils illegal argument: The chars array must not be empty") + return "", err + } + + if start == 0 && end == 0 { + if chars != nil { + end = len(chars) + } else { + if !letters && !numbers { + end = math.MaxInt32 + } else { + end = 'z' + 1 + start = ' ' + } + } + } else { + if end <= start { + err := fmt.Errorf("randomstringutils illegal argument: Parameter end (%v) must be greater than start (%v)", end, start) + return "", err + } + + if chars != nil && end > len(chars) { + err := fmt.Errorf("randomstringutils illegal argument: Parameter end (%v) cannot be greater than len(chars) (%v)", end, len(chars)) + return "", err + } + } + + buffer := make([]rune, count) + gap := end - start + + + // high-surrogates range, (\uD800-\uDBFF) = 55296 - 56319 + // low-surrogates range, (\uDC00-\uDFFF) = 56320 - 57343 + + for count != 0 { + count-- + var ch rune + if chars == nil { + ch = rune(random.Intn(gap) + start) + } else { + ch = chars[random.Intn(gap) + start] + } + + if letters && unicode.IsLetter(ch) || numbers && unicode.IsDigit(ch) || !letters && !numbers { + if ch >= 56320 && ch <= 57343 { // low surrogate range + if count == 0 { + count++ + } else { + // Insert low surrogate + buffer[count] = ch + count-- + // Insert high surrogate + buffer[count] = rune(55296 + random.Intn(128)) + } + } else if ch >= 55296 && ch <= 56191 { // High surrogates range (Partial) + if count == 0 { + count++ + } else { + // Insert low surrogate + buffer[count] = rune(56320 + random.Intn(128)) + count-- + // Insert high surrogate + buffer[count] = ch + } + } else if ch >= 56192 && ch <= 56319 { + // private high surrogate, skip it + count++ + } else { + // not one of the surrogates* + buffer[count] = ch + } + } else { + count++ + } + } + return string(buffer), nil } diff --git a/vendor/github.com/aokoli/goutils/randomstringutils_test.go b/vendor/github.com/aokoli/goutils/randomstringutils_test.go index b990654a1..dba45e9a0 100644 --- a/vendor/github.com/aokoli/goutils/randomstringutils_test.go +++ b/vendor/github.com/aokoli/goutils/randomstringutils_test.go @@ -1,75 +1,92 @@ + + + + + + + + + + package goutils import ( - "fmt" - "math/rand" - "testing" +"testing" +"fmt" +"math/rand" ) // ****************************** TESTS ******************************************** func TestRandomSeed(t *testing.T) { + + // count, start, end, letters, numbers := 5, 0, 0, true, true random := rand.New(rand.NewSource(10)) out := "3ip9v" // Test 1: Simulating RandomAlphaNumeric(count int) - if x, _ := RandomSeed(5, 0, 0, true, true, nil, random); x != out { + if x, _ := RandomSeed (5, 0, 0, true, true, nil, random); x != out { t.Errorf("RandomSeed(%v, %v, %v, %v, %v, %v, %v) = %v, want %v", 5, 0, 0, true, true, nil, random, x, out) } // Test 2: Simulating RandomAlphabetic(count int) out = "MBrbj" - if x, _ := RandomSeed(5, 0, 0, true, false, nil, random); x != out { + if x, _ := RandomSeed (5, 0, 0, true, false, nil, random); x != out { t.Errorf("RandomSeed(%v, %v, %v, %v, %v, %v, %v) = %v, want %v", 5, 0, 0, true, false, nil, random, x, out) } + // Test 3: Simulating RandomNumeric(count int) out = "88935" - if x, _ := RandomSeed(5, 0, 0, false, true, nil, random); x != out { + if x, _ := RandomSeed (5, 0, 0, false, true, nil, random); x != out { t.Errorf("RandomSeed(%v, %v, %v, %v, %v, %v, %v) = %v, want %v", 5, 0, 0, false, true, nil, random, x, out) } + // Test 4: Simulating RandomAscii(count int) out = "H_I;E" - if x, _ := RandomSeed(5, 32, 127, false, false, nil, random); x != out { + if x, _ := RandomSeed (5, 32, 127, false, false, nil, random); x != out { t.Errorf("RandomSeed(%v, %v, %v, %v, %v, %v, %v) = %v, want %v", 5, 32, 127, false, false, nil, random, x, out) } + // Test 5: Simulating RandomSeed(...) with custom chars - chars := []rune{'1', '2', '3', 'a', 'b', 'c'} + chars := []rune {'1','2','3','a','b','c'} out = "2b2ca" - if x, _ := RandomSeed(5, 0, 0, false, false, chars, random); x != out { + if x, _ := RandomSeed (5, 0, 0, false, false, chars, random); x != out { t.Errorf("RandomSeed(%v, %v, %v, %v, %v, %v, %v) = %v, want %v", 5, 0, 0, false, false, chars, random, x, out) } } + // ****************************** EXAMPLES ******************************************** + func ExampleRandomSeed() { - var seed int64 = 10 // If you change this seed #, the random sequence below will change - random := rand.New(rand.NewSource(seed)) - chars := []rune{'1', '2', '3', 'a', 'b', 'c'} + var seed int64 = 10 // If you change this seed #, the random sequence below will change + random := rand.New(rand.NewSource(seed)) + chars := []rune {'1','2','3','a','b','c'} - rand1, _ := RandomSeed(5, 0, 0, true, true, nil, random) // RandomAlphaNumeric (Alphabets and numbers possible) - rand2, _ := RandomSeed(5, 0, 0, true, false, nil, random) // RandomAlphabetic (Only alphabets) - rand3, _ := RandomSeed(5, 0, 0, false, true, nil, random) // RandomNumeric (Only numbers) - rand4, _ := RandomSeed(5, 32, 127, false, false, nil, random) // RandomAscii (Alphabets, numbers, and other ASCII chars) - rand5, _ := RandomSeed(5, 0, 0, true, true, chars, random) // RandomSeed with custom characters + rand1, _ := RandomSeed (5, 0, 0, true, true, nil, random) // RandomAlphaNumeric (Alphabets and numbers possible) + rand2, _ := RandomSeed (5, 0, 0, true, false, nil, random) // RandomAlphabetic (Only alphabets) + rand3, _ := RandomSeed (5, 0, 0, false, true, nil, random) // RandomNumeric (Only numbers) + rand4, _ := RandomSeed (5, 32, 127, false, false, nil, random) // RandomAscii (Alphabets, numbers, and other ASCII chars) + rand5, _ := RandomSeed (5, 0, 0, true, true, chars, random) // RandomSeed with custom characters fmt.Println(rand1) fmt.Println(rand2) fmt.Println(rand3) fmt.Println(rand4) fmt.Println(rand5) - // Output: + // Output: // 3ip9v // MBrbj // 88935 diff --git a/vendor/github.com/aokoli/goutils/stringutils.go b/vendor/github.com/aokoli/goutils/stringutils.go index 5037c4516..6a956f25b 100644 --- a/vendor/github.com/aokoli/goutils/stringutils.go +++ b/vendor/github.com/aokoli/goutils/stringutils.go @@ -16,25 +16,27 @@ limitations under the License. package goutils + import ( - "bytes" "fmt" + "unicode" + "bytes" "strings" - "unicode" ) // Typically returned by functions where a searched item cannot be found -const INDEX_NOT_FOUND = -1 +const INDEX_NOT_FOUND = -1 + /* Abbreviate abbreviates a string using ellipses. This will turn the string "Now is the time for all good men" into "Now is the time for..." -Specifically, the algorithm is as follows: +Specifically, the algorithm is as follows: - - If str is less than maxWidth characters long, return it. - - Else abbreviate it to (str[0:maxWidth - 3] + "..."). - - If maxWidth is less than 4, return an illegal argument error. - - In no case will it return a string of length greater than maxWidth. + - If str is less than maxWidth characters long, return it. + - Else abbreviate it to (str[0:maxWidth - 3] + "..."). + - If maxWidth is less than 4, return an illegal argument error. + - In no case will it return a string of length greater than maxWidth. Parameters: str - the string to check @@ -44,14 +46,15 @@ Returns: string - abbreviated string error - if the width is too small */ -func Abbreviate(str string, maxWidth int) (string, error) { +func Abbreviate (str string, maxWidth int) (string, error) { return AbbreviateFull(str, 0, maxWidth) } + /* AbbreviateFull abbreviates a string using ellipses. This will turn the string "Now is the time for all good men" into "...is the time for..." -This function works like Abbreviate(string, int), but allows you to specify a "left edge" offset. Note that this left edge is not -necessarily going to be the leftmost character in the result, or the first character following the ellipses, but it will appear +This function works like Abbreviate(string, int), but allows you to specify a "left edge" offset. Note that this left edge is not +necessarily going to be the leftmost character in the result, or the first character following the ellipses, but it will appear somewhere in the result. In no case will it return a string of length greater than maxWidth. @@ -64,38 +67,39 @@ Returns: string - abbreviated string error - if the width is too small */ -func AbbreviateFull(str string, offset int, maxWidth int) (string, error) { - if str == "" { - return "", nil - } - if maxWidth < 4 { - err := fmt.Errorf("stringutils illegal argument: Minimum abbreviation width is 4") - return "", err - } - if len(str) <= maxWidth { - return str, nil - } - if offset > len(str) { - offset = len(str) - } - if len(str)-offset < (maxWidth - 3) { // 15 - 5 < 10 - 3 = 10 < 7 - offset = len(str) - (maxWidth - 3) - } - abrevMarker := "..." - if offset <= 4 { - return str[0:maxWidth-3] + abrevMarker, nil // str.substring(0, maxWidth - 3) + abrevMarker; - } - if maxWidth < 7 { - err := fmt.Errorf("stringutils illegal argument: Minimum abbreviation width with offset is 7") - return "", err - } - if (offset + maxWidth - 3) < len(str) { // 5 + (10-3) < 15 = 12 < 15 - abrevStr, _ := Abbreviate(str[offset:len(str)], (maxWidth - 3)) - return abrevMarker + abrevStr, nil // abrevMarker + abbreviate(str.substring(offset), maxWidth - 3); - } - return abrevMarker + str[(len(str)-(maxWidth-3)):len(str)], nil // abrevMarker + str.substring(str.length() - (maxWidth - 3)); +func AbbreviateFull (str string, offset int, maxWidth int) (string, error) { + if str == "" { + return "", nil + } + if maxWidth < 4 { + err := fmt.Errorf("stringutils illegal argument: Minimum abbreviation width is 4") + return "", err + } + if len(str) <= maxWidth { + return str, nil + } + if offset > len(str) { + offset = len(str) + } + if len(str) - offset < (maxWidth - 3) { // 15 - 5 < 10 - 3 = 10 < 7 + offset = len(str) - (maxWidth - 3) + } + abrevMarker := "..." + if offset <= 4 { + return str[0:maxWidth - 3] + abrevMarker, nil// str.substring(0, maxWidth - 3) + abrevMarker; + } + if maxWidth < 7 { + err := fmt.Errorf("stringutils illegal argument: Minimum abbreviation width with offset is 7") + return "", err + } + if (offset + maxWidth - 3) < len(str) { // 5 + (10-3) < 15 = 12 < 15 + abrevStr, _ := Abbreviate(str[offset:len(str)], (maxWidth - 3)) + return abrevMarker + abrevStr, nil// abrevMarker + abbreviate(str.substring(offset), maxWidth - 3); + } + return abrevMarker + str[(len(str) - (maxWidth - 3)):len(str)], nil // abrevMarker + str.substring(str.length() - (maxWidth - 3)); } + /* DeleteWhiteSpace deletes all whitespaces from a string as defined by unicode.IsSpace(rune). It returns the string without whitespaces. @@ -107,25 +111,26 @@ Returns: the string without whitespaces */ func DeleteWhiteSpace(str string) string { - if str == "" { - return str - } - sz := len(str) - var chs bytes.Buffer - count := 0 - for i := 0; i < sz; i++ { - ch := rune(str[i]) - if !unicode.IsSpace(ch) { - chs.WriteRune(ch) - count++ - } - } - if count == sz { - return str - } - return chs.String() + if str == "" { + return str + } + sz := len(str) + var chs bytes.Buffer + count := 0 + for i := 0; i < sz; i++ { + ch := rune(str[i]) + if !unicode.IsSpace(ch) { + chs.WriteRune(ch) + count++ + } + } + if count == sz { + return str + } + return chs.String() } + /* IndexOfDifference compares two strings, and returns the index at which the strings begin to differ. @@ -137,24 +142,26 @@ Returns: the index where str1 and str2 begin to differ; -1 if they are equal */ func IndexOfDifference(str1 string, str2 string) int { - if str1 == str2 { - return INDEX_NOT_FOUND - } - if IsEmpty(str1) || IsEmpty(str2) { - return 0 - } - var i int - for i = 0; i < len(str1) && i < len(str2); i++ { - if rune(str1[i]) != rune(str2[i]) { - break - } - } - if i < len(str2) || i < len(str1) { - return i - } - return INDEX_NOT_FOUND + if str1 == str2 { + return INDEX_NOT_FOUND + } + if IsEmpty(str1) || IsEmpty(str2) { + return 0 + } + var i int; + for i = 0; i < len(str1) && i < len(str2); i++ { + if rune(str1[i]) != rune(str2[i]) { + break + } + } + if i < len(str2) || i < len(str1) { + return i + } + return INDEX_NOT_FOUND } + + /* IsBlank checks if a string is whitespace or empty (""). Observe the following behavior: @@ -162,7 +169,7 @@ IsBlank checks if a string is whitespace or empty (""). Observe the following be goutils.IsBlank(" ") = true goutils.IsBlank("bob") = false goutils.IsBlank(" bob ") = false - + Parameter: str - the string to check @@ -170,23 +177,24 @@ Returns: true - if the string is whitespace or empty ("") */ func IsBlank(str string) bool { - strLen := len(str) - if str == "" || strLen == 0 { - return true - } - for i := 0; i < strLen; i++ { - if unicode.IsSpace(rune(str[i])) == false { - return false - } - } - return true + strLen := len(str) + if str == "" || strLen == 0 { + return true + } + for i := 0; i < strLen; i++ { + if unicode.IsSpace(rune(str[i])) == false { + return false + } + } + return true } -/* -IndexOf returns the index of the first instance of sub in str, with the search beginning from the + +/* +IndexOf returns the index of the first instance of sub in str, with the search beginning from the index start point specified. -1 is returned if sub is not present in str. -An empty string ("") will return -1 (INDEX_NOT_FOUND). A negative start position is treated as zero. +An empty string ("") will return -1 (INDEX_NOT_FOUND). A negative start position is treated as zero. A start position greater than the string length returns -1. Parameters: @@ -199,26 +207,26 @@ Returns: */ func IndexOf(str string, sub string, start int) int { - if start < 0 { - start = 0 - } + if (start < 0) { + start = 0 + } - if len(str) < start { - return INDEX_NOT_FOUND - } + if len(str) < start { + return INDEX_NOT_FOUND + } - if IsEmpty(str) || IsEmpty(sub) { - return INDEX_NOT_FOUND - } + if IsEmpty(str) || IsEmpty(sub) { + return INDEX_NOT_FOUND + } - partialIndex := strings.Index(str[start:len(str)], sub) - if partialIndex == -1 { - return INDEX_NOT_FOUND - } - return partialIndex + start + partialIndex := strings.Index(str[start:len(str)], sub) + if partialIndex == -1 { + return INDEX_NOT_FOUND + } + return partialIndex + start } // IsEmpty checks if a string is empty (""). Returns true if empty, and false otherwise. func IsEmpty(str string) bool { - return len(str) == 0 + return len(str) == 0 } diff --git a/vendor/github.com/aokoli/goutils/stringutils_test.go b/vendor/github.com/aokoli/goutils/stringutils_test.go index dae93132a..27482b42c 100644 --- a/vendor/github.com/aokoli/goutils/stringutils_test.go +++ b/vendor/github.com/aokoli/goutils/stringutils_test.go @@ -1,8 +1,8 @@ package goutils import ( - "fmt" - "testing" +"testing" +"fmt" ) // ****************************** TESTS ******************************************** @@ -26,6 +26,7 @@ func TestAbbreviate(t *testing.T) { t.Errorf("Abbreviate(%v, %v) = %v, want %v", in, maxWidth, x, out) } + // Test 3 out = "a..." maxWidth = 4 @@ -35,6 +36,7 @@ func TestAbbreviate(t *testing.T) { } } + func TestAbbreviateFull(t *testing.T) { // Test 1 @@ -56,16 +58,20 @@ func TestAbbreviateFull(t *testing.T) { t.Errorf("AbbreviateFull(%v, %v, %v) = %v, want %v", in, offset, maxWidth, x, out) } + // Test 3 out = "...ijklmno" offset = 12 maxWidth = 10 + if x, _ := AbbreviateFull(in, offset, maxWidth); x != out { t.Errorf("AbbreviateFull(%v, %v, %v) = %v, want %v", in, offset, maxWidth, x, out) } } + + func TestIndexOf(t *testing.T) { // Test 1 @@ -94,6 +100,7 @@ func TestIndexOf(t *testing.T) { t.Errorf("IndexOf(%v, %v, %v) = %v, want %v", str, sub, start, x, out) } + // Test 4 sub = "z" out = -1 @@ -102,7 +109,8 @@ func TestIndexOf(t *testing.T) { t.Errorf("IndexOf(%v, %v, %v) = %v, want %v", str, sub, start, x, out) } -} +} + func TestIsBlank(t *testing.T) { @@ -129,7 +137,9 @@ func TestIsBlank(t *testing.T) { if x := IsBlank(str); x != out { t.Errorf("IndexOf(%v) = %v, want %v", str, x, out) } -} +} + + func TestDeleteWhiteSpace(t *testing.T) { @@ -148,7 +158,8 @@ func TestDeleteWhiteSpace(t *testing.T) { if x := DeleteWhiteSpace(str); x != out { t.Errorf("IndexOf(%v) = %v, want %v", str, x, out) } -} +} + func TestIndexOfDifference(t *testing.T) { @@ -159,7 +170,8 @@ func TestIndexOfDifference(t *testing.T) { if x := IndexOfDifference(str1, str2); x != out { t.Errorf("IndexOfDifference(%v, %v) = %v, want %v", str1, str2, x, out) } -} +} + // ****************************** EXAMPLES ******************************************** @@ -172,12 +184,13 @@ func ExampleAbbreviate() { out4, _ := Abbreviate(str, 4) _, err1 := Abbreviate(str, 3) + fmt.Println(out1) fmt.Println(out2) fmt.Println(out3) fmt.Println(out4) fmt.Println(err1) - // Output: + // Output: // abc... // abcdefg // abcdefg @@ -185,6 +198,7 @@ func ExampleAbbreviate() { // stringutils illegal argument: Minimum abbreviation width is 4 } + func ExampleAbbreviateFull() { str := "abcdefghijklmno" @@ -201,6 +215,7 @@ func ExampleAbbreviateFull() { _, err1 := AbbreviateFull(str2, 0, 3) _, err2 := AbbreviateFull(str2, 5, 6) + fmt.Println(out1) fmt.Println(out2) fmt.Println(out3) @@ -212,7 +227,7 @@ func ExampleAbbreviateFull() { fmt.Println(out9) fmt.Println(err1) fmt.Println(err2) - // Output: + // Output: // abcdefg... // abcdefg... // abcdefg... @@ -223,9 +238,10 @@ func ExampleAbbreviateFull() { // ...ijklmno // ...ijklmno // stringutils illegal argument: Minimum abbreviation width is 4 - // stringutils illegal argument: Minimum abbreviation width with offset is 7 + // stringutils illegal argument: Minimum abbreviation width with offset is 7 } + func ExampleIsBlank() { out1 := IsBlank("") @@ -237,13 +253,14 @@ func ExampleIsBlank() { fmt.Println(out2) fmt.Println(out3) fmt.Println(out4) - // Output: + // Output: // true // true // false // false } + func ExampleDeleteWhiteSpace() { out1 := DeleteWhiteSpace(" ") @@ -255,17 +272,18 @@ func ExampleDeleteWhiteSpace() { fmt.Println(out2) fmt.Println(out3) fmt.Println(out4) - // Output: - // + // Output: + // // bob // bob // bob } + func ExampleIndexOf() { str := "abcdefgehije" - out1 := IndexOf(str, "e", 0) + out1 := IndexOf(str, "e", 0) out2 := IndexOf(str, "e", 5) out3 := IndexOf(str, "e", 8) out4 := IndexOf(str, "eh", 0) @@ -280,7 +298,7 @@ func ExampleIndexOf() { fmt.Println(out5) fmt.Println(out6) fmt.Println(out7) - // Output: + // Output: // 4 // 7 // 11 @@ -289,10 +307,12 @@ func ExampleIndexOf() { // -1 // -1 } + + func ExampleIndexOfDifference() { - out1 := IndexOfDifference("abc", "abc") + out1 := IndexOfDifference("abc", "abc") out2 := IndexOfDifference("ab", "abxyz") out3 := IndexOfDifference("", "abc") out4 := IndexOfDifference("abcde", "abxyz") @@ -301,7 +321,7 @@ func ExampleIndexOfDifference() { fmt.Println(out2) fmt.Println(out3) fmt.Println(out4) - // Output: + // Output: // -1 // 2 // 0 diff --git a/vendor/github.com/aokoli/goutils/wordutils.go b/vendor/github.com/aokoli/goutils/wordutils.go index e92dd3990..872964af0 100644 --- a/vendor/github.com/aokoli/goutils/wordutils.go +++ b/vendor/github.com/aokoli/goutils/wordutils.go @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -/* +/* Package goutils provides utility functions to manipulate strings in various ways. -The code snippets below show examples of how to use goutils. Some functions return +The code snippets below show examples of how to use goutils. Some functions return errors while others do not, so usage would vary as a result. Example: @@ -36,21 +36,21 @@ Example: // EXAMPLE 2: A goutils function which returns an error - rand1, err1 := goutils.Random (-1, 0, 0, true, true) + rand1, err1 := goutils.Random (-1, 0, 0, true, true) - if err1 != nil { + if err1 != nil { fmt.Println(err1) // Prints out error message because -1 was entered as the first parameter in goutils.Random(...) } else { - fmt.Println(rand1) + fmt.Println(rand1) } } */ package goutils import ( - "bytes" + "bytes" "strings" - "unicode" + "unicode" ) // VERSION indicates the current version of goutils @@ -68,8 +68,8 @@ Parameters: Returns: a line with newlines inserted */ -func Wrap(str string, wrapLength int) string { - return WrapCustom(str, wrapLength, "", false) +func Wrap (str string, wrapLength int) string { + return WrapCustom (str, wrapLength, "", false) } /* @@ -85,74 +85,75 @@ Parameters: Returns: a line with newlines inserted */ -func WrapCustom(str string, wrapLength int, newLineStr string, wrapLongWords bool) string { +func WrapCustom (str string, wrapLength int, newLineStr string, wrapLongWords bool) string { if str == "" { return "" } if newLineStr == "" { - newLineStr = "\n" // TODO Assumes "\n" is seperator. Explore SystemUtils.LINE_SEPARATOR from Apache Commons + newLineStr = "\n" // TODO Assumes "\n" is seperator. Explore SystemUtils.LINE_SEPARATOR from Apache Commons } if wrapLength < 1 { wrapLength = 1 } - inputLineLength := len(str) - offset := 0 - - var wrappedLine bytes.Buffer + inputLineLength := len(str) + offset := 0 - for inputLineLength-offset > wrapLength { + var wrappedLine bytes.Buffer - if rune(str[offset]) == ' ' { + for inputLineLength-offset > wrapLength { + + if rune(str[offset]) == ' ' { offset++ continue } end := wrapLength + offset + 1 - spaceToWrapAt := strings.LastIndex(str[offset:end], " ") + offset + spaceToWrapAt := strings.LastIndex(str[offset:end], " ") + offset - if spaceToWrapAt >= offset { + if spaceToWrapAt >= offset { // normal word (not longer than wrapLength) - wrappedLine.WriteString(str[offset:spaceToWrapAt]) - wrappedLine.WriteString(newLineStr) + wrappedLine.WriteString(str[offset:spaceToWrapAt]) + wrappedLine.WriteString(newLineStr) offset = spaceToWrapAt + 1 - } else { - // long word or URL - if wrapLongWords { - end := wrapLength + offset - // long words are wrapped one line at a time - wrappedLine.WriteString(str[offset:end]) - wrappedLine.WriteString(newLineStr) - offset += wrapLength - } else { - // long words aren't wrapped, just extended beyond limit - end := wrapLength + offset - spaceToWrapAt = strings.IndexRune(str[end:len(str)], ' ') + end - if spaceToWrapAt >= 0 { - wrappedLine.WriteString(str[offset:spaceToWrapAt]) - wrappedLine.WriteString(newLineStr) - offset = spaceToWrapAt + 1 - } else { - wrappedLine.WriteString(str[offset:len(str)]) - offset = inputLineLength - } - } + } else { + // long word or URL + if wrapLongWords { + end := wrapLength + offset + // long words are wrapped one line at a time + wrappedLine.WriteString(str[offset:end]) + wrappedLine.WriteString(newLineStr) + offset += wrapLength + } else { + // long words aren't wrapped, just extended beyond limit + end := wrapLength + offset + spaceToWrapAt = strings.IndexRune(str[end:len(str)], ' ') + end + if spaceToWrapAt >= 0 { + wrappedLine.WriteString(str[offset:spaceToWrapAt]) + wrappedLine.WriteString(newLineStr) + offset = spaceToWrapAt + 1 + } else { + wrappedLine.WriteString(str[offset:len(str)]) + offset = inputLineLength + } + } } } - wrappedLine.WriteString(str[offset:len(str)]) + wrappedLine.WriteString(str[offset:len(str)]) - return wrappedLine.String() + return wrappedLine.String() } + /* -Capitalize capitalizes all the delimiter separated words in a string. Only the first letter of each word is changed. +Capitalize capitalizes all the delimiter separated words in a string. Only the first letter of each word is changed. To convert the rest of each word to lowercase at the same time, use CapitalizeFully(str string, delimiters ...rune). -The delimiters represent a set of characters understood to separate words. The first string character -and the first non-delimiter character after a delimiter will be capitalized. A "" input string returns "". +The delimiters represent a set of characters understood to separate words. The first string character +and the first non-delimiter character after a delimiter will be capitalized. A "" input string returns "". Capitalization uses the Unicode title case, normally equivalent to upper case. Parameters: @@ -162,39 +163,41 @@ Parameters: Returns: capitalized string */ -func Capitalize(str string, delimiters ...rune) string { +func Capitalize (str string, delimiters ...rune) string { var delimLen int - - if delimiters == nil { + + if delimiters == nil { delimLen = -1 } else { delimLen = len(delimiters) } - if str == "" || delimLen == 0 { - return str - } + if str == "" || delimLen == 0 { + return str; + } - buffer := []rune(str) - capitalizeNext := true - for i := 0; i < len(buffer); i++ { - ch := buffer[i] - if isDelimiter(ch, delimiters...) { - capitalizeNext = true - } else if capitalizeNext { - buffer[i] = unicode.ToTitle(ch) - capitalizeNext = false - } - } - return string(buffer) + buffer := []rune(str) + capitalizeNext := true + for i := 0; i < len(buffer); i++ { + ch := buffer[i] + if isDelimiter(ch, delimiters...) { + capitalizeNext = true + } else if capitalizeNext { + buffer[i] = unicode.ToTitle(ch) + capitalizeNext = false + } + } + return string(buffer) } + + /* -CapitalizeFully converts all the delimiter separated words in a string into capitalized words, that is each word is made up of a -titlecase character and then a series of lowercase characters. The delimiters represent a set of characters understood -to separate words. The first string character and the first non-delimiter character after a delimiter will be capitalized. +CapitalizeFully converts all the delimiter separated words in a string into capitalized words, that is each word is made up of a +titlecase character and then a series of lowercase characters. The delimiters represent a set of characters understood +to separate words. The first string character and the first non-delimiter character after a delimiter will be capitalized. Capitalization uses the Unicode title case, normally equivalent to upper case. Parameters: @@ -204,27 +207,29 @@ Parameters: Returns: capitalized string */ -func CapitalizeFully(str string, delimiters ...rune) string { +func CapitalizeFully (str string, delimiters ...rune) string { - var delimLen int + var delimLen int - if delimiters == nil { - delimLen = -1 - } else { + if delimiters == nil { + delimLen = -1 + } else { delimLen = len(delimiters) } - if str == "" || delimLen == 0 { - return str - } - str = strings.ToLower(str) - return Capitalize(str, delimiters...) + + if str == "" || delimLen == 0 { + return str; + } + str = strings.ToLower(str) + return Capitalize(str, delimiters...); } + /* Uncapitalize uncapitalizes all the whitespace separated words in a string. Only the first letter of each word is changed. -The delimiters represent a set of characters understood to separate words. The first string character and the first non-delimiter -character after a delimiter will be uncapitalized. Whitespace is defined by unicode.IsSpace(char). +The delimiters represent a set of characters understood to separate words. The first string character and the first non-delimiter +character after a delimiter will be uncapitalized. Whitespace is defined by unicode.IsSpace(char). Parameters: str - the string to uncapitalize fully @@ -233,45 +238,46 @@ Parameters: Returns: uncapitalized string */ -func Uncapitalize(str string, delimiters ...rune) string { +func Uncapitalize (str string, delimiters ...rune) string { var delimLen int - - if delimiters == nil { + + if delimiters == nil { delimLen = -1 } else { delimLen = len(delimiters) } - if str == "" || delimLen == 0 { - return str - } + if str == "" || delimLen == 0 { + return str; + } - buffer := []rune(str) - uncapitalizeNext := true // TODO Always makes capitalize/un apply to first char. - for i := 0; i < len(buffer); i++ { - ch := buffer[i] - if isDelimiter(ch, delimiters...) { - uncapitalizeNext = true - } else if uncapitalizeNext { - buffer[i] = unicode.ToLower(ch) - uncapitalizeNext = false - } - } - return string(buffer) + buffer := []rune(str) + uncapitalizeNext := true // TODO Always makes capitalize/un apply to first char. + for i := 0; i < len(buffer); i++ { + ch := buffer[i] + if isDelimiter(ch, delimiters...) { + uncapitalizeNext = true + } else if uncapitalizeNext { + buffer[i] = unicode.ToLower(ch) + uncapitalizeNext = false + } + } + return string(buffer) } + /* SwapCase swaps the case of a string using a word based algorithm. Conversion algorithm: - Upper case character converts to Lower case - Title case character converts to Lower case - Lower case character after Whitespace or at start converts to Title case - Other Lower case character converts to Upper case + Upper case character converts to Lower case + Title case character converts to Lower case + Lower case character after Whitespace or at start converts to Title case + Other Lower case character converts to Upper case Whitespace is defined by unicode.IsSpace(char). - + Parameters: str - the string to swap case @@ -279,38 +285,39 @@ Returns: the changed string */ func SwapCase(str string) string { - if str == "" { - return str - } - buffer := []rune(str) - - whitespace := true - - for i := 0; i < len(buffer); i++ { - ch := buffer[i] - if unicode.IsUpper(ch) { - buffer[i] = unicode.ToLower(ch) - whitespace = false - } else if unicode.IsTitle(ch) { - buffer[i] = unicode.ToLower(ch) - whitespace = false - } else if unicode.IsLower(ch) { - if whitespace { - buffer[i] = unicode.ToTitle(ch) - whitespace = false - } else { - buffer[i] = unicode.ToUpper(ch) - } - } else { - whitespace = unicode.IsSpace(ch) - } - } - return string(buffer) + if str == "" { + return str + } + buffer := []rune(str) + + whitespace := true + + for i := 0; i < len(buffer); i++ { + ch := buffer[i] + if unicode.IsUpper(ch) { + buffer[i] = unicode.ToLower(ch) + whitespace = false + } else if unicode.IsTitle(ch) { + buffer[i] = unicode.ToLower(ch) + whitespace = false + } else if unicode.IsLower(ch) { + if whitespace { + buffer[i] = unicode.ToTitle(ch) + whitespace = false + } else { + buffer[i] = unicode.ToUpper(ch) + } + } else { + whitespace = unicode.IsSpace(ch) + } + } + return string(buffer); } + /* -Initials extracts the initial letters from each word in the string. The first letter of the string and all first -letters after the defined delimiters are returned as a new string. Their case is not changed. If the delimiters +Initials extracts the initial letters from each word in the string. The first letter of the string and all first +letters after the defined delimiters are returned as a new string. Their case is not changed. If the delimiters parameter is excluded, then Whitespace is used. Whitespace is defined by unicode.IsSpacea(char). An empty delimiter array returns an empty string. Parameters: @@ -320,37 +327,39 @@ Returns: string of initial letters */ func Initials(str string, delimiters ...rune) string { - if str == "" { - return str - } - if delimiters != nil && len(delimiters) == 0 { - return "" - } - strLen := len(str) - var buf bytes.Buffer - lastWasGap := true - for i := 0; i < strLen; i++ { - ch := rune(str[i]) - - if isDelimiter(ch, delimiters...) { - lastWasGap = true - } else if lastWasGap { - buf.WriteRune(ch) - lastWasGap = false - } - } - return buf.String() -} + if str == "" { + return str + } + if delimiters != nil && len(delimiters) == 0 { + return "" + } + strLen := len(str) + var buf bytes.Buffer + lastWasGap := true + for i := 0; i < strLen; i++ { + ch := rune(str[i]) + + if isDelimiter(ch, delimiters...) { + lastWasGap = true + } else if lastWasGap { + buf.WriteRune(ch) + lastWasGap = false + } + } + return buf.String() + } + + -// private function (lower case func name) + // private function (lower case func name) func isDelimiter(ch rune, delimiters ...rune) bool { - if delimiters == nil { - return unicode.IsSpace(ch) - } - for _, delimiter := range delimiters { - if ch == delimiter { - return true - } - } - return false -} + if delimiters == nil { + return unicode.IsSpace(ch) + } + for _, delimiter := range delimiters { + if ch == delimiter { + return true + } + } + return false +} \ No newline at end of file diff --git a/vendor/github.com/aokoli/goutils/wordutils_test.go b/vendor/github.com/aokoli/goutils/wordutils_test.go index 377d9439c..632eb73e9 100644 --- a/vendor/github.com/aokoli/goutils/wordutils_test.go +++ b/vendor/github.com/aokoli/goutils/wordutils_test.go @@ -1,8 +1,8 @@ package goutils import ( - "fmt" - "testing" +"testing" +"fmt" ) // ****************************** TESTS ******************************************** @@ -18,6 +18,7 @@ func TestWrapNormalWord(t *testing.T) { } } + func TestWrapCustomLongWordFalse(t *testing.T) { in := "BobManuelBob Bob" @@ -31,6 +32,7 @@ func TestWrapCustomLongWordFalse(t *testing.T) { } } + func TestWrapCustomLongWordTrue(t *testing.T) { in := "BobManuelBob Bob" @@ -44,86 +46,96 @@ func TestWrapCustomLongWordTrue(t *testing.T) { } } + func TestCapitalize(t *testing.T) { + // Test 1: Checks if function works with 1 parameter, and default whitespace delimiter - in := "test is going.well.thank.you.for inquiring" - out := "Test Is Going.well.thank.you.for Inquiring" + in := "test is going.well.thank.you.for inquiring" + out := "Test Is Going.well.thank.you.for Inquiring" if x := Capitalize(in); x != out { t.Errorf("Capitalize(%v) = %v, want %v", in, x, out) } + // Test 2: Checks if function works with both parameters, with param 2 containing whitespace and '.' - out = "Test Is Going.Well.Thank.You.For Inquiring" - delimiters := []rune{' ', '.'} + out = "Test Is Going.Well.Thank.You.For Inquiring" + delimiters := []rune{' ', '.'} if x := Capitalize(in, delimiters...); x != out { t.Errorf("Capitalize(%v) = %v, want %v", in, x, out) } } + + func TestCapitalizeFully(t *testing.T) { // Test 1 - in := "tEsT iS goiNG.wELL.tHaNk.yOU.for inqUIrING" - out := "Test Is Going.well.thank.you.for Inquiring" + in := "tEsT iS goiNG.wELL.tHaNk.yOU.for inqUIrING" + out := "Test Is Going.well.thank.you.for Inquiring" if x := CapitalizeFully(in); x != out { t.Errorf("CapitalizeFully(%v) = %v, want %v", in, x, out) } + // Test 2 - out = "Test Is Going.Well.Thank.You.For Inquiring" - delimiters := []rune{' ', '.'} + out = "Test Is Going.Well.Thank.You.For Inquiring" + delimiters := []rune{' ', '.'} if x := CapitalizeFully(in, delimiters...); x != out { t.Errorf("CapitalizeFully(%v) = %v, want %v", in, x, out) } } + func TestUncapitalize(t *testing.T) { // Test 1: Checks if function works with 1 parameter, and default whitespace delimiter - in := "This Is A.Test" - out := "this is a.Test" + in := "This Is A.Test" + out := "this is a.Test" if x := Uncapitalize(in); x != out { t.Errorf("Uncapitalize(%v) = %v, want %v", in, x, out) } // Test 2: Checks if function works with both parameters, with param 2 containing whitespace and '.' - out = "this is a.test" - delimiters := []rune{' ', '.'} + out = "this is a.test" + delimiters := []rune{' ', '.'} if x := Uncapitalize(in, delimiters...); x != out { t.Errorf("Uncapitalize(%v) = %v, want %v", in, x, out) } } + func TestSwapCase(t *testing.T) { - in := "This Is A.Test" - out := "tHIS iS a.tEST" + in := "This Is A.Test" + out := "tHIS iS a.tEST" if x := SwapCase(in); x != out { t.Errorf("SwapCase(%v) = %v, want %v", in, x, out) } } + func TestInitials(t *testing.T) { // Test 1 - in := "John Doe.Ray" - out := "JD" + in := "John Doe.Ray" + out := "JD" if x := Initials(in); x != out { t.Errorf("Initials(%v) = %v, want %v", in, x, out) } + // Test 2 - out = "JDR" - delimiters := []rune{' ', '.'} + out = "JDR" + delimiters := []rune{' ','.'} if x := Initials(in, delimiters...); x != out { t.Errorf("Initials(%v) = %v, want %v", in, x, out) @@ -131,19 +143,24 @@ func TestInitials(t *testing.T) { } + + + + // ****************************** EXAMPLES ******************************************** func ExampleWrap() { - in := "Bob Manuel Bob Manuel" + in := "Bob Manuel Bob Manuel" wrapLength := 10 - fmt.Println(Wrap(in, wrapLength)) - // Output: + fmt.Println (Wrap(in, wrapLength)) + // Output: // Bob Manuel // Bob Manuel } + func ExampleWrapCustom_1() { in := "BobManuelBob Bob" @@ -151,11 +168,12 @@ func ExampleWrapCustom_1() { newLineStr := "" wrapLongWords := false - fmt.Println(WrapCustom(in, wrapLength, newLineStr, wrapLongWords)) - // Output: + fmt.Println (WrapCustom(in, wrapLength, newLineStr, wrapLongWords)) + // Output: // BobManuelBobBob } + func ExampleWrapCustom_2() { in := "BobManuelBob Bob" @@ -163,63 +181,72 @@ func ExampleWrapCustom_2() { newLineStr := "" wrapLongWords := true - fmt.Println(WrapCustom(in, wrapLength, newLineStr, wrapLongWords)) - // Output: + fmt.Println (WrapCustom(in, wrapLength, newLineStr, wrapLongWords)) + // Output: // BobManuelBob Bob } + + func ExampleCapitalize() { in := "test is going.well.thank.you.for inquiring" // Compare input to CapitalizeFully example - delimiters := []rune{' ', '.'} + delimiters := []rune{' ', '.'} - fmt.Println(Capitalize(in)) - fmt.Println(Capitalize(in, delimiters...)) + fmt.Println (Capitalize(in)) + fmt.Println (Capitalize(in, delimiters...)) // Output: // Test Is Going.well.thank.you.for Inquiring - // Test Is Going.Well.Thank.You.For Inquiring + // Test Is Going.Well.Thank.You.For Inquiring } + + func ExampleCapitalizeFully() { - in := "tEsT iS goiNG.wELL.tHaNk.yOU.for inqUIrING" // Notice scattered capitalization - delimiters := []rune{' ', '.'} - fmt.Println(CapitalizeFully(in)) - fmt.Println(CapitalizeFully(in, delimiters...)) + in := "tEsT iS goiNG.wELL.tHaNk.yOU.for inqUIrING" // Notice scattered capitalization + delimiters := []rune{' ', '.'} + + fmt.Println (CapitalizeFully(in)) + fmt.Println (CapitalizeFully(in, delimiters...)) // Output: // Test Is Going.well.thank.you.for Inquiring - // Test Is Going.Well.Thank.You.For Inquiring + // Test Is Going.Well.Thank.You.For Inquiring } + func ExampleUncapitalize() { - in := "This Is A.Test" - delimiters := []rune{' ', '.'} + in := "This Is A.Test" + delimiters := []rune{' ', '.'} - fmt.Println(Uncapitalize(in)) - fmt.Println(Uncapitalize(in, delimiters...)) + fmt.Println (Uncapitalize(in)) + fmt.Println (Uncapitalize(in, delimiters...)) // Output: // this is a.Test - // this is a.test + // this is a.test } + func ExampleSwapCase() { - in := "This Is A.Test" - fmt.Println(SwapCase(in)) + in := "This Is A.Test" + fmt.Println (SwapCase(in)) // Output: // tHIS iS a.tEST } + func ExampleInitials() { - in := "John Doe.Ray" - delimiters := []rune{' ', '.'} + in := "John Doe.Ray" + delimiters := []rune{' ','.'} - fmt.Println(Initials(in)) - fmt.Println(Initials(in, delimiters...)) + fmt.Println (Initials(in)) + fmt.Println (Initials(in, delimiters...)) // Output: // JD // JDR } + diff --git a/vendor/github.com/docker/docker/.github/CODEOWNERS b/vendor/github.com/docker/docker/.github/CODEOWNERS index 79ff08905..58ed55052 100644 --- a/vendor/github.com/docker/docker/.github/CODEOWNERS +++ b/vendor/github.com/docker/docker/.github/CODEOWNERS @@ -14,6 +14,8 @@ daemon/graphdriver/windows/** @johnstep @jhowardmsft daemon/logger/awslogs/** @samuelkarp hack/** @dnephin @tianon hack/integration-cli-on-swarm/** @AkihiroSuda +integration-cli/** @dnephin @vdemeester +integration/** @dnephin @vdemeester pkg/testutil/** @dnephin plugin/** @cpuguy83 project/** @thaJeztah diff --git a/vendor/github.com/docker/docker/.gitignore b/vendor/github.com/docker/docker/.gitignore index 943e7f3f6..93a6df48e 100644 --- a/vendor/github.com/docker/docker/.gitignore +++ b/vendor/github.com/docker/docker/.gitignore @@ -4,7 +4,7 @@ *.exe *.exe~ *.orig -*.test +test.main .*.swp .DS_Store # a .bashrc may be added to customize the build environment diff --git a/vendor/github.com/docker/docker/CHANGELOG.md b/vendor/github.com/docker/docker/CHANGELOG.md index bbedc491e..e9db48fa9 100644 --- a/vendor/github.com/docker/docker/CHANGELOG.md +++ b/vendor/github.com/docker/docker/CHANGELOG.md @@ -2284,7 +2284,7 @@ by another client (#15489) - Use mock for search tests. - Update to double-dash everywhere. - Move .dockerenv parsing to lxc driver. -- Move all bind-mounts in the container inside the namespace. +- Move all bind mounts in the container inside the namespace. - Don't use separate bind mount for container. - Always symlink /dev/ptmx for libcontainer. - Don't kill by pid for other drivers. @@ -2719,7 +2719,7 @@ With the ongoing changes to the networking and execution subsystems of docker te + Implement `docker log -f` to stream logs + Add env variable to disable kernel version warning + Add -format to `docker inspect` -+ Support bind-mount for files ++ Support bind mount for files - Fix bridge creation on RHEL - Fix image size calculation - Make sure iptables are called even if the bridge already exists diff --git a/vendor/github.com/docker/docker/CONTRIBUTING.md b/vendor/github.com/docker/docker/CONTRIBUTING.md index 917214cd1..c55e13bbc 100644 --- a/vendor/github.com/docker/docker/CONTRIBUTING.md +++ b/vendor/github.com/docker/docker/CONTRIBUTING.md @@ -155,10 +155,11 @@ Fork the repository and make changes on your fork in a feature branch: your intentions, and name it XXXX-something where XXXX is the number of the issue. -Submit unit tests for your changes. Go has a great test framework built in; use -it! Take a look at existing tests for inspiration. [Run the full test -suite](https://docs.docker.com/opensource/project/test-and-docs/) on your branch before -submitting a pull request. +Submit tests for your changes. See [TESTING.md](./TESTING.md) for details. + +If your changes need integration tests, write them against the API. The `cli` +integration tests are slowly either migrated to API tests or moved away as unit +tests in `docker/cli` and end-to-end tests for docker. Update the documentation when creating or modifying features. Test your documentation changes for clarity, concision, and correctness, as well as a @@ -251,10 +252,9 @@ calling it in another file constitute a single logical unit of work. The very high majority of submissions should have a single commit, so if in doubt: squash down to one. -After every commit, [make sure the test suite passes] -(https://docs.docker.com/opensource/project/test-and-docs/). Include documentation -changes in the same pull request so that a revert would remove all traces of -the feature or fix. +After every commit, [make sure the test suite passes](./TESTING.md). Include +documentation changes in the same pull request so that a revert would remove +all traces of the feature or fix. Include an issue reference like `Closes #XXXX` or `Fixes #XXXX` in commits that close an issue. Including references automatically closes the issue on a merge. diff --git a/vendor/github.com/docker/docker/Dockerfile b/vendor/github.com/docker/docker/Dockerfile index 33e88dce2..82375a78e 100644 --- a/vendor/github.com/docker/docker/Dockerfile +++ b/vendor/github.com/docker/docker/Dockerfile @@ -9,7 +9,7 @@ # docker run -v `pwd`:/go/src/github.com/docker/docker --privileged -i -t docker bash # # # Run the test suite: -# docker run -e DOCKER_GITCOMMIT=foo --privileged docker hack/make.sh test-unit test-integration-cli test-docker-py +# docker run -e DOCKER_GITCOMMIT=foo --privileged docker hack/make.sh test-unit test-integration test-docker-py # # # Publish a release: # docker run --privileged \ @@ -23,7 +23,7 @@ # the case. Therefore, you don't have to disable it anymore. # -FROM debian:jessie +FROM debian:stretch # allow replacing httpredir or deb mirror ARG APT_MIRROR=deb.debian.org @@ -51,42 +51,34 @@ RUN apt-get update && apt-get install -y \ less \ libapparmor-dev \ libcap-dev \ + libdevmapper-dev \ libnl-3-dev \ libprotobuf-c0-dev \ libprotobuf-dev \ - libsystemd-journal-dev \ + libsystemd-dev \ libtool \ + libudev-dev \ mercurial \ net-tools \ pkg-config \ protobuf-compiler \ protobuf-c-compiler \ + python-backports.ssl-match-hostname \ python-dev \ python-mock \ python-pip \ + python-requests \ + python-setuptools \ python-websocket \ + python-wheel \ tar \ + thin-provisioning-tools \ vim \ vim-common \ xfsprogs \ zip \ --no-install-recommends \ && pip install awscli==1.10.15 -# Get lvm2 source for compiling statically -ENV LVM2_VERSION 2.02.103 -RUN mkdir -p /usr/local/lvm2 \ - && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ - | tar -xzC /usr/local/lvm2 --strip-components=1 -# See https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags - -# Compile and install lvm2 -RUN cd /usr/local/lvm2 \ - && ./configure \ - --build="$(gcc -print-multiarch)" \ - --enable-static_link \ - && make device-mapper \ - && make install_device-mapper -# See https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL # Install seccomp: the version shipped upstream is too old ENV SECCOMP_VERSION 2.3.2 @@ -115,17 +107,6 @@ RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" \ ENV PATH /go/bin:/usr/local/go/bin:$PATH ENV GOPATH /go -# Dependency for golint -ENV GO_TOOLS_COMMIT 823804e1ae08dbb14eb807afc7db9993bc9e3cc3 -RUN git clone https://github.com/golang/tools.git /go/src/golang.org/x/tools \ - && (cd /go/src/golang.org/x/tools && git checkout -q $GO_TOOLS_COMMIT) - -# Grab Go's lint tool -ENV GO_LINT_COMMIT 32a87160691b3c96046c0c678fe57c5bef761456 -RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint \ - && (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \ - && go install -v github.com/golang/lint/golint - # Install CRIU for checkpoint/restore support ENV CRIU_VERSION 2.12.1 # Install dependancy packages specific to criu @@ -168,9 +149,6 @@ RUN set -x \ # Get the "docker-py" source so we can run their integration tests ENV DOCKER_PY_COMMIT a962578e515185cf06506050b2200c0b81aa84ef # To run integration tests docker-pycreds is required. -# Before running the integration tests conftest.py is -# loaded which results in loads auth.py that -# imports the docker-pycreds module. RUN git clone https://github.com/docker/docker-py.git /docker-py \ && cd /docker-py \ && git checkout -q $DOCKER_PY_COMMIT \ @@ -215,7 +193,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ # Please edit hack/dockerfile/install-binaries.sh to update them. COPY hack/dockerfile/binaries-commits /tmp/binaries-commits COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh -RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli +RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli gometalinter ENV PATH=/usr/local/cli:$PATH # Activate bash completion and include Docker's completion if mounted with DOCKER_BASH_COMPLETION_PATH @@ -227,3 +205,6 @@ ENTRYPOINT ["hack/dind"] # Upload docker source COPY . /go/src/github.com/docker/docker + +# Options for hack/validate/gometalinter +ENV GOMETALINTER_OPTS="--deadline 2m" diff --git a/vendor/github.com/docker/docker/Dockerfile.aarch64 b/vendor/github.com/docker/docker/Dockerfile.aarch64 index cabcda28b..493145174 100644 --- a/vendor/github.com/docker/docker/Dockerfile.aarch64 +++ b/vendor/github.com/docker/docker/Dockerfile.aarch64 @@ -9,20 +9,26 @@ # docker run -v `pwd`:/go/src/github.com/docker/docker --privileged -i -t docker bash # # # Run the test suite: -# docker run --privileged docker hack/make.sh test-unit test-integration-cli test-docker-py +# docker run --privileged docker hack/make.sh test-unit test-integration test-docker-py # # Note: AppArmor used to mess with privileged mode, but this is no longer # the case. Therefore, you don't have to disable it anymore. # -FROM aarch64/ubuntu:xenial +FROM arm64v8/debian:stretch + +# allow replacing httpredir or deb mirror +ARG APT_MIRROR=deb.debian.org +RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list # Packaged dependencies RUN apt-get update && apt-get install -y \ apparmor \ + apt-utils \ aufs-tools \ automake \ bash-completion \ + bsdmainutils \ btrfs-tools \ build-essential \ cmake \ @@ -32,51 +38,40 @@ RUN apt-get update && apt-get install -y \ g++ \ gcc \ git \ + golang \ iptables \ jq \ + less \ libapparmor-dev \ - libc6-dev \ libcap-dev \ + libdevmapper-dev \ + libnl-3-dev \ + libprotobuf-c0-dev \ + libprotobuf-dev \ libsystemd-dev \ - libyaml-dev \ + libtool \ + libudev-dev \ mercurial \ net-tools \ - parallel \ pkg-config \ + protobuf-compiler \ + protobuf-c-compiler \ + python-backports.ssl-match-hostname \ python-dev \ python-mock \ python-pip \ + python-requests \ python-setuptools \ python-websocket \ - golang-go \ - iproute2 \ - iputils-ping \ + python-wheel \ + tar \ + thin-provisioning-tools \ + vim \ vim-common \ + xfsprogs \ + zip \ --no-install-recommends -# Get lvm2 source for compiling statically -ENV LVM2_VERSION 2.02.103 -RUN mkdir -p /usr/local/lvm2 \ - && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ - | tar -xzC /usr/local/lvm2 --strip-components=1 -# See https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags - -# Fix platform enablement in lvm2 to support aarch64 properly -RUN set -e \ - && for f in config.guess config.sub; do \ - curl -fsSL -o "/usr/local/lvm2/autoconf/$f" "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=$f;hb=HEAD"; \ - done -# "arch.c:78:2: error: #error the arch code needs to know about your machine type" - -# Compile and install lvm2 -RUN cd /usr/local/lvm2 \ - && ./configure \ - --build="$(gcc -print-multiarch)" \ - --enable-static_link \ - && make device-mapper \ - && make install_device-mapper -# See https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL - # Install seccomp: the version shipped upstream is too old ENV SECCOMP_VERSION 2.3.2 RUN set -x \ @@ -94,9 +89,7 @@ RUN set -x \ # Install Go # We don't have official binary golang 1.7.5 tarballs for ARM64, either for Go or -# bootstrap, so we use golang-go (1.6) as bootstrap to build Go from source code. -# We don't use the official ARMv6 released binaries as a GOROOT_BOOTSTRAP, because -# not all ARM64 platforms support 32-bit mode. 32-bit mode is optional for ARMv8. +# bootstrap, so we use Debian golang (1.7) as bootstrap to build Go from source code. # IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored ENV GO_VERSION 1.8.3 RUN mkdir /usr/src/go && curl -fsSL https://golang.org/dl/go${GO_VERSION}.src.tar.gz | tar -v -C /usr/src/go -xz --strip-components=1 \ @@ -106,17 +99,6 @@ RUN mkdir /usr/src/go && curl -fsSL https://golang.org/dl/go${GO_VERSION}.src.ta ENV PATH /go/bin:/usr/src/go/bin:$PATH ENV GOPATH /go -# Dependency for golint -ENV GO_TOOLS_COMMIT 823804e1ae08dbb14eb807afc7db9993bc9e3cc3 -RUN git clone https://github.com/golang/tools.git /go/src/golang.org/x/tools \ - && (cd /go/src/golang.org/x/tools && git checkout -q $GO_TOOLS_COMMIT) - -# Grab Go's lint tool -ENV GO_LINT_COMMIT 32a87160691b3c96046c0c678fe57c5bef761456 -RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint \ - && (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \ - && go install -v github.com/golang/lint/golint - # Only install one version of the registry, because old version which support # schema1 manifests is not working on ARM64, we should skip integration-cli # tests for schema1 manifests on ARM64. @@ -143,13 +125,10 @@ RUN set -x \ # Get the "docker-py" source so we can run their integration tests ENV DOCKER_PY_COMMIT a962578e515185cf06506050b2200c0b81aa84ef -# Before running the integration tests conftest.py is -# loaded which results in loads auth.py that -# imports the docker-pycreds module. +# To run integration tests docker-pycreds is required. RUN git clone https://github.com/docker/docker-py.git /docker-py \ && cd /docker-py \ && git checkout -q $DOCKER_PY_COMMIT \ - && pip install wheel \ && pip install docker-pycreds==0.2.1 \ && pip install -r test-requirements.txt @@ -192,7 +171,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ # Please edit hack/dockerfile/install-binaries.sh to update them. COPY hack/dockerfile/binaries-commits /tmp/binaries-commits COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh -RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli +RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli gometalinter ENV PATH=/usr/local/cli:$PATH # Wrap all commands in the "docker-in-docker" script to allow nested containers @@ -200,3 +179,6 @@ ENTRYPOINT ["hack/dind"] # Upload docker source COPY . /go/src/github.com/docker/docker + +# Options for hack/validate/gometalinter +ENV GOMETALINTER_OPTS="--deadline 4m -j2" diff --git a/vendor/github.com/docker/docker/Dockerfile.armhf b/vendor/github.com/docker/docker/Dockerfile.armhf index dd1f53619..9818c34cc 100644 --- a/vendor/github.com/docker/docker/Dockerfile.armhf +++ b/vendor/github.com/docker/docker/Dockerfile.armhf @@ -9,13 +9,13 @@ # docker run -v `pwd`:/go/src/github.com/docker/docker --privileged -i -t docker bash # # # Run the test suite: -# docker run --privileged docker hack/make.sh test-unit test-integration-cli test-docker-py +# docker run --privileged docker hack/make.sh test-unit test-integration test-docker-py # # Note: AppArmor used to mess with privileged mode, but this is no longer # the case. Therefore, you don't have to disable it anymore. # -FROM armhf/debian:jessie +FROM arm32v7/debian:stretch # allow replacing httpredir or deb mirror ARG APT_MIRROR=deb.debian.org @@ -39,36 +39,27 @@ RUN apt-get update && apt-get install -y \ net-tools \ libapparmor-dev \ libcap-dev \ - libsystemd-journal-dev \ + libdevmapper-dev \ + libsystemd-dev \ libtool \ + libudev-dev \ mercurial \ pkg-config \ + python-backports.ssl-match-hostname \ python-dev \ python-mock \ python-pip \ + python-requests \ + python-setuptools \ python-websocket \ + python-wheel \ xfsprogs \ tar \ + thin-provisioning-tools \ vim-common \ --no-install-recommends \ && pip install awscli==1.10.15 -# Get lvm2 source for compiling statically -ENV LVM2_VERSION 2.02.103 -RUN mkdir -p /usr/local/lvm2 \ - && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ - | tar -xzC /usr/local/lvm2 --strip-components=1 -# See https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags - -# Compile and install lvm2 -RUN cd /usr/local/lvm2 \ - && ./configure \ - --build="$(gcc -print-multiarch)" \ - --enable-static_link \ - && make device-mapper \ - && make install_device-mapper -# See https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL - # Install Go # IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored ENV GO_VERSION 1.8.3 @@ -81,17 +72,6 @@ ENV GOPATH /go ENV GOARCH arm ENV GOARM 7 -# Dependency for golint -ENV GO_TOOLS_COMMIT 823804e1ae08dbb14eb807afc7db9993bc9e3cc3 -RUN git clone https://github.com/golang/tools.git /go/src/golang.org/x/tools \ - && (cd /go/src/golang.org/x/tools && git checkout -q $GO_TOOLS_COMMIT) - -# Grab Go's lint tool -ENV GO_LINT_COMMIT 32a87160691b3c96046c0c678fe57c5bef761456 -RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint \ - && (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \ - && go install -v github.com/golang/lint/golint - # Install seccomp: the version shipped upstream is too old ENV SECCOMP_VERSION 2.3.2 RUN set -x \ @@ -138,9 +118,11 @@ RUN set -x \ # Get the "docker-py" source so we can run their integration tests ENV DOCKER_PY_COMMIT a962578e515185cf06506050b2200c0b81aa84ef +# To run integration tests docker-pycreds is required. RUN git clone https://github.com/docker/docker-py.git /docker-py \ && cd /docker-py \ && git checkout -q $DOCKER_PY_COMMIT \ + && pip install docker-pycreds==0.2.1 \ && pip install -r test-requirements.txt # Set user.email so crosbymichael's in-container merge commits go smoothly @@ -173,10 +155,13 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ # Please edit hack/dockerfile/install-binaries.sh to update them. COPY hack/dockerfile/binaries-commits /tmp/binaries-commits COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh -RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli +RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli gometalinter ENV PATH=/usr/local/cli:$PATH ENTRYPOINT ["hack/dind"] # Upload docker source COPY . /go/src/github.com/docker/docker + +# Options for hack/validate/gometalinter +ENV GOMETALINTER_OPTS="--deadline 10m -j2" diff --git a/vendor/github.com/docker/docker/Dockerfile.e2e b/vendor/github.com/docker/docker/Dockerfile.e2e new file mode 100644 index 000000000..3d700fab5 --- /dev/null +++ b/vendor/github.com/docker/docker/Dockerfile.e2e @@ -0,0 +1,70 @@ +## Step 1: Build tests +FROM golang:1.8.3-alpine3.6 as builder + +RUN apk add --update \ + bash \ + build-base \ + curl \ + lvm2-dev \ + jq \ + && rm -rf /var/cache/apk/* + +RUN mkdir -p /go/src/github.com/docker/docker/ +WORKDIR /go/src/github.com/docker/docker/ + +# Generate frozen images +COPY contrib/download-frozen-image-v2.sh contrib/download-frozen-image-v2.sh +RUN contrib/download-frozen-image-v2.sh /output/docker-frozen-images \ + buildpack-deps:jessie@sha256:85b379ec16065e4fe4127eb1c5fb1bcc03c559bd36dbb2e22ff496de55925fa6 \ + busybox:latest@sha256:32f093055929dbc23dec4d03e09dfe971f5973a9ca5cf059cbfb644c206aa83f \ + debian:jessie@sha256:72f784399fd2719b4cb4e16ef8e369a39dc67f53d978cd3e2e7bf4e502c7b793 \ + hello-world:latest@sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 + +# Download Docker CLI binary +COPY hack/dockerfile hack/dockerfile +RUN hack/dockerfile/install-binaries.sh dockercli + +# Set tag and add sources +ARG DOCKER_GITCOMMIT +ENV DOCKER_GITCOMMIT=$DOCKER_GITCOMMIT +ADD . . + +# Build DockerSuite.TestBuild* dependency +RUN CGO_ENABLED=0 go build -o /output/httpserver github.com/docker/docker/contrib/httpserver + +# Build the integration tests and copy the resulting binaries to /output/tests +RUN hack/make.sh build-integration-test-binary +RUN mkdir -p /output/tests && find . -name test.main -exec cp --parents '{}' /output/tests \; + +## Step 2: Generate testing image +FROM alpine:3.6 as runner + +# GNU tar is used for generating the emptyfs image +RUN apk add --update \ + bash \ + ca-certificates \ + g++ \ + git \ + iptables \ + tar \ + xz \ + && rm -rf /var/cache/apk/* + +# Add an unprivileged user to be used for tests which need it +RUN addgroup docker && adduser -D -G docker unprivilegeduser -s /bin/ash + +COPY contrib/httpserver/Dockerfile /tests/contrib/httpserver/Dockerfile +COPY contrib/syscall-test /tests/contrib/syscall-test +COPY integration-cli/fixtures /tests/integration-cli/fixtures + +COPY hack/test/e2e-run.sh /scripts/run.sh +COPY hack/make/.ensure-emptyfs /scripts/ensure-emptyfs.sh + +COPY --from=builder /output/docker-frozen-images /docker-frozen-images +COPY --from=builder /output/httpserver /tests/contrib/httpserver/httpserver +COPY --from=builder /output/tests /tests +COPY --from=builder /usr/local/bin/docker /usr/bin/docker + +ENV DOCKER_REMOTE_DAEMON=1 DOCKER_INTEGRATION_DAEMON_DEST=/ + +ENTRYPOINT ["/scripts/run.sh"] diff --git a/vendor/github.com/docker/docker/Dockerfile.ppc64le b/vendor/github.com/docker/docker/Dockerfile.ppc64le index 43b84e450..91d2bd247 100644 --- a/vendor/github.com/docker/docker/Dockerfile.ppc64le +++ b/vendor/github.com/docker/docker/Dockerfile.ppc64le @@ -9,13 +9,13 @@ # docker run -v `pwd`:/go/src/github.com/docker/docker --privileged -i -t docker bash # # # Run the test suite: -# docker run --privileged docker hack/make.sh test-unit test-integration-cli test-docker-py +# docker run --privileged docker hack/make.sh test-unit test-integration test-docker-py # # Note: AppArmor used to mess with privileged mode, but this is no longer # the case. Therefore, you don't have to disable it anymore. # -FROM ppc64le/debian:jessie +FROM ppc64le/debian:stretch # allow replacing httpredir or deb mirror ARG APT_MIRROR=deb.debian.org @@ -40,42 +40,26 @@ RUN apt-get update && apt-get install -y \ net-tools \ libapparmor-dev \ libcap-dev \ - libsystemd-journal-dev \ + libdevmapper-dev \ + libsystemd-dev \ libtool \ + libudev-dev \ mercurial \ pkg-config \ + python-backports.ssl-match-hostname \ python-dev \ python-mock \ python-pip \ + python-requests \ + python-setuptools \ python-websocket \ + python-wheel \ xfsprogs \ tar \ + thin-provisioning-tools \ vim-common \ --no-install-recommends -# Get lvm2 source for compiling statically -ENV LVM2_VERSION 2.02.103 -RUN mkdir -p /usr/local/lvm2 \ - && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ - | tar -xzC /usr/local/lvm2 --strip-components=1 -# See https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags - -# Fix platform enablement in lvm2 to support ppc64le properly -RUN set -e \ - && for f in config.guess config.sub; do \ - curl -fsSL -o "/usr/local/lvm2/autoconf/$f" "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=$f;hb=HEAD"; \ - done -# "arch.c:78:2: error: #error the arch code needs to know about your machine type" - -# Compile and install lvm2 -RUN cd /usr/local/lvm2 \ - && ./configure \ - --build="$(gcc -print-multiarch)" \ - --enable-static_link \ - && make device-mapper \ - && make install_device-mapper -# See https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL - # Install seccomp: the version shipped upstream is too old ENV SECCOMP_VERSION 2.3.2 RUN set -x \ @@ -102,17 +86,6 @@ RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-ppc64le.tar.gz" \ ENV PATH /go/bin:/usr/local/go/bin:$PATH ENV GOPATH /go -# Dependency for golint -ENV GO_TOOLS_COMMIT 823804e1ae08dbb14eb807afc7db9993bc9e3cc3 -RUN git clone https://github.com/golang/tools.git /go/src/golang.org/x/tools \ - && (cd /go/src/golang.org/x/tools && git checkout -q $GO_TOOLS_COMMIT) - -# Grab Go's lint tool -ENV GO_LINT_COMMIT 32a87160691b3c96046c0c678fe57c5bef761456 -RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint \ - && (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \ - && go install -v github.com/golang/lint/golint - # Install two versions of the registry. The first is an older version that # only supports schema1 manifests. The second is a newer version that supports # both. This allows integration-cli tests to cover push/pull with both schema1 @@ -144,9 +117,11 @@ RUN set -x \ # Get the "docker-py" source so we can run their integration tests ENV DOCKER_PY_COMMIT a962578e515185cf06506050b2200c0b81aa84ef +# To run integration tests docker-pycreds is required. RUN git clone https://github.com/docker/docker-py.git /docker-py \ && cd /docker-py \ && git checkout -q $DOCKER_PY_COMMIT \ + && pip install docker-pycreds==0.2.1 \ && pip install -r test-requirements.txt # Set user.email so crosbymichael's in-container merge commits go smoothly @@ -179,7 +154,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ # Please edit hack/dockerfile/install-binaries.sh to update them. COPY hack/dockerfile/binaries-commits /tmp/binaries-commits COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh -RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli +RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli gometalinter ENV PATH=/usr/local/cli:$PATH # Wrap all commands in the "docker-in-docker" script to allow nested containers diff --git a/vendor/github.com/docker/docker/Dockerfile.s390x b/vendor/github.com/docker/docker/Dockerfile.s390x index 35ec68373..9ad5d5aa5 100644 --- a/vendor/github.com/docker/docker/Dockerfile.s390x +++ b/vendor/github.com/docker/docker/Dockerfile.s390x @@ -9,13 +9,13 @@ # docker run -v `pwd`:/go/src/github.com/docker/docker --privileged -i -t docker bash # # # Run the test suite: -# docker run --privileged docker hack/make.sh test-unit test-integration-cli test-docker-py +# docker run --privileged docker hack/make.sh test-unit test-integration test-docker-py # # Note: AppArmor used to mess with privileged mode, but this is no longer # the case. Therefore, you don't have to disable it anymore. # -FROM s390x/debian:jessie +FROM s390x/debian:stretch # Packaged dependencies RUN apt-get update && apt-get install -y \ @@ -36,16 +36,23 @@ RUN apt-get update && apt-get install -y \ net-tools \ libapparmor-dev \ libcap-dev \ - libsystemd-journal-dev \ + libdevmapper-dev \ + libsystemd-dev \ libtool \ + libudev-dev \ mercurial \ pkg-config \ + python-backports.ssl-match-hostname \ python-dev \ python-mock \ python-pip \ + python-requests \ + python-setuptools \ python-websocket \ + python-wheel \ xfsprogs \ tar \ + thin-provisioning-tools \ vim-common \ --no-install-recommends @@ -64,29 +71,6 @@ RUN set -x \ ) \ && rm -rf "$SECCOMP_PATH" -# Get lvm2 source for compiling statically -ENV LVM2_VERSION 2.02.103 -RUN mkdir -p /usr/local/lvm2 \ - && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ - | tar -xzC /usr/local/lvm2 --strip-components=1 -# See https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags - -# Fix platform enablement in lvm2 to support s390x properly -RUN set -e \ - && for f in config.guess config.sub; do \ - curl -fsSL -o "/usr/local/lvm2/autoconf/$f" "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=$f;hb=HEAD"; \ - done -# "arch.c:78:2: error: #error the arch code needs to know about your machine type" - -# Compile and install lvm2 -RUN cd /usr/local/lvm2 \ - && ./configure \ - --build="$(gcc -print-multiarch)" \ - --enable-static_link \ - && make device-mapper \ - && make install_device-mapper -# See https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL - # IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored ENV GO_VERSION 1.8.3 RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-s390x.tar.gz" \ @@ -95,17 +79,6 @@ RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-s390x.tar.gz" \ ENV PATH /go/bin:/usr/local/go/bin:$PATH ENV GOPATH /go -# Dependency for golint -ENV GO_TOOLS_COMMIT 823804e1ae08dbb14eb807afc7db9993bc9e3cc3 -RUN git clone https://github.com/golang/tools.git /go/src/golang.org/x/tools \ - && (cd /go/src/golang.org/x/tools && git checkout -q $GO_TOOLS_COMMIT) - -# Grab Go's lint tool -ENV GO_LINT_COMMIT 32a87160691b3c96046c0c678fe57c5bef761456 -RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint \ - && (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \ - && go install -v github.com/golang/lint/golint - # Install two versions of the registry. The first is an older version that # only supports schema1 manifests. The second is a newer version that supports # both. This allows integration-cli tests to cover push/pull with both schema1 @@ -137,9 +110,11 @@ RUN set -x \ # Get the "docker-py" source so we can run their integration tests ENV DOCKER_PY_COMMIT a962578e515185cf06506050b2200c0b81aa84ef +# To run integration tests docker-pycreds is required. RUN git clone https://github.com/docker/docker-py.git /docker-py \ && cd /docker-py \ && git checkout -q $DOCKER_PY_COMMIT \ + && pip install docker-pycreds==0.2.1 \ && pip install -r test-requirements.txt # Set user.email so crosbymichael's in-container merge commits go smoothly @@ -172,7 +147,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ # Please edit hack/dockerfile/install-binaries.sh to update them. COPY hack/dockerfile/binaries-commits /tmp/binaries-commits COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh -RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli +RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli gometalinter ENV PATH=/usr/local/cli:$PATH # Wrap all commands in the "docker-in-docker" script to allow nested containers diff --git a/vendor/github.com/docker/docker/Dockerfile.simple b/vendor/github.com/docker/docker/Dockerfile.simple index b4682d4cb..cdbc242a7 100644 --- a/vendor/github.com/docker/docker/Dockerfile.simple +++ b/vendor/github.com/docker/docker/Dockerfile.simple @@ -1,11 +1,11 @@ # docker build -t docker:simple -f Dockerfile.simple . # docker run --rm docker:simple hack/make.sh dynbinary # docker run --rm --privileged docker:simple hack/dind hack/make.sh test-unit -# docker run --rm --privileged -v /var/lib/docker docker:simple hack/dind hack/make.sh dynbinary test-integration-cli +# docker run --rm --privileged -v /var/lib/docker docker:simple hack/dind hack/make.sh dynbinary test-integration # This represents the bare minimum required to build and test Docker. -FROM debian:jessie +FROM debian:stretch # allow replacing httpredir or deb mirror ARG APT_MIRROR=deb.debian.org diff --git a/vendor/github.com/docker/docker/Dockerfile.windows b/vendor/github.com/docker/docker/Dockerfile.windows index 8f8ee609c..0c62c9414 100644 --- a/vendor/github.com/docker/docker/Dockerfile.windows +++ b/vendor/github.com/docker/docker/Dockerfile.windows @@ -132,8 +132,8 @@ # Important notes: # --------------- # -# Don't attempt to use a bind-mount to pass a local directory as the bundles target -# directory. It does not work (golang attempts for follow a mapped folder incorrectly). +# Don't attempt to use a bind mount to pass a local directory as the bundles target +# directory. It does not work (golang attempts for follow a mapped folder incorrectly). # Instead, use docker cp as per the example. # # go.zip is not removed from the image as it is used by the Windows CI servers diff --git a/vendor/github.com/docker/docker/Makefile b/vendor/github.com/docker/docker/Makefile index 0d99606cc..d9fb68b1d 100644 --- a/vendor/github.com/docker/docker/Makefile +++ b/vendor/github.com/docker/docker/Makefile @@ -1,4 +1,4 @@ -.PHONY: all binary dynbinary build cross deb help init-go-pkg-cache install manpages rpm run shell test test-docker-py test-integration-cli test-unit tgz validate win +.PHONY: all binary dynbinary build cross deb help init-go-pkg-cache install manpages rpm run shell test test-docker-py test-integration test-unit tgz validate win # set the graph driver as the current graphdriver if not set DOCKER_GRAPHDRIVER := $(if $(DOCKER_GRAPHDRIVER),$(DOCKER_GRAPHDRIVER),$(shell docker info 2>&1 | grep "Storage Driver" | sed 's/.*: //')) @@ -35,6 +35,7 @@ DOCKER_ENVS := \ -e DOCKER_REMAP_ROOT \ -e DOCKER_STORAGE_OPTS \ -e DOCKER_USERLANDPROXY \ + -e TEST_INTEGRATION_DIR \ -e TESTDIRS \ -e TESTFLAGS \ -e TIMEOUT \ @@ -43,7 +44,8 @@ DOCKER_ENVS := \ -e NO_PROXY \ -e http_proxy \ -e https_proxy \ - -e no_proxy + -e no_proxy \ + -e VERSION # note: we _cannot_ add "-e DOCKER_BUILDTAGS" here because even if it's unset in the shell, that would shadow the "ENV DOCKER_BUILDTAGS" set in our Dockerfile, which is very important for our official builds # to allow `make BIND_DIR=. shell` or `make BIND_DIR= test` @@ -110,7 +112,7 @@ dynbinary: build ## build the linux dynbinaries $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary build: bundles init-go-pkg-cache - $(warning The docker client CLI has moved to github.com/docker/cli. By default, it is built from the git sha specified in hack/dockerfile/binaries-commits. For a dev-test cycle involving the CLI, run:${\n} DOCKER_CLI_PATH=/host/path/to/cli/binary make shell ${\n} then change the cli and compile into a binary at the same location.${\n}) + $(warning The docker client CLI has moved to github.com/docker/cli. For a dev-test cycle involving the CLI, run:${\n} DOCKER_CLI_PATH=/host/path/to/cli/binary make shell ${\n} then change the cli and compile into a binary at the same location.${\n}) docker build ${BUILD_APT_MIRROR} ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" . bundles: @@ -149,16 +151,18 @@ shell: build ## start a shell inside the build env $(DOCKER_RUN_DOCKER) bash test: build ## run the unit, integration and docker-py tests - $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary cross test-unit test-integration-cli test-docker-py + $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary cross test-unit test-integration test-docker-py test-docker-py: build ## run the docker-py tests $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-docker-py -test-integration-cli: build ## run the integration tests - $(DOCKER_RUN_DOCKER) hack/make.sh build-integration-test-binary dynbinary test-integration-cli +test-integration-cli: test-integration ## (DEPRECATED) use test-integration + +test-integration: build ## run the integration tests + $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-integration test-unit: build ## run the unit tests - $(DOCKER_RUN_DOCKER) hack/make.sh test-unit + $(DOCKER_RUN_DOCKER) hack/test/unit tgz: build ## build the archives (.zip on windows and .tgz\notherwise) containing the binaries $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary cross tgz diff --git a/vendor/github.com/docker/docker/TESTING.md b/vendor/github.com/docker/docker/TESTING.md new file mode 100644 index 000000000..20f7c9254 --- /dev/null +++ b/vendor/github.com/docker/docker/TESTING.md @@ -0,0 +1,71 @@ +# Testing + +This document contains the Moby code testing guidelines. It should answer any +questions you may have as an aspiring Moby contributor. + +## Test suites + +Moby has two test suites (and one legacy test suite): + +* Unit tests - use standard `go test` and + [testify](https://github.com/stretchr/testify) assertions. They are located in + the package they test. Unit tests should be fast and test only their own + package. +* API integration tests - use standard `go test` and + [testify](https://github.com/stretchr/testify) assertions. They are located in + `./integration/` directories, where `component` is: container, + image, volume, etc. These tests perform HTTP requests to an API endpoint and + check the HTTP response and daemon state after the call. + +The legacy test suite `integration-cli/` is deprecated. No new tests will be +added to this suite. Any tests in this suite which require updates should be +ported to either the unit test suite or the new API integration test suite. + +## Writing new tests + +Most code changes will fall into one of the following categories. + +### Writing tests for new features + +New code should be covered by unit tests. If the code is difficult to test with +a unit tests then that is a good sign that it should be refactored to make it +easier to reuse and maintain. Consider accepting unexported interfaces instead +of structs so that fakes can be provided for dependencies. + +If the new feature includes a completely new API endpoint then a new API +integration test should be added to cover the success case of that endpoint. + +If the new feature does not include a completely new API endpoint consider +adding the new API fields to the existing test for that endpoint. A new +integration test should **not** be added for every new API field or API error +case. Error cases should be handled by unit tests. + +### Writing tests for bug fixes + +Bugs fixes should include a unit test case which exercises the bug. + +A bug fix may also include new assertions in an existing integration tests for the +API endpoint. + +## Running tests + +To run the unit test suite: + +``` +make test-unit +``` + +or `hack/test/unit` from inside a `BINDDIR=. make shell` container or properly +configured environment. + +The following environment variables may be used to run a subset of tests: + +* `TESTDIRS` - paths to directories to be tested, defaults to `./...` +* `TESTFLAGS` - flags passed to `go test`, to run tests which match a pattern + use `TESTFLAGS="-test.run TestNameOrPrefix"` + +To run the integration test suite: + +``` +make test-integration +``` diff --git a/vendor/github.com/docker/docker/api/common.go b/vendor/github.com/docker/docker/api/common.go index 6e462aeda..ff87a94b5 100644 --- a/vendor/github.com/docker/docker/api/common.go +++ b/vendor/github.com/docker/docker/api/common.go @@ -1,17 +1,5 @@ package api -import ( - "encoding/json" - "encoding/pem" - "fmt" - "os" - "path/filepath" - - "github.com/docker/docker/pkg/ioutils" - "github.com/docker/docker/pkg/system" - "github.com/docker/libtrust" -) - // Common constants for daemon and client. const ( // DefaultVersion of Current REST API @@ -21,45 +9,3 @@ const ( // command to specify that no base image is to be used. NoBaseImageSpecifier string = "scratch" ) - -// LoadOrCreateTrustKey attempts to load the libtrust key at the given path, -// otherwise generates a new one -func LoadOrCreateTrustKey(trustKeyPath string) (libtrust.PrivateKey, error) { - err := system.MkdirAll(filepath.Dir(trustKeyPath), 0700, "") - if err != nil { - return nil, err - } - trustKey, err := libtrust.LoadKeyFile(trustKeyPath) - if err == libtrust.ErrKeyFileDoesNotExist { - trustKey, err = libtrust.GenerateECP256PrivateKey() - if err != nil { - return nil, fmt.Errorf("Error generating key: %s", err) - } - encodedKey, err := serializePrivateKey(trustKey, filepath.Ext(trustKeyPath)) - if err != nil { - return nil, fmt.Errorf("Error serializing key: %s", err) - } - if err := ioutils.AtomicWriteFile(trustKeyPath, encodedKey, os.FileMode(0600)); err != nil { - return nil, fmt.Errorf("Error saving key file: %s", err) - } - } else if err != nil { - return nil, fmt.Errorf("Error loading key file %s: %s", trustKeyPath, err) - } - return trustKey, nil -} - -func serializePrivateKey(key libtrust.PrivateKey, ext string) (encoded []byte, err error) { - if ext == ".json" || ext == ".jwk" { - encoded, err = json.Marshal(key) - if err != nil { - return nil, fmt.Errorf("unable to encode private key JWK: %s", err) - } - } else { - pemBlock, err := key.PEMBlock() - if err != nil { - return nil, fmt.Errorf("unable to encode private key PEM: %s", err) - } - encoded = pem.EncodeToMemory(pemBlock) - } - return -} diff --git a/vendor/github.com/docker/docker/api/common_test.go b/vendor/github.com/docker/docker/api/common_test.go deleted file mode 100644 index f466616b0..000000000 --- a/vendor/github.com/docker/docker/api/common_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package api - -import ( - "io/ioutil" - "path/filepath" - "testing" - - "os" -) - -// LoadOrCreateTrustKey -func TestLoadOrCreateTrustKeyInvalidKeyFile(t *testing.T) { - tmpKeyFolderPath, err := ioutil.TempDir("", "api-trustkey-test") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tmpKeyFolderPath) - - tmpKeyFile, err := ioutil.TempFile(tmpKeyFolderPath, "keyfile") - if err != nil { - t.Fatal(err) - } - - if _, err := LoadOrCreateTrustKey(tmpKeyFile.Name()); err == nil { - t.Fatal("expected an error, got nothing.") - } - -} - -func TestLoadOrCreateTrustKeyCreateKey(t *testing.T) { - tmpKeyFolderPath, err := ioutil.TempDir("", "api-trustkey-test") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tmpKeyFolderPath) - - // Without the need to create the folder hierarchy - tmpKeyFile := filepath.Join(tmpKeyFolderPath, "keyfile") - - if key, err := LoadOrCreateTrustKey(tmpKeyFile); err != nil || key == nil { - t.Fatalf("expected a new key file, got : %v and %v", err, key) - } - - if _, err := os.Stat(tmpKeyFile); err != nil { - t.Fatalf("Expected to find a file %s, got %v", tmpKeyFile, err) - } - - // With the need to create the folder hierarchy as tmpKeyFie is in a path - // where some folders do not exist. - tmpKeyFile = filepath.Join(tmpKeyFolderPath, "folder/hierarchy/keyfile") - - if key, err := LoadOrCreateTrustKey(tmpKeyFile); err != nil || key == nil { - t.Fatalf("expected a new key file, got : %v and %v", err, key) - } - - if _, err := os.Stat(tmpKeyFile); err != nil { - t.Fatalf("Expected to find a file %s, got %v", tmpKeyFile, err) - } - - // With no path at all - defer os.Remove("keyfile") - if key, err := LoadOrCreateTrustKey("keyfile"); err != nil || key == nil { - t.Fatalf("expected a new key file, got : %v and %v", err, key) - } - - if _, err := os.Stat("keyfile"); err != nil { - t.Fatalf("Expected to find a file keyfile, got %v", err) - } -} - -func TestLoadOrCreateTrustKeyLoadValidKey(t *testing.T) { - tmpKeyFile := filepath.Join("fixtures", "keyfile") - - if key, err := LoadOrCreateTrustKey(tmpKeyFile); err != nil || key == nil { - t.Fatalf("expected a key file, got : %v and %v", err, key) - } -} diff --git a/vendor/github.com/docker/docker/api/errdefs/defs.go b/vendor/github.com/docker/docker/api/errdefs/defs.go new file mode 100644 index 000000000..4987c623f --- /dev/null +++ b/vendor/github.com/docker/docker/api/errdefs/defs.go @@ -0,0 +1,54 @@ +package errdefs + +// ErrNotFound signals that the requested object doesn't exist +type ErrNotFound interface { + NotFound() +} + +// ErrInvalidParameter signals that the user input is invalid +type ErrInvalidParameter interface { + InvalidParameter() +} + +// ErrConflict signals that some internal state conflicts with the requested action and can't be performed. +// A change in state should be able to clear this error. +type ErrConflict interface { + Conflict() +} + +// ErrUnauthorized is used to signify that the user is not authorized to perform a specific action +type ErrUnauthorized interface { + Unauthorized() +} + +// ErrUnavailable signals that the requested action/subsystem is not available. +type ErrUnavailable interface { + Unavailable() +} + +// ErrForbidden signals that the requested action cannot be performed under any circumstances. +// When a ErrForbidden is returned, the caller should never retry the action. +type ErrForbidden interface { + Forbidden() +} + +// ErrSystem signals that some internal error occurred. +// An example of this would be a failed mount request. +type ErrSystem interface { + ErrSystem() +} + +// ErrNotModified signals that an action can't be performed because it's already in the desired state +type ErrNotModified interface { + NotModified() +} + +// ErrNotImplemented signals that the requested action/feature is not implemented on the system as configured. +type ErrNotImplemented interface { + NotImplemented() +} + +// ErrUnknown signals that the kind of error that occurred is not known. +type ErrUnknown interface { + Unknown() +} diff --git a/vendor/github.com/docker/docker/api/errdefs/doc.go b/vendor/github.com/docker/docker/api/errdefs/doc.go new file mode 100644 index 000000000..065346aa2 --- /dev/null +++ b/vendor/github.com/docker/docker/api/errdefs/doc.go @@ -0,0 +1,8 @@ +// Package errdefs defines a set of error interfaces that packages should use for communicating classes of errors. +// Errors that cross the package boundary should implement one (and only one) of these interfaces. +// +// Packages should not reference these interfaces directly, only implement them. +// To check if a particular error implements one of these interfaces, there are helper +// functions provided (e.g. `Is`) which can be used rather than asserting the interfaces directly. +// If you must assert on these interfaces, be sure to check the causal chain (`err.Cause()`). +package errdefs diff --git a/vendor/github.com/docker/docker/api/errdefs/is.go b/vendor/github.com/docker/docker/api/errdefs/is.go new file mode 100644 index 000000000..ce574cdd1 --- /dev/null +++ b/vendor/github.com/docker/docker/api/errdefs/is.go @@ -0,0 +1,86 @@ +package errdefs + +type causer interface { + Cause() error +} + +func getImplementer(err error) error { + switch e := err.(type) { + case + ErrNotFound, + ErrInvalidParameter, + ErrConflict, + ErrUnauthorized, + ErrUnavailable, + ErrForbidden, + ErrSystem, + ErrNotModified, + ErrNotImplemented, + ErrUnknown: + return e + case causer: + return getImplementer(e.Cause()) + default: + return err + } +} + +// IsNotFound returns if the passed in error is a ErrNotFound +func IsNotFound(err error) bool { + _, ok := getImplementer(err).(ErrNotFound) + return ok +} + +// IsInvalidParameter returns if the passed in error is an ErrInvalidParameter +func IsInvalidParameter(err error) bool { + _, ok := getImplementer(err).(ErrInvalidParameter) + return ok +} + +// IsConflict returns if the passed in error is a ErrConflict +func IsConflict(err error) bool { + _, ok := getImplementer(err).(ErrConflict) + return ok +} + +// IsUnauthorized returns if the the passed in error is an ErrUnauthorized +func IsUnauthorized(err error) bool { + _, ok := getImplementer(err).(ErrUnauthorized) + return ok +} + +// IsUnavailable returns if the passed in error is an ErrUnavailable +func IsUnavailable(err error) bool { + _, ok := getImplementer(err).(ErrUnavailable) + return ok +} + +// IsForbidden returns if the passed in error is a ErrForbidden +func IsForbidden(err error) bool { + _, ok := getImplementer(err).(ErrForbidden) + return ok +} + +// IsSystem returns if the passed in error is a ErrSystem +func IsSystem(err error) bool { + _, ok := getImplementer(err).(ErrSystem) + return ok +} + +// IsNotModified returns if the passed in error is a NotModified error +func IsNotModified(err error) bool { + _, ok := getImplementer(err).(ErrNotModified) + return ok +} + +// IsNotImplemented returns if the passed in error is a ErrNotImplemented +func IsNotImplemented(err error) bool { + _, ok := getImplementer(err).(ErrNotImplemented) + return ok +} + +// IsUnknown returns if the passed in error is an ErrUnknown +func IsUnknown(err error) bool { + _, ok := getImplementer(err).(ErrUnknown) + return ok +} diff --git a/vendor/github.com/docker/docker/api/errors/errors.go b/vendor/github.com/docker/docker/api/errors/errors.go deleted file mode 100644 index 39d52e1a0..000000000 --- a/vendor/github.com/docker/docker/api/errors/errors.go +++ /dev/null @@ -1,47 +0,0 @@ -package errors - -import "net/http" - -// apiError is an error wrapper that also -// holds information about response status codes. -type apiError struct { - error - statusCode int -} - -// HTTPErrorStatusCode returns a status code. -func (e apiError) HTTPErrorStatusCode() int { - return e.statusCode -} - -// NewErrorWithStatusCode allows you to associate -// a specific HTTP Status Code to an error. -// The server will take that code and set -// it as the response status. -func NewErrorWithStatusCode(err error, code int) error { - return apiError{err, code} -} - -// NewBadRequestError creates a new API error -// that has the 400 HTTP status code associated to it. -func NewBadRequestError(err error) error { - return NewErrorWithStatusCode(err, http.StatusBadRequest) -} - -// NewRequestForbiddenError creates a new API error -// that has the 403 HTTP status code associated to it. -func NewRequestForbiddenError(err error) error { - return NewErrorWithStatusCode(err, http.StatusForbidden) -} - -// NewRequestNotFoundError creates a new API error -// that has the 404 HTTP status code associated to it. -func NewRequestNotFoundError(err error) error { - return NewErrorWithStatusCode(err, http.StatusNotFound) -} - -// NewRequestConflictError creates a new API error -// that has the 409 HTTP status code associated to it. -func NewRequestConflictError(err error) error { - return NewErrorWithStatusCode(err, http.StatusConflict) -} diff --git a/vendor/github.com/docker/docker/api/errors/errors_test.go b/vendor/github.com/docker/docker/api/errors/errors_test.go deleted file mode 100644 index 1d6a596ac..000000000 --- a/vendor/github.com/docker/docker/api/errors/errors_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package errors - -import ( - "fmt" - "github.com/stretchr/testify/assert" - "net/http" - "testing" -) - -func newError(errorname string) error { - - return fmt.Errorf("test%v", errorname) -} - -func TestErrors(t *testing.T) { - errmsg := newError("apiError") - err := apiError{ - error: errmsg, - statusCode: 0, - } - assert.Equal(t, err.HTTPErrorStatusCode(), err.statusCode) - - errmsg = newError("ErrorWithStatusCode") - errcode := 1 - serr := NewErrorWithStatusCode(errmsg, errcode) - apierr, ok := serr.(apiError) - if !ok { - t.Fatal("excepted err is apiError type") - } - assert.Equal(t, errcode, apierr.statusCode) - - errmsg = newError("NewBadRequestError") - baderr := NewBadRequestError(errmsg) - apierr, ok = baderr.(apiError) - if !ok { - t.Fatal("excepted err is apiError type") - } - assert.Equal(t, http.StatusBadRequest, apierr.statusCode) - - errmsg = newError("RequestForbiddenError") - ferr := NewRequestForbiddenError(errmsg) - apierr, ok = ferr.(apiError) - if !ok { - t.Fatal("excepted err is apiError type") - } - assert.Equal(t, http.StatusForbidden, apierr.statusCode) - - errmsg = newError("RequestNotFoundError") - nerr := NewRequestNotFoundError(errmsg) - apierr, ok = nerr.(apiError) - if !ok { - t.Fatal("excepted err is apiError type") - } - assert.Equal(t, http.StatusNotFound, apierr.statusCode) - - errmsg = newError("RequestConflictError") - cerr := NewRequestConflictError(errmsg) - apierr, ok = cerr.(apiError) - if !ok { - t.Fatal("excepted err is apiError type") - } - assert.Equal(t, http.StatusConflict, apierr.statusCode) - -} diff --git a/vendor/github.com/docker/docker/api/server/httputils/errors.go b/vendor/github.com/docker/docker/api/server/httputils/errors.go index b677f95d6..05a842c3a 100644 --- a/vendor/github.com/docker/docker/api/server/httputils/errors.go +++ b/vendor/github.com/docker/docker/api/server/httputils/errors.go @@ -1,9 +1,10 @@ package httputils import ( + "fmt" "net/http" - "strings" + "github.com/docker/docker/api/errdefs" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/versions" "github.com/gorilla/mux" @@ -12,21 +13,8 @@ import ( "google.golang.org/grpc/codes" ) -// httpStatusError is an interface -// that errors with custom status codes -// implement to tell the api layer -// which response status to set. -type httpStatusError interface { - HTTPErrorStatusCode() int -} - -// inputValidationError is an interface -// that errors generated by invalid -// inputs can implement to tell the -// api layer to set a 400 status code -// in the response. -type inputValidationError interface { - IsValidationError() bool +type causer interface { + Cause() error } // GetHTTPErrorStatusCode retrieves status code from error message. @@ -37,49 +25,44 @@ func GetHTTPErrorStatusCode(err error) int { } var statusCode int - errMsg := err.Error() - switch e := err.(type) { - case httpStatusError: - statusCode = e.HTTPErrorStatusCode() - case inputValidationError: + // Stop right there + // Are you sure you should be adding a new error class here? Do one of the existing ones work? + + // Note that the below functions are already checking the error causal chain for matches. + switch { + case errdefs.IsNotFound(err): + statusCode = http.StatusNotFound + case errdefs.IsInvalidParameter(err): statusCode = http.StatusBadRequest + case errdefs.IsConflict(err): + statusCode = http.StatusConflict + case errdefs.IsUnauthorized(err): + statusCode = http.StatusUnauthorized + case errdefs.IsUnavailable(err): + statusCode = http.StatusServiceUnavailable + case errdefs.IsForbidden(err): + statusCode = http.StatusForbidden + case errdefs.IsNotModified(err): + statusCode = http.StatusNotModified + case errdefs.IsNotImplemented(err): + statusCode = http.StatusNotImplemented + case errdefs.IsSystem(err) || errdefs.IsUnknown(err): + statusCode = http.StatusInternalServerError default: statusCode = statusCodeFromGRPCError(err) if statusCode != http.StatusInternalServerError { return statusCode } - // FIXME: this is brittle and should not be necessary, but we still need to identify if - // there are errors falling back into this logic. - // If we need to differentiate between different possible error types, - // we should create appropriate error types that implement the httpStatusError interface. - errStr := strings.ToLower(errMsg) - - for _, status := range []struct { - keyword string - code int - }{ - {"not found", http.StatusNotFound}, - {"cannot find", http.StatusNotFound}, - {"no such", http.StatusNotFound}, - {"bad parameter", http.StatusBadRequest}, - {"no command", http.StatusBadRequest}, - {"conflict", http.StatusConflict}, - {"impossible", http.StatusNotAcceptable}, - {"wrong login/password", http.StatusUnauthorized}, - {"unauthorized", http.StatusUnauthorized}, - {"hasn't been activated", http.StatusForbidden}, - {"this node", http.StatusServiceUnavailable}, - {"needs to be unlocked", http.StatusServiceUnavailable}, - {"certificates have expired", http.StatusServiceUnavailable}, - {"repository does not exist", http.StatusNotFound}, - } { - if strings.Contains(errStr, status.keyword) { - statusCode = status.code - break - } + if e, ok := err.(causer); ok { + return GetHTTPErrorStatusCode(e.Cause()) } + + logrus.WithFields(logrus.Fields{ + "module": "api", + "error_type": fmt.Sprintf("%T", err), + }).Debugf("FIXME: Got an API for which error does not match any expected type!!!: %+v", err) } if statusCode == 0 { @@ -133,6 +116,9 @@ func statusCodeFromGRPCError(err error) int { case codes.Unavailable: // code 14 return http.StatusServiceUnavailable default: + if e, ok := err.(causer); ok { + return statusCodeFromGRPCError(e.Cause()) + } // codes.Canceled(1) // codes.Unknown(2) // codes.DeadlineExceeded(4) diff --git a/vendor/github.com/docker/docker/api/server/httputils/form.go b/vendor/github.com/docker/docker/api/server/httputils/form.go index 78bd379c7..1ce822ed9 100644 --- a/vendor/github.com/docker/docker/api/server/httputils/form.go +++ b/vendor/github.com/docker/docker/api/server/httputils/form.go @@ -1,9 +1,7 @@ package httputils import ( - "errors" "net/http" - "path/filepath" "strconv" "strings" ) @@ -49,6 +47,16 @@ type ArchiveOptions struct { Path string } +type badParameterError struct { + param string +} + +func (e badParameterError) Error() string { + return "bad parameter: " + e.param + "cannot be empty" +} + +func (e badParameterError) InvalidParameter() {} + // ArchiveFormValues parses form values and turns them into ArchiveOptions. // It fails if the archive name and path are not in the request. func ArchiveFormValues(r *http.Request, vars map[string]string) (ArchiveOptions, error) { @@ -57,14 +65,12 @@ func ArchiveFormValues(r *http.Request, vars map[string]string) (ArchiveOptions, } name := vars["name"] - path := filepath.FromSlash(r.Form.Get("path")) - - switch { - case name == "": - return ArchiveOptions{}, errors.New("bad parameter: 'name' cannot be empty") - case path == "": - return ArchiveOptions{}, errors.New("bad parameter: 'path' cannot be empty") + if name == "" { + return ArchiveOptions{}, badParameterError{"name"} + } + path := r.Form.Get("path") + if path == "" { + return ArchiveOptions{}, badParameterError{"path"} } - return ArchiveOptions{name, path}, nil } diff --git a/vendor/github.com/docker/docker/api/server/httputils/httputils.go b/vendor/github.com/docker/docker/api/server/httputils/httputils.go index 4708d7d16..57eeb4beb 100644 --- a/vendor/github.com/docker/docker/api/server/httputils/httputils.go +++ b/vendor/github.com/docker/docker/api/server/httputils/httputils.go @@ -1,12 +1,12 @@ package httputils import ( - "fmt" "io" "mime" "net/http" "strings" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/net/context" ) @@ -43,6 +43,20 @@ func CloseStreams(streams ...interface{}) { } } +type validationError struct { + cause error +} + +func (e validationError) Error() string { + return e.cause.Error() +} + +func (e validationError) Cause() error { + return e.cause +} + +func (e validationError) InvalidParameter() {} + // CheckForJSON makes sure that the request's Content-Type is application/json. func CheckForJSON(r *http.Request) error { ct := r.Header.Get("Content-Type") @@ -58,7 +72,7 @@ func CheckForJSON(r *http.Request) error { if matchesContentType(ct, "application/json") { return nil } - return fmt.Errorf("Content-Type specified (%s) must be 'application/json'", ct) + return validationError{errors.Errorf("Content-Type specified (%s) must be 'application/json'", ct)} } // ParseForm ensures the request form is parsed even with invalid content types. @@ -68,7 +82,7 @@ func ParseForm(r *http.Request) error { return nil } if err := r.ParseForm(); err != nil && !strings.HasPrefix(err.Error(), "mime:") { - return err + return validationError{err} } return nil } diff --git a/vendor/github.com/docker/docker/api/server/httputils/write_log_stream.go b/vendor/github.com/docker/docker/api/server/httputils/write_log_stream.go index fd024e196..e90e610da 100644 --- a/vendor/github.com/docker/docker/api/server/httputils/write_log_stream.go +++ b/vendor/github.com/docker/docker/api/server/httputils/write_log_stream.go @@ -17,20 +17,13 @@ import ( // WriteLogStream writes an encoded byte stream of log messages from the // messages channel, multiplexing them with a stdcopy.Writer if mux is true -func WriteLogStream(ctx context.Context, w io.Writer, msgs <-chan *backend.LogMessage, config *types.ContainerLogsOptions, mux bool) { +func WriteLogStream(_ context.Context, w io.Writer, msgs <-chan *backend.LogMessage, config *types.ContainerLogsOptions, mux bool) { wf := ioutils.NewWriteFlusher(w) defer wf.Close() wf.Flush() - // this might seem like doing below is clear: - // var outStream io.Writer = wf - // however, this GREATLY DISPLEASES golint, and if you do that, it will - // fail CI. we need outstream to be type writer because if we mux streams, - // we will need to reassign all of the streams to be stdwriters, which only - // conforms to the io.Writer interface. - var outStream io.Writer - outStream = wf + outStream := io.Writer(wf) errStream := outStream sysErrStream := errStream if mux { diff --git a/vendor/github.com/docker/docker/api/server/middleware/version.go b/vendor/github.com/docker/docker/api/server/middleware/version.go index 390a7f059..ef35c728f 100644 --- a/vendor/github.com/docker/docker/api/server/middleware/version.go +++ b/vendor/github.com/docker/docker/api/server/middleware/version.go @@ -5,7 +5,6 @@ import ( "net/http" "runtime" - "github.com/docker/docker/api/errors" "github.com/docker/docker/api/types/versions" "golang.org/x/net/context" ) @@ -28,6 +27,16 @@ func NewVersionMiddleware(s, d, m string) VersionMiddleware { } } +type versionUnsupportedError struct { + version, minVersion string +} + +func (e versionUnsupportedError) Error() string { + return fmt.Sprintf("client version %s is too old. Minimum supported API version is %s, please upgrade your client to a newer version", e.version, e.minVersion) +} + +func (e versionUnsupportedError) InvalidParameter() {} + // WrapHandler returns a new handler function wrapping the previous one in the request chain. func (v VersionMiddleware) WrapHandler(handler func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error) func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { @@ -37,13 +46,14 @@ func (v VersionMiddleware) WrapHandler(handler func(ctx context.Context, w http. } if versions.LessThan(apiVersion, v.minVersion) { - return errors.NewBadRequestError(fmt.Errorf("client version %s is too old. Minimum supported API version is %s, please upgrade your client to a newer version", apiVersion, v.minVersion)) + return versionUnsupportedError{apiVersion, v.minVersion} } header := fmt.Sprintf("Docker/%s (%s)", v.serverVersion, runtime.GOOS) w.Header().Set("Server", header) w.Header().Set("API-Version", v.defaultVersion) w.Header().Set("OSType", runtime.GOOS) + // nolint: golint ctx = context.WithValue(ctx, "api-version", apiVersion) return handler(ctx, w, r, vars) } diff --git a/vendor/github.com/docker/docker/api/server/router/build/build_routes.go b/vendor/github.com/docker/docker/api/server/router/build/build_routes.go index d9a123915..2c9a94795 100644 --- a/vendor/github.com/docker/docker/api/server/router/build/build_routes.go +++ b/vendor/github.com/docker/docker/api/server/router/build/build_routes.go @@ -12,7 +12,6 @@ import ( "strings" "sync" - apierrors "github.com/docker/docker/api/errors" "github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" @@ -27,6 +26,14 @@ import ( "golang.org/x/net/context" ) +type invalidIsolationError string + +func (e invalidIsolationError) Error() string { + return fmt.Sprintf("Unsupported isolation: %q", string(e)) +} + +func (e invalidIsolationError) InvalidParameter() {} + func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBuildOptions, error) { version := httputils.VersionFromContext(ctx) options := &types.ImageBuildOptions{} @@ -71,20 +78,20 @@ func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBui if i := container.Isolation(r.FormValue("isolation")); i != "" { if !container.Isolation.IsValid(i) { - return nil, fmt.Errorf("Unsupported isolation: %q", i) + return nil, invalidIsolationError(i) } options.Isolation = i } if runtime.GOOS != "windows" && options.SecurityOpt != nil { - return nil, fmt.Errorf("The daemon on this platform does not support setting security options on build") + return nil, validationError{fmt.Errorf("The daemon on this platform does not support setting security options on build")} } var buildUlimits = []*units.Ulimit{} ulimitsJSON := r.FormValue("ulimits") if ulimitsJSON != "" { if err := json.Unmarshal([]byte(ulimitsJSON), &buildUlimits); err != nil { - return nil, err + return nil, errors.Wrap(validationError{err}, "error reading ulimit settings") } options.Ulimits = buildUlimits } @@ -105,7 +112,7 @@ func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBui if buildArgsJSON != "" { var buildArgs = map[string]*string{} if err := json.Unmarshal([]byte(buildArgsJSON), &buildArgs); err != nil { - return nil, err + return nil, errors.Wrap(validationError{err}, "error reading build args") } options.BuildArgs = buildArgs } @@ -114,7 +121,7 @@ func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBui if labelsJSON != "" { var labels = map[string]string{} if err := json.Unmarshal([]byte(labelsJSON), &labels); err != nil { - return nil, err + return nil, errors.Wrap(validationError{err}, "error reading labels") } options.Labels = labels } @@ -140,6 +147,16 @@ func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r * return httputils.WriteJSON(w, http.StatusOK, report) } +type validationError struct { + cause error +} + +func (e validationError) Error() string { + return e.cause.Error() +} + +func (e validationError) InvalidParameter() {} + func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { var ( notVerboseBuffer = bytes.NewBuffer(nil) @@ -173,8 +190,7 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r * buildOptions.AuthConfigs = getAuthConfigs(r.Header) if buildOptions.Squash && !br.daemon.HasExperimental() { - return apierrors.NewBadRequestError( - errors.New("squash is only supported with experimental mode")) + return validationError{errors.New("squash is only supported with experimental mode")} } out := io.Writer(output) diff --git a/vendor/github.com/docker/docker/api/server/router/container/backend.go b/vendor/github.com/docker/docker/api/server/router/container/backend.go index d51ed8177..8a32f26e6 100644 --- a/vendor/github.com/docker/docker/api/server/router/container/backend.go +++ b/vendor/github.com/docker/docker/api/server/router/container/backend.go @@ -18,7 +18,7 @@ type execBackend interface { ContainerExecCreate(name string, config *types.ExecConfig) (string, error) ContainerExecInspect(id string) (*backend.ExecInspect, error) ContainerExecResize(name string, height, width int) error - ContainerExecStart(ctx context.Context, name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error + ContainerExecStart(ctx context.Context, name string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error ExecExists(name string) (bool, error) } @@ -51,7 +51,7 @@ type stateBackend interface { type monitorBackend interface { ContainerChanges(name string) ([]archive.Change, error) ContainerInspect(name string, size bool, version string) (interface{}, error) - ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (<-chan *backend.LogMessage, error) + ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error) ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error) diff --git a/vendor/github.com/docker/docker/api/server/router/container/container.go b/vendor/github.com/docker/docker/api/server/router/container/container.go index 24c3224ee..90ae6dc38 100644 --- a/vendor/github.com/docker/docker/api/server/router/container/container.go +++ b/vendor/github.com/docker/docker/api/server/router/container/container.go @@ -6,13 +6,19 @@ import ( ) type validationError struct { - error + cause error } -func (validationError) IsValidationError() bool { - return true +func (e validationError) Error() string { + return e.cause.Error() } +func (e validationError) Cause() error { + return e.cause +} + +func (e validationError) InvalidParameter() {} + // containerRouter is a router to talk with the container controller type containerRouter struct { backend Backend diff --git a/vendor/github.com/docker/docker/api/server/router/container/container_routes.go b/vendor/github.com/docker/docker/api/server/router/container/container_routes.go index 57204b2e8..30fd3a15b 100644 --- a/vendor/github.com/docker/docker/api/server/router/container/container_routes.go +++ b/vendor/github.com/docker/docker/api/server/router/container/container_routes.go @@ -8,7 +8,7 @@ import ( "strconv" "syscall" - "github.com/docker/docker/api" + "github.com/docker/docker/api/errdefs" "github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" @@ -18,6 +18,7 @@ import ( containerpkg "github.com/docker/docker/container" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/signal" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/net/context" "golang.org/x/net/websocket" @@ -69,7 +70,7 @@ func (s *containerRouter) getContainersStats(ctx context.Context, w http.Respons config := &backend.ContainerStatsConfig{ Stream: stream, OutStream: w, - Version: string(httputils.VersionFromContext(ctx)), + Version: httputils.VersionFromContext(ctx), } return s.backend.ContainerStats(ctx, vars["name"], config) @@ -87,7 +88,7 @@ func (s *containerRouter) getContainersLogs(ctx context.Context, w http.Response // with the appropriate status code. stdout, stderr := httputils.BoolValue(r, "stdout"), httputils.BoolValue(r, "stderr") if !(stdout || stderr) { - return fmt.Errorf("Bad parameters: you must choose at least one stream") + return validationError{errors.New("Bad parameters: you must choose at least one stream")} } containerName := vars["name"] @@ -101,19 +102,7 @@ func (s *containerRouter) getContainersLogs(ctx context.Context, w http.Response Details: httputils.BoolValue(r, "details"), } - // doesn't matter what version the client is on, we're using this internally only - // also do we need size? i'm thinking no we don't - raw, err := s.backend.ContainerInspect(containerName, false, api.DefaultVersion) - if err != nil { - return err - } - container, ok := raw.(*types.ContainerJSON) - if !ok { - // %T prints the type. handy! - return fmt.Errorf("expected container to be *types.ContainerJSON but got %T", raw) - } - - msgs, err := s.backend.ContainerLogs(ctx, containerName, logsConfig) + msgs, tty, err := s.backend.ContainerLogs(ctx, containerName, logsConfig) if err != nil { return err } @@ -122,7 +111,7 @@ func (s *containerRouter) getContainersLogs(ctx context.Context, w http.Response // this is the point of no return for writing a response. once we call // WriteLogStream, the response has been started and errors will be // returned in band by WriteLogStream - httputils.WriteLogStream(ctx, w, msgs, logsConfig, !container.Config.Tty) + httputils.WriteLogStream(ctx, w, msgs, logsConfig, !tty) return nil } @@ -130,6 +119,14 @@ func (s *containerRouter) getContainersExport(ctx context.Context, w http.Respon return s.backend.ContainerExport(vars["name"], w) } +type bodyOnStartError struct{} + +func (bodyOnStartError) Error() string { + return "starting container with non-empty request body was deprecated since API v1.22 and removed in v1.24" +} + +func (bodyOnStartError) InvalidParameter() {} + func (s *containerRouter) postContainersStart(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { // If contentLength is -1, we can assumed chunked encoding // or more technically that the length is unknown @@ -143,7 +140,7 @@ func (s *containerRouter) postContainersStart(ctx context.Context, w http.Respon // A non-nil json object is at least 7 characters. if r.ContentLength > 7 || r.ContentLength == -1 { if versions.GreaterThanOrEqualTo(version, "1.24") { - return validationError{fmt.Errorf("starting container with non-empty request body was deprecated since v1.10 and removed in v1.12")} + return bodyOnStartError{} } if err := httputils.CheckForJSON(r); err != nil { @@ -193,10 +190,6 @@ func (s *containerRouter) postContainersStop(ctx context.Context, w http.Respons return nil } -type errContainerIsRunning interface { - ContainerIsRunning() bool -} - func (s *containerRouter) postContainersKill(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := httputils.ParseForm(r); err != nil { return err @@ -209,14 +202,14 @@ func (s *containerRouter) postContainersKill(ctx context.Context, w http.Respons if sigStr := r.Form.Get("signal"); sigStr != "" { var err error if sig, err = signal.ParseSignal(sigStr); err != nil { - return err + return validationError{err} } } if err := s.backend.ContainerKill(name, uint64(sig)); err != nil { var isStopped bool - if e, ok := err.(errContainerIsRunning); ok { - isStopped = !e.ContainerIsRunning() + if errdefs.IsConflict(err) { + isStopped = true } // Return error that's not caused because the container is stopped. @@ -224,7 +217,7 @@ func (s *containerRouter) postContainersKill(ctx context.Context, w http.Respons // to keep backwards compatibility. version := httputils.VersionFromContext(ctx) if versions.GreaterThanOrEqualTo(version, "1.20") || !isStopped { - return fmt.Errorf("Cannot kill container %s: %v", name, err) + return errors.Wrapf(err, "Cannot kill container: %s", name) } } @@ -458,11 +451,11 @@ func (s *containerRouter) postContainersResize(ctx context.Context, w http.Respo height, err := strconv.Atoi(r.Form.Get("h")) if err != nil { - return err + return validationError{err} } width, err := strconv.Atoi(r.Form.Get("w")) if err != nil { - return err + return validationError{err} } return s.backend.ContainerResize(vars["name"], height, width) @@ -480,7 +473,7 @@ func (s *containerRouter) postContainersAttach(ctx context.Context, w http.Respo hijacker, ok := w.(http.Hijacker) if !ok { - return fmt.Errorf("error attaching to container %s, hijack connection missing", containerName) + return validationError{errors.Errorf("error attaching to container %s, hijack connection missing", containerName)} } setupStreams := func() (io.ReadCloser, io.Writer, io.Writer, error) { @@ -597,7 +590,7 @@ func (s *containerRouter) postContainersPrune(ctx context.Context, w http.Respon pruneFilters, err := filters.FromParam(r.Form.Get("filters")) if err != nil { - return err + return validationError{err} } pruneReport, err := s.backend.ContainersPrune(ctx, pruneFilters) diff --git a/vendor/github.com/docker/docker/api/server/router/container/copy.go b/vendor/github.com/docker/docker/api/server/router/container/copy.go index 5cfe8d7ba..356775f4d 100644 --- a/vendor/github.com/docker/docker/api/server/router/container/copy.go +++ b/vendor/github.com/docker/docker/api/server/router/container/copy.go @@ -3,11 +3,8 @@ package container import ( "encoding/base64" "encoding/json" - "fmt" "io" "net/http" - "os" - "strings" "github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/types" @@ -15,6 +12,14 @@ import ( "golang.org/x/net/context" ) +type pathError struct{} + +func (pathError) Error() string { + return "Path cannot be empty" +} + +func (pathError) InvalidParameter() {} + // postContainersCopy is deprecated in favor of getContainersArchive. func (s *containerRouter) postContainersCopy(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { // Deprecated since 1.8, Errors out since 1.12 @@ -33,18 +38,11 @@ func (s *containerRouter) postContainersCopy(ctx context.Context, w http.Respons } if cfg.Resource == "" { - return fmt.Errorf("Path cannot be empty") + return pathError{} } data, err := s.backend.ContainerCopy(vars["name"], cfg.Resource) if err != nil { - if strings.Contains(strings.ToLower(err.Error()), "no such container") { - w.WriteHeader(http.StatusNotFound) - return nil - } - if os.IsNotExist(err) { - return fmt.Errorf("Could not find the file %s in container %s", cfg.Resource, vars["name"]) - } return err } defer data.Close() diff --git a/vendor/github.com/docker/docker/api/server/router/container/exec.go b/vendor/github.com/docker/docker/api/server/router/container/exec.go index 64629b69a..aa2ebb187 100644 --- a/vendor/github.com/docker/docker/api/server/router/container/exec.go +++ b/vendor/github.com/docker/docker/api/server/router/container/exec.go @@ -24,6 +24,14 @@ func (s *containerRouter) getExecByID(ctx context.Context, w http.ResponseWriter return httputils.WriteJSON(w, http.StatusOK, eConfig) } +type execCommandError struct{} + +func (execCommandError) Error() string { + return "No exec command specified" +} + +func (execCommandError) InvalidParameter() {} + func (s *containerRouter) postContainerExecCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := httputils.ParseForm(r); err != nil { return err @@ -39,7 +47,7 @@ func (s *containerRouter) postContainerExecCreate(ctx context.Context, w http.Re } if len(execConfig.Cmd) == 0 { - return fmt.Errorf("No exec command specified") + return execCommandError{} } // Register an instance of Exec in container. @@ -129,11 +137,11 @@ func (s *containerRouter) postContainerExecResize(ctx context.Context, w http.Re } height, err := strconv.Atoi(r.Form.Get("h")) if err != nil { - return err + return validationError{err} } width, err := strconv.Atoi(r.Form.Get("w")) if err != nil { - return err + return validationError{err} } return s.backend.ContainerExecResize(vars["name"], height, width) diff --git a/vendor/github.com/docker/docker/api/server/router/experimental.go b/vendor/github.com/docker/docker/api/server/router/experimental.go index ac31f0487..4045de543 100644 --- a/vendor/github.com/docker/docker/api/server/router/experimental.go +++ b/vendor/github.com/docker/docker/api/server/router/experimental.go @@ -1,19 +1,13 @@ package router import ( - "errors" "net/http" "golang.org/x/net/context" - apierrors "github.com/docker/docker/api/errors" "github.com/docker/docker/api/server/httputils" ) -var ( - errExperimentalFeature = errors.New("This experimental feature is disabled by default. Start the Docker daemon in experimental mode in order to enable it.") -) - // ExperimentalRoute defines an experimental API route that can be enabled or disabled. type ExperimentalRoute interface { Route @@ -39,8 +33,16 @@ func (r *experimentalRoute) Disable() { r.handler = experimentalHandler } +type notImplementedError struct{} + +func (notImplementedError) Error() string { + return "This experimental feature is disabled by default. Start the Docker daemon in experimental mode in order to enable it." +} + +func (notImplementedError) NotImplemented() {} + func experimentalHandler(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { - return apierrors.NewErrorWithStatusCode(errExperimentalFeature, http.StatusNotImplemented) + return notImplementedError{} } // Handler returns returns the APIFunc to let the server wrap it in middlewares. diff --git a/vendor/github.com/docker/docker/api/server/router/image/image_routes.go b/vendor/github.com/docker/docker/api/server/router/image/image_routes.go index 9b99a585f..86d73df0e 100644 --- a/vendor/github.com/docker/docker/api/server/router/image/image_routes.go +++ b/vendor/github.com/docker/docker/api/server/router/image/image_routes.go @@ -3,7 +3,6 @@ package image import ( "encoding/base64" "encoding/json" - "fmt" "io" "net/http" "runtime" @@ -20,6 +19,7 @@ import ( "github.com/docker/docker/pkg/streamformatter" "github.com/docker/docker/pkg/system" "github.com/docker/docker/registry" + "github.com/pkg/errors" "golang.org/x/net/context" ) @@ -66,9 +66,7 @@ func (s *imageRouter) postCommit(ctx context.Context, w http.ResponseWriter, r * return err } - return httputils.WriteJSON(w, http.StatusCreated, &types.IDResponse{ - ID: string(imgID), - }) + return httputils.WriteJSON(w, http.StatusCreated, &types.IDResponse{ID: imgID}) } // Creates an image from Pull or from Import @@ -161,6 +159,20 @@ func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite return nil } +type validationError struct { + cause error +} + +func (e validationError) Error() string { + return e.cause.Error() +} + +func (e validationError) Cause() error { + return e.cause +} + +func (validationError) InvalidParameter() {} + func (s *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { metaHeaders := map[string][]string{} for k, v := range r.Header { @@ -184,7 +196,7 @@ func (s *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter, } else { // the old format is supported for compatibility if there was no authConfig header if err := json.NewDecoder(r.Body).Decode(authConfig); err != nil { - return fmt.Errorf("Bad parameters and missing X-Registry-Auth: %v", err) + return errors.Wrap(validationError{err}, "Bad parameters and missing X-Registry-Auth") } } @@ -246,6 +258,14 @@ func (s *imageRouter) postImagesLoad(ctx context.Context, w http.ResponseWriter, return nil } +type missingImageError struct{} + +func (missingImageError) Error() string { + return "image name cannot be blank" +} + +func (missingImageError) InvalidParameter() {} + func (s *imageRouter) deleteImages(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := httputils.ParseForm(r); err != nil { return err @@ -254,7 +274,7 @@ func (s *imageRouter) deleteImages(ctx context.Context, w http.ResponseWriter, r name := vars["name"] if strings.TrimSpace(name) == "" { - return fmt.Errorf("image name cannot be blank") + return missingImageError{} } force := httputils.BoolValue(r, "force") diff --git a/vendor/github.com/docker/docker/api/server/router/network/filter.go b/vendor/github.com/docker/docker/api/server/router/network/filter.go index afe4e235e..21fc828b8 100644 --- a/vendor/github.com/docker/docker/api/server/router/network/filter.go +++ b/vendor/github.com/docker/docker/api/server/router/network/filter.go @@ -1,8 +1,6 @@ package network import ( - "fmt" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/runconfig" @@ -24,11 +22,19 @@ func filterNetworkByType(nws []types.NetworkResource, netType string) ([]types.N } } default: - return nil, fmt.Errorf("Invalid filter: 'type'='%s'", netType) + return nil, invalidFilter(netType) } return retNws, nil } +type invalidFilter string + +func (e invalidFilter) Error() string { + return "Invalid filter: 'type'='" + string(e) + "'" +} + +func (e invalidFilter) InvalidParameter() {} + // filterNetworks filters network list according to user specified filter // and returns user chosen networks func filterNetworks(nws []types.NetworkResource, filter filters.Args) ([]types.NetworkResource, error) { diff --git a/vendor/github.com/docker/docker/api/server/router/network/network_routes.go b/vendor/github.com/docker/docker/api/server/router/network/network_routes.go index f439d65ad..ad3e74e6e 100644 --- a/vendor/github.com/docker/docker/api/server/router/network/network_routes.go +++ b/vendor/github.com/docker/docker/api/server/router/network/network_routes.go @@ -2,14 +2,12 @@ package network import ( "encoding/json" - "fmt" "net/http" "strconv" "strings" "golang.org/x/net/context" - "github.com/docker/docker/api/errors" "github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" @@ -18,6 +16,7 @@ import ( "github.com/docker/libnetwork" netconst "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/networkdb" + "github.com/pkg/errors" ) var ( @@ -83,6 +82,24 @@ SKIP: return httputils.WriteJSON(w, http.StatusOK, list) } +type invalidRequestError struct { + cause error +} + +func (e invalidRequestError) Error() string { + return e.cause.Error() +} + +func (e invalidRequestError) InvalidParameter() {} + +type ambigousResultsError string + +func (e ambigousResultsError) Error() string { + return "network " + string(e) + " is ambiguous" +} + +func (ambigousResultsError) InvalidParameter() {} + func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := httputils.ParseForm(r); err != nil { return err @@ -95,8 +112,7 @@ func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r ) if v := r.URL.Query().Get("verbose"); v != "" { if verbose, err = strconv.ParseBool(v); err != nil { - err = fmt.Errorf("invalid value for verbose: %s", v) - return errors.NewBadRequestError(err) + return errors.Wrapf(invalidRequestError{err}, "invalid value for verbose: %s", v) } } scope := r.URL.Query().Get("scope") @@ -177,7 +193,7 @@ func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r } } if len(listByFullName) > 1 { - return fmt.Errorf("network %s is ambiguous (%d matches found based on name)", term, len(listByFullName)) + return errors.Wrapf(ambigousResultsError(term), "%d matches found based on name", len(listByFullName)) } // Find based on partial ID, returns true only if no duplicates @@ -187,7 +203,7 @@ func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r } } if len(listByPartialID) > 1 { - return fmt.Errorf("network %s is ambiguous (%d matches found based on ID prefix)", term, len(listByPartialID)) + return errors.Wrapf(ambigousResultsError(term), "%d matches found based on ID prefix", len(listByPartialID)) } return libnetwork.ErrNoSuchNetwork(term) diff --git a/vendor/github.com/docker/docker/api/server/router/session/session_routes.go b/vendor/github.com/docker/docker/api/server/router/session/session_routes.go index ef9753c6e..bccd76422 100644 --- a/vendor/github.com/docker/docker/api/server/router/session/session_routes.go +++ b/vendor/github.com/docker/docker/api/server/router/session/session_routes.go @@ -3,14 +3,27 @@ package session import ( "net/http" - apierrors "github.com/docker/docker/api/errors" "golang.org/x/net/context" ) +type invalidRequest struct { + cause error +} + +func (e invalidRequest) Error() string { + return e.cause.Error() +} + +func (e invalidRequest) Cause() error { + return e.cause +} + +func (e invalidRequest) InvalidParameter() {} + func (sr *sessionRouter) startSession(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { err := sr.backend.HandleHTTPRequest(ctx, w, r) if err != nil { - return apierrors.NewBadRequestError(err) + return invalidRequest{err} } return nil } diff --git a/vendor/github.com/docker/docker/api/server/router/swarm/cluster_routes.go b/vendor/github.com/docker/docker/api/server/router/swarm/cluster_routes.go index a1e18f5fa..55743a621 100644 --- a/vendor/github.com/docker/docker/api/server/router/swarm/cluster_routes.go +++ b/vendor/github.com/docker/docker/api/server/router/swarm/cluster_routes.go @@ -6,13 +6,13 @@ import ( "net/http" "strconv" - "github.com/docker/docker/api/errors" "github.com/docker/docker/api/server/httputils" basictypes "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" "github.com/docker/docker/api/types/filters" types "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/versions" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/net/context" ) @@ -57,6 +57,20 @@ func (sr *swarmRouter) inspectCluster(ctx context.Context, w http.ResponseWriter return httputils.WriteJSON(w, http.StatusOK, swarm) } +type invalidRequestError struct { + err error +} + +func (e invalidRequestError) Error() string { + return e.err.Error() +} + +func (e invalidRequestError) Cause() error { + return e.err +} + +func (e invalidRequestError) InvalidParameter() {} + func (sr *swarmRouter) updateCluster(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { var swarm types.Spec if err := json.NewDecoder(r.Body).Decode(&swarm); err != nil { @@ -67,7 +81,7 @@ func (sr *swarmRouter) updateCluster(ctx context.Context, w http.ResponseWriter, version, err := strconv.ParseUint(rawVersion, 10, 64) if err != nil { err := fmt.Errorf("invalid swarm version '%s': %v", rawVersion, err) - return errors.NewBadRequestError(err) + return invalidRequestError{err} } var flags types.UpdateFlags @@ -76,7 +90,7 @@ func (sr *swarmRouter) updateCluster(ctx context.Context, w http.ResponseWriter, rot, err := strconv.ParseBool(value) if err != nil { err := fmt.Errorf("invalid value for rotateWorkerToken: %s", value) - return errors.NewBadRequestError(err) + return invalidRequestError{err} } flags.RotateWorkerToken = rot @@ -86,7 +100,7 @@ func (sr *swarmRouter) updateCluster(ctx context.Context, w http.ResponseWriter, rot, err := strconv.ParseBool(value) if err != nil { err := fmt.Errorf("invalid value for rotateManagerToken: %s", value) - return errors.NewBadRequestError(err) + return invalidRequestError{err} } flags.RotateManagerToken = rot @@ -95,7 +109,7 @@ func (sr *swarmRouter) updateCluster(ctx context.Context, w http.ResponseWriter, if value := r.URL.Query().Get("rotateManagerUnlockKey"); value != "" { rot, err := strconv.ParseBool(value) if err != nil { - return errors.NewBadRequestError(fmt.Errorf("invalid value for rotateManagerUnlockKey: %s", value)) + return invalidRequestError{fmt.Errorf("invalid value for rotateManagerUnlockKey: %s", value)} } flags.RotateManagerUnlockKey = rot @@ -139,7 +153,7 @@ func (sr *swarmRouter) getServices(ctx context.Context, w http.ResponseWriter, r } filter, err := filters.FromParam(r.Form.Get("filters")) if err != nil { - return err + return invalidRequestError{err} } services, err := sr.backend.GetServices(basictypes.ServiceListOptions{Filters: filter}) @@ -158,7 +172,7 @@ func (sr *swarmRouter) getService(ctx context.Context, w http.ResponseWriter, r insertDefaults, err = strconv.ParseBool(value) if err != nil { err := fmt.Errorf("invalid value for insertDefaults: %s", value) - return errors.NewBadRequestError(err) + return errors.Wrapf(invalidRequestError{err}, "invalid value for insertDefaults: %s", value) } } @@ -204,7 +218,7 @@ func (sr *swarmRouter) updateService(ctx context.Context, w http.ResponseWriter, version, err := strconv.ParseUint(rawVersion, 10, 64) if err != nil { err := fmt.Errorf("invalid service version '%s': %v", rawVersion, err) - return errors.NewBadRequestError(err) + return invalidRequestError{err} } var flags basictypes.ServiceUpdateOptions @@ -297,7 +311,7 @@ func (sr *swarmRouter) updateNode(ctx context.Context, w http.ResponseWriter, r version, err := strconv.ParseUint(rawVersion, 10, 64) if err != nil { err := fmt.Errorf("invalid node version '%s': %v", rawVersion, err) - return errors.NewBadRequestError(err) + return invalidRequestError{err} } if err := sr.backend.UpdateNode(vars["id"], version, node); err != nil { @@ -403,21 +417,17 @@ func (sr *swarmRouter) getSecret(ctx context.Context, w http.ResponseWriter, r * func (sr *swarmRouter) updateSecret(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { var secret types.SecretSpec if err := json.NewDecoder(r.Body).Decode(&secret); err != nil { - return errors.NewBadRequestError(err) + return invalidRequestError{err} } rawVersion := r.URL.Query().Get("version") version, err := strconv.ParseUint(rawVersion, 10, 64) if err != nil { - return errors.NewBadRequestError(fmt.Errorf("invalid secret version")) + return invalidRequestError{fmt.Errorf("invalid secret version")} } id := vars["id"] - if err := sr.backend.UpdateSecret(id, version, secret); err != nil { - return err - } - - return nil + return sr.backend.UpdateSecret(id, version, secret) } func (sr *swarmRouter) getConfigs(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { @@ -474,19 +484,15 @@ func (sr *swarmRouter) getConfig(ctx context.Context, w http.ResponseWriter, r * func (sr *swarmRouter) updateConfig(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { var config types.ConfigSpec if err := json.NewDecoder(r.Body).Decode(&config); err != nil { - return errors.NewBadRequestError(err) + return invalidRequestError{err} } rawVersion := r.URL.Query().Get("version") version, err := strconv.ParseUint(rawVersion, 10, 64) if err != nil { - return errors.NewBadRequestError(fmt.Errorf("invalid config version")) + return invalidRequestError{fmt.Errorf("invalid config version")} } id := vars["id"] - if err := sr.backend.UpdateConfig(id, version, config); err != nil { - return err - } - - return nil + return sr.backend.UpdateConfig(id, version, config) } diff --git a/vendor/github.com/docker/docker/api/server/router/swarm/helpers.go b/vendor/github.com/docker/docker/api/server/router/swarm/helpers.go index 7d2944208..2c411f7d7 100644 --- a/vendor/github.com/docker/docker/api/server/router/swarm/helpers.go +++ b/vendor/github.com/docker/docker/api/server/router/swarm/helpers.go @@ -2,6 +2,7 @@ package swarm import ( "fmt" + "io" "net/http" "github.com/docker/docker/api/server/httputils" @@ -12,7 +13,7 @@ import ( // swarmLogs takes an http response, request, and selector, and writes the logs // specified by the selector to the response -func (sr *swarmRouter) swarmLogs(ctx context.Context, w http.ResponseWriter, r *http.Request, selector *backend.LogSelector) error { +func (sr *swarmRouter) swarmLogs(ctx context.Context, w io.Writer, r *http.Request, selector *backend.LogSelector) error { // Args are validated before the stream starts because when it starts we're // sending HTTP 200 by writing an empty chunk of data to tell the client that // daemon is going to stream. By sending this initial HTTP 200 we can't report diff --git a/vendor/github.com/docker/docker/api/server/router/system/system_routes.go b/vendor/github.com/docker/docker/api/server/router/system/system_routes.go index cd8c3a9fb..5884388eb 100644 --- a/vendor/github.com/docker/docker/api/server/router/system/system_routes.go +++ b/vendor/github.com/docker/docker/api/server/router/system/system_routes.go @@ -7,7 +7,6 @@ import ( "time" "github.com/docker/docker/api" - "github.com/docker/docker/api/errors" "github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/events" @@ -85,6 +84,16 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter, return httputils.WriteJSON(w, http.StatusOK, du) } +type invalidRequestError struct { + Err error +} + +func (e invalidRequestError) Error() string { + return e.Err.Error() +} + +func (e invalidRequestError) InvalidParameter() {} + func (s *systemRouter) getEvents(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := httputils.ParseForm(r); err != nil { return err @@ -105,7 +114,7 @@ func (s *systemRouter) getEvents(ctx context.Context, w http.ResponseWriter, r * ) if !until.IsZero() { if until.Before(since) { - return errors.NewBadRequestError(fmt.Errorf("`since` time (%s) cannot be after `until` time (%s)", r.Form.Get("since"), r.Form.Get("until"))) + return invalidRequestError{fmt.Errorf("`since` time (%s) cannot be after `until` time (%s)", r.Form.Get("since"), r.Form.Get("until"))} } now := time.Now() diff --git a/vendor/github.com/docker/docker/api/server/server.go b/vendor/github.com/docker/docker/api/server/server.go index 55edcec33..bf3774bba 100644 --- a/vendor/github.com/docker/docker/api/server/server.go +++ b/vendor/github.com/docker/docker/api/server/server.go @@ -2,12 +2,10 @@ package server import ( "crypto/tls" - "fmt" "net" "net/http" "strings" - "github.com/docker/docker/api/errors" "github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/server/middleware" "github.com/docker/docker/api/server/router" @@ -25,7 +23,6 @@ const versionMatcher = "/v{version:[0-9.]+}" // Config provides the configuration for the API server type Config struct { Logging bool - EnableCors bool CorsHeaders string Version string SocketGroup string @@ -158,6 +155,14 @@ func (s *Server) InitRouter(routers ...router.Router) { } } +type pageNotFoundError struct{} + +func (pageNotFoundError) Error() string { + return "page not found" +} + +func (pageNotFoundError) NotFound() {} + // createMux initializes the main router the server uses. func (s *Server) createMux() *mux.Router { m := mux.NewRouter() @@ -180,8 +185,7 @@ func (s *Server) createMux() *mux.Router { m.Path("/debug" + r.Path()).Handler(f) } - err := errors.NewRequestNotFoundError(fmt.Errorf("page not found")) - notFoundHandler := httputils.MakeErrorHandler(err) + notFoundHandler := httputils.MakeErrorHandler(pageNotFoundError{}) m.HandleFunc(versionMatcher+"/{path:.*}", notFoundHandler) m.NotFoundHandler = notFoundHandler diff --git a/vendor/github.com/docker/docker/api/swagger.yaml b/vendor/github.com/docker/docker/api/swagger.yaml index 69884f374..75276c1b9 100644 --- a/vendor/github.com/docker/docker/api/swagger.yaml +++ b/vendor/github.com/docker/docker/api/swagger.yaml @@ -144,6 +144,10 @@ tags: x-displayName: "Secrets" description: | Secrets are sensitive data that can be used by services. Swarm mode must be enabled for these endpoints to work. + - name: "Config" + x-displayName: "Configs" + description: | + Configs are application configurations that can be used by services. Swarm mode must be enabled for these endpoints to work. # System things - name: "Plugin" x-displayName: "Plugins" @@ -301,6 +305,7 @@ definitions: Mode: description: "The permission mode for the tmpfs mount in an integer." type: "integer" + RestartPolicy: description: | The behavior to apply when the container exits. The default is not to restart. @@ -400,6 +405,7 @@ definitions: CpusetCpus: description: "CPUs in which to allow execution (e.g., `0-3`, `0,1`)" type: "string" + example: "0-3" CpusetMems: description: "Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems." type: "string" @@ -494,14 +500,16 @@ definitions: NanoCPUs: type: "integer" format: "int64" + example: 4000000000 MemoryBytes: type: "integer" format: "int64" + example: 8272408576 GenericResources: $ref: "#/definitions/GenericResources" GenericResources: - description: "User defined Resources, can be either Integer resources (e.g: SSD=3) or String resources (e.g: GPU={UUID1, UUID2})" + description: "User-defined resources can be either Integer resources (e.g, `SSD=3`) or String resources (e.g, `GPU=UUID1`)" type: "array" items: type: "object" @@ -521,6 +529,16 @@ definitions: Value: type: "integer" format: "int64" + example: + - DiscreteResourceSpec: + Kind: "SSD" + Value: 3 + - NamedResourceSpec: + Kind: "GPU" + Value: "UUID1" + - NamedResourceSpec: + Kind: "GPU" + Value: "UUID2" HealthConfig: description: "A test to perform to check that the container is healthy." @@ -563,7 +581,7 @@ definitions: A list of volume bindings for this container. Each volume binding is a string in one of these forms: - `host-src:container-dest` to bind-mount a host path into the container. Both `host-src`, and `container-dest` must be an _absolute_ path. - - `host-src:container-dest:ro` to make the bind-mount read-only inside the container. Both `host-src`, and `container-dest` must be an _absolute_ path. + - `host-src:container-dest:ro` to make the bind mount read-only inside the container. Both `host-src`, and `container-dest` must be an _absolute_ path. - `volume-name:container-dest` to bind-mount a volume managed by a volume driver into the container. `container-dest` must be an _absolute_ path. - `volume-name:container-dest:ro` to mount the volume read-only inside the container. `container-dest` must be an _absolute_ path. items: @@ -665,7 +683,17 @@ definitions: type: "string" IpcMode: type: "string" - description: "IPC namespace to use for the container." + description: | + IPC sharing mode for the container. Possible values are: + + - `"none"`: own private IPC namespace, with /dev/shm not mounted + - `"private"`: own private IPC namespace + - `"shareable"`: own private IPC namespace, with a possibility to share it with other containers + - `"container:"`: join another (shareable) container's IPC namespace + - `"host"`: use the host system's IPC namespace + + If not specified, daemon default is used, which can either be `"private"` + or `"shareable"`, depending on daemon version and configuration. Cgroup: type: "string" description: "Cgroup to use for the container." @@ -677,6 +705,7 @@ definitions: OomScoreAdj: type: "integer" description: "An integer value containing the score given to the container in order to tune OOM killer preferences." + example: 500 PidMode: type: "string" description: | @@ -868,26 +897,223 @@ definitions: items: type: "string" - NetworkConfig: - description: "TODO: check is correct" + NetworkSettings: + description: "NetworkSettings exposes the network settings in the API" type: "object" properties: Bridge: + description: Name of the network'a bridge (for example, `docker0`). + type: "string" + example: "docker0" + SandboxID: + description: SandboxID uniquely represents a container's network stack. + type: "string" + example: "9d12daf2c33f5959c8bf90aa513e4f65b561738661003029ec84830cd503a0c3" + HairpinMode: + description: | + Indicates if hairpin NAT should be enabled on the virtual interface. + type: "boolean" + example: false + LinkLocalIPv6Address: + description: IPv6 unicast address using the link-local prefix. + type: "string" + example: "fe80::42:acff:fe11:1" + LinkLocalIPv6PrefixLen: + description: Prefix length of the IPv6 unicast address. + type: "integer" + example: "64" + Ports: + $ref: "#/definitions/PortMap" + SandboxKey: + description: SandboxKey identifies the sandbox + type: "string" + example: "/var/run/docker/netns/8ab54b426c38" + + # TODO is SecondaryIPAddresses actually used? + SecondaryIPAddresses: + description: "" + type: "array" + items: + $ref: "#/definitions/Address" + x-nullable: true + + # TODO is SecondaryIPv6Addresses actually used? + SecondaryIPv6Addresses: + description: "" + type: "array" + items: + $ref: "#/definitions/Address" + x-nullable: true + + # TODO properties below are part of DefaultNetworkSettings, which is + # marked as deprecated since Docker 1.9 and to be removed in Docker v17.12 + EndpointID: + description: | + EndpointID uniquely represents a service endpoint in a Sandbox. + +


+ + > **Deprecated**: This field is only propagated when attached to the + > default "bridge" network. Use the information from the "bridge" + > network inside the `Networks` map instead, which contains the same + > information. This field was deprecated in Docker 1.9 and is scheduled + > to be removed in Docker 17.12.0 type: "string" + example: "b88f5b905aabf2893f3cbc4ee42d1ea7980bbc0a92e2c8922b1e1795298afb0b" Gateway: + description: | + Gateway address for the default "bridge" network. + +


+ + > **Deprecated**: This field is only propagated when attached to the + > default "bridge" network. Use the information from the "bridge" + > network inside the `Networks` map instead, which contains the same + > information. This field was deprecated in Docker 1.9 and is scheduled + > to be removed in Docker 17.12.0 + type: "string" + example: "172.17.0.1" + GlobalIPv6Address: + description: | + Global IPv6 address for the default "bridge" network. + +


+ + > **Deprecated**: This field is only propagated when attached to the + > default "bridge" network. Use the information from the "bridge" + > network inside the `Networks` map instead, which contains the same + > information. This field was deprecated in Docker 1.9 and is scheduled + > to be removed in Docker 17.12.0 type: "string" - Address: + example: "2001:db8::5689" + GlobalIPv6PrefixLen: + description: | + Mask length of the global IPv6 address. + +


+ + > **Deprecated**: This field is only propagated when attached to the + > default "bridge" network. Use the information from the "bridge" + > network inside the `Networks` map instead, which contains the same + > information. This field was deprecated in Docker 1.9 and is scheduled + > to be removed in Docker 17.12.0 + type: "integer" + example: 64 + IPAddress: + description: | + IPv4 address for the default "bridge" network. + +


+ + > **Deprecated**: This field is only propagated when attached to the + > default "bridge" network. Use the information from the "bridge" + > network inside the `Networks` map instead, which contains the same + > information. This field was deprecated in Docker 1.9 and is scheduled + > to be removed in Docker 17.12.0 type: "string" + example: "172.17.0.4" IPPrefixLen: + description: | + Mask length of the IPv4 address. + +


+ + > **Deprecated**: This field is only propagated when attached to the + > default "bridge" network. Use the information from the "bridge" + > network inside the `Networks` map instead, which contains the same + > information. This field was deprecated in Docker 1.9 and is scheduled + > to be removed in Docker 17.12.0 type: "integer" + example: 16 + IPv6Gateway: + description: | + IPv6 gateway address for this network. + +


+ + > **Deprecated**: This field is only propagated when attached to the + > default "bridge" network. Use the information from the "bridge" + > network inside the `Networks` map instead, which contains the same + > information. This field was deprecated in Docker 1.9 and is scheduled + > to be removed in Docker 17.12.0 + type: "string" + example: "2001:db8:2::100" MacAddress: + description: | + MAC address for the container on the default "bridge" network. + +


+ + > **Deprecated**: This field is only propagated when attached to the + > default "bridge" network. Use the information from the "bridge" + > network inside the `Networks` map instead, which contains the same + > information. This field was deprecated in Docker 1.9 and is scheduled + > to be removed in Docker 17.12.0 type: "string" - PortMapping: + example: "02:42:ac:11:00:04" + Networks: + description: | + Information about all networks that the container is connected to. + type: "object" + additionalProperties: + $ref: "#/definitions/EndpointSettings" + + Address: + description: Address represents an IPv4 or IPv6 IP address. + type: "object" + properties: + Addr: + description: IP address. type: "string" - Ports: - type: "array" - items: - $ref: "#/definitions/Port" + PrefixLen: + description: Mask length of the IP address. + type: "integer" + + PortMap: + description: | + PortMap describes the mapping of container ports to host ports, using the + container's port-number and protocol as key in the format `/`, + for example, `80/udp`. + + If a container's port is mapped for both `tcp` and `udp`, two separate + entries are added to the mapping table. + type: "object" + additionalProperties: + type: "array" + items: + $ref: "#/definitions/PortBinding" + example: + "443/tcp": + - HostIp: "127.0.0.1" + HostPort: "4443" + "80/tcp": + - HostIp: "0.0.0.0" + HostPort: "80" + - HostIp: "0.0.0.0" + HostPort: "8080" + "80/udp": + - HostIp: "0.0.0.0" + HostPort: "80" + "53/udp": + - HostIp: "0.0.0.0" + HostPort: "53" + "2377/tcp": null + + PortBinding: + description: | + PortBinding represents a binding between a host IP address and a host + port. + type: "object" + x-nullable: true + properties: + HostIp: + description: "Host IP address that the container's port is mapped to." + type: "string" + example: "127.0.0.1" + HostPort: + description: "Host port number that the container's port is mapped to." + type: "string" + example: "4443" GraphDriverData: description: "Information about a container's graph driver." @@ -1250,6 +1476,7 @@ definitions: type: "object" additionalProperties: type: "string" + NetworkContainer: type: "object" properties: @@ -1305,6 +1532,7 @@ definitions: type: "string" progressDetail: $ref: "#/definitions/ProgressDetail" + ErrorDetail: type: "object" properties: @@ -1312,6 +1540,7 @@ definitions: type: "integer" message: type: "string" + ProgressDetail: type: "object" properties: @@ -1346,45 +1575,102 @@ definitions: description: "Configuration for a network endpoint." type: "object" properties: + # Configurations IPAMConfig: - description: "IPAM configurations for the endpoint" - type: "object" - properties: - IPv4Address: - type: "string" - IPv6Address: - type: "string" - LinkLocalIPs: - type: "array" - items: - type: "string" + $ref: "#/definitions/EndpointIPAMConfig" Links: type: "array" items: type: "string" + example: + - "container_1" + - "container_2" Aliases: type: "array" items: type: "string" + example: + - "server_x" + - "server_y" + + # Operational data NetworkID: + description: | + Unique ID of the network. type: "string" + example: "08754567f1f40222263eab4102e1c733ae697e8e354aa9cd6e18d7402835292a" EndpointID: + description: | + Unique ID for the service endpoint in a Sandbox. type: "string" + example: "b88f5b905aabf2893f3cbc4ee42d1ea7980bbc0a92e2c8922b1e1795298afb0b" Gateway: + description: | + Gateway address for this network. type: "string" + example: "172.17.0.1" IPAddress: + description: | + IPv4 address. type: "string" + example: "172.17.0.4" IPPrefixLen: + description: | + Mask length of the IPv4 address. type: "integer" + example: 16 IPv6Gateway: + description: | + IPv6 gateway address. type: "string" + example: "2001:db8:2::100" GlobalIPv6Address: + description: | + Global IPv6 address. type: "string" + example: "2001:db8::5689" GlobalIPv6PrefixLen: + description: | + Mask length of the global IPv6 address. type: "integer" format: "int64" + example: 64 MacAddress: + description: | + MAC address for the endpoint on this network. + type: "string" + example: "02:42:ac:11:00:04" + DriverOpts: + description: | + DriverOpts is a mapping of driver options and values. These options + are passed directly to the driver and are driver specific. + type: "object" + x-nullable: true + additionalProperties: + type: "string" + example: + com.example.some-label: "some-value" + com.example.some-other-label: "some-other-value" + + EndpointIPAMConfig: + description: | + EndpointIPAMConfig represents an endpoint's IPAM configuration. + type: "object" + x-nullable: true + properties: + IPv4Address: type: "string" + example: "172.20.30.33" + IPv6Address: + type: "string" + example: "2001:db8:abcd::3033" + LinkLocalIPs: + type: "array" + items: + type: "string" + example: + - "169.254.34.68" + - "fe80::3468" PluginMount: type: "object" @@ -1421,6 +1707,7 @@ definitions: example: - "rbind" - "rw" + PluginDevice: type: "object" required: [Name, Description, Settable, Path] @@ -1692,7 +1979,8 @@ definitions: properties: Index: type: "integer" - format: "int64" + format: "uint64" + example: 373531 NodeSpec: type: "object" @@ -1700,6 +1988,7 @@ definitions: Name: description: "Name for the node." type: "string" + example: "my-node" Labels: description: "User-defined key/value metadata." type: "object" @@ -1711,6 +2000,7 @@ definitions: enum: - "worker" - "manager" + example: "manager" Availability: description: "Availability of the node." type: "string" @@ -1718,125 +2008,140 @@ definitions: - "active" - "pause" - "drain" + example: "active" example: Availability: "active" Name: "node-name" Role: "manager" Labels: foo: "bar" + Node: type: "object" properties: ID: type: "string" + example: "24ifsmvkjbyhk" Version: $ref: "#/definitions/ObjectVersion" CreatedAt: + description: | + Date and time at which the node was added to the swarm in + [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds. type: "string" format: "dateTime" + example: "2016-08-18T10:44:24.496525531Z" UpdatedAt: + description: | + Date and time at which the node was last updated in + [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds. type: "string" format: "dateTime" + example: "2017-08-09T07:09:37.632105588Z" Spec: $ref: "#/definitions/NodeSpec" Description: - type: "object" - properties: - Hostname: - type: "string" - Platform: - type: "object" - properties: - Architecture: - type: "string" - OS: - type: "string" - Resources: - $ref: "#/definitions/ResourceObject" - Engine: - type: "object" - properties: - EngineVersion: - type: "string" - Labels: - type: "object" - additionalProperties: - type: "string" - Plugins: - type: "array" - items: - type: "object" - properties: - Type: - type: "string" - Name: - type: "string" - TLSInfo: - $ref: "#/definitions/SwarmSpec" - example: - ID: "24ifsmvkjbyhk" - Version: - Index: 8 - CreatedAt: "2016-06-07T20:31:11.853781916Z" - UpdatedAt: "2016-06-07T20:31:11.999868824Z" - Spec: - Name: "my-node" - Role: "manager" - Availability: "active" - Labels: - foo: "bar" - Description: - Hostname: "bf3067039e47" - Platform: - Architecture: "x86_64" - OS: "linux" - Resources: - NanoCPUs: 4000000000 - MemoryBytes: 8272408576 - GenericResources: - - DiscreteResourceSpec: - Kind: "SSD" - Value: 3 - - NamedResourceSpec: - Kind: "GPU" - Value: "UUID1" - - NamedResourceSpec: - Kind: "GPU" - Value: "UUID2" - Engine: - EngineVersion: "17.04.0" - Labels: - foo: "bar" - Plugins: - - Type: "Volume" - Name: "local" - - Type: "Network" - Name: "bridge" - - Type: "Network" - Name: "null" - - Type: "Network" - Name: "overlay" + $ref: "#/definitions/NodeDescription" Status: - State: "ready" - Addr: "172.17.0.2" + $ref: "#/definitions/NodeStatus" ManagerStatus: - Leader: true - Reachability: "reachable" - Addr: "172.17.0.2:2377" + $ref: "#/definitions/ManagerStatus" + + NodeDescription: + description: | + NodeDescription encapsulates the properties of the Node as reported by the + agent. + type: "object" + properties: + Hostname: + type: "string" + example: "bf3067039e47" + Platform: + $ref: "#/definitions/Platform" + Resources: + $ref: "#/definitions/ResourceObject" + Engine: + $ref: "#/definitions/EngineDescription" TLSInfo: - TrustRoot: | - -----BEGIN CERTIFICATE----- - MIIBajCCARCgAwIBAgIUbYqrLSOSQHoxD8CwG6Bi2PJi9c8wCgYIKoZIzj0EAwIw - EzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwNDI0MjE0MzAwWhcNMzcwNDE5MjE0 - MzAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH - A0IABJk/VyMPYdaqDXJb/VXh5n/1Yuv7iNrxV3Qb3l06XD46seovcDWs3IZNV1lf - 3Skyr0ofcchipoiHkXBODojJydSjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB - Af8EBTADAQH/MB0GA1UdDgQWBBRUXxuRcnFjDfR/RIAUQab8ZV/n4jAKBggqhkjO - PQQDAgNIADBFAiAy+JTe6Uc3KyLCMiqGl2GyWGQqQDEcO3/YG36x7om65AIhAJvz - pxv6zFeVEkAEEkqIYi0omA9+CjanB/6Bz4n1uw8H - -----END CERTIFICATE----- - CertIssuerSubject: "MBMxETAPBgNVBAMTCHN3YXJtLWNh" - CertIssuerPublicKey: "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEmT9XIw9h1qoNclv9VeHmf/Vi6/uI2vFXdBveXTpcPjqx6i9wNazchk1XWV/dKTKvSh9xyGKmiIeRcE4OiMnJ1A==" + $ref: "#/definitions/TLSInfo" + + Platform: + description: | + Platform represents the platform (Arch/OS). + type: "object" + properties: + Architecture: + description: | + Architecture represents the hardware architecture (for example, + `x86_64`). + type: "string" + example: "x86_64" + OS: + description: | + OS represents the Operating System (for example, `linux` or `windows`). + type: "string" + example: "linux" + + EngineDescription: + description: "EngineDescription provides information about an engine." + type: "object" + properties: + EngineVersion: + type: "string" + example: "17.06.0" + Labels: + type: "object" + additionalProperties: + type: "string" + example: + foo: "bar" + Plugins: + type: "array" + items: + type: "object" + properties: + Type: + type: "string" + Name: + type: "string" + example: + - Type: "Log" + Name: "awslogs" + - Type: "Log" + Name: "fluentd" + - Type: "Log" + Name: "gcplogs" + - Type: "Log" + Name: "gelf" + - Type: "Log" + Name: "journald" + - Type: "Log" + Name: "json-file" + - Type: "Log" + Name: "logentries" + - Type: "Log" + Name: "splunk" + - Type: "Log" + Name: "syslog" + - Type: "Network" + Name: "bridge" + - Type: "Network" + Name: "host" + - Type: "Network" + Name: "ipvlan" + - Type: "Network" + Name: "macvlan" + - Type: "Network" + Name: "null" + - Type: "Network" + Name: "overlay" + - Type: "Volume" + Name: "local" + - Type: "Volume" + Name: "localhost:5000/vieux/sshfs:latest" + - Type: "Volume" + Name: "vieux/sshfs:latest" + TLSInfo: description: "Information about the issuer of leaf TLS certificates and the trusted root CA certificate" type: "object" @@ -1864,6 +2169,64 @@ definitions: -----END CERTIFICATE----- CertIssuerSubject: "MBMxETAPBgNVBAMTCHN3YXJtLWNh" CertIssuerPublicKey: "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEmT9XIw9h1qoNclv9VeHmf/Vi6/uI2vFXdBveXTpcPjqx6i9wNazchk1XWV/dKTKvSh9xyGKmiIeRcE4OiMnJ1A==" + + NodeStatus: + description: | + NodeStatus represents the status of a node. + + It provides the current status of the node, as seen by the manager. + type: "object" + properties: + State: + $ref: "#/definitions/NodeState" + Message: + type: "string" + example: "" + Addr: + description: "IP address of the node." + type: "string" + example: "172.17.0.2" + + NodeState: + description: "NodeState represents the state of a node." + type: "string" + enum: + - "unknown" + - "down" + - "ready" + - "disconnected" + example: "ready" + + ManagerStatus: + description: | + ManagerStatus represents the status of a manager. + + It provides the current status of a node's manager component, if the node + is a manager. + x-nullable: true + type: "object" + properties: + Leader: + type: "boolean" + default: false + example: true + Reachability: + $ref: "#/definitions/Reachability" + Addr: + description: | + The IP address and port at which the manager is reachable. + type: "string" + example: "10.0.0.46:2377" + + Reachability: + description: "Reachability represents the reachability of a node." + type: "string" + enum: + - "unknown" + - "unreachable" + - "reachable" + example: "reachable" + SwarmSpec: description: "User modifiable swarm configuration." type: "object" @@ -1871,19 +2234,25 @@ definitions: Name: description: "Name of the swarm." type: "string" + example: "default" Labels: description: "User-defined key/value metadata." type: "object" additionalProperties: type: "string" + example: + com.example.corp.type: "production" + com.example.corp.department: "engineering" Orchestration: description: "Orchestration configuration." type: "object" + x-nullable: true properties: TaskHistoryRetentionLimit: description: "The number of historic tasks to keep per instance or node. If negative, never remove completed or failed tasks." type: "integer" format: "int64" + example: 10 Raft: description: "Raft configuration." type: "object" @@ -1891,43 +2260,51 @@ definitions: SnapshotInterval: description: "The number of log entries between snapshots." type: "integer" - format: "int64" + format: "uint64" + example: 10000 KeepOldSnapshots: description: "The number of snapshots to keep beyond the current snapshot." type: "integer" - format: "int64" + format: "uint64" LogEntriesForSlowFollowers: description: "The number of log entries to keep around to sync up slow followers after a snapshot is created." type: "integer" - format: "int64" + format: "uint64" + example: 500 ElectionTick: description: | The number of ticks that a follower will wait for a message from the leader before becoming a candidate and starting an election. `ElectionTick` must be greater than `HeartbeatTick`. A tick currently defaults to one second, so these translate directly to seconds currently, but this is NOT guaranteed. type: "integer" + example: 3 HeartbeatTick: description: | The number of ticks between heartbeats. Every HeartbeatTick ticks, the leader will send a heartbeat to the followers. A tick currently defaults to one second, so these translate directly to seconds currently, but this is NOT guaranteed. type: "integer" + example: 1 Dispatcher: description: "Dispatcher configuration." type: "object" + x-nullable: true properties: HeartbeatPeriod: description: "The delay for an agent to send a heartbeat to the dispatcher." type: "integer" format: "int64" + example: 5000000000 CAConfig: description: "CA configuration." type: "object" + x-nullable: true properties: NodeCertExpiry: description: "The duration node certificates are issued for." type: "integer" format: "int64" + example: 7776000000000000 ExternalCAs: description: "Configuration for forwarding signing requests to an external certificate authority." type: "array" @@ -1959,6 +2336,8 @@ definitions: type: "string" ForceRotate: description: "An integer whose purpose is to force swarm to generate a new signing CA certificate and key, if none have been specified in `SigningCACert` and `SigningCAKey`" + format: "uint64" + type: "integer" EncryptionConfig: description: "Parameters related to encryption-at-rest." type: "object" @@ -1966,57 +2345,65 @@ definitions: AutoLockManagers: description: "If set, generate a key and use it to lock data stored on the managers." type: "boolean" + example: false TaskDefaults: description: "Defaults for creating tasks in this cluster." type: "object" properties: LogDriver: description: | - The log driver to use for tasks created in the orchestrator if unspecified by a service. + The log driver to use for tasks created in the orchestrator if + unspecified by a service. - Updating this value will only have an affect on new tasks. Old tasks will continue use their previously configured log driver until recreated. + Updating this value only affects new tasks. Existing tasks continue + to use their previously configured log driver until recreated. type: "object" properties: Name: + description: | + The log driver to use as a default for new tasks. type: "string" + example: "json-file" Options: + description: | + Driver-specific options for the selectd log driver, specified + as key/value pairs. type: "object" additionalProperties: type: "string" - example: - Name: "default" - Orchestration: - TaskHistoryRetentionLimit: 10 - Raft: - SnapshotInterval: 10000 - LogEntriesForSlowFollowers: 500 - HeartbeatTick: 1 - ElectionTick: 3 - Dispatcher: - HeartbeatPeriod: 5000000000 - CAConfig: - NodeCertExpiry: 7776000000000000 - JoinTokens: - Worker: "SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx" - Manager: "SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2" - EncryptionConfig: - AutoLockManagers: false + example: + "max-file": "10" + "max-size": "100m" + # The Swarm information for `GET /info`. It is the same as `GET /swarm`, but # without `JoinTokens`. ClusterInfo: + description: | + ClusterInfo represents information about the swarm as is returned by the + "/info" endpoint. Join-tokens are not included. + x-nullable: true type: "object" properties: ID: description: "The ID of the swarm." type: "string" + example: "abajmipo7b4xz5ip2nrla6b11" Version: $ref: "#/definitions/ObjectVersion" CreatedAt: + description: | + Date and time at which the swarm was initialised in + [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds. type: "string" format: "dateTime" + example: "2016-08-18T10:44:24.496525531Z" UpdatedAt: + description: | + Date and time at which the swarm was last updated in + [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds. type: "string" format: "dateTime" + example: "2017-08-09T07:09:37.632105588Z" Spec: $ref: "#/definitions/SwarmSpec" TLSInfo: @@ -2024,13 +2411,40 @@ definitions: RootRotationInProgress: description: "Whether there is currently a root CA rotation in progress for the swarm" type: "boolean" + example: false + + JoinTokens: + description: | + JoinTokens contains the tokens workers and managers need to join the swarm. + type: "object" + properties: + Worker: + description: | + The token workers can use to join the swarm. + type: "string" + example: "SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx" + Manager: + description: | + The token managers can use to join the swarm. + type: "string" + example: "SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2" + + Swarm: + type: "object" + allOf: + - $ref: "#/definitions/ClusterInfo" + - type: "object" + properties: + JoinTokens: + $ref: "#/definitions/JoinTokens" + TaskSpec: description: "User modifiable task configuration." type: "object" properties: PluginSpec: type: "object" - description: "Invalid when specified with `ContainerSpec`." + description: "Invalid when specified with `ContainerSpec`. *(Experimental release only.)*" properties: Name: description: "The name or 'alias' to use for the plugin." @@ -2173,10 +2587,12 @@ definitions: Hosts: type: "array" description: | - A list of hostnames/IP mappings to add to the container's `/etc/hosts` file. - The format of extra hosts on swarmkit is specified in: - http://man7.org/linux/man-pages/man5/hosts.5.html - IP_address canonical_hostname [aliases...] + A list of hostname/IP mappings to add to the container's `hosts` + file. The format of extra hosts is specified in the + [hosts(5)](http://man7.org/linux/man-pages/man5/hosts.5.html) + man page: + + IP_address canonical_hostname [aliases...] items: type: "string" DNSConfig: @@ -2304,6 +2720,10 @@ definitions: type: "array" items: type: "string" + example: + - "node.hostname!=node3.corp.example.com" + - "node.role!=manager" + - "node.labels.type==production" Preferences: description: "Preferences provide a way to make the scheduler aware of factors such as topology. They are provided in order from highest to lowest precedence." type: "array" @@ -2316,16 +2736,20 @@ definitions: SpreadDescriptor: description: "label descriptor, such as engine.labels.az" type: "string" + example: + - Spread: + SpreadDescriptor: "node.labels.datacenter" + - Spread: + SpreadDescriptor: "node.labels.rack" Platforms: - description: "An array of supported platforms." + description: | + Platforms stores all the platforms that the service's image can + run on. This field is used in the platform filter for scheduling. + If empty, then the platform filter is off, meaning there are no + scheduling restrictions. type: "array" items: - type: "object" - properties: - Architecture: - type: "string" - OS: - type: "string" + $ref: "#/definitions/Platform" ForceUpdate: description: "A counter that triggers an update even if no relevant parameters have been changed." type: "integer" @@ -2353,6 +2777,7 @@ definitions: type: "object" additionalProperties: type: "string" + TaskState: type: "string" enum: @@ -2369,6 +2794,7 @@ definitions: - "shutdown" - "failed" - "rejected" + Task: type: "object" properties: @@ -2492,6 +2918,7 @@ definitions: - NamedResourceSpec: Kind: "GPU" Value: "UUID2" + ServiceSpec: description: "User modifiable configuration for a service." properties: @@ -2596,6 +3023,7 @@ definitions: type: "string" EndpointSpec: $ref: "#/definitions/EndpointSpec" + EndpointPortConfig: type: "object" properties: @@ -2612,6 +3040,7 @@ definitions: PublishedPort: description: "The port on the swarm hosts." type: "integer" + EndpointSpec: description: "Properties that can be configured to access and load balance a service." type: "object" @@ -2629,6 +3058,7 @@ definitions: type: "array" items: $ref: "#/definitions/EndpointPortConfig" + Service: type: "object" properties: @@ -2741,6 +3171,7 @@ definitions: - NetworkID: "4qvuz4ko70xaltuqbt8956gd1" Addr: "10.255.0.3/16" + ImageDeleteResponseItem: type: "object" properties: @@ -2750,6 +3181,7 @@ definitions: Deleted: description: "The image ID of an image that was deleted" type: "string" + ServiceUpdateResponse: type: "object" properties: @@ -2760,6 +3192,7 @@ definitions: type: "string" example: Warning: "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found" + ContainerSummary: type: "array" items: @@ -2808,123 +3241,893 @@ definitions: State: description: "The state of this container (e.g. `Exited`)" type: "string" - Status: - description: "Additional human-readable status of this container (e.g. `Exit 0`)" + Status: + description: "Additional human-readable status of this container (e.g. `Exit 0`)" + type: "string" + HostConfig: + type: "object" + properties: + NetworkMode: + type: "string" + NetworkSettings: + description: "A summary of the container's network settings" + type: "object" + properties: + Networks: + type: "object" + additionalProperties: + $ref: "#/definitions/EndpointSettings" + Mounts: + type: "array" + items: + $ref: "#/definitions/Mount" + + Driver: + description: "Driver represents a driver (network, logging, secrets)." + type: "object" + required: [Name] + properties: + Name: + description: "Name of the driver." + type: "string" + x-nullable: false + example: "some-driver" + Options: + description: "Key/value map of driver-specific options." + type: "object" + x-nullable: false + additionalProperties: + type: "string" + example: + OptionA: "value for driver-specific option A" + OptionB: "value for driver-specific option B" + + SecretSpec: + type: "object" + properties: + Name: + description: "User-defined name of the secret." + type: "string" + Labels: + description: "User-defined key/value metadata." + type: "object" + additionalProperties: + type: "string" + example: + com.example.some-label: "some-value" + com.example.some-other-label: "some-other-value" + Data: + description: | + Base64-url-safe-encoded ([RFC 4648](https://tools.ietf.org/html/rfc4648#section-3.2)) + data to store as secret. + + This field is only used to _create_ a secret, and is not returned by + other endpoints. + type: "string" + example: "" + Driver: + description: "Name of the secrets driver used to fetch the secret's value from an external secret store" + $ref: "#/definitions/Driver" + + Secret: + type: "object" + properties: + ID: + type: "string" + example: "blt1owaxmitz71s9v5zh81zun" + Version: + $ref: "#/definitions/ObjectVersion" + CreatedAt: + type: "string" + format: "dateTime" + example: "2017-07-20T13:55:28.678958722Z" + UpdatedAt: + type: "string" + format: "dateTime" + example: "2017-07-20T13:55:28.678958722Z" + Spec: + $ref: "#/definitions/SecretSpec" + + ConfigSpec: + type: "object" + properties: + Name: + description: "User-defined name of the config." + type: "string" + Labels: + description: "User-defined key/value metadata." + type: "object" + additionalProperties: + type: "string" + Data: + description: | + Base64-url-safe-encoded ([RFC 4648](https://tools.ietf.org/html/rfc4648#section-3.2)) + config data. + type: "string" + + Config: + type: "object" + properties: + ID: + type: "string" + Version: + $ref: "#/definitions/ObjectVersion" + CreatedAt: + type: "string" + format: "dateTime" + UpdatedAt: + type: "string" + format: "dateTime" + Spec: + $ref: "#/definitions/ConfigSpec" + + SystemInfo: + type: "object" + properties: + ID: + description: | + Unique identifier of the daemon. + +


+ + > **Note**: The format of the ID itself is not part of the API, and + > should not be considered stable. + type: "string" + example: "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS" + Containers: + description: "Total number of containers on the host." + type: "integer" + example: 14 + ContainersRunning: + description: | + Number of containers with status `"running"`. + type: "integer" + example: 3 + ContainersPaused: + description: | + Number of containers with status `"paused"`. + type: "integer" + example: 1 + ContainersStopped: + description: | + Number of containers with status `"stopped"`. + type: "integer" + example: 10 + Images: + description: | + Total number of images on the host. + + Both _tagged_ and _untagged_ (dangling) images are counted. + type: "integer" + example: 508 + Driver: + description: "Name of the storage driver in use." + type: "string" + example: "overlay2" + DriverStatus: + description: | + Information specific to the storage driver, provided as + "label" / "value" pairs. + + This information is provided by the storage driver, and formatted + in a way consistent with the output of `docker info` on the command + line. + +


+ + > **Note**: The information returned in this field, including the + > formatting of values and labels, should not be considered stable, + > and may change without notice. + type: "array" + items: + type: "array" + items: + type: "string" + example: + - ["Backing Filesystem", "extfs"] + - ["Supports d_type", "true"] + - ["Native Overlay Diff", "true"] + DockerRootDir: + description: | + Root directory of persistent Docker state. + + Defaults to `/var/lib/docker` on Linux, and `C:\ProgramData\docker` + on Windows. + type: "string" + example: "/var/lib/docker" + SystemStatus: + description: | + Status information about this node (standalone Swarm API). + +


+ + > **Note**: The information returned in this field is only propagated + > by the Swarm standalone API, and is empty (`null`) when using + > built-in swarm mode. + type: "array" + items: + type: "array" + items: + type: "string" + example: + - ["Role", "primary"] + - ["State", "Healthy"] + - ["Strategy", "spread"] + - ["Filters", "health, port, containerslots, dependency, affinity, constraint, whitelist"] + - ["Nodes", "2"] + - [" swarm-agent-00", "192.168.99.102:2376"] + - [" └ ID", "5CT6:FBGO:RVGO:CZL4:PB2K:WCYN:2JSV:KSHH:GGFW:QOPG:6J5Q:IOZ2|192.168.99.102:2376"] + - [" └ Status", "Healthy"] + - [" └ Containers", "1 (1 Running, 0 Paused, 0 Stopped)"] + - [" └ Reserved CPUs", "0 / 1"] + - [" └ Reserved Memory", "0 B / 1.021 GiB"] + - [" └ Labels", "kernelversion=4.4.74-boot2docker, operatingsystem=Boot2Docker 17.06.0-ce (TCL 7.2); HEAD : 0672754 - Thu Jun 29 00:06:31 UTC 2017, ostype=linux, provider=virtualbox, storagedriver=aufs"] + - [" └ UpdatedAt", "2017-08-09T10:03:46Z"] + - [" └ ServerVersion", "17.06.0-ce"] + - [" swarm-manager", "192.168.99.101:2376"] + - [" └ ID", "TAMD:7LL3:SEF7:LW2W:4Q2X:WVFH:RTXX:JSYS:XY2P:JEHL:ZMJK:JGIW|192.168.99.101:2376"] + - [" └ Status", "Healthy"] + - [" └ Containers", "2 (2 Running, 0 Paused, 0 Stopped)"] + - [" └ Reserved CPUs", "0 / 1"] + - [" └ Reserved Memory", "0 B / 1.021 GiB"] + - [" └ Labels", "kernelversion=4.4.74-boot2docker, operatingsystem=Boot2Docker 17.06.0-ce (TCL 7.2); HEAD : 0672754 - Thu Jun 29 00:06:31 UTC 2017, ostype=linux, provider=virtualbox, storagedriver=aufs"] + - [" └ UpdatedAt", "2017-08-09T10:04:11Z"] + - [" └ ServerVersion", "17.06.0-ce"] + Plugins: + $ref: "#/definitions/PluginsInfo" + MemoryLimit: + description: "Indicates if the host has memory limit support enabled." + type: "boolean" + example: true + SwapLimit: + description: "Indicates if the host has memory swap limit support enabled." + type: "boolean" + example: true + KernelMemory: + description: "Indicates if the host has kernel memory limit support enabled." + type: "boolean" + example: true + CpuCfsPeriod: + description: "Indicates if CPU CFS(Completely Fair Scheduler) period is supported by the host." + type: "boolean" + example: true + CpuCfsQuota: + description: "Indicates if CPU CFS(Completely Fair Scheduler) quota is supported by the host." + type: "boolean" + example: true + CPUShares: + description: "Indicates if CPU Shares limiting is supported by the host." + type: "boolean" + example: true + CPUSet: + description: | + Indicates if CPUsets (cpuset.cpus, cpuset.mems) are supported by the host. + + See [cpuset(7)](https://www.kernel.org/doc/Documentation/cgroup-v1/cpusets.txt) + type: "boolean" + example: true + OomKillDisable: + description: "Indicates if OOM killer disable is supported on the host." + type: "boolean" + IPv4Forwarding: + description: "Indicates IPv4 forwarding is enabled." + type: "boolean" + example: true + BridgeNfIptables: + description: "Indicates if `bridge-nf-call-iptables` is available on the host." + type: "boolean" + example: true + BridgeNfIp6tables: + description: "Indicates if `bridge-nf-call-ip6tables` is available on the host." + type: "boolean" + example: true + Debug: + description: "Indicates if the daemon is running in debug-mode / with debug-level logging enabled." + type: "boolean" + example: true + NFd: + description: | + The total number of file Descriptors in use by the daemon process. + + This information is only returned if debug-mode is enabled. + type: "integer" + example: 64 + NGoroutines: + description: | + The number of goroutines that currently exist. + + This information is only returned if debug-mode is enabled. + type: "integer" + example: 174 + SystemTime: + description: | + Current system-time in [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) + format with nano-seconds. + type: "string" + example: "2017-08-08T20:28:29.06202363Z" + LoggingDriver: + description: | + The logging driver to use as a default for new containers. + type: "string" + CgroupDriver: + description: | + The driver to use for managing cgroups. + type: "string" + enum: ["cgroupfs", "systemd"] + default: "cgroupfs" + example: "cgroupfs" + NEventsListener: + description: "Number of event listeners subscribed." + type: "integer" + example: 30 + KernelVersion: + description: | + Kernel version of the host. + + On Linux, this information obtained from `uname`. On Windows this + information is queried from the HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ + registry value, for example _"10.0 14393 (14393.1198.amd64fre.rs1_release_sec.170427-1353)"_. + type: "string" + example: "4.9.38-moby" + OperatingSystem: + description: | + Name of the host's operating system, for example: "Ubuntu 16.04.2 LTS" + or "Windows Server 2016 Datacenter" + type: "string" + example: "Alpine Linux v3.5" + OSType: + description: | + Generic type of the operating system of the host, as returned by the + Go runtime (`GOOS`). + + Currently returned values are "linux" and "windows". A full list of + possible values can be found in the [Go documentation](https://golang.org/doc/install/source#environment). + type: "string" + example: "linux" + Architecture: + description: | + Hardware architecture of the host, as returned by the Go runtime + (`GOARCH`). + + A full list of possible values can be found in the [Go documentation](https://golang.org/doc/install/source#environment). + type: "string" + example: "x86_64" + NCPU: + description: | + The number of logical CPUs usable by the daemon. + + The number of available CPUs is checked by querying the operating + system when the daemon starts. Changes to operating system CPU + allocation after the daemon is started are not reflected. + type: "integer" + example: 4 + MemTotal: + description: | + Total amount of physical memory available on the host, in kilobytes (kB). + type: "integer" + format: "int64" + example: 2095882240 + + IndexServerAddress: + description: | + Address / URL of the index server that is used for image search, + and as a default for user authentication for Docker Hub and Docker Cloud. + default: "https://index.docker.io/v1/" + type: "string" + example: "https://index.docker.io/v1/" + RegistryConfig: + $ref: "#/definitions/RegistryServiceConfig" + GenericResources: + $ref: "#/definitions/GenericResources" + HttpProxy: + description: | + HTTP-proxy configured for the daemon. This value is obtained from the + [`HTTP_PROXY`](https://www.gnu.org/software/wget/manual/html_node/Proxies.html) environment variable. + + Containers do not automatically inherit this configuration. + type: "string" + example: "http://user:pass@proxy.corp.example.com:8080" + HttpsProxy: + description: | + HTTPS-proxy configured for the daemon. This value is obtained from the + [`HTTPS_PROXY`](https://www.gnu.org/software/wget/manual/html_node/Proxies.html) environment variable. + + Containers do not automatically inherit this configuration. + type: "string" + example: "https://user:pass@proxy.corp.example.com:4443" + NoProxy: + description: | + Comma-separated list of domain extensions for which no proxy should be + used. This value is obtained from the [`NO_PROXY`](https://www.gnu.org/software/wget/manual/html_node/Proxies.html) + environment variable. + + Containers do not automatically inherit this configuration. + type: "string" + example: "*.local, 169.254/16" + Name: + description: "Hostname of the host." + type: "string" + example: "node5.corp.example.com" + Labels: + description: | + User-defined labels (key/value metadata) as set on the daemon. + +


+ + > **Note**: When part of a Swarm, nodes can both have _daemon_ labels, + > set through the daemon configuration, and _node_ labels, set from a + > manager node in the Swarm. Node labels are not included in this + > field. Node labels can be retrieved using the `/nodes/(id)` endpoint + > on a manager node in the Swarm. + type: "array" + items: + type: "string" + example: ["storage=ssd", "production"] + ExperimentalBuild: + description: | + Indicates if experimental features are enabled on the daemon. + type: "boolean" + example: true + ServerVersion: + description: | + Version string of the daemon. + + > **Note**: the [standalone Swarm API](https://docs.docker.com/swarm/swarm-api/) + > returns the Swarm version instead of the daemon version, for example + > `swarm/1.2.8`. + type: "string" + example: "17.06.0-ce" + ClusterStore: + description: | + URL of the distributed storage backend. + + + The storage backend is used for multihost networking (to store + network and endpoint information) and by the node discovery mechanism. + +


+ + > **Note**: This field is only propagated when using standalone Swarm + > mode, and overlay networking using an external k/v store. Overlay + > networks with Swarm mode enabled use the built-in raft store, and + > this field will be empty. + type: "string" + example: "consul://consul.corp.example.com:8600/some/path" + ClusterAdvertise: + description: | + The network endpoint that the Engine advertises for the purpose of + node discovery. ClusterAdvertise is a `host:port` combination on which + the daemon is reachable by other hosts. + +


+ + > **Note**: This field is only propagated when using standalone Swarm + > mode, and overlay networking using an external k/v store. Overlay + > networks with Swarm mode enabled use the built-in raft store, and + > this field will be empty. + type: "string" + example: "node5.corp.example.com:8000" + Runtimes: + description: | + List of [OCI compliant](https://github.com/opencontainers/runtime-spec) + runtimes configured on the daemon. Keys hold the "name" used to + reference the runtime. + + The Docker daemon relies on an OCI compliant runtime (invoked via the + `containerd` daemon) as its interface to the Linux kernel namespaces, + cgroups, and SELinux. + + The default runtime is `runc`, and automatically configured. Additional + runtimes can be configured by the user and will be listed here. + type: "object" + additionalProperties: + $ref: "#/definitions/Runtime" + default: + runc: + path: "docker-runc" + example: + runc: + path: "docker-runc" + runc-master: + path: "/go/bin/runc" + custom: + path: "/usr/local/bin/my-oci-runtime" + runtimeArgs: ["--debug", "--systemd-cgroup=false"] + DefaultRuntime: + description: | + Name of the default OCI runtime that is used when starting containers. + + The default can be overridden per-container at create time. + type: "string" + default: "runc" + example: "runc" + Swarm: + $ref: "#/definitions/SwarmInfo" + LiveRestoreEnabled: + description: | + Indicates if live restore is enabled. + + If enabled, containers are kept running when the daemon is shutdown + or upon daemon start if running containers are detected. + type: "boolean" + default: false + example: false + Isolation: + description: | + Represents the isolation technology to use as a default for containers. + The supported values are platform-specific. + + If no isolation value is specified on daemon start, on Windows client, + the default is `hyperv`, and on Windows server, the default is `process`. + + This option is currently not used on other platforms. + default: "default" + type: "string" + enum: + - "default" + - "hyperv" + - "process" + InitBinary: + description: | + Name and, optional, path of the the `docker-init` binary. + + If the path is omitted, the daemon searches the host's `$PATH` for the + binary and uses the first result. + type: "string" + example: "docker-init" + ContainerdCommit: + $ref: "#/definitions/Commit" + RuncCommit: + $ref: "#/definitions/Commit" + InitCommit: + $ref: "#/definitions/Commit" + SecurityOptions: + description: | + List of security features that are enabled on the daemon, such as + apparmor, seccomp, SELinux, and user-namespaces (userns). + + Additional configuration options for each security feature may + be present, and are included as a comma-separated list of key/value + pairs. + type: "array" + items: + type: "string" + example: + - "name=apparmor" + - "name=seccomp,profile=default" + - "name=selinux" + - "name=userns" + + + # PluginsInfo is a temp struct holding Plugins name + # registered with docker daemon. It is used by Info struct + PluginsInfo: + description: | + Available plugins per type. + +


+ + > **Note**: Only unmanaged (V1) plugins are included in this list. + > V1 plugins are "lazily" loaded, and are not returned in this list + > if there is no resource using the plugin. + type: "object" + properties: + Volume: + description: "Names of available volume-drivers, and network-driver plugins." + type: "array" + items: + type: "string" + example: ["local"] + Network: + description: "Names of available network-drivers, and network-driver plugins." + type: "array" + items: + type: "string" + example: ["bridge", "host", "ipvlan", "macvlan", "null", "overlay"] + Authorization: + description: "Names of available authorization plugins." + type: "array" + items: type: "string" - HostConfig: - type: "object" - properties: - NetworkMode: - type: "string" - NetworkSettings: - description: "A summary of the container's network settings" - type: "object" - properties: - Networks: - type: "object" - additionalProperties: - $ref: "#/definitions/EndpointSettings" - Mounts: - type: "array" - items: - $ref: "#/definitions/Mount" + example: ["img-authz-plugin", "hbm"] + Log: + description: "Names of available logging-drivers, and logging-driver plugins." + type: "array" + items: + type: "string" + example: ["awslogs", "fluentd", "gcplogs", "gelf", "journald", "json-file", "logentries", "splunk", "syslog"] - Driver: - description: "Driver represents a driver (network, logging, secrets)." + + RegistryServiceConfig: + description: | + RegistryServiceConfig stores daemon registry services configuration. type: "object" - required: [Name] + x-nullable: true properties: - Name: - description: "Name of the driver." - type: "string" - x-nullable: false - example: "some-driver" - Options: - description: "Key/value map of driver-specific options." + AllowNondistributableArtifactsCIDRs: + description: | + List of IP ranges to which nondistributable artifacts can be pushed, + using the CIDR syntax [RFC 4632](https://tools.ietf.org/html/4632). + + Some images (for example, Windows base images) contain artifacts + whose distribution is restricted by license. When these images are + pushed to a registry, restricted artifacts are not included. + + This configuration override this behavior, and enables the daemon to + push nondistributable artifacts to all registries whose resolved IP + address is within the subnet described by the CIDR syntax. + + This option is useful when pushing images containing + nondistributable artifacts to a registry on an air-gapped network so + hosts on that network can pull the images without connecting to + another server. + + > **Warning**: Nondistributable artifacts typically have restrictions + > on how and where they can be distributed and shared. Only use this + > feature to push artifacts to private registries and ensure that you + > are in compliance with any terms that cover redistributing + > nondistributable artifacts. + + type: "array" + items: + type: "string" + example: ["::1/128", "127.0.0.0/8"] + AllowNondistributableArtifactsHostnames: + description: | + List of registry hostnames to which nondistributable artifacts can be + pushed, using the format `[:]` or `[:]`. + + Some images (for example, Windows base images) contain artifacts + whose distribution is restricted by license. When these images are + pushed to a registry, restricted artifacts are not included. + + This configuration override this behavior for the specified + registries. + + This option is useful when pushing images containing + nondistributable artifacts to a registry on an air-gapped network so + hosts on that network can pull the images without connecting to + another server. + + > **Warning**: Nondistributable artifacts typically have restrictions + > on how and where they can be distributed and shared. Only use this + > feature to push artifacts to private registries and ensure that you + > are in compliance with any terms that cover redistributing + > nondistributable artifacts. + type: "array" + items: + type: "string" + example: ["registry.internal.corp.example.com:3000", "[2001:db8:a0b:12f0::1]:443"] + InsecureRegistryCIDRs: + description: | + List of IP ranges of insecure registries, using the CIDR syntax + ([RFC 4632](https://tools.ietf.org/html/4632)). Insecure registries + accept un-encrypted (HTTP) and/or untrusted (HTTPS with certificates + from unknown CAs) communication. + + By default, local registries (`127.0.0.0/8`) are configured as + insecure. All other registries are secure. Communicating with an + insecure registry is not possible if the daemon assumes that registry + is secure. + + This configuration override this behavior, insecure communication with + registries whose resolved IP address is within the subnet described by + the CIDR syntax. + + Registries can also be marked insecure by hostname. Those registries + are listed under `IndexConfigs` and have their `Secure` field set to + `false`. + + > **Warning**: Using this option can be useful when running a local + > registry, but introduces security vulnerabilities. This option + > should therefore ONLY be used for testing purposes. For increased + > security, users should add their CA to their system's list of trusted + > CAs instead of enabling this option. + type: "array" + items: + type: "string" + example: ["::1/128", "127.0.0.0/8"] + IndexConfigs: type: "object" - x-nullable: false additionalProperties: + $ref: "#/definitions/IndexInfo" + example: + "127.0.0.1:5000": + "Name": "127.0.0.1:5000" + "Mirrors": [] + "Secure": false + "Official": false + "[2001:db8:a0b:12f0::1]:80": + "Name": "[2001:db8:a0b:12f0::1]:80" + "Mirrors": [] + "Secure": false + "Official": false + "docker.io": + Name: "docker.io" + Mirrors: ["https://hub-mirror.corp.example.com:5000/"] + Secure: true + Official: true + "registry.internal.corp.example.com:3000": + Name: "registry.internal.corp.example.com:3000" + Mirrors: [] + Secure: false + Official: false + Mirrors: + description: | + List of registry URLs that act as a mirror for the official + (`docker.io`) registry. + + type: "array" + items: type: "string" example: - OptionA: "value for driver-specific option A" - OptionB: "value for driver-specific option B" + - "https://hub-mirror.corp.example.com:5000/" + - "https://[2001:db8:a0b:12f0::1]/" - SecretSpec: + IndexInfo: + description: + IndexInfo contains information about a registry. type: "object" + x-nullable: true properties: Name: - description: "User-defined name of the secret." + description: | + Name of the registry, such as "docker.io". type: "string" - Labels: - description: "User-defined key/value metadata." - type: "object" - additionalProperties: + example: "docker.io" + Mirrors: + description: | + List of mirrors, expressed as URIs. + type: "array" + items: type: "string" example: - com.example.some-label: "some-value" - com.example.some-other-label: "some-other-value" - Data: + - "https://hub-mirror.corp.example.com:5000/" + - "https://registry-2.docker.io/" + - "https://registry-3.docker.io/" + Secure: description: | - Base64-url-safe-encoded ([RFC 4648](https://tools.ietf.org/html/rfc4648#section-3.2)) - data to store as secret. + Indicates if the the registry is part of the list of insecure + registries. + + If `false`, the registry is insecure. Insecure registries accept + un-encrypted (HTTP) and/or untrusted (HTTPS with certificates from + unknown CAs) communication. + + > **Warning**: Insecure registries can be useful when running a local + > registry. However, because its use creates security vulnerabilities + > it should ONLY be enabled for testing purposes. For increased + > security, users should add their CA to their system's list of + > trusted CAs instead of enabling this option. + type: "boolean" + example: true + Official: + description: | + Indicates whether this is an official registry (i.e., Docker Hub / docker.io) + type: "boolean" + example: true - This field is only used to _create_ a secret, and is not returned by - other endpoints. + Runtime: + description: | + Runtime describes an [OCI compliant](https://github.com/opencontainers/runtime-spec) + runtime. + + The runtime is invoked by the daemon via the `containerd` daemon. OCI + runtimes act as an interface to the Linux kernel namespaces, cgroups, + and SELinux. + type: "object" + properties: + path: + description: | + Name and, optional, path, of the OCI executable binary. + + If the path is omitted, the daemon searches the host's `$PATH` for the + binary and uses the first result. type: "string" - example: "" - Driver: - description: "Name of the secrets driver used to fetch the secret's value from an external secret store" - $ref: "#/definitions/Driver" + example: "/usr/local/bin/my-oci-runtime" + runtimeArgs: + description: | + List of command-line arguments to pass to the runtime when invoked. + type: "array" + x-nullable: true + items: + type: "string" + example: ["--debug", "--systemd-cgroup=false"] - Secret: + Commit: + description: | + Commit holds the Git-commit (SHA1) that a binary was built from, as + reported in the version-string of external tools, such as `containerd`, + or `runC`. type: "object" properties: ID: + description: "Actual commit ID of external tool." type: "string" - example: "blt1owaxmitz71s9v5zh81zun" - Version: - $ref: "#/definitions/ObjectVersion" - CreatedAt: - type: "string" - format: "dateTime" - example: "2017-07-20T13:55:28.678958722Z" - UpdatedAt: + example: "cfb82a876ecc11b5ca0977d1733adbe58599088a" + Expected: + description: | + Commit ID of external tool expected by dockerd as set at build time. type: "string" - format: "dateTime" - example: "2017-07-20T13:55:28.678958722Z" - Spec: - $ref: "#/definitions/SecretSpec" - ConfigSpec: + example: "2d41c047c83e09a6d61d464906feb2a2f3c52aa4" + + SwarmInfo: + description: | + Represents generic information about swarm. type: "object" properties: - Name: - description: "User-defined name of the config." + NodeID: + description: "Unique identifier of for this node in the swarm." type: "string" - Labels: - description: "User-defined key/value metadata." - type: "object" - additionalProperties: - type: "string" - Data: + default: "" + example: "k67qz4598weg5unwwffg6z1m1" + NodeAddr: description: | - Base64-url-safe-encoded ([RFC 4648](https://tools.ietf.org/html/rfc4648#section-3.2)) - config data. + IP address at which this node can be reached by other nodes in the + swarm. + type: "string" + default: "" + example: "10.0.0.46" + LocalNodeState: + $ref: "#/definitions/LocalNodeState" + ControlAvailable: + type: "boolean" + default: false + example: true + Error: type: "string" - Config: - type: "object" + default: "" + RemoteManagers: + description: | + List of ID's and addresses of other managers in the swarm. + type: "array" + default: null + x-nullable: true + items: + $ref: "#/definitions/PeerNode" + example: + - NodeID: "71izy0goik036k48jg985xnds" + Addr: "10.0.0.158:2377" + - NodeID: "79y6h1o4gv8n120drcprv5nmc" + Addr: "10.0.0.159:2377" + - NodeID: "k67qz4598weg5unwwffg6z1m1" + Addr: "10.0.0.46:2377" + Nodes: + description: "Total number of nodes in the swarm." + type: "integer" + x-nullable: true + example: 4 + Managers: + description: "Total number of managers in the swarm." + type: "integer" + x-nullable: true + example: 3 + Cluster: + $ref: "#/definitions/ClusterInfo" + + LocalNodeState: + description: "Current local status of this node." + type: "string" + default: "" + enum: + - "" + - "inactive" + - "pending" + - "active" + - "error" + - "locked" + example: "active" + + PeerNode: + description: "Represents a peer-node in the swarm" properties: - ID: - type: "string" - Version: - $ref: "#/definitions/ObjectVersion" - CreatedAt: + NodeID: + description: "Unique identifier of for this node in the swarm." type: "string" - format: "dateTime" - UpdatedAt: + Addr: + description: | + IP address and ports at which this node can be reached. type: "string" - format: "dateTime" - Spec: - $ref: "#/definitions/ConfigSpec" paths: /containers/json: @@ -3301,10 +4504,6 @@ paths: examples: application/json: message: "No such container: c2ada9df5af8" - 406: - description: "impossible to attach" - schema: - $ref: "#/definitions/ErrorResponse" 409: description: "conflict" schema: @@ -3435,7 +4634,7 @@ paths: Config: $ref: "#/definitions/ContainerConfig" NetworkSettings: - $ref: "#/definitions/NetworkConfig" + $ref: "#/definitions/NetworkSettings" examples: application/json: AppArmorProfile: "" @@ -3534,8 +4733,6 @@ paths: LinkLocalIPv6Address: "" LinkLocalIPv6PrefixLen: 0 SandboxKey: "" - SecondaryIPAddresses: null - SecondaryIPv6Addresses: null EndpointID: "" Gateway: "" GlobalIPv6Address: "" @@ -5512,209 +6709,7 @@ paths: 200: description: "No error" schema: - type: "object" - properties: - Architecture: - type: "string" - Containers: - type: "integer" - ContainersRunning: - type: "integer" - ContainersStopped: - type: "integer" - ContainersPaused: - type: "integer" - CpuCfsPeriod: - type: "boolean" - CpuCfsQuota: - type: "boolean" - Debug: - type: "boolean" - DiscoveryBackend: - type: "string" - DockerRootDir: - type: "string" - Driver: - type: "string" - DriverStatus: - type: "array" - items: - type: "array" - items: - type: "string" - SystemStatus: - type: "array" - items: - type: "array" - items: - type: "string" - Plugins: - type: "object" - properties: - Volume: - type: "array" - items: - type: "string" - Network: - type: "array" - items: - type: "string" - Log: - type: "array" - items: - type: "string" - ExperimentalBuild: - type: "boolean" - HttpProxy: - type: "string" - HttpsProxy: - type: "string" - ID: - type: "string" - IPv4Forwarding: - type: "boolean" - Images: - type: "integer" - IndexServerAddress: - type: "string" - InitPath: - type: "string" - InitSha1: - type: "string" - KernelVersion: - type: "string" - Labels: - type: "array" - items: - type: "string" - MemTotal: - type: "integer" - GenericResources: - $ref: "#/definitions/GenericResources" - MemoryLimit: - type: "boolean" - NCPU: - type: "integer" - NEventsListener: - type: "integer" - NFd: - type: "integer" - NGoroutines: - type: "integer" - Name: - type: "string" - NoProxy: - type: "string" - OomKillDisable: - type: "boolean" - OSType: - type: "string" - OomScoreAdj: - type: "integer" - OperatingSystem: - type: "string" - RegistryConfig: - type: "object" - properties: - IndexConfigs: - type: "object" - additionalProperties: - type: "object" - properties: - Mirrors: - type: "array" - items: - type: "string" - Name: - type: "string" - Official: - type: "boolean" - Secure: - type: "boolean" - InsecureRegistryCIDRs: - type: "array" - items: - type: "string" - SwapLimit: - type: "boolean" - SystemTime: - type: "string" - ServerVersion: - type: "string" - examples: - application/json: - Architecture: "x86_64" - ClusterStore: "etcd://localhost:2379" - CgroupDriver: "cgroupfs" - Containers: 11 - ContainersRunning: 7 - ContainersStopped: 3 - ContainersPaused: 1 - CpuCfsPeriod: true - CpuCfsQuota: true - Debug: false - DockerRootDir: "/var/lib/docker" - Driver: "btrfs" - DriverStatus: - - - - "" - ExperimentalBuild: false - HttpProxy: "http://test:test@localhost:8080" - HttpsProxy: "https://test:test@localhost:8080" - ID: "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS" - IPv4Forwarding: true - Images: 16 - IndexServerAddress: "https://index.docker.io/v1/" - InitPath: "/usr/bin/docker" - InitSha1: "" - KernelMemory: true - KernelVersion: "3.12.0-1-amd64" - Labels: - - "storage=ssd" - MemTotal: 2099236864 - MemoryLimit: true - NCPU: 1 - NEventsListener: 0 - NFd: 11 - NGoroutines: 21 - Name: "prod-server-42" - NoProxy: "9.81.1.160" - OomKillDisable: true - OSType: "linux" - OperatingSystem: "Boot2Docker" - Plugins: - Volume: - - "local" - Network: - - "null" - - "host" - - "bridge" - RegistryConfig: - IndexConfigs: - docker.io: - Name: "docker.io" - Official: true - Secure: true - InsecureRegistryCIDRs: - - "127.0.0.0/8" - SecurityOptions: - - Key: "Name" - Value: "seccomp" - - Key: "Profile" - Value: "default" - - Key: "Name" - Value: "apparmor" - - Key: "Name" - Value: "selinux" - - Key: "Name" - Value: "userns" - ServerVersion: "1.9.0" - SwapLimit: false - SystemStatus: - - - - "State" - - "Healthy" - SystemTime: "2015-03-10T11:11:23.730591467-07:00" + $ref: "#/definitions/SystemInfo" 500: description: "Server error" schema: @@ -7485,60 +8480,7 @@ paths: 200: description: "no error" schema: - allOf: - - $ref: "#/definitions/ClusterInfo" - - type: "object" - properties: - JoinTokens: - description: "The tokens workers and managers need to join the swarm." - type: "object" - properties: - Worker: - description: "The token workers can use to join the swarm." - type: "string" - Manager: - description: "The token managers can use to join the swarm." - type: "string" - example: - CreatedAt: "2016-08-15T16:00:20.349727406Z" - Spec: - Dispatcher: - HeartbeatPeriod: 5000000000 - Orchestration: - TaskHistoryRetentionLimit: 10 - CAConfig: - NodeCertExpiry: 7776000000000000 - Raft: - LogEntriesForSlowFollowers: 500 - HeartbeatTick: 1 - SnapshotInterval: 10000 - ElectionTick: 3 - TaskDefaults: {} - EncryptionConfig: - AutoLockManagers: false - Name: "default" - JoinTokens: - Worker: "SWMTKN-1-1h8aps2yszaiqmz2l3oc5392pgk8e49qhx2aj3nyv0ui0hez2a-6qmn92w6bu3jdvnglku58u11a" - Manager: "SWMTKN-1-1h8aps2yszaiqmz2l3oc5392pgk8e49qhx2aj3nyv0ui0hez2a-8llk83c4wm9lwioey2s316r9l" - ID: "70ilmkj2f6sp2137c753w2nmt" - UpdatedAt: "2016-08-15T16:32:09.623207604Z" - Version: - Index: 51 - RootRotationInProgress: false - TLSInfo: - TrustRoot: | - -----BEGIN CERTIFICATE----- - MIIBajCCARCgAwIBAgIUbYqrLSOSQHoxD8CwG6Bi2PJi9c8wCgYIKoZIzj0EAwIw - EzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwNDI0MjE0MzAwWhcNMzcwNDE5MjE0 - MzAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH - A0IABJk/VyMPYdaqDXJb/VXh5n/1Yuv7iNrxV3Qb3l06XD46seovcDWs3IZNV1lf - 3Skyr0ofcchipoiHkXBODojJydSjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB - Af8EBTADAQH/MB0GA1UdDgQWBBRUXxuRcnFjDfR/RIAUQab8ZV/n4jAKBggqhkjO - PQQDAgNIADBFAiAy+JTe6Uc3KyLCMiqGl2GyWGQqQDEcO3/YG36x7om65AIhAJvz - pxv6zFeVEkAEEkqIYi0omA9+CjanB/6Bz4n1uw8H - -----END CERTIFICATE----- - CertIssuerSubject: "MBMxETAPBgNVBAMTCHN3YXJtLWNh" - CertIssuerPublicKey: "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEmT9XIw9h1qoNclv9VeHmf/Vi6/uI2vFXdBveXTpcPjqx6i9wNazchk1XWV/dKTKvSh9xyGKmiIeRcE4OiMnJ1A==" + $ref: "#/definitions/Swarm" 404: description: "no such swarm" schema: diff --git a/vendor/github.com/docker/docker/api/types/client.go b/vendor/github.com/docker/docker/api/types/client.go index 18a1263f1..4ca9ccac7 100644 --- a/vendor/github.com/docker/docker/api/types/client.go +++ b/vendor/github.com/docker/docker/api/types/client.go @@ -181,7 +181,7 @@ type ImageBuildOptions struct { SessionID string // TODO @jhowardmsft LCOW Support: This will require extending to include - // `Platform string`, but is ommited for now as it's hard-coded temporarily + // `Platform string`, but is omitted for now as it's hard-coded temporarily // to avoid API changes. } diff --git a/vendor/github.com/docker/docker/api/types/container/host_config.go b/vendor/github.com/docker/docker/api/types/container/host_config.go index 9fea9eb04..bb421b388 100644 --- a/vendor/github.com/docker/docker/api/types/container/host_config.go +++ b/vendor/github.com/docker/docker/api/types/container/host_config.go @@ -23,41 +23,46 @@ func (i Isolation) IsDefault() bool { // IpcMode represents the container ipc stack. type IpcMode string -// IsPrivate indicates whether the container uses its private ipc stack. +// IsPrivate indicates whether the container uses its own private ipc namespace which can not be shared. func (n IpcMode) IsPrivate() bool { - return !(n.IsHost() || n.IsContainer()) + return n == "private" } -// IsHost indicates whether the container uses the host's ipc stack. +// IsHost indicates whether the container shares the host's ipc namespace. func (n IpcMode) IsHost() bool { return n == "host" } -// IsContainer indicates whether the container uses a container's ipc stack. +// IsShareable indicates whether the container's ipc namespace can be shared with another container. +func (n IpcMode) IsShareable() bool { + return n == "shareable" +} + +// IsContainer indicates whether the container uses another container's ipc namespace. func (n IpcMode) IsContainer() bool { parts := strings.SplitN(string(n), ":", 2) return len(parts) > 1 && parts[0] == "container" } -// Valid indicates whether the ipc stack is valid. +// IsNone indicates whether container IpcMode is set to "none". +func (n IpcMode) IsNone() bool { + return n == "none" +} + +// IsEmpty indicates whether container IpcMode is empty +func (n IpcMode) IsEmpty() bool { + return n == "" +} + +// Valid indicates whether the ipc mode is valid. func (n IpcMode) Valid() bool { - parts := strings.Split(string(n), ":") - switch mode := parts[0]; mode { - case "", "host": - case "container": - if len(parts) != 2 || parts[1] == "" { - return false - } - default: - return false - } - return true + return n.IsEmpty() || n.IsNone() || n.IsPrivate() || n.IsHost() || n.IsShareable() || n.IsContainer() } // Container returns the name of the container ipc stack is going to be used. func (n IpcMode) Container() string { parts := strings.SplitN(string(n), ":", 2) - if len(parts) > 1 { + if len(parts) > 1 && parts[0] == "container" { return parts[1] } return "" diff --git a/vendor/github.com/docker/docker/api/types/filters/example_test.go b/vendor/github.com/docker/docker/api/types/filters/example_test.go new file mode 100644 index 000000000..6529be325 --- /dev/null +++ b/vendor/github.com/docker/docker/api/types/filters/example_test.go @@ -0,0 +1,24 @@ +package filters + +func ExampleArgs_MatchKVList() { + args := NewArgs( + Arg("label", "image=foo"), + Arg("label", "state=running")) + + // returns true because there are no values for bogus + args.MatchKVList("bogus", nil) + + // returns false because there are no sources + args.MatchKVList("label", nil) + + // returns true because all sources are matched + args.MatchKVList("label", map[string]string{ + "image": "foo", + "state": "running", + }) + + // returns false because the values do not match + args.MatchKVList("label", map[string]string{ + "image": "other", + }) +} diff --git a/vendor/github.com/docker/docker/api/types/filters/parse.go b/vendor/github.com/docker/docker/api/types/filters/parse.go index beec3d494..d45d0528f 100644 --- a/vendor/github.com/docker/docker/api/types/filters/parse.go +++ b/vendor/github.com/docker/docker/api/types/filters/parse.go @@ -1,38 +1,45 @@ -// Package filters provides helper function to parse and handle command line -// filter, used for example in docker ps or docker images commands. +/*Package filters provides tools for encoding a mapping of keys to a set of +multiple values. +*/ package filters import ( "encoding/json" "errors" - "fmt" "regexp" "strings" "github.com/docker/docker/api/types/versions" ) -// Args stores filter arguments as map key:{map key: bool}. -// It contains an aggregation of the map of arguments (which are in the form -// of -f 'key=value') based on the key, and stores values for the same key -// in a map with string keys and boolean values. -// e.g given -f 'label=label1=1' -f 'label=label2=2' -f 'image.name=ubuntu' -// the args will be {"image.name":{"ubuntu":true},"label":{"label1=1":true,"label2=2":true}} +// Args stores a mapping of keys to a set of multiple values. type Args struct { fields map[string]map[string]bool } -// NewArgs initializes a new Args struct. -func NewArgs() Args { - return Args{fields: map[string]map[string]bool{}} +// KeyValuePair are used to initialize a new Args +type KeyValuePair struct { + Key string + Value string } -// ParseFlag parses the argument to the filter flag. Like -// -// `docker ps -f 'created=today' -f 'image.name=ubuntu*'` +// Arg creates a new KeyValuePair for initializing Args +func Arg(key, value string) KeyValuePair { + return KeyValuePair{Key: key, Value: value} +} + +// NewArgs returns a new Args populated with the initial args +func NewArgs(initialArgs ...KeyValuePair) Args { + args := Args{fields: map[string]map[string]bool{}} + for _, arg := range initialArgs { + args.Add(arg.Key, arg.Value) + } + return args +} + +// ParseFlag parses a key=value string and adds it to an Args. // -// If prev map is provided, then it is appended to, and returned. By default a new -// map is created. +// Deprecated: Use Args.Add() func ParseFlag(arg string, prev Args) (Args, error) { filters := prev if len(arg) == 0 { @@ -53,74 +60,95 @@ func ParseFlag(arg string, prev Args) (Args, error) { return filters, nil } -// ErrBadFormat is an error returned in case of bad format for a filter. +// ErrBadFormat is an error returned when a filter is not in the form key=value +// +// Deprecated: this error will be removed in a future version var ErrBadFormat = errors.New("bad format of filter (expected name=value)") -// ToParam packs the Args into a string for easy transport from client to server. +// ToParam encodes the Args as args JSON encoded string +// +// Deprecated: use ToJSON func ToParam(a Args) (string, error) { - // this way we don't URL encode {}, just empty space - if a.Len() == 0 { - return "", nil + return ToJSON(a) +} + +// MarshalJSON returns a JSON byte representation of the Args +func (args Args) MarshalJSON() ([]byte, error) { + if len(args.fields) == 0 { + return []byte{}, nil } + return json.Marshal(args.fields) +} - buf, err := json.Marshal(a.fields) - if err != nil { - return "", err +// ToJSON returns the Args as a JSON encoded string +func ToJSON(a Args) (string, error) { + if a.Len() == 0 { + return "", nil } - return string(buf), nil + buf, err := json.Marshal(a) + return string(buf), err } -// ToParamWithVersion packs the Args into a string for easy transport from client to server. -// The generated string will depend on the specified version (corresponding to the API version). +// ToParamWithVersion encodes Args as a JSON string. If version is less than 1.22 +// then the encoded format will use an older legacy format where the values are a +// list of strings, instead of a set. +// +// Deprecated: Use ToJSON func ToParamWithVersion(version string, a Args) (string, error) { - // this way we don't URL encode {}, just empty space if a.Len() == 0 { return "", nil } - // for daemons older than v1.10, filter must be of the form map[string][]string - var buf []byte - var err error if version != "" && versions.LessThan(version, "1.22") { - buf, err = json.Marshal(convertArgsToSlice(a.fields)) - } else { - buf, err = json.Marshal(a.fields) - } - if err != nil { - return "", err + buf, err := json.Marshal(convertArgsToSlice(a.fields)) + return string(buf), err } - return string(buf), nil + + return ToJSON(a) } -// FromParam unpacks the filter Args. +// FromParam decodes a JSON encoded string into Args +// +// Deprecated: use FromJSON func FromParam(p string) (Args, error) { - if len(p) == 0 { - return NewArgs(), nil + return FromJSON(p) +} + +// FromJSON decodes a JSON encoded string into Args +func FromJSON(p string) (Args, error) { + args := NewArgs() + + if p == "" { + return args, nil } - r := strings.NewReader(p) - d := json.NewDecoder(r) + raw := []byte(p) + err := json.Unmarshal(raw, &args) + if err == nil { + return args, nil + } - m := map[string]map[string]bool{} - if err := d.Decode(&m); err != nil { - r.Seek(0, 0) - - // Allow parsing old arguments in slice format. - // Because other libraries might be sending them in this format. - deprecated := map[string][]string{} - if deprecatedErr := d.Decode(&deprecated); deprecatedErr == nil { - m = deprecatedArgs(deprecated) - } else { - return NewArgs(), err - } + // Fallback to parsing arguments in the legacy slice format + deprecated := map[string][]string{} + if legacyErr := json.Unmarshal(raw, &deprecated); legacyErr != nil { + return args, err + } + + args.fields = deprecatedArgs(deprecated) + return args, nil +} + +// UnmarshalJSON populates the Args from JSON encode bytes +func (args Args) UnmarshalJSON(raw []byte) error { + if len(raw) == 0 { + return nil } - return Args{m}, nil + return json.Unmarshal(raw, &args.fields) } -// Get returns the list of values associates with a field. -// It returns a slice of strings to keep backwards compatibility with old code. -func (filters Args) Get(field string) []string { - values := filters.fields[field] +// Get returns the list of values associated with the key +func (args Args) Get(key string) []string { + values := args.fields[key] if values == nil { return make([]string, 0) } @@ -131,37 +159,34 @@ func (filters Args) Get(field string) []string { return slice } -// Add adds a new value to a filter field. -func (filters Args) Add(name, value string) { - if _, ok := filters.fields[name]; ok { - filters.fields[name][value] = true +// Add a new value to the set of values +func (args Args) Add(key, value string) { + if _, ok := args.fields[key]; ok { + args.fields[key][value] = true } else { - filters.fields[name] = map[string]bool{value: true} + args.fields[key] = map[string]bool{value: true} } } -// Del removes a value from a filter field. -func (filters Args) Del(name, value string) { - if _, ok := filters.fields[name]; ok { - delete(filters.fields[name], value) - if len(filters.fields[name]) == 0 { - delete(filters.fields, name) +// Del removes a value from the set +func (args Args) Del(key, value string) { + if _, ok := args.fields[key]; ok { + delete(args.fields[key], value) + if len(args.fields[key]) == 0 { + delete(args.fields, key) } } } -// Len returns the number of fields in the arguments. -func (filters Args) Len() int { - return len(filters.fields) +// Len returns the number of keys in the mapping +func (args Args) Len() int { + return len(args.fields) } -// MatchKVList returns true if the values for the specified field matches the ones -// from the sources. -// e.g. given Args are {'label': {'label1=1','label2=1'}, 'image.name', {'ubuntu'}}, -// field is 'label' and sources are {'label1': '1', 'label2': '2'} -// it returns true. -func (filters Args) MatchKVList(field string, sources map[string]string) bool { - fieldValues := filters.fields[field] +// MatchKVList returns true if all the pairs in sources exist as key=value +// pairs in the mapping at key, or if there are no values at key. +func (args Args) MatchKVList(key string, sources map[string]string) bool { + fieldValues := args.fields[key] //do not filter if there is no filter set or cannot determine filter if len(fieldValues) == 0 { @@ -172,8 +197,8 @@ func (filters Args) MatchKVList(field string, sources map[string]string) bool { return false } - for name2match := range fieldValues { - testKV := strings.SplitN(name2match, "=", 2) + for value := range fieldValues { + testKV := strings.SplitN(value, "=", 2) v, ok := sources[testKV[0]] if !ok { @@ -187,16 +212,13 @@ func (filters Args) MatchKVList(field string, sources map[string]string) bool { return true } -// Match returns true if the values for the specified field matches the source string -// e.g. given Args are {'label': {'label1=1','label2=1'}, 'image.name', {'ubuntu'}}, -// field is 'image.name' and source is 'ubuntu' -// it returns true. -func (filters Args) Match(field, source string) bool { - if filters.ExactMatch(field, source) { +// Match returns true if any of the values at key match the source string +func (args Args) Match(field, source string) bool { + if args.ExactMatch(field, source) { return true } - fieldValues := filters.fields[field] + fieldValues := args.fields[field] for name2match := range fieldValues { match, err := regexp.MatchString(name2match, source) if err != nil { @@ -209,9 +231,9 @@ func (filters Args) Match(field, source string) bool { return false } -// ExactMatch returns true if the source matches exactly one of the filters. -func (filters Args) ExactMatch(field, source string) bool { - fieldValues, ok := filters.fields[field] +// ExactMatch returns true if the source matches exactly one of the values. +func (args Args) ExactMatch(key, source string) bool { + fieldValues, ok := args.fields[key] //do not filter if there is no filter set or cannot determine filter if !ok || len(fieldValues) == 0 { return true @@ -221,14 +243,15 @@ func (filters Args) ExactMatch(field, source string) bool { return fieldValues[source] } -// UniqueExactMatch returns true if there is only one filter and the source matches exactly this one. -func (filters Args) UniqueExactMatch(field, source string) bool { - fieldValues := filters.fields[field] +// UniqueExactMatch returns true if there is only one value and the source +// matches exactly the value. +func (args Args) UniqueExactMatch(key, source string) bool { + fieldValues := args.fields[key] //do not filter if there is no filter set or cannot determine filter if len(fieldValues) == 0 { return true } - if len(filters.fields[field]) != 1 { + if len(args.fields[key]) != 1 { return false } @@ -236,14 +259,14 @@ func (filters Args) UniqueExactMatch(field, source string) bool { return fieldValues[source] } -// FuzzyMatch returns true if the source matches exactly one of the filters, -// or the source has one of the filters as a prefix. -func (filters Args) FuzzyMatch(field, source string) bool { - if filters.ExactMatch(field, source) { +// FuzzyMatch returns true if the source matches exactly one value, or the +// source has one of the values as a prefix. +func (args Args) FuzzyMatch(key, source string) bool { + if args.ExactMatch(key, source) { return true } - fieldValues := filters.fields[field] + fieldValues := args.fields[key] for prefix := range fieldValues { if strings.HasPrefix(source, prefix) { return true @@ -252,30 +275,47 @@ func (filters Args) FuzzyMatch(field, source string) bool { return false } -// Include returns true if the name of the field to filter is in the filters. -func (filters Args) Include(field string) bool { - _, ok := filters.fields[field] +// Include returns true if the key exists in the mapping +// +// Deprecated: use Contains +func (args Args) Include(field string) bool { + _, ok := args.fields[field] + return ok +} + +// Contains returns true if the key exists in the mapping +func (args Args) Contains(field string) bool { + _, ok := args.fields[field] return ok } -// Validate ensures that all the fields in the filter are valid. -// It returns an error as soon as it finds an invalid field. -func (filters Args) Validate(accepted map[string]bool) error { - for name := range filters.fields { +type invalidFilter string + +func (e invalidFilter) Error() string { + return "Invalid filter '" + string(e) + "'" +} + +func (invalidFilter) InvalidParameter() {} + +// Validate compared the set of accepted keys against the keys in the mapping. +// An error is returned if any mapping keys are not in the accepted set. +func (args Args) Validate(accepted map[string]bool) error { + for name := range args.fields { if !accepted[name] { - return fmt.Errorf("Invalid filter '%s'", name) + return invalidFilter(name) } } return nil } -// WalkValues iterates over the list of filtered values for a field. -// It stops the iteration if it finds an error and it returns that error. -func (filters Args) WalkValues(field string, op func(value string) error) error { - if _, ok := filters.fields[field]; !ok { +// WalkValues iterates over the list of values for a key in the mapping and calls +// op() for each value. If op returns an error the iteration stops and the +// error is returned. +func (args Args) WalkValues(field string, op func(value string) error) error { + if _, ok := args.fields[field]; !ok { return nil } - for v := range filters.fields[field] { + for v := range args.fields[field] { if err := op(v); err != nil { return err } diff --git a/vendor/github.com/docker/docker/api/types/filters/parse_test.go b/vendor/github.com/docker/docker/api/types/filters/parse_test.go index ccd1684a0..527905485 100644 --- a/vendor/github.com/docker/docker/api/types/filters/parse_test.go +++ b/vendor/github.com/docker/docker/api/types/filters/parse_test.go @@ -3,6 +3,9 @@ package filters import ( "errors" "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestParseArgs(t *testing.T) { @@ -16,23 +19,18 @@ func TestParseArgs(t *testing.T) { args = NewArgs() err error ) + for i := range flagArgs { args, err = ParseFlag(flagArgs[i], args) - if err != nil { - t.Errorf("failed to parse %s: %s", flagArgs[i], err) - } - } - if len(args.Get("created")) != 1 { - t.Error("failed to set this arg") - } - if len(args.Get("image.name")) != 2 { - t.Error("the args should have collapsed") + require.NoError(t, err) } + assert.Len(t, args.Get("created"), 1) + assert.Len(t, args.Get("image.name"), 2) } func TestParseArgsEdgeCase(t *testing.T) { - var filters Args - args, err := ParseFlag("", filters) + var args Args + args, err := ParseFlag("", args) if err != nil { t.Fatal(err) } @@ -184,7 +182,7 @@ func TestArgsMatchKVList(t *testing.T) { } for args, field := range matches { - if args.MatchKVList(field, sources) != true { + if !args.MatchKVList(field, sources) { t.Fatalf("Expected true for %v on %v, got false", sources, args) } } @@ -204,7 +202,7 @@ func TestArgsMatchKVList(t *testing.T) { } for args, field := range differs { - if args.MatchKVList(field, sources) != false { + if args.MatchKVList(field, sources) { t.Fatalf("Expected false for %v on %v, got true", sources, args) } } @@ -233,9 +231,8 @@ func TestArgsMatch(t *testing.T) { } for args, field := range matches { - if args.Match(field, source) != true { - t.Fatalf("Expected true for %v on %v, got false", source, args) - } + assert.True(t, args.Match(field, source), + "Expected field %s to match %s", field, source) } differs := map[*Args]string{ @@ -258,9 +255,8 @@ func TestArgsMatch(t *testing.T) { } for args, field := range differs { - if args.Match(field, source) != false { - t.Fatalf("Expected false for %v on %v, got true", source, args) - } + assert.False(t, args.Match(field, source), + "Expected field %s to not match %s", field, source) } } diff --git a/vendor/github.com/docker/docker/api/types/mount/mount.go b/vendor/github.com/docker/docker/api/types/mount/mount.go index 2744f85d6..b7d133cd8 100644 --- a/vendor/github.com/docker/docker/api/types/mount/mount.go +++ b/vendor/github.com/docker/docker/api/types/mount/mount.go @@ -15,6 +15,8 @@ const ( TypeVolume Type = "volume" // TypeTmpfs is the type for mounting tmpfs TypeTmpfs Type = "tmpfs" + // TypeNamedPipe is the type for mounting Windows named pipes + TypeNamedPipe Type = "npipe" ) // Mount represents a mount (volume). @@ -65,7 +67,7 @@ var Propagations = []Propagation{ type Consistency string const ( - // ConsistencyFull guarantees bind-mount-like consistency + // ConsistencyFull guarantees bind mount-like consistency ConsistencyFull Consistency = "consistent" // ConsistencyCached mounts can cache read data and FS structure ConsistencyCached Consistency = "cached" diff --git a/vendor/github.com/docker/docker/api/types/time/timestamp.go b/vendor/github.com/docker/docker/api/types/time/timestamp.go index 9aa9702da..ed9c1168b 100644 --- a/vendor/github.com/docker/docker/api/types/time/timestamp.go +++ b/vendor/github.com/docker/docker/api/types/time/timestamp.go @@ -29,10 +29,8 @@ func GetTimestamp(value string, reference time.Time) (string, error) { } var format string - var parseInLocation bool - // if the string has a Z or a + or three dashes use parse otherwise use parseinlocation - parseInLocation = !(strings.ContainsAny(value, "zZ+") || strings.Count(value, "-") == 3) + parseInLocation := !(strings.ContainsAny(value, "zZ+") || strings.Count(value, "-") == 3) if strings.Contains(value, ".") { if parseInLocation { diff --git a/vendor/github.com/docker/docker/builder/builder.go b/vendor/github.com/docker/docker/builder/builder.go index e480601d4..f376f530c 100644 --- a/vendor/github.com/docker/docker/builder/builder.go +++ b/vendor/github.com/docker/docker/builder/builder.go @@ -12,6 +12,7 @@ import ( "github.com/docker/docker/api/types/container" containerpkg "github.com/docker/docker/container" "github.com/docker/docker/layer" + "github.com/docker/docker/pkg/containerfs" "golang.org/x/net/context" ) @@ -24,7 +25,7 @@ const ( // instructions in the builder. type Source interface { // Root returns root path for accessing source - Root() string + Root() containerfs.ContainerFS // Close allows to signal that the filesystem tree won't be used anymore. // For Context implementations using a temporary directory, it is recommended to // delete the temporary directory in Close(). @@ -99,7 +100,7 @@ type Image interface { // ReleaseableLayer is an image layer that can be mounted and released type ReleaseableLayer interface { Release() error - Mount() (string, error) + Mount() (containerfs.ContainerFS, error) Commit(platform string) (ReleaseableLayer, error) DiffID() layer.DiffID } diff --git a/vendor/github.com/docker/docker/builder/dockerfile/buildargs.go b/vendor/github.com/docker/docker/builder/dockerfile/buildargs.go index e0daf9a77..c8f34a77a 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/buildargs.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/buildargs.go @@ -42,6 +42,26 @@ func newBuildArgs(argsFromOptions map[string]*string) *buildArgs { } } +func (b *buildArgs) Clone() *buildArgs { + result := newBuildArgs(b.argsFromOptions) + for k, v := range b.allowedBuildArgs { + result.allowedBuildArgs[k] = v + } + for k, v := range b.allowedMetaArgs { + result.allowedMetaArgs[k] = v + } + for k := range b.referencedArgs { + result.referencedArgs[k] = struct{}{} + } + return result +} + +func (b *buildArgs) MergeReferencedArgs(other *buildArgs) { + for k := range other.referencedArgs { + b.referencedArgs[k] = struct{}{} + } +} + // WarnOnUnusedBuildArgs checks if there are any leftover build-args that were // passed but not consumed during build. Print a warning, if there are any. func (b *buildArgs) WarnOnUnusedBuildArgs(out io.Writer) { diff --git a/vendor/github.com/docker/docker/builder/dockerfile/builder.go b/vendor/github.com/docker/docker/builder/dockerfile/builder.go index 1d7fa413f..27fd4d620 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/builder.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/builder.go @@ -13,12 +13,10 @@ import ( "github.com/docker/docker/api/types/backend" "github.com/docker/docker/api/types/container" "github.com/docker/docker/builder" - "github.com/docker/docker/builder/dockerfile/command" + "github.com/docker/docker/builder/dockerfile/instructions" "github.com/docker/docker/builder/dockerfile/parser" "github.com/docker/docker/builder/fscache" "github.com/docker/docker/builder/remotecontext" - "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/pkg/chrootarchive" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/streamformatter" "github.com/docker/docker/pkg/stringid" @@ -43,6 +41,10 @@ var validCommitCommands = map[string]bool{ "workdir": true, } +const ( + stepFormat = "Step %d/%d : %v" +) + // SessionGetter is object used to get access to a session by uuid type SessionGetter interface { Get(ctx context.Context, uuid string) (session.Caller, error) @@ -50,21 +52,21 @@ type SessionGetter interface { // BuildManager is shared across all Builder objects type BuildManager struct { - archiver *archive.Archiver - backend builder.Backend - pathCache pathCache // TODO: make this persistent - sg SessionGetter - fsCache *fscache.FSCache + idMappings *idtools.IDMappings + backend builder.Backend + pathCache pathCache // TODO: make this persistent + sg SessionGetter + fsCache *fscache.FSCache } // NewBuildManager creates a BuildManager func NewBuildManager(b builder.Backend, sg SessionGetter, fsCache *fscache.FSCache, idMappings *idtools.IDMappings) (*BuildManager, error) { bm := &BuildManager{ - backend: b, - pathCache: &syncmap.Map{}, - sg: sg, - archiver: chrootarchive.NewArchiver(idMappings), - fsCache: fsCache, + backend: b, + pathCache: &syncmap.Map{}, + sg: sg, + idMappings: idMappings, + fsCache: fsCache, } if err := fsCache.RegisterTransport(remotecontext.ClientSessionRemote, NewClientSessionTransport()); err != nil { return nil, err @@ -114,7 +116,7 @@ func (bm *BuildManager) Build(ctx context.Context, config backend.BuildConfig) ( ProgressWriter: config.ProgressWriter, Backend: bm.backend, PathCache: bm.pathCache, - Archiver: bm.archiver, + IDMappings: bm.idMappings, Platform: dockerfile.Platform, } @@ -160,7 +162,7 @@ type builderOptions struct { Backend builder.Backend ProgressWriter backend.ProgressWriter PathCache pathCache - Archiver *archive.Archiver + IDMappings *idtools.IDMappings Platform string } @@ -177,10 +179,8 @@ type Builder struct { docker builder.Backend clientCtx context.Context - archiver *archive.Archiver - buildStages *buildStages + idMappings *idtools.IDMappings disableCommit bool - buildArgs *buildArgs imageSources *imageSources pathCache pathCache containerManager *containerManager @@ -219,9 +219,7 @@ func newBuilder(clientCtx context.Context, options builderOptions) *Builder { Aux: options.ProgressWriter.AuxFormatter, Output: options.ProgressWriter.Output, docker: options.Backend, - archiver: options.Archiver, - buildArgs: newBuildArgs(config.BuildArgs), - buildStages: newBuildStages(), + idMappings: options.IDMappings, imageSources: newImageSources(clientCtx, options), pathCache: options.PathCache, imageProber: newImageProber(options.Backend, config.CacheFrom, options.Platform, config.NoCache), @@ -239,24 +237,27 @@ func (b *Builder) build(source builder.Source, dockerfile *parser.Result) (*buil addNodesForLabelOption(dockerfile.AST, b.options.Labels) - if err := checkDispatchDockerfile(dockerfile.AST); err != nil { - buildsFailed.WithValues(metricsDockerfileSyntaxError).Inc() - return nil, err - } - - dispatchState, err := b.dispatchDockerfileWithCancellation(dockerfile, source) + stages, metaArgs, err := instructions.Parse(dockerfile.AST) if err != nil { - return nil, err + if instructions.IsUnknownInstruction(err) { + buildsFailed.WithValues(metricsUnknownInstructionError).Inc() + } + return nil, validationError{err} } - - if b.options.Target != "" && !dispatchState.isCurrentStage(b.options.Target) { - buildsFailed.WithValues(metricsBuildTargetNotReachableError).Inc() - return nil, errors.Errorf("failed to reach build target %s in Dockerfile", b.options.Target) + if b.options.Target != "" { + targetIx, found := instructions.HasStage(stages, b.options.Target) + if !found { + buildsFailed.WithValues(metricsBuildTargetNotReachableError).Inc() + return nil, errors.Errorf("failed to reach build target %s in Dockerfile", b.options.Target) + } + stages = stages[:targetIx+1] } dockerfile.PrintWarnings(b.Stderr) - b.buildArgs.WarnOnUnusedBuildArgs(b.Stderr) - + dispatchState, err := b.dispatchDockerfileWithCancellation(stages, metaArgs, dockerfile.EscapeToken, source) + if err != nil { + return nil, err + } if dispatchState.imageID == "" { buildsFailed.WithValues(metricsDockerfileEmptyError).Inc() return nil, errors.New("No image was generated. Is your Dockerfile empty?") @@ -271,61 +272,91 @@ func emitImageID(aux *streamformatter.AuxFormatter, state *dispatchState) error return aux.Emit(types.BuildResult{ID: state.imageID}) } -func (b *Builder) dispatchDockerfileWithCancellation(dockerfile *parser.Result, source builder.Source) (*dispatchState, error) { - shlex := NewShellLex(dockerfile.EscapeToken) - state := newDispatchState() - total := len(dockerfile.AST.Children) - var err error - for i, n := range dockerfile.AST.Children { - select { - case <-b.clientCtx.Done(): - logrus.Debug("Builder: build cancelled!") - fmt.Fprint(b.Stdout, "Build cancelled") - buildsFailed.WithValues(metricsBuildCanceled).Inc() - return nil, errors.New("Build cancelled") - default: - // Not cancelled yet, keep going... - } +func processMetaArg(meta instructions.ArgCommand, shlex *ShellLex, args *buildArgs) error { + // ShellLex currently only support the concatenated string format + envs := convertMapToEnvList(args.GetAllAllowed()) + if err := meta.Expand(func(word string) (string, error) { + return shlex.ProcessWord(word, envs) + }); err != nil { + return err + } + args.AddArg(meta.Key, meta.Value) + args.AddMetaArg(meta.Key, meta.Value) + return nil +} - // If this is a FROM and we have a previous image then - // emit an aux message for that image since it is the - // end of the previous stage - if n.Value == command.From { - if err := emitImageID(b.Aux, state); err != nil { - return nil, err - } +func printCommand(out io.Writer, currentCommandIndex int, totalCommands int, cmd interface{}) int { + fmt.Fprintf(out, stepFormat, currentCommandIndex, totalCommands, cmd) + fmt.Fprintln(out) + return currentCommandIndex + 1 +} + +func (b *Builder) dispatchDockerfileWithCancellation(parseResult []instructions.Stage, metaArgs []instructions.ArgCommand, escapeToken rune, source builder.Source) (*dispatchState, error) { + dispatchRequest := dispatchRequest{} + buildArgs := newBuildArgs(b.options.BuildArgs) + totalCommands := len(metaArgs) + len(parseResult) + currentCommandIndex := 1 + for _, stage := range parseResult { + totalCommands += len(stage.Commands) + } + shlex := NewShellLex(escapeToken) + for _, meta := range metaArgs { + currentCommandIndex = printCommand(b.Stdout, currentCommandIndex, totalCommands, &meta) + + err := processMetaArg(meta, shlex, buildArgs) + if err != nil { + return nil, err } + } + + stagesResults := newStagesBuildResults() - if n.Value == command.From && state.isCurrentStage(b.options.Target) { - break + for _, stage := range parseResult { + if err := stagesResults.checkStageNameAvailable(stage.Name); err != nil { + return nil, err } + dispatchRequest = newDispatchRequest(b, escapeToken, source, buildArgs, stagesResults) - opts := dispatchOptions{ - state: state, - stepMsg: formatStep(i, total), - node: n, - shlex: shlex, - source: source, + currentCommandIndex = printCommand(b.Stdout, currentCommandIndex, totalCommands, stage.SourceCode) + if err := initializeStage(dispatchRequest, &stage); err != nil { + return nil, err } - if state, err = b.dispatch(opts); err != nil { - if b.options.ForceRemove { - b.containerManager.RemoveAll(b.Stdout) + dispatchRequest.state.updateRunConfig() + fmt.Fprintf(b.Stdout, " ---> %s\n", stringid.TruncateID(dispatchRequest.state.imageID)) + for _, cmd := range stage.Commands { + select { + case <-b.clientCtx.Done(): + logrus.Debug("Builder: build cancelled!") + fmt.Fprint(b.Stdout, "Build cancelled\n") + buildsFailed.WithValues(metricsBuildCanceled).Inc() + return nil, errors.New("Build cancelled") + default: + // Not cancelled yet, keep going... } + + currentCommandIndex = printCommand(b.Stdout, currentCommandIndex, totalCommands, cmd) + + if err := dispatch(dispatchRequest, cmd); err != nil { + return nil, err + } + + dispatchRequest.state.updateRunConfig() + fmt.Fprintf(b.Stdout, " ---> %s\n", stringid.TruncateID(dispatchRequest.state.imageID)) + + } + if err := emitImageID(b.Aux, dispatchRequest.state); err != nil { return nil, err } - - fmt.Fprintf(b.Stdout, " ---> %s\n", stringid.TruncateID(state.imageID)) - if b.options.Remove { - b.containerManager.RemoveAll(b.Stdout) + buildArgs.MergeReferencedArgs(dispatchRequest.state.buildArgs) + if err := commitStage(dispatchRequest.state, stagesResults); err != nil { + return nil, err } } - - // Emit a final aux message for the final image - if err := emitImageID(b.Aux, state); err != nil { - return nil, err + if b.options.Remove { + b.containerManager.RemoveAll(b.Stdout) } - - return state, nil + buildArgs.WarnOnUnusedBuildArgs(b.Stdout) + return dispatchRequest.state, nil } func addNodesForLabelOption(dockerfile *parser.Node, labels map[string]string) { @@ -357,7 +388,7 @@ func BuildFromConfig(config *container.Config, changes []string) (*container.Con dockerfile, err := parser.Parse(bytes.NewBufferString(strings.Join(changes, "\n"))) if err != nil { - return nil, err + return nil, validationError{err} } // TODO @jhowardmsft LCOW support. For now, if LCOW enabled, switch to linux. @@ -374,7 +405,7 @@ func BuildFromConfig(config *container.Config, changes []string) (*container.Con // ensure that the commands are valid for _, n := range dockerfile.AST.Children { if !validCommitCommands[n.Value] { - return nil, fmt.Errorf("%s is not a valid change command", n.Value) + return nil, validationError{errors.Errorf("%s is not a valid change command", n.Value)} } } @@ -382,39 +413,33 @@ func BuildFromConfig(config *container.Config, changes []string) (*container.Con b.Stderr = ioutil.Discard b.disableCommit = true - if err := checkDispatchDockerfile(dockerfile.AST); err != nil { - return nil, err + commands := []instructions.Command{} + for _, n := range dockerfile.AST.Children { + cmd, err := instructions.ParseCommand(n) + if err != nil { + return nil, validationError{err} + } + commands = append(commands, cmd) } - dispatchState := newDispatchState() - dispatchState.runConfig = config - return dispatchFromDockerfile(b, dockerfile, dispatchState, nil) -} -func checkDispatchDockerfile(dockerfile *parser.Node) error { - for _, n := range dockerfile.Children { - if err := checkDispatch(n); err != nil { - return errors.Wrapf(err, "Dockerfile parse error line %d", n.StartLine) + dispatchRequest := newDispatchRequest(b, dockerfile.EscapeToken, nil, newBuildArgs(b.options.BuildArgs), newStagesBuildResults()) + dispatchRequest.state.runConfig = config + dispatchRequest.state.imageID = config.Image + for _, cmd := range commands { + err := dispatch(dispatchRequest, cmd) + if err != nil { + return nil, validationError{err} } + dispatchRequest.state.updateRunConfig() } - return nil + + return dispatchRequest.state.runConfig, nil } -func dispatchFromDockerfile(b *Builder, result *parser.Result, dispatchState *dispatchState, source builder.Source) (*container.Config, error) { - shlex := NewShellLex(result.EscapeToken) - ast := result.AST - total := len(ast.Children) - - for i, n := range ast.Children { - opts := dispatchOptions{ - state: dispatchState, - stepMsg: formatStep(i, total), - node: n, - shlex: shlex, - source: source, - } - if _, err := b.dispatch(opts); err != nil { - return nil, err - } +func convertMapToEnvList(m map[string]string) []string { + result := []string{} + for k, v := range m { + result = append(result, k+"="+v) } - return dispatchState.runConfig, nil + return result } diff --git a/vendor/github.com/docker/docker/builder/dockerfile/copy.go b/vendor/github.com/docker/docker/builder/dockerfile/copy.go index c7db943f5..f4b703d8d 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/copy.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/copy.go @@ -1,12 +1,15 @@ package dockerfile import ( + "archive/tar" "fmt" "io" + "mime" "net/http" "net/url" "os" "path/filepath" + "runtime" "sort" "strings" "time" @@ -14,16 +17,18 @@ import ( "github.com/docker/docker/builder" "github.com/docker/docker/builder/remotecontext" "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/progress" "github.com/docker/docker/pkg/streamformatter" - "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/urlutil" "github.com/pkg/errors" ) +const unnamedFilename = "__unnamed__" + type pathCache interface { Load(key interface{}) (value interface{}, ok bool) Store(key, value interface{}) @@ -32,14 +37,14 @@ type pathCache interface { // copyInfo is a data object which stores the metadata about each source file in // a copyInstruction type copyInfo struct { - root string + root containerfs.ContainerFS path string hash string noDecompress bool } func (c copyInfo) fullPath() (string, error) { - return symlink.FollowSymlinkInScope(filepath.Join(c.root, c.path), c.root) + return c.root.ResolveScopedPath(c.path, true) } func newCopyInfoFromSource(source builder.Source, path string, hash string) copyInfo { @@ -56,6 +61,7 @@ type copyInstruction struct { cmdName string infos []copyInfo dest string + chownStr string allowLocalDecompression bool } @@ -67,6 +73,7 @@ type copier struct { pathCache pathCache download sourceDownloader tmpPaths []string + platform string } func copierFromDispatchRequest(req dispatchRequest, download sourceDownloader, imageSource *imageMount) copier { @@ -75,6 +82,7 @@ func copierFromDispatchRequest(req dispatchRequest, download sourceDownloader, i pathCache: req.builder.pathCache, download: download, imageSource: imageSource, + platform: req.builder.platform, } } @@ -82,14 +90,14 @@ func (o *copier) createCopyInstruction(args []string, cmdName string) (copyInstr inst := copyInstruction{cmdName: cmdName} last := len(args) - 1 - // Work in daemon-specific filepath semantics - inst.dest = filepath.FromSlash(args[last]) - - infos, err := o.getCopyInfosForSourcePaths(args[0:last]) + // Work in platform-specific filepath semantics + inst.dest = fromSlash(args[last], o.platform) + separator := string(separator(o.platform)) + infos, err := o.getCopyInfosForSourcePaths(args[0:last], inst.dest) if err != nil { return inst, errors.Wrapf(err, "%s failed", cmdName) } - if len(infos) > 1 && !strings.HasSuffix(inst.dest, string(os.PathSeparator)) { + if len(infos) > 1 && !strings.HasSuffix(inst.dest, separator) { return inst, errors.Errorf("When using %s with more than one source file, the destination must be a directory and end with a /", cmdName) } inst.infos = infos @@ -98,10 +106,11 @@ func (o *copier) createCopyInstruction(args []string, cmdName string) (copyInstr // getCopyInfosForSourcePaths iterates over the source files and calculate the info // needed to copy (e.g. hash value if cached) -func (o *copier) getCopyInfosForSourcePaths(sources []string) ([]copyInfo, error) { +// The dest is used in case source is URL (and ends with "/") +func (o *copier) getCopyInfosForSourcePaths(sources []string, dest string) ([]copyInfo, error) { var infos []copyInfo for _, orig := range sources { - subinfos, err := o.getCopyInfoForSourcePath(orig) + subinfos, err := o.getCopyInfoForSourcePath(orig, dest) if err != nil { return nil, err } @@ -114,15 +123,24 @@ func (o *copier) getCopyInfosForSourcePaths(sources []string) ([]copyInfo, error return infos, nil } -func (o *copier) getCopyInfoForSourcePath(orig string) ([]copyInfo, error) { +func (o *copier) getCopyInfoForSourcePath(orig, dest string) ([]copyInfo, error) { if !urlutil.IsURL(orig) { return o.calcCopyInfo(orig, true) } + remote, path, err := o.download(orig) if err != nil { return nil, err } - o.tmpPaths = append(o.tmpPaths, remote.Root()) + // If path == "" then we are unable to determine filename from src + // We have to make sure dest is available + if path == "" { + if strings.HasSuffix(dest, "/") { + return nil, errors.Errorf("cannot determine filename for source %s", orig) + } + path = unnamedFilename + } + o.tmpPaths = append(o.tmpPaths, remote.Root().Path()) hash, err := remote.Hash(path) ci := newCopyInfoFromSource(remote, path, hash) @@ -142,14 +160,6 @@ func (o *copier) Cleanup() { // TODO: allowWildcards can probably be removed by refactoring this function further. func (o *copier) calcCopyInfo(origPath string, allowWildcards bool) ([]copyInfo, error) { imageSource := o.imageSource - if err := validateCopySourcePath(imageSource, origPath); err != nil { - return nil, err - } - - // Work in daemon-specific OS filepath semantics - origPath = filepath.FromSlash(origPath) - origPath = strings.TrimPrefix(origPath, string(os.PathSeparator)) - origPath = strings.TrimPrefix(origPath, "."+string(os.PathSeparator)) // TODO: do this when creating copier. Requires validateCopySourcePath // (and other below) to be aware of the difference sources. Why is it only @@ -166,8 +176,20 @@ func (o *copier) calcCopyInfo(origPath string, allowWildcards bool) ([]copyInfo, return nil, errors.Errorf("missing build context") } + root := o.source.Root() + + if err := validateCopySourcePath(imageSource, origPath, root.OS()); err != nil { + return nil, err + } + + // Work in source OS specific filepath semantics + // For LCOW, this is NOT the daemon OS. + origPath = root.FromSlash(origPath) + origPath = strings.TrimPrefix(origPath, string(root.Separator())) + origPath = strings.TrimPrefix(origPath, "."+string(root.Separator())) + // Deal with wildcards - if allowWildcards && containsWildcards(origPath) { + if allowWildcards && containsWildcards(origPath, root.OS()) { return o.copyWithWildcards(origPath) } @@ -199,6 +221,19 @@ func (o *copier) calcCopyInfo(origPath string, allowWildcards bool) ([]copyInfo, return newCopyInfos(newCopyInfoFromSource(o.source, origPath, hash)), nil } +func containsWildcards(name, platform string) bool { + isWindows := platform == "windows" + for i := 0; i < len(name); i++ { + ch := name[i] + if ch == '\\' && !isWindows { + i++ + } else if ch == '*' || ch == '?' || ch == '[' { + return true + } + } + return false +} + func (o *copier) storeInPathCache(im *imageMount, path string, hash string) { if im != nil { o.pathCache.Store(im.ImageID()+path, hash) @@ -206,12 +241,13 @@ func (o *copier) storeInPathCache(im *imageMount, path string, hash string) { } func (o *copier) copyWithWildcards(origPath string) ([]copyInfo, error) { + root := o.source.Root() var copyInfos []copyInfo - if err := filepath.Walk(o.source.Root(), func(path string, info os.FileInfo, err error) error { + if err := root.Walk(root.Path(), func(path string, info os.FileInfo, err error) error { if err != nil { return err } - rel, err := remotecontext.Rel(o.source.Root(), path) + rel, err := remotecontext.Rel(root, path) if err != nil { return err } @@ -219,7 +255,7 @@ func (o *copier) copyWithWildcards(origPath string) ([]copyInfo, error) { if rel == "." { return nil } - if match, _ := filepath.Match(origPath, rel); !match { + if match, _ := root.Match(origPath, rel); !match { return nil } @@ -261,7 +297,7 @@ func walkSource(source builder.Source, origPath string) ([]string, error) { } // Must be a dir var subfiles []string - err = filepath.Walk(fp, func(path string, info os.FileInfo, err error) error { + err = source.Root().Walk(fp, func(path string, info os.FileInfo, err error) error { if err != nil { return err } @@ -300,22 +336,40 @@ func errOnSourceDownload(_ string) (builder.Source, string, error) { return nil, "", errors.New("source can't be a URL for COPY") } +func getFilenameForDownload(path string, resp *http.Response) string { + // Guess filename based on source + if path != "" && !strings.HasSuffix(path, "/") { + if filename := filepath.Base(filepath.FromSlash(path)); filename != "" { + return filename + } + } + + // Guess filename based on Content-Disposition + if contentDisposition := resp.Header.Get("Content-Disposition"); contentDisposition != "" { + if _, params, err := mime.ParseMediaType(contentDisposition); err == nil { + if params["filename"] != "" && !strings.HasSuffix(params["filename"], "/") { + if filename := filepath.Base(filepath.FromSlash(params["filename"])); filename != "" { + return filename + } + } + } + } + return "" +} + func downloadSource(output io.Writer, stdout io.Writer, srcURL string) (remote builder.Source, p string, err error) { u, err := url.Parse(srcURL) if err != nil { return } - filename := filepath.Base(filepath.FromSlash(u.Path)) // Ensure in platform semantics - if filename == "" { - err = errors.Errorf("cannot determine filename from url: %s", u) - return - } resp, err := remotecontext.GetWithStatusError(srcURL) if err != nil { return } + filename := getFilenameForDownload(u.Path, resp) + // Prepare file in a tmp dir tmpDir, err := ioutils.TempDir("", "docker-remote") if err != nil { @@ -326,7 +380,13 @@ func downloadSource(output io.Writer, stdout io.Writer, srcURL string) (remote b os.RemoveAll(tmpDir) } }() - tmpFileName := filepath.Join(tmpDir, filename) + // If filename is empty, the returned filename will be "" but + // the tmp filename will be created as "__unnamed__" + tmpFileName := filename + if filename == "" { + tmpFileName = unnamedFilename + } + tmpFileName = filepath.Join(tmpDir, tmpFileName) tmpFile, err := os.OpenFile(tmpFileName, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) if err != nil { return @@ -362,13 +422,19 @@ func downloadSource(output io.Writer, stdout io.Writer, srcURL string) (remote b return } - lc, err := remotecontext.NewLazySource(tmpDir) + lc, err := remotecontext.NewLazySource(containerfs.NewLocalContainerFS(tmpDir)) return lc, filename, err } type copyFileOptions struct { decompress bool - archiver *archive.Archiver + chownPair idtools.IDPair + archiver Archiver +} + +type copyEndpoint struct { + driver containerfs.Driver + path string } func performCopyForInfo(dest copyInfo, source copyInfo, options copyFileOptions) error { @@ -376,6 +442,7 @@ func performCopyForInfo(dest copyInfo, source copyInfo, options copyFileOptions) if err != nil { return err } + destPath, err := dest.fullPath() if err != nil { return err @@ -383,57 +450,90 @@ func performCopyForInfo(dest copyInfo, source copyInfo, options copyFileOptions) archiver := options.archiver - src, err := os.Stat(srcPath) + srcEndpoint := ©Endpoint{driver: source.root, path: srcPath} + destEndpoint := ©Endpoint{driver: dest.root, path: destPath} + + src, err := source.root.Stat(srcPath) if err != nil { return errors.Wrapf(err, "source path not found") } if src.IsDir() { - return copyDirectory(archiver, srcPath, destPath) + return copyDirectory(archiver, srcEndpoint, destEndpoint, options.chownPair) } - if options.decompress && archive.IsArchivePath(srcPath) && !source.noDecompress { + if options.decompress && isArchivePath(source.root, srcPath) && !source.noDecompress { return archiver.UntarPath(srcPath, destPath) } - destExistsAsDir, err := isExistingDirectory(destPath) + destExistsAsDir, err := isExistingDirectory(destEndpoint) if err != nil { return err } // dest.path must be used because destPath has already been cleaned of any // trailing slash - if endsInSlash(dest.path) || destExistsAsDir { + if endsInSlash(dest.root, dest.path) || destExistsAsDir { // source.path must be used to get the correct filename when the source // is a symlink - destPath = filepath.Join(destPath, filepath.Base(source.path)) + destPath = dest.root.Join(destPath, source.root.Base(source.path)) + destEndpoint = ©Endpoint{driver: dest.root, path: destPath} } - return copyFile(archiver, srcPath, destPath) + return copyFile(archiver, srcEndpoint, destEndpoint, options.chownPair) } -func copyDirectory(archiver *archive.Archiver, source, dest string) error { - if err := archiver.CopyWithTar(source, dest); err != nil { - return errors.Wrapf(err, "failed to copy directory") +func isArchivePath(driver containerfs.ContainerFS, path string) bool { + file, err := driver.Open(path) + if err != nil { + return false } - return fixPermissions(source, dest, archiver.IDMappings.RootPair()) + defer file.Close() + rdr, err := archive.DecompressStream(file) + if err != nil { + return false + } + r := tar.NewReader(rdr) + _, err = r.Next() + return err == nil } -func copyFile(archiver *archive.Archiver, source, dest string) error { - rootIDs := archiver.IDMappings.RootPair() +func copyDirectory(archiver Archiver, source, dest *copyEndpoint, chownPair idtools.IDPair) error { + destExists, err := isExistingDirectory(dest) + if err != nil { + return errors.Wrapf(err, "failed to query destination path") + } - if err := idtools.MkdirAllAndChownNew(filepath.Dir(dest), 0755, rootIDs); err != nil { - return errors.Wrapf(err, "failed to create new directory") + if err := archiver.CopyWithTar(source.path, dest.path); err != nil { + return errors.Wrapf(err, "failed to copy directory") } - if err := archiver.CopyFileWithTar(source, dest); err != nil { + // TODO: @gupta-ak. Investigate how LCOW permission mappings will work. + return fixPermissions(source.path, dest.path, chownPair, !destExists) +} + +func copyFile(archiver Archiver, source, dest *copyEndpoint, chownPair idtools.IDPair) error { + if runtime.GOOS == "windows" && dest.driver.OS() == "linux" { + // LCOW + if err := dest.driver.MkdirAll(dest.driver.Dir(dest.path), 0755); err != nil { + return errors.Wrapf(err, "failed to create new directory") + } + } else { + if err := idtools.MkdirAllAndChownNew(filepath.Dir(dest.path), 0755, chownPair); err != nil { + // Normal containers + return errors.Wrapf(err, "failed to create new directory") + } + } + + if err := archiver.CopyFileWithTar(source.path, dest.path); err != nil { return errors.Wrapf(err, "failed to copy file") } - return fixPermissions(source, dest, rootIDs) + // TODO: @gupta-ak. Investigate how LCOW permission mappings will work. + return fixPermissions(source.path, dest.path, chownPair, false) } -func endsInSlash(path string) bool { - return strings.HasSuffix(path, string(os.PathSeparator)) +func endsInSlash(driver containerfs.Driver, path string) bool { + return strings.HasSuffix(path, string(driver.Separator())) } // isExistingDirectory returns true if the path exists and is a directory -func isExistingDirectory(path string) (bool, error) { - destStat, err := os.Stat(path) +func isExistingDirectory(point *copyEndpoint) (bool, error) { + destStat, err := point.driver.Stat(point.path) switch { case os.IsNotExist(err): return false, nil diff --git a/vendor/github.com/docker/docker/builder/dockerfile/copy_test.go b/vendor/github.com/docker/docker/builder/dockerfile/copy_test.go index aee225b5f..87c5675d9 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/copy_test.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/copy_test.go @@ -1,16 +1,18 @@ package dockerfile import ( + "net/http" "testing" - "github.com/docker/docker/pkg/testutil/tempfile" + "github.com/docker/docker/pkg/containerfs" + "github.com/gotestyourself/gotestyourself/fs" "github.com/stretchr/testify/assert" ) func TestIsExistingDirectory(t *testing.T) { - tmpfile := tempfile.NewTempFile(t, "file-exists-test", "something") + tmpfile := fs.NewFile(t, "file-exists-test", fs.WithContent("something")) defer tmpfile.Remove() - tmpdir := tempfile.NewTempDir(t, "dir-exists-test") + tmpdir := fs.NewDir(t, "dir-exists-test") defer tmpdir.Remove() var testcases = []struct { @@ -20,7 +22,7 @@ func TestIsExistingDirectory(t *testing.T) { }{ { doc: "directory exists", - path: tmpdir.Path, + path: tmpdir.Path(), expected: true, }, { @@ -30,16 +32,116 @@ func TestIsExistingDirectory(t *testing.T) { }, { doc: "file exists", - path: tmpfile.Name(), + path: tmpfile.Path(), expected: false, }, } for _, testcase := range testcases { - result, err := isExistingDirectory(testcase.path) + result, err := isExistingDirectory(©Endpoint{driver: containerfs.NewLocalDriver(), path: testcase.path}) if !assert.NoError(t, err) { continue } assert.Equal(t, testcase.expected, result, testcase.doc) } } + +func TestGetFilenameForDownload(t *testing.T) { + var testcases = []struct { + path string + disposition string + expected string + }{ + { + path: "http://www.example.com/", + expected: "", + }, + { + path: "http://www.example.com/xyz", + expected: "xyz", + }, + { + path: "http://www.example.com/xyz.html", + expected: "xyz.html", + }, + { + path: "http://www.example.com/xyz/", + expected: "", + }, + { + path: "http://www.example.com/xyz/uvw", + expected: "uvw", + }, + { + path: "http://www.example.com/xyz/uvw.html", + expected: "uvw.html", + }, + { + path: "http://www.example.com/xyz/uvw/", + expected: "", + }, + { + path: "/", + expected: "", + }, + { + path: "/xyz", + expected: "xyz", + }, + { + path: "/xyz.html", + expected: "xyz.html", + }, + { + path: "/xyz/", + expected: "", + }, + { + path: "/xyz/", + disposition: "attachment; filename=xyz.html", + expected: "xyz.html", + }, + { + disposition: "", + expected: "", + }, + { + disposition: "attachment; filename=xyz", + expected: "xyz", + }, + { + disposition: "attachment; filename=xyz.html", + expected: "xyz.html", + }, + { + disposition: "attachment; filename=\"xyz\"", + expected: "xyz", + }, + { + disposition: "attachment; filename=\"xyz.html\"", + expected: "xyz.html", + }, + { + disposition: "attachment; filename=\"/xyz.html\"", + expected: "xyz.html", + }, + { + disposition: "attachment; filename=\"/xyz/uvw\"", + expected: "uvw", + }, + { + disposition: "attachment; filename=\"Naïve file.txt\"", + expected: "Naïve file.txt", + }, + } + for _, testcase := range testcases { + resp := http.Response{ + Header: make(map[string][]string), + } + if testcase.disposition != "" { + resp.Header.Add("Content-Disposition", testcase.disposition) + } + filename := getFilenameForDownload(testcase.path, &resp) + assert.Equal(t, testcase.expected, filename) + } +} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/copy_unix.go b/vendor/github.com/docker/docker/builder/dockerfile/copy_unix.go index 326d95bb3..883370055 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/copy_unix.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/copy_unix.go @@ -6,13 +6,21 @@ import ( "os" "path/filepath" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" ) -func fixPermissions(source, destination string, rootIDs idtools.IDPair) error { - skipChownRoot, err := isExistingDirectory(destination) - if err != nil { - return err +func fixPermissions(source, destination string, rootIDs idtools.IDPair, overrideSkip bool) error { + var ( + skipChownRoot bool + err error + ) + if !overrideSkip { + destEndpoint := ©Endpoint{driver: containerfs.NewLocalDriver(), path: destination} + skipChownRoot, err = isExistingDirectory(destEndpoint) + if err != nil { + return err + } } // We Walk on the source rather than on the destination because we don't @@ -34,3 +42,7 @@ func fixPermissions(source, destination string, rootIDs idtools.IDPair) error { return os.Lchown(fullpath, rootIDs.UID, rootIDs.GID) }) } + +func validateCopySourcePath(imageSource *imageMount, origPath, platform string) error { + return nil +} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/copy_windows.go b/vendor/github.com/docker/docker/builder/dockerfile/copy_windows.go index 78f5b0945..dcf4c5acf 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/copy_windows.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/copy_windows.go @@ -1,8 +1,38 @@ package dockerfile -import "github.com/docker/docker/pkg/idtools" +import ( + "errors" + "path/filepath" + "strings" -func fixPermissions(source, destination string, rootIDs idtools.IDPair) error { + "github.com/docker/docker/pkg/idtools" +) + +func fixPermissions(source, destination string, rootIDs idtools.IDPair, overrideSkip bool) error { // chown is not supported on Windows return nil } + +func validateCopySourcePath(imageSource *imageMount, origPath, platform string) error { + // validate windows paths from other images + LCOW + if imageSource == nil || platform != "windows" { + return nil + } + + origPath = filepath.FromSlash(origPath) + p := strings.ToLower(filepath.Clean(origPath)) + if !filepath.IsAbs(p) { + if filepath.VolumeName(p) != "" { + if p[len(p)-2:] == ":." { // case where clean returns weird c:. paths + p = p[:len(p)-1] + } + p += "\\" + } else { + p = filepath.Join("c:\\", p) + } + } + if _, blacklisted := pathBlacklist[p]; blacklisted { + return errors.New("copy from c:\\ or c:\\windows is not allowed on windows") + } + return nil +} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/dispatchers.go b/vendor/github.com/docker/docker/builder/dockerfile/dispatchers.go index 24a0a1c4d..76bcb0b2d 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/dispatchers.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/dispatchers.go @@ -10,17 +10,15 @@ package dockerfile import ( "bytes" "fmt" - "regexp" "runtime" "sort" - "strconv" "strings" - "time" "github.com/docker/docker/api" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/strslice" "github.com/docker/docker/builder" + "github.com/docker/docker/builder/dockerfile/instructions" "github.com/docker/docker/builder/dockerfile/parser" "github.com/docker/docker/image" "github.com/docker/docker/pkg/jsonmessage" @@ -36,32 +34,14 @@ import ( // Sets the environment variable foo to bar, also makes interpolation // in the dockerfile available from the next statement on via ${foo}. // -func env(req dispatchRequest) error { - if len(req.args) == 0 { - return errAtLeastOneArgument("ENV") - } - - if len(req.args)%2 != 0 { - // should never get here, but just in case - return errTooManyArguments("ENV") - } - - if err := req.flags.Parse(); err != nil { - return err - } - - runConfig := req.state.runConfig +func dispatchEnv(d dispatchRequest, c *instructions.EnvCommand) error { + runConfig := d.state.runConfig commitMessage := bytes.NewBufferString("ENV") + for _, e := range c.Env { + name := e.Key + newVar := e.String() - for j := 0; j < len(req.args); j += 2 { - if len(req.args[j]) == 0 { - return errBlankCommandNames("ENV") - } - name := req.args[j] - value := req.args[j+1] - newVar := name + "=" + value commitMessage.WriteString(" " + newVar) - gotOne := false for i, envVar := range runConfig.Env { envParts := strings.SplitN(envVar, "=", 2) @@ -76,64 +56,32 @@ func env(req dispatchRequest) error { runConfig.Env = append(runConfig.Env, newVar) } } - - return req.builder.commit(req.state, commitMessage.String()) + return d.builder.commit(d.state, commitMessage.String()) } // MAINTAINER some text // // Sets the maintainer metadata. -func maintainer(req dispatchRequest) error { - if len(req.args) != 1 { - return errExactlyOneArgument("MAINTAINER") - } - - if err := req.flags.Parse(); err != nil { - return err - } +func dispatchMaintainer(d dispatchRequest, c *instructions.MaintainerCommand) error { - maintainer := req.args[0] - req.state.maintainer = maintainer - return req.builder.commit(req.state, "MAINTAINER "+maintainer) + d.state.maintainer = c.Maintainer + return d.builder.commit(d.state, "MAINTAINER "+c.Maintainer) } // LABEL some json data describing the image // // Sets the Label variable foo to bar, // -func label(req dispatchRequest) error { - if len(req.args) == 0 { - return errAtLeastOneArgument("LABEL") - } - if len(req.args)%2 != 0 { - // should never get here, but just in case - return errTooManyArguments("LABEL") +func dispatchLabel(d dispatchRequest, c *instructions.LabelCommand) error { + if d.state.runConfig.Labels == nil { + d.state.runConfig.Labels = make(map[string]string) } - - if err := req.flags.Parse(); err != nil { - return err - } - commitStr := "LABEL" - runConfig := req.state.runConfig - - if runConfig.Labels == nil { - runConfig.Labels = map[string]string{} + for _, v := range c.Labels { + d.state.runConfig.Labels[v.Key] = v.Value + commitStr += " " + v.String() } - - for j := 0; j < len(req.args); j++ { - name := req.args[j] - if name == "" { - return errBlankCommandNames("LABEL") - } - - value := req.args[j+1] - commitStr += " " + name + "=" + value - - runConfig.Labels[name] = value - j++ - } - return req.builder.commit(req.state, commitStr) + return d.builder.commit(d.state, commitStr) } // ADD foo /path @@ -141,253 +89,172 @@ func label(req dispatchRequest) error { // Add the file 'foo' to '/path'. Tarball and Remote URL (git, http) handling // exist here. If you do not wish to have this automatic handling, use COPY. // -func add(req dispatchRequest) error { - if len(req.args) < 2 { - return errAtLeastTwoArguments("ADD") - } - - if err := req.flags.Parse(); err != nil { - return err - } - - downloader := newRemoteSourceDownloader(req.builder.Output, req.builder.Stdout) - copier := copierFromDispatchRequest(req, downloader, nil) +func dispatchAdd(d dispatchRequest, c *instructions.AddCommand) error { + downloader := newRemoteSourceDownloader(d.builder.Output, d.builder.Stdout) + copier := copierFromDispatchRequest(d, downloader, nil) defer copier.Cleanup() - copyInstruction, err := copier.createCopyInstruction(req.args, "ADD") + + copyInstruction, err := copier.createCopyInstruction(c.SourcesAndDest, "ADD") if err != nil { return err } + copyInstruction.chownStr = c.Chown copyInstruction.allowLocalDecompression = true - return req.builder.performCopy(req.state, copyInstruction) + return d.builder.performCopy(d.state, copyInstruction) } // COPY foo /path // // Same as 'ADD' but without the tar and remote url handling. // -func dispatchCopy(req dispatchRequest) error { - if len(req.args) < 2 { - return errAtLeastTwoArguments("COPY") - } - - flFrom := req.flags.AddString("from", "") - if err := req.flags.Parse(); err != nil { - return err - } - - im, err := req.builder.getImageMount(flFrom) - if err != nil { - return errors.Wrapf(err, "invalid from flag value %s", flFrom.Value) +func dispatchCopy(d dispatchRequest, c *instructions.CopyCommand) error { + var im *imageMount + var err error + if c.From != "" { + im, err = d.getImageMount(c.From) + if err != nil { + return errors.Wrapf(err, "invalid from flag value %s", c.From) + } } - - copier := copierFromDispatchRequest(req, errOnSourceDownload, im) + copier := copierFromDispatchRequest(d, errOnSourceDownload, im) defer copier.Cleanup() - copyInstruction, err := copier.createCopyInstruction(req.args, "COPY") + copyInstruction, err := copier.createCopyInstruction(c.SourcesAndDest, "COPY") if err != nil { return err } + copyInstruction.chownStr = c.Chown - return req.builder.performCopy(req.state, copyInstruction) + return d.builder.performCopy(d.state, copyInstruction) } -func (b *Builder) getImageMount(fromFlag *Flag) (*imageMount, error) { - if !fromFlag.IsUsed() { +func (d *dispatchRequest) getImageMount(imageRefOrID string) (*imageMount, error) { + if imageRefOrID == "" { // TODO: this could return the source in the default case as well? return nil, nil } var localOnly bool - imageRefOrID := fromFlag.Value - stage, err := b.buildStages.get(fromFlag.Value) + stage, err := d.stages.get(imageRefOrID) if err != nil { return nil, err } if stage != nil { - imageRefOrID = stage.ImageID() + imageRefOrID = stage.Image localOnly = true } - return b.imageSources.Get(imageRefOrID, localOnly) + return d.builder.imageSources.Get(imageRefOrID, localOnly) } // FROM imagename[:tag | @digest] [AS build-stage-name] // -func from(req dispatchRequest) error { - stageName, err := parseBuildStageName(req.args) - if err != nil { - return err - } - - if err := req.flags.Parse(); err != nil { - return err - } - - req.builder.imageProber.Reset() - image, err := req.builder.getFromImage(req.shlex, req.args[0]) +func initializeStage(d dispatchRequest, cmd *instructions.Stage) error { + d.builder.imageProber.Reset() + image, err := d.getFromImage(d.shlex, cmd.BaseName) if err != nil { return err } - if err := req.builder.buildStages.add(stageName, image); err != nil { - return err - } - req.state.beginStage(stageName, image) - req.builder.buildArgs.ResetAllowed() - if image.ImageID() == "" { - // Typically this means they used "FROM scratch" - return nil + state := d.state + state.beginStage(cmd.Name, image) + if len(state.runConfig.OnBuild) > 0 { + triggers := state.runConfig.OnBuild + state.runConfig.OnBuild = nil + return dispatchTriggeredOnBuild(d, triggers) } - - return processOnBuild(req) + return nil } -func parseBuildStageName(args []string) (string, error) { - stageName := "" - switch { - case len(args) == 3 && strings.EqualFold(args[1], "as"): - stageName = strings.ToLower(args[2]) - if ok, _ := regexp.MatchString("^[a-z][a-z0-9-_\\.]*$", stageName); !ok { - return "", errors.Errorf("invalid name for build stage: %q, name can't start with a number or contain symbols", stageName) +func dispatchTriggeredOnBuild(d dispatchRequest, triggers []string) error { + fmt.Fprintf(d.builder.Stdout, "# Executing %d build trigger", len(triggers)) + if len(triggers) > 1 { + fmt.Fprint(d.builder.Stdout, "s") + } + fmt.Fprintln(d.builder.Stdout) + for _, trigger := range triggers { + d.state.updateRunConfig() + ast, err := parser.Parse(strings.NewReader(trigger)) + if err != nil { + return err + } + if len(ast.AST.Children) != 1 { + return errors.New("onbuild trigger should be a single expression") + } + cmd, err := instructions.ParseCommand(ast.AST.Children[0]) + if err != nil { + if instructions.IsUnknownInstruction(err) { + buildsFailed.WithValues(metricsUnknownInstructionError).Inc() + } + return err + } + err = dispatch(d, cmd) + if err != nil { + return err } - case len(args) != 1: - return "", errors.New("FROM requires either one or three arguments") } - - return stageName, nil + return nil } -// scratchImage is used as a token for the empty base image. +// scratchImage is used as a token for the empty base image. It uses buildStage +// as a convenient implementation of builder.Image, but is not actually a +// buildStage. var scratchImage builder.Image = &image.Image{} -func (b *Builder) getFromImage(shlex *ShellLex, name string) (builder.Image, error) { +func (d *dispatchRequest) getExpandedImageName(shlex *ShellLex, name string) (string, error) { substitutionArgs := []string{} - for key, value := range b.buildArgs.GetAllMeta() { + for key, value := range d.state.buildArgs.GetAllMeta() { substitutionArgs = append(substitutionArgs, key+"="+value) } name, err := shlex.ProcessWord(name, substitutionArgs) if err != nil { - return nil, err + return "", err } - + return name, nil +} +func (d *dispatchRequest) getImageOrStage(name string) (builder.Image, error) { var localOnly bool - if stage, ok := b.buildStages.getByName(name); ok { - name = stage.ImageID() + if im, ok := d.stages.getByName(name); ok { + name = im.Image localOnly = true } // Windows cannot support a container with no base image unless it is LCOW. if name == api.NoBaseImageSpecifier { if runtime.GOOS == "windows" { - if b.platform == "windows" || (b.platform != "windows" && !system.LCOWSupported()) { + if d.builder.platform == "windows" || (d.builder.platform != "windows" && !system.LCOWSupported()) { return nil, errors.New("Windows does not support FROM scratch") } } return scratchImage, nil } - imageMount, err := b.imageSources.Get(name, localOnly) + imageMount, err := d.builder.imageSources.Get(name, localOnly) if err != nil { return nil, err } return imageMount.Image(), nil } - -func processOnBuild(req dispatchRequest) error { - dispatchState := req.state - // Process ONBUILD triggers if they exist - if nTriggers := len(dispatchState.runConfig.OnBuild); nTriggers != 0 { - word := "trigger" - if nTriggers > 1 { - word = "triggers" - } - fmt.Fprintf(req.builder.Stderr, "# Executing %d build %s...\n", nTriggers, word) - } - - // Copy the ONBUILD triggers, and remove them from the config, since the config will be committed. - onBuildTriggers := dispatchState.runConfig.OnBuild - dispatchState.runConfig.OnBuild = []string{} - - // Reset stdin settings as all build actions run without stdin - dispatchState.runConfig.OpenStdin = false - dispatchState.runConfig.StdinOnce = false - - // parse the ONBUILD triggers by invoking the parser - for _, step := range onBuildTriggers { - dockerfile, err := parser.Parse(strings.NewReader(step)) - if err != nil { - return err - } - - for _, n := range dockerfile.AST.Children { - if err := checkDispatch(n); err != nil { - return err - } - - upperCasedCmd := strings.ToUpper(n.Value) - switch upperCasedCmd { - case "ONBUILD": - return errors.New("Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed") - case "MAINTAINER", "FROM": - return errors.Errorf("%s isn't allowed as an ONBUILD trigger", upperCasedCmd) - } - } - - if _, err := dispatchFromDockerfile(req.builder, dockerfile, dispatchState, req.source); err != nil { - return err - } +func (d *dispatchRequest) getFromImage(shlex *ShellLex, name string) (builder.Image, error) { + name, err := d.getExpandedImageName(shlex, name) + if err != nil { + return nil, err } - return nil + return d.getImageOrStage(name) } -// ONBUILD RUN echo yo -// -// ONBUILD triggers run when the image is used in a FROM statement. -// -// ONBUILD handling has a lot of special-case functionality, the heading in -// evaluator.go and comments around dispatch() in the same file explain the -// special cases. search for 'OnBuild' in internals.go for additional special -// cases. -// -func onbuild(req dispatchRequest) error { - if len(req.args) == 0 { - return errAtLeastOneArgument("ONBUILD") - } - - if err := req.flags.Parse(); err != nil { - return err - } +func dispatchOnbuild(d dispatchRequest, c *instructions.OnbuildCommand) error { - triggerInstruction := strings.ToUpper(strings.TrimSpace(req.args[0])) - switch triggerInstruction { - case "ONBUILD": - return errors.New("Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed") - case "MAINTAINER", "FROM": - return fmt.Errorf("%s isn't allowed as an ONBUILD trigger", triggerInstruction) - } - - runConfig := req.state.runConfig - original := regexp.MustCompile(`(?i)^\s*ONBUILD\s*`).ReplaceAllString(req.original, "") - runConfig.OnBuild = append(runConfig.OnBuild, original) - return req.builder.commit(req.state, "ONBUILD "+original) + d.state.runConfig.OnBuild = append(d.state.runConfig.OnBuild, c.Expression) + return d.builder.commit(d.state, "ONBUILD "+c.Expression) } // WORKDIR /tmp // // Set the working directory for future RUN/CMD/etc statements. // -func workdir(req dispatchRequest) error { - if len(req.args) != 1 { - return errExactlyOneArgument("WORKDIR") - } - - err := req.flags.Parse() - if err != nil { - return err - } - - runConfig := req.state.runConfig - // This is from the Dockerfile and will not necessarily be in platform - // specific semantics, hence ensure it is converted. - runConfig.WorkingDir, err = normaliseWorkdir(runConfig.WorkingDir, req.args[0]) +func dispatchWorkdir(d dispatchRequest, c *instructions.WorkdirCommand) error { + runConfig := d.state.runConfig + var err error + runConfig.WorkingDir, err = normalizeWorkdir(d.builder.platform, runConfig.WorkingDir, c.Path) if err != nil { return err } @@ -396,23 +263,31 @@ func workdir(req dispatchRequest) error { // This avoids having an unnecessary expensive mount/unmount calls // (on Windows in particular) during each container create. // Prior to 1.13, the mkdir was deferred and not executed at this step. - if req.builder.disableCommit { + if d.builder.disableCommit { // Don't call back into the daemon if we're going through docker commit --change "WORKDIR /foo". // We've already updated the runConfig and that's enough. return nil } comment := "WORKDIR " + runConfig.WorkingDir - runConfigWithCommentCmd := copyRunConfig(runConfig, withCmdCommentString(comment, req.builder.platform)) - containerID, err := req.builder.probeAndCreate(req.state, runConfigWithCommentCmd) + runConfigWithCommentCmd := copyRunConfig(runConfig, withCmdCommentString(comment, d.builder.platform)) + containerID, err := d.builder.probeAndCreate(d.state, runConfigWithCommentCmd) if err != nil || containerID == "" { return err } - if err := req.builder.docker.ContainerCreateWorkdir(containerID); err != nil { + if err := d.builder.docker.ContainerCreateWorkdir(containerID); err != nil { return err } - return req.builder.commitContainer(req.state, containerID, runConfigWithCommentCmd) + return d.builder.commitContainer(d.state, containerID, runConfigWithCommentCmd) +} + +func resolveCmdLine(cmd instructions.ShellDependantCmdLine, runConfig *container.Config, platform string) []string { + result := cmd.CmdLine + if cmd.PrependShell && result != nil { + result = append(getShell(runConfig, platform), result...) + } + return result } // RUN some command yo @@ -425,32 +300,21 @@ func workdir(req dispatchRequest) error { // RUN echo hi # cmd /S /C echo hi (Windows) // RUN [ "echo", "hi" ] # echo hi // -func run(req dispatchRequest) error { - if !req.state.hasFromImage() { - return errors.New("Please provide a source image with `from` prior to run") - } +func dispatchRun(d dispatchRequest, c *instructions.RunCommand) error { - if err := req.flags.Parse(); err != nil { - return err - } - - stateRunConfig := req.state.runConfig - args := handleJSONArgs(req.args, req.attributes) - if !req.attributes["json"] { - args = append(getShell(stateRunConfig, req.builder.platform), args...) - } - cmdFromArgs := strslice.StrSlice(args) - buildArgs := req.builder.buildArgs.FilterAllowed(stateRunConfig.Env) + stateRunConfig := d.state.runConfig + cmdFromArgs := resolveCmdLine(c.ShellDependantCmdLine, stateRunConfig, d.builder.platform) + buildArgs := d.state.buildArgs.FilterAllowed(stateRunConfig.Env) saveCmd := cmdFromArgs if len(buildArgs) > 0 { - saveCmd = prependEnvOnCmd(req.builder.buildArgs, buildArgs, cmdFromArgs) + saveCmd = prependEnvOnCmd(d.state.buildArgs, buildArgs, cmdFromArgs) } runConfigForCacheProbe := copyRunConfig(stateRunConfig, withCmd(saveCmd), withEntrypointOverride(saveCmd, nil)) - hit, err := req.builder.probeCache(req.state, runConfigForCacheProbe) + hit, err := d.builder.probeCache(d.state, runConfigForCacheProbe) if err != nil || hit { return err } @@ -464,11 +328,11 @@ func run(req dispatchRequest) error { runConfig.ArgsEscaped = true logrus.Debugf("[BUILDER] Command to be executed: %v", runConfig.Cmd) - cID, err := req.builder.create(runConfig) + cID, err := d.builder.create(runConfig) if err != nil { return err } - if err := req.builder.containerManager.Run(req.builder.clientCtx, cID, req.builder.Stdout, req.builder.Stderr); err != nil { + if err := d.builder.containerManager.Run(d.builder.clientCtx, cID, d.builder.Stdout, d.builder.Stderr); err != nil { if err, ok := err.(*statusCodeError); ok { // TODO: change error type, because jsonmessage.JSONError assumes HTTP return &jsonmessage.JSONError{ @@ -481,7 +345,7 @@ func run(req dispatchRequest) error { return err } - return req.builder.commitContainer(req.state, cID, runConfigForCacheProbe) + return d.builder.commitContainer(d.state, cID, runConfigForCacheProbe) } // Derive the command to use for probeCache() and to commit in this container. @@ -514,139 +378,39 @@ func prependEnvOnCmd(buildArgs *buildArgs, buildArgVars []string, cmd strslice.S // Set the default command to run in the container (which may be empty). // Argument handling is the same as RUN. // -func cmd(req dispatchRequest) error { - if err := req.flags.Parse(); err != nil { - return err - } - - runConfig := req.state.runConfig - cmdSlice := handleJSONArgs(req.args, req.attributes) - if !req.attributes["json"] { - cmdSlice = append(getShell(runConfig, req.builder.platform), cmdSlice...) - } - - runConfig.Cmd = strslice.StrSlice(cmdSlice) +func dispatchCmd(d dispatchRequest, c *instructions.CmdCommand) error { + runConfig := d.state.runConfig + cmd := resolveCmdLine(c.ShellDependantCmdLine, runConfig, d.builder.platform) + runConfig.Cmd = cmd // set config as already being escaped, this prevents double escaping on windows runConfig.ArgsEscaped = true - if err := req.builder.commit(req.state, fmt.Sprintf("CMD %q", cmdSlice)); err != nil { + if err := d.builder.commit(d.state, fmt.Sprintf("CMD %q", cmd)); err != nil { return err } - if len(req.args) != 0 { - req.state.cmdSet = true + if len(c.ShellDependantCmdLine.CmdLine) != 0 { + d.state.cmdSet = true } return nil } -// parseOptInterval(flag) is the duration of flag.Value, or 0 if -// empty. An error is reported if the value is given and less than minimum duration. -func parseOptInterval(f *Flag) (time.Duration, error) { - s := f.Value - if s == "" { - return 0, nil - } - d, err := time.ParseDuration(s) - if err != nil { - return 0, err - } - if d < time.Duration(container.MinimumDuration) { - return 0, fmt.Errorf("Interval %#v cannot be less than %s", f.name, container.MinimumDuration) - } - return d, nil -} - // HEALTHCHECK foo // // Set the default healthcheck command to run in the container (which may be empty). // Argument handling is the same as RUN. // -func healthcheck(req dispatchRequest) error { - if len(req.args) == 0 { - return errAtLeastOneArgument("HEALTHCHECK") - } - runConfig := req.state.runConfig - typ := strings.ToUpper(req.args[0]) - args := req.args[1:] - if typ == "NONE" { - if len(args) != 0 { - return errors.New("HEALTHCHECK NONE takes no arguments") - } - test := strslice.StrSlice{typ} - runConfig.Healthcheck = &container.HealthConfig{ - Test: test, - } - } else { - if runConfig.Healthcheck != nil { - oldCmd := runConfig.Healthcheck.Test - if len(oldCmd) > 0 && oldCmd[0] != "NONE" { - fmt.Fprintf(req.builder.Stdout, "Note: overriding previous HEALTHCHECK: %v\n", oldCmd) - } - } - - healthcheck := container.HealthConfig{} - - flInterval := req.flags.AddString("interval", "") - flTimeout := req.flags.AddString("timeout", "") - flStartPeriod := req.flags.AddString("start-period", "") - flRetries := req.flags.AddString("retries", "") - - if err := req.flags.Parse(); err != nil { - return err - } - - switch typ { - case "CMD": - cmdSlice := handleJSONArgs(args, req.attributes) - if len(cmdSlice) == 0 { - return errors.New("Missing command after HEALTHCHECK CMD") - } - - if !req.attributes["json"] { - typ = "CMD-SHELL" - } - - healthcheck.Test = strslice.StrSlice(append([]string{typ}, cmdSlice...)) - default: - return fmt.Errorf("Unknown type %#v in HEALTHCHECK (try CMD)", typ) - } - - interval, err := parseOptInterval(flInterval) - if err != nil { - return err - } - healthcheck.Interval = interval - - timeout, err := parseOptInterval(flTimeout) - if err != nil { - return err - } - healthcheck.Timeout = timeout - - startPeriod, err := parseOptInterval(flStartPeriod) - if err != nil { - return err - } - healthcheck.StartPeriod = startPeriod - - if flRetries.Value != "" { - retries, err := strconv.ParseInt(flRetries.Value, 10, 32) - if err != nil { - return err - } - if retries < 1 { - return fmt.Errorf("--retries must be at least 1 (not %d)", retries) - } - healthcheck.Retries = int(retries) - } else { - healthcheck.Retries = 0 +func dispatchHealthcheck(d dispatchRequest, c *instructions.HealthCheckCommand) error { + runConfig := d.state.runConfig + if runConfig.Healthcheck != nil { + oldCmd := runConfig.Healthcheck.Test + if len(oldCmd) > 0 && oldCmd[0] != "NONE" { + fmt.Fprintf(d.builder.Stdout, "Note: overriding previous HEALTHCHECK: %v\n", oldCmd) } - - runConfig.Healthcheck = &healthcheck } - - return req.builder.commit(req.state, fmt.Sprintf("HEALTHCHECK %q", runConfig.Healthcheck)) + runConfig.Healthcheck = c.Health + return d.builder.commit(d.state, fmt.Sprintf("HEALTHCHECK %q", runConfig.Healthcheck)) } // ENTRYPOINT /usr/sbin/nginx @@ -657,33 +421,15 @@ func healthcheck(req dispatchRequest) error { // Handles command processing similar to CMD and RUN, only req.runConfig.Entrypoint // is initialized at newBuilder time instead of through argument parsing. // -func entrypoint(req dispatchRequest) error { - if err := req.flags.Parse(); err != nil { - return err - } - - runConfig := req.state.runConfig - parsed := handleJSONArgs(req.args, req.attributes) - - switch { - case req.attributes["json"]: - // ENTRYPOINT ["echo", "hi"] - runConfig.Entrypoint = strslice.StrSlice(parsed) - case len(parsed) == 0: - // ENTRYPOINT [] - runConfig.Entrypoint = nil - default: - // ENTRYPOINT echo hi - runConfig.Entrypoint = strslice.StrSlice(append(getShell(runConfig, req.builder.platform), parsed[0])) - } - - // when setting the entrypoint if a CMD was not explicitly set then - // set the command to nil - if !req.state.cmdSet { +func dispatchEntrypoint(d dispatchRequest, c *instructions.EntrypointCommand) error { + runConfig := d.state.runConfig + cmd := resolveCmdLine(c.ShellDependantCmdLine, runConfig, d.builder.platform) + runConfig.Entrypoint = cmd + if !d.state.cmdSet { runConfig.Cmd = nil } - return req.builder.commit(req.state, fmt.Sprintf("ENTRYPOINT %q", runConfig.Entrypoint)) + return d.builder.commit(d.state, fmt.Sprintf("ENTRYPOINT %q", runConfig.Entrypoint)) } // EXPOSE 6667/tcp 7000/tcp @@ -691,41 +437,33 @@ func entrypoint(req dispatchRequest) error { // Expose ports for links and port mappings. This all ends up in // req.runConfig.ExposedPorts for runconfig. // -func expose(req dispatchRequest) error { - portsTab := req.args - - if len(req.args) == 0 { - return errAtLeastOneArgument("EXPOSE") +func dispatchExpose(d dispatchRequest, c *instructions.ExposeCommand, envs []string) error { + // custom multi word expansion + // expose $FOO with FOO="80 443" is expanded as EXPOSE [80,443]. This is the only command supporting word to words expansion + // so the word processing has been de-generalized + ports := []string{} + for _, p := range c.Ports { + ps, err := d.shlex.ProcessWords(p, envs) + if err != nil { + return err + } + ports = append(ports, ps...) } + c.Ports = ports - if err := req.flags.Parse(); err != nil { + ps, _, err := nat.ParsePortSpecs(ports) + if err != nil { return err } - runConfig := req.state.runConfig - if runConfig.ExposedPorts == nil { - runConfig.ExposedPorts = make(nat.PortSet) + if d.state.runConfig.ExposedPorts == nil { + d.state.runConfig.ExposedPorts = make(nat.PortSet) } - - ports, _, err := nat.ParsePortSpecs(portsTab) - if err != nil { - return err + for p := range ps { + d.state.runConfig.ExposedPorts[p] = struct{}{} } - // instead of using ports directly, we build a list of ports and sort it so - // the order is consistent. This prevents cache burst where map ordering - // changes between builds - portList := make([]string, len(ports)) - var i int - for port := range ports { - if _, exists := runConfig.ExposedPorts[port]; !exists { - runConfig.ExposedPorts[port] = struct{}{} - } - portList[i] = string(port) - i++ - } - sort.Strings(portList) - return req.builder.commit(req.state, "EXPOSE "+strings.Join(portList, " ")) + return d.builder.commit(d.state, "EXPOSE "+strings.Join(c.Ports, " ")) } // USER foo @@ -733,62 +471,39 @@ func expose(req dispatchRequest) error { // Set the user to 'foo' for future commands and when running the // ENTRYPOINT/CMD at container run time. // -func user(req dispatchRequest) error { - if len(req.args) != 1 { - return errExactlyOneArgument("USER") - } - - if err := req.flags.Parse(); err != nil { - return err - } - - req.state.runConfig.User = req.args[0] - return req.builder.commit(req.state, fmt.Sprintf("USER %v", req.args)) +func dispatchUser(d dispatchRequest, c *instructions.UserCommand) error { + d.state.runConfig.User = c.User + return d.builder.commit(d.state, fmt.Sprintf("USER %v", c.User)) } // VOLUME /foo // // Expose the volume /foo for use. Will also accept the JSON array form. // -func volume(req dispatchRequest) error { - if len(req.args) == 0 { - return errAtLeastOneArgument("VOLUME") +func dispatchVolume(d dispatchRequest, c *instructions.VolumeCommand) error { + if d.state.runConfig.Volumes == nil { + d.state.runConfig.Volumes = map[string]struct{}{} } - - if err := req.flags.Parse(); err != nil { - return err - } - - runConfig := req.state.runConfig - if runConfig.Volumes == nil { - runConfig.Volumes = map[string]struct{}{} - } - for _, v := range req.args { - v = strings.TrimSpace(v) + for _, v := range c.Volumes { if v == "" { return errors.New("VOLUME specified can not be an empty string") } - runConfig.Volumes[v] = struct{}{} + d.state.runConfig.Volumes[v] = struct{}{} } - return req.builder.commit(req.state, fmt.Sprintf("VOLUME %v", req.args)) + return d.builder.commit(d.state, fmt.Sprintf("VOLUME %v", c.Volumes)) } // STOPSIGNAL signal // // Set the signal that will be used to kill the container. -func stopSignal(req dispatchRequest) error { - if len(req.args) != 1 { - return errExactlyOneArgument("STOPSIGNAL") - } +func dispatchStopSignal(d dispatchRequest, c *instructions.StopSignalCommand) error { - sig := req.args[0] - _, err := signal.ParseSignal(sig) + _, err := signal.ParseSignal(c.Signal) if err != nil { - return err + return validationError{err} } - - req.state.runConfig.StopSignal = sig - return req.builder.commit(req.state, fmt.Sprintf("STOPSIGNAL %v", req.args)) + d.state.runConfig.StopSignal = c.Signal + return d.builder.commit(d.state, fmt.Sprintf("STOPSIGNAL %v", c.Signal)) } // ARG name[=value] @@ -796,89 +511,21 @@ func stopSignal(req dispatchRequest) error { // Adds the variable foo to the trusted list of variables that can be passed // to builder using the --build-arg flag for expansion/substitution or passing to 'run'. // Dockerfile author may optionally set a default value of this variable. -func arg(req dispatchRequest) error { - if len(req.args) != 1 { - return errExactlyOneArgument("ARG") - } - - var ( - name string - newValue string - hasDefault bool - ) - - arg := req.args[0] - // 'arg' can just be a name or name-value pair. Note that this is different - // from 'env' that handles the split of name and value at the parser level. - // The reason for doing it differently for 'arg' is that we support just - // defining an arg and not assign it a value (while 'env' always expects a - // name-value pair). If possible, it will be good to harmonize the two. - if strings.Contains(arg, "=") { - parts := strings.SplitN(arg, "=", 2) - if len(parts[0]) == 0 { - return errBlankCommandNames("ARG") - } - - name = parts[0] - newValue = parts[1] - hasDefault = true - } else { - name = arg - hasDefault = false - } +func dispatchArg(d dispatchRequest, c *instructions.ArgCommand) error { - var value *string - if hasDefault { - value = &newValue + commitStr := "ARG " + c.Key + if c.Value != nil { + commitStr += "=" + *c.Value } - req.builder.buildArgs.AddArg(name, value) - // Arg before FROM doesn't add a layer - if !req.state.hasFromImage() { - req.builder.buildArgs.AddMetaArg(name, value) - return nil - } - return req.builder.commit(req.state, "ARG "+arg) + d.state.buildArgs.AddArg(c.Key, c.Value) + return d.builder.commit(d.state, commitStr) } // SHELL powershell -command // // Set the non-default shell to use. -func shell(req dispatchRequest) error { - if err := req.flags.Parse(); err != nil { - return err - } - shellSlice := handleJSONArgs(req.args, req.attributes) - switch { - case len(shellSlice) == 0: - // SHELL [] - return errAtLeastOneArgument("SHELL") - case req.attributes["json"]: - // SHELL ["powershell", "-command"] - req.state.runConfig.Shell = strslice.StrSlice(shellSlice) - default: - // SHELL powershell -command - not JSON - return errNotJSON("SHELL", req.original) - } - return req.builder.commit(req.state, fmt.Sprintf("SHELL %v", shellSlice)) -} - -func errAtLeastOneArgument(command string) error { - return fmt.Errorf("%s requires at least one argument", command) -} - -func errExactlyOneArgument(command string) error { - return fmt.Errorf("%s requires exactly one argument", command) -} - -func errAtLeastTwoArguments(command string) error { - return fmt.Errorf("%s requires at least two arguments", command) -} - -func errBlankCommandNames(command string) error { - return fmt.Errorf("%s names can not be blank", command) -} - -func errTooManyArguments(command string) error { - return fmt.Errorf("Bad input to %s, too many arguments", command) +func dispatchShell(d dispatchRequest, c *instructions.ShellCommand) error { + d.state.runConfig.Shell = c.Shell + return d.builder.commit(d.state, fmt.Sprintf("SHELL %v", d.state.runConfig.Shell)) } diff --git a/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_test.go b/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_test.go index b3672fce1..f7f1b1e31 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_test.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_test.go @@ -1,60 +1,29 @@ package dockerfile import ( - "fmt" - "runtime" - "testing" - "bytes" "context" + "runtime" + "testing" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/strslice" "github.com/docker/docker/builder" - "github.com/docker/docker/builder/dockerfile/parser" + "github.com/docker/docker/builder/dockerfile/instructions" "github.com/docker/docker/pkg/system" - "github.com/docker/docker/pkg/testutil" "github.com/docker/go-connections/nat" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -type commandWithFunction struct { - name string - function func(args []string) error -} - -func withArgs(f dispatcher) func([]string) error { - return func(args []string) error { - return f(dispatchRequest{args: args}) - } -} - -func withBuilderAndArgs(builder *Builder, f dispatcher) func([]string) error { - return func(args []string) error { - return f(defaultDispatchReq(builder, args...)) - } -} - -func defaultDispatchReq(builder *Builder, args ...string) dispatchRequest { - return dispatchRequest{ - builder: builder, - args: args, - flags: NewBFlags(), - shlex: NewShellLex(parser.DefaultEscapeToken), - state: &dispatchState{runConfig: &container.Config{}}, - } -} - func newBuilderWithMockBackend() *Builder { mockBackend := &MockBackend{} ctx := context.Background() b := &Builder{ options: &types.ImageBuildOptions{}, docker: mockBackend, - buildArgs: newBuildArgs(make(map[string]*string)), Stdout: new(bytes.Buffer), clientCtx: ctx, disableCommit: true, @@ -62,137 +31,84 @@ func newBuilderWithMockBackend() *Builder { Options: &types.ImageBuildOptions{}, Backend: mockBackend, }), - buildStages: newBuildStages(), imageProber: newImageProber(mockBackend, nil, runtime.GOOS, false), containerManager: newContainerManager(mockBackend), } return b } -func TestCommandsExactlyOneArgument(t *testing.T) { - commands := []commandWithFunction{ - {"MAINTAINER", withArgs(maintainer)}, - {"WORKDIR", withArgs(workdir)}, - {"USER", withArgs(user)}, - {"STOPSIGNAL", withArgs(stopSignal)}, - } - - for _, command := range commands { - err := command.function([]string{}) - assert.EqualError(t, err, errExactlyOneArgument(command.name).Error()) - } -} - -func TestCommandsAtLeastOneArgument(t *testing.T) { - commands := []commandWithFunction{ - {"ENV", withArgs(env)}, - {"LABEL", withArgs(label)}, - {"ONBUILD", withArgs(onbuild)}, - {"HEALTHCHECK", withArgs(healthcheck)}, - {"EXPOSE", withArgs(expose)}, - {"VOLUME", withArgs(volume)}, - } - - for _, command := range commands { - err := command.function([]string{}) - assert.EqualError(t, err, errAtLeastOneArgument(command.name).Error()) - } -} - -func TestCommandsAtLeastTwoArguments(t *testing.T) { - commands := []commandWithFunction{ - {"ADD", withArgs(add)}, - {"COPY", withArgs(dispatchCopy)}} - - for _, command := range commands { - err := command.function([]string{"arg1"}) - assert.EqualError(t, err, errAtLeastTwoArguments(command.name).Error()) - } -} - -func TestCommandsTooManyArguments(t *testing.T) { - commands := []commandWithFunction{ - {"ENV", withArgs(env)}, - {"LABEL", withArgs(label)}} - - for _, command := range commands { - err := command.function([]string{"arg1", "arg2", "arg3"}) - assert.EqualError(t, err, errTooManyArguments(command.name).Error()) - } -} - -func TestCommandsBlankNames(t *testing.T) { - builder := newBuilderWithMockBackend() - commands := []commandWithFunction{ - {"ENV", withBuilderAndArgs(builder, env)}, - {"LABEL", withBuilderAndArgs(builder, label)}, - } - - for _, command := range commands { - err := command.function([]string{"", ""}) - assert.EqualError(t, err, errBlankCommandNames(command.name).Error()) - } -} - func TestEnv2Variables(t *testing.T) { b := newBuilderWithMockBackend() - - args := []string{"var1", "val1", "var2", "val2"} - req := defaultDispatchReq(b, args...) - err := env(req) + sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) + envCommand := &instructions.EnvCommand{ + Env: instructions.KeyValuePairs{ + instructions.KeyValuePair{Key: "var1", Value: "val1"}, + instructions.KeyValuePair{Key: "var2", Value: "val2"}, + }, + } + err := dispatch(sb, envCommand) require.NoError(t, err) expected := []string{ - fmt.Sprintf("%s=%s", args[0], args[1]), - fmt.Sprintf("%s=%s", args[2], args[3]), + "var1=val1", + "var2=val2", } - assert.Equal(t, expected, req.state.runConfig.Env) + assert.Equal(t, expected, sb.state.runConfig.Env) } func TestEnvValueWithExistingRunConfigEnv(t *testing.T) { b := newBuilderWithMockBackend() - - args := []string{"var1", "val1"} - req := defaultDispatchReq(b, args...) - req.state.runConfig.Env = []string{"var1=old", "var2=fromenv"} - err := env(req) + sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) + sb.state.runConfig.Env = []string{"var1=old", "var2=fromenv"} + envCommand := &instructions.EnvCommand{ + Env: instructions.KeyValuePairs{ + instructions.KeyValuePair{Key: "var1", Value: "val1"}, + }, + } + err := dispatch(sb, envCommand) require.NoError(t, err) - expected := []string{ - fmt.Sprintf("%s=%s", args[0], args[1]), + "var1=val1", "var2=fromenv", } - assert.Equal(t, expected, req.state.runConfig.Env) + assert.Equal(t, expected, sb.state.runConfig.Env) } func TestMaintainer(t *testing.T) { maintainerEntry := "Some Maintainer " - b := newBuilderWithMockBackend() - req := defaultDispatchReq(b, maintainerEntry) - err := maintainer(req) + sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) + cmd := &instructions.MaintainerCommand{Maintainer: maintainerEntry} + err := dispatch(sb, cmd) require.NoError(t, err) - assert.Equal(t, maintainerEntry, req.state.maintainer) + assert.Equal(t, maintainerEntry, sb.state.maintainer) } func TestLabel(t *testing.T) { labelName := "label" labelValue := "value" - labelEntry := []string{labelName, labelValue} b := newBuilderWithMockBackend() - req := defaultDispatchReq(b, labelEntry...) - err := label(req) + sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) + cmd := &instructions.LabelCommand{ + Labels: instructions.KeyValuePairs{ + instructions.KeyValuePair{Key: labelName, Value: labelValue}, + }, + } + err := dispatch(sb, cmd) require.NoError(t, err) - require.Contains(t, req.state.runConfig.Labels, labelName) - assert.Equal(t, req.state.runConfig.Labels[labelName], labelValue) + require.Contains(t, sb.state.runConfig.Labels, labelName) + assert.Equal(t, sb.state.runConfig.Labels[labelName], labelValue) } func TestFromScratch(t *testing.T) { b := newBuilderWithMockBackend() - req := defaultDispatchReq(b, "scratch") - err := from(req) + sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) + cmd := &instructions.Stage{ + BaseName: "scratch", + } + err := initializeStage(sb, cmd) if runtime.GOOS == "windows" && !system.LCOWSupported() { assert.EqualError(t, err, "Windows does not support FROM scratch") @@ -200,14 +116,14 @@ func TestFromScratch(t *testing.T) { } require.NoError(t, err) - assert.True(t, req.state.hasFromImage()) - assert.Equal(t, "", req.state.imageID) + assert.True(t, sb.state.hasFromImage()) + assert.Equal(t, "", sb.state.imageID) // Windows does not set the default path. TODO @jhowardmsft LCOW support. This will need revisiting as we get further into the implementation expected := "PATH=" + system.DefaultPathEnv(runtime.GOOS) if runtime.GOOS == "windows" { expected = "" } - assert.Equal(t, []string{expected}, req.state.runConfig.Env) + assert.Equal(t, []string{expected}, sb.state.runConfig.Env) } func TestFromWithArg(t *testing.T) { @@ -219,16 +135,27 @@ func TestFromWithArg(t *testing.T) { } b := newBuilderWithMockBackend() b.docker.(*MockBackend).getImageFunc = getImage + args := newBuildArgs(make(map[string]*string)) - require.NoError(t, arg(defaultDispatchReq(b, "THETAG="+tag))) - req := defaultDispatchReq(b, "alpine${THETAG}") - err := from(req) + val := "sometag" + metaArg := instructions.ArgCommand{ + Key: "THETAG", + Value: &val, + } + cmd := &instructions.Stage{ + BaseName: "alpine:${THETAG}", + } + err := processMetaArg(metaArg, NewShellLex('\\'), args) + sb := newDispatchRequest(b, '\\', nil, args, newStagesBuildResults()) require.NoError(t, err) - assert.Equal(t, expected, req.state.imageID) - assert.Equal(t, expected, req.state.baseImage.ImageID()) - assert.Len(t, b.buildArgs.GetAllAllowed(), 0) - assert.Len(t, b.buildArgs.GetAllMeta(), 1) + err = initializeStage(sb, cmd) + require.NoError(t, err) + + assert.Equal(t, expected, sb.state.imageID) + assert.Equal(t, expected, sb.state.baseImage.ImageID()) + assert.Len(t, sb.state.buildArgs.GetAllAllowed(), 0) + assert.Len(t, sb.state.buildArgs.GetAllMeta(), 1) } func TestFromWithUndefinedArg(t *testing.T) { @@ -240,74 +167,74 @@ func TestFromWithUndefinedArg(t *testing.T) { } b := newBuilderWithMockBackend() b.docker.(*MockBackend).getImageFunc = getImage + sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) + b.options.BuildArgs = map[string]*string{"THETAG": &tag} - req := defaultDispatchReq(b, "alpine${THETAG}") - err := from(req) + cmd := &instructions.Stage{ + BaseName: "alpine${THETAG}", + } + err := initializeStage(sb, cmd) require.NoError(t, err) - assert.Equal(t, expected, req.state.imageID) + assert.Equal(t, expected, sb.state.imageID) } -func TestFromMultiStageWithScratchNamedStage(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("Windows does not support scratch") - } +func TestFromMultiStageWithNamedStage(t *testing.T) { b := newBuilderWithMockBackend() - req := defaultDispatchReq(b, "scratch", "AS", "base") - - require.NoError(t, from(req)) - assert.True(t, req.state.hasFromImage()) - - req.args = []string{"base"} - require.NoError(t, from(req)) - assert.True(t, req.state.hasFromImage()) -} - -func TestOnbuildIllegalTriggers(t *testing.T) { - triggers := []struct{ command, expectedError string }{ - {"ONBUILD", "Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed"}, - {"MAINTAINER", "MAINTAINER isn't allowed as an ONBUILD trigger"}, - {"FROM", "FROM isn't allowed as an ONBUILD trigger"}} - - for _, trigger := range triggers { - b := newBuilderWithMockBackend() - - err := onbuild(defaultDispatchReq(b, trigger.command)) - testutil.ErrorContains(t, err, trigger.expectedError) - } + firstFrom := &instructions.Stage{BaseName: "someimg", Name: "base"} + secondFrom := &instructions.Stage{BaseName: "base"} + previousResults := newStagesBuildResults() + firstSB := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), previousResults) + secondSB := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), previousResults) + err := initializeStage(firstSB, firstFrom) + require.NoError(t, err) + assert.True(t, firstSB.state.hasFromImage()) + previousResults.indexed["base"] = firstSB.state.runConfig + previousResults.flat = append(previousResults.flat, firstSB.state.runConfig) + err = initializeStage(secondSB, secondFrom) + require.NoError(t, err) + assert.True(t, secondSB.state.hasFromImage()) } func TestOnbuild(t *testing.T) { b := newBuilderWithMockBackend() - - req := defaultDispatchReq(b, "ADD", ".", "/app/src") - req.original = "ONBUILD ADD . /app/src" - req.state.runConfig = &container.Config{} - - err := onbuild(req) + sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) + cmd := &instructions.OnbuildCommand{ + Expression: "ADD . /app/src", + } + err := dispatch(sb, cmd) require.NoError(t, err) - assert.Equal(t, "ADD . /app/src", req.state.runConfig.OnBuild[0]) + assert.Equal(t, "ADD . /app/src", sb.state.runConfig.OnBuild[0]) } func TestWorkdir(t *testing.T) { b := newBuilderWithMockBackend() + sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) workingDir := "/app" if runtime.GOOS == "windows" { - workingDir = "C:\app" + workingDir = "C:\\app" + } + cmd := &instructions.WorkdirCommand{ + Path: workingDir, } - req := defaultDispatchReq(b, workingDir) - err := workdir(req) + err := dispatch(sb, cmd) require.NoError(t, err) - assert.Equal(t, workingDir, req.state.runConfig.WorkingDir) + assert.Equal(t, workingDir, sb.state.runConfig.WorkingDir) } func TestCmd(t *testing.T) { b := newBuilderWithMockBackend() + sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) command := "./executable" - req := defaultDispatchReq(b, command) - err := cmd(req) + cmd := &instructions.CmdCommand{ + ShellDependantCmdLine: instructions.ShellDependantCmdLine{ + CmdLine: strslice.StrSlice{command}, + PrependShell: true, + }, + } + err := dispatch(sb, cmd) require.NoError(t, err) var expectedCommand strslice.StrSlice @@ -317,42 +244,56 @@ func TestCmd(t *testing.T) { expectedCommand = strslice.StrSlice(append([]string{"/bin/sh"}, "-c", command)) } - assert.Equal(t, expectedCommand, req.state.runConfig.Cmd) - assert.True(t, req.state.cmdSet) + assert.Equal(t, expectedCommand, sb.state.runConfig.Cmd) + assert.True(t, sb.state.cmdSet) } func TestHealthcheckNone(t *testing.T) { b := newBuilderWithMockBackend() - - req := defaultDispatchReq(b, "NONE") - err := healthcheck(req) + sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) + cmd := &instructions.HealthCheckCommand{ + Health: &container.HealthConfig{ + Test: []string{"NONE"}, + }, + } + err := dispatch(sb, cmd) require.NoError(t, err) - require.NotNil(t, req.state.runConfig.Healthcheck) - assert.Equal(t, []string{"NONE"}, req.state.runConfig.Healthcheck.Test) + require.NotNil(t, sb.state.runConfig.Healthcheck) + assert.Equal(t, []string{"NONE"}, sb.state.runConfig.Healthcheck.Test) } func TestHealthcheckCmd(t *testing.T) { - b := newBuilderWithMockBackend() - args := []string{"CMD", "curl", "-f", "http://localhost/", "||", "exit", "1"} - req := defaultDispatchReq(b, args...) - err := healthcheck(req) + b := newBuilderWithMockBackend() + sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) + expectedTest := []string{"CMD-SHELL", "curl -f http://localhost/ || exit 1"} + cmd := &instructions.HealthCheckCommand{ + Health: &container.HealthConfig{ + Test: expectedTest, + }, + } + err := dispatch(sb, cmd) require.NoError(t, err) - require.NotNil(t, req.state.runConfig.Healthcheck) - expectedTest := []string{"CMD-SHELL", "curl -f http://localhost/ || exit 1"} - assert.Equal(t, expectedTest, req.state.runConfig.Healthcheck.Test) + require.NotNil(t, sb.state.runConfig.Healthcheck) + assert.Equal(t, expectedTest, sb.state.runConfig.Healthcheck.Test) } func TestEntrypoint(t *testing.T) { b := newBuilderWithMockBackend() + sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) entrypointCmd := "/usr/sbin/nginx" - req := defaultDispatchReq(b, entrypointCmd) - err := entrypoint(req) + cmd := &instructions.EntrypointCommand{ + ShellDependantCmdLine: instructions.ShellDependantCmdLine{ + CmdLine: strslice.StrSlice{entrypointCmd}, + PrependShell: true, + }, + } + err := dispatch(sb, cmd) require.NoError(t, err) - require.NotNil(t, req.state.runConfig.Entrypoint) + require.NotNil(t, sb.state.runConfig.Entrypoint) var expectedEntrypoint strslice.StrSlice if runtime.GOOS == "windows" { @@ -360,99 +301,99 @@ func TestEntrypoint(t *testing.T) { } else { expectedEntrypoint = strslice.StrSlice(append([]string{"/bin/sh"}, "-c", entrypointCmd)) } - assert.Equal(t, expectedEntrypoint, req.state.runConfig.Entrypoint) + assert.Equal(t, expectedEntrypoint, sb.state.runConfig.Entrypoint) } func TestExpose(t *testing.T) { b := newBuilderWithMockBackend() + sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) exposedPort := "80" - req := defaultDispatchReq(b, exposedPort) - err := expose(req) + cmd := &instructions.ExposeCommand{ + Ports: []string{exposedPort}, + } + err := dispatch(sb, cmd) require.NoError(t, err) - require.NotNil(t, req.state.runConfig.ExposedPorts) - require.Len(t, req.state.runConfig.ExposedPorts, 1) + require.NotNil(t, sb.state.runConfig.ExposedPorts) + require.Len(t, sb.state.runConfig.ExposedPorts, 1) portsMapping, err := nat.ParsePortSpec(exposedPort) require.NoError(t, err) - assert.Contains(t, req.state.runConfig.ExposedPorts, portsMapping[0].Port) + assert.Contains(t, sb.state.runConfig.ExposedPorts, portsMapping[0].Port) } func TestUser(t *testing.T) { b := newBuilderWithMockBackend() - userCommand := "foo" + sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) - req := defaultDispatchReq(b, userCommand) - err := user(req) + cmd := &instructions.UserCommand{ + User: "test", + } + err := dispatch(sb, cmd) require.NoError(t, err) - assert.Equal(t, userCommand, req.state.runConfig.User) + assert.Equal(t, "test", sb.state.runConfig.User) } func TestVolume(t *testing.T) { b := newBuilderWithMockBackend() + sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) exposedVolume := "/foo" - req := defaultDispatchReq(b, exposedVolume) - err := volume(req) + cmd := &instructions.VolumeCommand{ + Volumes: []string{exposedVolume}, + } + err := dispatch(sb, cmd) require.NoError(t, err) - - require.NotNil(t, req.state.runConfig.Volumes) - assert.Len(t, req.state.runConfig.Volumes, 1) - assert.Contains(t, req.state.runConfig.Volumes, exposedVolume) + require.NotNil(t, sb.state.runConfig.Volumes) + assert.Len(t, sb.state.runConfig.Volumes, 1) + assert.Contains(t, sb.state.runConfig.Volumes, exposedVolume) } func TestStopSignal(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("Windows does not support stopsignal") + return + } b := newBuilderWithMockBackend() + sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) signal := "SIGKILL" - req := defaultDispatchReq(b, signal) - err := stopSignal(req) + cmd := &instructions.StopSignalCommand{ + Signal: signal, + } + err := dispatch(sb, cmd) require.NoError(t, err) - assert.Equal(t, signal, req.state.runConfig.StopSignal) + assert.Equal(t, signal, sb.state.runConfig.StopSignal) } func TestArg(t *testing.T) { b := newBuilderWithMockBackend() + sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) argName := "foo" argVal := "bar" - argDef := fmt.Sprintf("%s=%s", argName, argVal) - - err := arg(defaultDispatchReq(b, argDef)) + cmd := &instructions.ArgCommand{Key: argName, Value: &argVal} + err := dispatch(sb, cmd) require.NoError(t, err) expected := map[string]string{argName: argVal} - assert.Equal(t, expected, b.buildArgs.GetAllAllowed()) + assert.Equal(t, expected, sb.state.buildArgs.GetAllAllowed()) } func TestShell(t *testing.T) { b := newBuilderWithMockBackend() + sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) shellCmd := "powershell" - req := defaultDispatchReq(b, shellCmd) - req.attributes = map[string]bool{"json": true} + cmd := &instructions.ShellCommand{Shell: strslice.StrSlice{shellCmd}} - err := shell(req) + err := dispatch(sb, cmd) require.NoError(t, err) expectedShell := strslice.StrSlice([]string{shellCmd}) - assert.Equal(t, expectedShell, req.state.runConfig.Shell) -} - -func TestParseOptInterval(t *testing.T) { - flInterval := &Flag{ - name: "interval", - flagType: stringType, - Value: "50ns", - } - _, err := parseOptInterval(flInterval) - testutil.ErrorContains(t, err, "cannot be less than 1ms") - - flInterval.Value = "1ms" - _, err = parseOptInterval(flInterval) - require.NoError(t, err) + assert.Equal(t, expectedShell, sb.state.runConfig.Shell) } func TestPrependEnvOnCmd(t *testing.T) { @@ -469,8 +410,10 @@ func TestPrependEnvOnCmd(t *testing.T) { func TestRunWithBuildArgs(t *testing.T) { b := newBuilderWithMockBackend() - b.buildArgs.argsFromOptions["HTTP_PROXY"] = strPtr("FOO") + args := newBuildArgs(make(map[string]*string)) + args.argsFromOptions["HTTP_PROXY"] = strPtr("FOO") b.disableCommit = false + sb := newDispatchRequest(b, '`', nil, args, newStagesBuildResults()) runConfig := &container.Config{} origCmd := strslice.StrSlice([]string{"cmd", "in", "from", "image"}) @@ -512,14 +455,18 @@ func TestRunWithBuildArgs(t *testing.T) { assert.Equal(t, strslice.StrSlice(nil), cfg.Config.Entrypoint) return "", nil } - - req := defaultDispatchReq(b, "abcdef") - require.NoError(t, from(req)) - b.buildArgs.AddArg("one", strPtr("two")) - - req.args = []string{"echo foo"} - require.NoError(t, run(req)) + from := &instructions.Stage{BaseName: "abcdef"} + err := initializeStage(sb, from) + require.NoError(t, err) + sb.state.buildArgs.AddArg("one", strPtr("two")) + run := &instructions.RunCommand{ + ShellDependantCmdLine: instructions.ShellDependantCmdLine{ + CmdLine: strslice.StrSlice{"echo foo"}, + PrependShell: true, + }, + } + require.NoError(t, dispatch(sb, run)) // Check that runConfig.Cmd has not been modified by run - assert.Equal(t, origCmd, req.state.runConfig.Cmd) + assert.Equal(t, origCmd, sb.state.runConfig.Cmd) } diff --git a/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_unix.go b/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_unix.go index 62ee371df..6f0d581b9 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_unix.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_unix.go @@ -4,16 +4,15 @@ package dockerfile import ( "errors" - "fmt" "os" "path/filepath" ) -// normaliseWorkdir normalises a user requested working directory in a +// normalizeWorkdir normalizes a user requested working directory in a // platform semantically consistent way. -func normaliseWorkdir(current string, requested string) (string, error) { +func normalizeWorkdir(_ string, current string, requested string) (string, error) { if requested == "" { - return "", errors.New("cannot normalise nothing") + return "", errors.New("cannot normalize nothing") } current = filepath.FromSlash(current) requested = filepath.FromSlash(requested) @@ -23,10 +22,6 @@ func normaliseWorkdir(current string, requested string) (string, error) { return requested, nil } -func errNotJSON(command, _ string) error { - return fmt.Errorf("%s requires the arguments to be in JSON form", command) -} - // equalEnvKeys compare two strings and returns true if they are equal. On // Windows this comparison is case insensitive. func equalEnvKeys(from, to string) bool { diff --git a/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_unix_test.go b/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_unix_test.go index 4aae6b460..053a38faa 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_unix_test.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_unix_test.go @@ -3,12 +3,13 @@ package dockerfile import ( + "runtime" "testing" ) -func TestNormaliseWorkdir(t *testing.T) { +func TestNormalizeWorkdir(t *testing.T) { testCases := []struct{ current, requested, expected, expectedError string }{ - {``, ``, ``, `cannot normalise nothing`}, + {``, ``, ``, `cannot normalize nothing`}, {``, `foo`, `/foo`, ``}, {``, `/foo`, `/foo`, ``}, {`/foo`, `bar`, `/foo/bar`, ``}, @@ -16,18 +17,18 @@ func TestNormaliseWorkdir(t *testing.T) { } for _, test := range testCases { - normalised, err := normaliseWorkdir(test.current, test.requested) + normalized, err := normalizeWorkdir(runtime.GOOS, test.current, test.requested) if test.expectedError != "" && err == nil { - t.Fatalf("NormaliseWorkdir should return an error %s, got nil", test.expectedError) + t.Fatalf("NormalizeWorkdir should return an error %s, got nil", test.expectedError) } if test.expectedError != "" && err.Error() != test.expectedError { - t.Fatalf("NormaliseWorkdir returned wrong error. Expected %s, got %s", test.expectedError, err.Error()) + t.Fatalf("NormalizeWorkdir returned wrong error. Expected %s, got %s", test.expectedError, err.Error()) } - if normalised != test.expected { - t.Fatalf("NormaliseWorkdir error. Expected %s for current %s and requested %s, got %s", test.expected, test.current, test.requested, normalised) + if normalized != test.expected { + t.Fatalf("NormalizeWorkdir error. Expected %s for current %s and requested %s, got %s", test.expected, test.current, test.requested, normalized) } } } diff --git a/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_windows.go b/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_windows.go index 71f7c9288..8f6eaac18 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_windows.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_windows.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "os" + "path" "path/filepath" "regexp" "strings" @@ -13,11 +14,37 @@ import ( var pattern = regexp.MustCompile(`^[a-zA-Z]:\.$`) -// normaliseWorkdir normalises a user requested working directory in a +// normalizeWorkdir normalizes a user requested working directory in a // platform semantically consistent way. -func normaliseWorkdir(current string, requested string) (string, error) { +func normalizeWorkdir(platform string, current string, requested string) (string, error) { + if platform == "" { + platform = "windows" + } + if platform == "windows" { + return normalizeWorkdirWindows(current, requested) + } + return normalizeWorkdirUnix(current, requested) +} + +// normalizeWorkdirUnix normalizes a user requested working directory in a +// platform semantically consistent way. +func normalizeWorkdirUnix(current string, requested string) (string, error) { + if requested == "" { + return "", errors.New("cannot normalize nothing") + } + current = strings.Replace(current, string(os.PathSeparator), "/", -1) + requested = strings.Replace(requested, string(os.PathSeparator), "/", -1) + if !path.IsAbs(requested) { + return path.Join(`/`, current, requested), nil + } + return requested, nil +} + +// normalizeWorkdirWindows normalizes a user requested working directory in a +// platform semantically consistent way. +func normalizeWorkdirWindows(current string, requested string) (string, error) { if requested == "" { - return "", errors.New("cannot normalise nothing") + return "", errors.New("cannot normalize nothing") } // `filepath.Clean` will replace "" with "." so skip in that case @@ -67,25 +94,6 @@ func normaliseWorkdir(current string, requested string) (string, error) { return (strings.ToUpper(string(requested[0])) + requested[1:]), nil } -func errNotJSON(command, original string) error { - // For Windows users, give a hint if it looks like it might contain - // a path which hasn't been escaped such as ["c:\windows\system32\prog.exe", "-param"], - // as JSON must be escaped. Unfortunate... - // - // Specifically looking for quote-driveletter-colon-backslash, there's no - // double backslash and a [] pair. No, this is not perfect, but it doesn't - // have to be. It's simply a hint to make life a little easier. - extra := "" - original = filepath.FromSlash(strings.ToLower(strings.Replace(strings.ToLower(original), strings.ToLower(command)+" ", "", -1))) - if len(regexp.MustCompile(`"[a-z]:\\.*`).FindStringSubmatch(original)) > 0 && - !strings.Contains(original, `\\`) && - strings.Contains(original, "[") && - strings.Contains(original, "]") { - extra = fmt.Sprintf(`. It looks like '%s' includes a file path without an escaped back-slash. JSON requires back-slashes to be escaped such as ["c:\\path\\to\\file.exe", "/parameter"]`, original) - } - return fmt.Errorf("%s requires the arguments to be in JSON form%s", command, extra) -} - // equalEnvKeys compare two strings and returns true if they are equal. On // Windows this comparison is case insensitive. func equalEnvKeys(from, to string) bool { diff --git a/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_windows_test.go b/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_windows_test.go index 3319c0658..cb0b5446f 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_windows_test.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/dispatchers_windows_test.go @@ -4,37 +4,43 @@ package dockerfile import "testing" -func TestNormaliseWorkdir(t *testing.T) { - tests := []struct{ current, requested, expected, etext string }{ - {``, ``, ``, `cannot normalise nothing`}, - {``, `C:`, ``, `C:. is not a directory. If you are specifying a drive letter, please add a trailing '\'`}, - {``, `C:.`, ``, `C:. is not a directory. If you are specifying a drive letter, please add a trailing '\'`}, - {`c:`, `\a`, ``, `c:. is not a directory. If you are specifying a drive letter, please add a trailing '\'`}, - {`c:.`, `\a`, ``, `c:. is not a directory. If you are specifying a drive letter, please add a trailing '\'`}, - {``, `a`, `C:\a`, ``}, - {``, `c:\foo`, `C:\foo`, ``}, - {``, `c:\\foo`, `C:\foo`, ``}, - {``, `\foo`, `C:\foo`, ``}, - {``, `\\foo`, `C:\foo`, ``}, - {``, `/foo`, `C:\foo`, ``}, - {``, `C:/foo`, `C:\foo`, ``}, - {`C:\foo`, `bar`, `C:\foo\bar`, ``}, - {`C:\foo`, `/bar`, `C:\bar`, ``}, - {`C:\foo`, `\bar`, `C:\bar`, ``}, +func TestNormalizeWorkdir(t *testing.T) { + tests := []struct{ platform, current, requested, expected, etext string }{ + {"windows", ``, ``, ``, `cannot normalize nothing`}, + {"windows", ``, `C:`, ``, `C:. is not a directory. If you are specifying a drive letter, please add a trailing '\'`}, + {"windows", ``, `C:.`, ``, `C:. is not a directory. If you are specifying a drive letter, please add a trailing '\'`}, + {"windows", `c:`, `\a`, ``, `c:. is not a directory. If you are specifying a drive letter, please add a trailing '\'`}, + {"windows", `c:.`, `\a`, ``, `c:. is not a directory. If you are specifying a drive letter, please add a trailing '\'`}, + {"windows", ``, `a`, `C:\a`, ``}, + {"windows", ``, `c:\foo`, `C:\foo`, ``}, + {"windows", ``, `c:\\foo`, `C:\foo`, ``}, + {"windows", ``, `\foo`, `C:\foo`, ``}, + {"windows", ``, `\\foo`, `C:\foo`, ``}, + {"windows", ``, `/foo`, `C:\foo`, ``}, + {"windows", ``, `C:/foo`, `C:\foo`, ``}, + {"windows", `C:\foo`, `bar`, `C:\foo\bar`, ``}, + {"windows", `C:\foo`, `/bar`, `C:\bar`, ``}, + {"windows", `C:\foo`, `\bar`, `C:\bar`, ``}, + {"linux", ``, ``, ``, `cannot normalize nothing`}, + {"linux", ``, `foo`, `/foo`, ``}, + {"linux", ``, `/foo`, `/foo`, ``}, + {"linux", `/foo`, `bar`, `/foo/bar`, ``}, + {"linux", `/foo`, `/bar`, `/bar`, ``}, + {"linux", `\a`, `b\c`, `/a/b/c`, ``}, } for _, i := range tests { - r, e := normaliseWorkdir(i.current, i.requested) + r, e := normalizeWorkdir(i.platform, i.current, i.requested) if i.etext != "" && e == nil { - t.Fatalf("TestNormaliseWorkingDir Expected error %s for '%s' '%s', got no error", i.etext, i.current, i.requested) + t.Fatalf("TestNormalizeWorkingDir Expected error %s for '%s' '%s', got no error", i.etext, i.current, i.requested) } if i.etext != "" && e.Error() != i.etext { - t.Fatalf("TestNormaliseWorkingDir Expected error %s for '%s' '%s', got %s", i.etext, i.current, i.requested, e.Error()) + t.Fatalf("TestNormalizeWorkingDir Expected error %s for '%s' '%s', got %s", i.etext, i.current, i.requested, e.Error()) } if r != i.expected { - t.Fatalf("TestNormaliseWorkingDir Expected '%s' for '%s' '%s', got '%s'", i.expected, i.current, i.requested, r) + t.Fatalf("TestNormalizeWorkingDir Expected '%s' for '%s' '%s', got '%s'", i.expected, i.current, i.requested, r) } } } diff --git a/vendor/github.com/docker/docker/builder/dockerfile/errors.go b/vendor/github.com/docker/docker/builder/dockerfile/errors.go new file mode 100644 index 000000000..25664dee7 --- /dev/null +++ b/vendor/github.com/docker/docker/builder/dockerfile/errors.go @@ -0,0 +1,15 @@ +package dockerfile + +type validationError struct { + err error +} + +func (e validationError) Error() string { + return e.err.Error() +} + +func (e validationError) InvalidParameter() {} + +func (e validationError) Cause() error { + return e.err +} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/evaluator.go b/vendor/github.com/docker/docker/builder/dockerfile/evaluator.go index ba4315940..cd4f513fa 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/evaluator.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/evaluator.go @@ -20,183 +20,178 @@ package dockerfile import ( - "bytes" - "fmt" + "reflect" "runtime" + "strconv" "strings" "github.com/docker/docker/api/types/container" "github.com/docker/docker/builder" - "github.com/docker/docker/builder/dockerfile/command" - "github.com/docker/docker/builder/dockerfile/parser" + "github.com/docker/docker/builder/dockerfile/instructions" "github.com/docker/docker/pkg/system" "github.com/docker/docker/runconfig/opts" "github.com/pkg/errors" ) -// Environment variable interpolation will happen on these statements only. -var replaceEnvAllowed = map[string]bool{ - command.Env: true, - command.Label: true, - command.Add: true, - command.Copy: true, - command.Workdir: true, - command.Expose: true, - command.Volume: true, - command.User: true, - command.StopSignal: true, - command.Arg: true, -} +func dispatch(d dispatchRequest, cmd instructions.Command) error { + if c, ok := cmd.(instructions.PlatformSpecific); ok { + err := c.CheckPlatform(d.builder.platform) + if err != nil { + return validationError{err} + } + } + runConfigEnv := d.state.runConfig.Env + envs := append(runConfigEnv, d.state.buildArgs.FilterAllowed(runConfigEnv)...) -// Certain commands are allowed to have their args split into more -// words after env var replacements. Meaning: -// ENV foo="123 456" -// EXPOSE $foo -// should result in the same thing as: -// EXPOSE 123 456 -// and not treat "123 456" as a single word. -// Note that: EXPOSE "$foo" and EXPOSE $foo are not the same thing. -// Quotes will cause it to still be treated as single word. -var allowWordExpansion = map[string]bool{ - command.Expose: true, -} + if ex, ok := cmd.(instructions.SupportsSingleWordExpansion); ok { + err := ex.Expand(func(word string) (string, error) { + return d.shlex.ProcessWord(word, envs) + }) + if err != nil { + return validationError{err} + } + } -type dispatchRequest struct { - builder *Builder // TODO: replace this with a smaller interface - args []string - attributes map[string]bool - flags *BFlags - original string - shlex *ShellLex - state *dispatchState - source builder.Source + if d.builder.options.ForceRemove { + defer d.builder.containerManager.RemoveAll(d.builder.Stdout) + } + + switch c := cmd.(type) { + case *instructions.EnvCommand: + return dispatchEnv(d, c) + case *instructions.MaintainerCommand: + return dispatchMaintainer(d, c) + case *instructions.LabelCommand: + return dispatchLabel(d, c) + case *instructions.AddCommand: + return dispatchAdd(d, c) + case *instructions.CopyCommand: + return dispatchCopy(d, c) + case *instructions.OnbuildCommand: + return dispatchOnbuild(d, c) + case *instructions.WorkdirCommand: + return dispatchWorkdir(d, c) + case *instructions.RunCommand: + return dispatchRun(d, c) + case *instructions.CmdCommand: + return dispatchCmd(d, c) + case *instructions.HealthCheckCommand: + return dispatchHealthcheck(d, c) + case *instructions.EntrypointCommand: + return dispatchEntrypoint(d, c) + case *instructions.ExposeCommand: + return dispatchExpose(d, c, envs) + case *instructions.UserCommand: + return dispatchUser(d, c) + case *instructions.VolumeCommand: + return dispatchVolume(d, c) + case *instructions.StopSignalCommand: + return dispatchStopSignal(d, c) + case *instructions.ArgCommand: + return dispatchArg(d, c) + case *instructions.ShellCommand: + return dispatchShell(d, c) + } + return errors.Errorf("unsupported command type: %v", reflect.TypeOf(cmd)) } -func newDispatchRequestFromOptions(options dispatchOptions, builder *Builder, args []string) dispatchRequest { - return dispatchRequest{ - builder: builder, - args: args, - attributes: options.node.Attributes, - original: options.node.Original, - flags: NewBFlagsWithArgs(options.node.Flags), - shlex: options.shlex, - state: options.state, - source: options.source, - } +// dispatchState is a data object which is modified by dispatchers +type dispatchState struct { + runConfig *container.Config + maintainer string + cmdSet bool + imageID string + baseImage builder.Image + stageName string + buildArgs *buildArgs } -type dispatcher func(dispatchRequest) error +func newDispatchState(baseArgs *buildArgs) *dispatchState { + args := baseArgs.Clone() + args.ResetAllowed() + return &dispatchState{runConfig: &container.Config{}, buildArgs: args} +} -var evaluateTable map[string]dispatcher +type stagesBuildResults struct { + flat []*container.Config + indexed map[string]*container.Config +} -func init() { - evaluateTable = map[string]dispatcher{ - command.Add: add, - command.Arg: arg, - command.Cmd: cmd, - command.Copy: dispatchCopy, // copy() is a go builtin - command.Entrypoint: entrypoint, - command.Env: env, - command.Expose: expose, - command.From: from, - command.Healthcheck: healthcheck, - command.Label: label, - command.Maintainer: maintainer, - command.Onbuild: onbuild, - command.Run: run, - command.Shell: shell, - command.StopSignal: stopSignal, - command.User: user, - command.Volume: volume, - command.Workdir: workdir, +func newStagesBuildResults() *stagesBuildResults { + return &stagesBuildResults{ + indexed: make(map[string]*container.Config), } } -func formatStep(stepN int, stepTotal int) string { - return fmt.Sprintf("%d/%d", stepN+1, stepTotal) +func (r *stagesBuildResults) getByName(name string) (*container.Config, bool) { + c, ok := r.indexed[strings.ToLower(name)] + return c, ok } -// This method is the entrypoint to all statement handling routines. -// -// Almost all nodes will have this structure: -// Child[Node, Node, Node] where Child is from parser.Node.Children and each -// node comes from parser.Node.Next. This forms a "line" with a statement and -// arguments and we process them in this normalized form by hitting -// evaluateTable with the leaf nodes of the command and the Builder object. -// -// ONBUILD is a special case; in this case the parser will emit: -// Child[Node, Child[Node, Node...]] where the first node is the literal -// "onbuild" and the child entrypoint is the command of the ONBUILD statement, -// such as `RUN` in ONBUILD RUN foo. There is special case logic in here to -// deal with that, at least until it becomes more of a general concern with new -// features. -func (b *Builder) dispatch(options dispatchOptions) (*dispatchState, error) { - node := options.node - cmd := node.Value - upperCasedCmd := strings.ToUpper(cmd) - - // To ensure the user is given a decent error message if the platform - // on which the daemon is running does not support a builder command. - if err := platformSupports(strings.ToLower(cmd)); err != nil { - buildsFailed.WithValues(metricsCommandNotSupportedError).Inc() - return nil, err +func (r *stagesBuildResults) validateIndex(i int) error { + if i == len(r.flat) { + return errors.New("refers to current build stage") } - - msg := bytes.NewBufferString(fmt.Sprintf("Step %s : %s%s", - options.stepMsg, upperCasedCmd, formatFlags(node.Flags))) - - args := []string{} - ast := node - if cmd == command.Onbuild { - var err error - ast, args, err = handleOnBuildNode(node, msg) - if err != nil { - return nil, err - } + if i < 0 || i > len(r.flat) { + return errors.New("index out of bounds") } + return nil +} - runConfigEnv := options.state.runConfig.Env - envs := append(runConfigEnv, b.buildArgs.FilterAllowed(runConfigEnv)...) - processFunc := createProcessWordFunc(options.shlex, cmd, envs) - words, err := getDispatchArgsFromNode(ast, processFunc, msg) +func (r *stagesBuildResults) get(nameOrIndex string) (*container.Config, error) { + if c, ok := r.getByName(nameOrIndex); ok { + return c, nil + } + ix, err := strconv.ParseInt(nameOrIndex, 10, 0) if err != nil { - buildsFailed.WithValues(metricsErrorProcessingCommandsError).Inc() + return nil, nil + } + if err := r.validateIndex(int(ix)); err != nil { return nil, err } - args = append(args, words...) + return r.flat[ix], nil +} - fmt.Fprintln(b.Stdout, msg.String()) +func (r *stagesBuildResults) checkStageNameAvailable(name string) error { + if name != "" { + if _, ok := r.getByName(name); ok { + return errors.Errorf("%s stage name already used", name) + } + } + return nil +} - f, ok := evaluateTable[cmd] - if !ok { - buildsFailed.WithValues(metricsUnknownInstructionError).Inc() - return nil, fmt.Errorf("unknown instruction: %s", upperCasedCmd) +func (r *stagesBuildResults) commitStage(name string, config *container.Config) error { + if name != "" { + if _, ok := r.getByName(name); ok { + return errors.Errorf("%s stage name already used", name) + } + r.indexed[strings.ToLower(name)] = config } - options.state.updateRunConfig() - err = f(newDispatchRequestFromOptions(options, b, args)) - return options.state, err + r.flat = append(r.flat, config) + return nil } -type dispatchOptions struct { +func commitStage(state *dispatchState, stages *stagesBuildResults) error { + return stages.commitStage(state.stageName, state.runConfig) +} + +type dispatchRequest struct { state *dispatchState - stepMsg string - node *parser.Node shlex *ShellLex + builder *Builder source builder.Source + stages *stagesBuildResults } -// dispatchState is a data object which is modified by dispatchers -type dispatchState struct { - runConfig *container.Config - maintainer string - cmdSet bool - imageID string - baseImage builder.Image - stageName string -} - -func newDispatchState() *dispatchState { - return &dispatchState{runConfig: &container.Config{}} +func newDispatchRequest(builder *Builder, escapeToken rune, source builder.Source, buildArgs *buildArgs, stages *stagesBuildResults) dispatchRequest { + return dispatchRequest{ + state: newDispatchState(buildArgs), + shlex: NewShellLex(escapeToken), + builder: builder, + source: source, + stages: stages, + } } func (s *dispatchState) updateRunConfig() { @@ -220,12 +215,14 @@ func (s *dispatchState) beginStage(stageName string, image builder.Image) { s.imageID = image.ImageID() if image.RunConfig() != nil { - s.runConfig = image.RunConfig() + s.runConfig = copyRunConfig(image.RunConfig()) // copy avoids referencing the same instance when 2 stages have the same base } else { s.runConfig = &container.Config{} } s.baseImage = image s.setDefaultPath() + s.runConfig.OpenStdin = false + s.runConfig.StdinOnce = false } // Add the default PATH to runConfig.ENV if one exists for the platform and there @@ -244,84 +241,3 @@ func (s *dispatchState) setDefaultPath() { s.runConfig.Env = append(s.runConfig.Env, "PATH="+system.DefaultPathEnv(platform)) } } - -func handleOnBuildNode(ast *parser.Node, msg *bytes.Buffer) (*parser.Node, []string, error) { - if ast.Next == nil { - return nil, nil, errors.New("ONBUILD requires at least one argument") - } - ast = ast.Next.Children[0] - msg.WriteString(" " + ast.Value + formatFlags(ast.Flags)) - return ast, []string{ast.Value}, nil -} - -func formatFlags(flags []string) string { - if len(flags) > 0 { - return " " + strings.Join(flags, " ") - } - return "" -} - -func getDispatchArgsFromNode(ast *parser.Node, processFunc processWordFunc, msg *bytes.Buffer) ([]string, error) { - args := []string{} - for i := 0; ast.Next != nil; i++ { - ast = ast.Next - words, err := processFunc(ast.Value) - if err != nil { - return nil, err - } - args = append(args, words...) - msg.WriteString(" " + ast.Value) - } - return args, nil -} - -type processWordFunc func(string) ([]string, error) - -func createProcessWordFunc(shlex *ShellLex, cmd string, envs []string) processWordFunc { - switch { - case !replaceEnvAllowed[cmd]: - return func(word string) ([]string, error) { - return []string{word}, nil - } - case allowWordExpansion[cmd]: - return func(word string) ([]string, error) { - return shlex.ProcessWords(word, envs) - } - default: - return func(word string) ([]string, error) { - word, err := shlex.ProcessWord(word, envs) - return []string{word}, err - } - } -} - -// checkDispatch does a simple check for syntax errors of the Dockerfile. -// Because some of the instructions can only be validated through runtime, -// arg, env, etc., this syntax check will not be complete and could not replace -// the runtime check. Instead, this function is only a helper that allows -// user to find out the obvious error in Dockerfile earlier on. -func checkDispatch(ast *parser.Node) error { - cmd := ast.Value - upperCasedCmd := strings.ToUpper(cmd) - - // To ensure the user is given a decent error message if the platform - // on which the daemon is running does not support a builder command. - if err := platformSupports(strings.ToLower(cmd)); err != nil { - return err - } - - // The instruction itself is ONBUILD, we will make sure it follows with at - // least one argument - if upperCasedCmd == "ONBUILD" { - if ast.Next == nil { - buildsFailed.WithValues(metricsMissingOnbuildArgumentsError).Inc() - return errors.New("ONBUILD requires at least one argument") - } - } - - if _, ok := evaluateTable[cmd]; ok { - return nil - } - buildsFailed.WithValues(metricsUnknownInstructionError).Inc() - return errors.Errorf("unknown instruction: %s", upperCasedCmd) -} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/evaluator_test.go b/vendor/github.com/docker/docker/builder/dockerfile/evaluator_test.go index 72d7ce10e..fc5512d0a 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/evaluator_test.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/evaluator_test.go @@ -1,21 +1,19 @@ package dockerfile import ( - "io/ioutil" - "strings" "testing" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/builder/dockerfile/parser" + "github.com/docker/docker/builder/dockerfile/instructions" "github.com/docker/docker/builder/remotecontext" + "github.com/docker/docker/internal/testutil" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/reexec" ) type dispatchTestCase struct { - name, dockerfile, expectedError string - files map[string]string + name, expectedError string + cmd instructions.Command + files map[string]string } func init() { @@ -23,108 +21,73 @@ func init() { } func initDispatchTestCases() []dispatchTestCase { - dispatchTestCases := []dispatchTestCase{{ - name: "copyEmptyWhitespace", - dockerfile: `COPY - quux \ - bar`, - expectedError: "COPY requires at least two arguments", - }, - { - name: "ONBUILD forbidden FROM", - dockerfile: "ONBUILD FROM scratch", - expectedError: "FROM isn't allowed as an ONBUILD trigger", - files: nil, - }, - { - name: "ONBUILD forbidden MAINTAINER", - dockerfile: "ONBUILD MAINTAINER docker.io", - expectedError: "MAINTAINER isn't allowed as an ONBUILD trigger", - files: nil, - }, - { - name: "ARG two arguments", - dockerfile: "ARG foo bar", - expectedError: "ARG requires exactly one argument", - files: nil, - }, - { - name: "MAINTAINER unknown flag", - dockerfile: "MAINTAINER --boo joe@example.com", - expectedError: "Unknown flag: boo", - files: nil, - }, - { - name: "ADD multiple files to file", - dockerfile: "ADD file1.txt file2.txt test", - expectedError: "When using ADD with more than one source file, the destination must be a directory and end with a /", - files: map[string]string{"file1.txt": "test1", "file2.txt": "test2"}, - }, - { - name: "JSON ADD multiple files to file", - dockerfile: `ADD ["file1.txt", "file2.txt", "test"]`, + dispatchTestCases := []dispatchTestCase{ + { + name: "ADD multiple files to file", + cmd: &instructions.AddCommand{SourcesAndDest: instructions.SourcesAndDest{ + "file1.txt", + "file2.txt", + "test", + }}, expectedError: "When using ADD with more than one source file, the destination must be a directory and end with a /", files: map[string]string{"file1.txt": "test1", "file2.txt": "test2"}, }, { - name: "Wildcard ADD multiple files to file", - dockerfile: "ADD file*.txt test", + name: "Wildcard ADD multiple files to file", + cmd: &instructions.AddCommand{SourcesAndDest: instructions.SourcesAndDest{ + "file*.txt", + "test", + }}, expectedError: "When using ADD with more than one source file, the destination must be a directory and end with a /", files: map[string]string{"file1.txt": "test1", "file2.txt": "test2"}, }, { - name: "Wildcard JSON ADD multiple files to file", - dockerfile: `ADD ["file*.txt", "test"]`, - expectedError: "When using ADD with more than one source file, the destination must be a directory and end with a /", - files: map[string]string{"file1.txt": "test1", "file2.txt": "test2"}, - }, - { - name: "COPY multiple files to file", - dockerfile: "COPY file1.txt file2.txt test", + name: "COPY multiple files to file", + cmd: &instructions.CopyCommand{SourcesAndDest: instructions.SourcesAndDest{ + "file1.txt", + "file2.txt", + "test", + }}, expectedError: "When using COPY with more than one source file, the destination must be a directory and end with a /", files: map[string]string{"file1.txt": "test1", "file2.txt": "test2"}, }, { - name: "JSON COPY multiple files to file", - dockerfile: `COPY ["file1.txt", "file2.txt", "test"]`, - expectedError: "When using COPY with more than one source file, the destination must be a directory and end with a /", - files: map[string]string{"file1.txt": "test1", "file2.txt": "test2"}, - }, - { - name: "ADD multiple files to file with whitespace", - dockerfile: `ADD [ "test file1.txt", "test file2.txt", "test" ]`, + name: "ADD multiple files to file with whitespace", + cmd: &instructions.AddCommand{SourcesAndDest: instructions.SourcesAndDest{ + "test file1.txt", + "test file2.txt", + "test", + }}, expectedError: "When using ADD with more than one source file, the destination must be a directory and end with a /", files: map[string]string{"test file1.txt": "test1", "test file2.txt": "test2"}, }, { - name: "COPY multiple files to file with whitespace", - dockerfile: `COPY [ "test file1.txt", "test file2.txt", "test" ]`, + name: "COPY multiple files to file with whitespace", + cmd: &instructions.CopyCommand{SourcesAndDest: instructions.SourcesAndDest{ + "test file1.txt", + "test file2.txt", + "test", + }}, expectedError: "When using COPY with more than one source file, the destination must be a directory and end with a /", files: map[string]string{"test file1.txt": "test1", "test file2.txt": "test2"}, }, { - name: "COPY wildcard no files", - dockerfile: `COPY file*.txt /tmp/`, + name: "COPY wildcard no files", + cmd: &instructions.CopyCommand{SourcesAndDest: instructions.SourcesAndDest{ + "file*.txt", + "/tmp/", + }}, expectedError: "COPY failed: no source files were specified", files: nil, }, { - name: "COPY url", - dockerfile: `COPY https://index.docker.io/robots.txt /`, + name: "COPY url", + cmd: &instructions.CopyCommand{SourcesAndDest: instructions.SourcesAndDest{ + "https://index.docker.io/robots.txt", + "/", + }}, expectedError: "source can't be a URL for COPY", files: nil, - }, - { - name: "Chaining ONBUILD", - dockerfile: `ONBUILD ONBUILD RUN touch foobar`, - expectedError: "Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed", - files: nil, - }, - { - name: "Invalid instruction", - dockerfile: `foo bar`, - expectedError: "unknown instruction: FOO", - files: nil, }} return dispatchTestCases @@ -170,41 +133,8 @@ func executeTestCase(t *testing.T, testCase dispatchTestCase) { } }() - r := strings.NewReader(testCase.dockerfile) - result, err := parser.Parse(r) - - if err != nil { - t.Fatalf("Error when parsing Dockerfile: %s", err) - } - - options := &types.ImageBuildOptions{ - BuildArgs: make(map[string]*string), - } - - b := &Builder{ - options: options, - Stdout: ioutil.Discard, - buildArgs: newBuildArgs(options.BuildArgs), - } - - shlex := NewShellLex(parser.DefaultEscapeToken) - n := result.AST - state := &dispatchState{runConfig: &container.Config{}} - opts := dispatchOptions{ - state: state, - stepMsg: formatStep(0, len(n.Children)), - node: n.Children[0], - shlex: shlex, - source: context, - } - state, err = b.dispatch(opts) - - if err == nil { - t.Fatalf("No error when executing test %s", testCase.name) - } - - if !strings.Contains(err.Error(), testCase.expectedError) { - t.Fatalf("Wrong error message. Should be \"%s\". Got \"%s\"", testCase.expectedError, err.Error()) - } - + b := newBuilderWithMockBackend() + sb := newDispatchRequest(b, '`', context, newBuildArgs(make(map[string]*string)), newStagesBuildResults()) + err = dispatch(sb, testCase.cmd) + testutil.ErrorContains(t, err, testCase.expectedError) } diff --git a/vendor/github.com/docker/docker/builder/dockerfile/evaluator_unix.go b/vendor/github.com/docker/docker/builder/dockerfile/evaluator_unix.go deleted file mode 100644 index 28fd5b156..000000000 --- a/vendor/github.com/docker/docker/builder/dockerfile/evaluator_unix.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build !windows - -package dockerfile - -// platformSupports is a short-term function to give users a quality error -// message if a Dockerfile uses a command not supported on the platform. -func platformSupports(command string) error { - return nil -} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/evaluator_windows.go b/vendor/github.com/docker/docker/builder/dockerfile/evaluator_windows.go deleted file mode 100644 index 72483a2ec..000000000 --- a/vendor/github.com/docker/docker/builder/dockerfile/evaluator_windows.go +++ /dev/null @@ -1,13 +0,0 @@ -package dockerfile - -import "fmt" - -// platformSupports is gives users a quality error message if a Dockerfile uses -// a command not supported on the platform. -func platformSupports(command string) error { - switch command { - case "stopsignal": - return fmt.Errorf("The daemon on this platform does not support the command '%s'", command) - } - return nil -} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/imagecontext.go b/vendor/github.com/docker/docker/builder/dockerfile/imagecontext.go index fedad6fdf..084255d17 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/imagecontext.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/imagecontext.go @@ -1,9 +1,6 @@ package dockerfile import ( - "strconv" - "strings" - "github.com/docker/docker/api/types/backend" "github.com/docker/docker/builder" "github.com/docker/docker/builder/remotecontext" @@ -13,79 +10,6 @@ import ( "golang.org/x/net/context" ) -type buildStage struct { - id string -} - -func newBuildStage(imageID string) *buildStage { - return &buildStage{id: imageID} -} - -func (b *buildStage) ImageID() string { - return b.id -} - -func (b *buildStage) update(imageID string) { - b.id = imageID -} - -// buildStages tracks each stage of a build so they can be retrieved by index -// or by name. -type buildStages struct { - sequence []*buildStage - byName map[string]*buildStage -} - -func newBuildStages() *buildStages { - return &buildStages{byName: make(map[string]*buildStage)} -} - -func (s *buildStages) getByName(name string) (*buildStage, bool) { - stage, ok := s.byName[strings.ToLower(name)] - return stage, ok -} - -func (s *buildStages) get(indexOrName string) (*buildStage, error) { - index, err := strconv.Atoi(indexOrName) - if err == nil { - if err := s.validateIndex(index); err != nil { - return nil, err - } - return s.sequence[index], nil - } - if im, ok := s.byName[strings.ToLower(indexOrName)]; ok { - return im, nil - } - return nil, nil -} - -func (s *buildStages) validateIndex(i int) error { - if i < 0 || i >= len(s.sequence)-1 { - if i == len(s.sequence)-1 { - return errors.New("refers to current build stage") - } - return errors.New("index out of bounds") - } - return nil -} - -func (s *buildStages) add(name string, image builder.Image) error { - stage := newBuildStage(image.ImageID()) - name = strings.ToLower(name) - if len(name) > 0 { - if _, ok := s.byName[name]; ok { - return errors.Errorf("duplicate name %s", name) - } - s.byName[name] = stage - } - s.sequence = append(s.sequence, stage) - return nil -} - -func (s *buildStages) update(imageID string) { - s.sequence[len(s.sequence)-1].update(imageID) -} - type getAndMountFunc func(string, bool) (builder.Image, builder.ReleaseableLayer, error) // imageSources mounts images and provides a cache for mounted images. It tracks diff --git a/vendor/github.com/docker/docker/builder/dockerfile/bflag.go b/vendor/github.com/docker/docker/builder/dockerfile/instructions/bflag.go similarity index 99% rename from vendor/github.com/docker/docker/builder/dockerfile/bflag.go rename to vendor/github.com/docker/docker/builder/dockerfile/instructions/bflag.go index d84966162..7a81e3c13 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/bflag.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/instructions/bflag.go @@ -1,4 +1,4 @@ -package dockerfile +package instructions import ( "fmt" diff --git a/vendor/github.com/docker/docker/builder/dockerfile/bflag_test.go b/vendor/github.com/docker/docker/builder/dockerfile/instructions/bflag_test.go similarity index 96% rename from vendor/github.com/docker/docker/builder/dockerfile/bflag_test.go rename to vendor/github.com/docker/docker/builder/dockerfile/instructions/bflag_test.go index ac07e48c1..b194ba785 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/bflag_test.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/instructions/bflag_test.go @@ -1,4 +1,4 @@ -package dockerfile +package instructions import ( "testing" @@ -34,10 +34,10 @@ func TestBuilderFlags(t *testing.T) { t.Fatalf("Test3 of %q was supposed to work: %s", bf.Args, err) } - if flStr1.IsUsed() == true { + if flStr1.IsUsed() { t.Fatal("Test3 - str1 was not used!") } - if flBool1.IsUsed() == true { + if flBool1.IsUsed() { t.Fatal("Test3 - bool1 was not used!") } @@ -58,10 +58,10 @@ func TestBuilderFlags(t *testing.T) { if flBool1.IsTrue() { t.Fatal("Bool1 was supposed to default to: false") } - if flStr1.IsUsed() == true { + if flStr1.IsUsed() { t.Fatal("Str1 was not used!") } - if flBool1.IsUsed() == true { + if flBool1.IsUsed() { t.Fatal("Bool1 was not used!") } diff --git a/vendor/github.com/docker/docker/builder/dockerfile/instructions/commands.go b/vendor/github.com/docker/docker/builder/dockerfile/instructions/commands.go new file mode 100644 index 000000000..8d5d6b09a --- /dev/null +++ b/vendor/github.com/docker/docker/builder/dockerfile/instructions/commands.go @@ -0,0 +1,396 @@ +package instructions + +import ( + "errors" + + "strings" + + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/strslice" +) + +// KeyValuePair represent an arbitrary named value (usefull in slice insted of map[string] string to preserve ordering) +type KeyValuePair struct { + Key string + Value string +} + +func (kvp *KeyValuePair) String() string { + return kvp.Key + "=" + kvp.Value +} + +// Command is implemented by every command present in a dockerfile +type Command interface { + Name() string +} + +// KeyValuePairs is a slice of KeyValuePair +type KeyValuePairs []KeyValuePair + +// withNameAndCode is the base of every command in a Dockerfile (String() returns its source code) +type withNameAndCode struct { + code string + name string +} + +func (c *withNameAndCode) String() string { + return c.code +} + +// Name of the command +func (c *withNameAndCode) Name() string { + return c.name +} + +func newWithNameAndCode(req parseRequest) withNameAndCode { + return withNameAndCode{code: strings.TrimSpace(req.original), name: req.command} +} + +// SingleWordExpander is a provider for variable expansion where 1 word => 1 output +type SingleWordExpander func(word string) (string, error) + +// SupportsSingleWordExpansion interface marks a command as supporting variable expansion +type SupportsSingleWordExpansion interface { + Expand(expander SingleWordExpander) error +} + +// PlatformSpecific adds platform checks to a command +type PlatformSpecific interface { + CheckPlatform(platform string) error +} + +func expandKvp(kvp KeyValuePair, expander SingleWordExpander) (KeyValuePair, error) { + key, err := expander(kvp.Key) + if err != nil { + return KeyValuePair{}, err + } + value, err := expander(kvp.Value) + if err != nil { + return KeyValuePair{}, err + } + return KeyValuePair{Key: key, Value: value}, nil +} +func expandKvpsInPlace(kvps KeyValuePairs, expander SingleWordExpander) error { + for i, kvp := range kvps { + newKvp, err := expandKvp(kvp, expander) + if err != nil { + return err + } + kvps[i] = newKvp + } + return nil +} + +func expandSliceInPlace(values []string, expander SingleWordExpander) error { + for i, v := range values { + newValue, err := expander(v) + if err != nil { + return err + } + values[i] = newValue + } + return nil +} + +// EnvCommand : ENV key1 value1 [keyN valueN...] +type EnvCommand struct { + withNameAndCode + Env KeyValuePairs // kvp slice instead of map to preserve ordering +} + +// Expand variables +func (c *EnvCommand) Expand(expander SingleWordExpander) error { + return expandKvpsInPlace(c.Env, expander) +} + +// MaintainerCommand : MAINTAINER maintainer_name +type MaintainerCommand struct { + withNameAndCode + Maintainer string +} + +// LabelCommand : LABEL some json data describing the image +// +// Sets the Label variable foo to bar, +// +type LabelCommand struct { + withNameAndCode + Labels KeyValuePairs // kvp slice instead of map to preserve ordering +} + +// Expand variables +func (c *LabelCommand) Expand(expander SingleWordExpander) error { + return expandKvpsInPlace(c.Labels, expander) +} + +// SourcesAndDest represent a list of source files and a destination +type SourcesAndDest []string + +// Sources list the source paths +func (s SourcesAndDest) Sources() []string { + res := make([]string, len(s)-1) + copy(res, s[:len(s)-1]) + return res +} + +// Dest path of the operation +func (s SourcesAndDest) Dest() string { + return s[len(s)-1] +} + +// AddCommand : ADD foo /path +// +// Add the file 'foo' to '/path'. Tarball and Remote URL (git, http) handling +// exist here. If you do not wish to have this automatic handling, use COPY. +// +type AddCommand struct { + withNameAndCode + SourcesAndDest + Chown string +} + +// Expand variables +func (c *AddCommand) Expand(expander SingleWordExpander) error { + return expandSliceInPlace(c.SourcesAndDest, expander) +} + +// CopyCommand : COPY foo /path +// +// Same as 'ADD' but without the tar and remote url handling. +// +type CopyCommand struct { + withNameAndCode + SourcesAndDest + From string + Chown string +} + +// Expand variables +func (c *CopyCommand) Expand(expander SingleWordExpander) error { + return expandSliceInPlace(c.SourcesAndDest, expander) +} + +// OnbuildCommand : ONBUILD +type OnbuildCommand struct { + withNameAndCode + Expression string +} + +// WorkdirCommand : WORKDIR /tmp +// +// Set the working directory for future RUN/CMD/etc statements. +// +type WorkdirCommand struct { + withNameAndCode + Path string +} + +// Expand variables +func (c *WorkdirCommand) Expand(expander SingleWordExpander) error { + p, err := expander(c.Path) + if err != nil { + return err + } + c.Path = p + return nil +} + +// ShellDependantCmdLine represents a cmdline optionaly prepended with the shell +type ShellDependantCmdLine struct { + CmdLine strslice.StrSlice + PrependShell bool +} + +// RunCommand : RUN some command yo +// +// run a command and commit the image. Args are automatically prepended with +// the current SHELL which defaults to 'sh -c' under linux or 'cmd /S /C' under +// Windows, in the event there is only one argument The difference in processing: +// +// RUN echo hi # sh -c echo hi (Linux) +// RUN echo hi # cmd /S /C echo hi (Windows) +// RUN [ "echo", "hi" ] # echo hi +// +type RunCommand struct { + withNameAndCode + ShellDependantCmdLine +} + +// CmdCommand : CMD foo +// +// Set the default command to run in the container (which may be empty). +// Argument handling is the same as RUN. +// +type CmdCommand struct { + withNameAndCode + ShellDependantCmdLine +} + +// HealthCheckCommand : HEALTHCHECK foo +// +// Set the default healthcheck command to run in the container (which may be empty). +// Argument handling is the same as RUN. +// +type HealthCheckCommand struct { + withNameAndCode + Health *container.HealthConfig +} + +// EntrypointCommand : ENTRYPOINT /usr/sbin/nginx +// +// Set the entrypoint to /usr/sbin/nginx. Will accept the CMD as the arguments +// to /usr/sbin/nginx. Uses the default shell if not in JSON format. +// +// Handles command processing similar to CMD and RUN, only req.runConfig.Entrypoint +// is initialized at newBuilder time instead of through argument parsing. +// +type EntrypointCommand struct { + withNameAndCode + ShellDependantCmdLine +} + +// ExposeCommand : EXPOSE 6667/tcp 7000/tcp +// +// Expose ports for links and port mappings. This all ends up in +// req.runConfig.ExposedPorts for runconfig. +// +type ExposeCommand struct { + withNameAndCode + Ports []string +} + +// UserCommand : USER foo +// +// Set the user to 'foo' for future commands and when running the +// ENTRYPOINT/CMD at container run time. +// +type UserCommand struct { + withNameAndCode + User string +} + +// Expand variables +func (c *UserCommand) Expand(expander SingleWordExpander) error { + p, err := expander(c.User) + if err != nil { + return err + } + c.User = p + return nil +} + +// VolumeCommand : VOLUME /foo +// +// Expose the volume /foo for use. Will also accept the JSON array form. +// +type VolumeCommand struct { + withNameAndCode + Volumes []string +} + +// Expand variables +func (c *VolumeCommand) Expand(expander SingleWordExpander) error { + return expandSliceInPlace(c.Volumes, expander) +} + +// StopSignalCommand : STOPSIGNAL signal +// +// Set the signal that will be used to kill the container. +type StopSignalCommand struct { + withNameAndCode + Signal string +} + +// Expand variables +func (c *StopSignalCommand) Expand(expander SingleWordExpander) error { + p, err := expander(c.Signal) + if err != nil { + return err + } + c.Signal = p + return nil +} + +// CheckPlatform checks that the command is supported in the target platform +func (c *StopSignalCommand) CheckPlatform(platform string) error { + if platform == "windows" { + return errors.New("The daemon on this platform does not support the command stopsignal") + } + return nil +} + +// ArgCommand : ARG name[=value] +// +// Adds the variable foo to the trusted list of variables that can be passed +// to builder using the --build-arg flag for expansion/substitution or passing to 'run'. +// Dockerfile author may optionally set a default value of this variable. +type ArgCommand struct { + withNameAndCode + Key string + Value *string +} + +// Expand variables +func (c *ArgCommand) Expand(expander SingleWordExpander) error { + p, err := expander(c.Key) + if err != nil { + return err + } + c.Key = p + if c.Value != nil { + p, err = expander(*c.Value) + if err != nil { + return err + } + c.Value = &p + } + return nil +} + +// ShellCommand : SHELL powershell -command +// +// Set the non-default shell to use. +type ShellCommand struct { + withNameAndCode + Shell strslice.StrSlice +} + +// Stage represents a single stage in a multi-stage build +type Stage struct { + Name string + Commands []Command + BaseName string + SourceCode string +} + +// AddCommand to the stage +func (s *Stage) AddCommand(cmd Command) { + // todo: validate cmd type + s.Commands = append(s.Commands, cmd) +} + +// IsCurrentStage check if the stage name is the current stage +func IsCurrentStage(s []Stage, name string) bool { + if len(s) == 0 { + return false + } + return s[len(s)-1].Name == name +} + +// CurrentStage return the last stage in a slice +func CurrentStage(s []Stage) (*Stage, error) { + if len(s) == 0 { + return nil, errors.New("No build stage in current context") + } + return &s[len(s)-1], nil +} + +// HasStage looks for the presence of a given stage name +func HasStage(s []Stage, name string) (int, bool) { + for i, stage := range s { + if stage.Name == name { + return i, true + } + } + return -1, false +} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/instructions/errors_unix.go b/vendor/github.com/docker/docker/builder/dockerfile/instructions/errors_unix.go new file mode 100644 index 000000000..0b03b34cd --- /dev/null +++ b/vendor/github.com/docker/docker/builder/dockerfile/instructions/errors_unix.go @@ -0,0 +1,9 @@ +// +build !windows + +package instructions + +import "fmt" + +func errNotJSON(command, _ string) error { + return fmt.Errorf("%s requires the arguments to be in JSON form", command) +} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/instructions/errors_windows.go b/vendor/github.com/docker/docker/builder/dockerfile/instructions/errors_windows.go new file mode 100644 index 000000000..a4843c5b6 --- /dev/null +++ b/vendor/github.com/docker/docker/builder/dockerfile/instructions/errors_windows.go @@ -0,0 +1,27 @@ +package instructions + +import ( + "fmt" + "path/filepath" + "regexp" + "strings" +) + +func errNotJSON(command, original string) error { + // For Windows users, give a hint if it looks like it might contain + // a path which hasn't been escaped such as ["c:\windows\system32\prog.exe", "-param"], + // as JSON must be escaped. Unfortunate... + // + // Specifically looking for quote-driveletter-colon-backslash, there's no + // double backslash and a [] pair. No, this is not perfect, but it doesn't + // have to be. It's simply a hint to make life a little easier. + extra := "" + original = filepath.FromSlash(strings.ToLower(strings.Replace(strings.ToLower(original), strings.ToLower(command)+" ", "", -1))) + if len(regexp.MustCompile(`"[a-z]:\\.*`).FindStringSubmatch(original)) > 0 && + !strings.Contains(original, `\\`) && + strings.Contains(original, "[") && + strings.Contains(original, "]") { + extra = fmt.Sprintf(`. It looks like '%s' includes a file path without an escaped back-slash. JSON requires back-slashes to be escaped such as ["c:\\path\\to\\file.exe", "/parameter"]`, original) + } + return fmt.Errorf("%s requires the arguments to be in JSON form%s", command, extra) +} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/instructions/parse.go b/vendor/github.com/docker/docker/builder/dockerfile/instructions/parse.go new file mode 100644 index 000000000..e52ac47a1 --- /dev/null +++ b/vendor/github.com/docker/docker/builder/dockerfile/instructions/parse.go @@ -0,0 +1,635 @@ +package instructions + +import ( + "fmt" + "regexp" + "sort" + "strconv" + "strings" + "time" + + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/strslice" + "github.com/docker/docker/builder/dockerfile/command" + "github.com/docker/docker/builder/dockerfile/parser" + "github.com/pkg/errors" +) + +type parseRequest struct { + command string + args []string + attributes map[string]bool + flags *BFlags + original string +} + +func nodeArgs(node *parser.Node) []string { + result := []string{} + for ; node.Next != nil; node = node.Next { + arg := node.Next + if len(arg.Children) == 0 { + result = append(result, arg.Value) + } else if len(arg.Children) == 1 { + //sub command + result = append(result, arg.Children[0].Value) + result = append(result, nodeArgs(arg.Children[0])...) + } + } + return result +} + +func newParseRequestFromNode(node *parser.Node) parseRequest { + return parseRequest{ + command: node.Value, + args: nodeArgs(node), + attributes: node.Attributes, + original: node.Original, + flags: NewBFlagsWithArgs(node.Flags), + } +} + +// ParseInstruction converts an AST to a typed instruction (either a command or a build stage beginning when encountering a `FROM` statement) +func ParseInstruction(node *parser.Node) (interface{}, error) { + req := newParseRequestFromNode(node) + switch node.Value { + case command.Env: + return parseEnv(req) + case command.Maintainer: + return parseMaintainer(req) + case command.Label: + return parseLabel(req) + case command.Add: + return parseAdd(req) + case command.Copy: + return parseCopy(req) + case command.From: + return parseFrom(req) + case command.Onbuild: + return parseOnBuild(req) + case command.Workdir: + return parseWorkdir(req) + case command.Run: + return parseRun(req) + case command.Cmd: + return parseCmd(req) + case command.Healthcheck: + return parseHealthcheck(req) + case command.Entrypoint: + return parseEntrypoint(req) + case command.Expose: + return parseExpose(req) + case command.User: + return parseUser(req) + case command.Volume: + return parseVolume(req) + case command.StopSignal: + return parseStopSignal(req) + case command.Arg: + return parseArg(req) + case command.Shell: + return parseShell(req) + } + + return nil, &UnknownInstruction{Instruction: node.Value, Line: node.StartLine} +} + +// ParseCommand converts an AST to a typed Command +func ParseCommand(node *parser.Node) (Command, error) { + s, err := ParseInstruction(node) + if err != nil { + return nil, err + } + if c, ok := s.(Command); ok { + return c, nil + } + return nil, errors.Errorf("%T is not a command type", s) +} + +// UnknownInstruction represents an error occuring when a command is unresolvable +type UnknownInstruction struct { + Line int + Instruction string +} + +func (e *UnknownInstruction) Error() string { + return fmt.Sprintf("unknown instruction: %s", strings.ToUpper(e.Instruction)) +} + +// IsUnknownInstruction checks if the error is an UnknownInstruction or a parseError containing an UnknownInstruction +func IsUnknownInstruction(err error) bool { + _, ok := err.(*UnknownInstruction) + if !ok { + var pe *parseError + if pe, ok = err.(*parseError); ok { + _, ok = pe.inner.(*UnknownInstruction) + } + } + return ok +} + +type parseError struct { + inner error + node *parser.Node +} + +func (e *parseError) Error() string { + return fmt.Sprintf("Dockerfile parse error line %d: %v", e.node.StartLine, e.inner.Error()) +} + +// Parse a docker file into a collection of buildable stages +func Parse(ast *parser.Node) (stages []Stage, metaArgs []ArgCommand, err error) { + for _, n := range ast.Children { + cmd, err := ParseInstruction(n) + if err != nil { + return nil, nil, &parseError{inner: err, node: n} + } + if len(stages) == 0 { + // meta arg case + if a, isArg := cmd.(*ArgCommand); isArg { + metaArgs = append(metaArgs, *a) + continue + } + } + switch c := cmd.(type) { + case *Stage: + stages = append(stages, *c) + case Command: + stage, err := CurrentStage(stages) + if err != nil { + return nil, nil, err + } + stage.AddCommand(c) + default: + return nil, nil, errors.Errorf("%T is not a command type", cmd) + } + + } + return stages, metaArgs, nil +} + +func parseKvps(args []string, cmdName string) (KeyValuePairs, error) { + if len(args) == 0 { + return nil, errAtLeastOneArgument(cmdName) + } + if len(args)%2 != 0 { + // should never get here, but just in case + return nil, errTooManyArguments(cmdName) + } + var res KeyValuePairs + for j := 0; j < len(args); j += 2 { + if len(args[j]) == 0 { + return nil, errBlankCommandNames(cmdName) + } + name := args[j] + value := args[j+1] + res = append(res, KeyValuePair{Key: name, Value: value}) + } + return res, nil +} + +func parseEnv(req parseRequest) (*EnvCommand, error) { + + if err := req.flags.Parse(); err != nil { + return nil, err + } + envs, err := parseKvps(req.args, "ENV") + if err != nil { + return nil, err + } + return &EnvCommand{ + Env: envs, + withNameAndCode: newWithNameAndCode(req), + }, nil +} + +func parseMaintainer(req parseRequest) (*MaintainerCommand, error) { + if len(req.args) != 1 { + return nil, errExactlyOneArgument("MAINTAINER") + } + + if err := req.flags.Parse(); err != nil { + return nil, err + } + return &MaintainerCommand{ + Maintainer: req.args[0], + withNameAndCode: newWithNameAndCode(req), + }, nil +} + +func parseLabel(req parseRequest) (*LabelCommand, error) { + + if err := req.flags.Parse(); err != nil { + return nil, err + } + + labels, err := parseKvps(req.args, "LABEL") + if err != nil { + return nil, err + } + + return &LabelCommand{ + Labels: labels, + withNameAndCode: newWithNameAndCode(req), + }, nil +} + +func parseAdd(req parseRequest) (*AddCommand, error) { + if len(req.args) < 2 { + return nil, errAtLeastTwoArguments("ADD") + } + flChown := req.flags.AddString("chown", "") + if err := req.flags.Parse(); err != nil { + return nil, err + } + return &AddCommand{ + SourcesAndDest: SourcesAndDest(req.args), + withNameAndCode: newWithNameAndCode(req), + Chown: flChown.Value, + }, nil +} + +func parseCopy(req parseRequest) (*CopyCommand, error) { + if len(req.args) < 2 { + return nil, errAtLeastTwoArguments("COPY") + } + flChown := req.flags.AddString("chown", "") + flFrom := req.flags.AddString("from", "") + if err := req.flags.Parse(); err != nil { + return nil, err + } + return &CopyCommand{ + SourcesAndDest: SourcesAndDest(req.args), + From: flFrom.Value, + withNameAndCode: newWithNameAndCode(req), + Chown: flChown.Value, + }, nil +} + +func parseFrom(req parseRequest) (*Stage, error) { + stageName, err := parseBuildStageName(req.args) + if err != nil { + return nil, err + } + + if err := req.flags.Parse(); err != nil { + return nil, err + } + code := strings.TrimSpace(req.original) + + return &Stage{ + BaseName: req.args[0], + Name: stageName, + SourceCode: code, + Commands: []Command{}, + }, nil + +} + +func parseBuildStageName(args []string) (string, error) { + stageName := "" + switch { + case len(args) == 3 && strings.EqualFold(args[1], "as"): + stageName = strings.ToLower(args[2]) + if ok, _ := regexp.MatchString("^[a-z][a-z0-9-_\\.]*$", stageName); !ok { + return "", errors.Errorf("invalid name for build stage: %q, name can't start with a number or contain symbols", stageName) + } + case len(args) != 1: + return "", errors.New("FROM requires either one or three arguments") + } + + return stageName, nil +} + +func parseOnBuild(req parseRequest) (*OnbuildCommand, error) { + if len(req.args) == 0 { + return nil, errAtLeastOneArgument("ONBUILD") + } + if err := req.flags.Parse(); err != nil { + return nil, err + } + + triggerInstruction := strings.ToUpper(strings.TrimSpace(req.args[0])) + switch strings.ToUpper(triggerInstruction) { + case "ONBUILD": + return nil, errors.New("Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed") + case "MAINTAINER", "FROM": + return nil, fmt.Errorf("%s isn't allowed as an ONBUILD trigger", triggerInstruction) + } + + original := regexp.MustCompile(`(?i)^\s*ONBUILD\s*`).ReplaceAllString(req.original, "") + return &OnbuildCommand{ + Expression: original, + withNameAndCode: newWithNameAndCode(req), + }, nil + +} + +func parseWorkdir(req parseRequest) (*WorkdirCommand, error) { + if len(req.args) != 1 { + return nil, errExactlyOneArgument("WORKDIR") + } + + err := req.flags.Parse() + if err != nil { + return nil, err + } + return &WorkdirCommand{ + Path: req.args[0], + withNameAndCode: newWithNameAndCode(req), + }, nil + +} + +func parseShellDependentCommand(req parseRequest, emptyAsNil bool) ShellDependantCmdLine { + args := handleJSONArgs(req.args, req.attributes) + cmd := strslice.StrSlice(args) + if emptyAsNil && len(cmd) == 0 { + cmd = nil + } + return ShellDependantCmdLine{ + CmdLine: cmd, + PrependShell: !req.attributes["json"], + } +} + +func parseRun(req parseRequest) (*RunCommand, error) { + + if err := req.flags.Parse(); err != nil { + return nil, err + } + return &RunCommand{ + ShellDependantCmdLine: parseShellDependentCommand(req, false), + withNameAndCode: newWithNameAndCode(req), + }, nil + +} + +func parseCmd(req parseRequest) (*CmdCommand, error) { + if err := req.flags.Parse(); err != nil { + return nil, err + } + return &CmdCommand{ + ShellDependantCmdLine: parseShellDependentCommand(req, false), + withNameAndCode: newWithNameAndCode(req), + }, nil + +} + +func parseEntrypoint(req parseRequest) (*EntrypointCommand, error) { + if err := req.flags.Parse(); err != nil { + return nil, err + } + + cmd := &EntrypointCommand{ + ShellDependantCmdLine: parseShellDependentCommand(req, true), + withNameAndCode: newWithNameAndCode(req), + } + + return cmd, nil +} + +// parseOptInterval(flag) is the duration of flag.Value, or 0 if +// empty. An error is reported if the value is given and less than minimum duration. +func parseOptInterval(f *Flag) (time.Duration, error) { + s := f.Value + if s == "" { + return 0, nil + } + d, err := time.ParseDuration(s) + if err != nil { + return 0, err + } + if d < container.MinimumDuration { + return 0, fmt.Errorf("Interval %#v cannot be less than %s", f.name, container.MinimumDuration) + } + return d, nil +} +func parseHealthcheck(req parseRequest) (*HealthCheckCommand, error) { + if len(req.args) == 0 { + return nil, errAtLeastOneArgument("HEALTHCHECK") + } + cmd := &HealthCheckCommand{ + withNameAndCode: newWithNameAndCode(req), + } + + typ := strings.ToUpper(req.args[0]) + args := req.args[1:] + if typ == "NONE" { + if len(args) != 0 { + return nil, errors.New("HEALTHCHECK NONE takes no arguments") + } + test := strslice.StrSlice{typ} + cmd.Health = &container.HealthConfig{ + Test: test, + } + } else { + + healthcheck := container.HealthConfig{} + + flInterval := req.flags.AddString("interval", "") + flTimeout := req.flags.AddString("timeout", "") + flStartPeriod := req.flags.AddString("start-period", "") + flRetries := req.flags.AddString("retries", "") + + if err := req.flags.Parse(); err != nil { + return nil, err + } + + switch typ { + case "CMD": + cmdSlice := handleJSONArgs(args, req.attributes) + if len(cmdSlice) == 0 { + return nil, errors.New("Missing command after HEALTHCHECK CMD") + } + + if !req.attributes["json"] { + typ = "CMD-SHELL" + } + + healthcheck.Test = strslice.StrSlice(append([]string{typ}, cmdSlice...)) + default: + return nil, fmt.Errorf("Unknown type %#v in HEALTHCHECK (try CMD)", typ) + } + + interval, err := parseOptInterval(flInterval) + if err != nil { + return nil, err + } + healthcheck.Interval = interval + + timeout, err := parseOptInterval(flTimeout) + if err != nil { + return nil, err + } + healthcheck.Timeout = timeout + + startPeriod, err := parseOptInterval(flStartPeriod) + if err != nil { + return nil, err + } + healthcheck.StartPeriod = startPeriod + + if flRetries.Value != "" { + retries, err := strconv.ParseInt(flRetries.Value, 10, 32) + if err != nil { + return nil, err + } + if retries < 1 { + return nil, fmt.Errorf("--retries must be at least 1 (not %d)", retries) + } + healthcheck.Retries = int(retries) + } else { + healthcheck.Retries = 0 + } + + cmd.Health = &healthcheck + } + return cmd, nil +} + +func parseExpose(req parseRequest) (*ExposeCommand, error) { + portsTab := req.args + + if len(req.args) == 0 { + return nil, errAtLeastOneArgument("EXPOSE") + } + + if err := req.flags.Parse(); err != nil { + return nil, err + } + + sort.Strings(portsTab) + return &ExposeCommand{ + Ports: portsTab, + withNameAndCode: newWithNameAndCode(req), + }, nil +} + +func parseUser(req parseRequest) (*UserCommand, error) { + if len(req.args) != 1 { + return nil, errExactlyOneArgument("USER") + } + + if err := req.flags.Parse(); err != nil { + return nil, err + } + return &UserCommand{ + User: req.args[0], + withNameAndCode: newWithNameAndCode(req), + }, nil +} + +func parseVolume(req parseRequest) (*VolumeCommand, error) { + if len(req.args) == 0 { + return nil, errAtLeastOneArgument("VOLUME") + } + + if err := req.flags.Parse(); err != nil { + return nil, err + } + + cmd := &VolumeCommand{ + withNameAndCode: newWithNameAndCode(req), + } + + for _, v := range req.args { + v = strings.TrimSpace(v) + if v == "" { + return nil, errors.New("VOLUME specified can not be an empty string") + } + cmd.Volumes = append(cmd.Volumes, v) + } + return cmd, nil + +} + +func parseStopSignal(req parseRequest) (*StopSignalCommand, error) { + if len(req.args) != 1 { + return nil, errExactlyOneArgument("STOPSIGNAL") + } + sig := req.args[0] + + cmd := &StopSignalCommand{ + Signal: sig, + withNameAndCode: newWithNameAndCode(req), + } + return cmd, nil + +} + +func parseArg(req parseRequest) (*ArgCommand, error) { + if len(req.args) != 1 { + return nil, errExactlyOneArgument("ARG") + } + + var ( + name string + newValue *string + ) + + arg := req.args[0] + // 'arg' can just be a name or name-value pair. Note that this is different + // from 'env' that handles the split of name and value at the parser level. + // The reason for doing it differently for 'arg' is that we support just + // defining an arg and not assign it a value (while 'env' always expects a + // name-value pair). If possible, it will be good to harmonize the two. + if strings.Contains(arg, "=") { + parts := strings.SplitN(arg, "=", 2) + if len(parts[0]) == 0 { + return nil, errBlankCommandNames("ARG") + } + + name = parts[0] + newValue = &parts[1] + } else { + name = arg + } + + return &ArgCommand{ + Key: name, + Value: newValue, + withNameAndCode: newWithNameAndCode(req), + }, nil +} + +func parseShell(req parseRequest) (*ShellCommand, error) { + if err := req.flags.Parse(); err != nil { + return nil, err + } + shellSlice := handleJSONArgs(req.args, req.attributes) + switch { + case len(shellSlice) == 0: + // SHELL [] + return nil, errAtLeastOneArgument("SHELL") + case req.attributes["json"]: + // SHELL ["powershell", "-command"] + + return &ShellCommand{ + Shell: strslice.StrSlice(shellSlice), + withNameAndCode: newWithNameAndCode(req), + }, nil + default: + // SHELL powershell -command - not JSON + return nil, errNotJSON("SHELL", req.original) + } +} + +func errAtLeastOneArgument(command string) error { + return errors.Errorf("%s requires at least one argument", command) +} + +func errExactlyOneArgument(command string) error { + return errors.Errorf("%s requires exactly one argument", command) +} + +func errAtLeastTwoArguments(command string) error { + return errors.Errorf("%s requires at least two arguments", command) +} + +func errBlankCommandNames(command string) error { + return errors.Errorf("%s names can not be blank", command) +} + +func errTooManyArguments(command string) error { + return errors.Errorf("Bad input to %s, too many arguments", command) +} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/instructions/parse_test.go b/vendor/github.com/docker/docker/builder/dockerfile/instructions/parse_test.go new file mode 100644 index 000000000..bf41b1a26 --- /dev/null +++ b/vendor/github.com/docker/docker/builder/dockerfile/instructions/parse_test.go @@ -0,0 +1,204 @@ +package instructions + +import ( + "strings" + "testing" + + "github.com/docker/docker/builder/dockerfile/command" + "github.com/docker/docker/builder/dockerfile/parser" + "github.com/docker/docker/internal/testutil" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestCommandsExactlyOneArgument(t *testing.T) { + commands := []string{ + "MAINTAINER", + "WORKDIR", + "USER", + "STOPSIGNAL", + } + + for _, command := range commands { + ast, err := parser.Parse(strings.NewReader(command)) + require.NoError(t, err) + _, err = ParseInstruction(ast.AST.Children[0]) + assert.EqualError(t, err, errExactlyOneArgument(command).Error()) + } +} + +func TestCommandsAtLeastOneArgument(t *testing.T) { + commands := []string{ + "ENV", + "LABEL", + "ONBUILD", + "HEALTHCHECK", + "EXPOSE", + "VOLUME", + } + + for _, command := range commands { + ast, err := parser.Parse(strings.NewReader(command)) + require.NoError(t, err) + _, err = ParseInstruction(ast.AST.Children[0]) + assert.EqualError(t, err, errAtLeastOneArgument(command).Error()) + } +} + +func TestCommandsAtLeastTwoArgument(t *testing.T) { + commands := []string{ + "ADD", + "COPY", + } + + for _, command := range commands { + ast, err := parser.Parse(strings.NewReader(command + " arg1")) + require.NoError(t, err) + _, err = ParseInstruction(ast.AST.Children[0]) + assert.EqualError(t, err, errAtLeastTwoArguments(command).Error()) + } +} + +func TestCommandsTooManyArguments(t *testing.T) { + commands := []string{ + "ENV", + "LABEL", + } + + for _, command := range commands { + node := &parser.Node{ + Original: command + "arg1 arg2 arg3", + Value: strings.ToLower(command), + Next: &parser.Node{ + Value: "arg1", + Next: &parser.Node{ + Value: "arg2", + Next: &parser.Node{ + Value: "arg3", + }, + }, + }, + } + _, err := ParseInstruction(node) + assert.EqualError(t, err, errTooManyArguments(command).Error()) + } +} + +func TestCommandsBlankNames(t *testing.T) { + commands := []string{ + "ENV", + "LABEL", + } + + for _, command := range commands { + node := &parser.Node{ + Original: command + " =arg2", + Value: strings.ToLower(command), + Next: &parser.Node{ + Value: "", + Next: &parser.Node{ + Value: "arg2", + }, + }, + } + _, err := ParseInstruction(node) + assert.EqualError(t, err, errBlankCommandNames(command).Error()) + } +} + +func TestHealthCheckCmd(t *testing.T) { + node := &parser.Node{ + Value: command.Healthcheck, + Next: &parser.Node{ + Value: "CMD", + Next: &parser.Node{ + Value: "hello", + Next: &parser.Node{ + Value: "world", + }, + }, + }, + } + cmd, err := ParseInstruction(node) + assert.NoError(t, err) + hc, ok := cmd.(*HealthCheckCommand) + assert.True(t, ok) + expected := []string{"CMD-SHELL", "hello world"} + assert.Equal(t, expected, hc.Health.Test) +} + +func TestParseOptInterval(t *testing.T) { + flInterval := &Flag{ + name: "interval", + flagType: stringType, + Value: "50ns", + } + _, err := parseOptInterval(flInterval) + testutil.ErrorContains(t, err, "cannot be less than 1ms") + + flInterval.Value = "1ms" + _, err = parseOptInterval(flInterval) + require.NoError(t, err) +} + +func TestErrorCases(t *testing.T) { + cases := []struct { + name string + dockerfile string + expectedError string + }{ + { + name: "copyEmptyWhitespace", + dockerfile: `COPY + quux \ + bar`, + expectedError: "COPY requires at least two arguments", + }, + { + name: "ONBUILD forbidden FROM", + dockerfile: "ONBUILD FROM scratch", + expectedError: "FROM isn't allowed as an ONBUILD trigger", + }, + { + name: "ONBUILD forbidden MAINTAINER", + dockerfile: "ONBUILD MAINTAINER docker.io", + expectedError: "MAINTAINER isn't allowed as an ONBUILD trigger", + }, + { + name: "ARG two arguments", + dockerfile: "ARG foo bar", + expectedError: "ARG requires exactly one argument", + }, + { + name: "MAINTAINER unknown flag", + dockerfile: "MAINTAINER --boo joe@example.com", + expectedError: "Unknown flag: boo", + }, + { + name: "Chaining ONBUILD", + dockerfile: `ONBUILD ONBUILD RUN touch foobar`, + expectedError: "Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed", + }, + { + name: "Invalid instruction", + dockerfile: `foo bar`, + expectedError: "unknown instruction: FOO", + }, + } + for _, c := range cases { + r := strings.NewReader(c.dockerfile) + ast, err := parser.Parse(r) + + if err != nil { + t.Fatalf("Error when parsing Dockerfile: %s", err) + } + n := ast.AST.Children[0] + _, err = ParseInstruction(n) + if err != nil { + testutil.ErrorContains(t, err, c.expectedError) + return + } + t.Fatalf("No error when executing test %s", c.name) + } + +} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/support.go b/vendor/github.com/docker/docker/builder/dockerfile/instructions/support.go similarity index 96% rename from vendor/github.com/docker/docker/builder/dockerfile/support.go rename to vendor/github.com/docker/docker/builder/dockerfile/instructions/support.go index e87588910..beefe775c 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/support.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/instructions/support.go @@ -1,4 +1,4 @@ -package dockerfile +package instructions import "strings" diff --git a/vendor/github.com/docker/docker/builder/dockerfile/support_test.go b/vendor/github.com/docker/docker/builder/dockerfile/instructions/support_test.go similarity index 98% rename from vendor/github.com/docker/docker/builder/dockerfile/support_test.go rename to vendor/github.com/docker/docker/builder/dockerfile/instructions/support_test.go index 7cc6fe9dc..2b888dca0 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/support_test.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/instructions/support_test.go @@ -1,4 +1,4 @@ -package dockerfile +package instructions import "testing" diff --git a/vendor/github.com/docker/docker/builder/dockerfile/internals.go b/vendor/github.com/docker/docker/builder/dockerfile/internals.go index c0d6081d0..4c82e6158 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/internals.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/internals.go @@ -7,16 +7,80 @@ import ( "crypto/sha256" "encoding/hex" "fmt" + "io" + "os" + "path" + "path/filepath" + "strconv" "strings" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" "github.com/docker/docker/api/types/container" "github.com/docker/docker/image" + "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/chrootarchive" + "github.com/docker/docker/pkg/containerfs" + "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/stringid" + "github.com/docker/docker/pkg/symlink" + "github.com/docker/docker/pkg/system" + lcUser "github.com/opencontainers/runc/libcontainer/user" "github.com/pkg/errors" ) +// For Windows only +var pathBlacklist = map[string]bool{ + "c:\\": true, + "c:\\windows": true, +} + +// Archiver defines an interface for copying files from one destination to +// another using Tar/Untar. +type Archiver interface { + TarUntar(src, dst string) error + UntarPath(src, dst string) error + CopyWithTar(src, dst string) error + CopyFileWithTar(src, dst string) error + IDMappings() *idtools.IDMappings +} + +// The builder will use the following interfaces if the container fs implements +// these for optimized copies to and from the container. +type extractor interface { + ExtractArchive(src io.Reader, dst string, opts *archive.TarOptions) error +} + +type archiver interface { + ArchivePath(src string, opts *archive.TarOptions) (io.ReadCloser, error) +} + +// helper functions to get tar/untar func +func untarFunc(i interface{}) containerfs.UntarFunc { + if ea, ok := i.(extractor); ok { + return ea.ExtractArchive + } + return chrootarchive.Untar +} + +func tarFunc(i interface{}) containerfs.TarFunc { + if ap, ok := i.(archiver); ok { + return ap.ArchivePath + } + return archive.TarWithOptions +} + +func (b *Builder) getArchiver(src, dst containerfs.Driver) Archiver { + t, u := tarFunc(src), untarFunc(dst) + return &containerfs.Archiver{ + SrcDriver: src, + DstDriver: dst, + Tar: t, + Untar: u, + IDMappingsVar: b.idMappings, + } +} + func (b *Builder) commit(dispatchState *dispatchState, comment string) error { if b.disableCommit { return nil @@ -60,7 +124,6 @@ func (b *Builder) commitContainer(dispatchState *dispatchState, id string, conta } dispatchState.imageID = imageID - b.buildStages.update(imageID) return nil } @@ -100,17 +163,22 @@ func (b *Builder) exportImage(state *dispatchState, imageMount *imageMount, runC state.imageID = exportedImage.ImageID() b.imageSources.Add(newImageMount(exportedImage, newLayer)) - b.buildStages.update(state.imageID) return nil } func (b *Builder) performCopy(state *dispatchState, inst copyInstruction) error { srcHash := getSourceHashFromInfos(inst.infos) + var chownComment string + if inst.chownStr != "" { + chownComment = fmt.Sprintf("--chown=%s", inst.chownStr) + } + commentStr := fmt.Sprintf("%s %s%s in %s ", inst.cmdName, chownComment, srcHash, inst.dest) + // TODO: should this have been using origPaths instead of srcHash in the comment? runConfigWithCommentCmd := copyRunConfig( state.runConfig, - withCmdCommentString(fmt.Sprintf("%s %s in %s ", inst.cmdName, srcHash, inst.dest), b.platform)) + withCmdCommentString(commentStr, b.platform)) hit, err := b.probeCache(state, runConfigWithCommentCmd) if err != nil || hit { return err @@ -120,16 +188,29 @@ func (b *Builder) performCopy(state *dispatchState, inst copyInstruction) error if err != nil { return errors.Wrapf(err, "failed to get destination image %q", state.imageID) } - destInfo, err := createDestInfo(state.runConfig.WorkingDir, inst, imageMount) + + destInfo, err := createDestInfo(state.runConfig.WorkingDir, inst, imageMount, b.platform) if err != nil { return err } - opts := copyFileOptions{ - decompress: inst.allowLocalDecompression, - archiver: b.archiver, + chownPair := b.idMappings.RootPair() + // if a chown was requested, perform the steps to get the uid, gid + // translated (if necessary because of user namespaces), and replace + // the root pair with the chown pair for copy operations + if inst.chownStr != "" { + chownPair, err = parseChownFlag(inst.chownStr, destInfo.root.Path(), b.idMappings) + if err != nil { + return errors.Wrapf(err, "unable to convert uid/gid chown string to host mapping") + } } + for _, info := range inst.infos { + opts := copyFileOptions{ + decompress: inst.allowLocalDecompression, + archiver: b.getArchiver(info.root, destInfo.root), + chownPair: chownPair, + } if err := performCopyForInfo(destInfo, info, opts); err != nil { return errors.Wrapf(err, "failed to copy files") } @@ -137,10 +218,86 @@ func (b *Builder) performCopy(state *dispatchState, inst copyInstruction) error return b.exportImage(state, imageMount, runConfigWithCommentCmd) } -func createDestInfo(workingDir string, inst copyInstruction, imageMount *imageMount) (copyInfo, error) { +func parseChownFlag(chown, ctrRootPath string, idMappings *idtools.IDMappings) (idtools.IDPair, error) { + var userStr, grpStr string + parts := strings.Split(chown, ":") + if len(parts) > 2 { + return idtools.IDPair{}, errors.New("invalid chown string format: " + chown) + } + if len(parts) == 1 { + // if no group specified, use the user spec as group as well + userStr, grpStr = parts[0], parts[0] + } else { + userStr, grpStr = parts[0], parts[1] + } + + passwdPath, err := symlink.FollowSymlinkInScope(filepath.Join(ctrRootPath, "etc", "passwd"), ctrRootPath) + if err != nil { + return idtools.IDPair{}, errors.Wrapf(err, "can't resolve /etc/passwd path in container rootfs") + } + groupPath, err := symlink.FollowSymlinkInScope(filepath.Join(ctrRootPath, "etc", "group"), ctrRootPath) + if err != nil { + return idtools.IDPair{}, errors.Wrapf(err, "can't resolve /etc/group path in container rootfs") + } + uid, err := lookupUser(userStr, passwdPath) + if err != nil { + return idtools.IDPair{}, errors.Wrapf(err, "can't find uid for user "+userStr) + } + gid, err := lookupGroup(grpStr, groupPath) + if err != nil { + return idtools.IDPair{}, errors.Wrapf(err, "can't find gid for group "+grpStr) + } + + // convert as necessary because of user namespaces + chownPair, err := idMappings.ToHost(idtools.IDPair{UID: uid, GID: gid}) + if err != nil { + return idtools.IDPair{}, errors.Wrapf(err, "unable to convert uid/gid to host mapping") + } + return chownPair, nil +} + +func lookupUser(userStr, filepath string) (int, error) { + // if the string is actually a uid integer, parse to int and return + // as we don't need to translate with the help of files + uid, err := strconv.Atoi(userStr) + if err == nil { + return uid, nil + } + users, err := lcUser.ParsePasswdFileFilter(filepath, func(u lcUser.User) bool { + return u.Name == userStr + }) + if err != nil { + return 0, err + } + if len(users) == 0 { + return 0, errors.New("no such user: " + userStr) + } + return users[0].Uid, nil +} + +func lookupGroup(groupStr, filepath string) (int, error) { + // if the string is actually a gid integer, parse to int and return + // as we don't need to translate with the help of files + gid, err := strconv.Atoi(groupStr) + if err == nil { + return gid, nil + } + groups, err := lcUser.ParseGroupFileFilter(filepath, func(g lcUser.Group) bool { + return g.Name == groupStr + }) + if err != nil { + return 0, err + } + if len(groups) == 0 { + return 0, errors.New("no such group: " + groupStr) + } + return groups[0].Gid, nil +} + +func createDestInfo(workingDir string, inst copyInstruction, imageMount *imageMount, platform string) (copyInfo, error) { // Twiddle the destination when it's a relative path - meaning, make it // relative to the WORKINGDIR - dest, err := normaliseDest(workingDir, inst.dest) + dest, err := normalizeDest(workingDir, inst.dest, platform) if err != nil { return copyInfo{}, errors.Wrapf(err, "invalid %s", inst.cmdName) } @@ -153,6 +310,63 @@ func createDestInfo(workingDir string, inst copyInstruction, imageMount *imageMo return newCopyInfoFromSource(destMount, dest, ""), nil } +// normalizeDest normalises the destination of a COPY/ADD command in a +// platform semantically consistent way. +func normalizeDest(workingDir, requested string, platform string) (string, error) { + dest := fromSlash(requested, platform) + endsInSlash := strings.HasSuffix(dest, string(separator(platform))) + + if platform != "windows" { + if !path.IsAbs(requested) { + dest = path.Join("/", filepath.ToSlash(workingDir), dest) + // Make sure we preserve any trailing slash + if endsInSlash { + dest += "/" + } + } + return dest, nil + } + + // We are guaranteed that the working directory is already consistent, + // However, Windows also has, for now, the limitation that ADD/COPY can + // only be done to the system drive, not any drives that might be present + // as a result of a bind mount. + // + // So... if the path requested is Linux-style absolute (/foo or \\foo), + // we assume it is the system drive. If it is a Windows-style absolute + // (DRIVE:\\foo), error if DRIVE is not C. And finally, ensure we + // strip any configured working directories drive letter so that it + // can be subsequently legitimately converted to a Windows volume-style + // pathname. + + // Not a typo - filepath.IsAbs, not system.IsAbs on this next check as + // we only want to validate where the DriveColon part has been supplied. + if filepath.IsAbs(dest) { + if strings.ToUpper(string(dest[0])) != "C" { + return "", fmt.Errorf("Windows does not support destinations not on the system drive (C:)") + } + dest = dest[2:] // Strip the drive letter + } + + // Cannot handle relative where WorkingDir is not the system drive. + if len(workingDir) > 0 { + if ((len(workingDir) > 1) && !system.IsAbs(workingDir[2:])) || (len(workingDir) == 1) { + return "", fmt.Errorf("Current WorkingDir %s is not platform consistent", workingDir) + } + if !system.IsAbs(dest) { + if string(workingDir[0]) != "C" { + return "", fmt.Errorf("Windows does not support relative paths when WORKDIR is not the system drive") + } + dest = filepath.Join(string(os.PathSeparator), workingDir[2:], dest) + // Make sure we preserve any trailing slash + if endsInSlash { + dest += string(os.PathSeparator) + } + } + } + return dest, nil +} + // For backwards compat, if there's just one info then use it as the // cache look-up string, otherwise hash 'em all into one func getSourceHashFromInfos(infos []copyInfo) string { @@ -243,8 +457,7 @@ func (b *Builder) probeCache(dispatchState *dispatchState, runConfig *container. } fmt.Fprint(b.Stdout, " ---> Using cache\n") - dispatchState.imageID = string(cachedID) - b.buildStages.update(dispatchState.imageID) + dispatchState.imageID = cachedID return true, nil } @@ -298,3 +511,19 @@ func hostConfigFromOptions(options *types.ImageBuildOptions) *container.HostConf ExtraHosts: options.ExtraHosts, } } + +// fromSlash works like filepath.FromSlash but with a given OS platform field +func fromSlash(path, platform string) string { + if platform == "windows" { + return strings.Replace(path, "/", "\\", -1) + } + return path +} + +// separator returns a OS path separator for the given OS platform +func separator(platform string) byte { + if platform == "windows" { + return '\\' + } + return '/' +} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/internals_test.go b/vendor/github.com/docker/docker/builder/dockerfile/internals_test.go index 8073cc671..ed7b4cdaf 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/internals_test.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/internals_test.go @@ -2,6 +2,8 @@ package dockerfile import ( "fmt" + "os" + "path/filepath" "runtime" "testing" @@ -11,6 +13,7 @@ import ( "github.com/docker/docker/builder" "github.com/docker/docker/builder/remotecontext" "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/idtools" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -129,3 +132,130 @@ func TestCopyRunConfig(t *testing.T) { } } + +func TestChownFlagParsing(t *testing.T) { + testFiles := map[string]string{ + "passwd": `root:x:0:0::/bin:/bin/false +bin:x:1:1::/bin:/bin/false +wwwwww:x:21:33::/bin:/bin/false +unicorn:x:1001:1002::/bin:/bin/false + `, + "group": `root:x:0: +bin:x:1: +wwwwww:x:33: +unicorn:x:1002: +somegrp:x:5555: +othergrp:x:6666: + `, + } + // test mappings for validating use of maps + idMaps := []idtools.IDMap{ + { + ContainerID: 0, + HostID: 100000, + Size: 65536, + }, + } + remapped := idtools.NewIDMappingsFromMaps(idMaps, idMaps) + unmapped := &idtools.IDMappings{} + + contextDir, cleanup := createTestTempDir(t, "", "builder-chown-parse-test") + defer cleanup() + + if err := os.Mkdir(filepath.Join(contextDir, "etc"), 0755); err != nil { + t.Fatalf("error creating test directory: %v", err) + } + + for filename, content := range testFiles { + createTestTempFile(t, filepath.Join(contextDir, "etc"), filename, content, 0644) + } + + // positive tests + for _, testcase := range []struct { + name string + chownStr string + idMapping *idtools.IDMappings + expected idtools.IDPair + }{ + { + name: "UIDNoMap", + chownStr: "1", + idMapping: unmapped, + expected: idtools.IDPair{UID: 1, GID: 1}, + }, + { + name: "UIDGIDNoMap", + chownStr: "0:1", + idMapping: unmapped, + expected: idtools.IDPair{UID: 0, GID: 1}, + }, + { + name: "UIDWithMap", + chownStr: "0", + idMapping: remapped, + expected: idtools.IDPair{UID: 100000, GID: 100000}, + }, + { + name: "UIDGIDWithMap", + chownStr: "1:33", + idMapping: remapped, + expected: idtools.IDPair{UID: 100001, GID: 100033}, + }, + { + name: "UserNoMap", + chownStr: "bin:5555", + idMapping: unmapped, + expected: idtools.IDPair{UID: 1, GID: 5555}, + }, + { + name: "GroupWithMap", + chownStr: "0:unicorn", + idMapping: remapped, + expected: idtools.IDPair{UID: 100000, GID: 101002}, + }, + { + name: "UserOnlyWithMap", + chownStr: "unicorn", + idMapping: remapped, + expected: idtools.IDPair{UID: 101001, GID: 101002}, + }, + } { + t.Run(testcase.name, func(t *testing.T) { + idPair, err := parseChownFlag(testcase.chownStr, contextDir, testcase.idMapping) + require.NoError(t, err, "Failed to parse chown flag: %q", testcase.chownStr) + assert.Equal(t, testcase.expected, idPair, "chown flag mapping failure") + }) + } + + // error tests + for _, testcase := range []struct { + name string + chownStr string + idMapping *idtools.IDMappings + descr string + }{ + { + name: "BadChownFlagFormat", + chownStr: "bob:1:555", + idMapping: unmapped, + descr: "invalid chown string format: bob:1:555", + }, + { + name: "UserNoExist", + chownStr: "bob", + idMapping: unmapped, + descr: "can't find uid for user bob: no such user: bob", + }, + { + name: "GroupNoExist", + chownStr: "root:bob", + idMapping: unmapped, + descr: "can't find gid for group bob: no such group: bob", + }, + } { + t.Run(testcase.name, func(t *testing.T) { + _, err := parseChownFlag(testcase.chownStr, contextDir, testcase.idMapping) + assert.EqualError(t, err, testcase.descr, "Expected error string doesn't match") + }) + } +} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/internals_unix.go b/vendor/github.com/docker/docker/builder/dockerfile/internals_unix.go deleted file mode 100644 index f4784e1cc..000000000 --- a/vendor/github.com/docker/docker/builder/dockerfile/internals_unix.go +++ /dev/null @@ -1,42 +0,0 @@ -// +build !windows - -package dockerfile - -import ( - "os" - "path/filepath" - "strings" - - "github.com/docker/docker/pkg/system" -) - -// normaliseDest normalises the destination of a COPY/ADD command in a -// platform semantically consistent way. -func normaliseDest(workingDir, requested string) (string, error) { - dest := filepath.FromSlash(requested) - endsInSlash := strings.HasSuffix(requested, string(os.PathSeparator)) - if !system.IsAbs(requested) { - dest = filepath.Join(string(os.PathSeparator), filepath.FromSlash(workingDir), dest) - // Make sure we preserve any trailing slash - if endsInSlash { - dest += string(os.PathSeparator) - } - } - return dest, nil -} - -func containsWildcards(name string) bool { - for i := 0; i < len(name); i++ { - ch := name[i] - if ch == '\\' { - i++ - } else if ch == '*' || ch == '?' || ch == '[' { - return true - } - } - return false -} - -func validateCopySourcePath(imageSource *imageMount, origPath string) error { - return nil -} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/internals_windows.go b/vendor/github.com/docker/docker/builder/dockerfile/internals_windows.go deleted file mode 100644 index bb3285925..000000000 --- a/vendor/github.com/docker/docker/builder/dockerfile/internals_windows.go +++ /dev/null @@ -1,95 +0,0 @@ -package dockerfile - -import ( - "fmt" - "os" - "path/filepath" - "strings" - - "github.com/docker/docker/pkg/system" - "github.com/pkg/errors" -) - -// normaliseDest normalises the destination of a COPY/ADD command in a -// platform semantically consistent way. -func normaliseDest(workingDir, requested string) (string, error) { - dest := filepath.FromSlash(requested) - endsInSlash := strings.HasSuffix(dest, string(os.PathSeparator)) - - // We are guaranteed that the working directory is already consistent, - // However, Windows also has, for now, the limitation that ADD/COPY can - // only be done to the system drive, not any drives that might be present - // as a result of a bind mount. - // - // So... if the path requested is Linux-style absolute (/foo or \\foo), - // we assume it is the system drive. If it is a Windows-style absolute - // (DRIVE:\\foo), error if DRIVE is not C. And finally, ensure we - // strip any configured working directories drive letter so that it - // can be subsequently legitimately converted to a Windows volume-style - // pathname. - - // Not a typo - filepath.IsAbs, not system.IsAbs on this next check as - // we only want to validate where the DriveColon part has been supplied. - if filepath.IsAbs(dest) { - if strings.ToUpper(string(dest[0])) != "C" { - return "", fmt.Errorf("Windows does not support destinations not on the system drive (C:)") - } - dest = dest[2:] // Strip the drive letter - } - - // Cannot handle relative where WorkingDir is not the system drive. - if len(workingDir) > 0 { - if ((len(workingDir) > 1) && !system.IsAbs(workingDir[2:])) || (len(workingDir) == 1) { - return "", fmt.Errorf("Current WorkingDir %s is not platform consistent", workingDir) - } - if !system.IsAbs(dest) { - if string(workingDir[0]) != "C" { - return "", fmt.Errorf("Windows does not support relative paths when WORKDIR is not the system drive") - } - dest = filepath.Join(string(os.PathSeparator), workingDir[2:], dest) - // Make sure we preserve any trailing slash - if endsInSlash { - dest += string(os.PathSeparator) - } - } - } - return dest, nil -} - -func containsWildcards(name string) bool { - for i := 0; i < len(name); i++ { - ch := name[i] - if ch == '*' || ch == '?' || ch == '[' { - return true - } - } - return false -} - -var pathBlacklist = map[string]bool{ - "c:\\": true, - "c:\\windows": true, -} - -func validateCopySourcePath(imageSource *imageMount, origPath string) error { - // validate windows paths from other images - if imageSource == nil { - return nil - } - origPath = filepath.FromSlash(origPath) - p := strings.ToLower(filepath.Clean(origPath)) - if !filepath.IsAbs(p) { - if filepath.VolumeName(p) != "" { - if p[len(p)-2:] == ":." { // case where clean returns weird c:. paths - p = p[:len(p)-1] - } - p += "\\" - } else { - p = filepath.Join("c:\\", p) - } - } - if _, blacklisted := pathBlacklist[p]; blacklisted { - return errors.New("copy from c:\\ or c:\\windows is not allowed on windows") - } - return nil -} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/internals_windows_test.go b/vendor/github.com/docker/docker/builder/dockerfile/internals_windows_test.go index b4c8d4b3c..6ecc37ba6 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/internals_windows_test.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/internals_windows_test.go @@ -6,11 +6,11 @@ import ( "fmt" "testing" - "github.com/docker/docker/pkg/testutil" + "github.com/docker/docker/internal/testutil" "github.com/stretchr/testify/assert" ) -func TestNormaliseDest(t *testing.T) { +func TestNormalizeDest(t *testing.T) { tests := []struct{ current, requested, expected, etext string }{ {``, `D:\`, ``, `Windows does not support destinations not on the system drive (C:)`}, {``, `e:/`, ``, `Windows does not support destinations not on the system drive (C:)`}, @@ -40,7 +40,7 @@ func TestNormaliseDest(t *testing.T) { } for _, testcase := range tests { msg := fmt.Sprintf("Input: %s, %s", testcase.current, testcase.requested) - actual, err := normaliseDest(testcase.current, testcase.requested) + actual, err := normalizeDest(testcase.current, testcase.requested, "windows") if testcase.etext == "" { if !assert.NoError(t, err, msg) { continue diff --git a/vendor/github.com/docker/docker/builder/dockerfile/mockbackend_test.go b/vendor/github.com/docker/docker/builder/dockerfile/mockbackend_test.go index adc22762e..0f076b532 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/mockbackend_test.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/mockbackend_test.go @@ -10,6 +10,7 @@ import ( "github.com/docker/docker/builder" containerpkg "github.com/docker/docker/container" "github.com/docker/docker/layer" + "github.com/docker/docker/pkg/containerfs" "golang.org/x/net/context" ) @@ -117,8 +118,8 @@ func (l *mockLayer) Release() error { return nil } -func (l *mockLayer) Mount() (string, error) { - return "mountPath", nil +func (l *mockLayer) Mount() (containerfs.ContainerFS, error) { + return containerfs.NewLocalContainerFS("mountPath"), nil } func (l *mockLayer) Commit(string) (builder.ReleaseableLayer, error) { diff --git a/vendor/github.com/docker/docker/builder/dockerfile/parser/line_parsers.go b/vendor/github.com/docker/docker/builder/dockerfile/parser/line_parsers.go index d0e182e8e..2c375b74e 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/parser/line_parsers.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/parser/line_parsers.go @@ -19,7 +19,7 @@ import ( ) var ( - errDockerfileNotStringArray = errors.New("When using JSON array syntax, arrays must be comprised of strings only.") + errDockerfileNotStringArray = errors.New("when using JSON array syntax, arrays must be comprised of strings only") ) const ( diff --git a/vendor/github.com/docker/docker/builder/dockerfile/parser/parser.go b/vendor/github.com/docker/docker/builder/dockerfile/parser/parser.go index 7f07ff215..4003cba46 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/parser/parser.go +++ b/vendor/github.com/docker/docker/builder/dockerfile/parser/parser.go @@ -143,7 +143,7 @@ func (d *Directive) possibleParserDirective(line string) error { if len(tecMatch) != 0 { for i, n := range tokenEscapeCommand.SubexpNames() { if n == "escapechar" { - if d.escapeSeen == true { + if d.escapeSeen { return errors.New("only one escape parser directive can be used") } d.escapeSeen = true @@ -159,7 +159,7 @@ func (d *Directive) possibleParserDirective(line string) error { if len(tpcMatch) != 0 { for i, n := range tokenPlatformCommand.SubexpNames() { if n == "platform" { - if d.platformSeen == true { + if d.platformSeen { return errors.New("only one platform parser directive can be used") } d.platformSeen = true diff --git a/vendor/github.com/docker/docker/builder/fscache/fscache_test.go b/vendor/github.com/docker/docker/builder/fscache/fscache_test.go index 3f6a1b02a..c327ec72d 100644 --- a/vendor/github.com/docker/docker/builder/fscache/fscache_test.go +++ b/vendor/github.com/docker/docker/builder/fscache/fscache_test.go @@ -36,25 +36,25 @@ func TestFSCache(t *testing.T) { src1, err := fscache.SyncFrom(context.TODO(), &testIdentifier{"foo", "data", "bar"}) assert.Nil(t, err) - dt, err := ioutil.ReadFile(filepath.Join(src1.Root(), "foo")) + dt, err := ioutil.ReadFile(filepath.Join(src1.Root().Path(), "foo")) assert.Nil(t, err) assert.Equal(t, string(dt), "data") // same id doesn't recalculate anything src2, err := fscache.SyncFrom(context.TODO(), &testIdentifier{"foo", "data2", "bar"}) assert.Nil(t, err) - assert.Equal(t, src1.Root(), src2.Root()) + assert.Equal(t, src1.Root().Path(), src2.Root().Path()) - dt, err = ioutil.ReadFile(filepath.Join(src1.Root(), "foo")) + dt, err = ioutil.ReadFile(filepath.Join(src1.Root().Path(), "foo")) assert.Nil(t, err) assert.Equal(t, string(dt), "data") assert.Nil(t, src2.Close()) src3, err := fscache.SyncFrom(context.TODO(), &testIdentifier{"foo2", "data2", "bar"}) assert.Nil(t, err) - assert.NotEqual(t, src1.Root(), src3.Root()) + assert.NotEqual(t, src1.Root().Path(), src3.Root().Path()) - dt, err = ioutil.ReadFile(filepath.Join(src3.Root(), "foo2")) + dt, err = ioutil.ReadFile(filepath.Join(src3.Root().Path(), "foo2")) assert.Nil(t, err) assert.Equal(t, string(dt), "data2") @@ -71,12 +71,12 @@ func TestFSCache(t *testing.T) { // new upload with the same shared key shoutl overwrite src4, err := fscache.SyncFrom(context.TODO(), &testIdentifier{"foo3", "data3", "bar"}) assert.Nil(t, err) - assert.NotEqual(t, src1.Root(), src3.Root()) + assert.NotEqual(t, src1.Root().Path(), src3.Root().Path()) - dt, err = ioutil.ReadFile(filepath.Join(src3.Root(), "foo3")) + dt, err = ioutil.ReadFile(filepath.Join(src3.Root().Path(), "foo3")) assert.Nil(t, err) assert.Equal(t, string(dt), "data3") - assert.Equal(t, src4.Root(), src3.Root()) + assert.Equal(t, src4.Root().Path(), src3.Root().Path()) assert.Nil(t, src4.Close()) s, err = fscache.DiskUsage() diff --git a/vendor/github.com/docker/docker/builder/remotecontext/archive.go b/vendor/github.com/docker/docker/builder/remotecontext/archive.go index f48cafecd..fc18c5da3 100644 --- a/vendor/github.com/docker/docker/builder/remotecontext/archive.go +++ b/vendor/github.com/docker/docker/builder/remotecontext/archive.go @@ -8,19 +8,19 @@ import ( "github.com/docker/docker/builder" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/chrootarchive" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/ioutils" - "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/pkg/tarsum" "github.com/pkg/errors" ) type archiveContext struct { - root string + root containerfs.ContainerFS sums tarsum.FileInfoSums } func (c *archiveContext) Close() error { - return os.RemoveAll(c.root) + return c.root.RemoveAll(c.root.Path()) } func convertPathError(err error, cleanpath string) error { @@ -52,7 +52,8 @@ func FromArchive(tarStream io.Reader) (builder.Source, error) { return nil, err } - tsc := &archiveContext{root: root} + // Assume local file system. Since it's coming from a tar file. + tsc := &archiveContext{root: containerfs.NewLocalContainerFS(root)} // Make sure we clean-up upon error. In the happy case the caller // is expected to manage the clean-up @@ -82,7 +83,7 @@ func FromArchive(tarStream io.Reader) (builder.Source, error) { return tsc, nil } -func (c *archiveContext) Root() string { +func (c *archiveContext) Root() containerfs.ContainerFS { return c.root } @@ -91,7 +92,7 @@ func (c *archiveContext) Remove(path string) error { if err != nil { return err } - return os.RemoveAll(fullpath) + return c.root.RemoveAll(fullpath) } func (c *archiveContext) Hash(path string) (string, error) { @@ -100,7 +101,7 @@ func (c *archiveContext) Hash(path string) (string, error) { return "", err } - rel, err := filepath.Rel(c.root, fullpath) + rel, err := c.root.Rel(c.root.Path(), fullpath) if err != nil { return "", convertPathError(err, cleanpath) } @@ -115,13 +116,13 @@ func (c *archiveContext) Hash(path string) (string, error) { return path, nil // backwards compat TODO: see if really needed } -func normalize(path, root string) (cleanPath, fullPath string, err error) { - cleanPath = filepath.Clean(string(os.PathSeparator) + path)[1:] - fullPath, err = symlink.FollowSymlinkInScope(filepath.Join(root, path), root) +func normalize(path string, root containerfs.ContainerFS) (cleanPath, fullPath string, err error) { + cleanPath = root.Clean(string(root.Separator()) + path)[1:] + fullPath, err = root.ResolveScopedPath(path, true) if err != nil { return "", "", errors.Wrapf(err, "forbidden path outside the build context: %s (%s)", path, cleanPath) } - if _, err := os.Lstat(fullPath); err != nil { + if _, err := root.Lstat(fullPath); err != nil { return "", "", errors.WithStack(convertPathError(err, path)) } return diff --git a/vendor/github.com/docker/docker/builder/remotecontext/detect.go b/vendor/github.com/docker/docker/builder/remotecontext/detect.go index ec32dbed7..38aff6798 100644 --- a/vendor/github.com/docker/docker/builder/remotecontext/detect.go +++ b/vendor/github.com/docker/docker/builder/remotecontext/detect.go @@ -5,15 +5,14 @@ import ( "fmt" "io" "os" - "path/filepath" "strings" + "github.com/containerd/continuity/driver" "github.com/docker/docker/api/types/backend" "github.com/docker/docker/builder" "github.com/docker/docker/builder/dockerfile/parser" "github.com/docker/docker/builder/dockerignore" "github.com/docker/docker/pkg/fileutils" - "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/pkg/urlutil" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -157,12 +156,12 @@ func readAndParseDockerfile(name string, rc io.Reader) (*parser.Result, error) { return parser.Parse(br) } -func openAt(remote builder.Source, path string) (*os.File, error) { +func openAt(remote builder.Source, path string) (driver.File, error) { fullPath, err := FullPath(remote, path) if err != nil { return nil, err } - return os.Open(fullPath) + return remote.Root().Open(fullPath) } // StatAt is a helper for calling Stat on a path from a source @@ -171,12 +170,12 @@ func StatAt(remote builder.Source, path string) (os.FileInfo, error) { if err != nil { return nil, err } - return os.Stat(fullPath) + return remote.Root().Stat(fullPath) } // FullPath is a helper for getting a full path for a path from a source func FullPath(remote builder.Source, path string) (string, error) { - fullPath, err := symlink.FollowSymlinkInScope(filepath.Join(remote.Root(), path), remote.Root()) + fullPath, err := remote.Root().ResolveScopedPath(path, true) if err != nil { return "", fmt.Errorf("Forbidden path outside the build context: %s (%s)", path, fullPath) // backwards compat with old error } diff --git a/vendor/github.com/docker/docker/builder/remotecontext/detect_test.go b/vendor/github.com/docker/docker/builder/remotecontext/detect_test.go index 6b47ac227..3d1ebd1c3 100644 --- a/vendor/github.com/docker/docker/builder/remotecontext/detect_test.go +++ b/vendor/github.com/docker/docker/builder/remotecontext/detect_test.go @@ -5,11 +5,11 @@ import ( "io/ioutil" "log" "os" - "path/filepath" "sort" "testing" "github.com/docker/docker/builder" + "github.com/docker/docker/pkg/containerfs" ) const ( @@ -21,7 +21,7 @@ const ( const shouldStayFilename = "should_stay" func extractFilenames(files []os.FileInfo) []string { - filenames := make([]string, len(files), len(files)) + filenames := make([]string, len(files)) for i, file := range files { filenames[i] = file.Name() @@ -53,7 +53,7 @@ func checkDirectory(t *testing.T, dir string, expectedFiles []string) { } func executeProcess(t *testing.T, contextDir string) { - modifiableCtx := &stubRemote{root: contextDir} + modifiableCtx := &stubRemote{root: containerfs.NewLocalContainerFS(contextDir)} err := removeDockerfile(modifiableCtx, builder.DefaultDockerfileName) @@ -105,19 +105,19 @@ func TestProcessShouldLeaveAllFiles(t *testing.T) { // TODO: remove after moving to a separate pkg type stubRemote struct { - root string + root containerfs.ContainerFS } func (r *stubRemote) Hash(path string) (string, error) { return "", errors.New("not implemented") } -func (r *stubRemote) Root() string { +func (r *stubRemote) Root() containerfs.ContainerFS { return r.root } func (r *stubRemote) Close() error { return errors.New("not implemented") } func (r *stubRemote) Remove(p string) error { - return os.Remove(filepath.Join(r.root, p)) + return r.root.Remove(r.root.Join(r.root.Path(), p)) } diff --git a/vendor/github.com/docker/docker/builder/remotecontext/errors.go b/vendor/github.com/docker/docker/builder/remotecontext/errors.go new file mode 100644 index 000000000..8ee33bc60 --- /dev/null +++ b/vendor/github.com/docker/docker/builder/remotecontext/errors.go @@ -0,0 +1,75 @@ +package remotecontext + +type notFoundError string + +func (e notFoundError) Error() string { + return string(e) +} + +func (notFoundError) NotFound() {} + +type requestError string + +func (e requestError) Error() string { + return string(e) +} + +func (e requestError) InvalidParameter() {} + +type unauthorizedError string + +func (e unauthorizedError) Error() string { + return string(e) +} + +func (unauthorizedError) Unauthorized() {} + +type forbiddenError string + +func (e forbiddenError) Error() string { + return string(e) +} + +func (forbiddenError) Forbidden() {} + +type dnsError struct { + cause error +} + +func (e dnsError) Error() string { + return e.cause.Error() +} + +func (e dnsError) NotFound() {} + +func (e dnsError) Cause() error { + return e.cause +} + +type systemError struct { + cause error +} + +func (e systemError) Error() string { + return e.cause.Error() +} + +func (e systemError) SystemError() {} + +func (e systemError) Cause() error { + return e.cause +} + +type unknownError struct { + cause error +} + +func (e unknownError) Error() string { + return e.cause.Error() +} + +func (unknownError) Unknown() {} + +func (e unknownError) Cause() error { + return e.cause +} diff --git a/vendor/github.com/docker/docker/builder/remotecontext/lazycontext.go b/vendor/github.com/docker/docker/builder/remotecontext/lazycontext.go index b29c413fa..66f36defd 100644 --- a/vendor/github.com/docker/docker/builder/remotecontext/lazycontext.go +++ b/vendor/github.com/docker/docker/builder/remotecontext/lazycontext.go @@ -3,11 +3,10 @@ package remotecontext import ( "encoding/hex" "os" - "path/filepath" - "runtime" "strings" "github.com/docker/docker/builder" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/pools" "github.com/pkg/errors" ) @@ -15,7 +14,7 @@ import ( // NewLazySource creates a new LazyContext. LazyContext defines a hashed build // context based on a root directory. Individual files are hashed first time // they are asked. It is not safe to call methods of LazyContext concurrently. -func NewLazySource(root string) (builder.Source, error) { +func NewLazySource(root containerfs.ContainerFS) (builder.Source, error) { return &lazySource{ root: root, sums: make(map[string]string), @@ -23,11 +22,11 @@ func NewLazySource(root string) (builder.Source, error) { } type lazySource struct { - root string + root containerfs.ContainerFS sums map[string]string } -func (c *lazySource) Root() string { +func (c *lazySource) Root() containerfs.ContainerFS { return c.root } @@ -41,7 +40,7 @@ func (c *lazySource) Hash(path string) (string, error) { return "", err } - fi, err := os.Lstat(fullPath) + fi, err := c.root.Lstat(fullPath) if err != nil { return "", errors.WithStack(err) } @@ -63,13 +62,13 @@ func (c *lazySource) Hash(path string) (string, error) { } func (c *lazySource) prepareHash(relPath string, fi os.FileInfo) (string, error) { - p := filepath.Join(c.root, relPath) + p := c.root.Join(c.root.Path(), relPath) h, err := NewFileHash(p, relPath, fi) if err != nil { return "", errors.Wrapf(err, "failed to create hash for %s", relPath) } if fi.Mode().IsRegular() && fi.Size() > 0 { - f, err := os.Open(p) + f, err := c.root.Open(p) if err != nil { return "", errors.Wrapf(err, "failed to open %s", relPath) } @@ -85,10 +84,10 @@ func (c *lazySource) prepareHash(relPath string, fi os.FileInfo) (string, error) // Rel makes a path relative to base path. Same as `filepath.Rel` but can also // handle UUID paths in windows. -func Rel(basepath, targpath string) (string, error) { +func Rel(basepath containerfs.ContainerFS, targpath string) (string, error) { // filepath.Rel can't handle UUID paths in windows - if runtime.GOOS == "windows" { - pfx := basepath + `\` + if basepath.OS() == "windows" { + pfx := basepath.Path() + `\` if strings.HasPrefix(targpath, pfx) { p := strings.TrimPrefix(targpath, pfx) if p == "" { @@ -97,5 +96,5 @@ func Rel(basepath, targpath string) (string, error) { return p, nil } } - return filepath.Rel(basepath, targpath) + return basepath.Rel(basepath.Path(), targpath) } diff --git a/vendor/github.com/docker/docker/builder/remotecontext/remote.go b/vendor/github.com/docker/docker/builder/remotecontext/remote.go index 4afd516be..6c4073bd4 100644 --- a/vendor/github.com/docker/docker/builder/remotecontext/remote.go +++ b/vendor/github.com/docker/docker/builder/remotecontext/remote.go @@ -5,7 +5,9 @@ import ( "fmt" "io" "io/ioutil" + "net" "net/http" + "net/url" "regexp" "github.com/docker/docker/builder" @@ -68,20 +70,37 @@ func MakeRemoteContext(remoteURL string, contentTypeHandlers map[string]func(io. // GetWithStatusError does an http.Get() and returns an error if the // status code is 4xx or 5xx. -func GetWithStatusError(url string) (resp *http.Response, err error) { - if resp, err = http.Get(url); err != nil { - return nil, err +func GetWithStatusError(address string) (resp *http.Response, err error) { + if resp, err = http.Get(address); err != nil { + if uerr, ok := err.(*url.Error); ok { + if derr, ok := uerr.Err.(*net.DNSError); ok && !derr.IsTimeout { + return nil, dnsError{err} + } + } + return nil, systemError{err} } if resp.StatusCode < 400 { return resp, nil } - msg := fmt.Sprintf("failed to GET %s with status %s", url, resp.Status) + msg := fmt.Sprintf("failed to GET %s with status %s", address, resp.Status) body, err := ioutil.ReadAll(resp.Body) resp.Body.Close() if err != nil { - return nil, errors.Wrapf(err, msg+": error reading body") + return nil, errors.Wrap(systemError{err}, msg+": error reading body") + } + + msg += ": " + string(bytes.TrimSpace(body)) + switch resp.StatusCode { + case http.StatusNotFound: + return nil, notFoundError(msg) + case http.StatusBadRequest: + return nil, requestError(msg) + case http.StatusUnauthorized: + return nil, unauthorizedError(msg) + case http.StatusForbidden: + return nil, forbiddenError(msg) } - return nil, errors.Errorf(msg+": %s", bytes.TrimSpace(body)) + return nil, unknownError{errors.New(msg)} } // inspectResponse looks into the http response data at r to determine whether its @@ -91,19 +110,19 @@ func GetWithStatusError(url string) (resp *http.Response, err error) { // - an io.Reader for the response body // - an error value which will be non-nil either when something goes wrong while // reading bytes from r or when the detected content-type is not acceptable. -func inspectResponse(ct string, r io.ReadCloser, clen int64) (string, io.ReadCloser, error) { +func inspectResponse(ct string, r io.Reader, clen int64) (string, io.ReadCloser, error) { plen := clen if plen <= 0 || plen > maxPreambleLength { plen = maxPreambleLength } - preamble := make([]byte, plen, plen) + preamble := make([]byte, plen) rlen, err := r.Read(preamble) if rlen == 0 { - return ct, r, errors.New("empty response") + return ct, ioutil.NopCloser(r), errors.New("empty response") } if err != nil && err != io.EOF { - return ct, r, err + return ct, ioutil.NopCloser(r), err } preambleR := bytes.NewReader(preamble[:rlen]) diff --git a/vendor/github.com/docker/docker/builder/remotecontext/remote_test.go b/vendor/github.com/docker/docker/builder/remotecontext/remote_test.go index c698726e8..c38433b34 100644 --- a/vendor/github.com/docker/docker/builder/remotecontext/remote_test.go +++ b/vendor/github.com/docker/docker/builder/remotecontext/remote_test.go @@ -10,8 +10,8 @@ import ( "testing" "github.com/docker/docker/builder" + "github.com/docker/docker/internal/testutil" "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/pkg/testutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -253,7 +253,7 @@ func TestGetWithStatusError(t *testing.T) { if testcase.expectedErr == "" { require.NoError(t, err) - body, err := testutil.ReadBody(response.Body) + body, err := readBody(response.Body) require.NoError(t, err) assert.Contains(t, string(body), testcase.expectedBody) } else { @@ -261,3 +261,8 @@ func TestGetWithStatusError(t *testing.T) { } } } + +func readBody(b io.ReadCloser) ([]byte, error) { + defer b.Close() + return ioutil.ReadAll(b) +} diff --git a/vendor/github.com/docker/docker/builder/remotecontext/tarsum.go b/vendor/github.com/docker/docker/builder/remotecontext/tarsum.go index 3ae9d8242..6770eed87 100644 --- a/vendor/github.com/docker/docker/builder/remotecontext/tarsum.go +++ b/vendor/github.com/docker/docker/builder/remotecontext/tarsum.go @@ -3,11 +3,11 @@ package remotecontext import ( "fmt" "os" - "path/filepath" "sync" - "github.com/docker/docker/pkg/symlink" iradix "github.com/hashicorp/go-immutable-radix" + + "github.com/docker/docker/pkg/containerfs" "github.com/pkg/errors" "github.com/tonistiigi/fsutil" ) @@ -19,7 +19,7 @@ type hashed interface { // CachableSource is a source that contains cache records for its contents type CachableSource struct { mu sync.Mutex - root string + root containerfs.ContainerFS tree *iradix.Tree txn *iradix.Txn } @@ -28,7 +28,7 @@ type CachableSource struct { func NewCachableSource(root string) *CachableSource { ts := &CachableSource{ tree: iradix.New(), - root: root, + root: containerfs.NewLocalContainerFS(root), } return ts } @@ -67,7 +67,7 @@ func (cs *CachableSource) Scan() error { return err } txn := iradix.New().Txn() - err = filepath.Walk(cs.root, func(path string, info os.FileInfo, err error) error { + err = cs.root.Walk(cs.root.Path(), func(path string, info os.FileInfo, err error) error { if err != nil { return errors.Wrapf(err, "failed to walk %s", path) } @@ -134,12 +134,12 @@ func (cs *CachableSource) Close() error { } func (cs *CachableSource) normalize(path string) (cleanpath, fullpath string, err error) { - cleanpath = filepath.Clean(string(os.PathSeparator) + path)[1:] - fullpath, err = symlink.FollowSymlinkInScope(filepath.Join(cs.root, path), cs.root) + cleanpath = cs.root.Clean(string(cs.root.Separator()) + path)[1:] + fullpath, err = cs.root.ResolveScopedPath(path, true) if err != nil { return "", "", fmt.Errorf("Forbidden path outside the context: %s (%s)", path, fullpath) } - _, err = os.Lstat(fullpath) + _, err = cs.root.Lstat(fullpath) if err != nil { return "", "", convertPathError(err, path) } @@ -149,19 +149,16 @@ func (cs *CachableSource) normalize(path string) (cleanpath, fullpath string, er // Hash returns a hash for a single file in the source func (cs *CachableSource) Hash(path string) (string, error) { n := cs.getRoot() - sum := "" // TODO: check this for symlinks v, ok := n.Get([]byte(path)) if !ok { - sum = path - } else { - sum = v.(*fileInfo).sum + return path, nil } - return sum, nil + return v.(*fileInfo).sum, nil } // Root returns a root directory for the source -func (cs *CachableSource) Root() string { +func (cs *CachableSource) Root() containerfs.ContainerFS { return cs.root } diff --git a/vendor/github.com/docker/docker/builder/remotecontext/tarsum.pb.go b/vendor/github.com/docker/docker/builder/remotecontext/tarsum.pb.go index 561a7f636..1d23bbe65 100644 --- a/vendor/github.com/docker/docker/builder/remotecontext/tarsum.pb.go +++ b/vendor/github.com/docker/docker/builder/remotecontext/tarsum.pb.go @@ -94,7 +94,7 @@ func (this *TarsumBackup) GoString() string { s := make([]string, 0, 5) s = append(s, "&remotecontext.TarsumBackup{") keysForHashes := make([]string, 0, len(this.Hashes)) - for k, _ := range this.Hashes { + for k := range this.Hashes { keysForHashes = append(keysForHashes, k) } github_com_gogo_protobuf_sortkeys.Strings(keysForHashes) @@ -133,7 +133,7 @@ func (m *TarsumBackup) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if len(m.Hashes) > 0 { - for k, _ := range m.Hashes { + for k := range m.Hashes { dAtA[i] = 0xa i++ v := m.Hashes[k] @@ -211,7 +211,7 @@ func (this *TarsumBackup) String() string { return "nil" } keysForHashes := make([]string, 0, len(this.Hashes)) - for k, _ := range this.Hashes { + for k := range this.Hashes { keysForHashes = append(keysForHashes, k) } github_com_gogo_protobuf_sortkeys.Strings(keysForHashes) diff --git a/vendor/github.com/docker/docker/builder/remotecontext/tarsum_test.go b/vendor/github.com/docker/docker/builder/remotecontext/tarsum_test.go index 8a9d69bb7..6d2b41d3d 100644 --- a/vendor/github.com/docker/docker/builder/remotecontext/tarsum_test.go +++ b/vendor/github.com/docker/docker/builder/remotecontext/tarsum_test.go @@ -35,7 +35,7 @@ func TestCloseRootDirectory(t *testing.T) { t.Fatalf("Error while executing Close: %s", err) } - _, err = os.Stat(src.Root()) + _, err = os.Stat(src.Root().Path()) if !os.IsNotExist(err) { t.Fatal("Directory should not exist at this point") diff --git a/vendor/github.com/docker/docker/client/checkpoint_list.go b/vendor/github.com/docker/docker/client/checkpoint_list.go index ffe44bc97..9835bad5c 100644 --- a/vendor/github.com/docker/docker/client/checkpoint_list.go +++ b/vendor/github.com/docker/docker/client/checkpoint_list.go @@ -2,7 +2,6 @@ package client import ( "encoding/json" - "net/http" "net/url" "github.com/docker/docker/api/types" @@ -20,10 +19,7 @@ func (cli *Client) CheckpointList(ctx context.Context, container string, options resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", query, nil) if err != nil { - if resp.statusCode == http.StatusNotFound { - return checkpoints, containerNotFoundError{container} - } - return checkpoints, err + return checkpoints, wrapResponseError(err, resp, "container", container) } err = json.NewDecoder(resp.body).Decode(&checkpoints) diff --git a/vendor/github.com/docker/docker/client/client.go b/vendor/github.com/docker/docker/client/client.go index c4e3914b1..2072b2f80 100644 --- a/vendor/github.com/docker/docker/client/client.go +++ b/vendor/github.com/docker/docker/client/client.go @@ -1,10 +1,6 @@ /* Package client is a Go client for the Docker Engine API. -The "docker" command uses this package to communicate with the daemon. It can also -be used by your own Go applications to do anything the command-line interface does -- running containers, pulling images, managing swarms, etc. - For more information about the Engine API, see the documentation: https://docs.docker.com/engine/reference/api/ @@ -51,6 +47,7 @@ import ( "net/http" "net/url" "os" + "path" "path/filepath" "strings" @@ -159,7 +156,7 @@ func NewEnvClient() (*Client, error) { // highly recommended that you set a version or your client may break if the // server is upgraded. func NewClient(host string, version string, client *http.Client, httpHeaders map[string]string) (*Client, error) { - proto, addr, basePath, err := ParseHost(host) + hostURL, err := ParseHostURL(host) if err != nil { return nil, err } @@ -170,7 +167,7 @@ func NewClient(host string, version string, client *http.Client, httpHeaders map } } else { transport := new(http.Transport) - sockets.ConfigureTransport(transport, proto, addr) + sockets.ConfigureTransport(transport, hostURL.Scheme, hostURL.Host) client = &http.Client{ Transport: transport, CheckRedirect: CheckRedirect, @@ -188,28 +185,24 @@ func NewClient(host string, version string, client *http.Client, httpHeaders map scheme = "https" } + // TODO: store URL instead of proto/addr/basePath return &Client{ scheme: scheme, host: host, - proto: proto, - addr: addr, - basePath: basePath, + proto: hostURL.Scheme, + addr: hostURL.Host, + basePath: hostURL.Path, client: client, version: version, customHTTPHeaders: httpHeaders, }, nil } -// Close ensures that transport.Client is closed -// especially needed while using NewClient with *http.Client = nil -// for example -// client.NewClient("unix:///var/run/docker.sock", nil, "v1.18", map[string]string{"User-Agent": "engine-api-cli-1.0"}) +// Close the transport used by the client func (cli *Client) Close() error { - if t, ok := cli.client.Transport.(*http.Transport); ok { t.CloseIdleConnections() } - return nil } @@ -219,37 +212,27 @@ func (cli *Client) getAPIPath(p string, query url.Values) string { var apiPath string if cli.version != "" { v := strings.TrimPrefix(cli.version, "v") - apiPath = cli.basePath + "/v" + v + p + apiPath = path.Join(cli.basePath, "/v"+v, p) } else { - apiPath = cli.basePath + p - } - - u := &url.URL{ - Path: apiPath, - } - if len(query) > 0 { - u.RawQuery = query.Encode() + apiPath = path.Join(cli.basePath, p) } - return u.String() + return (&url.URL{Path: apiPath, RawQuery: query.Encode()}).String() } -// ClientVersion returns the version string associated with this -// instance of the Client. Note that this value can be changed -// via the DOCKER_API_VERSION env var. -// This operation doesn't acquire a mutex. +// ClientVersion returns the API version used by this client. func (cli *Client) ClientVersion() string { return cli.version } -// NegotiateAPIVersion updates the version string associated with this -// instance of the Client to match the latest version the server supports +// NegotiateAPIVersion queries the API and updates the version to match the +// API version. Any errors are silently ignored. func (cli *Client) NegotiateAPIVersion(ctx context.Context) { ping, _ := cli.Ping(ctx) cli.NegotiateAPIVersionPing(ping) } -// NegotiateAPIVersionPing updates the version string associated with this -// instance of the Client to match the latest version the server supports +// NegotiateAPIVersionPing updates the client version to match the Ping.APIVersion +// if the ping version is less than the default version. func (cli *Client) NegotiateAPIVersionPing(p types.Ping) { if cli.manualOverride { return @@ -271,17 +254,28 @@ func (cli *Client) NegotiateAPIVersionPing(p types.Ping) { } } -// DaemonHost returns the host associated with this instance of the Client. -// This operation doesn't acquire a mutex. +// DaemonHost returns the host address used by the client func (cli *Client) DaemonHost() string { return cli.host } -// ParseHost verifies that the given host strings is valid. +// ParseHost parses a url string, validates the strings is a host url, and returns +// the parsed host as: protocol, address, and base path +// Deprecated: use ParseHostURL func ParseHost(host string) (string, string, string, error) { + hostURL, err := ParseHostURL(host) + if err != nil { + return "", "", "", err + } + return hostURL.Scheme, hostURL.Host, hostURL.Path, nil +} + +// ParseHostURL parses a url string, validates the string is a host url, and +// returns the parsed URL +func ParseHostURL(host string) (*url.URL, error) { protoAddrParts := strings.SplitN(host, "://", 2) if len(protoAddrParts) == 1 { - return "", "", "", fmt.Errorf("unable to parse docker host `%s`", host) + return nil, fmt.Errorf("unable to parse docker host `%s`", host) } var basePath string @@ -289,16 +283,19 @@ func ParseHost(host string) (string, string, string, error) { if proto == "tcp" { parsed, err := url.Parse("tcp://" + addr) if err != nil { - return "", "", "", err + return nil, err } addr = parsed.Host basePath = parsed.Path } - return proto, addr, basePath, nil + return &url.URL{ + Scheme: proto, + Host: addr, + Path: basePath, + }, nil } -// CustomHTTPHeaders returns the custom http headers associated with this -// instance of the Client. This operation doesn't acquire a mutex. +// CustomHTTPHeaders returns the custom http headers stored by the client. func (cli *Client) CustomHTTPHeaders() map[string]string { m := make(map[string]string) for k, v := range cli.customHTTPHeaders { @@ -307,8 +304,7 @@ func (cli *Client) CustomHTTPHeaders() map[string]string { return m } -// SetCustomHTTPHeaders updates the custom http headers associated with this -// instance of the Client. This operation doesn't acquire a mutex. +// SetCustomHTTPHeaders that will be set on every HTTP request made by the client. func (cli *Client) SetCustomHTTPHeaders(headers map[string]string) { cli.customHTTPHeaders = headers } diff --git a/vendor/github.com/docker/docker/client/client_mock_test.go b/vendor/github.com/docker/docker/client/client_mock_test.go index 0ab935d53..e75c3ecbf 100644 --- a/vendor/github.com/docker/docker/client/client_mock_test.go +++ b/vendor/github.com/docker/docker/client/client_mock_test.go @@ -9,6 +9,14 @@ import ( "github.com/docker/docker/api/types" ) +// transportFunc allows us to inject a mock transport for testing. We define it +// here so we can detect the tlsconfig and return nil for only this type. +type transportFunc func(*http.Request) (*http.Response, error) + +func (tf transportFunc) RoundTrip(req *http.Request) (*http.Response, error) { + return tf(req) +} + func newMockClient(doer func(*http.Request) (*http.Response, error)) *http.Client { return &http.Client{ Transport: transportFunc(doer), diff --git a/vendor/github.com/docker/docker/client/client_test.go b/vendor/github.com/docker/docker/client/client_test.go index bc911c0c4..9bde777f1 100644 --- a/vendor/github.com/docker/docker/client/client_test.go +++ b/vendor/github.com/docker/docker/client/client_test.go @@ -11,6 +11,7 @@ import ( "github.com/docker/docker/api" "github.com/docker/docker/api/types" + "github.com/docker/docker/internal/testutil" "github.com/stretchr/testify/assert" ) @@ -104,11 +105,11 @@ func TestNewEnvClient(t *testing.T) { } func TestGetAPIPath(t *testing.T) { - cases := []struct { - v string - p string - q url.Values - e string + testcases := []struct { + version string + path string + query url.Values + expected string }{ {"", "/containers/json", nil, "/containers/json"}, {"", "/containers/json", url.Values{}, "/containers/json"}, @@ -122,16 +123,10 @@ func TestGetAPIPath(t *testing.T) { {"v1.22", "/networks/kiwl$%^", nil, "/v1.22/networks/kiwl$%25%5E"}, } - for _, cs := range cases { - c, err := NewClient("unix:///var/run/docker.sock", cs.v, nil, nil) - if err != nil { - t.Fatal(err) - } - g := c.getAPIPath(cs.p, cs.q) - assert.Equal(t, g, cs.e) - - err = c.Close() - assert.NoError(t, err) + for _, testcase := range testcases { + c := Client{version: testcase.version, basePath: "/"} + actual := c.getAPIPath(testcase.path, testcase.query) + assert.Equal(t, actual, testcase.expected) } } @@ -152,7 +147,6 @@ func TestParseHost(t *testing.T) { for _, cs := range cases { p, a, b, e := ParseHost(cs.host) - // if we expected an error to be returned... if cs.err { assert.Error(t, e) } @@ -162,6 +156,43 @@ func TestParseHost(t *testing.T) { } } +func TestParseHostURL(t *testing.T) { + testcases := []struct { + host string + expected *url.URL + expectedErr string + }{ + { + host: "", + expectedErr: "unable to parse docker host", + }, + { + host: "foobar", + expectedErr: "unable to parse docker host", + }, + { + host: "foo://bar", + expected: &url.URL{Scheme: "foo", Host: "bar"}, + }, + { + host: "tcp://localhost:2476", + expected: &url.URL{Scheme: "tcp", Host: "localhost:2476"}, + }, + { + host: "tcp://localhost:2476/path", + expected: &url.URL{Scheme: "tcp", Host: "localhost:2476", Path: "/path"}, + }, + } + + for _, testcase := range testcases { + actual, err := ParseHostURL(testcase.host) + if testcase.expectedErr != "" { + testutil.ErrorContains(t, err, testcase.expectedErr) + } + assert.Equal(t, testcase.expected, actual) + } +} + func TestNewEnvClientSetsDefaultVersion(t *testing.T) { env := envToMap() defer mapToEnv(env) diff --git a/vendor/github.com/docker/docker/client/config_inspect.go b/vendor/github.com/docker/docker/client/config_inspect.go index ebb6d636c..b44d6fdd7 100644 --- a/vendor/github.com/docker/docker/client/config_inspect.go +++ b/vendor/github.com/docker/docker/client/config_inspect.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "io/ioutil" - "net/http" "github.com/docker/docker/api/types/swarm" "golang.org/x/net/context" @@ -17,10 +16,7 @@ func (cli *Client) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.C } resp, err := cli.get(ctx, "/configs/"+id, nil, nil) if err != nil { - if resp.statusCode == http.StatusNotFound { - return swarm.Config{}, nil, configNotFoundError{id} - } - return swarm.Config{}, nil, err + return swarm.Config{}, nil, wrapResponseError(err, resp, "config", id) } defer ensureReaderClosed(resp) diff --git a/vendor/github.com/docker/docker/client/config_remove.go b/vendor/github.com/docker/docker/client/config_remove.go index 726b5c853..e025d44f7 100644 --- a/vendor/github.com/docker/docker/client/config_remove.go +++ b/vendor/github.com/docker/docker/client/config_remove.go @@ -9,5 +9,5 @@ func (cli *Client) ConfigRemove(ctx context.Context, id string) error { } resp, err := cli.delete(ctx, "/configs/"+id, nil, nil) ensureReaderClosed(resp) - return err + return wrapResponseError(err, resp, "config", id) } diff --git a/vendor/github.com/docker/docker/client/container_commit.go b/vendor/github.com/docker/docker/client/container_commit.go index 531d796ee..b3b16abfd 100644 --- a/vendor/github.com/docker/docker/client/container_commit.go +++ b/vendor/github.com/docker/docker/client/container_commit.go @@ -39,7 +39,7 @@ func (cli *Client) ContainerCommit(ctx context.Context, container string, option for _, change := range options.Changes { query.Add("changes", change) } - if options.Pause != true { + if !options.Pause { query.Set("pause", "0") } diff --git a/vendor/github.com/docker/docker/client/container_create.go b/vendor/github.com/docker/docker/client/container_create.go index 6841b0b28..bd817e7fd 100644 --- a/vendor/github.com/docker/docker/client/container_create.go +++ b/vendor/github.com/docker/docker/client/container_create.go @@ -45,7 +45,7 @@ func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config serverResp, err := cli.post(ctx, "/containers/create", query, body, nil) if err != nil { if serverResp.statusCode == 404 && strings.Contains(err.Error(), "No such image") { - return response, imageNotFoundError{config.Image} + return response, objectNotFoundError{object: "image", id: config.Image} } return response, err } diff --git a/vendor/github.com/docker/docker/client/container_inspect.go b/vendor/github.com/docker/docker/client/container_inspect.go index 17f180974..a15db14be 100644 --- a/vendor/github.com/docker/docker/client/container_inspect.go +++ b/vendor/github.com/docker/docker/client/container_inspect.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "io/ioutil" - "net/http" "net/url" "github.com/docker/docker/api/types" @@ -15,10 +14,7 @@ import ( func (cli *Client) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) { serverResp, err := cli.get(ctx, "/containers/"+containerID+"/json", nil, nil) if err != nil { - if serverResp.statusCode == http.StatusNotFound { - return types.ContainerJSON{}, containerNotFoundError{containerID} - } - return types.ContainerJSON{}, err + return types.ContainerJSON{}, wrapResponseError(err, serverResp, "container", containerID) } var response types.ContainerJSON @@ -35,10 +31,7 @@ func (cli *Client) ContainerInspectWithRaw(ctx context.Context, containerID stri } serverResp, err := cli.get(ctx, "/containers/"+containerID+"/json", query, nil) if err != nil { - if serverResp.statusCode == http.StatusNotFound { - return types.ContainerJSON{}, nil, containerNotFoundError{containerID} - } - return types.ContainerJSON{}, nil, err + return types.ContainerJSON{}, nil, wrapResponseError(err, serverResp, "container", containerID) } defer ensureReaderClosed(serverResp) diff --git a/vendor/github.com/docker/docker/client/container_remove.go b/vendor/github.com/docker/docker/client/container_remove.go index 3a79590ce..070108bf3 100644 --- a/vendor/github.com/docker/docker/client/container_remove.go +++ b/vendor/github.com/docker/docker/client/container_remove.go @@ -23,5 +23,5 @@ func (cli *Client) ContainerRemove(ctx context.Context, containerID string, opti resp, err := cli.delete(ctx, "/containers/"+containerID, query, nil) ensureReaderClosed(resp) - return err + return wrapResponseError(err, resp, "container", containerID) } diff --git a/vendor/github.com/docker/docker/client/container_remove_test.go b/vendor/github.com/docker/docker/client/container_remove_test.go index 798c08b33..0eab7ee51 100644 --- a/vendor/github.com/docker/docker/client/container_remove_test.go +++ b/vendor/github.com/docker/docker/client/container_remove_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/stretchr/testify/assert" "golang.org/x/net/context" ) @@ -17,9 +18,16 @@ func TestContainerRemoveError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } err := client.ContainerRemove(context.Background(), "container_id", types.ContainerRemoveOptions{}) - if err == nil || err.Error() != "Error response from daemon: Server error" { - t.Fatalf("expected a Server Error, got %v", err) + assert.EqualError(t, err, "Error response from daemon: Server error") +} + +func TestContainerRemoveNotFoundError(t *testing.T) { + client := &Client{ + client: newMockClient(errorMock(http.StatusNotFound, "missing")), } + err := client.ContainerRemove(context.Background(), "container_id", types.ContainerRemoveOptions{}) + assert.EqualError(t, err, "Error: No such container: container_id") + assert.True(t, IsErrNotFound(err)) } func TestContainerRemove(t *testing.T) { @@ -53,7 +61,5 @@ func TestContainerRemove(t *testing.T) { RemoveVolumes: true, Force: true, }) - if err != nil { - t.Fatal(err) - } + assert.NoError(t, err) } diff --git a/vendor/github.com/docker/docker/client/errors.go b/vendor/github.com/docker/docker/client/errors.go index fc7df9f1e..cad452175 100644 --- a/vendor/github.com/docker/docker/client/errors.go +++ b/vendor/github.com/docker/docker/client/errors.go @@ -3,6 +3,8 @@ package client import ( "fmt" + "net/http" + "github.com/docker/docker/api/types/versions" "github.com/pkg/errors" ) @@ -36,93 +38,65 @@ type notFound interface { NotFound() bool // Is the error a NotFound error } -// IsErrNotFound returns true if the error is caused with an -// object (image, container, network, volume, …) is not found in the docker host. +// IsErrNotFound returns true if the error is a NotFound error, which is returned +// by the API when some object is not found. func IsErrNotFound(err error) bool { te, ok := err.(notFound) return ok && te.NotFound() } -// imageNotFoundError implements an error returned when an image is not in the docker host. -type imageNotFoundError struct { - imageID string +type objectNotFoundError struct { + object string + id string } -// NotFound indicates that this error type is of NotFound -func (e imageNotFoundError) NotFound() bool { +func (e objectNotFoundError) NotFound() bool { return true } -// Error returns a string representation of an imageNotFoundError -func (e imageNotFoundError) Error() string { - return fmt.Sprintf("Error: No such image: %s", e.imageID) +func (e objectNotFoundError) Error() string { + return fmt.Sprintf("Error: No such %s: %s", e.object, e.id) +} + +func wrapResponseError(err error, resp serverResponse, object, id string) error { + switch { + case err == nil: + return nil + case resp.statusCode == http.StatusNotFound: + return objectNotFoundError{object: object, id: id} + default: + return err + } } // IsErrImageNotFound returns true if the error is caused // when an image is not found in the docker host. +// +// Deprecated: Use IsErrNotFound func IsErrImageNotFound(err error) bool { return IsErrNotFound(err) } -// containerNotFoundError implements an error returned when a container is not in the docker host. -type containerNotFoundError struct { - containerID string -} - -// NotFound indicates that this error type is of NotFound -func (e containerNotFoundError) NotFound() bool { - return true -} - -// Error returns a string representation of a containerNotFoundError -func (e containerNotFoundError) Error() string { - return fmt.Sprintf("Error: No such container: %s", e.containerID) -} - // IsErrContainerNotFound returns true if the error is caused // when a container is not found in the docker host. +// +// Deprecated: Use IsErrNotFound func IsErrContainerNotFound(err error) bool { return IsErrNotFound(err) } -// networkNotFoundError implements an error returned when a network is not in the docker host. -type networkNotFoundError struct { - networkID string -} - -// NotFound indicates that this error type is of NotFound -func (e networkNotFoundError) NotFound() bool { - return true -} - -// Error returns a string representation of a networkNotFoundError -func (e networkNotFoundError) Error() string { - return fmt.Sprintf("Error: No such network: %s", e.networkID) -} - // IsErrNetworkNotFound returns true if the error is caused // when a network is not found in the docker host. +// +// Deprecated: Use IsErrNotFound func IsErrNetworkNotFound(err error) bool { return IsErrNotFound(err) } -// volumeNotFoundError implements an error returned when a volume is not in the docker host. -type volumeNotFoundError struct { - volumeID string -} - -// NotFound indicates that this error type is of NotFound -func (e volumeNotFoundError) NotFound() bool { - return true -} - -// Error returns a string representation of a volumeNotFoundError -func (e volumeNotFoundError) Error() string { - return fmt.Sprintf("Error: No such volume: %s", e.volumeID) -} - // IsErrVolumeNotFound returns true if the error is caused // when a volume is not found in the docker host. +// +// Deprecated: Use IsErrNotFound func IsErrVolumeNotFound(err error) bool { return IsErrNotFound(err) } @@ -144,70 +118,28 @@ func IsErrUnauthorized(err error) bool { return ok } -// nodeNotFoundError implements an error returned when a node is not found. -type nodeNotFoundError struct { - nodeID string -} - -// Error returns a string representation of a nodeNotFoundError -func (e nodeNotFoundError) Error() string { - return fmt.Sprintf("Error: No such node: %s", e.nodeID) -} - -// NotFound indicates that this error type is of NotFound -func (e nodeNotFoundError) NotFound() bool { - return true -} - // IsErrNodeNotFound returns true if the error is caused // when a node is not found. +// +// Deprecated: Use IsErrNotFound func IsErrNodeNotFound(err error) bool { - _, ok := err.(nodeNotFoundError) - return ok -} - -// serviceNotFoundError implements an error returned when a service is not found. -type serviceNotFoundError struct { - serviceID string -} - -// Error returns a string representation of a serviceNotFoundError -func (e serviceNotFoundError) Error() string { - return fmt.Sprintf("Error: No such service: %s", e.serviceID) -} - -// NotFound indicates that this error type is of NotFound -func (e serviceNotFoundError) NotFound() bool { - return true + return IsErrNotFound(err) } // IsErrServiceNotFound returns true if the error is caused // when a service is not found. +// +// Deprecated: Use IsErrNotFound func IsErrServiceNotFound(err error) bool { - _, ok := err.(serviceNotFoundError) - return ok -} - -// taskNotFoundError implements an error returned when a task is not found. -type taskNotFoundError struct { - taskID string -} - -// Error returns a string representation of a taskNotFoundError -func (e taskNotFoundError) Error() string { - return fmt.Sprintf("Error: No such task: %s", e.taskID) -} - -// NotFound indicates that this error type is of NotFound -func (e taskNotFoundError) NotFound() bool { - return true + return IsErrNotFound(err) } // IsErrTaskNotFound returns true if the error is caused // when a task is not found. +// +// Deprecated: Use IsErrNotFound func IsErrTaskNotFound(err error) bool { - _, ok := err.(taskNotFoundError) - return ok + return IsErrNotFound(err) } type pluginPermissionDenied struct { @@ -234,67 +166,26 @@ func (cli *Client) NewVersionError(APIrequired, feature string) error { return nil } -// secretNotFoundError implements an error returned when a secret is not found. -type secretNotFoundError struct { - name string -} - -// Error returns a string representation of a secretNotFoundError -func (e secretNotFoundError) Error() string { - return fmt.Sprintf("Error: no such secret: %s", e.name) -} - -// NotFound indicates that this error type is of NotFound -func (e secretNotFoundError) NotFound() bool { - return true -} - // IsErrSecretNotFound returns true if the error is caused // when a secret is not found. +// +// Deprecated: Use IsErrNotFound func IsErrSecretNotFound(err error) bool { - _, ok := err.(secretNotFoundError) - return ok -} - -// configNotFoundError implements an error returned when a config is not found. -type configNotFoundError struct { - name string -} - -// Error returns a string representation of a configNotFoundError -func (e configNotFoundError) Error() string { - return fmt.Sprintf("Error: no such config: %s", e.name) -} - -// NotFound indicates that this error type is of NotFound -func (e configNotFoundError) NotFound() bool { - return true + return IsErrNotFound(err) } // IsErrConfigNotFound returns true if the error is caused // when a config is not found. +// +// Deprecated: Use IsErrNotFound func IsErrConfigNotFound(err error) bool { - _, ok := err.(configNotFoundError) - return ok -} - -// pluginNotFoundError implements an error returned when a plugin is not in the docker host. -type pluginNotFoundError struct { - name string -} - -// NotFound indicates that this error type is of NotFound -func (e pluginNotFoundError) NotFound() bool { - return true -} - -// Error returns a string representation of a pluginNotFoundError -func (e pluginNotFoundError) Error() string { - return fmt.Sprintf("Error: No such plugin: %s", e.name) + return IsErrNotFound(err) } // IsErrPluginNotFound returns true if the error is caused // when a plugin is not found in the docker host. +// +// Deprecated: Use IsErrNotFound func IsErrPluginNotFound(err error) bool { return IsErrNotFound(err) } diff --git a/vendor/github.com/docker/docker/client/hijack.go b/vendor/github.com/docker/docker/client/hijack.go index 8cf0119f3..d04cebdcf 100644 --- a/vendor/github.com/docker/docker/client/hijack.go +++ b/vendor/github.com/docker/docker/client/hijack.go @@ -12,7 +12,6 @@ import ( "time" "github.com/docker/docker/api/types" - "github.com/docker/docker/pkg/tlsconfig" "github.com/docker/go-connections/sockets" "github.com/pkg/errors" "golang.org/x/net/context" @@ -71,7 +70,7 @@ func tlsDialWithDialer(dialer *net.Dialer, network, addr string, config *tls.Con timeout := dialer.Timeout if !dialer.Deadline.IsZero() { - deadlineTimeout := dialer.Deadline.Sub(time.Now()) + deadlineTimeout := time.Until(dialer.Deadline) if timeout == 0 || deadlineTimeout < timeout { timeout = deadlineTimeout } @@ -115,7 +114,7 @@ func tlsDialWithDialer(dialer *net.Dialer, network, addr string, config *tls.Con // from the hostname we're connecting to. if config.ServerName == "" { // Make a copy to avoid polluting argument or default. - config = tlsconfig.Clone(config) + config = tlsConfigClone(config) config.ServerName = hostname } diff --git a/vendor/github.com/docker/docker/client/image_inspect.go b/vendor/github.com/docker/docker/client/image_inspect.go index b3a64ce2f..1bc591990 100644 --- a/vendor/github.com/docker/docker/client/image_inspect.go +++ b/vendor/github.com/docker/docker/client/image_inspect.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "io/ioutil" - "net/http" "github.com/docker/docker/api/types" "golang.org/x/net/context" @@ -14,10 +13,7 @@ import ( func (cli *Client) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) { serverResp, err := cli.get(ctx, "/images/"+imageID+"/json", nil, nil) if err != nil { - if serverResp.statusCode == http.StatusNotFound { - return types.ImageInspect{}, nil, imageNotFoundError{imageID} - } - return types.ImageInspect{}, nil, err + return types.ImageInspect{}, nil, wrapResponseError(err, serverResp, "image", imageID) } defer ensureReaderClosed(serverResp) diff --git a/vendor/github.com/docker/docker/client/image_remove.go b/vendor/github.com/docker/docker/client/image_remove.go index 6921209ee..81d6c5438 100644 --- a/vendor/github.com/docker/docker/client/image_remove.go +++ b/vendor/github.com/docker/docker/client/image_remove.go @@ -19,12 +19,12 @@ func (cli *Client) ImageRemove(ctx context.Context, imageID string, options type query.Set("noprune", "1") } + var dels []types.ImageDeleteResponseItem resp, err := cli.delete(ctx, "/images/"+imageID, query, nil) if err != nil { - return nil, err + return dels, wrapResponseError(err, resp, "image", imageID) } - var dels []types.ImageDeleteResponseItem err = json.NewDecoder(resp.body).Decode(&dels) ensureReaderClosed(resp) return dels, err diff --git a/vendor/github.com/docker/docker/client/image_remove_test.go b/vendor/github.com/docker/docker/client/image_remove_test.go index 985631130..6149db7cb 100644 --- a/vendor/github.com/docker/docker/client/image_remove_test.go +++ b/vendor/github.com/docker/docker/client/image_remove_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/stretchr/testify/assert" "golang.org/x/net/context" ) @@ -19,9 +20,17 @@ func TestImageRemoveError(t *testing.T) { } _, err := client.ImageRemove(context.Background(), "image_id", types.ImageRemoveOptions{}) - if err == nil || err.Error() != "Error response from daemon: Server error" { - t.Fatalf("expected a Server Error, got %v", err) + assert.EqualError(t, err, "Error response from daemon: Server error") +} + +func TestImageRemoveImageNotFound(t *testing.T) { + client := &Client{ + client: newMockClient(errorMock(http.StatusNotFound, "missing")), } + + _, err := client.ImageRemove(context.Background(), "unknown", types.ImageRemoveOptions{}) + assert.EqualError(t, err, "Error: No such image: unknown") + assert.True(t, IsErrNotFound(err)) } func TestImageRemove(t *testing.T) { diff --git a/vendor/github.com/docker/docker/client/image_search_test.go b/vendor/github.com/docker/docker/client/image_search_test.go index b17bbd834..191e7f403 100644 --- a/vendor/github.com/docker/docker/client/image_search_test.go +++ b/vendor/github.com/docker/docker/client/image_search_test.go @@ -2,18 +2,17 @@ package client import ( "bytes" + "encoding/json" "fmt" "io/ioutil" "net/http" "strings" "testing" - "golang.org/x/net/context" - - "encoding/json" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/registry" + "golang.org/x/net/context" ) func TestImageSearchAnyError(t *testing.T) { diff --git a/vendor/github.com/docker/docker/client/network_inspect.go b/vendor/github.com/docker/docker/client/network_inspect.go index 848c9799f..afabe6597 100644 --- a/vendor/github.com/docker/docker/client/network_inspect.go +++ b/vendor/github.com/docker/docker/client/network_inspect.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "io/ioutil" - "net/http" "net/url" "github.com/docker/docker/api/types" @@ -33,10 +32,7 @@ func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, } resp, err = cli.get(ctx, "/networks/"+networkID, query, nil) if err != nil { - if resp.statusCode == http.StatusNotFound { - return networkResource, nil, networkNotFoundError{networkID} - } - return networkResource, nil, err + return networkResource, nil, wrapResponseError(err, resp, "network", networkID) } defer ensureReaderClosed(resp) diff --git a/vendor/github.com/docker/docker/client/network_inspect_test.go b/vendor/github.com/docker/docker/client/network_inspect_test.go index 9bfb55d74..56399c7bc 100644 --- a/vendor/github.com/docker/docker/client/network_inspect_test.go +++ b/vendor/github.com/docker/docker/client/network_inspect_test.go @@ -21,20 +21,17 @@ func TestNetworkInspectError(t *testing.T) { } _, err := client.NetworkInspect(context.Background(), "nothing", types.NetworkInspectOptions{}) - if err == nil || err.Error() != "Error response from daemon: Server error" { - t.Fatalf("expected a Server Error, got %v", err) - } + assert.EqualError(t, err, "Error response from daemon: Server error") } -func TestNetworkInspectContainerNotFound(t *testing.T) { +func TestNetworkInspectNotFoundError(t *testing.T) { client := &Client{ - client: newMockClient(errorMock(http.StatusNotFound, "Server error")), + client: newMockClient(errorMock(http.StatusNotFound, "missing")), } _, err := client.NetworkInspect(context.Background(), "unknown", types.NetworkInspectOptions{}) - if err == nil || !IsErrNetworkNotFound(err) { - t.Fatalf("expected a networkNotFound error, got %v", err) - } + assert.EqualError(t, err, "Error: No such network: unknown") + assert.True(t, IsErrNotFound(err)) } func TestNetworkInspect(t *testing.T) { diff --git a/vendor/github.com/docker/docker/client/network_remove.go b/vendor/github.com/docker/docker/client/network_remove.go index 6bd674892..0811b5b51 100644 --- a/vendor/github.com/docker/docker/client/network_remove.go +++ b/vendor/github.com/docker/docker/client/network_remove.go @@ -6,5 +6,5 @@ import "golang.org/x/net/context" func (cli *Client) NetworkRemove(ctx context.Context, networkID string) error { resp, err := cli.delete(ctx, "/networks/"+networkID, nil, nil) ensureReaderClosed(resp) - return err + return wrapResponseError(err, resp, "network", networkID) } diff --git a/vendor/github.com/docker/docker/client/node_inspect.go b/vendor/github.com/docker/docker/client/node_inspect.go index abf505d29..791d2c006 100644 --- a/vendor/github.com/docker/docker/client/node_inspect.go +++ b/vendor/github.com/docker/docker/client/node_inspect.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "io/ioutil" - "net/http" "github.com/docker/docker/api/types/swarm" "golang.org/x/net/context" @@ -14,10 +13,7 @@ import ( func (cli *Client) NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error) { serverResp, err := cli.get(ctx, "/nodes/"+nodeID, nil, nil) if err != nil { - if serverResp.statusCode == http.StatusNotFound { - return swarm.Node{}, nil, nodeNotFoundError{nodeID} - } - return swarm.Node{}, nil, err + return swarm.Node{}, nil, wrapResponseError(err, serverResp, "node", nodeID) } defer ensureReaderClosed(serverResp) diff --git a/vendor/github.com/docker/docker/client/node_remove.go b/vendor/github.com/docker/docker/client/node_remove.go index 0a77f3d57..adbf52feb 100644 --- a/vendor/github.com/docker/docker/client/node_remove.go +++ b/vendor/github.com/docker/docker/client/node_remove.go @@ -17,5 +17,5 @@ func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options types. resp, err := cli.delete(ctx, "/nodes/"+nodeID, query, nil) ensureReaderClosed(resp) - return err + return wrapResponseError(err, resp, "node", nodeID) } diff --git a/vendor/github.com/docker/docker/client/parse_logs.go b/vendor/github.com/docker/docker/client/parse_logs.go deleted file mode 100644 index e427f80a7..000000000 --- a/vendor/github.com/docker/docker/client/parse_logs.go +++ /dev/null @@ -1,41 +0,0 @@ -package client - -// parse_logs.go contains utility helpers for getting information out of docker -// log lines. really, it only contains ParseDetails right now. maybe in the -// future there will be some desire to parse log messages back into a struct? -// that would go here if we did - -import ( - "net/url" - "strings" - - "github.com/pkg/errors" -) - -// ParseLogDetails takes a details string of key value pairs in the form -// "k=v,l=w", where the keys and values are url query escaped, and each pair -// is separated by a comma, returns a map. returns an error if the details -// string is not in a valid format -// the exact form of details encoding is implemented in -// api/server/httputils/write_log_stream.go -func ParseLogDetails(details string) (map[string]string, error) { - pairs := strings.Split(details, ",") - detailsMap := make(map[string]string, len(pairs)) - for _, pair := range pairs { - p := strings.SplitN(pair, "=", 2) - // if there is no equals sign, we will only get 1 part back - if len(p) != 2 { - return nil, errors.New("invalid details format") - } - k, err := url.QueryUnescape(p[0]) - if err != nil { - return nil, err - } - v, err := url.QueryUnescape(p[1]) - if err != nil { - return nil, err - } - detailsMap[k] = v - } - return detailsMap, nil -} diff --git a/vendor/github.com/docker/docker/client/parse_logs_test.go b/vendor/github.com/docker/docker/client/parse_logs_test.go deleted file mode 100644 index ac7f61679..000000000 --- a/vendor/github.com/docker/docker/client/parse_logs_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package client - -import ( - "reflect" - "testing" - - "github.com/pkg/errors" -) - -func TestParseLogDetails(t *testing.T) { - testCases := []struct { - line string - expected map[string]string - err error - }{ - {"key=value", map[string]string{"key": "value"}, nil}, - {"key1=value1,key2=value2", map[string]string{"key1": "value1", "key2": "value2"}, nil}, - {"key+with+spaces=value%3Dequals,asdf%2C=", map[string]string{"key with spaces": "value=equals", "asdf,": ""}, nil}, - {"key=,=nothing", map[string]string{"key": "", "": "nothing"}, nil}, - {"=", map[string]string{"": ""}, nil}, - {"errors", nil, errors.New("invalid details format")}, - } - for _, tc := range testCases { - tc := tc // capture range variable - t.Run(tc.line, func(t *testing.T) { - t.Parallel() - res, err := ParseLogDetails(tc.line) - if err != nil && (err.Error() != tc.err.Error()) { - t.Fatalf("unexpected error parsing logs:\nExpected:\n\t%v\nActual:\n\t%v", tc.err, err) - } - if !reflect.DeepEqual(tc.expected, res) { - t.Errorf("result does not match expected:\nExpected:\n\t%#v\nActual:\n\t%#v", tc.expected, res) - } - }) - } -} diff --git a/vendor/github.com/docker/docker/client/ping.go b/vendor/github.com/docker/docker/client/ping.go index a4c2e2c4d..0b6e450da 100644 --- a/vendor/github.com/docker/docker/client/ping.go +++ b/vendor/github.com/docker/docker/client/ping.go @@ -1,6 +1,8 @@ package client import ( + "path" + "github.com/docker/docker/api/types" "golang.org/x/net/context" ) @@ -8,7 +10,7 @@ import ( // Ping pings the server and returns the value of the "Docker-Experimental", "OS-Type" & "API-Version" headers func (cli *Client) Ping(ctx context.Context) (types.Ping, error) { var ping types.Ping - req, err := cli.buildRequest("GET", cli.basePath+"/_ping", nil, nil) + req, err := cli.buildRequest("GET", path.Join(cli.basePath, "/_ping"), nil, nil) if err != nil { return ping, err } @@ -26,7 +28,5 @@ func (cli *Client) Ping(ctx context.Context) (types.Ping, error) { } ping.OSType = serverResp.header.Get("OSType") } - - err = cli.checkResponseErr(serverResp) - return ping, err + return ping, cli.checkResponseErr(serverResp) } diff --git a/vendor/github.com/docker/docker/client/plugin_inspect.go b/vendor/github.com/docker/docker/client/plugin_inspect.go index 89f39ee2c..6a6fc18df 100644 --- a/vendor/github.com/docker/docker/client/plugin_inspect.go +++ b/vendor/github.com/docker/docker/client/plugin_inspect.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "io/ioutil" - "net/http" "github.com/docker/docker/api/types" "golang.org/x/net/context" @@ -14,10 +13,7 @@ import ( func (cli *Client) PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) { resp, err := cli.get(ctx, "/plugins/"+name+"/json", nil, nil) if err != nil { - if resp.statusCode == http.StatusNotFound { - return nil, nil, pluginNotFoundError{name} - } - return nil, nil, err + return nil, nil, wrapResponseError(err, resp, "plugin", name) } defer ensureReaderClosed(resp) diff --git a/vendor/github.com/docker/docker/client/plugin_remove.go b/vendor/github.com/docker/docker/client/plugin_remove.go index b017e4d34..b498c4820 100644 --- a/vendor/github.com/docker/docker/client/plugin_remove.go +++ b/vendor/github.com/docker/docker/client/plugin_remove.go @@ -16,5 +16,5 @@ func (cli *Client) PluginRemove(ctx context.Context, name string, options types. resp, err := cli.delete(ctx, "/plugins/"+name, query, nil) ensureReaderClosed(resp) - return err + return wrapResponseError(err, resp, "plugin", name) } diff --git a/vendor/github.com/docker/docker/client/request.go b/vendor/github.com/docker/docker/client/request.go index 3e7d43fea..615d0b989 100644 --- a/vendor/github.com/docker/docker/client/request.go +++ b/vendor/github.com/docker/docker/client/request.go @@ -203,7 +203,7 @@ func (cli *Client) checkResponseErr(serverResp serverResponse) error { return err } if len(body) == 0 { - return fmt.Errorf("Error: request returned %s for API route and version %s, check if the server supports the requested API version", http.StatusText(serverResp.statusCode), serverResp.reqURL) + return fmt.Errorf("request returned %s for API route and version %s, check if the server supports the requested API version", http.StatusText(serverResp.statusCode), serverResp.reqURL) } var ct string diff --git a/vendor/github.com/docker/docker/client/secret_inspect.go b/vendor/github.com/docker/docker/client/secret_inspect.go index 9b602972b..6927ea96f 100644 --- a/vendor/github.com/docker/docker/client/secret_inspect.go +++ b/vendor/github.com/docker/docker/client/secret_inspect.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "io/ioutil" - "net/http" "github.com/docker/docker/api/types/swarm" "golang.org/x/net/context" @@ -17,10 +16,7 @@ func (cli *Client) SecretInspectWithRaw(ctx context.Context, id string) (swarm.S } resp, err := cli.get(ctx, "/secrets/"+id, nil, nil) if err != nil { - if resp.statusCode == http.StatusNotFound { - return swarm.Secret{}, nil, secretNotFoundError{id} - } - return swarm.Secret{}, nil, err + return swarm.Secret{}, nil, wrapResponseError(err, resp, "secret", id) } defer ensureReaderClosed(resp) diff --git a/vendor/github.com/docker/docker/client/secret_remove.go b/vendor/github.com/docker/docker/client/secret_remove.go index c5e37af17..9b4ee71e2 100644 --- a/vendor/github.com/docker/docker/client/secret_remove.go +++ b/vendor/github.com/docker/docker/client/secret_remove.go @@ -9,5 +9,5 @@ func (cli *Client) SecretRemove(ctx context.Context, id string) error { } resp, err := cli.delete(ctx, "/secrets/"+id, nil, nil) ensureReaderClosed(resp) - return err + return wrapResponseError(err, resp, "secret", id) } diff --git a/vendor/github.com/docker/docker/client/service_create.go b/vendor/github.com/docker/docker/client/service_create.go index a36839443..834709d1f 100644 --- a/vendor/github.com/docker/docker/client/service_create.go +++ b/vendor/github.com/docker/docker/client/service_create.go @@ -3,11 +3,12 @@ package client import ( "encoding/json" "fmt" + "strings" "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "github.com/opencontainers/go-digest" + digest "github.com/opencontainers/go-digest" "github.com/pkg/errors" "golang.org/x/net/context" ) @@ -85,21 +86,30 @@ func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, return response, err } -func imageDigestAndPlatforms(ctx context.Context, cli *Client, image, encodedAuth string) (string, []swarm.Platform, error) { +func imageDigestAndPlatforms(ctx context.Context, cli DistributionAPIClient, image, encodedAuth string) (string, []swarm.Platform, error) { distributionInspect, err := cli.DistributionInspect(ctx, image, encodedAuth) - imageWithDigest := image var platforms []swarm.Platform if err != nil { return "", nil, err } - imageWithDigest = imageWithDigestString(image, distributionInspect.Descriptor.Digest) + imageWithDigest := imageWithDigestString(image, distributionInspect.Descriptor.Digest) if len(distributionInspect.Platforms) > 0 { platforms = make([]swarm.Platform, 0, len(distributionInspect.Platforms)) for _, p := range distributionInspect.Platforms { + // clear architecture field for arm. This is a temporary patch to address + // https://github.com/docker/swarmkit/issues/2294. The issue is that while + // image manifests report "arm" as the architecture, the node reports + // something like "armv7l" (includes the variant), which causes arm images + // to stop working with swarm mode. This patch removes the architecture + // constraint for arm images to ensure tasks get scheduled. + arch := p.Architecture + if strings.ToLower(arch) == "arm" { + arch = "" + } platforms = append(platforms, swarm.Platform{ - Architecture: p.Architecture, + Architecture: arch, OS: p.OS, }) } diff --git a/vendor/github.com/docker/docker/client/service_inspect.go b/vendor/github.com/docker/docker/client/service_inspect.go index d7e051e3a..3e9699e5e 100644 --- a/vendor/github.com/docker/docker/client/service_inspect.go +++ b/vendor/github.com/docker/docker/client/service_inspect.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io/ioutil" - "net/http" "net/url" "github.com/docker/docker/api/types" @@ -19,10 +18,7 @@ func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string, query.Set("insertDefaults", fmt.Sprintf("%v", opts.InsertDefaults)) serverResp, err := cli.get(ctx, "/services/"+serviceID, query, nil) if err != nil { - if serverResp.statusCode == http.StatusNotFound { - return swarm.Service{}, nil, serviceNotFoundError{serviceID} - } - return swarm.Service{}, nil, err + return swarm.Service{}, nil, wrapResponseError(err, serverResp, "service", serviceID) } defer ensureReaderClosed(serverResp) diff --git a/vendor/github.com/docker/docker/client/service_remove.go b/vendor/github.com/docker/docker/client/service_remove.go index a9331f92c..ad992c01d 100644 --- a/vendor/github.com/docker/docker/client/service_remove.go +++ b/vendor/github.com/docker/docker/client/service_remove.go @@ -6,5 +6,5 @@ import "golang.org/x/net/context" func (cli *Client) ServiceRemove(ctx context.Context, serviceID string) error { resp, err := cli.delete(ctx, "/services/"+serviceID, nil, nil) ensureReaderClosed(resp) - return err + return wrapResponseError(err, resp, "service", serviceID) } diff --git a/vendor/github.com/docker/docker/client/service_remove_test.go b/vendor/github.com/docker/docker/client/service_remove_test.go index 8e2ac259c..d7c51ef3d 100644 --- a/vendor/github.com/docker/docker/client/service_remove_test.go +++ b/vendor/github.com/docker/docker/client/service_remove_test.go @@ -8,6 +8,7 @@ import ( "strings" "testing" + "github.com/stretchr/testify/assert" "golang.org/x/net/context" ) @@ -17,9 +18,17 @@ func TestServiceRemoveError(t *testing.T) { } err := client.ServiceRemove(context.Background(), "service_id") - if err == nil || err.Error() != "Error response from daemon: Server error" { - t.Fatalf("expected a Server Error, got %v", err) + assert.EqualError(t, err, "Error response from daemon: Server error") +} + +func TestServiceRemoveNotFoundError(t *testing.T) { + client := &Client{ + client: newMockClient(errorMock(http.StatusNotFound, "missing")), } + + err := client.ServiceRemove(context.Background(), "service_id") + assert.EqualError(t, err, "Error: No such service: service_id") + assert.True(t, IsErrNotFound(err)) } func TestServiceRemove(t *testing.T) { diff --git a/vendor/github.com/docker/docker/client/swarm_get_unlock_key_test.go b/vendor/github.com/docker/docker/client/swarm_get_unlock_key_test.go index 8dd08d95f..fbb290aae 100644 --- a/vendor/github.com/docker/docker/client/swarm_get_unlock_key_test.go +++ b/vendor/github.com/docker/docker/client/swarm_get_unlock_key_test.go @@ -10,7 +10,7 @@ import ( "testing" "github.com/docker/docker/api/types" - "github.com/docker/docker/pkg/testutil" + "github.com/docker/docker/internal/testutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/net/context" diff --git a/vendor/github.com/docker/docker/client/task_inspect.go b/vendor/github.com/docker/docker/client/task_inspect.go index bc8058fc3..dc08cedb9 100644 --- a/vendor/github.com/docker/docker/client/task_inspect.go +++ b/vendor/github.com/docker/docker/client/task_inspect.go @@ -4,10 +4,8 @@ import ( "bytes" "encoding/json" "io/ioutil" - "net/http" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) @@ -15,10 +13,7 @@ import ( func (cli *Client) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) { serverResp, err := cli.get(ctx, "/tasks/"+taskID, nil, nil) if err != nil { - if serverResp.statusCode == http.StatusNotFound { - return swarm.Task{}, nil, taskNotFoundError{taskID} - } - return swarm.Task{}, nil, err + return swarm.Task{}, nil, wrapResponseError(err, serverResp, "task", taskID) } defer ensureReaderClosed(serverResp) diff --git a/vendor/github.com/docker/docker/client/tlsconfig_clone.go b/vendor/github.com/docker/docker/client/tlsconfig_clone.go new file mode 100644 index 000000000..99b6be1ce --- /dev/null +++ b/vendor/github.com/docker/docker/client/tlsconfig_clone.go @@ -0,0 +1,11 @@ +// +build go1.8 + +package client + +import "crypto/tls" + +// tlsConfigClone returns a clone of tls.Config. This function is provided for +// compatibility for go1.7 that doesn't include this method in stdlib. +func tlsConfigClone(c *tls.Config) *tls.Config { + return c.Clone() +} diff --git a/vendor/github.com/docker/docker/pkg/tlsconfig/tlsconfig_clone_go17.go b/vendor/github.com/docker/docker/client/tlsconfig_clone_go17.go similarity index 89% rename from vendor/github.com/docker/docker/pkg/tlsconfig/tlsconfig_clone_go17.go rename to vendor/github.com/docker/docker/client/tlsconfig_clone_go17.go index 0d5b448fe..b837b2ade 100644 --- a/vendor/github.com/docker/docker/pkg/tlsconfig/tlsconfig_clone_go17.go +++ b/vendor/github.com/docker/docker/client/tlsconfig_clone_go17.go @@ -1,12 +1,12 @@ // +build go1.7,!go1.8 -package tlsconfig +package client import "crypto/tls" -// Clone returns a clone of tls.Config. This function is provided for +// tlsConfigClone returns a clone of tls.Config. This function is provided for // compatibility for go1.7 that doesn't include this method in stdlib. -func Clone(c *tls.Config) *tls.Config { +func tlsConfigClone(c *tls.Config) *tls.Config { return &tls.Config{ Rand: c.Rand, Time: c.Time, diff --git a/vendor/github.com/docker/docker/client/transport.go b/vendor/github.com/docker/docker/client/transport.go index 401ab15d3..73f6ef7b4 100644 --- a/vendor/github.com/docker/docker/client/transport.go +++ b/vendor/github.com/docker/docker/client/transport.go @@ -5,14 +5,6 @@ import ( "net/http" ) -// transportFunc allows us to inject a mock transport for testing. We define it -// here so we can detect the tlsconfig and return nil for only this type. -type transportFunc func(*http.Request) (*http.Response, error) - -func (tf transportFunc) RoundTrip(req *http.Request) (*http.Response, error) { - return tf(req) -} - // resolveTLSConfig attempts to resolve the TLS configuration from the // RoundTripper. func resolveTLSConfig(transport http.RoundTripper) *tls.Config { diff --git a/vendor/github.com/docker/docker/client/volume_inspect.go b/vendor/github.com/docker/docker/client/volume_inspect.go index 3860e9b22..988934384 100644 --- a/vendor/github.com/docker/docker/client/volume_inspect.go +++ b/vendor/github.com/docker/docker/client/volume_inspect.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "io/ioutil" - "net/http" + "path" "github.com/docker/docker/api/types" "golang.org/x/net/context" @@ -18,13 +18,17 @@ func (cli *Client) VolumeInspect(ctx context.Context, volumeID string) (types.Vo // VolumeInspectWithRaw returns the information about a specific volume in the docker host and its raw representation func (cli *Client) VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) { + // The empty ID needs to be handled here because with an empty ID the + // request url will not contain a trailing / which calls the volume list API + // instead of volume inspect + if volumeID == "" { + return types.Volume{}, nil, objectNotFoundError{object: "volume", id: volumeID} + } + var volume types.Volume - resp, err := cli.get(ctx, "/volumes/"+volumeID, nil, nil) + resp, err := cli.get(ctx, path.Join("/volumes", volumeID), nil, nil) if err != nil { - if resp.statusCode == http.StatusNotFound { - return volume, nil, volumeNotFoundError{volumeID} - } - return volume, nil, err + return volume, nil, wrapResponseError(err, resp, "volume", volumeID) } defer ensureReaderClosed(resp) diff --git a/vendor/github.com/docker/docker/client/volume_inspect_test.go b/vendor/github.com/docker/docker/client/volume_inspect_test.go index 0d1d11882..7d01f44ed 100644 --- a/vendor/github.com/docker/docker/client/volume_inspect_test.go +++ b/vendor/github.com/docker/docker/client/volume_inspect_test.go @@ -10,6 +10,9 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/docker/docker/internal/testutil" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "golang.org/x/net/context" ) @@ -19,9 +22,7 @@ func TestVolumeInspectError(t *testing.T) { } _, err := client.VolumeInspect(context.Background(), "nothing") - if err == nil || err.Error() != "Error response from daemon: Server error" { - t.Fatalf("expected a Server Error, got %v", err) - } + testutil.ErrorContains(t, err, "Error response from daemon: Server error") } func TestVolumeInspectNotFound(t *testing.T) { @@ -30,13 +31,34 @@ func TestVolumeInspectNotFound(t *testing.T) { } _, err := client.VolumeInspect(context.Background(), "unknown") - if err == nil || !IsErrVolumeNotFound(err) { - t.Fatalf("expected a volumeNotFound error, got %v", err) + assert.True(t, IsErrNotFound(err)) +} + +func TestVolumeInspectWithEmptyID(t *testing.T) { + expectedURL := "/volumes/" + + client := &Client{ + client: newMockClient(func(req *http.Request) (*http.Response, error) { + assert.Equal(t, req.URL.Path, expectedURL) + return &http.Response{ + StatusCode: http.StatusNotFound, + Body: ioutil.NopCloser(bytes.NewReader(nil)), + }, nil + }), } + _, err := client.VolumeInspect(context.Background(), "") + testutil.ErrorContains(t, err, "No such volume: ") + } func TestVolumeInspect(t *testing.T) { expectedURL := "/volumes/volume_id" + expected := types.Volume{ + Name: "name", + Driver: "driver", + Mountpoint: "mountpoint", + } + client := &Client{ client: newMockClient(func(req *http.Request) (*http.Response, error) { if !strings.HasPrefix(req.URL.Path, expectedURL) { @@ -45,11 +67,7 @@ func TestVolumeInspect(t *testing.T) { if req.Method != "GET" { return nil, fmt.Errorf("expected GET method, got %s", req.Method) } - content, err := json.Marshal(types.Volume{ - Name: "name", - Driver: "driver", - Mountpoint: "mountpoint", - }) + content, err := json.Marshal(expected) if err != nil { return nil, err } @@ -60,17 +78,7 @@ func TestVolumeInspect(t *testing.T) { }), } - v, err := client.VolumeInspect(context.Background(), "volume_id") - if err != nil { - t.Fatal(err) - } - if v.Name != "name" { - t.Fatalf("expected `name`, got %s", v.Name) - } - if v.Driver != "driver" { - t.Fatalf("expected `driver`, got %s", v.Driver) - } - if v.Mountpoint != "mountpoint" { - t.Fatalf("expected `mountpoint`, got %s", v.Mountpoint) - } + volume, err := client.VolumeInspect(context.Background(), "volume_id") + require.NoError(t, err) + assert.Equal(t, expected, volume) } diff --git a/vendor/github.com/docker/docker/client/volume_remove.go b/vendor/github.com/docker/docker/client/volume_remove.go index 6c26575b4..3ffb8bcf2 100644 --- a/vendor/github.com/docker/docker/client/volume_remove.go +++ b/vendor/github.com/docker/docker/client/volume_remove.go @@ -17,5 +17,5 @@ func (cli *Client) VolumeRemove(ctx context.Context, volumeID string, force bool } resp, err := cli.delete(ctx, "/volumes/"+volumeID, query, nil) ensureReaderClosed(resp) - return err + return wrapResponseError(err, resp, "volume", volumeID) } diff --git a/vendor/github.com/docker/docker/cmd/dockerd/config.go b/vendor/github.com/docker/docker/cmd/dockerd/config.go index fa5565ee4..f80641b1f 100644 --- a/vendor/github.com/docker/docker/cmd/dockerd/config.go +++ b/vendor/github.com/docker/docker/cmd/dockerd/config.go @@ -5,6 +5,7 @@ import ( "github.com/docker/docker/daemon/config" "github.com/docker/docker/opts" + "github.com/docker/docker/registry" "github.com/spf13/pflag" ) @@ -19,7 +20,7 @@ const ( func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) { var maxConcurrentDownloads, maxConcurrentUploads int - conf.ServiceOptions.InstallCliFlags(flags) + installRegistryServiceFlags(&conf.ServiceOptions, flags) flags.Var(opts.NewNamedListOptsRef("storage-opts", &conf.GraphOptions, nil), "storage-opt", "Storage driver options") flags.Var(opts.NewNamedListOptsRef("authorization-plugins", &conf.AuthorizationPlugins, nil), "authorization-plugin", "Authorization plugins to load") @@ -75,3 +76,17 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) { conf.MaxConcurrentDownloads = &maxConcurrentDownloads conf.MaxConcurrentUploads = &maxConcurrentUploads } + +func installRegistryServiceFlags(options *registry.ServiceOptions, flags *pflag.FlagSet) { + ana := opts.NewNamedListOptsRef("allow-nondistributable-artifacts", &options.AllowNondistributableArtifacts, registry.ValidateIndexName) + mirrors := opts.NewNamedListOptsRef("registry-mirrors", &options.Mirrors, registry.ValidateMirror) + insecureRegistries := opts.NewNamedListOptsRef("insecure-registries", &options.InsecureRegistries, registry.ValidateIndexName) + + flags.Var(ana, "allow-nondistributable-artifacts", "Allow push of nondistributable artifacts to registry") + flags.Var(mirrors, "registry-mirror", "Preferred Docker registry mirror") + flags.Var(insecureRegistries, "insecure-registry", "Enable insecure registry communication") + + if runtime.GOOS != "windows" { + flags.BoolVar(&options.V2Only, "disable-legacy-registry", true, "Disable contacting legacy registries") + } +} diff --git a/vendor/github.com/docker/docker/cmd/dockerd/config_solaris.go b/vendor/github.com/docker/docker/cmd/dockerd/config_solaris.go index 582211c6c..ed6706490 100644 --- a/vendor/github.com/docker/docker/cmd/dockerd/config_solaris.go +++ b/vendor/github.com/docker/docker/cmd/dockerd/config_solaris.go @@ -2,8 +2,6 @@ package main import ( "github.com/docker/docker/daemon/config" - runconfigopts "github.com/docker/docker/runconfig/opts" - units "github.com/docker/go-units" "github.com/spf13/pflag" ) diff --git a/vendor/github.com/docker/docker/cmd/dockerd/config_unix.go b/vendor/github.com/docker/docker/cmd/dockerd/config_unix.go index ba37121e9..ad27a4672 100644 --- a/vendor/github.com/docker/docker/cmd/dockerd/config_unix.go +++ b/vendor/github.com/docker/docker/cmd/dockerd/config_unix.go @@ -33,8 +33,6 @@ func installConfigFlags(conf *config.Config, flags *pflag.FlagSet) { flags.StringVar(&conf.BridgeConfig.FixedCIDRv6, "fixed-cidr-v6", "", "IPv6 subnet for fixed IPs") flags.BoolVar(&conf.BridgeConfig.EnableUserlandProxy, "userland-proxy", true, "Use userland proxy for loopback traffic") flags.StringVar(&conf.BridgeConfig.UserlandProxyPath, "userland-proxy-path", "", "Path to the userland proxy binary") - flags.BoolVar(&conf.EnableCors, "api-enable-cors", false, "Enable CORS headers in the Engine API, this is deprecated by --api-cors-header") - flags.MarkDeprecated("api-enable-cors", "Please use --api-cors-header") flags.StringVar(&conf.CgroupParent, "cgroup-parent", "", "Set parent cgroup for all containers") flags.StringVar(&conf.RemappedRoot, "userns-remap", "", "User/Group setting for user namespaces") flags.StringVar(&conf.ContainerdAddr, "containerd", "", "Path to containerd socket") @@ -47,6 +45,7 @@ func installConfigFlags(conf *config.Config, flags *pflag.FlagSet) { flags.StringVar(&conf.SeccompProfile, "seccomp-profile", "", "Path to seccomp profile") flags.Var(&conf.ShmSize, "default-shm-size", "Default shm size for containers") flags.BoolVar(&conf.NoNewPrivileges, "no-new-privileges", false, "Set no-new-privileges by default for new containers") + flags.StringVar(&conf.IpcMode, "default-ipc-mode", config.DefaultIpcMode, `Default mode for containers ipc ("shareable" | "private")`) attachExperimentalFlags(conf, flags) } diff --git a/vendor/github.com/docker/docker/cmd/dockerd/daemon.go b/vendor/github.com/docker/docker/cmd/dockerd/daemon.go index b15bd2bf8..2e8acf97d 100644 --- a/vendor/github.com/docker/docker/cmd/dockerd/daemon.go +++ b/vendor/github.com/docker/docker/cmd/dockerd/daemon.go @@ -32,13 +32,13 @@ import ( "github.com/docker/docker/daemon" "github.com/docker/docker/daemon/cluster" "github.com/docker/docker/daemon/config" + "github.com/docker/docker/daemon/listeners" "github.com/docker/docker/daemon/logger" "github.com/docker/docker/dockerversion" "github.com/docker/docker/libcontainerd" dopts "github.com/docker/docker/opts" "github.com/docker/docker/pkg/authorization" "github.com/docker/docker/pkg/jsonlog" - "github.com/docker/docker/pkg/listeners" "github.com/docker/docker/pkg/pidfile" "github.com/docker/docker/pkg/plugingetter" "github.com/docker/docker/pkg/signal" @@ -99,6 +99,8 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) { FullTimestamp: true, }) + system.InitLCOW(cli.Config.Experimental) + if err := setDefaultUmask(); err != nil { return fmt.Errorf("Failed to set umask: %v", err) } @@ -132,7 +134,6 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) { Logging: true, SocketGroup: cli.Config.SocketGroup, Version: dockerversion.Version, - EnableCors: cli.Config.EnableCors, CorsHeaders: cli.Config.CorsHeaders, } @@ -198,7 +199,11 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) { cli.api.Accept(addr, ls...) } - registryService := registry.NewService(cli.Config.ServiceOptions) + registryService, err := registry.NewService(cli.Config.ServiceOptions) + if err != nil { + return err + } + containerdRemote, err := libcontainerd.New(cli.getLibcontainerdRoot(), cli.getPlatformRemoteOptions()...) if err != nil { return err @@ -453,7 +458,7 @@ func loadDaemonCliConfig(opts *daemonOptions) (*config.Config, error) { c, err := config.MergeDaemonConfigurations(conf, flags, opts.configFile) if err != nil { if flags.Changed("config-file") || !os.IsNotExist(err) { - return nil, fmt.Errorf("unable to configure the Docker daemon with file %s: %v\n", opts.configFile, err) + return nil, fmt.Errorf("unable to configure the Docker daemon with file %s: %v", opts.configFile, err) } } // the merged configuration can be nil if the config file didn't exist. @@ -467,7 +472,7 @@ func loadDaemonCliConfig(opts *daemonOptions) (*config.Config, error) { return nil, err } - if conf.V2Only == false { + if !conf.V2Only { logrus.Warnf(`The "disable-legacy-registry" option is deprecated and wil be removed in Docker v17.12. Interacting with legacy (v1) registries will no longer be supported in Docker v17.12"`) } @@ -539,7 +544,7 @@ func initRouter(opts routerOptions) { } // TODO: remove this from cli and return the authzMiddleware -func (cli *DaemonCli) initMiddlewares(s *apiserver.Server, cfg *apiserver.Config, pluginStore *plugin.Store) error { +func (cli *DaemonCli) initMiddlewares(s *apiserver.Server, cfg *apiserver.Config, pluginStore plugingetter.PluginGetter) error { v := cfg.Version exp := middleware.NewExperimentalMiddleware(cli.Config.Experimental) @@ -548,7 +553,7 @@ func (cli *DaemonCli) initMiddlewares(s *apiserver.Server, cfg *apiserver.Config vm := middleware.NewVersionMiddleware(v, api.DefaultVersion, api.MinVersion) s.UseMiddleware(vm) - if cfg.EnableCors || cfg.CorsHeaders != "" { + if cfg.CorsHeaders != "" { c := middleware.NewCORSMiddleware(cfg.CorsHeaders) s.UseMiddleware(c) } diff --git a/vendor/github.com/docker/docker/cmd/dockerd/daemon_solaris.go b/vendor/github.com/docker/docker/cmd/dockerd/daemon_solaris.go index dab4d4aaa..9ee18dad7 100644 --- a/vendor/github.com/docker/docker/cmd/dockerd/daemon_solaris.go +++ b/vendor/github.com/docker/docker/cmd/dockerd/daemon_solaris.go @@ -5,27 +5,14 @@ package main import ( "fmt" "net" - "os" "path/filepath" "github.com/docker/docker/libcontainerd" - "github.com/docker/docker/pkg/system" "golang.org/x/sys/unix" ) const defaultDaemonConfigFile = "" -// currentUserIsOwner checks whether the current user is the owner of the given -// file. -func currentUserIsOwner(f string) bool { - if fileInfo, err := system.Stat(f); err == nil && fileInfo != nil { - if int(fileInfo.UID()) == os.Getuid() { - return true - } - } - return false -} - // setDefaultUmask sets the umask to 0022 to avoid problems // caused by custom umask func setDefaultUmask() error { diff --git a/vendor/github.com/docker/docker/cmd/dockerd/daemon_test.go b/vendor/github.com/docker/docker/cmd/dockerd/daemon_test.go index 1b81aa573..c559ee82a 100644 --- a/vendor/github.com/docker/docker/cmd/dockerd/daemon_test.go +++ b/vendor/github.com/docker/docker/cmd/dockerd/daemon_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/docker/docker/daemon/config" - "github.com/docker/docker/pkg/testutil" - "github.com/docker/docker/pkg/testutil/tempfile" + "github.com/docker/docker/internal/testutil" + "github.com/gotestyourself/gotestyourself/fs" "github.com/sirupsen/logrus" "github.com/spf13/pflag" "github.com/stretchr/testify/assert" @@ -46,9 +46,9 @@ func TestLoadDaemonCliConfigWithTLS(t *testing.T) { } func TestLoadDaemonCliConfigWithConflicts(t *testing.T) { - tempFile := tempfile.NewTempFile(t, "config", `{"labels": ["l3=foo"]}`) + tempFile := fs.NewFile(t, "config", fs.WithContent(`{"labels": ["l3=foo"]}`)) defer tempFile.Remove() - configFile := tempFile.Name() + configFile := tempFile.Path() opts := defaultOptions(configFile) flags := opts.flags @@ -62,10 +62,10 @@ func TestLoadDaemonCliConfigWithConflicts(t *testing.T) { } func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) { - tempFile := tempfile.NewTempFile(t, "config", `{"tlsverify": true}`) + tempFile := fs.NewFile(t, "config", fs.WithContent(`{"tlsverify": true}`)) defer tempFile.Remove() - opts := defaultOptions(tempFile.Name()) + opts := defaultOptions(tempFile.Path()) opts.TLSOptions.CAFile = "/tmp/ca.pem" loadedConfig, err := loadDaemonCliConfig(opts) @@ -75,10 +75,10 @@ func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) { } func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) { - tempFile := tempfile.NewTempFile(t, "config", `{"tlsverify": false}`) + tempFile := fs.NewFile(t, "config", fs.WithContent(`{"tlsverify": false}`)) defer tempFile.Remove() - opts := defaultOptions(tempFile.Name()) + opts := defaultOptions(tempFile.Path()) opts.TLSOptions.CAFile = "/tmp/ca.pem" loadedConfig, err := loadDaemonCliConfig(opts) @@ -88,10 +88,10 @@ func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) { } func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) { - tempFile := tempfile.NewTempFile(t, "config", `{}`) + tempFile := fs.NewFile(t, "config", fs.WithContent(`{}`)) defer tempFile.Remove() - opts := defaultOptions(tempFile.Name()) + opts := defaultOptions(tempFile.Path()) opts.TLSOptions.CAFile = "/tmp/ca.pem" loadedConfig, err := loadDaemonCliConfig(opts) @@ -101,10 +101,10 @@ func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) { } func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) { - tempFile := tempfile.NewTempFile(t, "config", `{"log-level": "warn"}`) + tempFile := fs.NewFile(t, "config", fs.WithContent(`{"log-level": "warn"}`)) defer tempFile.Remove() - opts := defaultOptions(tempFile.Name()) + opts := defaultOptions(tempFile.Path()) loadedConfig, err := loadDaemonCliConfig(opts) require.NoError(t, err) require.NotNil(t, loadedConfig) @@ -114,10 +114,10 @@ func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) { func TestLoadDaemonConfigWithEmbeddedOptions(t *testing.T) { content := `{"tlscacert": "/etc/certs/ca.pem", "log-driver": "syslog"}` - tempFile := tempfile.NewTempFile(t, "config", content) + tempFile := fs.NewFile(t, "config", fs.WithContent(content)) defer tempFile.Remove() - opts := defaultOptions(tempFile.Name()) + opts := defaultOptions(tempFile.Path()) loadedConfig, err := loadDaemonCliConfig(opts) require.NoError(t, err) require.NotNil(t, loadedConfig) @@ -131,10 +131,10 @@ func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) { "registry-mirrors": ["https://mirrors.docker.com"], "insecure-registries": ["https://insecure.docker.com"] }` - tempFile := tempfile.NewTempFile(t, "config", content) + tempFile := fs.NewFile(t, "config", fs.WithContent(content)) defer tempFile.Remove() - opts := defaultOptions(tempFile.Name()) + opts := defaultOptions(tempFile.Path()) loadedConfig, err := loadDaemonCliConfig(opts) require.NoError(t, err) require.NotNil(t, loadedConfig) diff --git a/vendor/github.com/docker/docker/cmd/dockerd/daemon_unix_test.go b/vendor/github.com/docker/docker/cmd/dockerd/daemon_unix_test.go index ebe73362f..5d99e5105 100644 --- a/vendor/github.com/docker/docker/cmd/dockerd/daemon_unix_test.go +++ b/vendor/github.com/docker/docker/cmd/dockerd/daemon_unix_test.go @@ -9,17 +9,17 @@ import ( "testing" "github.com/docker/docker/daemon/config" - "github.com/docker/docker/pkg/testutil/tempfile" + "github.com/gotestyourself/gotestyourself/fs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) { content := `{"log-opts": {"max-size": "1k"}}` - tempFile := tempfile.NewTempFile(t, "config", content) + tempFile := fs.NewFile(t, "config", fs.WithContent(content)) defer tempFile.Remove() - opts := defaultOptions(tempFile.Name()) + opts := defaultOptions(tempFile.Path()) opts.Debug = true opts.LogLevel = "info" assert.NoError(t, opts.flags.Set("selinux-enabled", "true")) @@ -37,10 +37,10 @@ func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) { func TestLoadDaemonConfigWithNetwork(t *testing.T) { content := `{"bip": "127.0.0.2", "ip": "127.0.0.1"}` - tempFile := tempfile.NewTempFile(t, "config", content) + tempFile := fs.NewFile(t, "config", fs.WithContent(content)) defer tempFile.Remove() - opts := defaultOptions(tempFile.Name()) + opts := defaultOptions(tempFile.Path()) loadedConfig, err := loadDaemonCliConfig(opts) require.NoError(t, err) require.NotNil(t, loadedConfig) @@ -54,10 +54,10 @@ func TestLoadDaemonConfigWithMapOptions(t *testing.T) { "cluster-store-opts": {"kv.cacertfile": "/var/lib/docker/discovery_certs/ca.pem"}, "log-opts": {"tag": "test"} }` - tempFile := tempfile.NewTempFile(t, "config", content) + tempFile := fs.NewFile(t, "config", fs.WithContent(content)) defer tempFile.Remove() - opts := defaultOptions(tempFile.Name()) + opts := defaultOptions(tempFile.Path()) loadedConfig, err := loadDaemonCliConfig(opts) require.NoError(t, err) require.NotNil(t, loadedConfig) @@ -71,10 +71,10 @@ func TestLoadDaemonConfigWithMapOptions(t *testing.T) { func TestLoadDaemonConfigWithTrueDefaultValues(t *testing.T) { content := `{ "userland-proxy": false }` - tempFile := tempfile.NewTempFile(t, "config", content) + tempFile := fs.NewFile(t, "config", fs.WithContent(content)) defer tempFile.Remove() - opts := defaultOptions(tempFile.Name()) + opts := defaultOptions(tempFile.Path()) loadedConfig, err := loadDaemonCliConfig(opts) require.NoError(t, err) require.NotNil(t, loadedConfig) @@ -90,10 +90,10 @@ func TestLoadDaemonConfigWithTrueDefaultValues(t *testing.T) { } func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) { - tempFile := tempfile.NewTempFile(t, "config", `{}`) + tempFile := fs.NewFile(t, "config", fs.WithContent(`{}`)) defer tempFile.Remove() - opts := defaultOptions(tempFile.Name()) + opts := defaultOptions(tempFile.Path()) loadedConfig, err := loadDaemonCliConfig(opts) require.NoError(t, err) require.NotNil(t, loadedConfig) @@ -103,10 +103,10 @@ func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) { func TestLoadDaemonConfigWithLegacyRegistryOptions(t *testing.T) { content := `{"disable-legacy-registry": false}` - tempFile := tempfile.NewTempFile(t, "config", content) + tempFile := fs.NewFile(t, "config", fs.WithContent(content)) defer tempFile.Remove() - opts := defaultOptions(tempFile.Name()) + opts := defaultOptions(tempFile.Path()) loadedConfig, err := loadDaemonCliConfig(opts) require.NoError(t, err) require.NotNil(t, loadedConfig) diff --git a/vendor/github.com/docker/docker/cmd/dockerd/daemon_windows.go b/vendor/github.com/docker/docker/cmd/dockerd/daemon_windows.go index 7dd0920ce..77bade2de 100644 --- a/vendor/github.com/docker/docker/cmd/dockerd/daemon_windows.go +++ b/vendor/github.com/docker/docker/cmd/dockerd/daemon_windows.go @@ -7,19 +7,12 @@ import ( "path/filepath" "github.com/docker/docker/libcontainerd" - "github.com/docker/docker/pkg/system" "github.com/sirupsen/logrus" "golang.org/x/sys/windows" ) var defaultDaemonConfigFile = "" -// currentUserIsOwner checks whether the current user is the owner of the given -// file. -func currentUserIsOwner(f string) bool { - return false -} - // setDefaultUmask doesn't do anything on windows func setDefaultUmask() error { return nil @@ -61,8 +54,8 @@ func (cli *DaemonCli) setupConfigReloadTrap() { sa := windows.SecurityAttributes{ Length: 0, } - ev := "Global\\docker-daemon-config-" + fmt.Sprint(os.Getpid()) - if h, _ := system.CreateEvent(&sa, false, false, ev); h != 0 { + ev, _ := windows.UTF16PtrFromString("Global\\docker-daemon-config-" + fmt.Sprint(os.Getpid())) + if h, _ := windows.CreateEvent(&sa, 0, 0, ev); h != 0 { logrus.Debugf("Config reload - waiting signal at %s", ev) for { windows.WaitForSingleObject(h, windows.INFINITE) diff --git a/vendor/github.com/docker/docker/container/archive.go b/vendor/github.com/docker/docker/container/archive.go index 56e6598b9..ec4c236fe 100644 --- a/vendor/github.com/docker/docker/container/archive.go +++ b/vendor/github.com/docker/docker/container/archive.go @@ -2,7 +2,6 @@ package container import ( "os" - "path/filepath" "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/archive" @@ -15,17 +14,20 @@ import ( // an error if the path points to outside the container's rootfs. func (container *Container) ResolvePath(path string) (resolvedPath, absPath string, err error) { // Check if a drive letter supplied, it must be the system drive. No-op except on Windows - path, err = system.CheckSystemDriveAndRemoveDriveLetter(path) + path, err = system.CheckSystemDriveAndRemoveDriveLetter(path, container.BaseFS) if err != nil { return "", "", err } // Consider the given path as an absolute path in the container. - absPath = archive.PreserveTrailingDotOrSeparator(filepath.Join(string(filepath.Separator), path), path) + absPath = archive.PreserveTrailingDotOrSeparator( + container.BaseFS.Join(string(container.BaseFS.Separator()), path), + path, + container.BaseFS.Separator()) // Split the absPath into its Directory and Base components. We will // resolve the dir in the scope of the container then append the base. - dirPath, basePath := filepath.Split(absPath) + dirPath, basePath := container.BaseFS.Split(absPath) resolvedDirPath, err := container.GetResourcePath(dirPath) if err != nil { @@ -34,8 +36,7 @@ func (container *Container) ResolvePath(path string) (resolvedPath, absPath stri // resolvedDirPath will have been cleaned (no trailing path separators) so // we can manually join it with the base path element. - resolvedPath = resolvedDirPath + string(filepath.Separator) + basePath - + resolvedPath = resolvedDirPath + string(container.BaseFS.Separator()) + basePath return resolvedPath, absPath, nil } @@ -44,7 +45,9 @@ func (container *Container) ResolvePath(path string) (resolvedPath, absPath stri // resolved to a path on the host corresponding to the given absolute path // inside the container. func (container *Container) StatPath(resolvedPath, absPath string) (stat *types.ContainerPathStat, err error) { - lstat, err := os.Lstat(resolvedPath) + driver := container.BaseFS + + lstat, err := driver.Lstat(resolvedPath) if err != nil { return nil, err } @@ -57,17 +60,17 @@ func (container *Container) StatPath(resolvedPath, absPath string) (stat *types. return nil, err } - linkTarget, err = filepath.Rel(container.BaseFS, hostPath) + linkTarget, err = driver.Rel(driver.Path(), hostPath) if err != nil { return nil, err } // Make it an absolute path. - linkTarget = filepath.Join(string(filepath.Separator), linkTarget) + linkTarget = driver.Join(string(driver.Separator()), linkTarget) } return &types.ContainerPathStat{ - Name: filepath.Base(absPath), + Name: driver.Base(absPath), Size: lstat.Size(), Mode: lstat.Mode(), Mtime: lstat.ModTime(), diff --git a/vendor/github.com/docker/docker/container/container.go b/vendor/github.com/docker/docker/container/container.go index 23de3f581..150910f79 100644 --- a/vendor/github.com/docker/docker/container/container.go +++ b/vendor/github.com/docker/docker/container/container.go @@ -28,6 +28,7 @@ import ( "github.com/docker/docker/layer" "github.com/docker/docker/libcontainerd" "github.com/docker/docker/opts" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/signal" @@ -43,6 +44,7 @@ import ( "github.com/docker/libnetwork/options" "github.com/docker/libnetwork/types" agentexec "github.com/docker/swarmkit/agent/exec" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/net/context" ) @@ -55,18 +57,18 @@ const ( ) var ( - errInvalidEndpoint = fmt.Errorf("invalid endpoint while building port map info") - errInvalidNetwork = fmt.Errorf("invalid network settings while building port map info") + errInvalidEndpoint = errors.New("invalid endpoint while building port map info") + errInvalidNetwork = errors.New("invalid network settings while building port map info") ) // Container holds the structure defining a container object. type Container struct { StreamConfig *stream.Config // embed for Container to support states directly. - *State `json:"State"` // Needed for Engine API version <= 1.11 - Root string `json:"-"` // Path to the "home" of the container, including metadata. - BaseFS string `json:"-"` // Path to the graphdriver mountpoint - RWLayer layer.RWLayer `json:"-"` + *State `json:"State"` // Needed for Engine API version <= 1.11 + Root string `json:"-"` // Path to the "home" of the container, including metadata. + BaseFS containerfs.ContainerFS `json:"-"` // interface containing graphdriver mount + RWLayer layer.RWLayer `json:"-"` ID string Created time.Time Managed bool @@ -167,7 +169,7 @@ func (container *Container) toDisk() (*Container, error) { } // Save container settings - f, err := ioutils.NewAtomicFileWriter(pth, 0644) + f, err := ioutils.NewAtomicFileWriter(pth, 0600) if err != nil { return nil, err } @@ -260,12 +262,17 @@ func (container *Container) WriteHostConfig() (*containertypes.HostConfig, error // SetupWorkingDirectory sets up the container's working directory as set in container.Config.WorkingDir func (container *Container) SetupWorkingDirectory(rootIDs idtools.IDPair) error { + // TODO @jhowardmsft, @gupta-ak LCOW Support. This will need revisiting. + // We will need to do remote filesystem operations here. + if container.Platform != runtime.GOOS { + return nil + } + if container.Config.WorkingDir == "" { return nil } container.Config.WorkingDir = filepath.Clean(container.Config.WorkingDir) - pth, err := container.GetResourcePath(container.Config.WorkingDir) if err != nil { return err @@ -274,7 +281,7 @@ func (container *Container) SetupWorkingDirectory(rootIDs idtools.IDPair) error if err := idtools.MkdirAllAndChownNew(pth, 0755, rootIDs); err != nil { pthInfo, err2 := os.Stat(pth) if err2 == nil && pthInfo != nil && !pthInfo.IsDir() { - return fmt.Errorf("Cannot mkdir: %s is not a directory", container.Config.WorkingDir) + return errors.Errorf("Cannot mkdir: %s is not a directory", container.Config.WorkingDir) } return err @@ -299,15 +306,13 @@ func (container *Container) SetupWorkingDirectory(rootIDs idtools.IDPair) error func (container *Container) GetResourcePath(path string) (string, error) { // IMPORTANT - These are paths on the OS where the daemon is running, hence // any filepath operations must be done in an OS agnostic way. - - cleanPath := cleanResourcePath(path) - r, e := symlink.FollowSymlinkInScope(filepath.Join(container.BaseFS, cleanPath), container.BaseFS) + r, e := container.BaseFS.ResolveScopedPath(path, false) // Log this here on the daemon side as there's otherwise no indication apart // from the error being propagated all the way back to the client. This makes // debugging significantly easier and clearly indicates the error comes from the daemon. if e != nil { - logrus.Errorf("Failed to FollowSymlinkInScope BaseFS %s cleanPath %s path %s %s\n", container.BaseFS, cleanPath, path, e) + logrus.Errorf("Failed to ResolveScopedPath BaseFS %s path %s %s\n", container.BaseFS.Path(), path, e) } return r, e } @@ -357,7 +362,7 @@ func (container *Container) StartLogger() (logger.Logger, error) { cfg := container.HostConfig.LogConfig initDriver, err := logger.GetLogDriver(cfg.Type) if err != nil { - return nil, fmt.Errorf("failed to get logging factory: %v", err) + return nil, errors.Wrap(err, "failed to get logging factory") } info := logger.Info{ Config: cfg.Config, @@ -429,6 +434,11 @@ func (container *Container) ShouldRestart() bool { // AddMountPointWithVolume adds a new mount point configured with a volume to the container. func (container *Container) AddMountPointWithVolume(destination string, vol volume.Volume, rw bool) { + operatingSystem := container.Platform + if operatingSystem == "" { + operatingSystem = runtime.GOOS + } + volumeParser := volume.NewParser(operatingSystem) container.MountPoints[destination] = &volume.MountPoint{ Type: mounttypes.TypeVolume, Name: vol.Name(), @@ -436,7 +446,7 @@ func (container *Container) AddMountPointWithVolume(destination string, vol volu Destination: destination, RW: rw, Volume: vol, - CopyData: volume.DefaultCopyMode, + CopyData: volumeParser.DefaultCopyMode(), } } @@ -649,8 +659,12 @@ func (container *Container) BuildEndpointInfo(n libnetwork.Network, ep libnetwor return nil } +type named interface { + Name() string +} + // UpdateJoinInfo updates network settings when container joins network n with endpoint ep. -func (container *Container) UpdateJoinInfo(n libnetwork.Network, ep libnetwork.Endpoint) error { +func (container *Container) UpdateJoinInfo(n named, ep libnetwork.Endpoint) error { if err := container.buildPortMapInfo(ep); err != nil { return err } @@ -678,7 +692,7 @@ func (container *Container) UpdateSandboxNetworkSettings(sb libnetwork.Sandbox) } // BuildJoinOptions builds endpoint Join options from a given network. -func (container *Container) BuildJoinOptions(n libnetwork.Network) ([]libnetwork.EndpointOption, error) { +func (container *Container) BuildJoinOptions(n named) ([]libnetwork.EndpointOption, error) { var joinOptions []libnetwork.EndpointOption if epConfig, ok := container.NetworkSettings.Networks[n.Name()]; ok { for _, str := range epConfig.Links { @@ -723,18 +737,18 @@ func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network, epC for _, ips := range ipam.LinkLocalIPs { if linkip = net.ParseIP(ips); linkip == nil && ips != "" { - return nil, fmt.Errorf("Invalid link-local IP address:%s", ipam.LinkLocalIPs) + return nil, errors.Errorf("Invalid link-local IP address: %s", ipam.LinkLocalIPs) } ipList = append(ipList, linkip) } if ip = net.ParseIP(ipam.IPv4Address); ip == nil && ipam.IPv4Address != "" { - return nil, fmt.Errorf("Invalid IPv4 address:%s)", ipam.IPv4Address) + return nil, errors.Errorf("Invalid IPv4 address: %s)", ipam.IPv4Address) } if ip6 = net.ParseIP(ipam.IPv6Address); ip6 == nil && ipam.IPv6Address != "" { - return nil, fmt.Errorf("Invalid IPv6 address:%s)", ipam.IPv6Address) + return nil, errors.Errorf("Invalid IPv6 address: %s)", ipam.IPv6Address) } createOptions = append(createOptions, @@ -838,7 +852,7 @@ func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network, epC portStart, portEnd, err = newP.Range() } if err != nil { - return nil, fmt.Errorf("Error parsing HostPort value(%s):%v", binding[i].HostPort, err) + return nil, errors.Wrapf(err, "Error parsing HostPort value (%s)", binding[i].HostPort) } pbCopy.HostPort = uint16(portStart) pbCopy.HostPortEnd = uint16(portEnd) diff --git a/vendor/github.com/docker/docker/container/container_unix.go b/vendor/github.com/docker/docker/container/container_unix.go index 6a08e562e..6bb253fae 100644 --- a/vendor/github.com/docker/docker/container/container_unix.go +++ b/vendor/github.com/docker/docker/container/container_unix.go @@ -3,11 +3,8 @@ package container import ( - "fmt" "io/ioutil" "os" - "path/filepath" - "strings" "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" @@ -15,10 +12,10 @@ import ( "github.com/docker/docker/pkg/chrootarchive" "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/stringid" - "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/pkg/system" "github.com/docker/docker/volume" "github.com/opencontainers/selinux/go-selinux/label" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/sys/unix" ) @@ -69,6 +66,7 @@ func (container *Container) BuildHostnameFile() error { func (container *Container) NetworkMounts() []Mount { var mounts []Mount shared := container.HostConfig.NetworkMode.IsContainer() + parser := volume.NewParser(container.Platform) if container.ResolvConfPath != "" { if _, err := os.Stat(container.ResolvConfPath); err != nil { logrus.Warnf("ResolvConfPath set to %q, but can't stat this filename (err = %v); skipping", container.ResolvConfPath, err) @@ -84,7 +82,7 @@ func (container *Container) NetworkMounts() []Mount { Source: container.ResolvConfPath, Destination: "/etc/resolv.conf", Writable: writable, - Propagation: string(volume.DefaultPropagationMode), + Propagation: string(parser.DefaultPropagationMode()), }) } } @@ -103,7 +101,7 @@ func (container *Container) NetworkMounts() []Mount { Source: container.HostnamePath, Destination: "/etc/hostname", Writable: writable, - Propagation: string(volume.DefaultPropagationMode), + Propagation: string(parser.DefaultPropagationMode()), }) } } @@ -122,7 +120,7 @@ func (container *Container) NetworkMounts() []Mount { Source: container.HostsPath, Destination: "/etc/hosts", Writable: writable, - Propagation: string(volume.DefaultPropagationMode), + Propagation: string(parser.DefaultPropagationMode()), }) } } @@ -131,7 +129,7 @@ func (container *Container) NetworkMounts() []Mount { // CopyImagePathContent copies files in destination to the volume. func (container *Container) CopyImagePathContent(v volume.Volume, destination string) error { - rootfs, err := symlink.FollowSymlinkInScope(filepath.Join(container.BaseFS, destination), container.BaseFS) + rootfs, err := container.GetResourcePath(destination) if err != nil { return err } @@ -171,48 +169,49 @@ func (container *Container) HasMountFor(path string) bool { return exists } -// UnmountIpcMounts uses the provided unmount function to unmount shm and mqueue if they were mounted -func (container *Container) UnmountIpcMounts(unmount func(pth string) error) { - if container.HostConfig.IpcMode.IsContainer() || container.HostConfig.IpcMode.IsHost() { - return +// UnmountIpcMount uses the provided unmount function to unmount shm if it was mounted +func (container *Container) UnmountIpcMount(unmount func(pth string) error) error { + if container.HasMountFor("/dev/shm") { + return nil } - var warnings []string - - if !container.HasMountFor("/dev/shm") { - shmPath, err := container.ShmResourcePath() - if err != nil { - logrus.Error(err) - warnings = append(warnings, err.Error()) - } else if shmPath != "" { - if err := unmount(shmPath); err != nil && !os.IsNotExist(err) { - if mounted, mErr := mount.Mounted(shmPath); mounted || mErr != nil { - warnings = append(warnings, fmt.Sprintf("failed to umount %s: %v", shmPath, err)) - } - } - - } + // container.ShmPath should not be used here as it may point + // to the host's or other container's /dev/shm + shmPath, err := container.ShmResourcePath() + if err != nil { + return err } - - if len(warnings) > 0 { - logrus.Warnf("failed to cleanup ipc mounts:\n%v", strings.Join(warnings, "\n")) + if shmPath == "" { + return nil } + if err = unmount(shmPath); err != nil && !os.IsNotExist(err) { + if mounted, mErr := mount.Mounted(shmPath); mounted || mErr != nil { + return errors.Wrapf(err, "umount %s", shmPath) + } + } + return nil } // IpcMounts returns the list of IPC mounts func (container *Container) IpcMounts() []Mount { var mounts []Mount + parser := volume.NewParser(container.Platform) - if !container.HasMountFor("/dev/shm") { - label.SetFileLabel(container.ShmPath, container.MountLabel) - mounts = append(mounts, Mount{ - Source: container.ShmPath, - Destination: "/dev/shm", - Writable: true, - Propagation: string(volume.DefaultPropagationMode), - }) + if container.HasMountFor("/dev/shm") { + return mounts + } + if container.ShmPath == "" { + return mounts } + label.SetFileLabel(container.ShmPath, container.MountLabel) + mounts = append(mounts, Mount{ + Source: container.ShmPath, + Destination: "/dev/shm", + Writable: true, + Propagation: string(parser.DefaultPropagationMode()), + }) + return mounts } @@ -262,6 +261,14 @@ func (container *Container) ConfigMounts() []Mount { return mounts } +type conflictingUpdateOptions string + +func (e conflictingUpdateOptions) Error() string { + return string(e) +} + +func (e conflictingUpdateOptions) Conflict() {} + // UpdateContainer updates configuration of a container. Callers must hold a Lock on the Container. func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfig) error { // update resources of container @@ -273,16 +280,16 @@ func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfi // once NanoCPU is already set, updating CPUPeriod/CPUQuota will be blocked, and vice versa. // In the following we make sure the intended update (resources) does not conflict with the existing (cResource). if resources.NanoCPUs > 0 && cResources.CPUPeriod > 0 { - return fmt.Errorf("Conflicting options: Nano CPUs cannot be updated as CPU Period has already been set") + return conflictingUpdateOptions("Conflicting options: Nano CPUs cannot be updated as CPU Period has already been set") } if resources.NanoCPUs > 0 && cResources.CPUQuota > 0 { - return fmt.Errorf("Conflicting options: Nano CPUs cannot be updated as CPU Quota has already been set") + return conflictingUpdateOptions("Conflicting options: Nano CPUs cannot be updated as CPU Quota has already been set") } if resources.CPUPeriod > 0 && cResources.NanoCPUs > 0 { - return fmt.Errorf("Conflicting options: CPU Period cannot be updated as NanoCPUs has already been set") + return conflictingUpdateOptions("Conflicting options: CPU Period cannot be updated as NanoCPUs has already been set") } if resources.CPUQuota > 0 && cResources.NanoCPUs > 0 { - return fmt.Errorf("Conflicting options: CPU Quota cannot be updated as NanoCPUs has already been set") + return conflictingUpdateOptions("Conflicting options: CPU Quota cannot be updated as NanoCPUs has already been set") } if resources.BlkioWeight != 0 { @@ -310,7 +317,7 @@ func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfi // if memory limit smaller than already set memoryswap limit and doesn't // update the memoryswap limit, then error out. if resources.Memory > cResources.MemorySwap && resources.MemorySwap == 0 { - return fmt.Errorf("Memory limit should be smaller than already set memoryswap limit, update the memoryswap at the same time") + return conflictingUpdateOptions("Memory limit should be smaller than already set memoryswap limit, update the memoryswap at the same time") } cResources.Memory = resources.Memory } @@ -327,7 +334,7 @@ func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfi // update HostConfig of container if hostConfig.RestartPolicy.Name != "" { if container.HostConfig.AutoRemove && !hostConfig.RestartPolicy.IsNone() { - return fmt.Errorf("Restart policy cannot be updated because AutoRemove is enabled for the container") + return conflictingUpdateOptions("Restart policy cannot be updated because AutoRemove is enabled for the container") } container.HostConfig.RestartPolicy = hostConfig.RestartPolicy } @@ -422,6 +429,7 @@ func copyOwnership(source, destination string) error { // TmpfsMounts returns the list of tmpfs mounts func (container *Container) TmpfsMounts() ([]Mount, error) { + parser := volume.NewParser(container.Platform) var mounts []Mount for dest, data := range container.HostConfig.Tmpfs { mounts = append(mounts, Mount{ @@ -432,7 +440,7 @@ func (container *Container) TmpfsMounts() ([]Mount, error) { } for dest, mnt := range container.MountPoints { if mnt.Type == mounttypes.TypeTmpfs { - data, err := volume.ConvertTmpfsOptions(mnt.Spec.TmpfsOptions, mnt.Spec.ReadOnly) + data, err := parser.ConvertTmpfsOptions(mnt.Spec.TmpfsOptions, mnt.Spec.ReadOnly) if err != nil { return nil, err } @@ -446,11 +454,6 @@ func (container *Container) TmpfsMounts() ([]Mount, error) { return mounts, nil } -// cleanResourcePath cleans a resource path and prepares to combine with mnt path -func cleanResourcePath(path string) string { - return filepath.Join(string(os.PathSeparator), path) -} - // EnableServiceDiscoveryOnDefaultNetwork Enable service discovery on default network func (container *Container) EnableServiceDiscoveryOnDefaultNetwork() bool { return false diff --git a/vendor/github.com/docker/docker/container/container_windows.go b/vendor/github.com/docker/docker/container/container_windows.go index 0f2a45df9..2dbea5905 100644 --- a/vendor/github.com/docker/docker/container/container_windows.go +++ b/vendor/github.com/docker/docker/container/container_windows.go @@ -24,9 +24,10 @@ type ExitStatus struct { ExitCode int } -// UnmountIpcMounts unmounts Ipc related mounts. +// UnmountIpcMount unmounts Ipc related mounts. // This is a NOOP on windows. -func (container *Container) UnmountIpcMounts(unmount func(pth string) error) { +func (container *Container) UnmountIpcMount(unmount func(pth string) error) error { + return nil } // IpcMounts returns the list of Ipc related mounts. @@ -171,18 +172,6 @@ func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfi return nil } -// cleanResourcePath cleans a resource path by removing C:\ syntax, and prepares -// to combine with a volume path -func cleanResourcePath(path string) string { - if len(path) >= 2 { - c := path[0] - if path[1] == ':' && ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z') { - path = path[2:] - } - } - return filepath.Join(string(os.PathSeparator), path) -} - // BuildHostnameFile writes the container's hostname file. func (container *Container) BuildHostnameFile() error { return nil diff --git a/vendor/github.com/docker/docker/container/view.go b/vendor/github.com/docker/docker/container/view.go index 8d885268c..164827c55 100644 --- a/vendor/github.com/docker/docker/container/view.go +++ b/vendor/github.com/docker/docker/container/view.go @@ -203,10 +203,7 @@ func (db *memDB) ReserveName(name, containerID string) error { // Once released, a name can be reserved again func (db *memDB) ReleaseName(name string) error { return db.withTxn(func(txn *memdb.Txn) error { - if err := txn.Delete(memdbNamesTable, nameAssociation{name: name}); err != nil { - return err - } - return nil + return txn.Delete(memdbNamesTable, nameAssociation{name: name}) }) } diff --git a/vendor/github.com/docker/docker/contrib/docker-device-tool/device_tool.go b/vendor/github.com/docker/docker/contrib/docker-device-tool/device_tool.go index 8f6251582..905b68958 100644 --- a/vendor/github.com/docker/docker/contrib/docker-device-tool/device_tool.go +++ b/vendor/github.com/docker/docker/contrib/docker-device-tool/device_tool.go @@ -90,14 +90,12 @@ func main() { fmt.Printf("Sector size: %d\n", status.SectorSize) fmt.Printf("Data use: %d of %d (%.1f %%)\n", status.Data.Used, status.Data.Total, 100.0*float64(status.Data.Used)/float64(status.Data.Total)) fmt.Printf("Metadata use: %d of %d (%.1f %%)\n", status.Metadata.Used, status.Metadata.Total, 100.0*float64(status.Metadata.Used)/float64(status.Metadata.Total)) - break case "list": ids := devices.List() sort.Strings(ids) for _, id := range ids { fmt.Println(id) } - break case "device": if flag.NArg() < 2 { usage() @@ -113,7 +111,6 @@ func main() { fmt.Printf("Size in Sectors: %d\n", status.SizeInSectors) fmt.Printf("Mapped Sectors: %d\n", status.MappedSectors) fmt.Printf("Highest Mapped Sector: %d\n", status.HighestMappedSector) - break case "resize": if flag.NArg() < 2 { usage() @@ -131,7 +128,6 @@ func main() { os.Exit(1) } - break case "snap": if flag.NArg() < 3 { usage() @@ -142,7 +138,6 @@ func main() { fmt.Println("Can't create snap device: ", err) os.Exit(1) } - break case "remove": if flag.NArg() < 2 { usage() @@ -153,7 +148,6 @@ func main() { fmt.Println("Can't remove device: ", err) os.Exit(1) } - break case "mount": if flag.NArg() < 3 { usage() @@ -164,13 +158,10 @@ func main() { fmt.Println("Can't mount device: ", err) os.Exit(1) } - break default: fmt.Printf("Unknown command %s\n", args[0]) usage() os.Exit(1) } - - return } diff --git a/vendor/github.com/docker/docker/contrib/syntax/textmate/Docker.tmbundle/Syntaxes/Dockerfile.tmLanguage b/vendor/github.com/docker/docker/contrib/syntax/textmate/Docker.tmbundle/Syntaxes/Dockerfile.tmLanguage index 5a273337f..a4a7b7ae8 100644 --- a/vendor/github.com/docker/docker/contrib/syntax/textmate/Docker.tmbundle/Syntaxes/Dockerfile.tmLanguage +++ b/vendor/github.com/docker/docker/contrib/syntax/textmate/Docker.tmbundle/Syntaxes/Dockerfile.tmLanguage @@ -25,7 +25,7 @@ match - ^\s*\b(FROM)\b.*?\b(AS)\b + ^\s*\b(?i:(FROM))\b.*?\b(?i:(AS))\b captures @@ -42,7 +42,7 @@ match - ^\s*(?:(ONBUILD)\s+)?(ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL|MAINTAINER|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)\s + ^\s*(?i:(ONBUILD)\s+)?(?i:(ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL|MAINTAINER|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR))\s captures @@ -59,7 +59,7 @@ match - ^\s*(?:(ONBUILD)\s+)?(CMD|ENTRYPOINT)\s + ^\s*(?i:(ONBUILD)\s+)?(?i:(CMD|ENTRYPOINT))\s begin diff --git a/vendor/github.com/docker/docker/daemon/archive.go b/vendor/github.com/docker/docker/daemon/archive.go index bd00daca5..c52d3b850 100644 --- a/vendor/github.com/docker/docker/daemon/archive.go +++ b/vendor/github.com/docker/docker/daemon/archive.go @@ -3,7 +3,6 @@ package daemon import ( "io" "os" - "path/filepath" "strings" "github.com/docker/docker/api/types" @@ -20,6 +19,31 @@ import ( // path does not refer to a directory. var ErrExtractPointNotDirectory = errors.New("extraction point is not a directory") +// The daemon will use the following interfaces if the container fs implements +// these for optimized copies to and from the container. +type extractor interface { + ExtractArchive(src io.Reader, dst string, opts *archive.TarOptions) error +} + +type archiver interface { + ArchivePath(src string, opts *archive.TarOptions) (io.ReadCloser, error) +} + +// helper functions to extract or archive +func extractArchive(i interface{}, src io.Reader, dst string, opts *archive.TarOptions) error { + if ea, ok := i.(extractor); ok { + return ea.ExtractArchive(src, dst, opts) + } + return chrootarchive.Untar(src, dst, opts) +} + +func archivePath(i interface{}, src string, opts *archive.TarOptions) (io.ReadCloser, error) { + if ap, ok := i.(archiver); ok { + return ap.ArchivePath(src, opts) + } + return archive.TarWithOptions(src, opts) +} + // ContainerCopy performs a deprecated operation of archiving the resource at // the specified path in the container identified by the given name. func (daemon *Daemon) ContainerCopy(name string, res string) (io.ReadCloser, error) { @@ -28,16 +52,20 @@ func (daemon *Daemon) ContainerCopy(name string, res string) (io.ReadCloser, err return nil, err } - if res[0] == '/' || res[0] == '\\' { - res = res[1:] - } - // Make sure an online file-system operation is permitted. if err := daemon.isOnlineFSOperationPermitted(container); err != nil { - return nil, err + return nil, systemError{err} } - return daemon.containerCopy(container, res) + data, err := daemon.containerCopy(container, res) + if err == nil { + return data, nil + } + + if os.IsNotExist(err) { + return nil, containerFileNotFound{res, name} + } + return nil, systemError{err} } // ContainerStatPath stats the filesystem resource at the specified path in the @@ -50,10 +78,18 @@ func (daemon *Daemon) ContainerStatPath(name string, path string) (stat *types.C // Make sure an online file-system operation is permitted. if err := daemon.isOnlineFSOperationPermitted(container); err != nil { - return nil, err + return nil, systemError{err} + } + + stat, err = daemon.containerStatPath(container, path) + if err == nil { + return stat, nil } - return daemon.containerStatPath(container, path) + if os.IsNotExist(err) { + return nil, containerFileNotFound{path, name} + } + return nil, systemError{err} } // ContainerArchivePath creates an archive of the filesystem resource at the @@ -67,10 +103,18 @@ func (daemon *Daemon) ContainerArchivePath(name string, path string) (content io // Make sure an online file-system operation is permitted. if err := daemon.isOnlineFSOperationPermitted(container); err != nil { - return nil, nil, err + return nil, nil, systemError{err} + } + + content, stat, err = daemon.containerArchivePath(container, path) + if err == nil { + return content, stat, nil } - return daemon.containerArchivePath(container, path) + if os.IsNotExist(err) { + return nil, nil, containerFileNotFound{path, name} + } + return nil, nil, systemError{err} } // ContainerExtractToDir extracts the given archive to the specified location @@ -87,10 +131,18 @@ func (daemon *Daemon) ContainerExtractToDir(name, path string, copyUIDGID, noOve // Make sure an online file-system operation is permitted. if err := daemon.isOnlineFSOperationPermitted(container); err != nil { - return err + return systemError{err} + } + + err = daemon.containerExtractToDir(container, path, copyUIDGID, noOverwriteDirNonDir, content) + if err == nil { + return nil } - return daemon.containerExtractToDir(container, path, copyUIDGID, noOverwriteDirNonDir, content) + if os.IsNotExist(err) { + return containerFileNotFound{path, name} + } + return systemError{err} } // containerStatPath stats the filesystem resource at the specified path in this @@ -110,6 +162,9 @@ func (daemon *Daemon) containerStatPath(container *container.Container, path str return nil, err } + // Normalize path before sending to rootfs + path = container.BaseFS.FromSlash(path) + resolvedPath, absPath, err := container.ResolvePath(path) if err != nil { return nil, err @@ -150,6 +205,9 @@ func (daemon *Daemon) containerArchivePath(container *container.Container, path return nil, nil, err } + // Normalize path before sending to rootfs + path = container.BaseFS.FromSlash(path) + resolvedPath, absPath, err := container.ResolvePath(path) if err != nil { return nil, nil, err @@ -168,7 +226,18 @@ func (daemon *Daemon) containerArchivePath(container *container.Container, path // also catches the case when the root directory of the container is // requested: we want the archive entries to start with "/" and not the // container ID. - data, err := archive.TarResourceRebase(resolvedPath, filepath.Base(absPath)) + driver := container.BaseFS + + // Get the source and the base paths of the container resolved path in order + // to get the proper tar options for the rebase tar. + resolvedPath = driver.Clean(resolvedPath) + if driver.Base(resolvedPath) == "." { + resolvedPath += string(driver.Separator()) + "." + } + sourceDir, sourceBase := driver.Dir(resolvedPath), driver.Base(resolvedPath) + opts := archive.TarResourceRebaseOpts(sourceBase, driver.Base(absPath)) + + data, err := archivePath(driver, sourceDir, opts) if err != nil { return nil, nil, err } @@ -207,8 +276,12 @@ func (daemon *Daemon) containerExtractToDir(container *container.Container, path return err } + // Normalize path before sending to rootfs' + path = container.BaseFS.FromSlash(path) + driver := container.BaseFS + // Check if a drive letter supplied, it must be the system drive. No-op except on Windows - path, err = system.CheckSystemDriveAndRemoveDriveLetter(path) + path, err = system.CheckSystemDriveAndRemoveDriveLetter(path, driver) if err != nil { return err } @@ -220,7 +293,10 @@ func (daemon *Daemon) containerExtractToDir(container *container.Container, path // that you can extract an archive to a symlink that points to a directory. // Consider the given path as an absolute path in the container. - absPath := archive.PreserveTrailingDotOrSeparator(filepath.Join(string(filepath.Separator), path), path) + absPath := archive.PreserveTrailingDotOrSeparator( + driver.Join(string(driver.Separator()), path), + path, + driver.Separator()) // This will evaluate the last path element if it is a symlink. resolvedPath, err := container.GetResourcePath(absPath) @@ -228,7 +304,7 @@ func (daemon *Daemon) containerExtractToDir(container *container.Container, path return err } - stat, err := os.Lstat(resolvedPath) + stat, err := driver.Lstat(resolvedPath) if err != nil { return err } @@ -251,21 +327,24 @@ func (daemon *Daemon) containerExtractToDir(container *container.Container, path // a volume file path. var baseRel string if strings.HasPrefix(resolvedPath, `\\?\Volume{`) { - if strings.HasPrefix(resolvedPath, container.BaseFS) { - baseRel = resolvedPath[len(container.BaseFS):] + if strings.HasPrefix(resolvedPath, driver.Path()) { + baseRel = resolvedPath[len(driver.Path()):] if baseRel[:1] == `\` { baseRel = baseRel[1:] } } } else { - baseRel, err = filepath.Rel(container.BaseFS, resolvedPath) + baseRel, err = driver.Rel(driver.Path(), resolvedPath) } if err != nil { return err } // Make it an absolute path. - absPath = filepath.Join(string(filepath.Separator), baseRel) + absPath = driver.Join(string(driver.Separator()), baseRel) + // @ TODO: gupta-ak: Technically, this works since it no-ops + // on Windows and the file system is local anyway on linux. + // But eventually, it should be made driver aware. toVolume, err := checkIfPathIsInAVolume(container, absPath) if err != nil { return err @@ -287,7 +366,7 @@ func (daemon *Daemon) containerExtractToDir(container *container.Container, path } } - if err := chrootarchive.Untar(content, resolvedPath, options); err != nil { + if err := extractArchive(driver, content, resolvedPath, options); err != nil { return err } @@ -297,6 +376,9 @@ func (daemon *Daemon) containerExtractToDir(container *container.Container, path } func (daemon *Daemon) containerCopy(container *container.Container, resource string) (rc io.ReadCloser, err error) { + if resource[0] == '/' || resource[0] == '\\' { + resource = resource[1:] + } container.Lock() defer func() { @@ -325,24 +407,28 @@ func (daemon *Daemon) containerCopy(container *container.Container, resource str return nil, err } + // Normalize path before sending to rootfs + resource = container.BaseFS.FromSlash(resource) + driver := container.BaseFS + basePath, err := container.GetResourcePath(resource) if err != nil { return nil, err } - stat, err := os.Stat(basePath) + stat, err := driver.Stat(basePath) if err != nil { return nil, err } var filter []string if !stat.IsDir() { - d, f := filepath.Split(basePath) + d, f := driver.Split(basePath) basePath = d filter = []string{f} } else { - filter = []string{filepath.Base(basePath)} - basePath = filepath.Dir(basePath) + filter = []string{driver.Base(basePath)} + basePath = driver.Dir(basePath) } - archive, err := archive.TarWithOptions(basePath, &archive.TarOptions{ + archive, err := archivePath(driver, basePath, &archive.TarOptions{ Compression: archive.Uncompressed, IncludeFiles: filter, }) diff --git a/vendor/github.com/docker/docker/daemon/archive_unix.go b/vendor/github.com/docker/docker/daemon/archive_unix.go index d5dfad78c..e2d4c308d 100644 --- a/vendor/github.com/docker/docker/daemon/archive_unix.go +++ b/vendor/github.com/docker/docker/daemon/archive_unix.go @@ -4,6 +4,7 @@ package daemon import ( "github.com/docker/docker/container" + "github.com/docker/docker/volume" ) // checkIfPathIsInAVolume checks if the path is in a volume. If it is, it @@ -11,8 +12,9 @@ import ( // cannot be configured with a read-only rootfs. func checkIfPathIsInAVolume(container *container.Container, absPath string) (bool, error) { var toVolume bool + parser := volume.NewParser(container.Platform) for _, mnt := range container.MountPoints { - if toVolume = mnt.HasResource(absPath); toVolume { + if toVolume = parser.HasResource(mnt, absPath); toVolume { if mnt.RW { break } diff --git a/vendor/github.com/docker/docker/daemon/attach.go b/vendor/github.com/docker/docker/daemon/attach.go index 115c31576..651a964c0 100644 --- a/vendor/github.com/docker/docker/daemon/attach.go +++ b/vendor/github.com/docker/docker/daemon/attach.go @@ -5,13 +5,13 @@ import ( "fmt" "io" - "github.com/docker/docker/api/errors" "github.com/docker/docker/api/types/backend" "github.com/docker/docker/container" "github.com/docker/docker/container/stream" "github.com/docker/docker/daemon/logger" "github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/pkg/term" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -22,7 +22,7 @@ func (daemon *Daemon) ContainerAttach(prefixOrName string, c *backend.ContainerA if c.DetachKeys != "" { keys, err = term.ToBytes(c.DetachKeys) if err != nil { - return fmt.Errorf("Invalid detach keys (%s) provided", c.DetachKeys) + return validationError{errors.Errorf("Invalid detach keys (%s) provided", c.DetachKeys)} } } @@ -31,12 +31,12 @@ func (daemon *Daemon) ContainerAttach(prefixOrName string, c *backend.ContainerA return err } if container.IsPaused() { - err := fmt.Errorf("Container %s is paused, unpause the container before attach.", prefixOrName) - return errors.NewRequestConflictError(err) + err := fmt.Errorf("container %s is paused, unpause the container before attach", prefixOrName) + return stateConflictError{err} } if container.IsRestarting() { - err := fmt.Errorf("Container %s is restarting, wait until the container is running.", prefixOrName) - return errors.NewRequestConflictError(err) + err := fmt.Errorf("container %s is restarting, wait until the container is running", prefixOrName) + return stateConflictError{err} } cfg := stream.AttachConfig{ @@ -119,7 +119,7 @@ func (daemon *Daemon) containerAttach(c *container.Container, cfg *stream.Attach } cLog, ok := logDriver.(logger.LogReader) if !ok { - return logger.ErrReadLogsNotSupported + return logger.ErrReadLogsNotSupported{} } logs := cLog.ReadLogs(logger.ReadConfig{Tail: -1}) defer logs.Close() @@ -168,7 +168,7 @@ func (daemon *Daemon) containerAttach(c *container.Container, cfg *stream.Attach // Wait for the container to stop before returning. waitChan := c.Wait(context.Background(), container.WaitConditionNotRunning) defer func() { - _ = <-waitChan // Ignore returned exit code. + <-waitChan // Ignore returned exit code. }() } diff --git a/vendor/github.com/docker/docker/daemon/build.go b/vendor/github.com/docker/docker/daemon/build.go index 39269ab5a..be344062f 100644 --- a/vendor/github.com/docker/docker/daemon/build.go +++ b/vendor/github.com/docker/docker/daemon/build.go @@ -10,6 +10,7 @@ import ( "github.com/docker/docker/builder" "github.com/docker/docker/image" "github.com/docker/docker/layer" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/registry" @@ -25,9 +26,9 @@ type releaseableLayer struct { rwLayer layer.RWLayer } -func (rl *releaseableLayer) Mount() (string, error) { +func (rl *releaseableLayer) Mount() (containerfs.ContainerFS, error) { var err error - var mountPath string + var mountPath containerfs.ContainerFS var chainID layer.ChainID if rl.roLayer != nil { chainID = rl.roLayer.ChainID() @@ -36,7 +37,7 @@ func (rl *releaseableLayer) Mount() (string, error) { mountID := stringid.GenerateRandomID() rl.rwLayer, err = rl.layerStore.CreateRWLayer(mountID, chainID, nil) if err != nil { - return "", errors.Wrap(err, "failed to create rwlayer") + return nil, errors.Wrap(err, "failed to create rwlayer") } mountPath, err = rl.rwLayer.Mount("") @@ -48,7 +49,7 @@ func (rl *releaseableLayer) Mount() (string, error) { logrus.Errorf("Failed to release RWLayer: %s", err) } rl.rwLayer = nil - return "", err + return nil, err } return mountPath, nil diff --git a/vendor/github.com/docker/docker/daemon/checkpoint.go b/vendor/github.com/docker/docker/daemon/checkpoint.go index d3028f1e2..7bdcae515 100644 --- a/vendor/github.com/docker/docker/daemon/checkpoint.go +++ b/vendor/github.com/docker/docker/daemon/checkpoint.go @@ -7,13 +7,13 @@ import ( "os" "path/filepath" - "github.com/docker/docker/api" "github.com/docker/docker/api/types" + "github.com/docker/docker/daemon/names" ) var ( - validCheckpointNameChars = api.RestrictedNameChars - validCheckpointNamePattern = api.RestrictedNamePattern + validCheckpointNameChars = names.RestrictedNameChars + validCheckpointNamePattern = names.RestrictedNamePattern ) // getCheckpointDir verifies checkpoint directory for create,remove, list options and checks if checkpoint already exists diff --git a/vendor/github.com/docker/docker/daemon/cluster/cluster.go b/vendor/github.com/docker/docker/daemon/cluster/cluster.go index 55540fc06..6a7db153b 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/cluster.go +++ b/vendor/github.com/docker/docker/daemon/cluster/cluster.go @@ -72,21 +72,6 @@ const ( contextPrefix = "com.docker.swarm" ) -// errNoSwarm is returned on leaving a cluster that was never initialized -var errNoSwarm = errors.New("This node is not part of a swarm") - -// errSwarmExists is returned on initialize or join request for a cluster that has already been activated -var errSwarmExists = errors.New("This node is already part of a swarm. Use \"docker swarm leave\" to leave this swarm and join another one.") - -// errSwarmJoinTimeoutReached is returned when cluster join could not complete before timeout was reached. -var errSwarmJoinTimeoutReached = errors.New("Timeout was reached before node was joined. The attempt to join the swarm will continue in the background. Use the \"docker info\" command to see the current swarm status of your node.") - -// errSwarmLocked is returned if the swarm is encrypted and needs a key to unlock it. -var errSwarmLocked = errors.New("Swarm is encrypted and needs to be unlocked before it can be used. Please use \"docker swarm unlock\" to unlock it.") - -// errSwarmCertificatesExpired is returned if docker was not started for the whole validity period and they had no chance to renew automatically. -var errSwarmCertificatesExpired = errors.New("Swarm certificates have expired. To replace them, leave the swarm and join again.") - // NetworkSubnetsProvider exposes functions for retrieving the subnets // of networks managed by Docker, so they can be filtered. type NetworkSubnetsProvider interface { @@ -343,12 +328,12 @@ func (c *Cluster) errNoManager(st nodeState) error { if st.err == errSwarmCertificatesExpired { return errSwarmCertificatesExpired } - return errors.New("This node is not a swarm manager. Use \"docker swarm init\" or \"docker swarm join\" to connect this node to swarm and try again.") + return errors.WithStack(notAvailableError("This node is not a swarm manager. Use \"docker swarm init\" or \"docker swarm join\" to connect this node to swarm and try again.")) } if st.swarmNode.Manager() != nil { - return errors.New("This node is not a swarm manager. Manager is being prepared or has trouble connecting to the cluster.") + return errors.WithStack(notAvailableError("This node is not a swarm manager. Manager is being prepared or has trouble connecting to the cluster.")) } - return errors.New("This node is not a swarm manager. Worker nodes can't be used to view or modify cluster state. Please run this command on a manager node or promote the current node to a manager.") + return errors.WithStack(notAvailableError("This node is not a swarm manager. Worker nodes can't be used to view or modify cluster state. Please run this command on a manager node or promote the current node to a manager.")) } // Cleanup stops active swarm node. This is run before daemon shutdown. diff --git a/vendor/github.com/docker/docker/daemon/cluster/controllers/plugin/controller.go b/vendor/github.com/docker/docker/daemon/cluster/controllers/plugin/controller.go index 8cc9b04e3..b48c9fd4e 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/controllers/plugin/controller.go +++ b/vendor/github.com/docker/docker/daemon/cluster/controllers/plugin/controller.go @@ -6,6 +6,7 @@ import ( "net/http" "github.com/docker/distribution/reference" + "github.com/docker/docker/api/errdefs" enginetypes "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm/runtime" "github.com/docker/docker/plugin" @@ -198,8 +199,7 @@ func (p *Controller) Wait(ctx context.Context) error { } func isNotFound(err error) bool { - _, ok := errors.Cause(err).(plugin.ErrNotFound) - return ok + return errdefs.IsNotFound(err) } // Shutdown is the shutdown phase from swarmkit diff --git a/vendor/github.com/docker/docker/daemon/cluster/convert/swarm.go b/vendor/github.com/docker/docker/daemon/cluster/convert/swarm.go index 2ea89b968..3ef3205e9 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/convert/swarm.go +++ b/vendor/github.com/docker/docker/daemon/cluster/convert/swarm.go @@ -3,7 +3,6 @@ package convert import ( "fmt" "strings" - "time" types "github.com/docker/docker/api/types/swarm" swarmapi "github.com/docker/swarmkit/api" @@ -115,7 +114,7 @@ func MergeSwarmSpecToGRPC(s types.Spec, spec swarmapi.ClusterSpec) (swarmapi.Clu spec.Raft.ElectionTick = uint32(s.Raft.ElectionTick) } if s.Dispatcher.HeartbeatPeriod != 0 { - spec.Dispatcher.HeartbeatPeriod = gogotypes.DurationProto(time.Duration(s.Dispatcher.HeartbeatPeriod)) + spec.Dispatcher.HeartbeatPeriod = gogotypes.DurationProto(s.Dispatcher.HeartbeatPeriod) } if s.CAConfig.NodeCertExpiry != 0 { spec.CAConfig.NodeCertExpiry = gogotypes.DurationProto(s.CAConfig.NodeCertExpiry) diff --git a/vendor/github.com/docker/docker/daemon/cluster/errors.go b/vendor/github.com/docker/docker/daemon/cluster/errors.go new file mode 100644 index 000000000..169822942 --- /dev/null +++ b/vendor/github.com/docker/docker/daemon/cluster/errors.go @@ -0,0 +1,114 @@ +package cluster + +const ( + // errNoSwarm is returned on leaving a cluster that was never initialized + errNoSwarm notAvailableError = "This node is not part of a swarm" + + // errSwarmExists is returned on initialize or join request for a cluster that has already been activated + errSwarmExists notAvailableError = "This node is already part of a swarm. Use \"docker swarm leave\" to leave this swarm and join another one." + + // errSwarmJoinTimeoutReached is returned when cluster join could not complete before timeout was reached. + errSwarmJoinTimeoutReached notAvailableError = "Timeout was reached before node joined. The attempt to join the swarm will continue in the background. Use the \"docker info\" command to see the current swarm status of your node." + + // errSwarmLocked is returned if the swarm is encrypted and needs a key to unlock it. + errSwarmLocked notAvailableError = "Swarm is encrypted and needs to be unlocked before it can be used. Please use \"docker swarm unlock\" to unlock it." + + // errSwarmCertificatesExpired is returned if docker was not started for the whole validity period and they had no chance to renew automatically. + errSwarmCertificatesExpired notAvailableError = "Swarm certificates have expired. To replace them, leave the swarm and join again." +) + +type notFoundError struct { + cause error +} + +func (e notFoundError) Error() string { + return e.cause.Error() +} + +func (e notFoundError) NotFound() {} + +func (e notFoundError) Cause() error { + return e.cause +} + +type ambiguousResultsError struct { + cause error +} + +func (e ambiguousResultsError) Error() string { + return e.cause.Error() +} + +func (e ambiguousResultsError) InvalidParameter() {} + +func (e ambiguousResultsError) Cause() error { + return e.cause +} + +type convertError struct { + cause error +} + +func (e convertError) Error() string { + return e.cause.Error() +} + +func (e convertError) InvalidParameter() {} + +func (e convertError) Cause() error { + return e.cause +} + +type notAllowedError string + +func (e notAllowedError) Error() string { + return string(e) +} + +func (e notAllowedError) Forbidden() {} + +type validationError struct { + cause error +} + +func (e validationError) Error() string { + return e.cause.Error() +} + +func (e validationError) InvalidParameter() {} + +func (e validationError) Cause() error { + return e.cause +} + +type notAvailableError string + +func (e notAvailableError) Error() string { + return string(e) +} + +func (e notAvailableError) Unavailable() {} + +type configError string + +func (e configError) Error() string { + return string(e) +} + +func (e configError) InvalidParameter() {} + +type invalidUnlockKey struct{} + +func (invalidUnlockKey) Error() string { + return "swarm could not be unlocked: invalid key provided" +} + +func (invalidUnlockKey) Unauthorized() {} + +type notLockedError struct{} + +func (notLockedError) Error() string { + return "swarm is not locked" +} + +func (notLockedError) Conflict() {} diff --git a/vendor/github.com/docker/docker/daemon/cluster/executor/backend.go b/vendor/github.com/docker/docker/daemon/cluster/executor/backend.go index fbe900656..89952c145 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/executor/backend.go +++ b/vendor/github.com/docker/docker/daemon/cluster/executor/backend.go @@ -15,6 +15,7 @@ import ( swarmtypes "github.com/docker/docker/api/types/swarm" containerpkg "github.com/docker/docker/container" clustertypes "github.com/docker/docker/daemon/cluster/provider" + networkSettings "github.com/docker/docker/daemon/network" "github.com/docker/docker/plugin" "github.com/docker/libnetwork" "github.com/docker/libnetwork/cluster" @@ -34,7 +35,7 @@ type Backend interface { CreateManagedContainer(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error) ContainerStart(name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error ContainerStop(name string, seconds *int) error - ContainerLogs(context.Context, string, *types.ContainerLogsOptions) (<-chan *backend.LogMessage, error) + ContainerLogs(context.Context, string, *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error) ConnectContainerToNetwork(containerName, networkName string, endpointConfig *network.EndpointSettings) error ActivateContainerServiceBinding(containerName string) error DeactivateContainerServiceBinding(containerName string) error @@ -61,4 +62,5 @@ type Backend interface { LookupImage(name string) (*types.ImageInspect, error) PluginManager() *plugin.Manager PluginGetter() *plugin.Store + GetLBAttachmentStore() *networkSettings.LBAttachmentStore } diff --git a/vendor/github.com/docker/docker/daemon/cluster/executor/container/adapter.go b/vendor/github.com/docker/docker/daemon/cluster/executor/container/adapter.go index 0a3373966..8077efdb0 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/executor/container/adapter.go +++ b/vendor/github.com/docker/docker/daemon/cluster/executor/container/adapter.go @@ -41,8 +41,8 @@ type containerAdapter struct { dependencies exec.DependencyGetter } -func newContainerAdapter(b executorpkg.Backend, task *api.Task, dependencies exec.DependencyGetter) (*containerAdapter, error) { - ctnr, err := newContainerConfig(task) +func newContainerAdapter(b executorpkg.Backend, task *api.Task, node *api.NodeDescription, dependencies exec.DependencyGetter) (*containerAdapter, error) { + ctnr, err := newContainerConfig(task, node) if err != nil { return nil, err } @@ -451,7 +451,7 @@ func (c *containerAdapter) logs(ctx context.Context, options api.LogSubscription } } } - msgs, err := c.backend.ContainerLogs(ctx, c.container.name(), apiOptions) + msgs, _, err := c.backend.ContainerLogs(ctx, c.container.name(), apiOptions) if err != nil { return nil, err } diff --git a/vendor/github.com/docker/docker/daemon/cluster/executor/container/attachment.go b/vendor/github.com/docker/docker/daemon/cluster/executor/container/attachment.go index 54f95a1fb..405aa2db6 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/executor/container/attachment.go +++ b/vendor/github.com/docker/docker/daemon/cluster/executor/container/attachment.go @@ -20,8 +20,8 @@ type networkAttacherController struct { closed chan struct{} } -func newNetworkAttacherController(b executorpkg.Backend, task *api.Task, dependencies exec.DependencyGetter) (*networkAttacherController, error) { - adapter, err := newContainerAdapter(b, task, dependencies) +func newNetworkAttacherController(b executorpkg.Backend, task *api.Task, node *api.NodeDescription, dependencies exec.DependencyGetter) (*networkAttacherController, error) { + adapter, err := newContainerAdapter(b, task, node, dependencies) if err != nil { return nil, err } @@ -40,11 +40,7 @@ func (nc *networkAttacherController) Update(ctx context.Context, t *api.Task) er func (nc *networkAttacherController) Prepare(ctx context.Context) error { // Make sure all the networks that the task needs are created. - if err := nc.adapter.createNetworks(ctx); err != nil { - return err - } - - return nil + return nc.adapter.createNetworks(ctx) } func (nc *networkAttacherController) Start(ctx context.Context) error { @@ -69,11 +65,7 @@ func (nc *networkAttacherController) Terminate(ctx context.Context) error { func (nc *networkAttacherController) Remove(ctx context.Context) error { // Try removing the network referenced in this task in case this // task is the last one referencing it - if err := nc.adapter.removeNetworks(ctx); err != nil { - return err - } - - return nil + return nc.adapter.removeNetworks(ctx) } func (nc *networkAttacherController) Close() error { diff --git a/vendor/github.com/docker/docker/daemon/cluster/executor/container/container.go b/vendor/github.com/docker/docker/daemon/cluster/executor/container/container.go index 8ea4126d7..59ac9bf21 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/executor/container/container.go +++ b/vendor/github.com/docker/docker/daemon/cluster/executor/container/container.go @@ -48,12 +48,12 @@ type containerConfig struct { // newContainerConfig returns a validated container config. No methods should // return an error if this function returns without error. -func newContainerConfig(t *api.Task) (*containerConfig, error) { +func newContainerConfig(t *api.Task, node *api.NodeDescription) (*containerConfig, error) { var c containerConfig - return &c, c.setTask(t) + return &c, c.setTask(t, node) } -func (c *containerConfig) setTask(t *api.Task) error { +func (c *containerConfig) setTask(t *api.Task, node *api.NodeDescription) error { if t.Spec.GetContainer() == nil && t.Spec.GetAttachment() == nil { return exec.ErrRuntimeUnsupported } @@ -78,7 +78,7 @@ func (c *containerConfig) setTask(t *api.Task) error { c.task = t if t.Spec.GetContainer() != nil { - preparedSpec, err := template.ExpandContainerSpec(nil, t) + preparedSpec, err := template.ExpandContainerSpec(node, t) if err != nil { return err } diff --git a/vendor/github.com/docker/docker/daemon/cluster/executor/container/controller.go b/vendor/github.com/docker/docker/daemon/cluster/executor/container/controller.go index 7fa4a864d..dda12591a 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/executor/container/controller.go +++ b/vendor/github.com/docker/docker/daemon/cluster/executor/container/controller.go @@ -40,8 +40,8 @@ type controller struct { var _ exec.Controller = &controller{} // NewController returns a docker exec runner for the provided task. -func newController(b executorpkg.Backend, task *api.Task, dependencies exec.DependencyGetter) (*controller, error) { - adapter, err := newContainerAdapter(b, task, dependencies) +func newController(b executorpkg.Backend, task *api.Task, node *api.NodeDescription, dependencies exec.DependencyGetter) (*controller, error) { + adapter, err := newContainerAdapter(b, task, node, dependencies) if err != nil { return nil, err } @@ -659,7 +659,7 @@ func (e *exitError) Error() string { } func (e *exitError) ExitCode() int { - return int(e.code) + return e.code } func (e *exitError) Cause() error { diff --git a/vendor/github.com/docker/docker/daemon/cluster/executor/container/executor.go b/vendor/github.com/docker/docker/daemon/cluster/executor/container/executor.go index 3a6188bff..a5bf2603d 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/executor/container/executor.go +++ b/vendor/github.com/docker/docker/daemon/cluster/executor/container/executor.go @@ -4,6 +4,7 @@ import ( "fmt" "sort" "strings" + "sync" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" @@ -26,6 +27,8 @@ type executor struct { backend executorpkg.Backend pluginBackend plugin.Backend dependencies exec.DependencyManager + mutex sync.Mutex // This mutex protects the following node field + node *api.NodeDescription } // NewExecutor returns an executor from the docker client. @@ -124,27 +127,41 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) { }, } + // Save the node information in the executor field + e.mutex.Lock() + e.node = description + e.mutex.Unlock() + return description, nil } func (e *executor) Configure(ctx context.Context, node *api.Node) error { - na := node.Attachment - if na == nil { + var ingressNA *api.NetworkAttachment + lbAttachments := make(map[string]string) + + for _, na := range node.LbAttachments { + if na.Network.Spec.Ingress { + ingressNA = na + } + lbAttachments[na.Network.ID] = na.Addresses[0] + } + + if ingressNA == nil { e.backend.ReleaseIngress() - return nil + return e.backend.GetLBAttachmentStore().ResetLBAttachments(lbAttachments) } options := types.NetworkCreate{ - Driver: na.Network.DriverState.Name, + Driver: ingressNA.Network.DriverState.Name, IPAM: &network.IPAM{ - Driver: na.Network.IPAM.Driver.Name, + Driver: ingressNA.Network.IPAM.Driver.Name, }, - Options: na.Network.DriverState.Options, + Options: ingressNA.Network.DriverState.Options, Ingress: true, CheckDuplicate: true, } - for _, ic := range na.Network.IPAM.Configs { + for _, ic := range ingressNA.Network.IPAM.Configs { c := network.IPAMConfig{ Subnet: ic.Subnet, IPRange: ic.Range, @@ -154,22 +171,30 @@ func (e *executor) Configure(ctx context.Context, node *api.Node) error { } _, err := e.backend.SetupIngress(clustertypes.NetworkCreateRequest{ - ID: na.Network.ID, + ID: ingressNA.Network.ID, NetworkCreateRequest: types.NetworkCreateRequest{ - Name: na.Network.Spec.Annotations.Name, + Name: ingressNA.Network.Spec.Annotations.Name, NetworkCreate: options, }, - }, na.Addresses[0]) + }, ingressNA.Addresses[0]) + if err != nil { + return err + } - return err + return e.backend.GetLBAttachmentStore().ResetLBAttachments(lbAttachments) } // Controller returns a docker container runner. func (e *executor) Controller(t *api.Task) (exec.Controller, error) { dependencyGetter := agent.Restrict(e.dependencies, t) + // Get the node description from the executor field + e.mutex.Lock() + nodeDescription := e.node + e.mutex.Unlock() + if t.Spec.GetAttachment() != nil { - return newNetworkAttacherController(e.backend, t, dependencyGetter) + return newNetworkAttacherController(e.backend, t, nodeDescription, dependencyGetter) } var ctlr exec.Controller @@ -185,16 +210,20 @@ func (e *executor) Controller(t *api.Task) (exec.Controller, error) { } switch runtimeKind { case string(swarmtypes.RuntimePlugin): + info, _ := e.backend.SystemInfo() + if !info.ExperimentalBuild { + return ctlr, fmt.Errorf("runtime type %q only supported in experimental", swarmtypes.RuntimePlugin) + } c, err := plugin.NewController(e.pluginBackend, t) if err != nil { return ctlr, err } ctlr = c default: - return ctlr, fmt.Errorf("unsupported runtime type: %q", r.Generic.Kind) + return ctlr, fmt.Errorf("unsupported runtime type: %q", runtimeKind) } case *api.TaskSpec_Container: - c, err := newController(e.backend, t, dependencyGetter) + c, err := newController(e.backend, t, nodeDescription, dependencyGetter) if err != nil { return ctlr, err } diff --git a/vendor/github.com/docker/docker/daemon/cluster/executor/container/health_test.go b/vendor/github.com/docker/docker/daemon/cluster/executor/container/health_test.go index b6f188557..450865edd 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/executor/container/health_test.go +++ b/vendor/github.com/docker/docker/daemon/cluster/executor/container/health_test.go @@ -52,7 +52,7 @@ func TestHealthStates(t *testing.T) { EventsService: e, } - controller, err := newController(daemon, task, nil) + controller, err := newController(daemon, task, nil, nil) if err != nil { t.Fatalf("create controller fail %v", err) } diff --git a/vendor/github.com/docker/docker/daemon/cluster/executor/container/validate_test.go b/vendor/github.com/docker/docker/daemon/cluster/executor/container/validate_test.go index 9d98e2c00..43e224a8f 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/executor/container/validate_test.go +++ b/vendor/github.com/docker/docker/daemon/cluster/executor/container/validate_test.go @@ -26,7 +26,8 @@ func newTestControllerWithMount(m api.Mount) (*controller, error) { }, }, }, - }, nil) + }, nil, + nil) } func TestControllerValidateMountBind(t *testing.T) { diff --git a/vendor/github.com/docker/docker/daemon/cluster/helpers.go b/vendor/github.com/docker/docker/daemon/cluster/helpers.go index a74118c42..fd50eef66 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/helpers.go +++ b/vendor/github.com/docker/docker/daemon/cluster/helpers.go @@ -3,8 +3,8 @@ package cluster import ( "fmt" - "github.com/docker/docker/api/errors" swarmapi "github.com/docker/swarmkit/api" + "github.com/pkg/errors" "golang.org/x/net/context" ) @@ -15,7 +15,7 @@ func getSwarm(ctx context.Context, c swarmapi.ControlClient) (*swarmapi.Cluster, } if len(rl.Clusters) == 0 { - return nil, errors.NewRequestNotFoundError(errNoSwarm) + return nil, errors.WithStack(errNoSwarm) } // TODO: assume one cluster only @@ -48,11 +48,11 @@ func getNode(ctx context.Context, c swarmapi.ControlClient, input string) (*swar if len(rl.Nodes) == 0 { err := fmt.Errorf("node %s not found", input) - return nil, errors.NewRequestNotFoundError(err) + return nil, notFoundError{err} } if l := len(rl.Nodes); l > 1 { - return nil, fmt.Errorf("node %s is ambiguous (%d matches found)", input, l) + return nil, ambiguousResultsError{fmt.Errorf("node %s is ambiguous (%d matches found)", input, l)} } return rl.Nodes[0], nil @@ -84,11 +84,11 @@ func getService(ctx context.Context, c swarmapi.ControlClient, input string, ins if len(rl.Services) == 0 { err := fmt.Errorf("service %s not found", input) - return nil, errors.NewRequestNotFoundError(err) + return nil, notFoundError{err} } if l := len(rl.Services); l > 1 { - return nil, fmt.Errorf("service %s is ambiguous (%d matches found)", input, l) + return nil, ambiguousResultsError{fmt.Errorf("service %s is ambiguous (%d matches found)", input, l)} } if !insertDefaults { @@ -128,11 +128,11 @@ func getTask(ctx context.Context, c swarmapi.ControlClient, input string) (*swar if len(rl.Tasks) == 0 { err := fmt.Errorf("task %s not found", input) - return nil, errors.NewRequestNotFoundError(err) + return nil, notFoundError{err} } if l := len(rl.Tasks); l > 1 { - return nil, fmt.Errorf("task %s is ambiguous (%d matches found)", input, l) + return nil, ambiguousResultsError{fmt.Errorf("task %s is ambiguous (%d matches found)", input, l)} } return rl.Tasks[0], nil @@ -164,11 +164,11 @@ func getSecret(ctx context.Context, c swarmapi.ControlClient, input string) (*sw if len(rl.Secrets) == 0 { err := fmt.Errorf("secret %s not found", input) - return nil, errors.NewRequestNotFoundError(err) + return nil, notFoundError{err} } if l := len(rl.Secrets); l > 1 { - return nil, fmt.Errorf("secret %s is ambiguous (%d matches found)", input, l) + return nil, ambiguousResultsError{fmt.Errorf("secret %s is ambiguous (%d matches found)", input, l)} } return rl.Secrets[0], nil @@ -200,11 +200,11 @@ func getConfig(ctx context.Context, c swarmapi.ControlClient, input string) (*sw if len(rl.Configs) == 0 { err := fmt.Errorf("config %s not found", input) - return nil, errors.NewRequestNotFoundError(err) + return nil, notFoundError{err} } if l := len(rl.Configs); l > 1 { - return nil, fmt.Errorf("config %s is ambiguous (%d matches found)", input, l) + return nil, ambiguousResultsError{fmt.Errorf("config %s is ambiguous (%d matches found)", input, l)} } return rl.Configs[0], nil @@ -238,7 +238,7 @@ func getNetwork(ctx context.Context, c swarmapi.ControlClient, input string) (*s } if l := len(rl.Networks); l > 1 { - return nil, fmt.Errorf("network %s is ambiguous (%d matches found)", input, l) + return nil, ambiguousResultsError{fmt.Errorf("network %s is ambiguous (%d matches found)", input, l)} } return rl.Networks[0], nil diff --git a/vendor/github.com/docker/docker/daemon/cluster/listen_addr.go b/vendor/github.com/docker/docker/daemon/cluster/listen_addr.go index 993ccb62a..0d6590765 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/listen_addr.go +++ b/vendor/github.com/docker/docker/daemon/cluster/listen_addr.go @@ -1,20 +1,19 @@ package cluster import ( - "errors" "fmt" "net" ) -var ( - errNoSuchInterface = errors.New("no such interface") - errNoIP = errors.New("could not find the system's IP address") - errMustSpecifyListenAddr = errors.New("must specify a listening address because the address to advertise is not recognized as a system address, and a system's IP address to use could not be uniquely identified") - errBadNetworkIdentifier = errors.New("must specify a valid IP address or interface name") - errBadListenAddr = errors.New("listen address must be an IP address or network interface (with optional port number)") - errBadAdvertiseAddr = errors.New("advertise address must be a non-zero IP address or network interface (with optional port number)") - errBadDataPathAddr = errors.New("data path address must be a non-zero IP address or network interface (without a port number)") - errBadDefaultAdvertiseAddr = errors.New("default advertise address must be a non-zero IP address or network interface (without a port number)") +const ( + errNoSuchInterface configError = "no such interface" + errNoIP configError = "could not find the system's IP address" + errMustSpecifyListenAddr configError = "must specify a listening address because the address to advertise is not recognized as a system address, and a system's IP address to use could not be uniquely identified" + errBadNetworkIdentifier configError = "must specify a valid IP address or interface name" + errBadListenAddr configError = "listen address must be an IP address or network interface (with optional port number)" + errBadAdvertiseAddr configError = "advertise address must be a non-zero IP address or network interface (with optional port number)" + errBadDataPathAddr configError = "data path address must be a non-zero IP address or network interface (without a port number)" + errBadDefaultAdvertiseAddr configError = "default advertise address must be a non-zero IP address or network interface (without a port number)" ) func resolveListenAddr(specifiedAddr string) (string, string, error) { @@ -125,13 +124,13 @@ func resolveInterfaceAddr(specifiedInterface string) (net.IP, error) { if ipAddr.IP.To4() != nil { // IPv4 if interfaceAddr4 != nil { - return nil, fmt.Errorf("interface %s has more than one IPv4 address (%s and %s)", specifiedInterface, interfaceAddr4, ipAddr.IP) + return nil, configError(fmt.Sprintf("interface %s has more than one IPv4 address (%s and %s)", specifiedInterface, interfaceAddr4, ipAddr.IP)) } interfaceAddr4 = ipAddr.IP } else { // IPv6 if interfaceAddr6 != nil { - return nil, fmt.Errorf("interface %s has more than one IPv6 address (%s and %s)", specifiedInterface, interfaceAddr6, ipAddr.IP) + return nil, configError(fmt.Sprintf("interface %s has more than one IPv6 address (%s and %s)", specifiedInterface, interfaceAddr6, ipAddr.IP)) } interfaceAddr6 = ipAddr.IP } @@ -139,7 +138,7 @@ func resolveInterfaceAddr(specifiedInterface string) (net.IP, error) { } if interfaceAddr4 == nil && interfaceAddr6 == nil { - return nil, fmt.Errorf("interface %s has no usable IPv4 or IPv6 address", specifiedInterface) + return nil, configError(fmt.Sprintf("interface %s has no usable IPv4 or IPv6 address", specifiedInterface)) } // In the case that there's exactly one IPv4 address @@ -296,7 +295,7 @@ func listSystemIPs() []net.IP { func errMultipleIPs(interfaceA, interfaceB string, addrA, addrB net.IP) error { if interfaceA == interfaceB { - return fmt.Errorf("could not choose an IP address to advertise since this system has multiple addresses on interface %s (%s and %s)", interfaceA, addrA, addrB) + return configError(fmt.Sprintf("could not choose an IP address to advertise since this system has multiple addresses on interface %s (%s and %s)", interfaceA, addrA, addrB)) } - return fmt.Errorf("could not choose an IP address to advertise since this system has multiple addresses on different interfaces (%s on %s and %s on %s)", addrA, interfaceA, addrB, interfaceB) + return configError(fmt.Sprintf("could not choose an IP address to advertise since this system has multiple addresses on different interfaces (%s on %s and %s on %s)", addrA, interfaceA, addrB, interfaceB)) } diff --git a/vendor/github.com/docker/docker/daemon/cluster/networks.go b/vendor/github.com/docker/docker/daemon/cluster/networks.go index 3b271dbc8..04582eb31 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/networks.go +++ b/vendor/github.com/docker/docker/daemon/cluster/networks.go @@ -3,7 +3,6 @@ package cluster import ( "fmt" - apierrors "github.com/docker/docker/api/errors" apitypes "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network" types "github.com/docker/docker/api/types/swarm" @@ -250,8 +249,8 @@ func (c *Cluster) DetachNetwork(target string, containerID string) error { // CreateNetwork creates a new cluster managed network. func (c *Cluster) CreateNetwork(s apitypes.NetworkCreateRequest) (string, error) { if runconfig.IsPreDefinedNetwork(s.Name) { - err := fmt.Errorf("%s is a pre-defined network and cannot be created", s.Name) - return "", apierrors.NewRequestForbiddenError(err) + err := notAllowedError(fmt.Sprintf("%s is a pre-defined network and cannot be created", s.Name)) + return "", errors.WithStack(err) } var resp *swarmapi.CreateNetworkResponse @@ -299,14 +298,13 @@ func (c *Cluster) populateNetworkID(ctx context.Context, client swarmapi.Control // and use its id for the request. apiNetwork, err = getNetwork(ctx, client, ln.Name()) if err != nil { - err = fmt.Errorf("could not find the corresponding predefined swarm network: %v", err) - return apierrors.NewRequestNotFoundError(err) + return errors.Wrap(notFoundError{err}, "could not find the corresponding predefined swarm network") } goto setid } if ln != nil && !ln.Info().Dynamic() { - err = fmt.Errorf("The network %s cannot be used with services. Only networks scoped to the swarm can be used, such as those created with the overlay driver.", ln.Name()) - return apierrors.NewRequestForbiddenError(err) + errMsg := fmt.Sprintf("The network %s cannot be used with services. Only networks scoped to the swarm can be used, such as those created with the overlay driver.", ln.Name()) + return errors.WithStack(notAllowedError(errMsg)) } return err } diff --git a/vendor/github.com/docker/docker/daemon/cluster/nodes.go b/vendor/github.com/docker/docker/daemon/cluster/nodes.go index 839c8f78e..582e7cdc7 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/nodes.go +++ b/vendor/github.com/docker/docker/daemon/cluster/nodes.go @@ -1,7 +1,6 @@ package cluster import ( - apierrors "github.com/docker/docker/api/errors" apitypes "github.com/docker/docker/api/types" types "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/daemon/cluster/convert" @@ -65,7 +64,7 @@ func (c *Cluster) UpdateNode(input string, version uint64, spec types.NodeSpec) return c.lockedManagerAction(func(ctx context.Context, state nodeState) error { nodeSpec, err := convert.NodeSpecToGRPC(spec) if err != nil { - return apierrors.NewBadRequestError(err) + return convertError{err} } ctx, cancel := c.getRequestContext() diff --git a/vendor/github.com/docker/docker/daemon/cluster/services.go b/vendor/github.com/docker/docker/daemon/cluster/services.go index c1cc5b9f5..0edb407d3 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/services.go +++ b/vendor/github.com/docker/docker/daemon/cluster/services.go @@ -11,7 +11,6 @@ import ( "time" "github.com/docker/distribution/reference" - apierrors "github.com/docker/docker/api/errors" apitypes "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" types "github.com/docker/docker/api/types/swarm" @@ -129,7 +128,7 @@ func (c *Cluster) CreateService(s types.ServiceSpec, encodedAuth string, queryRe serviceSpec, err := convert.ServiceSpecToGRPC(s) if err != nil { - return apierrors.NewBadRequestError(err) + return convertError{err} } resp = &apitypes.ServiceCreateResponse{} @@ -139,9 +138,16 @@ func (c *Cluster) CreateService(s types.ServiceSpec, encodedAuth string, queryRe case *swarmapi.TaskSpec_Generic: switch serviceSpec.Task.GetGeneric().Kind { case string(types.RuntimePlugin): + info, _ := c.config.Backend.SystemInfo() + if !info.ExperimentalBuild { + return fmt.Errorf("runtime type %q only supported in experimental", types.RuntimePlugin) + } if s.TaskTemplate.PluginSpec == nil { return errors.New("plugin spec must be set") } + + default: + return fmt.Errorf("unsupported runtime type: %q", serviceSpec.Task.GetGeneric().Kind) } r, err := state.controlClient.CreateService(ctx, &swarmapi.CreateServiceRequest{Spec: &serviceSpec}) @@ -226,7 +232,7 @@ func (c *Cluster) UpdateService(serviceIDOrName string, version uint64, spec typ serviceSpec, err := convert.ServiceSpecToGRPC(spec) if err != nil { - return apierrors.NewBadRequestError(err) + return convertError{err} } currentService, err := getService(ctx, state.controlClient, serviceIDOrName, false) diff --git a/vendor/github.com/docker/docker/daemon/cluster/swarm.go b/vendor/github.com/docker/docker/daemon/cluster/swarm.go index 2b34d89a6..1fa62920e 100644 --- a/vendor/github.com/docker/docker/daemon/cluster/swarm.go +++ b/vendor/github.com/docker/docker/daemon/cluster/swarm.go @@ -6,7 +6,6 @@ import ( "strings" "time" - apierrors "github.com/docker/docker/api/errors" apitypes "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" types "github.com/docker/docker/api/types/swarm" @@ -41,7 +40,7 @@ func (c *Cluster) Init(req types.InitRequest) (string, error) { } if err := validateAndSanitizeInitRequest(&req); err != nil { - return "", apierrors.NewBadRequestError(err) + return "", validationError{err} } listenHost, listenPort, err := resolveListenAddr(req.ListenAddr) @@ -132,12 +131,12 @@ func (c *Cluster) Join(req types.JoinRequest) error { c.mu.Lock() if c.nr != nil { c.mu.Unlock() - return errSwarmExists + return errors.WithStack(errSwarmExists) } c.mu.Unlock() if err := validateAndSanitizeJoinRequest(&req); err != nil { - return apierrors.NewBadRequestError(err) + return validationError{err} } listenHost, listenPort, err := resolveListenAddr(req.ListenAddr) @@ -222,7 +221,7 @@ func (c *Cluster) Update(version uint64, spec types.Spec, flags types.UpdateFlag // will be used to swarmkit. clusterSpec, err := convert.SwarmSpecToGRPC(spec) if err != nil { - return apierrors.NewBadRequestError(err) + return convertError{err} } _, err = state.controlClient.UpdateCluster( @@ -284,7 +283,7 @@ func (c *Cluster) UnlockSwarm(req types.UnlockRequest) error { } else { // when manager is active, return an error of "not locked" c.mu.RUnlock() - return errors.New("swarm is not locked") + return notLockedError{} } // only when swarm is locked, code running reaches here @@ -293,7 +292,7 @@ func (c *Cluster) UnlockSwarm(req types.UnlockRequest) error { key, err := encryption.ParseHumanReadableKey(req.UnlockKey) if err != nil { - return err + return validationError{err} } config := nr.config @@ -312,9 +311,9 @@ func (c *Cluster) UnlockSwarm(req types.UnlockRequest) error { if err := <-nr.Ready(); err != nil { if errors.Cause(err) == errSwarmLocked { - return errors.New("swarm could not be unlocked: invalid key provided") + return invalidUnlockKey{} } - return fmt.Errorf("swarm component could not be started: %v", err) + return errors.Errorf("swarm component could not be started: %v", err) } return nil } @@ -328,7 +327,7 @@ func (c *Cluster) Leave(force bool) error { nr := c.nr if nr == nil { c.mu.Unlock() - return errNoSwarm + return errors.WithStack(errNoSwarm) } state := c.currentNodeState() @@ -337,7 +336,7 @@ func (c *Cluster) Leave(force bool) error { if errors.Cause(state.err) == errSwarmLocked && !force { // leave a locked swarm without --force is not allowed - return errors.New("Swarm is encrypted and locked. Please unlock it first or use `--force` to ignore this message.") + return errors.WithStack(notAvailableError("Swarm is encrypted and locked. Please unlock it first or use `--force` to ignore this message.")) } if state.IsManager() && !force { @@ -348,7 +347,7 @@ func (c *Cluster) Leave(force bool) error { if active && removingManagerCausesLossOfQuorum(reachable, unreachable) { if isLastManager(reachable, unreachable) { msg += "Removing the last manager erases all current state of the swarm. Use `--force` to ignore this message. " - return errors.New(msg) + return errors.WithStack(notAvailableError(msg)) } msg += fmt.Sprintf("Removing this node leaves %v managers out of %v. Without a Raft quorum your swarm will be inaccessible. ", reachable-1, reachable+unreachable) } @@ -358,7 +357,7 @@ func (c *Cluster) Leave(force bool) error { } msg += "The only way to restore a swarm that has lost consensus is to reinitialize it with `--force-new-cluster`. Use `--force` to suppress this message." - return errors.New(msg) + return errors.WithStack(notAvailableError(msg)) } // release readers in here if err := nr.Stop(); err != nil { diff --git a/vendor/github.com/docker/docker/daemon/config/config.go b/vendor/github.com/docker/docker/daemon/config/config.go index 61c8deff7..501c07af7 100644 --- a/vendor/github.com/docker/docker/daemon/config/config.go +++ b/vendor/github.com/docker/docker/daemon/config/config.go @@ -103,7 +103,6 @@ type CommonConfig struct { Root string `json:"data-root,omitempty"` SocketGroup string `json:"group,omitempty"` CorsHeaders string `json:"api-cors-header,omitempty"` - EnableCors bool `json:"api-enable-cors,omitempty"` // TrustKeyPath is used to generate the daemon ID and for signing schema 1 manifests // when pushing to a registry which does not support schema 2. This field is marked as @@ -502,7 +501,7 @@ func Validate(config *Config) error { } } - if _, err := opts.ParseGenericResources(config.NodeGenericResources); err != nil { + if _, err := ParseGenericResources(config.NodeGenericResources); err != nil { return err } @@ -513,6 +512,11 @@ func Validate(config *Config) error { } } + // validate platform-specific settings + if err := config.ValidatePlatformConfig(); err != nil { + return err + } + return nil } diff --git a/vendor/github.com/docker/docker/daemon/config/config_solaris.go b/vendor/github.com/docker/docker/daemon/config/config_solaris.go index f4f080270..6b1e061b5 100644 --- a/vendor/github.com/docker/docker/daemon/config/config_solaris.go +++ b/vendor/github.com/docker/docker/daemon/config/config_solaris.go @@ -1,9 +1,5 @@ package config -import ( - "github.com/spf13/pflag" -) - // Config defines the configuration of a docker daemon. // These are the configuration settings that you pass // to the docker daemon when you launch it with say: `docker -d -e lxc` @@ -27,3 +23,8 @@ type BridgeConfig struct { func (conf *Config) IsSwarmCompatible() error { return nil } + +// ValidatePlatformConfig checks if any platform-specific configuration settings are invalid. +func (conf *Config) ValidatePlatformConfig() error { + return nil +} diff --git a/vendor/github.com/docker/docker/daemon/config/config_test.go b/vendor/github.com/docker/docker/daemon/config/config_test.go index cc5f01063..43246d99e 100644 --- a/vendor/github.com/docker/docker/daemon/config/config_test.go +++ b/vendor/github.com/docker/docker/daemon/config/config_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/docker/docker/daemon/discovery" + "github.com/docker/docker/internal/testutil" "github.com/docker/docker/opts" - "github.com/docker/docker/pkg/testutil" "github.com/spf13/pflag" "github.com/stretchr/testify/assert" ) diff --git a/vendor/github.com/docker/docker/daemon/config/config_unix.go b/vendor/github.com/docker/docker/daemon/config/config_unix.go index 8f1da5919..3a9e1cf53 100644 --- a/vendor/github.com/docker/docker/daemon/config/config_unix.go +++ b/vendor/github.com/docker/docker/daemon/config/config_unix.go @@ -5,10 +5,16 @@ package config import ( "fmt" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/opts" units "github.com/docker/go-units" ) +const ( + // DefaultIpcMode is default for container's IpcMode, if not set otherwise + DefaultIpcMode = "shareable" // TODO: change to private +) + // Config defines the configuration of a docker daemon. // It includes json tags to deserialize configuration from a file // using the same names that the flags in the command line uses. @@ -31,6 +37,7 @@ type Config struct { SeccompProfile string `json:"seccomp-profile,omitempty"` ShmSize opts.MemBytes `json:"default-shm-size,omitempty"` NoNewPrivileges bool `json:"no-new-privileges,omitempty"` + IpcMode string `json:"default-ipc-mode,omitempty"` } // BridgeConfig stores all the bridge driver specific @@ -61,3 +68,21 @@ func (conf *Config) IsSwarmCompatible() error { } return nil } + +func verifyDefaultIpcMode(mode string) error { + const hint = "Use \"shareable\" or \"private\"." + + dm := containertypes.IpcMode(mode) + if !dm.Valid() { + return fmt.Errorf("Default IPC mode setting (%v) is invalid. "+hint, dm) + } + if dm != "" && !dm.IsPrivate() && !dm.IsShareable() { + return fmt.Errorf("IPC mode \"%v\" is not supported as default value. "+hint, dm) + } + return nil +} + +// ValidatePlatformConfig checks if any platform-specific configuration settings are invalid. +func (conf *Config) ValidatePlatformConfig() error { + return verifyDefaultIpcMode(conf.IpcMode) +} diff --git a/vendor/github.com/docker/docker/daemon/config/config_unix_test.go b/vendor/github.com/docker/docker/daemon/config/config_unix_test.go index 9e52cb70f..fedf757eb 100644 --- a/vendor/github.com/docker/docker/daemon/config/config_unix_test.go +++ b/vendor/github.com/docker/docker/daemon/config/config_unix_test.go @@ -6,15 +6,15 @@ import ( "testing" "github.com/docker/docker/opts" - "github.com/docker/docker/pkg/testutil/tempfile" - "github.com/docker/go-units" + units "github.com/docker/go-units" + "github.com/gotestyourself/gotestyourself/fs" "github.com/spf13/pflag" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestGetConflictFreeConfiguration(t *testing.T) { - configFileData := string([]byte(` + configFileData := ` { "debug": true, "default-ulimits": { @@ -27,9 +27,9 @@ func TestGetConflictFreeConfiguration(t *testing.T) { "log-opts": { "tag": "test_tag" } - }`)) + }` - file := tempfile.NewTempFile(t, "docker-config", configFileData) + file := fs.NewFile(t, "docker-config", fs.WithContent(configFileData)) defer file.Remove() flags := pflag.NewFlagSet("test", pflag.ContinueOnError) @@ -38,7 +38,7 @@ func TestGetConflictFreeConfiguration(t *testing.T) { flags.Var(opts.NewNamedUlimitOpt("default-ulimits", nil), "default-ulimit", "") flags.Var(opts.NewNamedMapOpts("log-opts", nil, nil), "log-opt", "") - cc, err := getConflictFreeConfiguration(file.Name(), flags) + cc, err := getConflictFreeConfiguration(file.Path(), flags) require.NoError(t, err) assert.True(t, cc.Debug) @@ -55,7 +55,7 @@ func TestGetConflictFreeConfiguration(t *testing.T) { } func TestDaemonConfigurationMerge(t *testing.T) { - configFileData := string([]byte(` + configFileData := ` { "debug": true, "default-ulimits": { @@ -68,9 +68,9 @@ func TestDaemonConfigurationMerge(t *testing.T) { "log-opts": { "tag": "test_tag" } - }`)) + }` - file := tempfile.NewTempFile(t, "docker-config", configFileData) + file := fs.NewFile(t, "docker-config", fs.WithContent(configFileData)) defer file.Remove() c := &Config{ @@ -90,7 +90,7 @@ func TestDaemonConfigurationMerge(t *testing.T) { flags.Var(opts.NewNamedUlimitOpt("default-ulimits", nil), "default-ulimit", "") flags.Var(opts.NewNamedMapOpts("log-opts", nil, nil), "log-opt", "") - cc, err := MergeDaemonConfigurations(c, flags, file.Name()) + cc, err := MergeDaemonConfigurations(c, flags, file.Path()) require.NoError(t, err) assert.True(t, cc.Debug) @@ -115,12 +115,9 @@ func TestDaemonConfigurationMerge(t *testing.T) { } func TestDaemonConfigurationMergeShmSize(t *testing.T) { - data := string([]byte(` - { - "default-shm-size": "1g" - }`)) + data := `{"default-shm-size": "1g"}` - file := tempfile.NewTempFile(t, "docker-config", data) + file := fs.NewFile(t, "docker-config", fs.WithContent(data)) defer file.Remove() c := &Config{} @@ -129,11 +126,9 @@ func TestDaemonConfigurationMergeShmSize(t *testing.T) { shmSize := opts.MemBytes(DefaultShmSize) flags.Var(&shmSize, "default-shm-size", "") - cc, err := MergeDaemonConfigurations(c, flags, file.Name()) + cc, err := MergeDaemonConfigurations(c, flags, file.Path()) require.NoError(t, err) expectedValue := 1 * 1024 * 1024 * 1024 - if cc.ShmSize.Value() != int64(expectedValue) { - t.Fatalf("expected default shm size %d, got %d", expectedValue, cc.ShmSize.Value()) - } + assert.Equal(t, int64(expectedValue), cc.ShmSize.Value()) } diff --git a/vendor/github.com/docker/docker/daemon/config/config_windows.go b/vendor/github.com/docker/docker/daemon/config/config_windows.go index 849acc1ac..6f994e391 100644 --- a/vendor/github.com/docker/docker/daemon/config/config_windows.go +++ b/vendor/github.com/docker/docker/daemon/config/config_windows.go @@ -50,3 +50,8 @@ func (conf *Config) GetExecRoot() string { func (conf *Config) IsSwarmCompatible() error { return nil } + +// ValidatePlatformConfig checks if any platform-specific configuration settings are invalid. +func (conf *Config) ValidatePlatformConfig() error { + return nil +} diff --git a/vendor/github.com/docker/docker/daemon/config/opts.go b/vendor/github.com/docker/docker/daemon/config/opts.go new file mode 100644 index 000000000..00f32e43b --- /dev/null +++ b/vendor/github.com/docker/docker/daemon/config/opts.go @@ -0,0 +1,22 @@ +package config + +import ( + "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/daemon/cluster/convert" + "github.com/docker/swarmkit/api/genericresource" +) + +// ParseGenericResources parses and validates the specified string as a list of GenericResource +func ParseGenericResources(value string) ([]swarm.GenericResource, error) { + if value == "" { + return nil, nil + } + + resources, err := genericresource.Parse(value) + if err != nil { + return nil, err + } + + obj := convert.GenericResourcesFromGRPC(resources) + return obj, nil +} diff --git a/vendor/github.com/docker/docker/daemon/container.go b/vendor/github.com/docker/docker/daemon/container.go index 4c015b70d..79b9d412d 100644 --- a/vendor/github.com/docker/docker/daemon/container.go +++ b/vendor/github.com/docker/docker/daemon/container.go @@ -3,10 +3,12 @@ package daemon import ( "fmt" "os" + "path" "path/filepath" + "runtime" + "strings" "time" - "github.com/docker/docker/api/errors" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/strslice" "github.com/docker/docker/container" @@ -19,6 +21,7 @@ import ( "github.com/docker/docker/runconfig" "github.com/docker/go-connections/nat" "github.com/opencontainers/selinux/go-selinux/label" + "github.com/pkg/errors" ) // GetContainer looks for a container using the provided information, which could be @@ -30,7 +33,7 @@ import ( // If none of these searches succeed, an error is returned func (daemon *Daemon) GetContainer(prefixOrName string) (*container.Container, error) { if len(prefixOrName) == 0 { - return nil, errors.NewBadRequestError(fmt.Errorf("No container name or ID supplied")) + return nil, errors.WithStack(invalidIdentifier(prefixOrName)) } if containerByID := daemon.containers.Get(prefixOrName); containerByID != nil { @@ -48,10 +51,9 @@ func (daemon *Daemon) GetContainer(prefixOrName string) (*container.Container, e if indexError != nil { // When truncindex defines an error type, use that instead if indexError == truncindex.ErrNotExist { - err := fmt.Errorf("No such container: %s", prefixOrName) - return nil, errors.NewRequestNotFoundError(err) + return nil, containerNotFound(prefixOrName) } - return nil, indexError + return nil, systemError{indexError} } return daemon.containers.Get(containerID), nil } @@ -136,7 +138,7 @@ func (daemon *Daemon) newContainer(name string, platform string, config *contain if config.Hostname == "" { config.Hostname, err = os.Hostname() if err != nil { - return nil, err + return nil, systemError{err} } } } else { @@ -227,13 +229,24 @@ func (daemon *Daemon) setHostConfig(container *container.Container, hostConfig * // verifyContainerSettings performs validation of the hostconfig and config // structures. -func (daemon *Daemon) verifyContainerSettings(hostConfig *containertypes.HostConfig, config *containertypes.Config, update bool) ([]string, error) { - +func (daemon *Daemon) verifyContainerSettings(platform string, hostConfig *containertypes.HostConfig, config *containertypes.Config, update bool) ([]string, error) { // First perform verification of settings common across all platforms. if config != nil { if config.WorkingDir != "" { - config.WorkingDir = filepath.FromSlash(config.WorkingDir) // Ensure in platform semantics - if !system.IsAbs(config.WorkingDir) { + wdInvalid := false + if runtime.GOOS == platform { + config.WorkingDir = filepath.FromSlash(config.WorkingDir) // Ensure in platform semantics + if !system.IsAbs(config.WorkingDir) { + wdInvalid = true + } + } else { + // LCOW. Force Unix semantics + config.WorkingDir = strings.Replace(config.WorkingDir, string(os.PathSeparator), "/", -1) + if !path.IsAbs(config.WorkingDir) { + wdInvalid = true + } + } + if wdInvalid { return nil, fmt.Errorf("the working directory '%s' is invalid, it needs to be an absolute path", config.WorkingDir) } } @@ -255,19 +268,19 @@ func (daemon *Daemon) verifyContainerSettings(hostConfig *containertypes.HostCon // Validate the healthcheck params of Config if config.Healthcheck != nil { if config.Healthcheck.Interval != 0 && config.Healthcheck.Interval < containertypes.MinimumDuration { - return nil, fmt.Errorf("Interval in Healthcheck cannot be less than %s", containertypes.MinimumDuration) + return nil, errors.Errorf("Interval in Healthcheck cannot be less than %s", containertypes.MinimumDuration) } if config.Healthcheck.Timeout != 0 && config.Healthcheck.Timeout < containertypes.MinimumDuration { - return nil, fmt.Errorf("Timeout in Healthcheck cannot be less than %s", containertypes.MinimumDuration) + return nil, errors.Errorf("Timeout in Healthcheck cannot be less than %s", containertypes.MinimumDuration) } if config.Healthcheck.Retries < 0 { - return nil, fmt.Errorf("Retries in Healthcheck cannot be negative") + return nil, errors.Errorf("Retries in Healthcheck cannot be negative") } if config.Healthcheck.StartPeriod != 0 && config.Healthcheck.StartPeriod < containertypes.MinimumDuration { - return nil, fmt.Errorf("StartPeriod in Healthcheck cannot be less than %s", containertypes.MinimumDuration) + return nil, errors.Errorf("StartPeriod in Healthcheck cannot be less than %s", containertypes.MinimumDuration) } } } @@ -277,7 +290,7 @@ func (daemon *Daemon) verifyContainerSettings(hostConfig *containertypes.HostCon } if hostConfig.AutoRemove && !hostConfig.RestartPolicy.IsNone() { - return nil, fmt.Errorf("can't create 'AutoRemove' container with restart policy") + return nil, errors.Errorf("can't create 'AutoRemove' container with restart policy") } for _, extraHost := range hostConfig.ExtraHosts { @@ -289,12 +302,12 @@ func (daemon *Daemon) verifyContainerSettings(hostConfig *containertypes.HostCon for port := range hostConfig.PortBindings { _, portStr := nat.SplitProtoPort(string(port)) if _, err := nat.ParsePort(portStr); err != nil { - return nil, fmt.Errorf("invalid port specification: %q", portStr) + return nil, errors.Errorf("invalid port specification: %q", portStr) } for _, pb := range hostConfig.PortBindings[port] { _, err := nat.NewPort(nat.SplitProtoPort(pb.HostPort)) if err != nil { - return nil, fmt.Errorf("invalid port specification: %q", pb.HostPort) + return nil, errors.Errorf("invalid port specification: %q", pb.HostPort) } } } @@ -304,16 +317,16 @@ func (daemon *Daemon) verifyContainerSettings(hostConfig *containertypes.HostCon switch p.Name { case "always", "unless-stopped", "no": if p.MaximumRetryCount != 0 { - return nil, fmt.Errorf("maximum retry count cannot be used with restart policy '%s'", p.Name) + return nil, errors.Errorf("maximum retry count cannot be used with restart policy '%s'", p.Name) } case "on-failure": if p.MaximumRetryCount < 0 { - return nil, fmt.Errorf("maximum retry count cannot be negative") + return nil, errors.Errorf("maximum retry count cannot be negative") } case "": // do nothing default: - return nil, fmt.Errorf("invalid restart policy '%s'", p.Name) + return nil, errors.Errorf("invalid restart policy '%s'", p.Name) } // Now do platform-specific verification diff --git a/vendor/github.com/docker/docker/daemon/container_linux.go b/vendor/github.com/docker/docker/daemon/container_linux.go index 2c8771575..d05992d0f 100644 --- a/vendor/github.com/docker/docker/daemon/container_linux.go +++ b/vendor/github.com/docker/docker/daemon/container_linux.go @@ -14,7 +14,7 @@ func (daemon *Daemon) saveApparmorConfig(container *container.Container) error { } if err := parseSecurityOpt(container, container.HostConfig); err != nil { - return err + return validationError{err} } if !container.HostConfig.Privileged { diff --git a/vendor/github.com/docker/docker/daemon/container_operations.go b/vendor/github.com/docker/docker/daemon/container_operations.go index 70eee6e00..fc08f8263 100644 --- a/vendor/github.com/docker/docker/daemon/container_operations.go +++ b/vendor/github.com/docker/docker/daemon/container_operations.go @@ -10,7 +10,6 @@ import ( "strings" "time" - derr "github.com/docker/docker/api/errors" containertypes "github.com/docker/docker/api/types/container" networktypes "github.com/docker/docker/api/types/network" "github.com/docker/docker/container" @@ -923,7 +922,7 @@ func (daemon *Daemon) getNetworkedContainer(containerID, connectedContainerID st } if !nc.IsRunning() { err := fmt.Errorf("cannot join network of a non running container: %s", connectedContainerID) - return nil, derr.NewRequestConflictError(err) + return nil, stateConflictError{err} } if nc.IsRestarting() { return nil, errContainerIsRestarting(connectedContainerID) diff --git a/vendor/github.com/docker/docker/daemon/container_operations_unix.go b/vendor/github.com/docker/docker/daemon/container_operations_unix.go index fe635b22b..954c194ea 100644 --- a/vendor/github.com/docker/docker/daemon/container_operations_unix.go +++ b/vendor/github.com/docker/docker/daemon/container_operations_unix.go @@ -57,13 +57,27 @@ func (daemon *Daemon) setupLinkedContainers(container *container.Container) ([]s return env, nil } -func (daemon *Daemon) getIpcContainer(container *container.Container) (*container.Container, error) { - containerID := container.HostConfig.IpcMode.Container() - container, err := daemon.GetContainer(containerID) +func (daemon *Daemon) getIpcContainer(id string) (*container.Container, error) { + errMsg := "can't join IPC of container " + id + // Check the container exists + container, err := daemon.GetContainer(id) if err != nil { - return nil, errors.Wrapf(err, "cannot join IPC of a non running container: %s", container.ID) + return nil, errors.Wrap(err, errMsg) } - return container, daemon.checkContainer(container, containerIsRunning, containerIsNotRestarting) + // Check the container is running and not restarting + if err := daemon.checkContainer(container, containerIsRunning, containerIsNotRestarting); err != nil { + return nil, errors.Wrap(err, errMsg) + } + // Check the container ipc is shareable + if st, err := os.Stat(container.ShmPath); err != nil || !st.IsDir() { + if err == nil || os.IsNotExist(err) { + return nil, errors.New(errMsg + ": non-shareable IPC") + } + // stat() failed? + return nil, errors.Wrap(err, errMsg+": unexpected error from stat "+container.ShmPath) + } + + return container, nil } func (daemon *Daemon) getPidContainer(container *container.Container) (*container.Container, error) { @@ -77,7 +91,7 @@ func (daemon *Daemon) getPidContainer(container *container.Container) (*containe func containerIsRunning(c *container.Container) error { if !c.IsRunning() { - return errors.Errorf("container %s is not running", c.ID) + return stateConflictError{errors.Errorf("container %s is not running", c.ID)} } return nil } @@ -90,25 +104,33 @@ func containerIsNotRestarting(c *container.Container) error { } func (daemon *Daemon) setupIpcDirs(c *container.Container) error { - var err error + ipcMode := c.HostConfig.IpcMode - c.ShmPath, err = c.ShmResourcePath() - if err != nil { - return err - } - - if c.HostConfig.IpcMode.IsContainer() { - ic, err := daemon.getIpcContainer(c) + switch { + case ipcMode.IsContainer(): + ic, err := daemon.getIpcContainer(ipcMode.Container()) if err != nil { return err } c.ShmPath = ic.ShmPath - } else if c.HostConfig.IpcMode.IsHost() { + + case ipcMode.IsHost(): if _, err := os.Stat("/dev/shm"); err != nil { return fmt.Errorf("/dev/shm is not mounted, but must be for --ipc=host") } c.ShmPath = "/dev/shm" - } else { + + case ipcMode.IsPrivate(), ipcMode.IsNone(): + // c.ShmPath will/should not be used, so make it empty. + // Container's /dev/shm mount comes from OCI spec. + c.ShmPath = "" + + case ipcMode.IsEmpty(): + // A container was created by an older version of the daemon. + // The default behavior used to be what is now called "shareable". + fallthrough + + case ipcMode.IsShareable(): rootIDs := daemon.idMappings.RootPair() if !c.HasMountFor("/dev/shm") { shmPath, err := c.ShmResourcePath() @@ -120,19 +142,18 @@ func (daemon *Daemon) setupIpcDirs(c *container.Container) error { return err } - shmSize := int64(daemon.configStore.ShmSize) - if c.HostConfig.ShmSize != 0 { - shmSize = c.HostConfig.ShmSize - } - shmproperty := "mode=1777,size=" + strconv.FormatInt(shmSize, 10) + shmproperty := "mode=1777,size=" + strconv.FormatInt(c.HostConfig.ShmSize, 10) if err := unix.Mount("shm", shmPath, "tmpfs", uintptr(unix.MS_NOEXEC|unix.MS_NOSUID|unix.MS_NODEV), label.FormatMountLabel(shmproperty, c.GetMountLabel())); err != nil { return fmt.Errorf("mounting shm tmpfs: %s", err) } if err := os.Chown(shmPath, rootIDs.UID, rootIDs.GID); err != nil { return err } + c.ShmPath = shmPath } + default: + return fmt.Errorf("invalid IPC mode: %v", ipcMode) } return nil @@ -286,6 +307,8 @@ func (daemon *Daemon) setupConfigDir(c *container.Container) (setupErr error) { if err := os.Chown(fPath, rootIDs.UID+uid, rootIDs.GID+gid); err != nil { return errors.Wrap(err, "error setting ownership for config") } + + label.Relabel(fPath, c.MountLabel, false) } return nil diff --git a/vendor/github.com/docker/docker/daemon/create.go b/vendor/github.com/docker/docker/daemon/create.go index cf6133659..c722405db 100644 --- a/vendor/github.com/docker/docker/daemon/create.go +++ b/vendor/github.com/docker/docker/daemon/create.go @@ -9,7 +9,6 @@ import ( "github.com/pkg/errors" - apierrors "github.com/docker/docker/api/errors" "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" networktypes "github.com/docker/docker/api/types/network" @@ -37,17 +36,27 @@ func (daemon *Daemon) ContainerCreate(params types.ContainerCreateConfig) (conta func (daemon *Daemon) containerCreate(params types.ContainerCreateConfig, managed bool) (containertypes.ContainerCreateCreatedBody, error) { start := time.Now() if params.Config == nil { - return containertypes.ContainerCreateCreatedBody{}, fmt.Errorf("Config cannot be empty in order to create a container") + return containertypes.ContainerCreateCreatedBody{}, validationError{errors.New("Config cannot be empty in order to create a container")} } - warnings, err := daemon.verifyContainerSettings(params.HostConfig, params.Config, false) + // TODO: @jhowardmsft LCOW support - at a later point, can remove the hard-coding + // to force the platform to be linux. + // Default the platform if not supplied + if params.Platform == "" { + params.Platform = runtime.GOOS + } + if system.LCOWSupported() { + params.Platform = "linux" + } + + warnings, err := daemon.verifyContainerSettings(params.Platform, params.HostConfig, params.Config, false) if err != nil { - return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, err + return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, validationError{err} } - err = daemon.verifyNetworkingConfig(params.NetworkingConfig) + err = verifyNetworkingConfig(params.NetworkingConfig) if err != nil { - return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, err + return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, validationError{err} } if params.HostConfig == nil { @@ -55,12 +64,12 @@ func (daemon *Daemon) containerCreate(params types.ContainerCreateConfig, manage } err = daemon.adaptContainerSettings(params.HostConfig, params.AdjustCPUShares) if err != nil { - return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, err + return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, validationError{err} } container, err := daemon.create(params, managed) if err != nil { - return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, daemon.imageNotExistToErrcode(err) + return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, err } containerActions.WithValues("create").UpdateSince(start) @@ -76,16 +85,6 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig, managed bool) ( err error ) - // TODO: @jhowardmsft LCOW support - at a later point, can remove the hard-coding - // to force the platform to be linux. - // Default the platform if not supplied - if params.Platform == "" { - params.Platform = runtime.GOOS - } - if system.LCOWSupported() { - params.Platform = "linux" - } - if params.Config.Image != "" { img, err = daemon.GetImage(params.Config.Image) if err != nil { @@ -113,11 +112,11 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig, managed bool) ( } if err := daemon.mergeAndVerifyConfig(params.Config, img); err != nil { - return nil, err + return nil, validationError{err} } if err := daemon.mergeAndVerifyLogConfig(¶ms.HostConfig.LogConfig); err != nil { - return nil, err + return nil, validationError{err} } if container, err = daemon.newContainer(params.Name, params.Platform, params.Config, params.HostConfig, imgID, managed); err != nil { @@ -137,9 +136,26 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig, managed bool) ( container.HostConfig.StorageOpt = params.HostConfig.StorageOpt + // Fixes: https://github.com/moby/moby/issues/34074 and + // https://github.com/docker/for-win/issues/999. + // Merge the daemon's storage options if they aren't already present. We only + // do this on Windows as there's no effective sandbox size limit other than + // physical on Linux. + if runtime.GOOS == "windows" { + if container.HostConfig.StorageOpt == nil { + container.HostConfig.StorageOpt = make(map[string]string) + } + for _, v := range daemon.configStore.GraphOptions { + opt := strings.SplitN(v, "=", 2) + if _, ok := container.HostConfig.StorageOpt[opt[0]]; !ok { + container.HostConfig.StorageOpt[opt[0]] = opt[1] + } + } + } + // Set RWLayer for container after mount labels have been set if err := daemon.setRWLayer(container); err != nil { - return nil, err + return nil, systemError{err} } rootIDs := daemon.idMappings.RootPair() @@ -295,7 +311,7 @@ func (daemon *Daemon) mergeAndVerifyConfig(config *containertypes.Config, img *i // Checks if the client set configurations for more than one network while creating a container // Also checks if the IPAMConfig is valid -func (daemon *Daemon) verifyNetworkingConfig(nwConfig *networktypes.NetworkingConfig) error { +func verifyNetworkingConfig(nwConfig *networktypes.NetworkingConfig) error { if nwConfig == nil || len(nwConfig.EndpointsConfig) == 0 { return nil } @@ -303,14 +319,14 @@ func (daemon *Daemon) verifyNetworkingConfig(nwConfig *networktypes.NetworkingCo for _, v := range nwConfig.EndpointsConfig { if v != nil && v.IPAMConfig != nil { if v.IPAMConfig.IPv4Address != "" && net.ParseIP(v.IPAMConfig.IPv4Address).To4() == nil { - return apierrors.NewBadRequestError(fmt.Errorf("invalid IPv4 address: %s", v.IPAMConfig.IPv4Address)) + return errors.Errorf("invalid IPv4 address: %s", v.IPAMConfig.IPv4Address) } if v.IPAMConfig.IPv6Address != "" { n := net.ParseIP(v.IPAMConfig.IPv6Address) // if the address is an invalid network address (ParseIP == nil) or if it is // an IPv4 address (To4() != nil), then it is an invalid IPv6 address if n == nil || n.To4() != nil { - return apierrors.NewBadRequestError(fmt.Errorf("invalid IPv6 address: %s", v.IPAMConfig.IPv6Address)) + return errors.Errorf("invalid IPv6 address: %s", v.IPAMConfig.IPv6Address) } } } @@ -321,6 +337,5 @@ func (daemon *Daemon) verifyNetworkingConfig(nwConfig *networktypes.NetworkingCo for k := range nwConfig.EndpointsConfig { l = append(l, k) } - err := fmt.Errorf("Container cannot be connected to network endpoints: %s", strings.Join(l, ", ")) - return apierrors.NewBadRequestError(err) + return errors.Errorf("Container cannot be connected to network endpoints: %s", strings.Join(l, ", ")) } diff --git a/vendor/github.com/docker/docker/daemon/create_windows.go b/vendor/github.com/docker/docker/daemon/create_windows.go index bbf0dbe7b..059980b47 100644 --- a/vendor/github.com/docker/docker/daemon/create_windows.go +++ b/vendor/github.com/docker/docker/daemon/create_windows.go @@ -2,6 +2,7 @@ package daemon import ( "fmt" + "runtime" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" @@ -11,14 +12,24 @@ import ( // createContainerPlatformSpecificSettings performs platform specific container create functionality func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig) error { - // Make sure the host config has the default daemon isolation if not specified by caller. - if containertypes.Isolation.IsDefault(containertypes.Isolation(hostConfig.Isolation)) { - hostConfig.Isolation = daemon.defaultIsolation - } + if container.Platform == runtime.GOOS { + // Make sure the host config has the default daemon isolation if not specified by caller. + if containertypes.Isolation.IsDefault(containertypes.Isolation(hostConfig.Isolation)) { + hostConfig.Isolation = daemon.defaultIsolation + } + } else { + // LCOW must be a Hyper-V container as you can't run a shared kernel when one + // is a Windows kernel, the other is a Linux kernel. + if containertypes.Isolation.IsProcess(containertypes.Isolation(hostConfig.Isolation)) { + return fmt.Errorf("process isolation is invalid for Linux containers on Windows") + } + hostConfig.Isolation = "hyperv" + } + parser := volume.NewParser(container.Platform) for spec := range config.Volumes { - mp, err := volume.ParseMountRaw(spec, hostConfig.VolumeDriver) + mp, err := parser.ParseMountRaw(spec, hostConfig.VolumeDriver) if err != nil { return fmt.Errorf("Unrecognised volume spec: %v", err) } diff --git a/vendor/github.com/docker/docker/daemon/daemon.go b/vendor/github.com/docker/docker/daemon/daemon.go index ebfdb68d1..19d22bf70 100644 --- a/vendor/github.com/docker/docker/daemon/daemon.go +++ b/vendor/github.com/docker/docker/daemon/daemon.go @@ -19,7 +19,6 @@ import ( "time" containerd "github.com/containerd/containerd/api/grpc/types" - "github.com/docker/docker/api" "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/swarm" @@ -29,7 +28,7 @@ import ( "github.com/docker/docker/daemon/events" "github.com/docker/docker/daemon/exec" "github.com/docker/docker/daemon/logger" - "github.com/docker/docker/opts" + "github.com/docker/docker/daemon/network" "github.com/sirupsen/logrus" // register graph drivers _ "github.com/docker/docker/daemon/graphdriver/register" @@ -42,12 +41,14 @@ import ( "github.com/docker/docker/layer" "github.com/docker/docker/libcontainerd" "github.com/docker/docker/migrate/v1" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/plugingetter" "github.com/docker/docker/pkg/sysinfo" "github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/truncindex" "github.com/docker/docker/plugin" + pluginexec "github.com/docker/docker/plugin/executor/containerd" refstore "github.com/docker/docker/reference" "github.com/docker/docker/registry" "github.com/docker/docker/runconfig" @@ -66,7 +67,7 @@ var ( // containerd if none is specified DefaultRuntimeBinary = "docker-runc" - errSystemNotSupported = errors.New("The Docker daemon is not supported on this platform.") + errSystemNotSupported = errors.New("the Docker daemon is not supported on this platform") ) type daemonStore struct { @@ -75,7 +76,6 @@ type daemonStore struct { imageStore image.Store layerStore layer.Store distributionMetadataStore dmetadata.Store - referenceStore refstore.Store } // Daemon holds information about the Docker daemon. @@ -103,7 +103,8 @@ type Daemon struct { shutdown bool idMappings *idtools.IDMappings stores map[string]daemonStore // By container target platform - PluginStore *plugin.Store // todo: remove + referenceStore refstore.Store + PluginStore *plugin.Store // todo: remove pluginManager *plugin.Manager linkIndex *linkIndex containerd libcontainerd.Client @@ -123,6 +124,8 @@ type Daemon struct { pruneRunning int32 hosts map[string]bool // hosts stores the addresses the daemon is listening on startupDone chan struct{} + + lbAttachmentStore network.LBAttachmentStore } // StoreHosts stores the addresses the daemon is listening on @@ -490,6 +493,8 @@ func (daemon *Daemon) DaemonLeavesCluster() { } else { logrus.Warnf("failed to initiate ingress network removal: %v", err) } + + daemon.lbAttachmentStore.ClearLBAttachments() } // setClusterProvider sets a component for querying the current cluster state. @@ -642,12 +647,16 @@ func NewDaemon(config *config.Config, registryService registry.Service, containe } registerMetricsPluginCallback(d.PluginStore, metricsSockPath) + createPluginExec := func(m *plugin.Manager) (plugin.Executor, error) { + return pluginexec.New(containerdRemote, m) + } + // Plugin system initialization should happen before restore. Do not change order. d.pluginManager, err = plugin.NewManager(plugin.ManagerConfig{ Root: filepath.Join(config.Root, "plugins"), ExecRoot: getPluginExecRoot(config.Root), Store: d.PluginStore, - Executor: containerdRemote, + CreateExecutor: createPluginExec, RegistryService: registryService, LiveRestoreEnabled: config.LiveRestoreEnabled, LogPluginEvent: d.LogPluginEvent, // todo: make private @@ -691,7 +700,6 @@ func NewDaemon(config *config.Config, registryService registry.Service, containe d.downloadManager = xfer.NewLayerDownloadManager(lsMap, *config.MaxConcurrentDownloads) logrus.Debugf("Max Concurrent Uploads: %d", *config.MaxConcurrentUploads) d.uploadManager = xfer.NewLayerUploadManager(*config.MaxConcurrentUploads) - for platform, ds := range d.stores { imageRoot := filepath.Join(config.Root, "image", ds.graphDriver) ifs, err := image.NewFSStoreBackend(filepath.Join(imageRoot, "imagedb")) @@ -715,7 +723,7 @@ func NewDaemon(config *config.Config, registryService registry.Service, containe return nil, err } - trustKey, err := api.LoadOrCreateTrustKey(config.TrustKeyPath) + trustKey, err := loadOrCreateTrustKey(config.TrustKeyPath) if err != nil { return nil, err } @@ -728,18 +736,30 @@ func NewDaemon(config *config.Config, registryService registry.Service, containe eventsService := events.New() + // We have a single tag/reference store for the daemon globally. However, it's + // stored under the graphdriver. On host platforms which only support a single + // container OS, but multiple selectable graphdrivers, this means depending on which + // graphdriver is chosen, the global reference store is under there. For + // platforms which support multiple container operating systems, this is slightly + // more problematic as where does the global ref store get located? Fortunately, + // for Windows, which is currently the only daemon supporting multiple container + // operating systems, the list of graphdrivers available isn't user configurable. + // For backwards compatibility, we just put it under the windowsfilter + // directory regardless. + refStoreLocation := filepath.Join(d.stores[runtime.GOOS].imageRoot, `repositories.json`) + rs, err := refstore.NewReferenceStore(refStoreLocation) + if err != nil { + return nil, fmt.Errorf("Couldn't create reference store repository: %s", err) + } + d.referenceStore = rs + for platform, ds := range d.stores { dms, err := dmetadata.NewFSMetadataStore(filepath.Join(ds.imageRoot, "distribution"), platform) if err != nil { return nil, err } - rs, err := refstore.NewReferenceStore(filepath.Join(ds.imageRoot, "repositories.json"), platform) - if err != nil { - return nil, fmt.Errorf("Couldn't create Tag store repositories: %s", err) - } ds.distributionMetadataStore = dms - ds.referenceStore = rs d.stores[platform] = ds // No content-addressability migration on Windows as it never supported pre-CA @@ -850,7 +870,7 @@ func (daemon *Daemon) shutdownContainer(c *container.Container) error { // Wait without timeout for the container to exit. // Ignore the result. - _ = <-c.Wait(context.Background(), container.WaitConditionNotRunning) + <-c.Wait(context.Background(), container.WaitConditionNotRunning) return nil } @@ -957,11 +977,11 @@ func (daemon *Daemon) Mount(container *container.Container) error { } logrus.Debugf("container mounted via layerStore: %v", dir) - if container.BaseFS != dir { + if container.BaseFS != nil && container.BaseFS.Path() != dir.Path() { // The mount path reported by the graph driver should always be trusted on Windows, since the // volume path for a given mounted layer may change over time. This should only be an error // on non-Windows operating systems. - if container.BaseFS != "" && runtime.GOOS != "windows" { + if runtime.GOOS != "windows" { daemon.Unmount(container) return fmt.Errorf("Error: driver %s is returning inconsistent paths for container %s ('%s' then '%s')", daemon.GraphDriverName(container.Platform), container.ID, container.BaseFS, dir) @@ -1036,13 +1056,13 @@ func prepareTempDir(rootDir string, rootIDs idtools.IDPair) (string, error) { return tmpDir, idtools.MkdirAllAndChown(tmpDir, 0700, rootIDs) } -func (daemon *Daemon) setupInitLayer(initPath string) error { +func (daemon *Daemon) setupInitLayer(initPath containerfs.ContainerFS) error { rootIDs := daemon.idMappings.RootPair() return initlayer.Setup(initPath, rootIDs) } func (daemon *Daemon) setGenericResources(conf *config.Config) error { - genericResources, err := opts.ParseGenericResources(conf.NodeGenericResources) + genericResources, err := config.ParseGenericResources(conf.NodeGenericResources) if err != nil { return err } @@ -1233,3 +1253,8 @@ func fixMemorySwappiness(resources *containertypes.Resources) { resources.MemorySwappiness = nil } } + +// GetLBAttachmentStore returns current load balancer store associated with the daemon +func (daemon *Daemon) GetLBAttachmentStore() *network.LBAttachmentStore { + return &daemon.lbAttachmentStore +} diff --git a/vendor/github.com/docker/docker/daemon/daemon_solaris.go b/vendor/github.com/docker/docker/daemon/daemon_solaris.go index 53fc6ea92..9c7d67f0b 100644 --- a/vendor/github.com/docker/docker/daemon/daemon_solaris.go +++ b/vendor/github.com/docker/docker/daemon/daemon_solaris.go @@ -10,20 +10,20 @@ import ( "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" + "github.com/docker/docker/daemon/config" "github.com/docker/docker/image" - "github.com/docker/docker/layer" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/fileutils" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/parsers/kernel" "github.com/docker/docker/pkg/sysinfo" - refstore "github.com/docker/docker/reference" "github.com/docker/libnetwork" nwconfig "github.com/docker/libnetwork/config" "github.com/docker/libnetwork/drivers/solaris/bridge" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/netutils" lntypes "github.com/docker/libnetwork/types" - "github.com/opencontainers/runtime-spec/specs-go" + specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/selinux/go-selinux/label" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -33,14 +33,15 @@ import ( import "C" const ( - defaultVirtualSwitch = "Virtual Switch" - platformSupported = true - solarisMinCPUShares = 1 - solarisMaxCPUShares = 65535 + platformSupported = true + solarisMinCPUShares = 1 + solarisMaxCPUShares = 65535 ) func getMemoryResources(config containertypes.Resources) specs.CappedMemory { - memory := specs.CappedMemory{} + memory := specs.CappedMemory{ + DisableOOMKiller: config.OomKillDisable, + } if config.Memory > 0 { memory.Physical = strconv.FormatInt(config.Memory, 10) @@ -72,7 +73,7 @@ func (daemon *Daemon) parseSecurityOpt(container *container.Container, hostConfi } func parseSecurityOpt(container *container.Container, config *containertypes.HostConfig) error { - //Since config.SecurityOpt is specifically defined as a "List of string values to + //Since hostConfig.SecurityOpt is specifically defined as a "List of string values to //customize labels for MLs systems, such as SELinux" //until we figure out how to map to Trusted Extensions //this is being disabled for now on Solaris @@ -89,15 +90,15 @@ func parseSecurityOpt(container *container.Container, config *containertypes.Hos return err } -func setupRemappedRoot(config *Config) ([]idtools.IDMap, []idtools.IDMap, error) { - return nil, nil, nil +func setupRemappedRoot(config *config.Config) (*idtools.IDMappings, error) { + return nil, nil } -func setupDaemonRoot(config *Config, rootDir string, rootUID, rootGID int) error { +func setupDaemonRoot(config *config.Config, rootDir string, rootIDs idtools.IDPair) error { return nil } -func (daemon *Daemon) getLayerInit() func(string) error { +func (daemon *Daemon) getLayerInit() func(containerfs.ContainerFS) error { return nil } @@ -136,7 +137,7 @@ func (daemon *Daemon) adaptContainerSettings(hostConfig *containertypes.HostConf } // UsingSystemd returns true if cli option includes native.cgroupdriver=systemd -func UsingSystemd(config *Config) bool { +func UsingSystemd(config *config.Config) bool { return false } @@ -309,25 +310,26 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. // reloadPlatform updates configuration with platform specific options // and updates the passed attributes -func (daemon *Daemon) reloadPlatform(config *Config, attributes map[string]string) { +func (daemon *Daemon) reloadPlatform(conf *config.Config, attributes map[string]string) error { + return nil } // verifyDaemonSettings performs validation of daemon config struct -func verifyDaemonSettings(config *Config) error { +func verifyDaemonSettings(conf *config.Config) error { - if config.DefaultRuntime == "" { - config.DefaultRuntime = stockRuntimeName + if conf.DefaultRuntime == "" { + conf.DefaultRuntime = stockRuntimeName } - if config.Runtimes == nil { - config.Runtimes = make(map[string]types.Runtime) + if conf.Runtimes == nil { + conf.Runtimes = make(map[string]types.Runtime) } stockRuntimeOpts := []string{} - config.Runtimes[stockRuntimeName] = types.Runtime{Path: DefaultRuntimeBinary, Args: stockRuntimeOpts} + conf.Runtimes[stockRuntimeName] = types.Runtime{Path: DefaultRuntimeBinary, Args: stockRuntimeOpts} - // checkSystem validates platform-specific requirements return nil } +// checkSystem validates platform-specific requirements func checkSystem() error { // check OS version for compatibility, ensure running in global zone var err error @@ -349,16 +351,16 @@ func checkSystem() error { // configureMaxThreads sets the Go runtime max threads threshold // which is 90% of the kernel setting from /proc/sys/kernel/threads-max -func configureMaxThreads(config *Config) error { +func configureMaxThreads(config *config.Config) error { return nil } -// configureKernelSecuritySupport configures and validate security support for the kernel +// configureKernelSecuritySupport configures and validates security support for the kernel func configureKernelSecuritySupport(config *config.Config, driverNames []string) error { return nil } -func (daemon *Daemon) initNetworkController(config *Config, activeSandboxes map[string]interface{}) (libnetwork.NetworkController, error) { +func (daemon *Daemon) initNetworkController(config *config.Config, activeSandboxes map[string]interface{}) (libnetwork.NetworkController, error) { netOptions, err := daemon.networkOptions(config, daemon.PluginStore, activeSandboxes) if err != nil { return nil, err @@ -384,7 +386,7 @@ func (daemon *Daemon) initNetworkController(config *Config, activeSandboxes map[ return controller, nil } -func initBridgeDriver(controller libnetwork.NetworkController, config *Config) error { +func initBridgeDriver(controller libnetwork.NetworkController, config *config.Config) error { if n, err := controller.NetworkByName("bridge"); err == nil { if err = n.Delete(); err != nil { return fmt.Errorf("could not delete the default bridge network: %v", err) @@ -497,12 +499,7 @@ func (daemon *Daemon) conditionalUnmountOnCleanup(container *container.Container return daemon.Unmount(container) } -func restoreCustomImage(is image.Store, ls layer.Store, rs refstore.Store) error { - // Solaris has no custom images to register - return nil -} - -func driverOptions(config *Config) []nwconfig.Option { +func driverOptions(config *config.Config) []nwconfig.Option { return []nwconfig.Option{} } @@ -520,7 +517,7 @@ func rootFSToAPIType(rootfs *image.RootFS) types.RootFS { return types.RootFS{} } -func setupDaemonProcess(config *Config) error { +func setupDaemonProcess(config *config.Config) error { return nil } diff --git a/vendor/github.com/docker/docker/daemon/daemon_unix.go b/vendor/github.com/docker/docker/daemon/daemon_unix.go index ea306ee85..655483c89 100644 --- a/vendor/github.com/docker/docker/daemon/daemon_unix.go +++ b/vendor/github.com/docker/docker/daemon/daemon_unix.go @@ -24,6 +24,7 @@ import ( "github.com/docker/docker/daemon/config" "github.com/docker/docker/image" "github.com/docker/docker/opts" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/parsers/kernel" @@ -64,22 +65,23 @@ const ( cgroupSystemdDriver = "systemd" ) +type containerGetter interface { + GetContainer(string) (*container.Container, error) +} + func getMemoryResources(config containertypes.Resources) *specs.LinuxMemory { memory := specs.LinuxMemory{} if config.Memory > 0 { - limit := uint64(config.Memory) - memory.Limit = &limit + memory.Limit = &config.Memory } if config.MemoryReservation > 0 { - reservation := uint64(config.MemoryReservation) - memory.Reservation = &reservation + memory.Reservation = &config.MemoryReservation } if config.MemorySwap > 0 { - swap := uint64(config.MemorySwap) - memory.Swap = &swap + memory.Swap = &config.MemorySwap } if config.MemorySwappiness != nil { @@ -88,8 +90,7 @@ func getMemoryResources(config containertypes.Resources) *specs.LinuxMemory { } if config.KernelMemory != 0 { - kernelMemory := uint64(config.KernelMemory) - memory.Kernel = &kernelMemory + memory.Kernel = &config.KernelMemory } return &memory @@ -276,6 +277,17 @@ func (daemon *Daemon) adaptContainerSettings(hostConfig *containertypes.HostConf hostConfig.ShmSize = int64(daemon.configStore.ShmSize) } } + // Set default IPC mode, if unset for container + if hostConfig.IpcMode.IsEmpty() { + m := config.DefaultIpcMode + if daemon.configStore != nil { + m = daemon.configStore.IpcMode + } + hostConfig.IpcMode = containertypes.IpcMode(m) + } + + adaptSharedNamespaceContainer(daemon, hostConfig) + var err error opts, err := daemon.generateSecurityOpt(hostConfig) if err != nil { @@ -290,6 +302,36 @@ func (daemon *Daemon) adaptContainerSettings(hostConfig *containertypes.HostConf return nil } +// adaptSharedNamespaceContainer replaces container name with its ID in hostConfig. +// To be more precisely, it modifies `container:name` to `container:ID` of PidMode, IpcMode +// and NetworkMode. +// +// When a container shares its namespace with another container, use ID can keep the namespace +// sharing connection between the two containers even the another container is renamed. +func adaptSharedNamespaceContainer(daemon containerGetter, hostConfig *containertypes.HostConfig) { + containerPrefix := "container:" + if hostConfig.PidMode.IsContainer() { + pidContainer := hostConfig.PidMode.Container() + // if there is any error returned here, we just ignore it and leave it to be + // handled in the following logic + if c, err := daemon.GetContainer(pidContainer); err == nil { + hostConfig.PidMode = containertypes.PidMode(containerPrefix + c.ID) + } + } + if hostConfig.IpcMode.IsContainer() { + ipcContainer := hostConfig.IpcMode.Container() + if c, err := daemon.GetContainer(ipcContainer); err == nil { + hostConfig.IpcMode = containertypes.IpcMode(containerPrefix + c.ID) + } + } + if hostConfig.NetworkMode.IsContainer() { + netContainer := hostConfig.NetworkMode.ConnectedContainer() + if c, err := daemon.GetContainer(netContainer); err == nil { + hostConfig.NetworkMode = containertypes.NetworkMode(containerPrefix + c.ID) + } + } +} + func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysinfo.SysInfo, update bool) ([]string, error) { warnings := []string{} fixMemorySwappiness(resources) @@ -461,6 +503,7 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi warnings = append(warnings, "Your kernel does not support BPS Block I/O write limit or the cgroup is not mounted. Block I/O BPS write limit discarded.") logrus.Warn("Your kernel does not support BPS Block I/O write limit or the cgroup is not mounted. Block I/O BPS write limit discarded.") resources.BlkioDeviceWriteBps = []*pblkiodev.ThrottleDevice{} + } if len(resources.BlkioDeviceReadIOps) > 0 && !sysInfo.BlkioReadIOpsDevice { warnings = append(warnings, "Your kernel does not support IOPS Block read limit or the cgroup is not mounted. Block I/O IOPS read limit discarded.") @@ -547,13 +590,13 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. // check for various conflicting options with user namespaces if daemon.configStore.RemappedRoot != "" && hostConfig.UsernsMode.IsPrivate() { if hostConfig.Privileged { - return warnings, fmt.Errorf("Privileged mode is incompatible with user namespaces") + return warnings, fmt.Errorf("privileged mode is incompatible with user namespaces. You must run the container in the host namespace when running privileged mode") } if hostConfig.NetworkMode.IsHost() && !hostConfig.UsernsMode.IsHost() { - return warnings, fmt.Errorf("Cannot share the host's network namespace when user namespaces are enabled") + return warnings, fmt.Errorf("cannot share the host's network namespace when user namespaces are enabled") } if hostConfig.PidMode.IsHost() && !hostConfig.UsernsMode.IsHost() { - return warnings, fmt.Errorf("Cannot share the host PID namespace when user namespaces are enabled") + return warnings, fmt.Errorf("cannot share the host PID namespace when user namespaces are enabled") } } if hostConfig.CgroupParent != "" && UsingSystemd(daemon.configStore) { @@ -570,8 +613,9 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. return warnings, fmt.Errorf("Unknown runtime specified %s", hostConfig.Runtime) } + parser := volume.NewParser(runtime.GOOS) for dest := range hostConfig.Tmpfs { - if err := volume.ValidateTmpfsMountDestination(dest); err != nil { + if err := parser.ValidateTmpfsMountDestination(dest); err != nil { return warnings, err } } @@ -581,7 +625,11 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. // reloadPlatform updates configuration with platform specific options // and updates the passed attributes -func (daemon *Daemon) reloadPlatform(conf *config.Config, attributes map[string]string) { +func (daemon *Daemon) reloadPlatform(conf *config.Config, attributes map[string]string) error { + if err := conf.ValidatePlatformConfig(); err != nil { + return err + } + if conf.IsValueSet("runtimes") { daemon.configStore.Runtimes = conf.Runtimes // Always set the default one @@ -596,6 +644,10 @@ func (daemon *Daemon) reloadPlatform(conf *config.Config, attributes map[string] daemon.configStore.ShmSize = conf.ShmSize } + if conf.IpcMode != "" { + daemon.configStore.IpcMode = conf.IpcMode + } + // Update attributes var runtimeList bytes.Buffer for name, rt := range daemon.configStore.Runtimes { @@ -608,6 +660,9 @@ func (daemon *Daemon) reloadPlatform(conf *config.Config, attributes map[string] attributes["runtimes"] = runtimeList.String() attributes["default-runtime"] = daemon.configStore.DefaultRuntime attributes["default-shm-size"] = fmt.Sprintf("%d", daemon.configStore.ShmSize) + attributes["default-ipc-mode"] = daemon.configStore.IpcMode + + return nil } // verifyDaemonSettings performs validation of daemon config struct @@ -934,7 +989,7 @@ func removeDefaultBridgeInterface() { } } -func (daemon *Daemon) getLayerInit() func(string) error { +func (daemon *Daemon) getLayerInit() func(containerfs.ContainerFS) error { return daemon.setupInitLayer } @@ -1104,7 +1159,7 @@ func setupDaemonRoot(config *config.Config, rootDir string, rootIDs idtools.IDPa break } if !idtools.CanAccess(dirPath, rootIDs) { - return fmt.Errorf("A subdirectory in your graphroot path (%s) restricts access to the remapped root uid/gid; please fix by allowing 'o+x' permissions on existing directories.", config.Root) + return fmt.Errorf("a subdirectory in your graphroot path (%s) restricts access to the remapped root uid/gid; please fix by allowing 'o+x' permissions on existing directories", config.Root) } } } @@ -1124,13 +1179,13 @@ func (daemon *Daemon) registerLinks(container *container.Container, hostConfig * } child, err := daemon.GetContainer(name) if err != nil { - return fmt.Errorf("Could not get container for %s", name) + return errors.Wrapf(err, "could not get container for %s", name) } for child.HostConfig.NetworkMode.IsContainer() { parts := strings.SplitN(string(child.HostConfig.NetworkMode), ":", 2) child, err = daemon.GetContainer(parts[1]) if err != nil { - return fmt.Errorf("Could not get container for %s", parts[1]) + return errors.Wrapf(err, "Could not get container for %s", parts[1]) } } if child.HostConfig.NetworkMode.IsHost() { @@ -1161,12 +1216,12 @@ func (daemon *Daemon) conditionalUnmountOnCleanup(container *container.Container func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) { if !c.IsRunning() { - return nil, errNotRunning{c.ID} + return nil, errNotRunning(c.ID) } stats, err := daemon.containerd.Stats(c.ID) if err != nil { if strings.Contains(err.Error(), "container not found") { - return nil, errNotFound{c.ID} + return nil, containerNotFound(c.ID) } return nil, err } diff --git a/vendor/github.com/docker/docker/daemon/daemon_unix_test.go b/vendor/github.com/docker/docker/daemon/daemon_unix_test.go index c3aa443e4..2bdbd2329 100644 --- a/vendor/github.com/docker/docker/daemon/daemon_unix_test.go +++ b/vendor/github.com/docker/docker/daemon/daemon_unix_test.go @@ -3,6 +3,7 @@ package daemon import ( + "errors" "io/ioutil" "os" "path/filepath" @@ -16,8 +17,47 @@ import ( "github.com/docker/docker/volume/drivers" "github.com/docker/docker/volume/local" "github.com/docker/docker/volume/store" + "github.com/stretchr/testify/require" ) +type fakeContainerGetter struct { + containers map[string]*container.Container +} + +func (f *fakeContainerGetter) GetContainer(cid string) (*container.Container, error) { + container, ok := f.containers[cid] + if !ok { + return nil, errors.New("container not found") + } + return container, nil +} + +// Unix test as uses settings which are not available on Windows +func TestAdjustSharedNamespaceContainerName(t *testing.T) { + fakeID := "abcdef1234567890" + hostConfig := &containertypes.HostConfig{ + IpcMode: containertypes.IpcMode("container:base"), + PidMode: containertypes.PidMode("container:base"), + NetworkMode: containertypes.NetworkMode("container:base"), + } + containerStore := &fakeContainerGetter{} + containerStore.containers = make(map[string]*container.Container) + containerStore.containers["base"] = &container.Container{ + ID: fakeID, + } + + adaptSharedNamespaceContainer(containerStore, hostConfig) + if hostConfig.IpcMode != containertypes.IpcMode("container:"+fakeID) { + t.Errorf("Expected IpcMode to be container:%s", fakeID) + } + if hostConfig.PidMode != containertypes.PidMode("container:"+fakeID) { + t.Errorf("Expected PidMode to be container:%s", fakeID) + } + if hostConfig.NetworkMode != containertypes.NetworkMode("container:"+fakeID) { + t.Errorf("Expected NetworkMode to be container:%s", fakeID) + } +} + // Unix test as uses settings which are not available on Windows func TestAdjustCPUShares(t *testing.T) { tmp, err := ioutil.TempDir("", "docker-daemon-unix-test-") @@ -250,13 +290,12 @@ func TestMigratePre17Volumes(t *testing.T) { containerRoot := filepath.Join(rootDir, "containers") cid := "1234" err = os.MkdirAll(filepath.Join(containerRoot, cid), 0755) + require.NoError(t, err) vid := "5678" vfsPath := filepath.Join(rootDir, "vfs", "dir", vid) err = os.MkdirAll(vfsPath, 0755) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) config := []byte(` { diff --git a/vendor/github.com/docker/docker/daemon/daemon_windows.go b/vendor/github.com/docker/docker/daemon/daemon_windows.go index d299d52df..c85a1483f 100644 --- a/vendor/github.com/docker/docker/daemon/daemon_windows.go +++ b/vendor/github.com/docker/docker/daemon/daemon_windows.go @@ -5,7 +5,6 @@ import ( "os" "path/filepath" "strings" - "syscall" "github.com/Microsoft/hcsshim" "github.com/docker/docker/api/types" @@ -13,6 +12,7 @@ import ( "github.com/docker/docker/container" "github.com/docker/docker/daemon/config" "github.com/docker/docker/image" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/fileutils" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/parsers" @@ -38,9 +38,6 @@ const ( windowsMaxCPUShares = 10000 windowsMinCPUPercent = 1 windowsMaxCPUPercent = 100 - windowsMinCPUCount = 1 - - errInvalidState = syscall.Errno(0x139F) ) // Windows has no concept of an execution state directory. So use config.Root here. @@ -60,23 +57,7 @@ func parseSecurityOpt(container *container.Container, config *containertypes.Hos return nil } -func getBlkioReadIOpsDevices(config *containertypes.HostConfig) ([]blkiodev.ThrottleDevice, error) { - return nil, nil -} - -func getBlkioWriteIOpsDevices(config *containertypes.HostConfig) ([]blkiodev.ThrottleDevice, error) { - return nil, nil -} - -func getBlkioReadBpsDevices(config *containertypes.HostConfig) ([]blkiodev.ThrottleDevice, error) { - return nil, nil -} - -func getBlkioWriteBpsDevices(config *containertypes.HostConfig) ([]blkiodev.ThrottleDevice, error) { - return nil, nil -} - -func (daemon *Daemon) getLayerInit() func(string) error { +func (daemon *Daemon) getLayerInit() func(containerfs.ContainerFS) error { return nil } @@ -231,7 +212,8 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. // reloadPlatform updates configuration with platform specific options // and updates the passed attributes -func (daemon *Daemon) reloadPlatform(config *config.Config, attributes map[string]string) { +func (daemon *Daemon) reloadPlatform(config *config.Config, attributes map[string]string) error { + return nil } // verifyDaemonSettings performs validation of daemon config struct @@ -519,14 +501,14 @@ func driverOptions(config *config.Config) []nwconfig.Option { func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) { if !c.IsRunning() { - return nil, errNotRunning{c.ID} + return nil, errNotRunning(c.ID) } // Obtain the stats from HCS via libcontainerd stats, err := daemon.containerd.Stats(c.ID) if err != nil { if strings.Contains(err.Error(), "container not found") { - return nil, errNotFound{c.ID} + return nil, containerNotFound(c.ID) } return nil, err } diff --git a/vendor/github.com/docker/docker/daemon/debugtrap_windows.go b/vendor/github.com/docker/docker/daemon/debugtrap_windows.go index 6bd83e544..f7d95c036 100644 --- a/vendor/github.com/docker/docker/daemon/debugtrap_windows.go +++ b/vendor/github.com/docker/docker/daemon/debugtrap_windows.go @@ -7,7 +7,6 @@ import ( winio "github.com/Microsoft/go-winio" "github.com/docker/docker/pkg/signal" - "github.com/docker/docker/pkg/system" "github.com/sirupsen/logrus" "golang.org/x/sys/windows" ) @@ -16,7 +15,7 @@ func (d *Daemon) setupDumpStackTrap(root string) { // Windows does not support signals like *nix systems. So instead of // trapping on SIGUSR1 to dump stacks, we wait on a Win32 event to be // signaled. ACL'd to builtin administrators and local system - ev := "Global\\docker-daemon-" + fmt.Sprint(os.Getpid()) + ev, _ := windows.UTF16PtrFromString("Global\\docker-daemon-" + fmt.Sprint(os.Getpid())) sd, err := winio.SddlToSecurityDescriptor("D:P(A;;GA;;;BA)(A;;GA;;;SY)") if err != nil { logrus.Errorf("failed to get security descriptor for debug stackdump event %s: %s", ev, err.Error()) @@ -26,7 +25,7 @@ func (d *Daemon) setupDumpStackTrap(root string) { sa.Length = uint32(unsafe.Sizeof(sa)) sa.InheritHandle = 1 sa.SecurityDescriptor = uintptr(unsafe.Pointer(&sd[0])) - h, err := system.CreateEvent(&sa, false, false, ev) + h, err := windows.CreateEvent(&sa, 0, 0, ev) if h == 0 || err != nil { logrus.Errorf("failed to create debug stackdump event %s: %s", ev, err.Error()) return diff --git a/vendor/github.com/docker/docker/daemon/delete.go b/vendor/github.com/docker/docker/daemon/delete.go index aea33c84c..99b515d01 100644 --- a/vendor/github.com/docker/docker/daemon/delete.go +++ b/vendor/github.com/docker/docker/daemon/delete.go @@ -7,7 +7,6 @@ import ( "strings" "time" - apierrors "github.com/docker/docker/api/errors" "github.com/docker/docker/api/types" "github.com/docker/docker/container" "github.com/docker/docker/layer" @@ -31,7 +30,7 @@ func (daemon *Daemon) ContainerRm(name string, config *types.ContainerRmConfig) // Container state RemovalInProgress should be used to avoid races. if inProgress := container.SetRemovalInProgress(); inProgress { err := fmt.Errorf("removal of container %s is already in progress", name) - return apierrors.NewBadRequestError(err) + return stateConflictError{err} } defer container.ResetRemovalInProgress() @@ -87,7 +86,7 @@ func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemo procedure = "Unpause and then " + strings.ToLower(procedure) } err := fmt.Errorf("You cannot remove a %s container %s. %s", state, container.ID, procedure) - return apierrors.NewRequestConflictError(err) + return stateConflictError{err} } if err := daemon.Kill(container); err != nil { return fmt.Errorf("Could not kill running container %s, cannot remove - %v", container.ID, err) @@ -128,7 +127,7 @@ func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemo return errors.Wrapf(err, "unable to remove filesystem for %s", container.ID) } - daemon.linkIndex.delete(container) + linkNames := daemon.linkIndex.delete(container) selinuxFreeLxcContexts(container.ProcessLabel) daemon.idIndex.Delete(container.ID) daemon.containers.Delete(container.ID) @@ -136,6 +135,9 @@ func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemo if e := daemon.removeMountPoints(container, removeVolume); e != nil { logrus.Error(e) } + for _, name := range linkNames { + daemon.releaseName(name) + } container.SetRemoved() stateCtr.del(container.ID) daemon.LogContainerEvent(container, "destroy") @@ -148,7 +150,7 @@ func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemo func (daemon *Daemon) VolumeRm(name string, force bool) error { err := daemon.volumeRm(name) if err != nil && volumestore.IsInUse(err) { - return apierrors.NewRequestConflictError(err) + return stateConflictError{err} } if err == nil || force { daemon.volumes.Purge(name) diff --git a/vendor/github.com/docker/docker/daemon/delete_test.go b/vendor/github.com/docker/docker/daemon/delete_test.go index f1a979003..887fa5314 100644 --- a/vendor/github.com/docker/docker/daemon/delete_test.go +++ b/vendor/github.com/docker/docker/daemon/delete_test.go @@ -9,7 +9,7 @@ import ( "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" - "github.com/docker/docker/pkg/testutil" + "github.com/docker/docker/internal/testutil" "github.com/stretchr/testify/require" ) diff --git a/vendor/github.com/docker/docker/daemon/discovery/discovery_test.go b/vendor/github.com/docker/docker/daemon/discovery/discovery_test.go index f084a649a..d5c9966a3 100644 --- a/vendor/github.com/docker/docker/daemon/discovery/discovery_test.go +++ b/vendor/github.com/docker/docker/daemon/discovery/discovery_test.go @@ -4,92 +4,77 @@ import ( "fmt" "testing" "time" -) - -func TestDiscoveryOpts(t *testing.T) { - clusterOpts := map[string]string{"discovery.heartbeat": "10", "discovery.ttl": "5"} - heartbeat, ttl, err := discoveryOpts(clusterOpts) - if err == nil { - t.Fatal("discovery.ttl < discovery.heartbeat must fail") - } - - clusterOpts = map[string]string{"discovery.heartbeat": "10", "discovery.ttl": "10"} - heartbeat, ttl, err = discoveryOpts(clusterOpts) - if err == nil { - t.Fatal("discovery.ttl == discovery.heartbeat must fail") - } - - clusterOpts = map[string]string{"discovery.heartbeat": "-10", "discovery.ttl": "10"} - heartbeat, ttl, err = discoveryOpts(clusterOpts) - if err == nil { - t.Fatal("negative discovery.heartbeat must fail") - } - clusterOpts = map[string]string{"discovery.heartbeat": "10", "discovery.ttl": "-10"} - heartbeat, ttl, err = discoveryOpts(clusterOpts) - if err == nil { - t.Fatal("negative discovery.ttl must fail") - } - - clusterOpts = map[string]string{"discovery.heartbeat": "invalid"} - heartbeat, ttl, err = discoveryOpts(clusterOpts) - if err == nil { - t.Fatal("invalid discovery.heartbeat must fail") - } - - clusterOpts = map[string]string{"discovery.ttl": "invalid"} - heartbeat, ttl, err = discoveryOpts(clusterOpts) - if err == nil { - t.Fatal("invalid discovery.ttl must fail") - } - - clusterOpts = map[string]string{"discovery.heartbeat": "10", "discovery.ttl": "20"} - heartbeat, ttl, err = discoveryOpts(clusterOpts) - if err != nil { - t.Fatal(err) - } + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) - if heartbeat != 10*time.Second { - t.Fatalf("Heartbeat - Expected : %v, Actual : %v", 10*time.Second, heartbeat) +func TestDiscoveryOptsErrors(t *testing.T) { + var testcases = []struct { + doc string + opts map[string]string + }{ + { + doc: "discovery.ttl < discovery.heartbeat", + opts: map[string]string{"discovery.heartbeat": "10", "discovery.ttl": "5"}, + }, + { + doc: "discovery.ttl == discovery.heartbeat", + opts: map[string]string{"discovery.heartbeat": "10", "discovery.ttl": "10"}, + }, + { + doc: "negative discovery.heartbeat", + opts: map[string]string{"discovery.heartbeat": "-10", "discovery.ttl": "10"}, + }, + { + doc: "negative discovery.ttl", + opts: map[string]string{"discovery.heartbeat": "10", "discovery.ttl": "-10"}, + }, + { + doc: "invalid discovery.heartbeat", + opts: map[string]string{"discovery.heartbeat": "invalid"}, + }, + { + doc: "invalid discovery.ttl", + opts: map[string]string{"discovery.ttl": "invalid"}, + }, + } + + for _, testcase := range testcases { + _, _, err := discoveryOpts(testcase.opts) + assert.Error(t, err, testcase.doc) } +} - if ttl != 20*time.Second { - t.Fatalf("TTL - Expected : %v, Actual : %v", 20*time.Second, ttl) - } +func TestDiscoveryOpts(t *testing.T) { + clusterOpts := map[string]string{"discovery.heartbeat": "10", "discovery.ttl": "20"} + heartbeat, ttl, err := discoveryOpts(clusterOpts) + require.NoError(t, err) + assert.Equal(t, 10*time.Second, heartbeat) + assert.Equal(t, 20*time.Second, ttl) clusterOpts = map[string]string{"discovery.heartbeat": "10"} heartbeat, ttl, err = discoveryOpts(clusterOpts) - if err != nil { - t.Fatal(err) - } - - if heartbeat != 10*time.Second { - t.Fatalf("Heartbeat - Expected : %v, Actual : %v", 10*time.Second, heartbeat) - } - - expected := 10 * defaultDiscoveryTTLFactor * time.Second - if ttl != expected { - t.Fatalf("TTL - Expected : %v, Actual : %v", expected, ttl) - } + require.NoError(t, err) + assert.Equal(t, 10*time.Second, heartbeat) + assert.Equal(t, 10*defaultDiscoveryTTLFactor*time.Second, ttl) clusterOpts = map[string]string{"discovery.ttl": "30"} heartbeat, ttl, err = discoveryOpts(clusterOpts) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) if ttl != 30*time.Second { t.Fatalf("TTL - Expected : %v, Actual : %v", 30*time.Second, ttl) } - expected = 30 * time.Second / defaultDiscoveryTTLFactor + expected := 30 * time.Second / defaultDiscoveryTTLFactor if heartbeat != expected { t.Fatalf("Heartbeat - Expected : %v, Actual : %v", expected, heartbeat) } discoveryTTL := fmt.Sprintf("%d", defaultDiscoveryTTLFactor-1) clusterOpts = map[string]string{"discovery.ttl": discoveryTTL} - heartbeat, ttl, err = discoveryOpts(clusterOpts) + heartbeat, _, err = discoveryOpts(clusterOpts) if err == nil && heartbeat == 0 { t.Fatal("discovery.heartbeat must be positive") } diff --git a/vendor/github.com/docker/docker/daemon/disk_usage.go b/vendor/github.com/docker/docker/daemon/disk_usage.go index 23bce4f70..7142ef078 100644 --- a/vendor/github.com/docker/docker/daemon/disk_usage.go +++ b/vendor/github.com/docker/docker/daemon/disk_usage.go @@ -20,7 +20,7 @@ func (daemon *Daemon) getLayerRefs(platform string) map[layer.ChainID]int { layerRefs := map[layer.ChainID]int{} for id, img := range tmpImages { dgst := digest.Digest(id) - if len(daemon.stores[platform].referenceStore.References(dgst)) == 0 && len(daemon.stores[platform].imageStore.Children(id)) != 0 { + if len(daemon.referenceStore.References(dgst)) == 0 && len(daemon.stores[platform].imageStore.Children(id)) != 0 { continue } @@ -99,7 +99,6 @@ func (daemon *Daemon) SystemDiskUsage(ctx context.Context) (*types.DiskUsage, er for platform := range daemon.stores { layerRefs := daemon.getLayerRefs(platform) allLayers := daemon.stores[platform].layerStore.Map() - var allLayersSize int64 for _, l := range allLayers { select { case <-ctx.Done(): diff --git a/vendor/github.com/docker/docker/daemon/errors.go b/vendor/github.com/docker/docker/daemon/errors.go index 5050f87e4..cd8de4dc7 100644 --- a/vendor/github.com/docker/docker/daemon/errors.go +++ b/vendor/github.com/docker/docker/daemon/errors.go @@ -2,52 +2,215 @@ package daemon import ( "fmt" + "strings" + "syscall" - "github.com/docker/docker/api/errors" + "github.com/pkg/errors" + "google.golang.org/grpc" ) -func (d *Daemon) imageNotExistToErrcode(err error) error { - if dne, isDNE := err.(ErrImageDoesNotExist); isDNE { - return errors.NewRequestNotFoundError(dne) - } - return err +func errNotRunning(id string) error { + return stateConflictError{errors.Errorf("Container %s is not running", id)} +} + +func containerNotFound(id string) error { + return objNotFoundError{"container", id} +} + +func volumeNotFound(id string) error { + return objNotFoundError{"volume", id} +} + +func networkNotFound(id string) error { + return objNotFoundError{"network", id} +} + +type objNotFoundError struct { + object string + id string } -type errNotRunning struct { - containerID string +func (e objNotFoundError) Error() string { + return "No such " + e.object + ": " + e.id } -func (e errNotRunning) Error() string { - return fmt.Sprintf("Container %s is not running", e.containerID) +func (e objNotFoundError) NotFound() {} + +type stateConflictError struct { + cause error +} + +func (e stateConflictError) Error() string { + return e.cause.Error() } -func (e errNotRunning) ContainerIsRunning() bool { - return false +func (e stateConflictError) Cause() error { + return e.cause } +func (e stateConflictError) Conflict() {} + func errContainerIsRestarting(containerID string) error { - err := fmt.Errorf("Container %s is restarting, wait until the container is running", containerID) - return errors.NewRequestConflictError(err) + cause := errors.Errorf("Container %s is restarting, wait until the container is running", containerID) + return stateConflictError{cause} } func errExecNotFound(id string) error { - err := fmt.Errorf("No such exec instance '%s' found in daemon", id) - return errors.NewRequestNotFoundError(err) + return objNotFoundError{"exec instance", id} } func errExecPaused(id string) error { - err := fmt.Errorf("Container %s is paused, unpause the container before exec", id) - return errors.NewRequestConflictError(err) + cause := errors.Errorf("Container %s is paused, unpause the container before exec", id) + return stateConflictError{cause} +} + +type validationError struct { + cause error +} + +func (e validationError) Error() string { + return e.cause.Error() +} + +func (e validationError) InvalidParameter() {} + +func (e validationError) Cause() error { + return e.cause +} + +type notAllowedError struct { + cause error +} + +func (e notAllowedError) Error() string { + return e.cause.Error() +} + +func (e notAllowedError) Forbidden() {} + +func (e notAllowedError) Cause() error { + return e.cause } -type errNotFound struct { - containerID string +type containerNotModifiedError struct { + running bool } -func (e errNotFound) Error() string { - return fmt.Sprintf("Container %s is not found", e.containerID) +func (e containerNotModifiedError) Error() string { + if e.running { + return "Container is already started" + } + return "Container is already stopped" +} + +func (e containerNotModifiedError) NotModified() {} + +type systemError struct { + cause error +} + +func (e systemError) Error() string { + return e.cause.Error() +} + +func (e systemError) SystemError() {} + +func (e systemError) Cause() error { + return e.cause } -func (e errNotFound) ContainerNotFound() bool { - return true +type invalidIdentifier string + +func (e invalidIdentifier) Error() string { + return fmt.Sprintf("invalid name or ID supplied: %q", string(e)) +} + +func (invalidIdentifier) InvalidParameter() {} + +type duplicateMountPointError string + +func (e duplicateMountPointError) Error() string { + return "Duplicate mount point: " + string(e) +} +func (duplicateMountPointError) InvalidParameter() {} + +type containerFileNotFound struct { + file string + container string +} + +func (e containerFileNotFound) Error() string { + return "Could not find the file " + e.file + " in container " + e.container +} + +func (containerFileNotFound) NotFound() {} + +type invalidFilter struct { + filter string + value interface{} +} + +func (e invalidFilter) Error() string { + msg := "Invalid filter '" + e.filter + if e.value != nil { + msg += fmt.Sprintf("=%s", e.value) + } + return msg + "'" +} + +func (e invalidFilter) InvalidParameter() {} + +type unknownError struct { + cause error +} + +func (e unknownError) Error() string { + return e.cause.Error() +} + +func (unknownError) Unknown() {} + +func (e unknownError) Cause() error { + return e.cause +} + +type startInvalidConfigError string + +func (e startInvalidConfigError) Error() string { + return string(e) +} + +func (e startInvalidConfigError) InvalidParameter() {} // Is this right??? + +func translateContainerdStartErr(cmd string, setExitCode func(int), err error) error { + errDesc := grpc.ErrorDesc(err) + contains := func(s1, s2 string) bool { + return strings.Contains(strings.ToLower(s1), s2) + } + var retErr error = unknownError{errors.New(errDesc)} + // if we receive an internal error from the initial start of a container then lets + // return it instead of entering the restart loop + // set to 127 for container cmd not found/does not exist) + if contains(errDesc, cmd) && + (contains(errDesc, "executable file not found") || + contains(errDesc, "no such file or directory") || + contains(errDesc, "system cannot find the file specified")) { + setExitCode(127) + retErr = startInvalidConfigError(errDesc) + } + // set to 126 for container cmd can't be invoked errors + if contains(errDesc, syscall.EACCES.Error()) { + setExitCode(126) + retErr = startInvalidConfigError(errDesc) + } + + // attempted to mount a file onto a directory, or a directory onto a file, maybe from user specified bind mounts + if contains(errDesc, syscall.ENOTDIR.Error()) { + errDesc += ": Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type" + setExitCode(127) + retErr = startInvalidConfigError(errDesc) + } + + // TODO: it would be nice to get some better errors from containerd so we can return better errors here + return retErr } diff --git a/vendor/github.com/docker/docker/daemon/exec.go b/vendor/github.com/docker/docker/daemon/exec.go index e77970968..9b3e583bf 100644 --- a/vendor/github.com/docker/docker/daemon/exec.go +++ b/vendor/github.com/docker/docker/daemon/exec.go @@ -8,7 +8,6 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/errors" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/strslice" "github.com/docker/docker/container" @@ -18,6 +17,7 @@ import ( "github.com/docker/docker/pkg/pools" "github.com/docker/docker/pkg/signal" "github.com/docker/docker/pkg/term" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -81,7 +81,7 @@ func (d *Daemon) getActiveContainer(name string) (*container.Container, error) { } if !container.IsRunning() { - return nil, errNotRunning{container.ID} + return nil, errNotRunning(container.ID) } if container.IsPaused() { return nil, errExecPaused(name) @@ -142,7 +142,7 @@ func (d *Daemon) ContainerExecCreate(name string, config *types.ExecConfig) (str // ContainerExecStart starts a previously set up exec instance. The // std streams are set up. // If ctx is cancelled, the process is terminated. -func (d *Daemon) ContainerExecStart(ctx context.Context, name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) (err error) { +func (d *Daemon) ContainerExecStart(ctx context.Context, name string, stdin io.Reader, stdout io.Writer, stderr io.Writer) (err error) { var ( cStdin io.ReadCloser cStdout, cStderr io.Writer @@ -157,12 +157,12 @@ func (d *Daemon) ContainerExecStart(ctx context.Context, name string, stdin io.R if ec.ExitCode != nil { ec.Unlock() err := fmt.Errorf("Error: Exec command %s has already run", ec.ID) - return errors.NewRequestConflictError(err) + return stateConflictError{err} } if ec.Running { ec.Unlock() - return fmt.Errorf("Error: Exec command %s is already running", ec.ID) + return stateConflictError{fmt.Errorf("Error: Exec command %s is already running", ec.ID)} } ec.Running = true ec.Unlock() @@ -233,7 +233,7 @@ func (d *Daemon) ContainerExecStart(ctx context.Context, name string, stdin io.R systemPid, err := d.containerd.AddProcess(ctx, c.ID, name, p, ec.InitializeStdio) if err != nil { - return err + return translateContainerdStartErr(ec.Entrypoint, ec.SetExitCode, err) } ec.Lock() ec.Pid = systemPid @@ -254,7 +254,7 @@ func (d *Daemon) ContainerExecStart(ctx context.Context, name string, stdin io.R case err := <-attachErr: if err != nil { if _, ok := err.(term.EscapeError); !ok { - return fmt.Errorf("exec attach failed with error: %v", err) + return errors.Wrap(systemError{err}, "exec attach failed") } d.LogContainerEvent(c, "exec_detach") } diff --git a/vendor/github.com/docker/docker/daemon/exec/exec.go b/vendor/github.com/docker/docker/daemon/exec/exec.go index 471113cc4..f4efb4d54 100644 --- a/vendor/github.com/docker/docker/daemon/exec/exec.go +++ b/vendor/github.com/docker/docker/daemon/exec/exec.go @@ -62,6 +62,11 @@ func (c *Config) CloseStreams() error { return c.StreamConfig.CloseStreams() } +// SetExitCode sets the exec config's exit code +func (c *Config) SetExitCode(code int) { + c.ExitCode = &code +} + // Store keeps track of the exec configurations. type Store struct { commands map[string]*Config @@ -70,7 +75,7 @@ type Store struct { // NewStore initializes a new exec store. func NewStore() *Store { - return &Store{commands: make(map[string]*Config, 0)} + return &Store{commands: make(map[string]*Config)} } // Commands returns the exec configurations in the store. diff --git a/vendor/github.com/docker/docker/daemon/export.go b/vendor/github.com/docker/docker/daemon/export.go index 402e67583..730387d76 100644 --- a/vendor/github.com/docker/docker/daemon/export.go +++ b/vendor/github.com/docker/docker/daemon/export.go @@ -13,15 +13,15 @@ import ( // ContainerExport writes the contents of the container to the given // writer. An error is returned if the container cannot be found. func (daemon *Daemon) ContainerExport(name string, out io.Writer) error { - if runtime.GOOS == "windows" { - return fmt.Errorf("the daemon on this platform does not support export of a container") - } - container, err := daemon.GetContainer(name) if err != nil { return err } + if runtime.GOOS == "windows" && container.Platform == "windows" { + return fmt.Errorf("the daemon on this platform does not support exporting Windows containers") + } + data, err := daemon.containerExport(container) if err != nil { return fmt.Errorf("Error exporting container %s: %v", name, err) @@ -40,7 +40,7 @@ func (daemon *Daemon) containerExport(container *container.Container) (io.ReadCl return nil, err } - archive, err := archive.TarWithOptions(container.BaseFS, &archive.TarOptions{ + archive, err := archivePath(container.BaseFS, container.BaseFS.Path(), &archive.TarOptions{ Compression: archive.Uncompressed, UIDMaps: daemon.idMappings.UIDs(), GIDMaps: daemon.idMappings.GIDs(), diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/aufs/aufs.go b/vendor/github.com/docker/docker/daemon/graphdriver/aufs/aufs.go index 81edb8ea9..8313263ff 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/aufs/aufs.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/aufs/aufs.go @@ -38,6 +38,7 @@ import ( "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/chrootarchive" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/directory" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/locker" @@ -141,6 +142,30 @@ func Init(root string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap return nil, err } } + logger := logrus.WithFields(logrus.Fields{ + "module": "graphdriver", + "driver": "aufs", + }) + + for _, path := range []string{"mnt", "diff"} { + p := filepath.Join(root, path) + entries, err := ioutil.ReadDir(p) + if err != nil { + logger.WithError(err).WithField("dir", p).Error("error reading dir entries") + continue + } + for _, entry := range entries { + if !entry.IsDir() { + continue + } + if strings.HasSuffix(entry.Name(), "-removing") { + logger.WithField("dir", entry.Name()).Debug("Cleaning up stale layer dir") + if err := system.EnsureRemoveAll(filepath.Join(p, entry.Name())); err != nil { + logger.WithField("dir", entry.Name()).WithError(err).Error("Error removing stale layer dir") + } + } + } + } a.naiveDiff = graphdriver.NewNaiveDiffDriver(a, uidMaps, gidMaps) return a, nil @@ -317,31 +342,25 @@ func (a *Driver) Remove(id string) error { retries++ logger.Warnf("unmount failed due to EBUSY: retry count: %d", retries) time.Sleep(100 * time.Millisecond) - continue } - // Atomically remove each directory in turn by first moving it out of the - // way (so that docker doesn't find it anymore) before doing removal of - // the whole tree. - tmpMntPath := path.Join(a.mntPath(), fmt.Sprintf("%s-removing", id)) - if err := os.Rename(mountpoint, tmpMntPath); err != nil && !os.IsNotExist(err) { - if err == unix.EBUSY { - logger.WithField("dir", mountpoint).WithError(err).Warn("os.Rename err due to EBUSY") - } - return errors.Wrapf(err, "error preparing atomic delete of aufs mountpoint for id: %s", id) - } - if err := system.EnsureRemoveAll(tmpMntPath); err != nil { - return errors.Wrapf(err, "error removing aufs layer %s", id) + // Remove the layers file for the id + if err := os.Remove(path.Join(a.rootPath(), "layers", id)); err != nil && !os.IsNotExist(err) { + return errors.Wrapf(err, "error removing layers dir for %s", id) } - tmpDiffpath := path.Join(a.diffPath(), fmt.Sprintf("%s-removing", id)) - if err := os.Rename(a.getDiffPath(id), tmpDiffpath); err != nil && !os.IsNotExist(err) { - return errors.Wrapf(err, "error preparing atomic delete of aufs diff dir for id: %s", id) + if err := atomicRemove(a.getDiffPath(id)); err != nil { + return errors.Wrapf(err, "could not remove diff path for id %s", id) } - // Remove the layers file for the id - if err := os.Remove(path.Join(a.rootPath(), "layers", id)); err != nil && !os.IsNotExist(err) { - return errors.Wrapf(err, "error removing layers dir for %s", id) + // Atomically remove each directory in turn by first moving it out of the + // way (so that docker doesn't find it anymore) before doing removal of + // the whole tree. + if err := atomicRemove(mountpoint); err != nil { + if errors.Cause(err) == unix.EBUSY { + logger.WithField("dir", mountpoint).WithError(err).Warn("error performing atomic remove due to EBUSY") + } + return errors.Wrapf(err, "could not remove mountpoint for id %s", id) } a.pathCacheLock.Lock() @@ -350,14 +369,32 @@ func (a *Driver) Remove(id string) error { return nil } +func atomicRemove(source string) error { + target := source + "-removing" + + err := os.Rename(source, target) + switch { + case err == nil, os.IsNotExist(err): + case os.IsExist(err): + // Got error saying the target dir already exists, maybe the source doesn't exist due to a previous (failed) remove + if _, e := os.Stat(source); !os.IsNotExist(e) { + return errors.Wrapf(err, "target rename dir '%s' exists but should not, this needs to be manually cleaned up") + } + default: + return errors.Wrapf(err, "error preparing atomic delete") + } + + return system.EnsureRemoveAll(target) +} + // Get returns the rootfs path for the id. // This will mount the dir at its given path -func (a *Driver) Get(id, mountLabel string) (string, error) { +func (a *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { a.locker.Lock(id) defer a.locker.Unlock(id) parents, err := a.getParentLayerPaths(id) if err != nil && !os.IsNotExist(err) { - return "", err + return nil, err } a.pathCacheLock.Lock() @@ -371,21 +408,21 @@ func (a *Driver) Get(id, mountLabel string) (string, error) { } } if count := a.ctr.Increment(m); count > 1 { - return m, nil + return containerfs.NewLocalContainerFS(m), nil } // If a dir does not have a parent ( no layers )do not try to mount // just return the diff path to the data if len(parents) > 0 { if err := a.mount(id, m, mountLabel, parents); err != nil { - return "", err + return nil, err } } a.pathCacheLock.Lock() a.pathCache[id] = m a.pathCacheLock.Unlock() - return m, nil + return containerfs.NewLocalContainerFS(m), nil } // Put unmounts and updates list of active mounts. diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/aufs/aufs_test.go b/vendor/github.com/docker/docker/daemon/graphdriver/aufs/aufs_test.go index baf0fd89f..a58f18a0d 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/aufs/aufs_test.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/aufs/aufs_test.go @@ -9,6 +9,7 @@ import ( "io/ioutil" "os" "path" + "path/filepath" "sync" "testing" @@ -16,6 +17,8 @@ import ( "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/reexec" "github.com/docker/docker/pkg/stringid" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) var ( @@ -39,6 +42,14 @@ func testInit(dir string, t testing.TB) graphdriver.Driver { return d } +func driverGet(d *Driver, id string, mntLabel string) (string, error) { + mnt, err := d.Get(id, mntLabel) + if err != nil { + return "", err + } + return mnt.Path(), nil +} + func newDriver(t testing.TB) *Driver { if err := os.MkdirAll(tmp, 0755); err != nil { t.Fatal(err) @@ -147,7 +158,10 @@ func TestRemoveImage(t *testing.T) { for _, p := range paths { if _, err := os.Stat(path.Join(tmp, p, "1")); err == nil { - t.Fatalf("Error should not be nil because dirs with id 1 should be delted: %s", p) + t.Fatalf("Error should not be nil because dirs with id 1 should be deleted: %s", p) + } + if _, err := os.Stat(path.Join(tmp, p, "1-removing")); err == nil { + t.Fatalf("Error should not be nil because dirs with id 1-removing should be deleted: %s", p) } } } @@ -165,7 +179,7 @@ func TestGetWithoutParent(t *testing.T) { t.Fatal(err) } expected := path.Join(tmp, "diff", "1") - if diffPath != expected { + if diffPath.Path() != expected { t.Fatalf("Expected path %s got %s", expected, diffPath) } } @@ -174,9 +188,8 @@ func TestCleanupWithNoDirs(t *testing.T) { d := newDriver(t) defer os.RemoveAll(tmp) - if err := d.Cleanup(); err != nil { - t.Fatal(err) - } + err := d.Cleanup() + assert.NoError(t, err) } func TestCleanupWithDir(t *testing.T) { @@ -196,18 +209,12 @@ func TestMountedFalseResponse(t *testing.T) { d := newDriver(t) defer os.RemoveAll(tmp) - if err := d.Create("1", "", nil); err != nil { - t.Fatal(err) - } + err := d.Create("1", "", nil) + require.NoError(t, err) response, err := d.mounted(d.getDiffPath("1")) - if err != nil { - t.Fatal(err) - } - - if response != false { - t.Fatal("Response if dir id 1 is mounted should be false") - } + require.NoError(t, err) + assert.False(t, response) } func TestMountedTrueResponse(t *testing.T) { @@ -215,26 +222,17 @@ func TestMountedTrueResponse(t *testing.T) { defer os.RemoveAll(tmp) defer d.Cleanup() - if err := d.Create("1", "", nil); err != nil { - t.Fatal(err) - } - if err := d.Create("2", "1", nil); err != nil { - t.Fatal(err) - } + err := d.Create("1", "", nil) + require.NoError(t, err) + err = d.Create("2", "1", nil) + require.NoError(t, err) - _, err := d.Get("2", "") - if err != nil { - t.Fatal(err) - } + _, err = d.Get("2", "") + require.NoError(t, err) response, err := d.mounted(d.pathCache["2"]) - if err != nil { - t.Fatal(err) - } - - if response != true { - t.Fatal("Response if dir id 2 is mounted should be true") - } + require.NoError(t, err) + assert.True(t, response) } func TestMountWithParent(t *testing.T) { @@ -258,13 +256,13 @@ func TestMountWithParent(t *testing.T) { if err != nil { t.Fatal(err) } - if mntPath == "" { - t.Fatal("mntPath should not be empty string") + if mntPath == nil { + t.Fatal("mntPath should not be nil") } expected := path.Join(tmp, "mnt", "2") - if mntPath != expected { - t.Fatalf("Expected %s got %s", expected, mntPath) + if mntPath.Path() != expected { + t.Fatalf("Expected %s got %s", expected, mntPath.Path()) } } @@ -289,8 +287,8 @@ func TestRemoveMountedDir(t *testing.T) { if err != nil { t.Fatal(err) } - if mntPath == "" { - t.Fatal("mntPath should not be empty string") + if mntPath == nil { + t.Fatal("mntPath should not be nil") } mounted, err := d.mounted(d.pathCache["2"]) @@ -324,7 +322,7 @@ func TestGetDiff(t *testing.T) { t.Fatal(err) } - diffPath, err := d.Get("1", "") + diffPath, err := driverGet(d, "1", "") if err != nil { t.Fatal(err) } @@ -368,7 +366,7 @@ func TestChanges(t *testing.T) { } }() - mntPoint, err := d.Get("2", "") + mntPoint, err := driverGet(d, "2", "") if err != nil { t.Fatal(err) } @@ -407,7 +405,7 @@ func TestChanges(t *testing.T) { if err := d.CreateReadWrite("3", "2", nil); err != nil { t.Fatal(err) } - mntPoint, err = d.Get("3", "") + mntPoint, err = driverGet(d, "3", "") if err != nil { t.Fatal(err) } @@ -453,7 +451,7 @@ func TestDiffSize(t *testing.T) { t.Fatal(err) } - diffPath, err := d.Get("1", "") + diffPath, err := driverGet(d, "1", "") if err != nil { t.Fatal(err) } @@ -495,7 +493,7 @@ func TestChildDiffSize(t *testing.T) { t.Fatal(err) } - diffPath, err := d.Get("1", "") + diffPath, err := driverGet(d, "1", "") if err != nil { t.Fatal(err) } @@ -569,9 +567,8 @@ func TestStatus(t *testing.T) { } status := d.Status() - if status == nil || len(status) == 0 { - t.Fatal("Status should not be nil or empty") - } + assert.Len(t, status, 4) + rootDir := status[0] dirs := status[2] if rootDir[0] != "Root Dir" { @@ -597,7 +594,7 @@ func TestApplyDiff(t *testing.T) { t.Fatal(err) } - diffPath, err := d.Get("1", "") + diffPath, err := driverGet(d, "1", "") if err != nil { t.Fatal(err) } @@ -632,7 +629,7 @@ func TestApplyDiff(t *testing.T) { // Ensure that the file is in the mount point for id 3 - mountPoint, err := d.Get("3", "") + mountPoint, err := driverGet(d, "3", "") if err != nil { t.Fatal(err) } @@ -672,48 +669,34 @@ func testMountMoreThan42Layers(t *testing.T, mountPath string) { } current = hash(current) - if err := d.CreateReadWrite(current, parent, nil); err != nil { - t.Logf("Current layer %d", i) - t.Error(err) - } - point, err := d.Get(current, "") - if err != nil { - t.Logf("Current layer %d", i) - t.Error(err) - } + err := d.CreateReadWrite(current, parent, nil) + require.NoError(t, err, "current layer %d", i) + + point, err := driverGet(d, current, "") + require.NoError(t, err, "current layer %d", i) + f, err := os.Create(path.Join(point, current)) - if err != nil { - t.Logf("Current layer %d", i) - t.Error(err) - } + require.NoError(t, err, "current layer %d", i) f.Close() if i%10 == 0 { - if err := os.Remove(path.Join(point, parent)); err != nil { - t.Logf("Current layer %d", i) - t.Error(err) - } + err := os.Remove(path.Join(point, parent)) + require.NoError(t, err, "current layer %d", i) expected-- } last = current } // Perform the actual mount for the top most image - point, err := d.Get(last, "") - if err != nil { - t.Error(err) - } + point, err := driverGet(d, last, "") + require.NoError(t, err) files, err := ioutil.ReadDir(point) - if err != nil { - t.Error(err) - } - if len(files) != expected { - t.Errorf("Expected %d got %d", expected, len(files)) - } + require.NoError(t, err) + assert.Len(t, files, expected) } func TestMountMoreThan42Layers(t *testing.T) { - os.RemoveAll(tmpOuter) + defer os.RemoveAll(tmpOuter) testMountMoreThan42Layers(t, tmp) } @@ -800,3 +783,23 @@ func BenchmarkConcurrentAccess(b *testing.B) { } } } + +func TestInitStaleCleanup(t *testing.T) { + if err := os.MkdirAll(tmp, 0755); err != nil { + t.Fatal(err) + } + defer os.RemoveAll(tmp) + + for _, d := range []string{"diff", "mnt"} { + if err := os.MkdirAll(filepath.Join(tmp, d, "123-removing"), 0755); err != nil { + t.Fatal(err) + } + } + + testInit(tmp, t) + for _, d := range []string{"diff", "mnt"} { + if _, err := os.Stat(filepath.Join(tmp, d, "123-removing")); err == nil { + t.Fatal("cleanup failed") + } + } +} diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/btrfs/btrfs.go b/vendor/github.com/docker/docker/daemon/graphdriver/btrfs/btrfs.go index dcdfc9a86..5a6121734 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/btrfs/btrfs.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/btrfs/btrfs.go @@ -27,6 +27,7 @@ import ( "unsafe" "github.com/docker/docker/daemon/graphdriver" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/parsers" @@ -631,29 +632,29 @@ func (d *Driver) Remove(id string) error { } // Get the requested filesystem id. -func (d *Driver) Get(id, mountLabel string) (string, error) { +func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { dir := d.subvolumesDirID(id) st, err := os.Stat(dir) if err != nil { - return "", err + return nil, err } if !st.IsDir() { - return "", fmt.Errorf("%s: not a directory", dir) + return nil, fmt.Errorf("%s: not a directory", dir) } if quota, err := ioutil.ReadFile(d.quotasDirID(id)); err == nil { if size, err := strconv.ParseUint(string(quota), 10, 64); err == nil && size >= d.options.minSpace { if err := d.subvolEnableQuota(); err != nil { - return "", err + return nil, err } if err := subvolLimitQgroup(dir, size); err != nil { - return "", err + return nil, err } } } - return dir, nil + return containerfs.NewLocalContainerFS(dir), nil } // Put is not implemented for BTRFS as there is no cleanup required for the id. diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/btrfs/btrfs_test.go b/vendor/github.com/docker/docker/daemon/graphdriver/btrfs/btrfs_test.go index 0038dbcdc..056b99b94 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/btrfs/btrfs_test.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/btrfs/btrfs_test.go @@ -35,12 +35,14 @@ func TestBtrfsSubvolDelete(t *testing.T) { } defer graphtest.PutDriver(t) - dir, err := d.Get("test", "") + dirFS, err := d.Get("test", "") if err != nil { t.Fatal(err) } defer d.Put("test") + dir := dirFS.Path() + if err := subvolCreate(dir, "subvoltest"); err != nil { t.Fatal(err) } diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/devmapper/device_setup.go b/vendor/github.com/docker/docker/daemon/graphdriver/devmapper/device_setup.go index 05a295cb6..30463f23a 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/devmapper/device_setup.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/devmapper/device_setup.go @@ -172,29 +172,18 @@ func writeLVMConfig(root string, cfg directLVMConfig) error { } func setupDirectLVM(cfg directLVMConfig) error { - pvCreate, err := exec.LookPath("pvcreate") - if err != nil { - return errors.Wrap(err, "error looking up command `pvcreate` while setting up direct lvm") - } - - vgCreate, err := exec.LookPath("vgcreate") - if err != nil { - return errors.Wrap(err, "error looking up command `vgcreate` while setting up direct lvm") - } + lvmProfileDir := "/etc/lvm/profile" + binaries := []string{"pvcreate", "vgcreate", "lvcreate", "lvconvert", "lvchange", "thin_check"} - lvCreate, err := exec.LookPath("lvcreate") - if err != nil { - return errors.Wrap(err, "error looking up command `lvcreate` while setting up direct lvm") - } - - lvConvert, err := exec.LookPath("lvconvert") - if err != nil { - return errors.Wrap(err, "error looking up command `lvconvert` while setting up direct lvm") + for _, bin := range binaries { + if _, err := exec.LookPath(bin); err != nil { + return errors.Wrap(err, "error looking up command `"+bin+"` while setting up direct lvm") + } } - lvChange, err := exec.LookPath("lvchange") + err := os.MkdirAll(lvmProfileDir, 0755) if err != nil { - return errors.Wrap(err, "error looking up command `lvchange` while setting up direct lvm") + return errors.Wrap(err, "error creating lvm profile directory") } if cfg.AutoExtendPercent == 0 { @@ -212,36 +201,36 @@ func setupDirectLVM(cfg directLVMConfig) error { cfg.ThinpMetaPercent = 1 } - out, err := exec.Command(pvCreate, "-f", cfg.Device).CombinedOutput() + out, err := exec.Command("pvcreate", "-f", cfg.Device).CombinedOutput() if err != nil { return errors.Wrap(err, string(out)) } - out, err = exec.Command(vgCreate, "docker", cfg.Device).CombinedOutput() + out, err = exec.Command("vgcreate", "docker", cfg.Device).CombinedOutput() if err != nil { return errors.Wrap(err, string(out)) } - out, err = exec.Command(lvCreate, "--wipesignatures", "y", "-n", "thinpool", "docker", "--extents", fmt.Sprintf("%d%%VG", cfg.ThinpPercent)).CombinedOutput() + out, err = exec.Command("lvcreate", "--wipesignatures", "y", "-n", "thinpool", "docker", "--extents", fmt.Sprintf("%d%%VG", cfg.ThinpPercent)).CombinedOutput() if err != nil { return errors.Wrap(err, string(out)) } - out, err = exec.Command(lvCreate, "--wipesignatures", "y", "-n", "thinpoolmeta", "docker", "--extents", fmt.Sprintf("%d%%VG", cfg.ThinpMetaPercent)).CombinedOutput() + out, err = exec.Command("lvcreate", "--wipesignatures", "y", "-n", "thinpoolmeta", "docker", "--extents", fmt.Sprintf("%d%%VG", cfg.ThinpMetaPercent)).CombinedOutput() if err != nil { return errors.Wrap(err, string(out)) } - out, err = exec.Command(lvConvert, "-y", "--zero", "n", "-c", "512K", "--thinpool", "docker/thinpool", "--poolmetadata", "docker/thinpoolmeta").CombinedOutput() + out, err = exec.Command("lvconvert", "-y", "--zero", "n", "-c", "512K", "--thinpool", "docker/thinpool", "--poolmetadata", "docker/thinpoolmeta").CombinedOutput() if err != nil { return errors.Wrap(err, string(out)) } profile := fmt.Sprintf("activation{\nthin_pool_autoextend_threshold=%d\nthin_pool_autoextend_percent=%d\n}", cfg.AutoExtendThreshold, cfg.AutoExtendPercent) - err = ioutil.WriteFile("/etc/lvm/profile/docker-thinpool.profile", []byte(profile), 0600) + err = ioutil.WriteFile(lvmProfileDir+"/docker-thinpool.profile", []byte(profile), 0600) if err != nil { return errors.Wrap(err, "error writing docker thinp autoextend profile") } - out, err = exec.Command(lvChange, "--metadataprofile", "docker-thinpool", "docker/thinpool").CombinedOutput() + out, err = exec.Command("lvchange", "--metadataprofile", "docker-thinpool", "docker/thinpool").CombinedOutput() return errors.Wrap(err, string(out)) } diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/devmapper/deviceset.go b/vendor/github.com/docker/docker/daemon/graphdriver/devmapper/deviceset.go index d52a7f591..deb8c87d1 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/devmapper/deviceset.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/devmapper/deviceset.go @@ -21,10 +21,12 @@ import ( "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/dockerversion" "github.com/docker/docker/pkg/devicemapper" + "github.com/docker/docker/pkg/dmesg" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/loopback" "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/parsers" + "github.com/docker/docker/pkg/parsers/kernel" units "github.com/docker/go-units" "github.com/opencontainers/selinux/go-selinux/label" "github.com/pkg/errors" @@ -533,11 +535,11 @@ func (devices *DeviceSet) activateDeviceIfNeeded(info *devInfo, ignoreDeleted bo return devicemapper.ActivateDevice(devices.getPoolDevName(), info.Name(), info.DeviceID, info.Size) } -// Return true only if kernel supports xfs and mkfs.xfs is available -func xfsSupported() bool { +// xfsSupported checks if xfs is supported, returns nil if it is, otherwise an error +func xfsSupported() error { // Make sure mkfs.xfs is available if _, err := exec.LookPath("mkfs.xfs"); err != nil { - return false + return err // error text is descriptive enough } // Check if kernel supports xfs filesystem or not. @@ -545,40 +547,47 @@ func xfsSupported() bool { f, err := os.Open("/proc/filesystems") if err != nil { - logrus.Warnf("devmapper: Could not check if xfs is supported: %v", err) - return false + return errors.Wrapf(err, "error checking for xfs support") } defer f.Close() s := bufio.NewScanner(f) for s.Scan() { if strings.HasSuffix(s.Text(), "\txfs") { - return true + return nil } } if err := s.Err(); err != nil { - logrus.Warnf("devmapper: Could not check if xfs is supported: %v", err) + return errors.Wrapf(err, "error checking for xfs support") } - return false + + return errors.New(`kernel does not support xfs, or "modprobe xfs" failed`) } func determineDefaultFS() string { - if xfsSupported() { + err := xfsSupported() + if err == nil { return "xfs" } - logrus.Warn("devmapper: XFS is not supported in your system. Either the kernel doesn't support it or mkfs.xfs is not in your PATH. Defaulting to ext4 filesystem") + logrus.Warnf("devmapper: XFS is not supported in your system (%v). Defaulting to ext4 filesystem", err) return "ext4" } -func (devices *DeviceSet) createFilesystem(info *devInfo) (err error) { - devname := info.DevName() +// mkfsOptions tries to figure out whether some additional mkfs options are required +func mkfsOptions(fs string) []string { + if fs == "xfs" && !kernel.CheckKernelVersion(3, 16, 0) { + // For kernels earlier than 3.16 (and newer xfsutils), + // some xfs features need to be explicitly disabled. + return []string{"-m", "crc=0,finobt=0"} + } - args := []string{} - args = append(args, devices.mkfsArgs...) + return []string{} +} - args = append(args, devname) +func (devices *DeviceSet) createFilesystem(info *devInfo) (err error) { + devname := info.DevName() if devices.filesystem == "" { devices.filesystem = determineDefaultFS() @@ -587,7 +596,11 @@ func (devices *DeviceSet) createFilesystem(info *devInfo) (err error) { return err } - logrus.Infof("devmapper: Creating filesystem %s on device %s", devices.filesystem, info.Name()) + args := mkfsOptions(devices.filesystem) + args = append(args, devices.mkfsArgs...) + args = append(args, devname) + + logrus.Infof("devmapper: Creating filesystem %s on device %s, mkfs args: %v", devices.filesystem, info.Name(), args) defer func() { if err != nil { logrus.Infof("devmapper: Error while creating filesystem %s on device %s: %v", devices.filesystem, info.Name(), err) @@ -1188,7 +1201,7 @@ func (devices *DeviceSet) growFS(info *devInfo) error { options = joinMountOptions(options, devices.mountOptions) if err := mount.Mount(info.DevName(), fsMountPoint, devices.BaseDeviceFilesystem, options); err != nil { - return fmt.Errorf("Error mounting '%s' on '%s': %s", info.DevName(), fsMountPoint, err) + return fmt.Errorf("Error mounting '%s' on '%s': %s\n%v", info.DevName(), fsMountPoint, err, string(dmesg.Dmesg(256))) } defer unix.Unmount(fsMountPoint, unix.MNT_DETACH) @@ -1254,14 +1267,13 @@ func (devices *DeviceSet) setupBaseImage() error { } func setCloseOnExec(name string) { - if fileInfos, _ := ioutil.ReadDir("/proc/self/fd"); fileInfos != nil { - for _, i := range fileInfos { - link, _ := os.Readlink(filepath.Join("/proc/self/fd", i.Name())) - if link == name { - fd, err := strconv.Atoi(i.Name()) - if err == nil { - unix.CloseOnExec(fd) - } + fileInfos, _ := ioutil.ReadDir("/proc/self/fd") + for _, i := range fileInfos { + link, _ := os.Readlink(filepath.Join("/proc/self/fd", i.Name())) + if link == name { + fd, err := strconv.Atoi(i.Name()) + if err == nil { + unix.CloseOnExec(fd) } } } @@ -1860,7 +1872,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) (retErr error) { if devices.thinPoolDevice == "" { if devices.metadataLoopFile != "" || devices.dataLoopFile != "" { - logrus.Warn("devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docker` to refer to dm.thinpooldev section.") + logrus.Warn("devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man dockerd` to refer to dm.thinpooldev section.") } } @@ -2380,7 +2392,7 @@ func (devices *DeviceSet) MountDevice(hash, path, mountLabel string) error { options = joinMountOptions(options, label.FormatMountLabel("", mountLabel)) if err := mount.Mount(info.DevName(), path, fstype, options); err != nil { - return fmt.Errorf("devmapper: Error mounting '%s' on '%s': %s", info.DevName(), path, err) + return fmt.Errorf("devmapper: Error mounting '%s' on '%s': %s\n%v", info.DevName(), path, err, string(dmesg.Dmesg(256))) } if fstype == "xfs" && devices.xfsNospaceRetries != "" { @@ -2664,7 +2676,7 @@ func NewDeviceSet(root string, doInit bool, options []string, uidMaps, gidMaps [ devices.metaDataLoopbackSize = size case "dm.fs": if val != "ext4" && val != "xfs" { - return nil, fmt.Errorf("devmapper: Unsupported filesystem %s\n", val) + return nil, fmt.Errorf("devmapper: Unsupported filesystem %s", val) } devices.filesystem = val case "dm.mkfsarg": @@ -2786,7 +2798,7 @@ func NewDeviceSet(root string, doInit bool, options []string, uidMaps, gidMaps [ Level: int(level), }) default: - return nil, fmt.Errorf("devmapper: Unknown option %s\n", key) + return nil, fmt.Errorf("devmapper: Unknown option %s", key) } } diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/devmapper/driver.go b/vendor/github.com/docker/docker/daemon/graphdriver/devmapper/driver.go index 02ee0124f..f41afa2ae 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/devmapper/driver.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/devmapper/driver.go @@ -12,6 +12,7 @@ import ( "github.com/sirupsen/logrus" "github.com/docker/docker/daemon/graphdriver" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/devicemapper" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/locker" @@ -69,18 +70,18 @@ func (d *Driver) Status() [][2]string { status := [][2]string{ {"Pool Name", s.PoolName}, - {"Pool Blocksize", fmt.Sprintf("%s", units.HumanSize(float64(s.SectorSize)))}, - {"Base Device Size", fmt.Sprintf("%s", units.HumanSize(float64(s.BaseDeviceSize)))}, + {"Pool Blocksize", units.HumanSize(float64(s.SectorSize))}, + {"Base Device Size", units.HumanSize(float64(s.BaseDeviceSize))}, {"Backing Filesystem", s.BaseDeviceFS}, {"Data file", s.DataFile}, {"Metadata file", s.MetadataFile}, - {"Data Space Used", fmt.Sprintf("%s", units.HumanSize(float64(s.Data.Used)))}, - {"Data Space Total", fmt.Sprintf("%s", units.HumanSize(float64(s.Data.Total)))}, - {"Data Space Available", fmt.Sprintf("%s", units.HumanSize(float64(s.Data.Available)))}, - {"Metadata Space Used", fmt.Sprintf("%s", units.HumanSize(float64(s.Metadata.Used)))}, - {"Metadata Space Total", fmt.Sprintf("%s", units.HumanSize(float64(s.Metadata.Total)))}, - {"Metadata Space Available", fmt.Sprintf("%s", units.HumanSize(float64(s.Metadata.Available)))}, - {"Thin Pool Minimum Free Space", fmt.Sprintf("%s", units.HumanSize(float64(s.MinFreeSpace)))}, + {"Data Space Used", units.HumanSize(float64(s.Data.Used))}, + {"Data Space Total", units.HumanSize(float64(s.Data.Total))}, + {"Data Space Available", units.HumanSize(float64(s.Data.Available))}, + {"Metadata Space Used", units.HumanSize(float64(s.Metadata.Used))}, + {"Metadata Space Total", units.HumanSize(float64(s.Metadata.Total))}, + {"Metadata Space Available", units.HumanSize(float64(s.Metadata.Available))}, + {"Thin Pool Minimum Free Space", units.HumanSize(float64(s.MinFreeSpace))}, {"Udev Sync Supported", fmt.Sprintf("%v", s.UdevSyncSupported)}, {"Deferred Removal Enabled", fmt.Sprintf("%v", s.DeferredRemoveEnabled)}, {"Deferred Deletion Enabled", fmt.Sprintf("%v", s.DeferredDeleteEnabled)}, @@ -159,51 +160,45 @@ func (d *Driver) Remove(id string) error { if err := d.DeviceSet.DeleteDevice(id, false); err != nil { return fmt.Errorf("failed to remove device %s: %v", id, err) } - - mp := path.Join(d.home, "mnt", id) - if err := system.EnsureRemoveAll(mp); err != nil { - return err - } - - return nil + return system.EnsureRemoveAll(path.Join(d.home, "mnt", id)) } // Get mounts a device with given id into the root filesystem -func (d *Driver) Get(id, mountLabel string) (string, error) { +func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { d.locker.Lock(id) defer d.locker.Unlock(id) mp := path.Join(d.home, "mnt", id) rootFs := path.Join(mp, "rootfs") if count := d.ctr.Increment(mp); count > 1 { - return rootFs, nil + return containerfs.NewLocalContainerFS(rootFs), nil } uid, gid, err := idtools.GetRootUIDGID(d.uidMaps, d.gidMaps) if err != nil { d.ctr.Decrement(mp) - return "", err + return nil, err } // Create the target directories if they don't exist if err := idtools.MkdirAllAs(path.Join(d.home, "mnt"), 0755, uid, gid); err != nil && !os.IsExist(err) { d.ctr.Decrement(mp) - return "", err + return nil, err } if err := idtools.MkdirAs(mp, 0755, uid, gid); err != nil && !os.IsExist(err) { d.ctr.Decrement(mp) - return "", err + return nil, err } // Mount the device if err := d.DeviceSet.MountDevice(id, mp, mountLabel); err != nil { d.ctr.Decrement(mp) - return "", err + return nil, err } if err := idtools.MkdirAllAs(rootFs, 0755, uid, gid); err != nil && !os.IsExist(err) { d.ctr.Decrement(mp) d.DeviceSet.UnmountDevice(id, mp) - return "", err + return nil, err } idFile := path.Join(mp, "id") @@ -213,11 +208,11 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { if err := ioutil.WriteFile(idFile, []byte(id), 0600); err != nil { d.ctr.Decrement(mp) d.DeviceSet.UnmountDevice(id, mp) - return "", err + return nil, err } } - return rootFs, nil + return containerfs.NewLocalContainerFS(rootFs), nil } // Put unmounts a device and removes it. diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/driver.go b/vendor/github.com/docker/docker/daemon/graphdriver/driver.go index 94c52094c..68f9022e1 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/driver.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/driver.go @@ -12,6 +12,7 @@ import ( "github.com/vbatts/tar-split/tar/storage" "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/plugingetter" ) @@ -68,7 +69,7 @@ type ProtoDriver interface { // Get returns the mountpoint for the layered filesystem referred // to by this id. You can optionally specify a mountLabel or "". // Returns the absolute path to the mounted layered filesystem. - Get(id, mountLabel string) (dir string, err error) + Get(id, mountLabel string) (fs containerfs.ContainerFS, err error) // Put releases the system resources for the specified id, // e.g, unmounting layered filesystem. Put(id string) error diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/driver_freebsd.go b/vendor/github.com/docker/docker/daemon/graphdriver/driver_freebsd.go index fb13ac3d5..53394b738 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/driver_freebsd.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/driver_freebsd.go @@ -1,6 +1,10 @@ package graphdriver -import "golang.org/x/sys/unix" +import ( + "syscall" + + "golang.org/x/sys/unix" +) var ( // Slice of drivers that should be used in an order diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/driver_linux.go b/vendor/github.com/docker/docker/daemon/graphdriver/driver_linux.go index a92993d45..a2be46b53 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/driver_linux.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/driver_linux.go @@ -53,10 +53,10 @@ const ( var ( // Slice of drivers that should be used in an order priority = []string{ - "aufs", "btrfs", "zfs", "overlay2", + "aufs", "overlay", "devicemapper", "vfs", @@ -67,6 +67,7 @@ var ( FsMagicAufs: "aufs", FsMagicBtrfs: "btrfs", FsMagicCramfs: "cramfs", + FsMagicEcryptfs: "ecryptfs", FsMagicExtfs: "extfs", FsMagicF2fs: "f2fs", FsMagicGPFS: "gpfs", diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/fsdiff.go b/vendor/github.com/docker/docker/daemon/graphdriver/fsdiff.go index e8c7ff27a..533c5a769 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/fsdiff.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/fsdiff.go @@ -18,9 +18,9 @@ var ( ) // NaiveDiffDriver takes a ProtoDriver and adds the -// capability of the Diffing methods which it may or may not -// support on its own. See the comment on the exported -// NewNaiveDiffDriver function below. +// capability of the Diffing methods on the local file system, +// which it may or may not support on its own. See the comment +// on the exported NewNaiveDiffDriver function below. // Notably, the AUFS driver doesn't need to be wrapped like this. type NaiveDiffDriver struct { ProtoDriver @@ -47,10 +47,11 @@ func (gdw *NaiveDiffDriver) Diff(id, parent string) (arch io.ReadCloser, err err startTime := time.Now() driver := gdw.ProtoDriver - layerFs, err := driver.Get(id, "") + layerRootFs, err := driver.Get(id, "") if err != nil { return nil, err } + layerFs := layerRootFs.Path() defer func() { if err != nil { @@ -70,12 +71,14 @@ func (gdw *NaiveDiffDriver) Diff(id, parent string) (arch io.ReadCloser, err err }), nil } - parentFs, err := driver.Get(parent, "") + parentRootFs, err := driver.Get(parent, "") if err != nil { return nil, err } defer driver.Put(parent) + parentFs := parentRootFs.Path() + changes, err := archive.ChangesDirs(layerFs, parentFs) if err != nil { return nil, err @@ -94,7 +97,7 @@ func (gdw *NaiveDiffDriver) Diff(id, parent string) (arch io.ReadCloser, err err // are extracted from tar's with full second precision on modified time. // We need this hack here to make sure calls within same second receive // correct result. - time.Sleep(startTime.Truncate(time.Second).Add(time.Second).Sub(time.Now())) + time.Sleep(time.Until(startTime.Truncate(time.Second).Add(time.Second))) return err }), nil } @@ -104,20 +107,22 @@ func (gdw *NaiveDiffDriver) Diff(id, parent string) (arch io.ReadCloser, err err func (gdw *NaiveDiffDriver) Changes(id, parent string) ([]archive.Change, error) { driver := gdw.ProtoDriver - layerFs, err := driver.Get(id, "") + layerRootFs, err := driver.Get(id, "") if err != nil { return nil, err } defer driver.Put(id) + layerFs := layerRootFs.Path() parentFs := "" if parent != "" { - parentFs, err = driver.Get(parent, "") + parentRootFs, err := driver.Get(parent, "") if err != nil { return nil, err } defer driver.Put(parent) + parentFs = parentRootFs.Path() } return archive.ChangesDirs(layerFs, parentFs) @@ -130,12 +135,13 @@ func (gdw *NaiveDiffDriver) ApplyDiff(id, parent string, diff io.Reader) (size i driver := gdw.ProtoDriver // Mount the root filesystem so we can apply the diff/layer. - layerFs, err := driver.Get(id, "") + layerRootFs, err := driver.Get(id, "") if err != nil { return } defer driver.Put(id) + layerFs := layerRootFs.Path() options := &archive.TarOptions{UIDMaps: gdw.uidMaps, GIDMaps: gdw.gidMaps} start := time.Now().UTC() @@ -165,5 +171,5 @@ func (gdw *NaiveDiffDriver) DiffSize(id, parent string) (size int64, err error) } defer driver.Put(id) - return archive.ChangesSize(layerFs, changes), nil + return archive.ChangesSize(layerFs.Path(), changes), nil } diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/graphbench_unix.go b/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/graphbench_unix.go index def822b9a..c04394d51 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/graphbench_unix.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/graphbench_unix.go @@ -3,13 +3,13 @@ package graphtest import ( - "bytes" "io" "io/ioutil" - "path/filepath" "testing" + contdriver "github.com/containerd/continuity/driver" "github.com/docker/docker/pkg/stringid" + "github.com/stretchr/testify/require" ) // DriverBenchExists benchmarks calls to exist @@ -245,15 +245,13 @@ func DriverBenchDeepLayerRead(b *testing.B, layerCount int, drivername string, d for i := 0; i < b.N; i++ { // Read content - c, err := ioutil.ReadFile(filepath.Join(root, "testfile.txt")) + c, err := contdriver.ReadFile(root, root.Join(root.Path(), "testfile.txt")) if err != nil { b.Fatal(err) } b.StopTimer() - if bytes.Compare(c, content) != 0 { - b.Fatalf("Wrong content in file %v, expected %v", c, content) - } + require.Equal(b, content, c) b.StartTimer() } } diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/graphtest_unix.go b/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/graphtest_unix.go index 2f8ae5477..11dff4889 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/graphtest_unix.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/graphtest_unix.go @@ -97,10 +97,10 @@ func DriverTestCreateEmpty(t testing.TB, drivername string, driverOptions ...str dir, err := driver.Get("empty", "") require.NoError(t, err) - verifyFile(t, dir, 0755|os.ModeDir, 0, 0) + verifyFile(t, dir.Path(), 0755|os.ModeDir, 0, 0) // Verify that the directory is empty - fis, err := readDir(dir) + fis, err := readDir(dir, dir.Path()) require.NoError(t, err) assert.Len(t, fis, 0) @@ -328,9 +328,9 @@ func DriverTestSetQuota(t *testing.T, drivername string) { } quota := uint64(50 * units.MiB) - err = writeRandomFile(path.Join(mountPath, "file"), quota*2) + + err = writeRandomFile(path.Join(mountPath.Path(), "file"), quota*2) if pathError, ok := err.(*os.PathError); ok && pathError.Err != unix.EDQUOT { t.Fatalf("expect write() to fail with %v, got %v", unix.EDQUOT, err) } - } diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/testutil.go b/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/testutil.go index 35bf6d17b..946313296 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/testutil.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/testutil.go @@ -3,12 +3,11 @@ package graphtest import ( "bytes" "fmt" - "io/ioutil" "math/rand" "os" - "path" "sort" + "github.com/containerd/continuity/driver" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/stringid" @@ -36,17 +35,17 @@ func addFiles(drv graphdriver.Driver, layer string, seed int64) error { } defer drv.Put(layer) - if err := ioutil.WriteFile(path.Join(root, "file-a"), randomContent(64, seed), 0755); err != nil { + if err := driver.WriteFile(root, root.Join(root.Path(), "file-a"), randomContent(64, seed), 0755); err != nil { return err } - if err := os.MkdirAll(path.Join(root, "dir-b"), 0755); err != nil { + if err := root.MkdirAll(root.Join(root.Path(), "dir-b"), 0755); err != nil { return err } - if err := ioutil.WriteFile(path.Join(root, "dir-b", "file-b"), randomContent(128, seed+1), 0755); err != nil { + if err := driver.WriteFile(root, root.Join(root.Path(), "dir-b", "file-b"), randomContent(128, seed+1), 0755); err != nil { return err } - return ioutil.WriteFile(path.Join(root, "file-c"), randomContent(128*128, seed+2), 0755) + return driver.WriteFile(root, root.Join(root.Path(), "file-c"), randomContent(128*128, seed+2), 0755) } func checkFile(drv graphdriver.Driver, layer, filename string, content []byte) error { @@ -56,12 +55,12 @@ func checkFile(drv graphdriver.Driver, layer, filename string, content []byte) e } defer drv.Put(layer) - fileContent, err := ioutil.ReadFile(path.Join(root, filename)) + fileContent, err := driver.ReadFile(root, root.Join(root.Path(), filename)) if err != nil { return err } - if bytes.Compare(fileContent, content) != 0 { + if !bytes.Equal(fileContent, content) { return fmt.Errorf("mismatched file content %v, expecting %v", fileContent, content) } @@ -75,7 +74,7 @@ func addFile(drv graphdriver.Driver, layer, filename string, content []byte) err } defer drv.Put(layer) - return ioutil.WriteFile(path.Join(root, filename), content, 0755) + return driver.WriteFile(root, root.Join(root.Path(), filename), content, 0755) } func addDirectory(drv graphdriver.Driver, layer, dir string) error { @@ -85,7 +84,7 @@ func addDirectory(drv graphdriver.Driver, layer, dir string) error { } defer drv.Put(layer) - return os.MkdirAll(path.Join(root, dir), 0755) + return root.MkdirAll(root.Join(root.Path(), dir), 0755) } func removeAll(drv graphdriver.Driver, layer string, names ...string) error { @@ -96,7 +95,7 @@ func removeAll(drv graphdriver.Driver, layer string, names ...string) error { defer drv.Put(layer) for _, filename := range names { - if err := os.RemoveAll(path.Join(root, filename)); err != nil { + if err := root.RemoveAll(root.Join(root.Path(), filename)); err != nil { return err } } @@ -110,8 +109,8 @@ func checkFileRemoved(drv graphdriver.Driver, layer, filename string) error { } defer drv.Put(layer) - if _, err := os.Stat(path.Join(root, filename)); err == nil { - return fmt.Errorf("file still exists: %s", path.Join(root, filename)) + if _, err := root.Stat(root.Join(root.Path(), filename)); err == nil { + return fmt.Errorf("file still exists: %s", root.Join(root.Path(), filename)) } else if !os.IsNotExist(err) { return err } @@ -127,13 +126,13 @@ func addManyFiles(drv graphdriver.Driver, layer string, count int, seed int64) e defer drv.Put(layer) for i := 0; i < count; i += 100 { - dir := path.Join(root, fmt.Sprintf("directory-%d", i)) - if err := os.MkdirAll(dir, 0755); err != nil { + dir := root.Join(root.Path(), fmt.Sprintf("directory-%d", i)) + if err := root.MkdirAll(dir, 0755); err != nil { return err } for j := 0; i+j < count && j < 100; j++ { - file := path.Join(dir, fmt.Sprintf("file-%d", i+j)) - if err := ioutil.WriteFile(file, randomContent(64, seed+int64(i+j)), 0755); err != nil { + file := root.Join(dir, fmt.Sprintf("file-%d", i+j)) + if err := driver.WriteFile(root, file, randomContent(64, seed+int64(i+j)), 0755); err != nil { return err } } @@ -152,7 +151,7 @@ func changeManyFiles(drv graphdriver.Driver, layer string, count int, seed int64 changes := []archive.Change{} for i := 0; i < count; i += 100 { archiveRoot := fmt.Sprintf("/directory-%d", i) - if err := os.MkdirAll(path.Join(root, archiveRoot), 0755); err != nil { + if err := root.MkdirAll(root.Join(root.Path(), archiveRoot), 0755); err != nil { return nil, err } for j := 0; i+j < count && j < 100; j++ { @@ -166,23 +165,23 @@ func changeManyFiles(drv graphdriver.Driver, layer string, count int, seed int64 switch j % 3 { // Update file case 0: - change.Path = path.Join(archiveRoot, fmt.Sprintf("file-%d", i+j)) + change.Path = root.Join(archiveRoot, fmt.Sprintf("file-%d", i+j)) change.Kind = archive.ChangeModify - if err := ioutil.WriteFile(path.Join(root, change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil { + if err := driver.WriteFile(root, root.Join(root.Path(), change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil { return nil, err } // Add file case 1: - change.Path = path.Join(archiveRoot, fmt.Sprintf("file-%d-%d", seed, i+j)) + change.Path = root.Join(archiveRoot, fmt.Sprintf("file-%d-%d", seed, i+j)) change.Kind = archive.ChangeAdd - if err := ioutil.WriteFile(path.Join(root, change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil { + if err := driver.WriteFile(root, root.Join(root.Path(), change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil { return nil, err } // Remove file case 2: - change.Path = path.Join(archiveRoot, fmt.Sprintf("file-%d", i+j)) + change.Path = root.Join(archiveRoot, fmt.Sprintf("file-%d", i+j)) change.Kind = archive.ChangeDelete - if err := os.Remove(path.Join(root, change.Path)); err != nil { + if err := root.Remove(root.Join(root.Path(), change.Path)); err != nil { return nil, err } } @@ -201,17 +200,17 @@ func checkManyFiles(drv graphdriver.Driver, layer string, count int, seed int64) defer drv.Put(layer) for i := 0; i < count; i += 100 { - dir := path.Join(root, fmt.Sprintf("directory-%d", i)) + dir := root.Join(root.Path(), fmt.Sprintf("directory-%d", i)) for j := 0; i+j < count && j < 100; j++ { - file := path.Join(dir, fmt.Sprintf("file-%d", i+j)) - fileContent, err := ioutil.ReadFile(file) + file := root.Join(dir, fmt.Sprintf("file-%d", i+j)) + fileContent, err := driver.ReadFile(root, file) if err != nil { return err } content := randomContent(64, seed+int64(i+j)) - if bytes.Compare(fileContent, content) != 0 { + if !bytes.Equal(fileContent, content) { return fmt.Errorf("mismatched file content %v, expecting %v", fileContent, content) } } @@ -254,17 +253,17 @@ func addLayerFiles(drv graphdriver.Driver, layer, parent string, i int) error { } defer drv.Put(layer) - if err := ioutil.WriteFile(path.Join(root, "top-id"), []byte(layer), 0755); err != nil { + if err := driver.WriteFile(root, root.Join(root.Path(), "top-id"), []byte(layer), 0755); err != nil { return err } - layerDir := path.Join(root, fmt.Sprintf("layer-%d", i)) - if err := os.MkdirAll(layerDir, 0755); err != nil { + layerDir := root.Join(root.Path(), fmt.Sprintf("layer-%d", i)) + if err := root.MkdirAll(layerDir, 0755); err != nil { return err } - if err := ioutil.WriteFile(path.Join(layerDir, "layer-id"), []byte(layer), 0755); err != nil { + if err := driver.WriteFile(root, root.Join(layerDir, "layer-id"), []byte(layer), 0755); err != nil { return err } - if err := ioutil.WriteFile(path.Join(layerDir, "parent-id"), []byte(parent), 0755); err != nil { + if err := driver.WriteFile(root, root.Join(layerDir, "parent-id"), []byte(parent), 0755); err != nil { return err } @@ -295,26 +294,26 @@ func checkManyLayers(drv graphdriver.Driver, layer string, count int) error { } defer drv.Put(layer) - layerIDBytes, err := ioutil.ReadFile(path.Join(root, "top-id")) + layerIDBytes, err := driver.ReadFile(root, root.Join(root.Path(), "top-id")) if err != nil { return err } - if bytes.Compare(layerIDBytes, []byte(layer)) != 0 { + if !bytes.Equal(layerIDBytes, []byte(layer)) { return fmt.Errorf("mismatched file content %v, expecting %v", layerIDBytes, []byte(layer)) } for i := count; i > 0; i-- { - layerDir := path.Join(root, fmt.Sprintf("layer-%d", i)) + layerDir := root.Join(root.Path(), fmt.Sprintf("layer-%d", i)) - thisLayerIDBytes, err := ioutil.ReadFile(path.Join(layerDir, "layer-id")) + thisLayerIDBytes, err := driver.ReadFile(root, root.Join(layerDir, "layer-id")) if err != nil { return err } - if bytes.Compare(thisLayerIDBytes, layerIDBytes) != 0 { + if !bytes.Equal(thisLayerIDBytes, layerIDBytes) { return fmt.Errorf("mismatched file content %v, expecting %v", thisLayerIDBytes, layerIDBytes) } - layerIDBytes, err = ioutil.ReadFile(path.Join(layerDir, "parent-id")) + layerIDBytes, err = driver.ReadFile(root, root.Join(layerDir, "parent-id")) if err != nil { return err } @@ -322,11 +321,11 @@ func checkManyLayers(drv graphdriver.Driver, layer string, count int) error { return nil } -// readDir reads a directory just like ioutil.ReadDir() +// readDir reads a directory just like driver.ReadDir() // then hides specific files (currently "lost+found") // so the tests don't "see" it -func readDir(dir string) ([]os.FileInfo, error) { - a, err := ioutil.ReadDir(dir) +func readDir(r driver.Driver, dir string) ([]os.FileInfo, error) { + a, err := driver.ReadDir(r, dir) if err != nil { return nil, err } diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/testutil_unix.go b/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/testutil_unix.go index 96474487a..b5dec43fb 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/testutil_unix.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/graphtest/testutil_unix.go @@ -3,12 +3,11 @@ package graphtest import ( - "io/ioutil" "os" - "path" "syscall" "testing" + contdriver "github.com/containerd/continuity/driver" "github.com/docker/docker/daemon/graphdriver" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -40,31 +39,31 @@ func createBase(t testing.TB, driver graphdriver.Driver, name string) { err := driver.CreateReadWrite(name, "", nil) require.NoError(t, err) - dir, err := driver.Get(name, "") + dirFS, err := driver.Get(name, "") require.NoError(t, err) defer driver.Put(name) - subdir := path.Join(dir, "a subdir") - require.NoError(t, os.Mkdir(subdir, 0705|os.ModeSticky)) - require.NoError(t, os.Chown(subdir, 1, 2)) + subdir := dirFS.Join(dirFS.Path(), "a subdir") + require.NoError(t, dirFS.Mkdir(subdir, 0705|os.ModeSticky)) + require.NoError(t, dirFS.Lchown(subdir, 1, 2)) - file := path.Join(dir, "a file") - err = ioutil.WriteFile(file, []byte("Some data"), 0222|os.ModeSetuid) + file := dirFS.Join(dirFS.Path(), "a file") + err = contdriver.WriteFile(dirFS, file, []byte("Some data"), 0222|os.ModeSetuid) require.NoError(t, err) } func verifyBase(t testing.TB, driver graphdriver.Driver, name string) { - dir, err := driver.Get(name, "") + dirFS, err := driver.Get(name, "") require.NoError(t, err) defer driver.Put(name) - subdir := path.Join(dir, "a subdir") + subdir := dirFS.Join(dirFS.Path(), "a subdir") verifyFile(t, subdir, 0705|os.ModeDir|os.ModeSticky, 1, 2) - file := path.Join(dir, "a file") + file := dirFS.Join(dirFS.Path(), "a file") verifyFile(t, file, 0222|os.ModeSetuid, 0, 0) - files, err := readDir(dir) + files, err := readDir(dirFS, dirFS.Path()) require.NoError(t, err) assert.Len(t, files, 2) } diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/lcow/lcow.go b/vendor/github.com/docker/docker/daemon/graphdriver/lcow/lcow.go index b50506876..9ae04b1be 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/lcow/lcow.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/lcow/lcow.go @@ -13,7 +13,7 @@ // operations. The downside of safe-mode is that operations are slower as // a new service utility VM has to be started and torn-down when needed. // -// Options (needs official documentation, but lets get full functionality first...) @jhowardmsft +// Options: // // The following options are read by the graphdriver itself: // @@ -23,33 +23,33 @@ // // * lcow.sandboxsize - Specifies a custom sandbox size in GB for starting a container // -- Possible values: >= default sandbox size (opengcs defined, currently 20) -// -- Default if ommitted: 20 +// -- Default if omitted: 20 // // The following options are read by opengcs: // // * lcow.kirdpath - Specifies a custom path to a kernel/initrd pair // -- Possible values: Any local path that is not a mapped drive -// -- Default if ommitted: %ProgramFiles%\Linux Containers +// -- Default if omitted: %ProgramFiles%\Linux Containers // // * lcow.kernel - Specifies a custom kernel file located in the `lcow.kirdpath` path // -- Possible values: Any valid filename -// -- Default if ommitted: bootx64.efi +// -- Default if omitted: bootx64.efi // // * lcow.initrd - Specifies a custom initrd file located in the `lcow.kirdpath` path // -- Possible values: Any valid filename -// -- Default if ommitted: initrd.img +// -- Default if omitted: initrd.img // // * lcow.bootparameters - Specifies additional boot parameters for booting in kernel+initrd mode // -- Possible values: Any valid linux kernel boot options -// -- Default if ommitted: +// -- Default if omitted: // // * lcow.vhdx - Specifies a custom vhdx file to boot (instead of a kernel+initrd) // -- Possible values: Any valid filename -// -- Default if ommitted: uvm.vhdx under `lcow.kirdpath` +// -- Default if omitted: uvm.vhdx under `lcow.kirdpath` // // * lcow.timeout - Specifies a timeout for utility VM operations in seconds // -- Possible values: >=0 -// -- Default if ommitted: 300 +// -- Default if omitted: 300 // TODO: Grab logs from SVM at terminate or errors @@ -65,15 +65,17 @@ import ( "strconv" "strings" "sync" + "syscall" "time" "github.com/Microsoft/hcsshim" + "github.com/Microsoft/opengcs/client" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/system" - "github.com/jhowardmsft/opengcs/gogcs/client" "github.com/sirupsen/logrus" ) @@ -106,72 +108,24 @@ const ( // scratchDirectory is the sub-folder under the driver's data-root used for scratch VHDs in service VMs scratchDirectory = "scratch" -) - -// cacheItem is our internal structure representing an item in our local cache -// of things that have been mounted. -type cacheItem struct { - sync.Mutex // Protects operations performed on this item - uvmPath string // Path in utility VM - hostPath string // Path on host - refCount int // How many times its been mounted - isSandbox bool // True if a sandbox - isMounted bool // True when mounted in a service VM -} - -// setIsMounted is a helper function for a cacheItem which does exactly what it says -func (ci *cacheItem) setIsMounted() { - logrus.Debugf("locking cache item for set isMounted") - ci.Lock() - defer ci.Unlock() - ci.isMounted = true - logrus.Debugf("set isMounted on cache item") -} -// incrementRefCount is a helper function for a cacheItem which does exactly what it says -func (ci *cacheItem) incrementRefCount() { - logrus.Debugf("locking cache item for increment") - ci.Lock() - defer ci.Unlock() - ci.refCount++ - logrus.Debugf("incremented refcount on cache item %+v", ci) -} - -// decrementRefCount is a helper function for a cacheItem which does exactly what it says -func (ci *cacheItem) decrementRefCount() int { - logrus.Debugf("locking cache item for decrement") - ci.Lock() - defer ci.Unlock() - ci.refCount-- - logrus.Debugf("decremented refcount on cache item %+v", ci) - return ci.refCount -} - -// serviceVMItem is our internal structure representing an item in our -// map of service VMs we are maintaining. -type serviceVMItem struct { - sync.Mutex // Serialises operations being performed in this service VM. - scratchAttached bool // Has a scratch been attached? - config *client.Config // Represents the service VM item. -} + // errOperationPending is the HRESULT returned by the HCS when the VM termination operation is still pending. + errOperationPending syscall.Errno = 0xc0370103 +) // Driver represents an LCOW graph driver. type Driver struct { - dataRoot string // Root path on the host where we are storing everything. - cachedSandboxFile string // Location of the local default-sized cached sandbox. - cachedSandboxMutex sync.Mutex // Protects race conditions from multiple threads creating the cached sandbox. - cachedScratchFile string // Location of the local cached empty scratch space. - cachedScratchMutex sync.Mutex // Protects race conditions from multiple threads creating the cached scratch. - options []string // Graphdriver options we are initialised with. - serviceVmsMutex sync.Mutex // Protects add/updates/delete to the serviceVMs map. - serviceVms map[string]*serviceVMItem // Map of the configs representing the service VM(s) we are running. - globalMode bool // Indicates if running in an unsafe/global service VM mode. + dataRoot string // Root path on the host where we are storing everything. + cachedSandboxFile string // Location of the local default-sized cached sandbox. + cachedSandboxMutex sync.Mutex // Protects race conditions from multiple threads creating the cached sandbox. + cachedScratchFile string // Location of the local cached empty scratch space. + cachedScratchMutex sync.Mutex // Protects race conditions from multiple threads creating the cached scratch. + options []string // Graphdriver options we are initialised with. + globalMode bool // Indicates if running in an unsafe/global service VM mode. // NOTE: It is OK to use a cache here because Windows does not support // restoring containers when the daemon dies. - - cacheMutex sync.Mutex // Protects add/update/deletes to cache. - cache map[string]*cacheItem // Map holding a cache of all the IDs we've mounted/unmounted. + serviceVms *serviceVMMap // Map of the configs representing the service VM(s) we are running. } // layerDetails is the structure returned by a helper function `getLayerDetails` @@ -204,9 +158,10 @@ func InitDriver(dataRoot string, options []string, _, _ []idtools.IDMap) (graphd options: options, cachedSandboxFile: filepath.Join(cd, sandboxFilename), cachedScratchFile: filepath.Join(cd, scratchFilename), - cache: make(map[string]*cacheItem), - serviceVms: make(map[string]*serviceVMItem), - globalMode: false, + serviceVms: &serviceVMMap{ + svms: make(map[string]*serviceVMMapItem), + }, + globalMode: false, } // Looks for relevant options @@ -248,53 +203,59 @@ func InitDriver(dataRoot string, options []string, _, _ []idtools.IDMap) (graphd return d, nil } +func (d *Driver) getVMID(id string) string { + if d.globalMode { + return svmGlobalID + } + return id +} + // startServiceVMIfNotRunning starts a service utility VM if it is not currently running. // It can optionally be started with a mapped virtual disk. Returns a opengcs config structure // representing the VM. -func (d *Driver) startServiceVMIfNotRunning(id string, mvdToAdd *hcsshim.MappedVirtualDisk, context string) (*serviceVMItem, error) { +func (d *Driver) startServiceVMIfNotRunning(id string, mvdToAdd []hcsshim.MappedVirtualDisk, context string) (_ *serviceVM, err error) { // Use the global ID if in global mode - if d.globalMode { - id = svmGlobalID - } + id = d.getVMID(id) title := fmt.Sprintf("lcowdriver: startservicevmifnotrunning %s:", id) - // Make sure thread-safe when interrogating the map - logrus.Debugf("%s taking serviceVmsMutex", title) - d.serviceVmsMutex.Lock() - - // Nothing to do if it's already running except add the mapped drive if supplied. - if svm, ok := d.serviceVms[id]; ok { - logrus.Debugf("%s exists, releasing serviceVmsMutex", title) - d.serviceVmsMutex.Unlock() - - if mvdToAdd != nil { - logrus.Debugf("hot-adding %s to %s", mvdToAdd.HostPath, mvdToAdd.ContainerPath) - - // Ensure the item is locked while doing this - logrus.Debugf("%s locking serviceVmItem %s", title, svm.config.Name) - svm.Lock() - - if err := svm.config.HotAddVhd(mvdToAdd.HostPath, mvdToAdd.ContainerPath, false, true); err != nil { - logrus.Debugf("%s releasing serviceVmItem %s on hot-add failure %s", title, svm.config.Name, err) - svm.Unlock() - return nil, fmt.Errorf("%s hot add %s to %s failed: %s", title, mvdToAdd.HostPath, mvdToAdd.ContainerPath, err) - } + // Attempt to add ID to the service vm map + logrus.Debugf("%s: Adding entry to service vm map", title) + svm, exists, err := d.serviceVms.add(id) + if err != nil && err == errVMisTerminating { + // VM is in the process of terminating. Wait until it's done and and then try again + logrus.Debugf("%s: VM with current ID still in the process of terminating: %s", title, id) + if err := svm.getStopError(); err != nil { + logrus.Debugf("%s: VM %s did not stop succesfully: %s", title, id, err) + return nil, err + } + return d.startServiceVMIfNotRunning(id, mvdToAdd, context) + } else if err != nil { + logrus.Debugf("%s: failed to add service vm to map: %s", err) + return nil, fmt.Errorf("%s: failed to add to service vm map: %s", title, err) + } - logrus.Debugf("%s releasing serviceVmItem %s", title, svm.config.Name) - svm.Unlock() + if exists { + // Service VM is already up and running. In this case, just hot add the vhds. + logrus.Debugf("%s: service vm already exists. Just hot adding: %+v", title, mvdToAdd) + if err := svm.hotAddVHDs(mvdToAdd...); err != nil { + logrus.Debugf("%s: failed to hot add vhds on service vm creation: %s", title, err) + return nil, fmt.Errorf("%s: failed to hot add vhds on service vm: %s", title, err) } return svm, nil } - // Release the lock early - logrus.Debugf("%s releasing serviceVmsMutex", title) - d.serviceVmsMutex.Unlock() + // We are the first service for this id, so we need to start it + logrus.Debugf("%s: service vm doesn't exist. Now starting it up: %s", title, id) - // So we are starting one. First need an enpty structure. - svm := &serviceVMItem{ - config: &client.Config{}, - } + defer func() { + // Signal that start has finished, passing in the error if any. + svm.signalStartFinished(err) + if err != nil { + // We added a ref to the VM, since we failed, we should delete the ref. + d.terminateServiceVM(id, "error path on startServiceVMIfNotRunning", false) + } + }() // Generate a default configuration if err := svm.config.GenerateDefault(d.options); err != nil { @@ -335,12 +296,14 @@ func (d *Driver) startServiceVMIfNotRunning(id string, mvdToAdd *hcsshim.MappedV svm.config.MappedVirtualDisks = append(svm.config.MappedVirtualDisks, mvd) svm.scratchAttached = true } + logrus.Debugf("%s releasing cachedScratchMutex", title) d.cachedScratchMutex.Unlock() // If requested to start it with a mapped virtual disk, add it now. - if mvdToAdd != nil { - svm.config.MappedVirtualDisks = append(svm.config.MappedVirtualDisks, *mvdToAdd) + svm.config.MappedVirtualDisks = append(svm.config.MappedVirtualDisks, mvdToAdd...) + for _, mvd := range svm.config.MappedVirtualDisks { + svm.attachedVHDs[mvd.HostPath] = 1 } // Start it. @@ -349,108 +312,80 @@ func (d *Driver) startServiceVMIfNotRunning(id string, mvdToAdd *hcsshim.MappedV return nil, fmt.Errorf("failed to start service utility VM (%s): %s", context, err) } - // As it's now running, add it to the map, checking for a race where another - // thread has simultaneously tried to start it. - logrus.Debugf("%s locking serviceVmsMutex for insertion", title) - d.serviceVmsMutex.Lock() - if svm, ok := d.serviceVms[id]; ok { - logrus.Debugf("%s releasing serviceVmsMutex after insertion but exists", title) - d.serviceVmsMutex.Unlock() - return svm, nil - } - d.serviceVms[id] = svm - logrus.Debugf("%s releasing serviceVmsMutex after insertion", title) - d.serviceVmsMutex.Unlock() + // defer function to terminate the VM if the next steps fail + defer func() { + if err != nil { + waitTerminate(svm, fmt.Sprintf("startServiceVmIfNotRunning: %s (%s)", id, context)) + } + }() // Now we have a running service VM, we can create the cached scratch file if it doesn't exist. logrus.Debugf("%s locking cachedScratchMutex", title) d.cachedScratchMutex.Lock() if _, err := os.Stat(d.cachedScratchFile); err != nil { - logrus.Debugf("%s (%s): creating an SVM scratch - locking serviceVM", title, context) - svm.Lock() + logrus.Debugf("%s (%s): creating an SVM scratch", title, context) + + // Don't use svm.CreateExt4Vhdx since that only works when the service vm is setup, + // but we're still in that process right now. if err := svm.config.CreateExt4Vhdx(scratchTargetFile, client.DefaultVhdxSizeGB, d.cachedScratchFile); err != nil { - logrus.Debugf("%s (%s): releasing serviceVM on error path from CreateExt4Vhdx: %s", title, context, err) - svm.Unlock() logrus.Debugf("%s (%s): releasing cachedScratchMutex on error path", title, context) d.cachedScratchMutex.Unlock() - - // Do a force terminate and remove it from the map on failure, ignoring any errors - if err2 := d.terminateServiceVM(id, "error path from CreateExt4Vhdx", true); err2 != nil { - logrus.Warnf("failed to terminate service VM on error path from CreateExt4Vhdx: %s", err2) - } - + logrus.Debugf("%s: failed to create vm scratch %s: %s", title, scratchTargetFile, err) return nil, fmt.Errorf("failed to create SVM scratch VHDX (%s): %s", context, err) } - logrus.Debugf("%s (%s): releasing serviceVM after %s created and cached to %s", title, context, scratchTargetFile, d.cachedScratchFile) - svm.Unlock() } logrus.Debugf("%s (%s): releasing cachedScratchMutex", title, context) d.cachedScratchMutex.Unlock() // Hot-add the scratch-space if not already attached if !svm.scratchAttached { - logrus.Debugf("lcowdriver: startServiceVmIfNotRunning: (%s) hot-adding scratch %s - locking serviceVM", context, scratchTargetFile) - svm.Lock() - if err := svm.config.HotAddVhd(scratchTargetFile, toolsScratchPath, false, true); err != nil { - logrus.Debugf("%s (%s): releasing serviceVM on error path of HotAddVhd: %s", title, context, err) - svm.Unlock() - - // Do a force terminate and remove it from the map on failure, ignoring any errors - if err2 := d.terminateServiceVM(id, "error path from HotAddVhd", true); err2 != nil { - logrus.Warnf("failed to terminate service VM on error path from HotAddVhd: %s", err2) - } - + logrus.Debugf("lcowdriver: startServiceVmIfNotRunning: (%s) hot-adding scratch %s", context, scratchTargetFile) + if err := svm.hotAddVHDsAtStart(hcsshim.MappedVirtualDisk{ + HostPath: scratchTargetFile, + ContainerPath: toolsScratchPath, + CreateInUtilityVM: true, + }); err != nil { + logrus.Debugf("%s: failed to hot-add scratch %s: %s", title, scratchTargetFile, err) return nil, fmt.Errorf("failed to hot-add %s failed: %s", scratchTargetFile, err) } - logrus.Debugf("%s (%s): releasing serviceVM", title, context) - svm.Unlock() + svm.scratchAttached = true } logrus.Debugf("lcowdriver: startServiceVmIfNotRunning: (%s) success", context) return svm, nil } -// getServiceVM returns the appropriate service utility VM instance, optionally -// deleting it from the map (but not the global one) -func (d *Driver) getServiceVM(id string, deleteFromMap bool) (*serviceVMItem, error) { - logrus.Debugf("lcowdriver: getservicevm:locking serviceVmsMutex") - d.serviceVmsMutex.Lock() - defer func() { - logrus.Debugf("lcowdriver: getservicevm:releasing serviceVmsMutex") - d.serviceVmsMutex.Unlock() - }() - if d.globalMode { - id = svmGlobalID - } - if _, ok := d.serviceVms[id]; !ok { - return nil, fmt.Errorf("getservicevm for %s failed as not found", id) - } - svm := d.serviceVms[id] - if deleteFromMap && id != svmGlobalID { - logrus.Debugf("lcowdriver: getservicevm: removing %s from map", id) - delete(d.serviceVms, id) +// terminateServiceVM terminates a service utility VM if its running if it's, +// not being used by any goroutine, but does nothing when in global mode as it's +// lifetime is limited to that of the daemon. If the force flag is set, then +// the VM will be killed regardless of the ref count or if it's global. +func (d *Driver) terminateServiceVM(id, context string, force bool) (err error) { + // We don't do anything in safe mode unless the force flag has been passed, which + // is only the case for cleanup at driver termination. + if d.globalMode && !force { + logrus.Debugf("lcowdriver: terminateservicevm: %s (%s) - doing nothing as in global mode", id, context) + return nil } - return svm, nil -} -// terminateServiceVM terminates a service utility VM if its running, but does nothing -// when in global mode as it's lifetime is limited to that of the daemon. -func (d *Driver) terminateServiceVM(id, context string, force bool) error { + id = d.getVMID(id) - // We don't do anything in safe mode unless the force flag has been passed, which - // is only the case for cleanup at driver termination. - if d.globalMode { - if !force { - logrus.Debugf("lcowdriver: terminateservicevm: %s (%s) - doing nothing as in global mode", id, context) - return nil - } - id = svmGlobalID + var svm *serviceVM + var lastRef bool + if !force { + // In the not force case, we ref count + svm, lastRef, err = d.serviceVms.decrementRefCount(id) + } else { + // In the force case, we ignore the ref count and just set it to 0 + svm, err = d.serviceVms.setRefCountZero(id) + lastRef = true } - // Get the service VM and delete it from the map - svm, err := d.getServiceVM(id, true) - if err != nil { - return err + if err == errVMUnknown { + return nil + } else if err == errVMisTerminating { + return svm.getStopError() + } else if !lastRef { + return nil } // We run the deletion of the scratch as a deferred function to at least attempt @@ -459,26 +394,64 @@ func (d *Driver) terminateServiceVM(id, context string, force bool) error { if svm.scratchAttached { scratchTargetFile := filepath.Join(d.dataRoot, scratchDirectory, fmt.Sprintf("%s.vhdx", id)) logrus.Debugf("lcowdriver: terminateservicevm: %s (%s) - deleting scratch %s", id, context, scratchTargetFile) - if err := os.Remove(scratchTargetFile); err != nil { - logrus.Warnf("failed to remove scratch file %s (%s): %s", scratchTargetFile, context, err) + if errRemove := os.Remove(scratchTargetFile); errRemove != nil { + logrus.Warnf("failed to remove scratch file %s (%s): %s", scratchTargetFile, context, errRemove) + err = errRemove } } + + // This function shouldn't actually return error unless there is a bug + if errDelete := d.serviceVms.deleteID(id); errDelete != nil { + logrus.Warnf("failed to service vm from svm map %s (%s): %s", id, context, errDelete) + } + + // Signal that this VM has stopped + svm.signalStopFinished(err) }() - // Nothing to do if it's not running - if svm.config.Uvm != nil { - logrus.Debugf("lcowdriver: terminateservicevm: %s (%s) - calling terminate", id, context) - if err := svm.config.Uvm.Terminate(); err != nil { - return fmt.Errorf("failed to terminate utility VM (%s): %s", context, err) + // Now it's possible that the serivce VM failed to start and now we are trying to termiante it. + // In this case, we will relay the error to the goroutines waiting for this vm to stop. + if err := svm.getStartError(); err != nil { + logrus.Debugf("lcowdriver: terminateservicevm: %s had failed to start up: %s", id, err) + return err + } + + if err := waitTerminate(svm, fmt.Sprintf("terminateservicevm: %s (%s)", id, context)); err != nil { + return err + } + + logrus.Debugf("lcowdriver: terminateservicevm: %s (%s) - success", id, context) + return nil +} + +func waitTerminate(svm *serviceVM, context string) error { + if svm.config == nil { + return fmt.Errorf("lcowdriver: waitTermiante: Nil utility VM. %s", context) + } + + logrus.Debugf("lcowdriver: waitTerminate: Calling terminate: %s", context) + if err := svm.config.Uvm.Terminate(); err != nil { + // We might get operation still pending from the HCS. In that case, we shouldn't return + // an error since we call wait right after. + underlyingError := err + if conterr, ok := err.(*hcsshim.ContainerError); ok { + underlyingError = conterr.Err } - logrus.Debugf("lcowdriver: terminateservicevm: %s (%s) - waiting for utility VM to terminate", id, context) - if err := svm.config.Uvm.WaitTimeout(time.Duration(svm.config.UvmTimeoutSeconds) * time.Second); err != nil { - return fmt.Errorf("failed waiting for utility VM to terminate (%s): %s", context, err) + if syscallErr, ok := underlyingError.(syscall.Errno); ok { + underlyingError = syscallErr + } + + if underlyingError != errOperationPending { + return fmt.Errorf("failed to terminate utility VM (%s): %s", context, err) } + logrus.Debugf("lcowdriver: waitTerminate: uvm.Terminate() returned operation pending (%s)", context) } - logrus.Debugf("lcowdriver: terminateservicevm: %s (%s) - success", id, context) + logrus.Debugf("lcowdriver: waitTerminate: (%s) - waiting for utility VM to terminate", context) + if err := svm.config.Uvm.WaitTimeout(time.Duration(svm.config.UvmTimeoutSeconds) * time.Second); err != nil { + return fmt.Errorf("failed waiting for utility VM to terminate (%s): %s", context, err) + } return nil } @@ -571,25 +544,18 @@ func (d *Driver) CreateReadWrite(id, parent string, opts *graphdriver.CreateOpts }() } - // Synchronise the operation in the service VM. - logrus.Debugf("%s: locking svm for sandbox creation", title) - svm.Lock() - defer func() { - logrus.Debugf("%s: releasing svm for sandbox creation", title) - svm.Unlock() - }() - // Make sure we don't write to our local cached copy if this is for a non-default size request. targetCacheFile := d.cachedSandboxFile if sandboxSize != client.DefaultVhdxSizeGB { targetCacheFile = "" } - // Actually do the creation. - if err := svm.config.CreateExt4Vhdx(filepath.Join(d.dir(id), sandboxFilename), uint32(sandboxSize), targetCacheFile); err != nil { + // Create the ext4 vhdx + logrus.Debugf("%s: creating sandbox ext4 vhdx", title) + if err := svm.createExt4VHDX(filepath.Join(d.dir(id), sandboxFilename), uint32(sandboxSize), targetCacheFile); err != nil { + logrus.Debugf("%s: failed to create sandbox vhdx for %s: %s", title, id, err) return err } - return nil } @@ -638,6 +604,21 @@ func (d *Driver) Remove(id string) error { layerPath := d.dir(id) logrus.Debugf("lcowdriver: remove: id %s: layerPath %s", id, layerPath) + + // Unmount all the layers + err := d.Put(id) + if err != nil { + logrus.Debugf("lcowdriver: remove id %s: failed to unmount: %s", id, err) + return err + } + + // for non-global case just kill the vm + if !d.globalMode { + if err := d.terminateServiceVM(id, fmt.Sprintf("Remove %s", id), true); err != nil { + return err + } + } + if err := os.Rename(layerPath, tmpLayerPath); err != nil && !os.IsNotExist(err) { return err } @@ -659,43 +640,24 @@ func (d *Driver) Remove(id string) error { // For optimisation, we don't actually mount the filesystem (which in our // case means [hot-]adding it to a service VM. But we track that and defer // the actual adding to the point we need to access it. -func (d *Driver) Get(id, mountLabel string) (string, error) { +func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { title := fmt.Sprintf("lcowdriver: get: %s", id) logrus.Debugf(title) - // Work out what we are working on - ld, err := getLayerDetails(d.dir(id)) + // Generate the mounts needed for the defered operation. + disks, err := d.getAllMounts(id) if err != nil { - logrus.Debugf("%s failed to get layer details from %s: %s", title, d.dir(id), err) - return "", fmt.Errorf("%s failed to open layer or sandbox VHD to open in %s: %s", title, d.dir(id), err) - } - logrus.Debugf("%s %s, size %d, isSandbox %t", title, ld.filename, ld.size, ld.isSandbox) - - // Add item to cache, or update existing item, but ensure we have the - // lock while updating items. - logrus.Debugf("%s: locking cacheMutex", title) - d.cacheMutex.Lock() - var ci *cacheItem - if item, ok := d.cache[id]; !ok { - // The item is not currently in the cache. - ci = &cacheItem{ - refCount: 1, - isSandbox: ld.isSandbox, - hostPath: ld.filename, - uvmPath: fmt.Sprintf("/mnt/%s", id), - isMounted: false, // we defer this as an optimisation - } - d.cache[id] = ci - logrus.Debugf("%s: added cache item %+v", title, ci) - } else { - // Increment the reference counter in the cache. - item.incrementRefCount() + logrus.Debugf("%s failed to get all layer details for %s: %s", title, d.dir(id), err) + return nil, fmt.Errorf("%s failed to get layer details for %s: %s", title, d.dir(id), err) } - logrus.Debugf("%s: releasing cacheMutex", title) - d.cacheMutex.Unlock() - logrus.Debugf("%s %s success. %s: %+v: size %d", title, id, d.dir(id), ci, ld.size) - return d.dir(id), nil + logrus.Debugf("%s: got layer mounts: %+v", title, disks) + return &lcowfs{ + root: unionMountName(disks), + d: d, + mappedDisks: disks, + vmID: d.getVMID(id), + }, nil } // Put does the reverse of get. If there are no more references to @@ -703,56 +665,45 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { func (d *Driver) Put(id string) error { title := fmt.Sprintf("lcowdriver: put: %s", id) - logrus.Debugf("%s: locking cacheMutex", title) - d.cacheMutex.Lock() - item, ok := d.cache[id] - if !ok { - logrus.Debugf("%s: releasing cacheMutex on error path", title) - d.cacheMutex.Unlock() - return fmt.Errorf("%s possible ref-count error, or invalid id was passed to the graphdriver. Cannot handle id %s as it's not in the cache", title, id) - } - - // Decrement the ref-count, and nothing more to do if still in use. - if item.decrementRefCount() > 0 { - logrus.Debugf("%s: releasing cacheMutex. Cache item is still in use", title) - d.cacheMutex.Unlock() + // Get the service VM that we need to remove from + svm, err := d.serviceVms.get(d.getVMID(id)) + if err == errVMUnknown { return nil + } else if err == errVMisTerminating { + return svm.getStopError() } - // Remove from the cache map. - delete(d.cache, id) - logrus.Debugf("%s: releasing cacheMutex. Ref count on cache item has dropped to zero, removed from cache", title) - d.cacheMutex.Unlock() + // Generate the mounts that Get() might have mounted + disks, err := d.getAllMounts(id) + if err != nil { + logrus.Debugf("%s failed to get all layer details for %s: %s", title, d.dir(id), err) + return fmt.Errorf("%s failed to get layer details for %s: %s", title, d.dir(id), err) + } - // If we have done a mount and we are in global mode, then remove it. We don't - // need to remove in safe mode as the service VM is going to be torn down anyway. - if d.globalMode { - logrus.Debugf("%s: locking cache item at zero ref-count", title) - item.Lock() - defer func() { - logrus.Debugf("%s: releasing cache item at zero ref-count", title) - item.Unlock() - }() - if item.isMounted { - svm, err := d.getServiceVM(id, false) - if err != nil { - return err - } + // Now, we want to perform the unmounts, hot-remove and stop the service vm. + // We want to go though all the steps even if we have an error to clean up properly + err = svm.deleteUnionMount(unionMountName(disks), disks...) + if err != nil { + logrus.Debugf("%s failed to delete union mount %s: %s", title, id, err) + } - logrus.Debugf("%s: Hot-Removing %s. Locking svm", title, item.hostPath) - svm.Lock() - if err := svm.config.HotRemoveVhd(item.hostPath); err != nil { - logrus.Debugf("%s: releasing svm on error path", title) - svm.Unlock() - return fmt.Errorf("%s failed to hot-remove %s from global service utility VM: %s", title, item.hostPath, err) - } - logrus.Debugf("%s: releasing svm", title) - svm.Unlock() + err1 := svm.hotRemoveVHDs(disks...) + if err1 != nil { + logrus.Debugf("%s failed to hot remove vhds %s: %s", title, id, err) + if err == nil { + err = err1 } } - logrus.Debugf("%s %s: refCount 0. %s (%s) completed successfully", title, id, item.hostPath, item.uvmPath) - return nil + err1 = d.terminateServiceVM(id, fmt.Sprintf("Put %s", id), false) + if err1 != nil { + logrus.Debugf("%s failed to terminate service vm %s: %s", title, id, err1) + if err == nil { + err = err1 + } + } + logrus.Debugf("Put succeeded on id %s", id) + return err } // Cleanup ensures the information the driver stores is properly removed. @@ -761,15 +712,6 @@ func (d *Driver) Put(id string) error { func (d *Driver) Cleanup() error { title := "lcowdriver: cleanup" - d.cacheMutex.Lock() - for k, v := range d.cache { - logrus.Debugf("%s cache item: %s: %+v", title, k, v) - if v.refCount > 0 { - logrus.Warnf("%s leaked %s: %+v", title, k, v) - } - } - d.cacheMutex.Unlock() - items, err := ioutil.ReadDir(d.dataRoot) if err != nil { if os.IsNotExist(err) { @@ -794,8 +736,8 @@ func (d *Driver) Cleanup() error { // Cleanup any service VMs we have running, along with their scratch spaces. // We don't take the lock for this as it's taken in terminateServiceVm. - for k, v := range d.serviceVms { - logrus.Debugf("%s svm: %s: %+v", title, k, v) + for k, v := range d.serviceVms.svms { + logrus.Debugf("%s svm entry: %s: %+v", title, k, v) d.terminateServiceVM(k, "cleanup", true) } @@ -812,65 +754,41 @@ func (d *Driver) Cleanup() error { func (d *Driver) Diff(id, parent string) (io.ReadCloser, error) { title := fmt.Sprintf("lcowdriver: diff: %s", id) - logrus.Debugf("%s: locking cacheMutex", title) - d.cacheMutex.Lock() - if _, ok := d.cache[id]; !ok { - logrus.Debugf("%s: releasing cacheMutex on error path", title) - d.cacheMutex.Unlock() - return nil, fmt.Errorf("%s fail as %s is not in the cache", title, id) - } - ci := d.cache[id] - logrus.Debugf("%s: releasing cacheMutex", title) - d.cacheMutex.Unlock() - - // Stat to get size - logrus.Debugf("%s: locking cacheItem", title) - ci.Lock() - fileInfo, err := os.Stat(ci.hostPath) + // Get VHDX info + ld, err := getLayerDetails(d.dir(id)) if err != nil { - logrus.Debugf("%s: releasing cacheItem on error path", title) - ci.Unlock() - return nil, fmt.Errorf("%s failed to stat %s: %s", title, ci.hostPath, err) + logrus.Debugf("%s: failed to get vhdx information of %s: %s", title, d.dir(id), err) + return nil, err } - logrus.Debugf("%s: releasing cacheItem", title) - ci.Unlock() // Start the SVM with a mapped virtual disk. Note that if the SVM is - // already runing and we are in global mode, this will be + // already running and we are in global mode, this will be // hot-added. - mvd := &hcsshim.MappedVirtualDisk{ - HostPath: ci.hostPath, - ContainerPath: ci.uvmPath, + mvd := hcsshim.MappedVirtualDisk{ + HostPath: ld.filename, + ContainerPath: hostToGuest(ld.filename), CreateInUtilityVM: true, ReadOnly: true, } logrus.Debugf("%s: starting service VM", title) - svm, err := d.startServiceVMIfNotRunning(id, mvd, fmt.Sprintf("diff %s", id)) + svm, err := d.startServiceVMIfNotRunning(id, []hcsshim.MappedVirtualDisk{mvd}, fmt.Sprintf("diff %s", id)) if err != nil { return nil, err } - // Set `isMounted` for the cache item. Note that we re-scan the cache - // at this point as it's possible the cacheItem changed during the long- - // running operation above when we weren't holding the cacheMutex lock. - logrus.Debugf("%s: locking cacheMutex for updating isMounted", title) - d.cacheMutex.Lock() - if _, ok := d.cache[id]; !ok { - logrus.Debugf("%s: releasing cacheMutex on error path of isMounted", title) - d.cacheMutex.Unlock() + logrus.Debugf("lcowdriver: diff: waiting for svm to finish booting") + err = svm.getStartError() + if err != nil { d.terminateServiceVM(id, fmt.Sprintf("diff %s", id), false) - return nil, fmt.Errorf("%s fail as %s is not in the cache when updating isMounted", title, id) + return nil, fmt.Errorf("lcowdriver: diff: svm failed to boot: %s", err) } - ci = d.cache[id] - ci.setIsMounted() - logrus.Debugf("%s: releasing cacheMutex for updating isMounted", title) - d.cacheMutex.Unlock() // Obtain the tar stream for it - logrus.Debugf("%s %s, size %d, isSandbox %t", title, ci.hostPath, fileInfo.Size(), ci.isSandbox) - tarReadCloser, err := svm.config.VhdToTar(ci.hostPath, ci.uvmPath, ci.isSandbox, fileInfo.Size()) + logrus.Debugf("%s: %s %s, size %d, ReadOnly %t", title, ld.filename, mvd.ContainerPath, ld.size, ld.isSandbox) + tarReadCloser, err := svm.config.VhdToTar(mvd.HostPath, mvd.ContainerPath, ld.isSandbox, ld.size) if err != nil { + svm.hotRemoveVHDs(mvd) d.terminateServiceVM(id, fmt.Sprintf("diff %s", id), false) return nil, fmt.Errorf("%s failed to export layer to tar stream for id: %s, parent: %s : %s", title, id, parent, err) } @@ -878,14 +796,12 @@ func (d *Driver) Diff(id, parent string) (io.ReadCloser, error) { logrus.Debugf("%s id %s parent %s completed successfully", title, id, parent) // In safe/non-global mode, we can't tear down the service VM until things have been read. - if !d.globalMode { - return ioutils.NewReadCloserWrapper(tarReadCloser, func() error { - tarReadCloser.Close() - d.terminateServiceVM(id, fmt.Sprintf("diff %s", id), false) - return nil - }), nil - } - return tarReadCloser, nil + return ioutils.NewReadCloserWrapper(tarReadCloser, func() error { + tarReadCloser.Close() + svm.hotRemoveVHDs(mvd) + d.terminateServiceVM(id, fmt.Sprintf("diff %s", id), false) + return nil + }), nil } // ApplyDiff extracts the changeset from the given diff into the @@ -902,6 +818,12 @@ func (d *Driver) ApplyDiff(id, parent string, diff io.Reader) (int64, error) { } defer d.terminateServiceVM(id, fmt.Sprintf("applydiff %s", id), false) + logrus.Debugf("lcowdriver: applydiff: waiting for svm to finish booting") + err = svm.getStartError() + if err != nil { + return 0, fmt.Errorf("lcowdriver: applydiff: svm failed to boot: %s", err) + } + // TODO @jhowardmsft - the retries are temporary to overcome platform reliablity issues. // Obviously this will be removed as platform bugs are fixed. retries := 0 @@ -944,6 +866,11 @@ func (d *Driver) GetMetadata(id string) (map[string]string, error) { return m, nil } +// GetLayerPath gets the layer path on host (path to VHD/VHDX) +func (d *Driver) GetLayerPath(id string) (string, error) { + return d.dir(id), nil +} + // dir returns the absolute path to the layer. func (d *Driver) dir(id string) string { return filepath.Join(d.dataRoot, filepath.Base(id)) @@ -1006,3 +933,34 @@ func getLayerDetails(folder string) (*layerDetails, error) { return ld, nil } + +func (d *Driver) getAllMounts(id string) ([]hcsshim.MappedVirtualDisk, error) { + layerChain, err := d.getLayerChain(id) + if err != nil { + return nil, err + } + layerChain = append([]string{d.dir(id)}, layerChain...) + + logrus.Debugf("getting all layers: %v", layerChain) + disks := make([]hcsshim.MappedVirtualDisk, len(layerChain), len(layerChain)) + for i := range layerChain { + ld, err := getLayerDetails(layerChain[i]) + if err != nil { + logrus.Debugf("Failed to get LayerVhdDetails from %s: %s", layerChain[i], err) + return nil, err + } + disks[i].HostPath = ld.filename + disks[i].ContainerPath = hostToGuest(ld.filename) + disks[i].CreateInUtilityVM = true + disks[i].ReadOnly = !ld.isSandbox + } + return disks, nil +} + +func hostToGuest(hostpath string) string { + return fmt.Sprintf("/tmp/%s", filepath.Base(filepath.Dir(hostpath))) +} + +func unionMountName(disks []hcsshim.MappedVirtualDisk) string { + return fmt.Sprintf("%s-mount", disks[0].ContainerPath) +} diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/lcow/lcow_svm.go b/vendor/github.com/docker/docker/daemon/graphdriver/lcow/lcow_svm.go new file mode 100644 index 000000000..26f6df4f0 --- /dev/null +++ b/vendor/github.com/docker/docker/daemon/graphdriver/lcow/lcow_svm.go @@ -0,0 +1,373 @@ +// +build windows + +package lcow + +import ( + "errors" + "fmt" + "io" + "strings" + "sync" + "time" + + "github.com/Microsoft/hcsshim" + "github.com/Microsoft/opengcs/client" + "github.com/sirupsen/logrus" +) + +// Code for all the service VM management for the LCOW graphdriver + +var errVMisTerminating = errors.New("service VM is shutting down") +var errVMUnknown = errors.New("service vm id is unknown") +var errVMStillHasReference = errors.New("Attemping to delete a VM that is still being used") + +// serviceVMMap is the struct representing the id -> service VM mapping. +type serviceVMMap struct { + sync.Mutex + svms map[string]*serviceVMMapItem +} + +// serviceVMMapItem is our internal structure representing an item in our +// map of service VMs we are maintaining. +type serviceVMMapItem struct { + svm *serviceVM // actual service vm object + refCount int // refcount for VM +} + +type serviceVM struct { + sync.Mutex // Serialises operations being performed in this service VM. + scratchAttached bool // Has a scratch been attached? + config *client.Config // Represents the service VM item. + + // Indicates that the vm is started + startStatus chan interface{} + startError error + + // Indicates that the vm is stopped + stopStatus chan interface{} + stopError error + + attachedVHDs map[string]int // Map ref counting all the VHDS we've hot-added/hot-removed. + unionMounts map[string]int // Map ref counting all the union filesystems we mounted. +} + +// add will add an id to the service vm map. There are three cases: +// - entry doesn't exist: +// - add id to map and return a new vm that the caller can manually configure+start +// - entry does exist +// - return vm in map and increment ref count +// - entry does exist but the ref count is 0 +// - return the svm and errVMisTerminating. Caller can call svm.getStopError() to wait for stop +func (svmMap *serviceVMMap) add(id string) (svm *serviceVM, alreadyExists bool, err error) { + svmMap.Lock() + defer svmMap.Unlock() + if svm, ok := svmMap.svms[id]; ok { + if svm.refCount == 0 { + return svm.svm, true, errVMisTerminating + } + svm.refCount++ + return svm.svm, true, nil + } + + // Doesn't exist, so create an empty svm to put into map and return + newSVM := &serviceVM{ + startStatus: make(chan interface{}), + stopStatus: make(chan interface{}), + attachedVHDs: make(map[string]int), + unionMounts: make(map[string]int), + config: &client.Config{}, + } + svmMap.svms[id] = &serviceVMMapItem{ + svm: newSVM, + refCount: 1, + } + return newSVM, false, nil +} + +// get will get the service vm from the map. There are three cases: +// - entry doesn't exist: +// - return errVMUnknown +// - entry does exist +// - return vm with no error +// - entry does exist but the ref count is 0 +// - return the svm and errVMisTerminating. Caller can call svm.getStopError() to wait for stop +func (svmMap *serviceVMMap) get(id string) (*serviceVM, error) { + svmMap.Lock() + defer svmMap.Unlock() + svm, ok := svmMap.svms[id] + if !ok { + return nil, errVMUnknown + } + if svm.refCount == 0 { + return svm.svm, errVMisTerminating + } + return svm.svm, nil +} + +// decrementRefCount decrements the ref count of the given ID from the map. There are four cases: +// - entry doesn't exist: +// - return errVMUnknown +// - entry does exist but the ref count is 0 +// - return the svm and errVMisTerminating. Caller can call svm.getStopError() to wait for stop +// - entry does exist but ref count is 1 +// - return vm and set lastRef to true. The caller can then stop the vm, delete the id from this map +// - and execute svm.signalStopFinished to signal the threads that the svm has been terminated. +// - entry does exist and ref count > 1 +// - just reduce ref count and return svm +func (svmMap *serviceVMMap) decrementRefCount(id string) (_ *serviceVM, lastRef bool, _ error) { + svmMap.Lock() + defer svmMap.Unlock() + + svm, ok := svmMap.svms[id] + if !ok { + return nil, false, errVMUnknown + } + if svm.refCount == 0 { + return svm.svm, false, errVMisTerminating + } + svm.refCount-- + return svm.svm, svm.refCount == 0, nil +} + +// setRefCountZero works the same way as decrementRefCount, but sets ref count to 0 instead of decrementing it. +func (svmMap *serviceVMMap) setRefCountZero(id string) (*serviceVM, error) { + svmMap.Lock() + defer svmMap.Unlock() + + svm, ok := svmMap.svms[id] + if !ok { + return nil, errVMUnknown + } + if svm.refCount == 0 { + return svm.svm, errVMisTerminating + } + svm.refCount = 0 + return svm.svm, nil +} + +// deleteID deletes the given ID from the map. If the refcount is not 0 or the +// VM does not exist, then this function returns an error. +func (svmMap *serviceVMMap) deleteID(id string) error { + svmMap.Lock() + defer svmMap.Unlock() + svm, ok := svmMap.svms[id] + if !ok { + return errVMUnknown + } + if svm.refCount != 0 { + return errVMStillHasReference + } + delete(svmMap.svms, id) + return nil +} + +func (svm *serviceVM) signalStartFinished(err error) { + svm.Lock() + svm.startError = err + svm.Unlock() + close(svm.startStatus) +} + +func (svm *serviceVM) getStartError() error { + <-svm.startStatus + svm.Lock() + defer svm.Unlock() + return svm.startError +} + +func (svm *serviceVM) signalStopFinished(err error) { + svm.Lock() + svm.stopError = err + svm.Unlock() + close(svm.stopStatus) +} + +func (svm *serviceVM) getStopError() error { + <-svm.stopStatus + svm.Lock() + defer svm.Unlock() + return svm.stopError +} + +// hotAddVHDs waits for the service vm to start and then attaches the vhds. +func (svm *serviceVM) hotAddVHDs(mvds ...hcsshim.MappedVirtualDisk) error { + if err := svm.getStartError(); err != nil { + return err + } + return svm.hotAddVHDsAtStart(mvds...) +} + +// hotAddVHDsAtStart works the same way as hotAddVHDs but does not wait for the VM to start. +func (svm *serviceVM) hotAddVHDsAtStart(mvds ...hcsshim.MappedVirtualDisk) error { + svm.Lock() + defer svm.Unlock() + for i, mvd := range mvds { + if _, ok := svm.attachedVHDs[mvd.HostPath]; ok { + svm.attachedVHDs[mvd.HostPath]++ + continue + } + + if err := svm.config.HotAddVhd(mvd.HostPath, mvd.ContainerPath, mvd.ReadOnly, !mvd.AttachOnly); err != nil { + svm.hotRemoveVHDsAtStart(mvds[:i]...) + return err + } + svm.attachedVHDs[mvd.HostPath] = 1 + } + return nil +} + +// hotRemoveVHDs waits for the service vm to start and then removes the vhds. +func (svm *serviceVM) hotRemoveVHDs(mvds ...hcsshim.MappedVirtualDisk) error { + if err := svm.getStartError(); err != nil { + return err + } + return svm.hotRemoveVHDsAtStart(mvds...) +} + +// hotRemoveVHDsAtStart works the same way as hotRemoveVHDs but does not wait for the VM to start. +func (svm *serviceVM) hotRemoveVHDsAtStart(mvds ...hcsshim.MappedVirtualDisk) error { + svm.Lock() + defer svm.Unlock() + var retErr error + for _, mvd := range mvds { + if _, ok := svm.attachedVHDs[mvd.HostPath]; !ok { + // We continue instead of returning an error if we try to hot remove a non-existent VHD. + // This is because one of the callers of the function is graphdriver.Put(). Since graphdriver.Get() + // defers the VM start to the first operation, it's possible that nothing have been hot-added + // when Put() is called. To avoid Put returning an error in that case, we simply continue if we + // don't find the vhd attached. + continue + } + + if svm.attachedVHDs[mvd.HostPath] > 1 { + svm.attachedVHDs[mvd.HostPath]-- + continue + } + + // last VHD, so remove from VM and map + if err := svm.config.HotRemoveVhd(mvd.HostPath); err == nil { + delete(svm.attachedVHDs, mvd.HostPath) + } else { + // Take note of the error, but still continue to remove the other VHDs + logrus.Warnf("Failed to hot remove %s: %s", mvd.HostPath, err) + if retErr == nil { + retErr = err + } + } + } + return retErr +} + +func (svm *serviceVM) createExt4VHDX(destFile string, sizeGB uint32, cacheFile string) error { + if err := svm.getStartError(); err != nil { + return err + } + + svm.Lock() + defer svm.Unlock() + return svm.config.CreateExt4Vhdx(destFile, sizeGB, cacheFile) +} + +func (svm *serviceVM) createUnionMount(mountName string, mvds ...hcsshim.MappedVirtualDisk) (err error) { + if len(mvds) == 0 { + return fmt.Errorf("createUnionMount: error must have at least 1 layer") + } + + if err = svm.getStartError(); err != nil { + return err + } + + svm.Lock() + defer svm.Unlock() + if _, ok := svm.unionMounts[mountName]; ok { + svm.unionMounts[mountName]++ + return nil + } + + var lowerLayers []string + if mvds[0].ReadOnly { + lowerLayers = append(lowerLayers, mvds[0].ContainerPath) + } + + for i := 1; i < len(mvds); i++ { + lowerLayers = append(lowerLayers, mvds[i].ContainerPath) + } + + logrus.Debugf("Doing the overlay mount with union directory=%s", mountName) + if err = svm.runProcess(fmt.Sprintf("mkdir -p %s", mountName), nil, nil, nil); err != nil { + return err + } + + var cmd string + if mvds[0].ReadOnly { + // Readonly overlay + cmd = fmt.Sprintf("mount -t overlay overlay -olowerdir=%s %s", + strings.Join(lowerLayers, ","), + mountName) + } else { + upper := fmt.Sprintf("%s/upper", mvds[0].ContainerPath) + work := fmt.Sprintf("%s/work", mvds[0].ContainerPath) + + if err = svm.runProcess(fmt.Sprintf("mkdir -p %s %s", upper, work), nil, nil, nil); err != nil { + return err + } + + cmd = fmt.Sprintf("mount -t overlay overlay -olowerdir=%s,upperdir=%s,workdir=%s %s", + strings.Join(lowerLayers, ":"), + upper, + work, + mountName) + } + + logrus.Debugf("createUnionMount: Executing mount=%s", cmd) + if err = svm.runProcess(cmd, nil, nil, nil); err != nil { + return err + } + + svm.unionMounts[mountName] = 1 + return nil +} + +func (svm *serviceVM) deleteUnionMount(mountName string, disks ...hcsshim.MappedVirtualDisk) error { + if err := svm.getStartError(); err != nil { + return err + } + + svm.Lock() + defer svm.Unlock() + if _, ok := svm.unionMounts[mountName]; !ok { + return nil + } + + if svm.unionMounts[mountName] > 1 { + svm.unionMounts[mountName]-- + return nil + } + + logrus.Debugf("Removing union mount %s", mountName) + if err := svm.runProcess(fmt.Sprintf("umount %s", mountName), nil, nil, nil); err != nil { + return err + } + + delete(svm.unionMounts, mountName) + return nil +} + +func (svm *serviceVM) runProcess(command string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error { + process, err := svm.config.RunProcess(command, stdin, stdout, stderr) + if err != nil { + return err + } + defer process.Close() + + process.WaitTimeout(time.Duration(int(time.Second) * svm.config.UvmTimeoutSeconds)) + exitCode, err := process.ExitCode() + if err != nil { + return err + } + + if exitCode != 0 { + return fmt.Errorf("svm.runProcess: command %s failed with exit code %d", command, exitCode) + } + return nil +} diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs.go b/vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs.go new file mode 100644 index 000000000..148e3c0a2 --- /dev/null +++ b/vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs.go @@ -0,0 +1,139 @@ +// +build windows + +package lcow + +import ( + "bytes" + "fmt" + "io" + "runtime" + "strings" + "sync" + + "github.com/Microsoft/hcsshim" + "github.com/Microsoft/opengcs/service/gcsutils/remotefs" + "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/containerfs" + "github.com/sirupsen/logrus" +) + +type lcowfs struct { + root string + d *Driver + mappedDisks []hcsshim.MappedVirtualDisk + vmID string + currentSVM *serviceVM + sync.Mutex +} + +var _ containerfs.ContainerFS = &lcowfs{} + +// ErrNotSupported is an error for unsupported operations in the remotefs +var ErrNotSupported = fmt.Errorf("not supported") + +// Functions to implement the ContainerFS interface +func (l *lcowfs) Path() string { + return l.root +} + +func (l *lcowfs) ResolveScopedPath(path string, rawPath bool) (string, error) { + logrus.Debugf("remotefs.resolvescopedpath inputs: %s %s ", path, l.root) + + arg1 := l.Join(l.root, path) + if !rawPath { + // The l.Join("/", path) will make path an absolute path and then clean it + // so if path = ../../X, it will become /X. + arg1 = l.Join(l.root, l.Join("/", path)) + } + arg2 := l.root + + output := &bytes.Buffer{} + if err := l.runRemoteFSProcess(nil, output, remotefs.ResolvePathCmd, arg1, arg2); err != nil { + return "", err + } + + logrus.Debugf("remotefs.resolvescopedpath success. Output: %s\n", output.String()) + return output.String(), nil +} + +func (l *lcowfs) OS() string { + return "linux" +} + +func (l *lcowfs) Architecture() string { + return runtime.GOARCH +} + +// Other functions that are used by docker like the daemon Archiver/Extractor +func (l *lcowfs) ExtractArchive(src io.Reader, dst string, opts *archive.TarOptions) error { + logrus.Debugf("remotefs.ExtractArchve inputs: %s %+v", dst, opts) + + tarBuf := &bytes.Buffer{} + if err := remotefs.WriteTarOptions(tarBuf, opts); err != nil { + return fmt.Errorf("failed to marshall tar opts: %s", err) + } + + input := io.MultiReader(tarBuf, src) + if err := l.runRemoteFSProcess(input, nil, remotefs.ExtractArchiveCmd, dst); err != nil { + return fmt.Errorf("failed to extract archive to %s: %s", dst, err) + } + return nil +} + +func (l *lcowfs) ArchivePath(src string, opts *archive.TarOptions) (io.ReadCloser, error) { + logrus.Debugf("remotefs.ArchivePath: %s %+v", src, opts) + + tarBuf := &bytes.Buffer{} + if err := remotefs.WriteTarOptions(tarBuf, opts); err != nil { + return nil, fmt.Errorf("failed to marshall tar opts: %s", err) + } + + r, w := io.Pipe() + go func() { + defer w.Close() + if err := l.runRemoteFSProcess(tarBuf, w, remotefs.ArchivePathCmd, src); err != nil { + logrus.Debugf("REMOTEFS: Failed to extract archive: %s %+v %s", src, opts, err) + } + }() + return r, nil +} + +// Helper functions +func (l *lcowfs) startVM() error { + l.Lock() + defer l.Unlock() + if l.currentSVM != nil { + return nil + } + + svm, err := l.d.startServiceVMIfNotRunning(l.vmID, l.mappedDisks, fmt.Sprintf("lcowfs.startVM")) + if err != nil { + return err + } + + if err = svm.createUnionMount(l.root, l.mappedDisks...); err != nil { + return err + } + l.currentSVM = svm + return nil +} + +func (l *lcowfs) runRemoteFSProcess(stdin io.Reader, stdout io.Writer, args ...string) error { + if err := l.startVM(); err != nil { + return err + } + + // Append remotefs prefix and setup as a command line string + cmd := fmt.Sprintf("%s %s", remotefs.RemotefsCmd, strings.Join(args, " ")) + stderr := &bytes.Buffer{} + if err := l.currentSVM.runProcess(cmd, stdin, stdout, stderr); err != nil { + return err + } + + eerr, err := remotefs.ReadError(stderr) + if eerr != nil { + // Process returned an error so return that. + return remotefs.ExportedToError(eerr) + } + return err +} diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs_file.go b/vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs_file.go new file mode 100644 index 000000000..c13431973 --- /dev/null +++ b/vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs_file.go @@ -0,0 +1,211 @@ +// +build windows + +package lcow + +import ( + "bytes" + "encoding/binary" + "encoding/json" + "fmt" + "io" + "os" + "strconv" + + "github.com/Microsoft/hcsshim" + "github.com/Microsoft/opengcs/service/gcsutils/remotefs" + "github.com/containerd/continuity/driver" +) + +type lcowfile struct { + process hcsshim.Process + stdin io.WriteCloser + stdout io.ReadCloser + stderr io.ReadCloser + fs *lcowfs + guestPath string +} + +func (l *lcowfs) Open(path string) (driver.File, error) { + return l.OpenFile(path, os.O_RDONLY, 0) +} + +func (l *lcowfs) OpenFile(path string, flag int, perm os.FileMode) (_ driver.File, err error) { + flagStr := strconv.FormatInt(int64(flag), 10) + permStr := strconv.FormatUint(uint64(perm), 8) + + commandLine := fmt.Sprintf("%s %s %s %s", remotefs.RemotefsCmd, remotefs.OpenFileCmd, flagStr, permStr) + env := make(map[string]string) + env["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:" + processConfig := &hcsshim.ProcessConfig{ + EmulateConsole: false, + CreateStdInPipe: true, + CreateStdOutPipe: true, + CreateStdErrPipe: true, + CreateInUtilityVm: true, + WorkingDirectory: "/bin", + Environment: env, + CommandLine: commandLine, + } + + process, err := l.currentSVM.config.Uvm.CreateProcess(processConfig) + if err != nil { + return nil, fmt.Errorf("failed to open file %s: %s", path, err) + } + + stdin, stdout, stderr, err := process.Stdio() + if err != nil { + process.Kill() + process.Close() + return nil, fmt.Errorf("failed to open file pipes %s: %s", path, err) + } + + lf := &lcowfile{ + process: process, + stdin: stdin, + stdout: stdout, + stderr: stderr, + fs: l, + guestPath: path, + } + + if _, err := lf.getResponse(); err != nil { + return nil, fmt.Errorf("failed to open file %s: %s", path, err) + } + return lf, nil +} + +func (l *lcowfile) Read(b []byte) (int, error) { + hdr := &remotefs.FileHeader{ + Cmd: remotefs.Read, + Size: uint64(len(b)), + } + + if err := remotefs.WriteFileHeader(l.stdin, hdr, nil); err != nil { + return 0, err + } + + buf, err := l.getResponse() + if err != nil { + return 0, nil + } + + n := copy(b, buf) + return n, nil +} + +func (l *lcowfile) Write(b []byte) (int, error) { + hdr := &remotefs.FileHeader{ + Cmd: remotefs.Write, + Size: uint64(len(b)), + } + + if err := remotefs.WriteFileHeader(l.stdin, hdr, b); err != nil { + return 0, err + } + + _, err := l.getResponse() + if err != nil { + return 0, nil + } + + return len(b), nil +} + +func (l *lcowfile) Seek(offset int64, whence int) (int64, error) { + seekHdr := &remotefs.SeekHeader{ + Offset: offset, + Whence: int32(whence), + } + + buf := &bytes.Buffer{} + if err := binary.Write(buf, binary.BigEndian, seekHdr); err != nil { + return 0, err + } + + hdr := &remotefs.FileHeader{ + Cmd: remotefs.Write, + Size: uint64(buf.Len()), + } + if err := remotefs.WriteFileHeader(l.stdin, hdr, buf.Bytes()); err != nil { + return 0, err + } + + resBuf, err := l.getResponse() + if err != nil { + return 0, err + } + + var res int64 + if err := binary.Read(bytes.NewBuffer(resBuf), binary.BigEndian, &res); err != nil { + return 0, err + } + return res, nil +} + +func (l *lcowfile) Close() error { + hdr := &remotefs.FileHeader{ + Cmd: remotefs.Close, + Size: 0, + } + + if err := remotefs.WriteFileHeader(l.stdin, hdr, nil); err != nil { + return err + } + + _, err := l.getResponse() + return err +} + +func (l *lcowfile) Readdir(n int) ([]os.FileInfo, error) { + nStr := strconv.FormatInt(int64(n), 10) + + // Unlike the other File functions, this one can just be run without maintaining state, + // so just do the normal runRemoteFSProcess way. + buf := &bytes.Buffer{} + if err := l.fs.runRemoteFSProcess(nil, buf, remotefs.ReadDirCmd, l.guestPath, nStr); err != nil { + return nil, err + } + + var info []remotefs.FileInfo + if err := json.Unmarshal(buf.Bytes(), &info); err != nil { + return nil, nil + } + + osInfo := make([]os.FileInfo, len(info)) + for i := range info { + osInfo[i] = &info[i] + } + return osInfo, nil +} + +func (l *lcowfile) getResponse() ([]byte, error) { + hdr, err := remotefs.ReadFileHeader(l.stdout) + if err != nil { + return nil, err + } + + if hdr.Cmd != remotefs.CmdOK { + // Something went wrong during the openfile in the server. + // Parse stderr and return that as an error + eerr, err := remotefs.ReadError(l.stderr) + if eerr != nil { + return nil, remotefs.ExportedToError(eerr) + } + + // Maybe the parsing went wrong? + if err != nil { + return nil, err + } + + // At this point, we know something went wrong in the remotefs program, but + // we we don't know why. + return nil, fmt.Errorf("unknown error") + } + + // Successful command, we might have some data to read (for Read + Seek) + buf := make([]byte, hdr.Size, hdr.Size) + if _, err := io.ReadFull(l.stdout, buf); err != nil { + return nil, err + } + return buf, nil +} diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs_filedriver.go b/vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs_filedriver.go new file mode 100644 index 000000000..a3e0d9e9f --- /dev/null +++ b/vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs_filedriver.go @@ -0,0 +1,123 @@ +// +build windows + +package lcow + +import ( + "bytes" + "encoding/json" + "os" + "strconv" + + "github.com/Microsoft/opengcs/service/gcsutils/remotefs" + + "github.com/containerd/continuity/driver" + "github.com/sirupsen/logrus" +) + +var _ driver.Driver = &lcowfs{} + +func (l *lcowfs) Readlink(p string) (string, error) { + logrus.Debugf("removefs.readlink args: %s", p) + + result := &bytes.Buffer{} + if err := l.runRemoteFSProcess(nil, result, remotefs.ReadlinkCmd, p); err != nil { + return "", err + } + return result.String(), nil +} + +func (l *lcowfs) Mkdir(path string, mode os.FileMode) error { + return l.mkdir(path, mode, remotefs.MkdirCmd) +} + +func (l *lcowfs) MkdirAll(path string, mode os.FileMode) error { + return l.mkdir(path, mode, remotefs.MkdirAllCmd) +} + +func (l *lcowfs) mkdir(path string, mode os.FileMode, cmd string) error { + modeStr := strconv.FormatUint(uint64(mode), 8) + logrus.Debugf("remotefs.%s args: %s %s", cmd, path, modeStr) + return l.runRemoteFSProcess(nil, nil, cmd, path, modeStr) +} + +func (l *lcowfs) Remove(path string) error { + return l.remove(path, remotefs.RemoveCmd) +} + +func (l *lcowfs) RemoveAll(path string) error { + return l.remove(path, remotefs.RemoveAllCmd) +} + +func (l *lcowfs) remove(path string, cmd string) error { + logrus.Debugf("remotefs.%s args: %s", cmd, path) + return l.runRemoteFSProcess(nil, nil, cmd, path) +} + +func (l *lcowfs) Link(oldname, newname string) error { + return l.link(oldname, newname, remotefs.LinkCmd) +} + +func (l *lcowfs) Symlink(oldname, newname string) error { + return l.link(oldname, newname, remotefs.SymlinkCmd) +} + +func (l *lcowfs) link(oldname, newname, cmd string) error { + logrus.Debugf("remotefs.%s args: %s %s", cmd, oldname, newname) + return l.runRemoteFSProcess(nil, nil, cmd, oldname, newname) +} + +func (l *lcowfs) Lchown(name string, uid, gid int64) error { + uidStr := strconv.FormatInt(uid, 10) + gidStr := strconv.FormatInt(gid, 10) + + logrus.Debugf("remotefs.lchown args: %s %s %s", name, uidStr, gidStr) + return l.runRemoteFSProcess(nil, nil, remotefs.LchownCmd, name, uidStr, gidStr) +} + +// Lchmod changes the mode of an file not following symlinks. +func (l *lcowfs) Lchmod(path string, mode os.FileMode) error { + modeStr := strconv.FormatUint(uint64(mode), 8) + logrus.Debugf("remotefs.lchmod args: %s %s", path, modeStr) + return l.runRemoteFSProcess(nil, nil, remotefs.LchmodCmd, path, modeStr) +} + +func (l *lcowfs) Mknod(path string, mode os.FileMode, major, minor int) error { + modeStr := strconv.FormatUint(uint64(mode), 8) + majorStr := strconv.FormatUint(uint64(major), 10) + minorStr := strconv.FormatUint(uint64(minor), 10) + + logrus.Debugf("remotefs.mknod args: %s %s %s %s", path, modeStr, majorStr, minorStr) + return l.runRemoteFSProcess(nil, nil, remotefs.MknodCmd, path, modeStr, majorStr, minorStr) +} + +func (l *lcowfs) Mkfifo(path string, mode os.FileMode) error { + modeStr := strconv.FormatUint(uint64(mode), 8) + logrus.Debugf("remotefs.mkfifo args: %s %s", path, modeStr) + return l.runRemoteFSProcess(nil, nil, remotefs.MkfifoCmd, path, modeStr) +} + +func (l *lcowfs) Stat(p string) (os.FileInfo, error) { + return l.stat(p, remotefs.StatCmd) +} + +func (l *lcowfs) Lstat(p string) (os.FileInfo, error) { + return l.stat(p, remotefs.LstatCmd) +} + +func (l *lcowfs) stat(path string, cmd string) (os.FileInfo, error) { + logrus.Debugf("remotefs.stat inputs: %s %s", cmd, path) + + output := &bytes.Buffer{} + err := l.runRemoteFSProcess(nil, output, cmd, path) + if err != nil { + return nil, err + } + + var fi remotefs.FileInfo + if err := json.Unmarshal(output.Bytes(), &fi); err != nil { + return nil, err + } + + logrus.Debugf("remotefs.stat success. got: %v\n", fi) + return &fi, nil +} diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs_pathdriver.go b/vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs_pathdriver.go new file mode 100644 index 000000000..95d3e715a --- /dev/null +++ b/vendor/github.com/docker/docker/daemon/graphdriver/lcow/remotefs_pathdriver.go @@ -0,0 +1,212 @@ +// +build windows + +package lcow + +import ( + "errors" + "os" + pathpkg "path" + "path/filepath" + "sort" + "strings" + + "github.com/containerd/continuity/pathdriver" +) + +var _ pathdriver.PathDriver = &lcowfs{} + +// Continuity Path functions can be done locally +func (l *lcowfs) Join(path ...string) string { + return pathpkg.Join(path...) +} + +func (l *lcowfs) IsAbs(path string) bool { + return pathpkg.IsAbs(path) +} + +func sameWord(a, b string) bool { + return a == b +} + +// Implementation taken from the Go standard library +func (l *lcowfs) Rel(basepath, targpath string) (string, error) { + baseVol := "" + targVol := "" + base := l.Clean(basepath) + targ := l.Clean(targpath) + if sameWord(targ, base) { + return ".", nil + } + base = base[len(baseVol):] + targ = targ[len(targVol):] + if base == "." { + base = "" + } + // Can't use IsAbs - `\a` and `a` are both relative in Windows. + baseSlashed := len(base) > 0 && base[0] == l.Separator() + targSlashed := len(targ) > 0 && targ[0] == l.Separator() + if baseSlashed != targSlashed || !sameWord(baseVol, targVol) { + return "", errors.New("Rel: can't make " + targpath + " relative to " + basepath) + } + // Position base[b0:bi] and targ[t0:ti] at the first differing elements. + bl := len(base) + tl := len(targ) + var b0, bi, t0, ti int + for { + for bi < bl && base[bi] != l.Separator() { + bi++ + } + for ti < tl && targ[ti] != l.Separator() { + ti++ + } + if !sameWord(targ[t0:ti], base[b0:bi]) { + break + } + if bi < bl { + bi++ + } + if ti < tl { + ti++ + } + b0 = bi + t0 = ti + } + if base[b0:bi] == ".." { + return "", errors.New("Rel: can't make " + targpath + " relative to " + basepath) + } + if b0 != bl { + // Base elements left. Must go up before going down. + seps := strings.Count(base[b0:bl], string(l.Separator())) + size := 2 + seps*3 + if tl != t0 { + size += 1 + tl - t0 + } + buf := make([]byte, size) + n := copy(buf, "..") + for i := 0; i < seps; i++ { + buf[n] = l.Separator() + copy(buf[n+1:], "..") + n += 3 + } + if t0 != tl { + buf[n] = l.Separator() + copy(buf[n+1:], targ[t0:]) + } + return string(buf), nil + } + return targ[t0:], nil +} + +func (l *lcowfs) Base(path string) string { + return pathpkg.Base(path) +} + +func (l *lcowfs) Dir(path string) string { + return pathpkg.Dir(path) +} + +func (l *lcowfs) Clean(path string) string { + return pathpkg.Clean(path) +} + +func (l *lcowfs) Split(path string) (dir, file string) { + return pathpkg.Split(path) +} + +func (l *lcowfs) Separator() byte { + return '/' +} + +func (l *lcowfs) Abs(path string) (string, error) { + // Abs is supposed to add the current working directory, which is meaningless in lcow. + // So, return an error. + return "", ErrNotSupported +} + +// Implementation taken from the Go standard library +func (l *lcowfs) Walk(root string, walkFn filepath.WalkFunc) error { + info, err := l.Lstat(root) + if err != nil { + err = walkFn(root, nil, err) + } else { + err = l.walk(root, info, walkFn) + } + if err == filepath.SkipDir { + return nil + } + return err +} + +// walk recursively descends path, calling w. +func (l *lcowfs) walk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error { + err := walkFn(path, info, nil) + if err != nil { + if info.IsDir() && err == filepath.SkipDir { + return nil + } + return err + } + + if !info.IsDir() { + return nil + } + + names, err := l.readDirNames(path) + if err != nil { + return walkFn(path, info, err) + } + + for _, name := range names { + filename := l.Join(path, name) + fileInfo, err := l.Lstat(filename) + if err != nil { + if err := walkFn(filename, fileInfo, err); err != nil && err != filepath.SkipDir { + return err + } + } else { + err = l.walk(filename, fileInfo, walkFn) + if err != nil { + if !fileInfo.IsDir() || err != filepath.SkipDir { + return err + } + } + } + } + return nil +} + +// readDirNames reads the directory named by dirname and returns +// a sorted list of directory entries. +func (l *lcowfs) readDirNames(dirname string) ([]string, error) { + f, err := l.Open(dirname) + if err != nil { + return nil, err + } + files, err := f.Readdir(-1) + f.Close() + if err != nil { + return nil, err + } + + names := make([]string, len(files), len(files)) + for i := range files { + names[i] = files[i].Name() + } + + sort.Strings(names) + return names, nil +} + +// Note that Go's filepath.FromSlash/ToSlash convert between OS paths and '/'. Since the path separator +// for LCOW (and Unix) is '/', they are no-ops. +func (l *lcowfs) FromSlash(path string) string { + return path +} + +func (l *lcowfs) ToSlash(path string) string { + return path +} + +func (l *lcowfs) Match(pattern, name string) (matched bool, err error) { + return pathpkg.Match(pattern, name) +} diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/overlay/copy.go b/vendor/github.com/docker/docker/daemon/graphdriver/overlay/copy.go index 53ea5bff1..f7e35e2bd 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/overlay/copy.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/overlay/copy.go @@ -121,7 +121,7 @@ func copyDir(srcDir, dstDir string, flags copyFlags) error { } default: - return fmt.Errorf("Unknown file type for %s\n", srcPath) + return fmt.Errorf("unknown file type for %s", srcPath) } // Everything below is copying metadata from src to dst. All this metadata @@ -157,6 +157,7 @@ func copyDir(srcDir, dstDir string, flags copyFlags) error { } // system.Chtimes doesn't support a NOFOLLOW flag atm + // nolint: unconvert if !isSymlink { aTime := time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)) mTime := time.Unix(int64(stat.Mtim.Sec), int64(stat.Mtim.Nsec)) diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/overlay/overlay.go b/vendor/github.com/docker/docker/daemon/graphdriver/overlay/overlay.go index 0d14b045f..9012722c2 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/overlay/overlay.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/overlay/overlay.go @@ -15,6 +15,7 @@ import ( "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/daemon/graphdriver/overlayutils" "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/fsutils" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/locker" @@ -269,10 +270,7 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) (retErr // Toplevel images are just a "root" dir if parent == "" { - if err := idtools.MkdirAs(path.Join(dir, "root"), 0755, rootUID, rootGID); err != nil { - return err - } - return nil + return idtools.MkdirAndChown(path.Join(dir, "root"), 0755, idtools.IDPair{rootUID, rootGID}) } parentDir := d.dir(parent) @@ -344,21 +342,21 @@ func (d *Driver) Remove(id string) error { } // Get creates and mounts the required file system for the given id and returns the mount path. -func (d *Driver) Get(id string, mountLabel string) (s string, err error) { +func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, err error) { d.locker.Lock(id) defer d.locker.Unlock(id) dir := d.dir(id) if _, err := os.Stat(dir); err != nil { - return "", err + return nil, err } // If id has a root, just return it rootDir := path.Join(dir, "root") if _, err := os.Stat(rootDir); err == nil { - return rootDir, nil + return containerfs.NewLocalContainerFS(rootDir), nil } mergedDir := path.Join(dir, "merged") if count := d.ctr.Increment(mergedDir); count > 1 { - return mergedDir, nil + return containerfs.NewLocalContainerFS(mergedDir), nil } defer func() { if err != nil { @@ -369,7 +367,7 @@ func (d *Driver) Get(id string, mountLabel string) (s string, err error) { }() lowerID, err := ioutil.ReadFile(path.Join(dir, "lower-id")) if err != nil { - return "", err + return nil, err } var ( lowerDir = path.Join(d.dir(string(lowerID)), "root") @@ -378,18 +376,18 @@ func (d *Driver) Get(id string, mountLabel string) (s string, err error) { opts = fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", lowerDir, upperDir, workDir) ) if err := unix.Mount("overlay", mergedDir, "overlay", 0, label.FormatMountLabel(opts, mountLabel)); err != nil { - return "", fmt.Errorf("error creating overlay mount to %s: %v", mergedDir, err) + return nil, fmt.Errorf("error creating overlay mount to %s: %v", mergedDir, err) } // chown "workdir/work" to the remapped root UID/GID. Overlay fs inside a // user namespace requires this to move a directory from lower to upper. rootUID, rootGID, err := idtools.GetRootUIDGID(d.uidMaps, d.gidMaps) if err != nil { - return "", err + return nil, err } if err := os.Chown(path.Join(workDir, "work"), rootUID, rootGID); err != nil { - return "", err + return nil, err } - return mergedDir, nil + return containerfs.NewLocalContainerFS(mergedDir), nil } // Put unmounts the mount path created for the give id. diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/overlay2/overlay.go b/vendor/github.com/docker/docker/daemon/graphdriver/overlay2/overlay.go index 6b0d4be86..9650975b3 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/overlay2/overlay.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/overlay2/overlay.go @@ -23,6 +23,7 @@ import ( "github.com/docker/docker/daemon/graphdriver/quota" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/chrootarchive" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/directory" "github.com/docker/docker/pkg/fsutils" "github.com/docker/docker/pkg/idtools" @@ -514,12 +515,12 @@ func (d *Driver) Remove(id string) error { } // Get creates and mounts the required file system for the given id and returns the mount path. -func (d *Driver) Get(id string, mountLabel string) (s string, err error) { +func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { d.locker.Lock(id) defer d.locker.Unlock(id) dir := d.dir(id) if _, err := os.Stat(dir); err != nil { - return "", err + return nil, err } diffDir := path.Join(dir, "diff") @@ -527,14 +528,14 @@ func (d *Driver) Get(id string, mountLabel string) (s string, err error) { if err != nil { // If no lower, just return diff directory if os.IsNotExist(err) { - return diffDir, nil + return containerfs.NewLocalContainerFS(diffDir), nil } - return "", err + return nil, err } mergedDir := path.Join(dir, "merged") if count := d.ctr.Increment(mergedDir); count > 1 { - return mergedDir, nil + return containerfs.NewLocalContainerFS(mergedDir), nil } defer func() { if err != nil { @@ -574,7 +575,7 @@ func (d *Driver) Get(id string, mountLabel string) (s string, err error) { opts = fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", string(lowers), path.Join(id, "diff"), path.Join(id, "work")) mountData = label.FormatMountLabel(opts, mountLabel) if len(mountData) > pageSize { - return "", fmt.Errorf("cannot mount layer, mount label too large %d", len(mountData)) + return nil, fmt.Errorf("cannot mount layer, mount label too large %d", len(mountData)) } mount = func(source string, target string, mType string, flags uintptr, label string) error { @@ -584,21 +585,21 @@ func (d *Driver) Get(id string, mountLabel string) (s string, err error) { } if err := mount("overlay", mountTarget, "overlay", 0, mountData); err != nil { - return "", fmt.Errorf("error creating overlay mount to %s: %v", mergedDir, err) + return nil, fmt.Errorf("error creating overlay mount to %s: %v", mergedDir, err) } // chown "workdir/work" to the remapped root UID/GID. Overlay fs inside a // user namespace requires this to move a directory from lower to upper. rootUID, rootGID, err := idtools.GetRootUIDGID(d.uidMaps, d.gidMaps) if err != nil { - return "", err + return nil, err } if err := os.Chown(path.Join(workDir, "work"), rootUID, rootGID); err != nil { - return "", err + return nil, err } - return mergedDir, nil + return containerfs.NewLocalContainerFS(mergedDir), nil } // Put unmounts the mount path created for the give id. diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/plugin.go b/vendor/github.com/docker/docker/daemon/graphdriver/plugin.go index f6852f075..5d433e519 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/plugin.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/plugin.go @@ -2,22 +2,12 @@ package graphdriver import ( "fmt" - "io" "path/filepath" "github.com/docker/docker/pkg/plugingetter" "github.com/docker/docker/plugin/v2" ) -type pluginClient interface { - // Call calls the specified method with the specified arguments for the plugin. - Call(string, interface{}, interface{}) error - // Stream calls the specified method with the specified arguments for the plugin and returns the response IO stream - Stream(string, interface{}) (io.ReadCloser, error) - // SendFile calls the specified method, and passes through the IO stream - SendFile(string, io.Reader, interface{}) error -} - func lookupPlugin(name string, pg plugingetter.PluginGetter, config Options) (Driver, error) { if !config.ExperimentalEnabled { return nil, fmt.Errorf("graphdriver plugins are only supported with experimental mode") diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/proxy.go b/vendor/github.com/docker/docker/daemon/graphdriver/proxy.go index 120afad45..81ef872ad 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/proxy.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/proxy.go @@ -7,6 +7,7 @@ import ( "path/filepath" "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/plugingetter" "github.com/docker/docker/pkg/plugins" @@ -129,20 +130,20 @@ func (d *graphDriverProxy) Remove(id string) error { return nil } -func (d *graphDriverProxy) Get(id, mountLabel string) (string, error) { +func (d *graphDriverProxy) Get(id, mountLabel string) (containerfs.ContainerFS, error) { args := &graphDriverRequest{ ID: id, MountLabel: mountLabel, } var ret graphDriverResponse if err := d.p.Client().Call("GraphDriver.Get", args, &ret); err != nil { - return "", err + return nil, err } var err error if ret.Err != "" { err = errors.New(ret.Err) } - return filepath.Join(d.p.BasePath(), ret.Dir), err + return containerfs.NewLocalContainerFS(filepath.Join(d.p.BasePath(), ret.Dir)), err } func (d *graphDriverProxy) Put(id string) error { diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/register/register_devicemapper.go b/vendor/github.com/docker/docker/daemon/graphdriver/register/register_devicemapper.go index bb2e9ef54..09dfb71eb 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/register/register_devicemapper.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/register/register_devicemapper.go @@ -1,4 +1,4 @@ -// +build !exclude_graphdriver_devicemapper,linux +// +build !exclude_graphdriver_devicemapper,!static_build,linux package register diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/vfs/driver.go b/vendor/github.com/docker/docker/daemon/graphdriver/vfs/driver.go index 15a4de360..0482dccb8 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/vfs/driver.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/vfs/driver.go @@ -7,6 +7,7 @@ import ( "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/pkg/chrootarchive" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/system" "github.com/opencontainers/selinux/go-selinux/label" @@ -94,7 +95,7 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error { if err != nil { return fmt.Errorf("%s: %s", parent, err) } - return CopyWithTar(parentDir, dir) + return CopyWithTar(parentDir.Path(), dir) } func (d *Driver) dir(id string) string { @@ -103,21 +104,18 @@ func (d *Driver) dir(id string) string { // Remove deletes the content from the directory for a given id. func (d *Driver) Remove(id string) error { - if err := system.EnsureRemoveAll(d.dir(id)); err != nil { - return err - } - return nil + return system.EnsureRemoveAll(d.dir(id)) } // Get returns the directory for the given id. -func (d *Driver) Get(id, mountLabel string) (string, error) { +func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { dir := d.dir(id) if st, err := os.Stat(dir); err != nil { - return "", err + return nil, err } else if !st.IsDir() { - return "", fmt.Errorf("%s: not a directory", dir) + return nil, fmt.Errorf("%s: not a directory", dir) } - return dir, nil + return containerfs.NewLocalContainerFS(dir), nil } // Put is a noop for vfs that return nil for the error, since this driver has no runtime resources to clean up. diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/windows/windows.go b/vendor/github.com/docker/docker/daemon/graphdriver/windows/windows.go index 44114051b..e7130d80f 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/windows/windows.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/windows/windows.go @@ -26,6 +26,7 @@ import ( "github.com/Microsoft/hcsshim" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/longpath" @@ -354,36 +355,36 @@ func (d *Driver) Remove(id string) error { } // Get returns the rootfs path for the id. This will mount the dir at its given path. -func (d *Driver) Get(id, mountLabel string) (string, error) { +func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { panicIfUsedByLcow() logrus.Debugf("WindowsGraphDriver Get() id %s mountLabel %s", id, mountLabel) var dir string rID, err := d.resolveID(id) if err != nil { - return "", err + return nil, err } if count := d.ctr.Increment(rID); count > 1 { - return d.cache[rID], nil + return containerfs.NewLocalContainerFS(d.cache[rID]), nil } // Getting the layer paths must be done outside of the lock. layerChain, err := d.getLayerChain(rID) if err != nil { d.ctr.Decrement(rID) - return "", err + return nil, err } if err := hcsshim.ActivateLayer(d.info, rID); err != nil { d.ctr.Decrement(rID) - return "", err + return nil, err } if err := hcsshim.PrepareLayer(d.info, rID, layerChain); err != nil { d.ctr.Decrement(rID) if err2 := hcsshim.DeactivateLayer(d.info, rID); err2 != nil { logrus.Warnf("Failed to Deactivate %s: %s", id, err) } - return "", err + return nil, err } mountPath, err := hcsshim.GetLayerMountPath(d.info, rID) @@ -395,7 +396,7 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { if err2 := hcsshim.DeactivateLayer(d.info, rID); err2 != nil { logrus.Warnf("Failed to Deactivate %s: %s", id, err) } - return "", err + return nil, err } d.cacheMu.Lock() d.cache[rID] = mountPath @@ -409,7 +410,7 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { dir = d.dir(id) } - return dir, nil + return containerfs.NewLocalContainerFS(dir), nil } // Put adds a new layer to the driver. @@ -618,7 +619,7 @@ func (d *Driver) DiffSize(id, parent string) (size int64, err error) { } defer d.Put(id) - return archive.ChangesSize(layerFs, changes), nil + return archive.ChangesSize(layerFs.Path(), changes), nil } // GetMetadata returns custom driver information. diff --git a/vendor/github.com/docker/docker/daemon/graphdriver/zfs/zfs.go b/vendor/github.com/docker/docker/daemon/graphdriver/zfs/zfs.go index 729099a6c..4caedef0e 100644 --- a/vendor/github.com/docker/docker/daemon/graphdriver/zfs/zfs.go +++ b/vendor/github.com/docker/docker/daemon/graphdriver/zfs/zfs.go @@ -13,6 +13,7 @@ import ( "time" "github.com/docker/docker/daemon/graphdriver" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/parsers" @@ -356,10 +357,10 @@ func (d *Driver) Remove(id string) error { } // Get returns the mountpoint for the given id after creating the target directories if necessary. -func (d *Driver) Get(id, mountLabel string) (string, error) { +func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { mountpoint := d.mountPath(id) if count := d.ctr.Increment(mountpoint); count > 1 { - return mountpoint, nil + return containerfs.NewLocalContainerFS(mountpoint), nil } filesystem := d.zfsPath(id) @@ -369,17 +370,17 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { rootUID, rootGID, err := idtools.GetRootUIDGID(d.uidMaps, d.gidMaps) if err != nil { d.ctr.Decrement(mountpoint) - return "", err + return nil, err } // Create the target directories if they don't exist if err := idtools.MkdirAllAs(mountpoint, 0755, rootUID, rootGID); err != nil { d.ctr.Decrement(mountpoint) - return "", err + return nil, err } if err := mount.Mount(filesystem, mountpoint, "zfs", options); err != nil { d.ctr.Decrement(mountpoint) - return "", fmt.Errorf("error creating zfs mount of %s to %s: %v", filesystem, mountpoint, err) + return nil, fmt.Errorf("error creating zfs mount of %s to %s: %v", filesystem, mountpoint, err) } // this could be our first mount after creation of the filesystem, and the root dir may still have root @@ -387,10 +388,10 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { if err := os.Chown(mountpoint, rootUID, rootGID); err != nil { mount.Unmount(mountpoint) d.ctr.Decrement(mountpoint) - return "", fmt.Errorf("error modifying zfs mountpoint (%s) directory ownership: %v", mountpoint, err) + return nil, fmt.Errorf("error modifying zfs mountpoint (%s) directory ownership: %v", mountpoint, err) } - return mountpoint, nil + return containerfs.NewLocalContainerFS(mountpoint), nil } // Put removes the existing mountpoint for the given id if it exists. @@ -416,5 +417,5 @@ func (d *Driver) Put(id string) error { func (d *Driver) Exists(id string) bool { d.Lock() defer d.Unlock() - return d.filesystemsCache[d.zfsPath(id)] == true + return d.filesystemsCache[d.zfsPath(id)] } diff --git a/vendor/github.com/docker/docker/daemon/health.go b/vendor/github.com/docker/docker/daemon/health.go index c8e84a2d1..7d8c84a39 100644 --- a/vendor/github.com/docker/docker/daemon/health.go +++ b/vendor/github.com/docker/docker/daemon/health.go @@ -45,8 +45,7 @@ const ( const ( // Exit status codes that can be returned by the probe command. - exitStatusHealthy = 0 // Container is healthy - exitStatusUnhealthy = 1 // Container is unhealthy + exitStatusHealthy = 0 // Container is healthy ) // probe implementations know how to run a particular type of probe. @@ -101,7 +100,7 @@ func (p *cmdProbe) run(ctx context.Context, d *Daemon, cntr *container.Container return nil, err } if info.ExitCode == nil { - return nil, fmt.Errorf("Healthcheck for container %s has no exit code!", cntr.ID) + return nil, fmt.Errorf("healthcheck for container %s has no exit code", cntr.ID) } // Note: Go's json package will handle invalid UTF-8 for us out := output.String() diff --git a/vendor/github.com/docker/docker/daemon/image.go b/vendor/github.com/docker/docker/daemon/image.go index a51049dbb..23670c4e0 100644 --- a/vendor/github.com/docker/docker/daemon/image.go +++ b/vendor/github.com/docker/docker/daemon/image.go @@ -2,18 +2,19 @@ package daemon import ( "fmt" + "runtime" "github.com/docker/distribution/reference" "github.com/docker/docker/image" "github.com/docker/docker/pkg/stringid" ) -// ErrImageDoesNotExist is error returned when no image can be found for a reference. -type ErrImageDoesNotExist struct { +// errImageDoesNotExist is error returned when no image can be found for a reference. +type errImageDoesNotExist struct { ref reference.Reference } -func (e ErrImageDoesNotExist) Error() string { +func (e errImageDoesNotExist) Error() string { ref := e.ref if named, ok := ref.(reference.Named); ok { ref = reference.TagNameOnly(named) @@ -21,18 +22,20 @@ func (e ErrImageDoesNotExist) Error() string { return fmt.Sprintf("No such image: %s", reference.FamiliarString(ref)) } +func (e errImageDoesNotExist) NotFound() {} + // GetImageIDAndPlatform returns an image ID and platform corresponding to the image referred to by // refOrID. func (daemon *Daemon) GetImageIDAndPlatform(refOrID string) (image.ID, string, error) { ref, err := reference.ParseAnyReference(refOrID) if err != nil { - return "", "", err + return "", "", validationError{err} } namedRef, ok := ref.(reference.Named) if !ok { digested, ok := ref.(reference.Digested) if !ok { - return "", "", ErrImageDoesNotExist{ref} + return "", "", errImageDoesNotExist{ref} } id := image.IDFromDigest(digested.Digest()) for platform := range daemon.stores { @@ -40,13 +43,20 @@ func (daemon *Daemon) GetImageIDAndPlatform(refOrID string) (image.ID, string, e return id, platform, nil } } - return "", "", ErrImageDoesNotExist{ref} + return "", "", errImageDoesNotExist{ref} } - for platform := range daemon.stores { - if id, err := daemon.stores[platform].referenceStore.Get(namedRef); err == nil { - return image.IDFromDigest(id), platform, nil + if digest, err := daemon.referenceStore.Get(namedRef); err == nil { + // Search the image stores to get the platform, defaulting to host OS. + imagePlatform := runtime.GOOS + id := image.IDFromDigest(digest) + for platform := range daemon.stores { + if img, err := daemon.stores[platform].imageStore.Get(id); err == nil { + imagePlatform = img.Platform() + break + } } + return id, imagePlatform, nil } // deprecated: repo:shortid https://github.com/docker/docker/pull/799 @@ -54,7 +64,7 @@ func (daemon *Daemon) GetImageIDAndPlatform(refOrID string) (image.ID, string, e if tag := tagged.Tag(); stringid.IsShortID(stringid.TruncateID(tag)) { for platform := range daemon.stores { if id, err := daemon.stores[platform].imageStore.Search(tag); err == nil { - for _, storeRef := range daemon.stores[platform].referenceStore.References(id.Digest()) { + for _, storeRef := range daemon.referenceStore.References(id.Digest()) { if storeRef.Name() == namedRef.Name() { return id, platform, nil } @@ -71,7 +81,7 @@ func (daemon *Daemon) GetImageIDAndPlatform(refOrID string) (image.ID, string, e } } - return "", "", ErrImageDoesNotExist{ref} + return "", "", errImageDoesNotExist{ref} } // GetImage returns an image corresponding to the image referred to by refOrID. diff --git a/vendor/github.com/docker/docker/daemon/image_delete.go b/vendor/github.com/docker/docker/daemon/image_delete.go index 4e228594b..987392481 100644 --- a/vendor/github.com/docker/docker/daemon/image_delete.go +++ b/vendor/github.com/docker/docker/daemon/image_delete.go @@ -6,11 +6,11 @@ import ( "time" "github.com/docker/distribution/reference" - "github.com/docker/docker/api/errors" "github.com/docker/docker/api/types" "github.com/docker/docker/container" "github.com/docker/docker/image" "github.com/docker/docker/pkg/stringid" + "github.com/pkg/errors" ) type conflictType int @@ -67,10 +67,10 @@ func (daemon *Daemon) ImageDelete(imageRef string, force, prune bool) ([]types.I imgID, platform, err := daemon.GetImageIDAndPlatform(imageRef) if err != nil { - return nil, daemon.imageNotExistToErrcode(err) + return nil, err } - repoRefs := daemon.stores[platform].referenceStore.References(imgID.Digest()) + repoRefs := daemon.referenceStore.References(imgID.Digest()) var removedRepositoryRef bool if !isImageIDPrefix(imgID.String(), imageRef) { @@ -84,8 +84,8 @@ func (daemon *Daemon) ImageDelete(imageRef string, force, prune bool) ([]types.I // this image would remain "dangling" and since // we really want to avoid that the client must // explicitly force its removal. - err := fmt.Errorf("conflict: unable to remove repository reference %q (must force) - container %s is using its referenced image %s", imageRef, stringid.TruncateID(container.ID), stringid.TruncateID(imgID.String())) - return nil, errors.NewRequestConflictError(err) + err := errors.Errorf("conflict: unable to remove repository reference %q (must force) - container %s is using its referenced image %s", imageRef, stringid.TruncateID(container.ID), stringid.TruncateID(imgID.String())) + return nil, stateConflictError{err} } } @@ -104,7 +104,7 @@ func (daemon *Daemon) ImageDelete(imageRef string, force, prune bool) ([]types.I daemon.LogImageEvent(imgID.String(), imgID.String(), "untag") records = append(records, untaggedRecord) - repoRefs = daemon.stores[platform].referenceStore.References(imgID.Digest()) + repoRefs = daemon.referenceStore.References(imgID.Digest()) // If a tag reference was removed and the only remaining // references to the same repository are digest references, @@ -237,7 +237,7 @@ func (daemon *Daemon) removeImageRef(platform string, ref reference.Named) (refe // Ignore the boolean value returned, as far as we're concerned, this // is an idempotent operation and it's okay if the reference didn't // exist in the first place. - _, err := daemon.stores[platform].referenceStore.Delete(ref) + _, err := daemon.referenceStore.Delete(ref) return ref, err } @@ -248,7 +248,7 @@ func (daemon *Daemon) removeImageRef(platform string, ref reference.Named) (refe // daemon's event service. An "Untagged" types.ImageDeleteResponseItem is added to the // given list of records. func (daemon *Daemon) removeAllReferencesToImageID(imgID image.ID, platform string, records *[]types.ImageDeleteResponseItem) error { - imageRefs := daemon.stores[platform].referenceStore.References(imgID.Digest()) + imageRefs := daemon.referenceStore.References(imgID.Digest()) for _, imageRef := range imageRefs { parsedRef, err := daemon.removeImageRef(platform, imageRef) @@ -285,6 +285,8 @@ func (idc *imageDeleteConflict) Error() string { return fmt.Sprintf("conflict: unable to delete %s (%s) - %s", stringid.TruncateID(idc.imgID.String()), forceMsg, idc.message) } +func (idc *imageDeleteConflict) Conflict() {} + // imageDeleteHelper attempts to delete the given image from this daemon. If // the image has any hard delete conflicts (child images or running containers // using the image) then it cannot be deleted. If the image has any soft delete @@ -381,7 +383,7 @@ func (daemon *Daemon) checkImageDeleteConflict(imgID image.ID, platform string, } // Check if any repository tags/digest reference this image. - if mask&conflictActiveReference != 0 && len(daemon.stores[platform].referenceStore.References(imgID.Digest())) > 0 { + if mask&conflictActiveReference != 0 && len(daemon.referenceStore.References(imgID.Digest())) > 0 { return &imageDeleteConflict{ imgID: imgID, message: "image is referenced in multiple repositories", @@ -409,5 +411,5 @@ func (daemon *Daemon) checkImageDeleteConflict(imgID image.ID, platform string, // that there are no repository references to the given image and it has no // child images. func (daemon *Daemon) imageIsDangling(imgID image.ID, platform string) bool { - return !(len(daemon.stores[platform].referenceStore.References(imgID.Digest())) > 0 || len(daemon.stores[platform].imageStore.Children(imgID)) > 0) + return !(len(daemon.referenceStore.References(imgID.Digest())) > 0 || len(daemon.stores[platform].imageStore.Children(imgID)) > 0) } diff --git a/vendor/github.com/docker/docker/daemon/image_exporter.go b/vendor/github.com/docker/docker/daemon/image_exporter.go index a7b0be64c..ce9aa7a05 100644 --- a/vendor/github.com/docker/docker/daemon/image_exporter.go +++ b/vendor/github.com/docker/docker/daemon/image_exporter.go @@ -19,7 +19,7 @@ func (daemon *Daemon) ExportImage(names []string, outStream io.Writer) error { if system.LCOWSupported() { platform = "linux" } - imageExporter := tarexport.NewTarExporter(daemon.stores[platform].imageStore, daemon.stores[platform].layerStore, daemon.stores[platform].referenceStore, daemon) + imageExporter := tarexport.NewTarExporter(daemon.stores[platform].imageStore, daemon.stores[platform].layerStore, daemon.referenceStore, daemon) return imageExporter.Save(names, outStream) } @@ -32,6 +32,6 @@ func (daemon *Daemon) LoadImage(inTar io.ReadCloser, outStream io.Writer, quiet if system.LCOWSupported() { platform = "linux" } - imageExporter := tarexport.NewTarExporter(daemon.stores[platform].imageStore, daemon.stores[platform].layerStore, daemon.stores[platform].referenceStore, daemon) + imageExporter := tarexport.NewTarExporter(daemon.stores[platform].imageStore, daemon.stores[platform].layerStore, daemon.referenceStore, daemon) return imageExporter.Load(inTar, outStream, quiet) } diff --git a/vendor/github.com/docker/docker/daemon/image_history.go b/vendor/github.com/docker/docker/daemon/image_history.go index c9e81554e..e7dd85cba 100644 --- a/vendor/github.com/docker/docker/daemon/image_history.go +++ b/vendor/github.com/docker/docker/daemon/image_history.go @@ -69,7 +69,7 @@ func (daemon *Daemon) ImageHistory(name string) ([]*image.HistoryResponseItem, e h.ID = id.String() var tags []string - for _, r := range daemon.stores[platform].referenceStore.References(id.Digest()) { + for _, r := range daemon.referenceStore.References(id.Digest()) { if _, ok := r.(reference.NamedTagged); ok { tags = append(tags, reference.FamiliarString(r)) } diff --git a/vendor/github.com/docker/docker/daemon/image_inspect.go b/vendor/github.com/docker/docker/daemon/image_inspect.go index 3baf265da..fefb93c6e 100644 --- a/vendor/github.com/docker/docker/daemon/image_inspect.go +++ b/vendor/github.com/docker/docker/daemon/image_inspect.go @@ -24,7 +24,7 @@ func (daemon *Daemon) LookupImage(name string) (*types.ImageInspect, error) { platform = runtime.GOOS } - refs := daemon.stores[platform].referenceStore.References(img.ID().Digest()) + refs := daemon.referenceStore.References(img.ID().Digest()) repoTags := []string{} repoDigests := []string{} for _, ref := range refs { diff --git a/vendor/github.com/docker/docker/daemon/image_pull.go b/vendor/github.com/docker/docker/daemon/image_pull.go index abc81ec67..aef1876ba 100644 --- a/vendor/github.com/docker/docker/daemon/image_pull.go +++ b/vendor/github.com/docker/docker/daemon/image_pull.go @@ -26,7 +26,7 @@ func (daemon *Daemon) PullImage(ctx context.Context, image, tag, platform string ref, err := reference.ParseNormalizedNamed(image) if err != nil { - return err + return validationError{err} } if tag != "" { @@ -39,7 +39,7 @@ func (daemon *Daemon) PullImage(ctx context.Context, image, tag, platform string ref, err = reference.WithTag(ref, tag) } if err != nil { - return err + return validationError{err} } } @@ -74,7 +74,7 @@ func (daemon *Daemon) pullImageWithReference(ctx context.Context, ref reference. ImageEventLogger: daemon.LogImageEvent, MetadataStore: daemon.stores[platform].distributionMetadataStore, ImageStore: distribution.NewImageConfigStoreFromStore(daemon.stores[platform].imageStore), - ReferenceStore: daemon.stores[platform].referenceStore, + ReferenceStore: daemon.referenceStore, }, DownloadManager: daemon.downloadManager, Schema2Types: distribution.ImageTypes, @@ -96,7 +96,7 @@ func (daemon *Daemon) GetRepository(ctx context.Context, ref reference.Named, au } // makes sure name is not empty or `scratch` if err := distribution.ValidateRepoName(repoInfo.Name); err != nil { - return nil, false, err + return nil, false, validationError{err} } // get endpoints diff --git a/vendor/github.com/docker/docker/daemon/image_push.go b/vendor/github.com/docker/docker/daemon/image_push.go index c2e5967b1..b55807337 100644 --- a/vendor/github.com/docker/docker/daemon/image_push.go +++ b/vendor/github.com/docker/docker/daemon/image_push.go @@ -56,7 +56,7 @@ func (daemon *Daemon) PushImage(ctx context.Context, image, tag string, metaHead ImageEventLogger: daemon.LogImageEvent, MetadataStore: daemon.stores[platform].distributionMetadataStore, ImageStore: distribution.NewImageConfigStoreFromStore(daemon.stores[platform].imageStore), - ReferenceStore: daemon.stores[platform].referenceStore, + ReferenceStore: daemon.referenceStore, }, ConfigMediaType: schema2.MediaTypeImageConfig, LayerStore: distribution.NewLayerProviderFromStore(daemon.stores[platform].layerStore), diff --git a/vendor/github.com/docker/docker/daemon/image_tag.go b/vendor/github.com/docker/docker/daemon/image_tag.go index 5f28daed0..0c1d761c8 100644 --- a/vendor/github.com/docker/docker/daemon/image_tag.go +++ b/vendor/github.com/docker/docker/daemon/image_tag.go @@ -28,7 +28,7 @@ func (daemon *Daemon) TagImage(imageName, repository, tag string) error { // TagImageWithReference adds the given reference to the image ID provided. func (daemon *Daemon) TagImageWithReference(imageID image.ID, platform string, newTag reference.Named) error { - if err := daemon.stores[platform].referenceStore.AddTag(newTag, imageID.Digest(), true); err != nil { + if err := daemon.referenceStore.AddTag(newTag, imageID.Digest(), true); err != nil { return err } diff --git a/vendor/github.com/docker/docker/daemon/images.go b/vendor/github.com/docker/docker/daemon/images.go index 4baf70371..f4110ce78 100644 --- a/vendor/github.com/docker/docker/daemon/images.go +++ b/vendor/github.com/docker/docker/daemon/images.go @@ -71,7 +71,7 @@ func (daemon *Daemon) Images(imageFilters filters.Args, all bool, withExtraAttrs if imageFilters.ExactMatch("dangling", "true") { danglingOnly = true } else if !imageFilters.ExactMatch("dangling", "false") { - return nil, fmt.Errorf("Invalid filter 'dangling=%s'", imageFilters.Get("dangling")) + return nil, invalidFilter{"dangling", imageFilters.Get("dangling")} } } if danglingOnly { @@ -149,7 +149,7 @@ func (daemon *Daemon) Images(imageFilters filters.Args, all bool, withExtraAttrs newImage := newImage(img, size) - for _, ref := range daemon.stores[platform].referenceStore.References(id.Digest()) { + for _, ref := range daemon.referenceStore.References(id.Digest()) { if imageFilters.Include("reference") { var found bool var matchErr error @@ -301,12 +301,10 @@ func (daemon *Daemon) SquashImage(id, parent string) (string, error) { } defer daemon.stores[img.Platform()].layerStore.Release(newL) - var newImage image.Image - newImage = *img + newImage := *img newImage.RootFS = nil - var rootFS image.RootFS - rootFS = *parentImg.RootFS + rootFS := *parentImg.RootFS rootFS.DiffIDs = append(rootFS.DiffIDs, newL.DiffID()) newImage.RootFS = &rootFS diff --git a/vendor/github.com/docker/docker/daemon/import.go b/vendor/github.com/docker/docker/daemon/import.go index 0409cd6bd..e58d912de 100644 --- a/vendor/github.com/docker/docker/daemon/import.go +++ b/vendor/github.com/docker/docker/daemon/import.go @@ -42,16 +42,16 @@ func (daemon *Daemon) ImportImage(src string, repository, platform string, tag s var err error newRef, err = reference.ParseNormalizedNamed(repository) if err != nil { - return err + return validationError{err} } if _, isCanonical := newRef.(reference.Canonical); isCanonical { - return errors.New("cannot import digest reference") + return validationError{errors.New("cannot import digest reference")} } if tag != "" { newRef, err = reference.WithTag(newRef, tag) if err != nil { - return err + return validationError{err} } } } @@ -69,7 +69,7 @@ func (daemon *Daemon) ImportImage(src string, repository, platform string, tag s } u, err := url.Parse(src) if err != nil { - return err + return validationError{err} } resp, err = remotecontext.GetWithStatusError(u.String()) diff --git a/vendor/github.com/docker/docker/daemon/info.go b/vendor/github.com/docker/docker/daemon/info.go index 1c4aa561b..b14e7ba80 100644 --- a/vendor/github.com/docker/docker/daemon/info.go +++ b/vendor/github.com/docker/docker/daemon/info.go @@ -97,10 +97,10 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) { drivers = strings.TrimSpace(drivers) v := &types.Info{ ID: daemon.ID, - Containers: int(cRunning + cPaused + cStopped), - ContainersRunning: int(cRunning), - ContainersPaused: int(cPaused), - ContainersStopped: int(cStopped), + Containers: cRunning + cPaused + cStopped, + ContainersRunning: cRunning, + ContainersPaused: cPaused, + ContainersStopped: cStopped, Images: imageCount, Driver: drivers, DriverStatus: daemon.stores[p].layerStore.DriverStatus(), diff --git a/vendor/github.com/docker/docker/daemon/initlayer/setup_solaris.go b/vendor/github.com/docker/docker/daemon/initlayer/setup_solaris.go index 66d53f0ee..57bc116b4 100644 --- a/vendor/github.com/docker/docker/daemon/initlayer/setup_solaris.go +++ b/vendor/github.com/docker/docker/daemon/initlayer/setup_solaris.go @@ -2,12 +2,14 @@ package initlayer +import "github.com/docker/docker/pkg/containerfs" + // Setup populates a directory with mountpoints suitable // for bind-mounting dockerinit into the container. The mountpoint is simply an // empty file at /.dockerinit // // This extra layer is used by all containers as the top-most ro layer. It protects // the container from unwanted side-effects on the rw layer. -func Setup(initLayer string, rootUID, rootGID int) error { +func Setup(initLayer containerfs.ContainerFS, rootUID, rootGID int) error { return nil } diff --git a/vendor/github.com/docker/docker/daemon/initlayer/setup_unix.go b/vendor/github.com/docker/docker/daemon/initlayer/setup_unix.go index e26d3a05f..a02cea6f3 100644 --- a/vendor/github.com/docker/docker/daemon/initlayer/setup_unix.go +++ b/vendor/github.com/docker/docker/daemon/initlayer/setup_unix.go @@ -7,6 +7,7 @@ import ( "path/filepath" "strings" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "golang.org/x/sys/unix" ) @@ -16,7 +17,10 @@ import ( // // This extra layer is used by all containers as the top-most ro layer. It protects // the container from unwanted side-effects on the rw layer. -func Setup(initLayer string, rootIDs idtools.IDPair) error { +func Setup(initLayerFs containerfs.ContainerFS, rootIDs idtools.IDPair) error { + // Since all paths are local to the container, we can just extract initLayerFs.Path() + initLayer := initLayerFs.Path() + for pth, typ := range map[string]string{ "/dev/pts": "dir", "/dev/shm": "dir", diff --git a/vendor/github.com/docker/docker/daemon/initlayer/setup_windows.go b/vendor/github.com/docker/docker/daemon/initlayer/setup_windows.go index 2b22f58b5..b47563ebf 100644 --- a/vendor/github.com/docker/docker/daemon/initlayer/setup_windows.go +++ b/vendor/github.com/docker/docker/daemon/initlayer/setup_windows.go @@ -3,6 +3,7 @@ package initlayer import ( + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" ) @@ -12,6 +13,6 @@ import ( // // This extra layer is used by all containers as the top-most ro layer. It protects // the container from unwanted side-effects on the rw layer. -func Setup(initLayer string, rootIDs idtools.IDPair) error { +func Setup(initLayer containerfs.ContainerFS, rootIDs idtools.IDPair) error { return nil } diff --git a/vendor/github.com/docker/docker/daemon/inspect.go b/vendor/github.com/docker/docker/daemon/inspect.go index fcdeb81ab..98f291c52 100644 --- a/vendor/github.com/docker/docker/daemon/inspect.go +++ b/vendor/github.com/docker/docker/daemon/inspect.go @@ -11,6 +11,7 @@ import ( "github.com/docker/docker/api/types/versions/v1p20" "github.com/docker/docker/container" "github.com/docker/docker/daemon/network" + volumestore "github.com/docker/docker/volume/store" "github.com/docker/go-connections/nat" ) @@ -187,7 +188,7 @@ func (daemon *Daemon) getInspectData(container *container.Container) (*types.Con // could have been removed, it will cause error if we try to get the metadata, // we can ignore the error if the container is dead. if err != nil && !container.Dead { - return nil, err + return nil, systemError{err} } contJSONBase.GraphDriver.Data = graphDriverData @@ -228,7 +229,10 @@ func (daemon *Daemon) ContainerExecInspect(id string) (*backend.ExecInspect, err func (daemon *Daemon) VolumeInspect(name string) (*types.Volume, error) { v, err := daemon.volumes.Get(name) if err != nil { - return nil, err + if volumestore.IsNotExist(err) { + return nil, volumeNotFound(name) + } + return nil, systemError{err} } apiV := volumeToAPIType(v) apiV.Mountpoint = v.Path() diff --git a/vendor/github.com/docker/docker/daemon/kill.go b/vendor/github.com/docker/docker/daemon/kill.go index 586c9661f..bb3e87cae 100644 --- a/vendor/github.com/docker/docker/daemon/kill.go +++ b/vendor/github.com/docker/docker/daemon/kill.go @@ -10,6 +10,7 @@ import ( containerpkg "github.com/docker/docker/container" "github.com/docker/docker/pkg/signal" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -22,6 +23,8 @@ func (e errNoSuchProcess) Error() string { return fmt.Sprintf("Cannot kill process (pid=%d) with signal %d: no such process.", e.pid, e.signal) } +func (errNoSuchProcess) NotFound() {} + // isErrNoSuchProcess returns true if the error // is an instance of errNoSuchProcess. func isErrNoSuchProcess(err error) bool { @@ -61,7 +64,7 @@ func (daemon *Daemon) killWithSignal(container *containerpkg.Container, sig int) defer container.Unlock() if !container.Running { - return errNotRunning{container.ID} + return errNotRunning(container.ID) } var unpause bool @@ -91,8 +94,9 @@ func (daemon *Daemon) killWithSignal(container *containerpkg.Container, sig int) } if err := daemon.kill(container, sig); err != nil { - err = fmt.Errorf("Cannot kill container %s: %s", container.ID, err) + err = errors.Wrapf(err, "Cannot kill container %s", container.ID) // if container or process not exists, ignore the error + // TODO: we shouldn't have to parse error strings from containerd if strings.Contains(err.Error(), "container not found") || strings.Contains(err.Error(), "no such process") { logrus.Warnf("container kill failed because of 'container not found' or 'no such process': %s", err.Error()) @@ -119,7 +123,7 @@ func (daemon *Daemon) killWithSignal(container *containerpkg.Container, sig int) // Kill forcefully terminates a container. func (daemon *Daemon) Kill(container *containerpkg.Container) error { if !container.IsRunning() { - return errNotRunning{container.ID} + return errNotRunning(container.ID) } // 1. Send SIGKILL @@ -156,7 +160,7 @@ func (daemon *Daemon) Kill(container *containerpkg.Container) error { // Wait for exit with no timeout. // Ignore returned status. - _ = <-container.Wait(context.Background(), containerpkg.WaitConditionNotRunning) + <-container.Wait(context.Background(), containerpkg.WaitConditionNotRunning) return nil } diff --git a/vendor/github.com/docker/docker/daemon/links.go b/vendor/github.com/docker/docker/daemon/links.go index 7f691d4f1..219a50276 100644 --- a/vendor/github.com/docker/docker/daemon/links.go +++ b/vendor/github.com/docker/docker/daemon/links.go @@ -76,12 +76,16 @@ func (l *linkIndex) parents(child *container.Container) map[string]*container.Co } // delete deletes all link relationships referencing this container -func (l *linkIndex) delete(container *container.Container) { +func (l *linkIndex) delete(container *container.Container) []string { l.mu.Lock() - for _, child := range l.idx[container] { + + var aliases []string + for alias, child := range l.idx[container] { + aliases = append(aliases, alias) delete(l.childIdx[child], container) } delete(l.idx, container) delete(l.childIdx, container) l.mu.Unlock() + return aliases } diff --git a/vendor/github.com/docker/docker/daemon/list.go b/vendor/github.com/docker/docker/daemon/list.go index 5906ed3a6..b171ffb1b 100644 --- a/vendor/github.com/docker/docker/daemon/list.go +++ b/vendor/github.com/docker/docker/daemon/list.go @@ -1,7 +1,6 @@ package daemon import ( - "errors" "fmt" "sort" "strconv" @@ -13,6 +12,7 @@ import ( "github.com/docker/docker/image" "github.com/docker/docker/volume" "github.com/docker/go-connections/nat" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -265,7 +265,7 @@ func (daemon *Daemon) foldFilter(view container.View, config *types.ContainerLis err = psFilters.WalkValues("status", func(value string) error { if !container.IsValidStateString(value) { - return fmt.Errorf("Unrecognised filter value for status: %s", value) + return invalidFilter{"status", value} } config.All = true @@ -284,13 +284,13 @@ func (daemon *Daemon) foldFilter(view container.View, config *types.ContainerLis taskFilter = true isTask = false } else { - return nil, fmt.Errorf("Invalid filter 'is-task=%s'", psFilters.Get("is-task")) + return nil, invalidFilter{"is-task", psFilters.Get("is-task")} } } err = psFilters.WalkValues("health", func(value string) error { if !container.IsValidHealthString(value) { - return fmt.Errorf("Unrecognised filter value for health: %s", value) + return validationError{errors.Errorf("Unrecognised filter value for health: %s", value)} } return nil @@ -567,7 +567,7 @@ func (daemon *Daemon) refreshImage(s *container.Snapshot, ctx *listContext) (*ty image := s.Image // keep the original ref if still valid (hasn't changed) if image != s.ImageID { id, _, err := daemon.GetImageIDAndPlatform(image) - if _, isDNE := err.(ErrImageDoesNotExist); err != nil && !isDNE { + if _, isDNE := err.(errImageDoesNotExist); err != nil && !isDNE { return nil, err } if err != nil || id.String() != s.ImageID { @@ -653,7 +653,7 @@ func (daemon *Daemon) filterVolumes(vols []volume.Volume, filter filters.Args) ( if filter.ExactMatch("dangling", "true") || filter.ExactMatch("dangling", "1") { danglingOnly = true } else if !filter.ExactMatch("dangling", "false") && !filter.ExactMatch("dangling", "0") { - return nil, fmt.Errorf("Invalid filter 'dangling=%s'", filter.Get("dangling")) + return nil, invalidFilter{"dangling", filter.Get("dangling")} } retVols = daemon.volumes.FilterByUsed(retVols, !danglingOnly) } diff --git a/vendor/github.com/docker/docker/pkg/listeners/group_unix.go b/vendor/github.com/docker/docker/daemon/listeners/group_unix.go similarity index 100% rename from vendor/github.com/docker/docker/pkg/listeners/group_unix.go rename to vendor/github.com/docker/docker/daemon/listeners/group_unix.go diff --git a/vendor/github.com/docker/docker/pkg/listeners/listeners_solaris.go b/vendor/github.com/docker/docker/daemon/listeners/listeners_solaris.go similarity index 100% rename from vendor/github.com/docker/docker/pkg/listeners/listeners_solaris.go rename to vendor/github.com/docker/docker/daemon/listeners/listeners_solaris.go diff --git a/vendor/github.com/docker/docker/pkg/listeners/listeners_unix.go b/vendor/github.com/docker/docker/daemon/listeners/listeners_unix.go similarity index 98% rename from vendor/github.com/docker/docker/pkg/listeners/listeners_unix.go rename to vendor/github.com/docker/docker/daemon/listeners/listeners_unix.go index dc5460689..0a4e5e4e3 100644 --- a/vendor/github.com/docker/docker/pkg/listeners/listeners_unix.go +++ b/vendor/github.com/docker/docker/daemon/listeners/listeners_unix.go @@ -86,7 +86,7 @@ func listenFD(addr string, tlsConfig *tls.Config) ([]net.Listener, error) { return nil, fmt.Errorf("failed to parse systemd fd address: should be a number: %v", addr) } fdOffset := fdNum - 3 - if len(listeners) < int(fdOffset)+1 { + if len(listeners) < fdOffset+1 { return nil, fmt.Errorf("too few socket activated files passed in by systemd") } if listeners[fdOffset] == nil { diff --git a/vendor/github.com/docker/docker/pkg/listeners/listeners_windows.go b/vendor/github.com/docker/docker/daemon/listeners/listeners_windows.go similarity index 100% rename from vendor/github.com/docker/docker/pkg/listeners/listeners_windows.go rename to vendor/github.com/docker/docker/daemon/listeners/listeners_windows.go diff --git a/vendor/github.com/docker/docker/daemon/logger/awslogs/cloudwatchlogs.go b/vendor/github.com/docker/docker/daemon/logger/awslogs/cloudwatchlogs.go index cabfcbd8d..3a7f2f631 100644 --- a/vendor/github.com/docker/docker/daemon/logger/awslogs/cloudwatchlogs.go +++ b/vendor/github.com/docker/docker/daemon/logger/awslogs/cloudwatchlogs.go @@ -2,7 +2,6 @@ package awslogs import ( - "bytes" "fmt" "os" "regexp" @@ -22,7 +21,6 @@ import ( "github.com/docker/docker/daemon/logger" "github.com/docker/docker/daemon/logger/loggerutils" "github.com/docker/docker/dockerversion" - "github.com/docker/docker/pkg/templates" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -194,19 +192,6 @@ var strftimeToRegex = map[string]string{ /*milliseconds */ `%L`: `\.\d{3}`, } -func parseLogGroup(info logger.Info, groupTemplate string) (string, error) { - tmpl, err := templates.NewParse("log-group", groupTemplate) - if err != nil { - return "", err - } - buf := new(bytes.Buffer) - if err := tmpl.Execute(buf, &info); err != nil { - return "", err - } - - return buf.String(), nil -} - // newRegionFinder is a variable such that the implementation // can be swapped out for unit tests. var newRegionFinder = func() regionFinder { diff --git a/vendor/github.com/docker/docker/daemon/logger/awslogs/cloudwatchlogs_test.go b/vendor/github.com/docker/docker/daemon/logger/awslogs/cloudwatchlogs_test.go index 8688026a0..989eb6f52 100644 --- a/vendor/github.com/docker/docker/daemon/logger/awslogs/cloudwatchlogs_test.go +++ b/vendor/github.com/docker/docker/daemon/logger/awslogs/cloudwatchlogs_test.go @@ -162,7 +162,7 @@ func TestCreateError(t *testing.T) { client: mockClient, } mockClient.createLogStreamResult <- &createLogStreamResult{ - errorResult: errors.New("Error!"), + errorResult: errors.New("Error"), } err := stream.create() @@ -243,7 +243,7 @@ func TestPublishBatchError(t *testing.T) { sequenceToken: aws.String(sequenceToken), } mockClient.putLogEventsResult <- &putLogEventsResult{ - errorResult: errors.New("Error!"), + errorResult: errors.New("Error"), } events := []wrappedEvent{ diff --git a/vendor/github.com/docker/docker/daemon/logger/factory.go b/vendor/github.com/docker/docker/daemon/logger/factory.go index 32001590d..2ef3bf879 100644 --- a/vendor/github.com/docker/docker/daemon/logger/factory.go +++ b/vendor/github.com/docker/docker/daemon/logger/factory.go @@ -93,7 +93,7 @@ func (lf *logdriverFactory) getLogOptValidator(name string) LogOptValidator { lf.m.Lock() defer lf.m.Unlock() - c, _ := lf.optValidator[name] + c := lf.optValidator[name] return c } diff --git a/vendor/github.com/docker/docker/daemon/logger/jsonfilelog/read.go b/vendor/github.com/docker/docker/daemon/logger/jsonfilelog/read.go index 32425b512..25fc99a98 100644 --- a/vendor/github.com/docker/docker/daemon/logger/jsonfilelog/read.go +++ b/vendor/github.com/docker/docker/daemon/logger/jsonfilelog/read.go @@ -137,8 +137,7 @@ func newSectionReader(f *os.File) (*io.SectionReader, error) { } func tailFile(f io.ReadSeeker, logWatcher *logger.LogWatcher, tail int, since time.Time) { - var rdr io.Reader - rdr = f + rdr := io.Reader(f) if tail > 0 { ls, err := tailfile.TailFile(f, tail) if err != nil { diff --git a/vendor/github.com/docker/docker/daemon/logger/logentries/logentries.go b/vendor/github.com/docker/docker/daemon/logger/logentries/logentries.go index 7f6ff471d..e28707c74 100644 --- a/vendor/github.com/docker/docker/daemon/logger/logentries/logentries.go +++ b/vendor/github.com/docker/docker/daemon/logger/logentries/logentries.go @@ -4,9 +4,11 @@ package logentries import ( "fmt" + "strconv" "github.com/bsphere/le_go" "github.com/docker/docker/daemon/logger" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -16,11 +18,13 @@ type logentries struct { containerName string writer *le_go.Logger extra map[string]string + lineOnly bool } const ( - name = "logentries" - token = "logentries-token" + name = "logentries" + token = "logentries-token" + lineonly = "line-only" ) func init() { @@ -38,32 +42,44 @@ func init() { func New(info logger.Info) (logger.Logger, error) { logrus.WithField("container", info.ContainerID). WithField("token", info.Config[token]). + WithField("line-only", info.Config[lineonly]). Debug("logging driver logentries configured") log, err := le_go.Connect(info.Config[token]) if err != nil { - return nil, err + return nil, errors.Wrap(err, "error connecting to logentries") + } + var lineOnly bool + if lineOnly, err = strconv.ParseBool(info.Config[lineonly]); err != nil { + return nil, errors.Wrap(err, "error parsing lineonly option") } return &logentries{ containerID: info.ContainerID, containerName: info.ContainerName, writer: log, + lineOnly: lineOnly, }, nil } func (f *logentries) Log(msg *logger.Message) error { - data := map[string]string{ - "container_id": f.containerID, - "container_name": f.containerName, - "source": msg.Source, - "log": string(msg.Line), - } - for k, v := range f.extra { - data[k] = v + if !f.lineOnly { + data := map[string]string{ + "container_id": f.containerID, + "container_name": f.containerName, + "source": msg.Source, + "log": string(msg.Line), + } + for k, v := range f.extra { + data[k] = v + } + ts := msg.Timestamp + logger.PutMessage(msg) + f.writer.Println(f.tag, ts, data) + } else { + line := msg.Line + logger.PutMessage(msg) + f.writer.Println(line) } - ts := msg.Timestamp - logger.PutMessage(msg) - f.writer.Println(f.tag, ts, data) return nil } diff --git a/vendor/github.com/docker/docker/daemon/logger/logger.go b/vendor/github.com/docker/docker/daemon/logger/logger.go index 258a5dc5f..a9d1e7640 100644 --- a/vendor/github.com/docker/docker/daemon/logger/logger.go +++ b/vendor/github.com/docker/docker/daemon/logger/logger.go @@ -8,7 +8,6 @@ package logger import ( - "errors" "sync" "time" @@ -16,8 +15,15 @@ import ( "github.com/docker/docker/pkg/jsonlog" ) -// ErrReadLogsNotSupported is returned when the logger does not support reading logs. -var ErrReadLogsNotSupported = errors.New("configured logging driver does not support reading") +// ErrReadLogsNotSupported is returned when the underlying log driver does not support reading +type ErrReadLogsNotSupported struct{} + +func (ErrReadLogsNotSupported) Error() string { + return "configured logging driver does not support reading" +} + +// NotImplemented makes this error implement the `NotImplemented` interface from api/errdefs +func (ErrReadLogsNotSupported) NotImplemented() {} const ( // TimeFormat is the time format used for timestamps sent to log readers. diff --git a/vendor/github.com/docker/docker/daemon/logger/loggerutils/log_tag.go b/vendor/github.com/docker/docker/daemon/logger/loggerutils/log_tag.go index f801047c4..7c170909a 100644 --- a/vendor/github.com/docker/docker/daemon/logger/loggerutils/log_tag.go +++ b/vendor/github.com/docker/docker/daemon/logger/loggerutils/log_tag.go @@ -4,7 +4,7 @@ import ( "bytes" "github.com/docker/docker/daemon/logger" - "github.com/docker/docker/pkg/templates" + "github.com/docker/docker/daemon/logger/templates" ) // DefaultTemplate defines the defaults template logger should use. diff --git a/vendor/github.com/docker/docker/daemon/logger/ring.go b/vendor/github.com/docker/docker/daemon/logger/ring.go index dea8f6b6a..c89897cfd 100644 --- a/vendor/github.com/docker/docker/daemon/logger/ring.go +++ b/vendor/github.com/docker/docker/daemon/logger/ring.go @@ -202,7 +202,6 @@ func (r *messageRing) Close() { r.closed = true r.wait.Broadcast() r.mu.Unlock() - return } // Drain drains all messages from the queue. diff --git a/vendor/github.com/docker/docker/daemon/logger/splunk/splunk.go b/vendor/github.com/docker/docker/daemon/logger/splunk/splunk.go index 7319a3e3d..31a048700 100644 --- a/vendor/github.com/docker/docker/daemon/logger/splunk/splunk.go +++ b/vendor/github.com/docker/docker/daemon/logger/splunk/splunk.go @@ -15,6 +15,7 @@ import ( "net/url" "os" "strconv" + "strings" "sync" "time" @@ -203,7 +204,7 @@ func New(info logger.Info) (logger.Logger, error) { } gzipCompressionLevel = int(gzipCompressionLevel64) if gzipCompressionLevel < gzip.DefaultCompression || gzipCompressionLevel > gzip.BestCompression { - err := fmt.Errorf("Not supported level '%s' for %s (supported values between %d and %d).", + err := fmt.Errorf("not supported level '%s' for %s (supported values between %d and %d)", gzipCompressionLevelStr, splunkGzipCompressionLevelKey, gzip.DefaultCompression, gzip.BestCompression) return nil, err } @@ -363,6 +364,11 @@ func (l *splunkLoggerJSON) Log(msg *logger.Message) error { } func (l *splunkLoggerRaw) Log(msg *logger.Message) error { + // empty or whitespace-only messages are not accepted by HEC + if strings.TrimSpace(string(msg.Line)) == "" { + return nil + } + message := l.createSplunkMessage(msg) message.Event = string(append(l.prefix, msg.Line...)) diff --git a/vendor/github.com/docker/docker/daemon/logger/splunk/splunk_test.go b/vendor/github.com/docker/docker/daemon/logger/splunk/splunk_test.go index cbe9a55bf..ebf835c58 100644 --- a/vendor/github.com/docker/docker/daemon/logger/splunk/splunk_test.go +++ b/vendor/github.com/docker/docker/daemon/logger/splunk/splunk_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/docker/docker/daemon/logger" + "github.com/stretchr/testify/require" ) // Validate options @@ -125,7 +126,7 @@ func TestDefault(t *testing.T) { splunkLoggerDriver.nullMessage.Source != "" || splunkLoggerDriver.nullMessage.SourceType != "" || splunkLoggerDriver.nullMessage.Index != "" || - splunkLoggerDriver.gzipCompression != false || + splunkLoggerDriver.gzipCompression || splunkLoggerDriver.postMessagesFrequency != defaultPostMessagesFrequency || splunkLoggerDriver.postMessagesBatchSize != defaultPostMessagesBatchSize || splunkLoggerDriver.bufferMaximum != defaultBufferMaximum || @@ -255,7 +256,7 @@ func TestInlineFormatWithNonDefaultOptions(t *testing.T) { splunkLoggerDriver.nullMessage.Source != "mysource" || splunkLoggerDriver.nullMessage.SourceType != "mysourcetype" || splunkLoggerDriver.nullMessage.Index != "myindex" || - splunkLoggerDriver.gzipCompression != true || + !splunkLoggerDriver.gzipCompression || splunkLoggerDriver.gzipCompressionLevel != gzip.DefaultCompression || splunkLoggerDriver.postMessagesFrequency != defaultPostMessagesFrequency || splunkLoggerDriver.postMessagesBatchSize != defaultPostMessagesBatchSize || @@ -355,7 +356,7 @@ func TestJsonFormat(t *testing.T) { splunkLoggerDriver.nullMessage.Source != "" || splunkLoggerDriver.nullMessage.SourceType != "" || splunkLoggerDriver.nullMessage.Index != "" || - splunkLoggerDriver.gzipCompression != true || + !splunkLoggerDriver.gzipCompression || splunkLoggerDriver.gzipCompressionLevel != gzip.BestSpeed || splunkLoggerDriver.postMessagesFrequency != defaultPostMessagesFrequency || splunkLoggerDriver.postMessagesBatchSize != defaultPostMessagesBatchSize || @@ -448,14 +449,10 @@ func TestRawFormat(t *testing.T) { } hostname, err := info.Hostname() - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) loggerDriver, err := New(info) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) if !hec.connectionVerified { t.Fatal("By default connection should be verified") @@ -472,7 +469,7 @@ func TestRawFormat(t *testing.T) { splunkLoggerDriver.nullMessage.Source != "" || splunkLoggerDriver.nullMessage.SourceType != "" || splunkLoggerDriver.nullMessage.Index != "" || - splunkLoggerDriver.gzipCompression != false || + splunkLoggerDriver.gzipCompression || splunkLoggerDriver.postMessagesFrequency != defaultPostMessagesFrequency || splunkLoggerDriver.postMessagesBatchSize != defaultPostMessagesBatchSize || splunkLoggerDriver.bufferMaximum != defaultBufferMaximum || @@ -586,7 +583,7 @@ func TestRawFormatWithLabels(t *testing.T) { splunkLoggerDriver.nullMessage.Source != "" || splunkLoggerDriver.nullMessage.SourceType != "" || splunkLoggerDriver.nullMessage.Index != "" || - splunkLoggerDriver.gzipCompression != false || + splunkLoggerDriver.gzipCompression || splunkLoggerDriver.postMessagesFrequency != defaultPostMessagesFrequency || splunkLoggerDriver.postMessagesBatchSize != defaultPostMessagesBatchSize || splunkLoggerDriver.bufferMaximum != defaultBufferMaximum || @@ -698,7 +695,7 @@ func TestRawFormatWithoutTag(t *testing.T) { splunkLoggerDriver.nullMessage.Source != "" || splunkLoggerDriver.nullMessage.SourceType != "" || splunkLoggerDriver.nullMessage.Index != "" || - splunkLoggerDriver.gzipCompression != false || + splunkLoggerDriver.gzipCompression || splunkLoggerDriver.postMessagesFrequency != defaultPostMessagesFrequency || splunkLoggerDriver.postMessagesBatchSize != defaultPostMessagesBatchSize || splunkLoggerDriver.bufferMaximum != defaultBufferMaximum || @@ -716,12 +713,19 @@ func TestRawFormatWithoutTag(t *testing.T) { if err := loggerDriver.Log(&logger.Message{Line: []byte("notjson"), Source: "stdout", Timestamp: message2Time}); err != nil { t.Fatal(err) } + message3Time := time.Now() + if err := loggerDriver.Log(&logger.Message{Line: []byte(" "), Source: "stdout", Timestamp: message3Time}); err != nil { + t.Fatal(err) + } err = loggerDriver.Close() if err != nil { t.Fatal(err) } + // message3 would have an empty or whitespace only string in the "event" field + // both of which are not acceptable to HEC + // thus here we must expect 2 messages, not 3 if len(hec.messages) != 2 { t.Fatal("Expected two messages") } diff --git a/vendor/github.com/docker/docker/pkg/templates/templates.go b/vendor/github.com/docker/docker/daemon/logger/templates/templates.go similarity index 65% rename from vendor/github.com/docker/docker/pkg/templates/templates.go rename to vendor/github.com/docker/docker/daemon/logger/templates/templates.go index d2d7e0c3d..f632e6e4b 100644 --- a/vendor/github.com/docker/docker/pkg/templates/templates.go +++ b/vendor/github.com/docker/docker/daemon/logger/templates/templates.go @@ -27,34 +27,6 @@ var basicFunctions = template.FuncMap{ "truncate": truncateWithLength, } -// HeaderFunctions are used to created headers of a table. -// This is a replacement of basicFunctions for header generation -// because we want the header to remain intact. -// Some functions like `split` are irrelevant so not added. -var HeaderFunctions = template.FuncMap{ - "json": func(v string) string { - return v - }, - "title": func(v string) string { - return v - }, - "lower": func(v string) string { - return v - }, - "upper": func(v string) string { - return v - }, - "truncate": func(v string, l int) string { - return v - }, -} - -// Parse creates a new anonymous template with the basic functions -// and parses the given format. -func Parse(format string) (*template.Template, error) { - return NewParse("", format) -} - // NewParse creates a new tagged template with the basic functions // and parses the given format. func NewParse(tag, format string) (*template.Template, error) { diff --git a/vendor/github.com/docker/docker/daemon/logger/templates/templates_test.go b/vendor/github.com/docker/docker/daemon/logger/templates/templates_test.go new file mode 100644 index 000000000..6205e1dc7 --- /dev/null +++ b/vendor/github.com/docker/docker/daemon/logger/templates/templates_test.go @@ -0,0 +1,18 @@ +package templates + +import ( + "bytes" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestNewParse(t *testing.T) { + tm, err := NewParse("foo", "this is a {{ . }}") + assert.NoError(t, err) + + var b bytes.Buffer + assert.NoError(t, tm.Execute(&b, "string")) + want := "this is a string" + assert.Equal(t, want, b.String()) +} diff --git a/vendor/github.com/docker/docker/daemon/logs.go b/vendor/github.com/docker/docker/daemon/logs.go index 2bd57ee53..68c5e5aa4 100644 --- a/vendor/github.com/docker/docker/daemon/logs.go +++ b/vendor/github.com/docker/docker/daemon/logs.go @@ -22,7 +22,7 @@ import ( // // if it returns nil, the config channel will be active and return log // messages until it runs out or the context is canceled. -func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, config *types.ContainerLogsOptions) (<-chan *backend.LogMessage, error) { +func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, config *types.ContainerLogsOptions) (<-chan *backend.LogMessage, bool, error) { lg := logrus.WithFields(logrus.Fields{ "module": "daemon", "method": "(*Daemon).ContainerLogs", @@ -30,24 +30,24 @@ func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, c }) if !(config.ShowStdout || config.ShowStderr) { - return nil, errors.New("You must choose at least one stream") + return nil, false, validationError{errors.New("You must choose at least one stream")} } container, err := daemon.GetContainer(containerName) if err != nil { - return nil, err + return nil, false, err } if container.RemovalInProgress || container.Dead { - return nil, errors.New("can not get logs from container which is dead or marked for removal") + return nil, false, stateConflictError{errors.New("can not get logs from container which is dead or marked for removal")} } if container.HostConfig.LogConfig.Type == "none" { - return nil, logger.ErrReadLogsNotSupported + return nil, false, logger.ErrReadLogsNotSupported{} } cLog, cLogCreated, err := daemon.getLogger(container) if err != nil { - return nil, err + return nil, false, err } if cLogCreated { defer func() { @@ -59,7 +59,7 @@ func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, c logReader, ok := cLog.(logger.LogReader) if !ok { - return nil, logger.ErrReadLogsNotSupported + return nil, false, logger.ErrReadLogsNotSupported{} } follow := config.Follow && !cLogCreated @@ -72,7 +72,7 @@ func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, c if config.Since != "" { s, n, err := timetypes.ParseTimestamps(config.Since, 0) if err != nil { - return nil, err + return nil, false, err } since = time.Unix(s, n) } @@ -137,7 +137,7 @@ func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, c } } }() - return messageChan, nil + return messageChan, container.Config.Tty, nil } func (daemon *Daemon) getLogger(container *container.Container) (l logger.Logger, created bool, err error) { diff --git a/vendor/github.com/docker/docker/daemon/metrics.go b/vendor/github.com/docker/docker/daemon/metrics.go index 0d9f37e8d..44228e7db 100644 --- a/vendor/github.com/docker/docker/daemon/metrics.go +++ b/vendor/github.com/docker/docker/daemon/metrics.go @@ -6,7 +6,7 @@ import ( "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/plugingetter" - "github.com/docker/go-metrics" + metrics "github.com/docker/go-metrics" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/sirupsen/logrus" @@ -16,7 +16,6 @@ const metricsPluginType = "MetricsCollector" var ( containerActions metrics.LabeledTimer - containerStates metrics.LabeledGauge imageActions metrics.LabeledTimer networkActions metrics.LabeledTimer engineInfo metrics.LabeledGauge @@ -170,5 +169,4 @@ func pluginStopMetricsCollection(p plugingetter.CompatPlugin) { logrus.WithError(err).WithField("name", p.Name()).WithField("socket", sockPath).Error("error unmounting metrics socket for plugin") } } - return } diff --git a/vendor/github.com/docker/docker/daemon/monitor.go b/vendor/github.com/docker/docker/daemon/monitor.go index 3fd7bffb8..3946e7aae 100644 --- a/vendor/github.com/docker/docker/daemon/monitor.go +++ b/vendor/github.com/docker/docker/daemon/monitor.go @@ -36,7 +36,7 @@ func (daemon *Daemon) StateChanged(id string, e libcontainerd.StateInfo) error { case libcontainerd.StateOOM: // StateOOM is Linux specific and should never be hit on Windows if runtime.GOOS == "windows" { - return errors.New("Received StateOOM from libcontainerd on Windows. This should never happen.") + return errors.New("received StateOOM from libcontainerd on Windows. This should never happen") } daemon.updateHealthMonitor(c) if err := c.CheckpointTo(daemon.containersReplica); err != nil { diff --git a/vendor/github.com/docker/docker/daemon/monitor_windows.go b/vendor/github.com/docker/docker/daemon/monitor_windows.go index 9648b1b41..15d656de0 100644 --- a/vendor/github.com/docker/docker/daemon/monitor_windows.go +++ b/vendor/github.com/docker/docker/daemon/monitor_windows.go @@ -22,22 +22,17 @@ func (daemon *Daemon) postRunProcessing(container *container.Container, e libcon return err } - newOpts := []libcontainerd.CreateOption{&libcontainerd.ServicingOption{ - IsServicing: true, - }} + // Turn on servicing + spec.Windows.Servicing = true copts, err := daemon.getLibcontainerdCreateOptions(container) if err != nil { return err } - if copts != nil { - newOpts = append(newOpts, copts...) - } - // Create a new servicing container, which will start, complete the update, and merge back the // results if it succeeded, all as part of the below function call. - if err := daemon.containerd.Create((container.ID + "_servicing"), "", "", *spec, container.InitializeStdio, newOpts...); err != nil { + if err := daemon.containerd.Create((container.ID + "_servicing"), "", "", *spec, container.InitializeStdio, copts...); err != nil { container.SetExitCode(-1) return fmt.Errorf("Post-run update servicing failed: %s", err) } diff --git a/vendor/github.com/docker/docker/daemon/names.go b/vendor/github.com/docker/docker/daemon/names.go index 845c4e995..712df9fd0 100644 --- a/vendor/github.com/docker/docker/daemon/names.go +++ b/vendor/github.com/docker/docker/daemon/names.go @@ -4,16 +4,17 @@ import ( "fmt" "strings" - "github.com/docker/docker/api" "github.com/docker/docker/container" + "github.com/docker/docker/daemon/names" "github.com/docker/docker/pkg/namesgenerator" "github.com/docker/docker/pkg/stringid" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) var ( - validContainerNameChars = api.RestrictedNameChars - validContainerNamePattern = api.RestrictedNamePattern + validContainerNameChars = names.RestrictedNameChars + validContainerNamePattern = names.RestrictedNamePattern ) func (daemon *Daemon) registerName(container *container.Container) error { @@ -55,7 +56,7 @@ func (daemon *Daemon) generateIDAndName(name string) (string, string, error) { func (daemon *Daemon) reserveName(id, name string) (string, error) { if !validContainerNamePattern.MatchString(strings.TrimPrefix(name, "/")) { - return "", fmt.Errorf("Invalid container name (%s), only %s are allowed", name, validContainerNameChars) + return "", validationError{errors.Errorf("Invalid container name (%s), only %s are allowed", name, validContainerNameChars)} } if name[0] != '/' { name = "/" + name @@ -68,9 +69,9 @@ func (daemon *Daemon) reserveName(id, name string) (string, error) { logrus.Errorf("got unexpected error while looking up reserved name: %v", err) return "", err } - return "", fmt.Errorf("Conflict. The container name %q is already in use by container %q. You have to remove (or rename) that container to be able to reuse that name.", name, id) + return "", validationError{errors.Errorf("Conflict. The container name %q is already in use by container %q. You have to remove (or rename) that container to be able to reuse that name.", name, id)} } - return "", fmt.Errorf("error reserving name: %q, error: %v", name, err) + return "", errors.Wrapf(err, "error reserving name: %q", name) } return name, nil } diff --git a/vendor/github.com/docker/docker/api/names.go b/vendor/github.com/docker/docker/daemon/names/names.go similarity index 96% rename from vendor/github.com/docker/docker/api/names.go rename to vendor/github.com/docker/docker/daemon/names/names.go index f147d1f4c..26f6748a8 100644 --- a/vendor/github.com/docker/docker/api/names.go +++ b/vendor/github.com/docker/docker/daemon/names/names.go @@ -1,4 +1,4 @@ -package api +package names import "regexp" diff --git a/vendor/github.com/docker/docker/daemon/network.go b/vendor/github.com/docker/docker/daemon/network.go index 22f94bcb3..92d49765c 100644 --- a/vendor/github.com/docker/docker/daemon/network.go +++ b/vendor/github.com/docker/docker/daemon/network.go @@ -8,7 +8,6 @@ import ( "strings" "sync" - apierrors "github.com/docker/docker/api/errors" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network" clustertypes "github.com/docker/docker/daemon/cluster/provider" @@ -57,10 +56,10 @@ func (daemon *Daemon) GetNetworkByID(partialID string) (libnetwork.Network, erro list := daemon.GetNetworksByID(partialID) if len(list) == 0 { - return nil, libnetwork.ErrNoSuchNetwork(partialID) + return nil, errors.WithStack(networkNotFound(partialID)) } if len(list) > 1 { - return nil, libnetwork.ErrInvalidID(partialID) + return nil, errors.WithStack(invalidIdentifier(partialID)) } return list[0], nil } @@ -116,6 +115,7 @@ var ( func (daemon *Daemon) startIngressWorker() { ingressJobsChannel = make(chan *ingressJob, 100) go func() { + // nolint: gosimple for { select { case r := <-ingressJobsChannel: @@ -182,27 +182,8 @@ func (daemon *Daemon) setupIngress(create *clustertypes.NetworkCreateRequest, ip logrus.Errorf("Failed getting ingress network by id after creating: %v", err) } - sb, err := controller.NewSandbox("ingress-sbox", libnetwork.OptionIngress()) - if err != nil { - if _, ok := err.(networktypes.ForbiddenError); !ok { - logrus.Errorf("Failed creating ingress sandbox: %v", err) - } - return - } - - ep, err := n.CreateEndpoint("ingress-endpoint", libnetwork.CreateOptionIpam(ip, nil, nil, nil)) - if err != nil { - logrus.Errorf("Failed creating ingress endpoint: %v", err) - return - } - - if err := ep.Join(sb, nil); err != nil { - logrus.Errorf("Failed joining ingress sandbox to ingress endpoint: %v", err) - return - } - - if err := sb.EnableService(); err != nil { - logrus.Errorf("Failed enabling service for ingress sandbox") + if err = daemon.createLoadBalancerSandbox("ingress", create.ID, ip, n, libnetwork.OptionIngress()); err != nil { + logrus.Errorf("Failed creating load balancer sandbox for ingress network: %v", err) } } @@ -233,7 +214,6 @@ func (daemon *Daemon) releaseIngress(id string) { logrus.Errorf("Failed to delete ingress network %s: %v", n.ID(), err) return } - return } // SetNetworkBootstrapKeys sets the bootstrap keys. @@ -284,10 +264,38 @@ func (daemon *Daemon) CreateNetwork(create types.NetworkCreateRequest) (*types.N return resp, err } +func (daemon *Daemon) createLoadBalancerSandbox(prefix, id string, ip net.IP, n libnetwork.Network, options ...libnetwork.SandboxOption) error { + c := daemon.netController + sandboxName := prefix + "-sbox" + sb, err := c.NewSandbox(sandboxName, options...) + if err != nil { + if _, ok := err.(networktypes.ForbiddenError); !ok { + return errors.Wrapf(err, "Failed creating %s sandbox", sandboxName) + } + return nil + } + + endpointName := prefix + "-endpoint" + ep, err := n.CreateEndpoint(endpointName, libnetwork.CreateOptionIpam(ip, nil, nil, nil), libnetwork.CreateOptionLoadBalancer()) + if err != nil { + return errors.Wrapf(err, "Failed creating %s in sandbox %s", endpointName, sandboxName) + } + + if err := ep.Join(sb, nil); err != nil { + return errors.Wrapf(err, "Failed joining %s to sandbox %s", endpointName, sandboxName) + } + + if err := sb.EnableService(); err != nil { + return errors.Wrapf(err, "Failed enabling service in %s sandbox", sandboxName) + } + + return nil +} + func (daemon *Daemon) createNetwork(create types.NetworkCreateRequest, id string, agent bool) (*types.NetworkCreateResponse, error) { if runconfig.IsPreDefinedNetwork(create.Name) && !agent { err := fmt.Errorf("%s is a pre-defined network and cannot be created", create.Name) - return nil, apierrors.NewRequestForbiddenError(err) + return nil, notAllowedError{err} } var warning string @@ -349,6 +357,7 @@ func (daemon *Daemon) createNetwork(create types.NetworkCreateRequest, id string n, err := c.NewNetwork(driver, create.Name, id, nwOptions...) if err != nil { if _, ok := err.(libnetwork.ErrDataStoreNotInitialized); ok { + // nolint: golint return nil, errors.New("This node is not a swarm manager. Use \"docker swarm init\" or \"docker swarm join\" to connect this node to swarm and try again.") } return nil, err @@ -360,6 +369,18 @@ func (daemon *Daemon) createNetwork(create types.NetworkCreateRequest, id string } daemon.LogNetworkEvent(n, "create") + if agent && !n.Info().Ingress() && n.Type() == "overlay" { + nodeIP, exists := daemon.GetLBAttachmentStore().GetLBIPForNetwork(id) + if !exists { + return nil, fmt.Errorf("Failed to find a load balancer IP to use for network: %v", id) + } + + if err := daemon.createLoadBalancerSandbox(create.Name, id, nodeIP, n); err != nil { + return nil, err + } + + } + return &types.NetworkCreateResponse{ ID: n.ID(), Warning: warning, @@ -496,6 +517,31 @@ func (daemon *Daemon) DeleteNetwork(networkID string) error { return daemon.deleteNetwork(networkID, false) } +func (daemon *Daemon) deleteLoadBalancerSandbox(n libnetwork.Network) { + controller := daemon.netController + + //The only endpoint left should be the LB endpoint (nw.Name() + "-endpoint") + endpoints := n.Endpoints() + if len(endpoints) == 1 { + sandboxName := n.Name() + "-sbox" + + if err := endpoints[0].Info().Sandbox().DisableService(); err != nil { + logrus.Errorf("Failed to disable service on sandbox %s: %v", sandboxName, err) + //Ignore error and attempt to delete the load balancer endpoint + } + + if err := endpoints[0].Delete(true); err != nil { + logrus.Errorf("Failed to delete endpoint %s (%s) in %s: %v", endpoints[0].Name(), endpoints[0].ID(), sandboxName, err) + //Ignore error and attempt to delete the sandbox. + } + + if err := controller.SandboxDestroy(sandboxName); err != nil { + logrus.Errorf("Failed to delete %s sandbox: %v", sandboxName, err) + //Ignore error and attempt to delete the network. + } + } +} + func (daemon *Daemon) deleteNetwork(networkID string, dynamic bool) error { nw, err := daemon.FindNetwork(networkID) if err != nil { @@ -504,7 +550,7 @@ func (daemon *Daemon) deleteNetwork(networkID string, dynamic bool) error { if runconfig.IsPreDefinedNetwork(nw.Name()) && !dynamic { err := fmt.Errorf("%s is a pre-defined network and cannot be removed", nw.Name()) - return apierrors.NewRequestForbiddenError(err) + return notAllowedError{err} } if dynamic && !nw.Info().Dynamic() { @@ -514,7 +560,11 @@ func (daemon *Daemon) deleteNetwork(networkID string, dynamic bool) error { return nil } err := fmt.Errorf("%s is not a dynamic network", nw.Name()) - return apierrors.NewRequestForbiddenError(err) + return notAllowedError{err} + } + + if !nw.Info().Ingress() && nw.Type() == "overlay" { + daemon.deleteLoadBalancerSandbox(nw) } if err := nw.Delete(); err != nil { diff --git a/vendor/github.com/docker/docker/daemon/network/settings.go b/vendor/github.com/docker/docker/daemon/network/settings.go index 8f6b7dd59..0d7d5baf5 100644 --- a/vendor/github.com/docker/docker/daemon/network/settings.go +++ b/vendor/github.com/docker/docker/daemon/network/settings.go @@ -1,9 +1,12 @@ package network import ( + "net" + networktypes "github.com/docker/docker/api/types/network" clustertypes "github.com/docker/docker/daemon/cluster/provider" "github.com/docker/go-connections/nat" + "github.com/pkg/errors" ) // Settings stores configuration details about the daemon network config @@ -31,3 +34,36 @@ type EndpointSettings struct { *networktypes.EndpointSettings IPAMOperational bool } + +// LBAttachmentStore stores the load balancer IP address for a network id. +type LBAttachmentStore struct { + //key: networkd id + //value: load balancer ip address + networkToNodeLBIP map[string]net.IP +} + +// ResetLBAttachments clears any exsiting load balancer IP to network mapping and +// sets the mapping to the given lbAttachments. +func (lbStore *LBAttachmentStore) ResetLBAttachments(lbAttachments map[string]string) error { + lbStore.ClearLBAttachments() + for nid, nodeIP := range lbAttachments { + ip, _, err := net.ParseCIDR(nodeIP) + if err != nil { + lbStore.networkToNodeLBIP = make(map[string]net.IP) + return errors.Wrapf(err, "Failed to parse load balancer address %s", nodeIP) + } + lbStore.networkToNodeLBIP[nid] = ip + } + return nil +} + +// ClearLBAttachments clears all the mappings of network to load balancer IP Address. +func (lbStore *LBAttachmentStore) ClearLBAttachments() { + lbStore.networkToNodeLBIP = make(map[string]net.IP) +} + +// GetLBIPForNetwork return the load balancer IP address for the given network. +func (lbStore *LBAttachmentStore) GetLBIPForNetwork(networkID string) (net.IP, bool) { + ip, exists := lbStore.networkToNodeLBIP[networkID] + return ip, exists +} diff --git a/vendor/github.com/docker/docker/daemon/oci_linux.go b/vendor/github.com/docker/docker/daemon/oci_linux.go index 9f666f879..0f8a392c2 100644 --- a/vendor/github.com/docker/docker/daemon/oci_linux.go +++ b/vendor/github.com/docker/docker/daemon/oci_linux.go @@ -19,7 +19,6 @@ import ( "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/stringutils" - "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/volume" "github.com/opencontainers/runc/libcontainer/apparmor" "github.com/opencontainers/runc/libcontainer/cgroups" @@ -29,6 +28,7 @@ import ( "github.com/sirupsen/logrus" ) +// nolint: gosimple var ( deviceCgroupRuleRegex = regexp.MustCompile("^([acb]) ([0-9]+|\\*):([0-9]+|\\*) ([rwm]{1,3})$") ) @@ -73,7 +73,6 @@ func setResources(s *specs.Spec, r containertypes.Resources) error { ThrottleReadIOPSDevice: readIOpsDevice, ThrottleWriteIOPSDevice: writeIOpsDevice, }, - DisableOOMKiller: r.OomKillDisable, Pids: &specs.LinuxPids{ Limit: r.PidsLimit, }, @@ -157,14 +156,14 @@ func setDevices(s *specs.Spec, c *container.Container) error { } func setRlimits(daemon *Daemon, s *specs.Spec, c *container.Container) error { - var rlimits []specs.LinuxRlimit + var rlimits []specs.POSIXRlimit // We want to leave the original HostConfig alone so make a copy here hostConfig := *c.HostConfig // Merge with the daemon defaults daemon.mergeUlimits(&hostConfig) for _, ul := range hostConfig.Ulimits { - rlimits = append(rlimits, specs.LinuxRlimit{ + rlimits = append(rlimits, specs.POSIXRlimit{ Type: "RLIMIT_" + strings.ToUpper(ul.Name), Soft: uint64(ul.Soft), Hard: uint64(ul.Hard), @@ -187,7 +186,7 @@ func setUser(s *specs.Spec, c *container.Container) error { } func readUserFile(c *container.Container, p string) (io.ReadCloser, error) { - fp, err := symlink.FollowSymlinkInScope(filepath.Join(c.BaseFS, p), c.BaseFS) + fp, err := c.GetResourcePath(p) if err != nil { return nil, err } @@ -301,10 +300,13 @@ func setNamespaces(daemon *Daemon, s *specs.Spec, c *container.Container) error } setNamespace(s, ns) } + // ipc - if c.HostConfig.IpcMode.IsContainer() { + ipcMode := c.HostConfig.IpcMode + switch { + case ipcMode.IsContainer(): ns := specs.LinuxNamespace{Type: "ipc"} - ic, err := daemon.getIpcContainer(c) + ic, err := daemon.getIpcContainer(ipcMode.Container()) if err != nil { return err } @@ -316,12 +318,19 @@ func setNamespaces(daemon *Daemon, s *specs.Spec, c *container.Container) error nsUser.Path = fmt.Sprintf("/proc/%d/ns/user", ic.State.GetPID()) setNamespace(s, nsUser) } - } else if c.HostConfig.IpcMode.IsHost() { + case ipcMode.IsHost(): oci.RemoveNamespace(s, specs.LinuxNamespaceType("ipc")) - } else { + case ipcMode.IsEmpty(): + // A container was created by an older version of the daemon. + // The default behavior used to be what is now called "shareable". + fallthrough + case ipcMode.IsPrivate(), ipcMode.IsShareable(), ipcMode.IsNone(): ns := specs.LinuxNamespace{Type: "ipc"} setNamespace(s, ns) + default: + return fmt.Errorf("Invalid IPC mode: %v", ipcMode) } + // pid if c.HostConfig.PidMode.IsContainer() { ns := specs.LinuxNamespace{Type: "pid"} @@ -428,7 +437,7 @@ func ensureShared(path string) error { } if !sharedMount { - return fmt.Errorf("Path %s is mounted on %s but it is not a shared mount.", path, sourceMount) + return fmt.Errorf("path %s is mounted on %s but it is not a shared mount", path, sourceMount) } return nil } @@ -455,7 +464,7 @@ func ensureSharedOrSlave(path string) error { } if !sharedMount && !slaveMount { - return fmt.Errorf("Path %s is mounted on %s but it is not a shared or slave mount.", path, sourceMount) + return fmt.Errorf("path %s is mounted on %s but it is not a shared or slave mount", path, sourceMount) } return nil } @@ -486,10 +495,17 @@ func setMounts(daemon *Daemon, s *specs.Spec, c *container.Container, mounts []c userMounts[m.Destination] = struct{}{} } + // Filter out mounts from spec + noIpc := c.HostConfig.IpcMode.IsNone() // Filter out mounts that are overridden by user supplied mounts var defaultMounts []specs.Mount _, mountDev := userMounts["/dev"] for _, m := range s.Mounts { + // filter out /dev/shm mount if case IpcMode is none + if noIpc && m.Destination == "/dev/shm" { + continue + } + // filter out mount overridden by a user supplied mount if _, ok := userMounts[m.Destination]; !ok { if mountDev && strings.HasPrefix(m.Destination, "/dev/") { continue @@ -502,13 +518,14 @@ func setMounts(daemon *Daemon, s *specs.Spec, c *container.Container, mounts []c for _, m := range mounts { for _, cm := range s.Mounts { if cm.Destination == m.Destination { - return fmt.Errorf("Duplicate mount point '%s'", m.Destination) + return duplicateMountPointError(m.Destination) } } if m.Source == "tmpfs" { data := m.Data - options := []string{"noexec", "nosuid", "nodev", string(volume.DefaultPropagationMode)} + parser := volume.NewParser("linux") + options := []string{"noexec", "nosuid", "nodev", string(parser.DefaultPropagationMode())} if data != "" { options = append(options, strings.Split(data, ",")...) } @@ -589,6 +606,14 @@ func setMounts(daemon *Daemon, s *specs.Spec, c *container.Container, mounts []c s.Linux.MaskedPaths = nil } + // Set size for /dev/shm mount that comes from spec (IpcMode: private only) + for i, m := range s.Mounts { + if m.Destination == "/dev/shm" { + sizeOpt := "size=" + strconv.FormatInt(c.HostConfig.ShmSize, 10) + s.Mounts[i].Options = append(s.Mounts[i].Options, sizeOpt) + } + } + // TODO: until a kernel/mount solution exists for handling remount in a user namespace, // we must clear the readonly flag for the cgroups mount (@mrunalp concurs) if uidMap := daemon.idMappings.UIDs(); uidMap != nil || c.HostConfig.Privileged { @@ -607,8 +632,8 @@ func (daemon *Daemon) populateCommonSpec(s *specs.Spec, c *container.Container) if err != nil { return err } - s.Root = specs.Root{ - Path: c.BaseFS, + s.Root = &specs.Root{ + Path: c.BaseFS.Path(), Readonly: c.HostConfig.ReadonlyRootfs, } if err := c.SetupWorkingDirectory(daemon.idMappings.RootPair()); err != nil { @@ -684,7 +709,6 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) { if err := setResources(&s, c.HostConfig.Resources); err != nil { return nil, fmt.Errorf("linux runtime spec resources: %v", err) } - s.Linux.Resources.OOMScoreAdj = &c.HostConfig.OomScoreAdj s.Linux.Sysctl = c.HostConfig.Sysctls p := s.Linux.CgroupsPath @@ -745,7 +769,9 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) { return nil, err } - ms = append(ms, c.IpcMounts()...) + if !c.HostConfig.IpcMode.IsPrivate() && !c.HostConfig.IpcMode.IsEmpty() { + ms = append(ms, c.IpcMounts()...) + } tmpfsMounts, err := c.TmpfsMounts() if err != nil { @@ -806,9 +832,10 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) { } s.Process.SelinuxLabel = c.GetProcessLabel() s.Process.NoNewPrivileges = c.NoNewPrivileges + s.Process.OOMScoreAdj = &c.HostConfig.OomScoreAdj s.Linux.MountLabel = c.MountLabel - return (*specs.Spec)(&s), nil + return &s, nil } func clearReadOnly(m *specs.Mount) { diff --git a/vendor/github.com/docker/docker/daemon/oci_solaris.go b/vendor/github.com/docker/docker/daemon/oci_solaris.go index 610efe10a..45fa1e0ff 100644 --- a/vendor/github.com/docker/docker/daemon/oci_solaris.go +++ b/vendor/github.com/docker/docker/daemon/oci_solaris.go @@ -2,7 +2,6 @@ package daemon import ( "fmt" - "path/filepath" "sort" "strconv" @@ -127,7 +126,7 @@ func (daemon *Daemon) populateCommonSpec(s *specs.Spec, c *container.Container) return err } s.Root = specs.Root{ - Path: filepath.Dir(c.BaseFS), + Path: c.BaseFS.Dir(c.BaseFS.Path()), Readonly: c.HostConfig.ReadonlyRootfs, } if err := c.SetupWorkingDirectory(daemon.idMappings.RootPair()); err != nil { diff --git a/vendor/github.com/docker/docker/daemon/oci_windows.go b/vendor/github.com/docker/docker/daemon/oci_windows.go index 555a466fe..17b104049 100644 --- a/vendor/github.com/docker/docker/daemon/oci_windows.go +++ b/vendor/github.com/docker/docker/daemon/oci_windows.go @@ -1,13 +1,26 @@ package daemon import ( + "fmt" + "io/ioutil" + "path/filepath" + "runtime" + "strings" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" + "github.com/docker/docker/layer" "github.com/docker/docker/oci" "github.com/docker/docker/pkg/sysinfo" "github.com/docker/docker/pkg/system" "github.com/opencontainers/runtime-spec/specs-go" "golang.org/x/sys/windows" + "golang.org/x/sys/windows/registry" +) + +const ( + credentialSpecRegistryLocation = `SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\Containers\CredentialSpecs` + credentialSpecFileLocation = "CredentialSpecs" ) func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) { @@ -53,6 +66,10 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) { isHyperV = c.HostConfig.Isolation.IsHyperV() } + if isHyperV { + s.Windows.HyperV = &specs.WindowsHyperV{} + } + // If the container has not been started, and has configs or secrets // secrets, create symlinks to each config and secret. If it has been // started before, the symlinks should have already been created. Also, it @@ -92,6 +109,11 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) { if !mount.Writable { m.Options = append(m.Options, "ro") } + if img.OS != runtime.GOOS { + m.Type = "bind" + m.Options = append(m.Options, "rbind") + m.Options = append(m.Options, fmt.Sprintf("uvmpath=/tmp/gcs/%s/binds", c.ID)) + } s.Mounts = append(s.Mounts, m) } @@ -105,13 +127,93 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) { s.Process.Env = c.CreateDaemonEnvironment(c.Config.Tty, linkedEnv) if c.Config.Tty { s.Process.Terminal = c.Config.Tty - s.Process.ConsoleSize.Height = c.HostConfig.ConsoleSize[0] - s.Process.ConsoleSize.Width = c.HostConfig.ConsoleSize[1] + s.Process.ConsoleSize = &specs.Box{ + Height: c.HostConfig.ConsoleSize[0], + Width: c.HostConfig.ConsoleSize[1], + } } s.Process.User.Username = c.Config.User + // Get the layer path for each layer. + max := len(img.RootFS.DiffIDs) + for i := 1; i <= max; i++ { + img.RootFS.DiffIDs = img.RootFS.DiffIDs[:i] + layerPath, err := layer.GetLayerPath(daemon.stores[c.Platform].layerStore, img.RootFS.ChainID()) + if err != nil { + return nil, fmt.Errorf("failed to get layer path from graphdriver %s for ImageID %s - %s", daemon.stores[c.Platform].layerStore, img.RootFS.ChainID(), err) + } + // Reverse order, expecting parent most first + s.Windows.LayerFolders = append([]string{layerPath}, s.Windows.LayerFolders...) + } + m, err := c.RWLayer.Metadata() + if err != nil { + return nil, fmt.Errorf("failed to get layer metadata - %s", err) + } + s.Windows.LayerFolders = append(s.Windows.LayerFolders, m["dir"]) + + dnsSearch := daemon.getDNSSearchSettings(c) + + // Get endpoints for the libnetwork allocated networks to the container + var epList []string + AllowUnqualifiedDNSQuery := false + gwHNSID := "" + if c.NetworkSettings != nil { + for n := range c.NetworkSettings.Networks { + sn, err := daemon.FindNetwork(n) + if err != nil { + continue + } + + ep, err := c.GetEndpointInNetwork(sn) + if err != nil { + continue + } + + data, err := ep.DriverInfo() + if err != nil { + continue + } + + if data["GW_INFO"] != nil { + gwInfo := data["GW_INFO"].(map[string]interface{}) + if gwInfo["hnsid"] != nil { + gwHNSID = gwInfo["hnsid"].(string) + } + } + + if data["hnsid"] != nil { + epList = append(epList, data["hnsid"].(string)) + } + + if data["AllowUnqualifiedDNSQuery"] != nil { + AllowUnqualifiedDNSQuery = true + } + } + } + + var networkSharedContainerID string + if c.HostConfig.NetworkMode.IsContainer() { + networkSharedContainerID = c.NetworkSharedContainerID + for _, ep := range c.SharedEndpointList { + epList = append(epList, ep) + } + } + + if gwHNSID != "" { + epList = append(epList, gwHNSID) + } + + s.Windows.Network = &specs.WindowsNetwork{ + AllowUnqualifiedDNSQuery: AllowUnqualifiedDNSQuery, + DNSSearchList: dnsSearch, + EndpointList: epList, + NetworkSharedContainerName: networkSharedContainerID, + } + if img.OS == "windows" { - daemon.createSpecWindowsFields(c, &s, isHyperV) + if err := daemon.createSpecWindowsFields(c, &s, isHyperV); err != nil { + return nil, err + } } else { // TODO @jhowardmsft LCOW Support. Modify this check when running in dual-mode if system.LCOWSupported() && img.OS == "linux" { @@ -123,7 +225,7 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) { } // Sets the Windows-specific fields of the OCI spec -func (daemon *Daemon) createSpecWindowsFields(c *container.Container, s *specs.Spec, isHyperV bool) { +func (daemon *Daemon) createSpecWindowsFields(c *container.Container, s *specs.Spec, isHyperV bool) error { if len(s.Process.Cwd) == 0 { // We default to C:\ to workaround the oddity of the case that the // default directory for cmd running as LocalSystem (or @@ -137,9 +239,15 @@ func (daemon *Daemon) createSpecWindowsFields(c *container.Container, s *specs.S s.Root.Readonly = false // Windows does not support a read-only root filesystem if !isHyperV { - s.Root.Path = c.BaseFS // This is not set for Hyper-V containers + s.Root.Path = c.BaseFS.Path() // This is not set for Hyper-V containers + if !strings.HasSuffix(s.Root.Path, `\`) { + s.Root.Path = s.Root.Path + `\` // Ensure a correctly formatted volume GUID path \\?\Volume{GUID}\ + } } + // First boot optimization + s.Windows.IgnoreFlushesDuringBoot = !c.HasBeenStartedBefore + // In s.Windows.Resources cpuShares := uint16(c.HostConfig.CPUShares) cpuMaximum := uint16(c.HostConfig.CPUPercent) * 100 @@ -179,6 +287,54 @@ func (daemon *Daemon) createSpecWindowsFields(c *container.Container, s *specs.S Iops: &c.HostConfig.IOMaximumIOps, }, } + + // Read and add credentials from the security options if a credential spec has been provided. + if c.HostConfig.SecurityOpt != nil { + cs := "" + for _, sOpt := range c.HostConfig.SecurityOpt { + sOpt = strings.ToLower(sOpt) + if !strings.Contains(sOpt, "=") { + return fmt.Errorf("invalid security option: no equals sign in supplied value %s", sOpt) + } + var splitsOpt []string + splitsOpt = strings.SplitN(sOpt, "=", 2) + if len(splitsOpt) != 2 { + return fmt.Errorf("invalid security option: %s", sOpt) + } + if splitsOpt[0] != "credentialspec" { + return fmt.Errorf("security option not supported: %s", splitsOpt[0]) + } + + var ( + match bool + csValue string + err error + ) + if match, csValue = getCredentialSpec("file://", splitsOpt[1]); match { + if csValue == "" { + return fmt.Errorf("no value supplied for file:// credential spec security option") + } + if cs, err = readCredentialSpecFile(c.ID, daemon.root, filepath.Clean(csValue)); err != nil { + return err + } + } else if match, csValue = getCredentialSpec("registry://", splitsOpt[1]); match { + if csValue == "" { + return fmt.Errorf("no value supplied for registry:// credential spec security option") + } + if cs, err = readCredentialSpecRegistry(c.ID, csValue); err != nil { + return err + } + } else { + return fmt.Errorf("invalid credential spec security option - value must be prefixed file:// or registry:// followed by a value") + } + } + s.Windows.CredentialSpec = cs + } + + // Assume we are not starting a container for a servicing operation + s.Windows.Servicing = false + + return nil } // Sets the Linux-specific fields of the OCI spec @@ -205,3 +361,52 @@ func escapeArgs(args []string) []string { func (daemon *Daemon) mergeUlimits(c *containertypes.HostConfig) { return } + +// getCredentialSpec is a helper function to get the value of a credential spec supplied +// on the CLI, stripping the prefix +func getCredentialSpec(prefix, value string) (bool, string) { + if strings.HasPrefix(value, prefix) { + return true, strings.TrimPrefix(value, prefix) + } + return false, "" +} + +// readCredentialSpecRegistry is a helper function to read a credential spec from +// the registry. If not found, we return an empty string and warn in the log. +// This allows for staging on machines which do not have the necessary components. +func readCredentialSpecRegistry(id, name string) (string, error) { + var ( + k registry.Key + err error + val string + ) + if k, err = registry.OpenKey(registry.LOCAL_MACHINE, credentialSpecRegistryLocation, registry.QUERY_VALUE); err != nil { + return "", fmt.Errorf("failed handling spec %q for container %s - %s could not be opened", name, id, credentialSpecRegistryLocation) + } + if val, _, err = k.GetStringValue(name); err != nil { + if err == registry.ErrNotExist { + return "", fmt.Errorf("credential spec %q for container %s as it was not found", name, id) + } + return "", fmt.Errorf("error %v reading credential spec %q from registry for container %s", err, name, id) + } + return val, nil +} + +// readCredentialSpecFile is a helper function to read a credential spec from +// a file. If not found, we return an empty string and warn in the log. +// This allows for staging on machines which do not have the necessary components. +func readCredentialSpecFile(id, root, location string) (string, error) { + if filepath.IsAbs(location) { + return "", fmt.Errorf("invalid credential spec - file:// path cannot be absolute") + } + base := filepath.Join(root, credentialSpecFileLocation) + full := filepath.Join(base, location) + if !strings.HasPrefix(full, base) { + return "", fmt.Errorf("invalid credential spec - file:// path must be under %s", base) + } + bcontents, err := ioutil.ReadFile(full) + if err != nil { + return "", fmt.Errorf("credential spec '%s' for container %s as the file could not be read: %q", full, id, err) + } + return string(bcontents[:]), nil +} diff --git a/vendor/github.com/docker/docker/daemon/pause.go b/vendor/github.com/docker/docker/daemon/pause.go index dbfafbc5f..3fecea59c 100644 --- a/vendor/github.com/docker/docker/daemon/pause.go +++ b/vendor/github.com/docker/docker/daemon/pause.go @@ -28,7 +28,7 @@ func (daemon *Daemon) containerPause(container *container.Container) error { // We cannot Pause the container which is not running if !container.Running { - return errNotRunning{container.ID} + return errNotRunning(container.ID) } // We cannot Pause the container which is already paused diff --git a/vendor/github.com/docker/docker/daemon/prune.go b/vendor/github.com/docker/docker/daemon/prune.go index 824e0cd83..66eca2b6e 100644 --- a/vendor/github.com/docker/docker/daemon/prune.go +++ b/vendor/github.com/docker/docker/daemon/prune.go @@ -186,7 +186,7 @@ func (daemon *Daemon) ImagesPrune(ctx context.Context, pruneFilters filters.Args if pruneFilters.ExactMatch("dangling", "false") || pruneFilters.ExactMatch("dangling", "0") { danglingOnly = false } else if !pruneFilters.ExactMatch("dangling", "true") && !pruneFilters.ExactMatch("dangling", "1") { - return nil, fmt.Errorf("Invalid filter 'dangling=%s'", pruneFilters.Get("dangling")) + return nil, invalidFilter{"dangling", pruneFilters.Get("dangling")} } } @@ -221,7 +221,7 @@ func (daemon *Daemon) ImagesPrune(ctx context.Context, pruneFilters filters.Args return nil, ctx.Err() default: dgst := digest.Digest(id) - if len(daemon.stores[platform].referenceStore.References(dgst)) == 0 && len(daemon.stores[platform].imageStore.Children(id)) != 0 { + if len(daemon.referenceStore.References(dgst)) == 0 && len(daemon.stores[platform].imageStore.Children(id)) != 0 { continue } if !until.IsZero() && img.Created.After(until) { @@ -252,7 +252,7 @@ deleteImagesLoop: } deletedImages := []types.ImageDeleteResponseItem{} - refs := daemon.stores[platform].referenceStore.References(dgst) + refs := daemon.referenceStore.References(dgst) if len(refs) > 0 { shouldDelete := !danglingOnly if !shouldDelete { diff --git a/vendor/github.com/docker/docker/daemon/reload.go b/vendor/github.com/docker/docker/daemon/reload.go index a71d31efc..a6674ec95 100644 --- a/vendor/github.com/docker/docker/daemon/reload.go +++ b/vendor/github.com/docker/docker/daemon/reload.go @@ -37,7 +37,9 @@ func (daemon *Daemon) Reload(conf *config.Config) (err error) { } }() - daemon.reloadPlatform(conf, attributes) + if err := daemon.reloadPlatform(conf, attributes); err != nil { + return err + } daemon.reloadDebug(conf, attributes) daemon.reloadMaxConcurrentDownloadsAndUploads(conf, attributes) daemon.reloadShutdownTimeout(conf, attributes) diff --git a/vendor/github.com/docker/docker/daemon/reload_test.go b/vendor/github.com/docker/docker/daemon/reload_test.go index bf11b6bd5..3ff6b5773 100644 --- a/vendor/github.com/docker/docker/daemon/reload_test.go +++ b/vendor/github.com/docker/docker/daemon/reload_test.go @@ -12,6 +12,7 @@ import ( "github.com/docker/docker/pkg/discovery" _ "github.com/docker/docker/pkg/discovery/memory" "github.com/docker/docker/registry" + "github.com/stretchr/testify/assert" ) func TestDaemonReloadLabels(t *testing.T) { @@ -46,8 +47,9 @@ func TestDaemonReloadAllowNondistributableArtifacts(t *testing.T) { configStore: &config.Config{}, } + var err error // Initialize daemon with some registries. - daemon.RegistryService = registry.NewService(registry.ServiceOptions{ + daemon.RegistryService, err = registry.NewService(registry.ServiceOptions{ AllowNondistributableArtifacts: []string{ "127.0.0.0/8", "10.10.1.11:5000", @@ -56,6 +58,9 @@ func TestDaemonReloadAllowNondistributableArtifacts(t *testing.T) { "docker2.com", // This will be removed during reload. }, }) + if err != nil { + t.Fatal(err) + } registries := []string{ "127.0.0.0/8", @@ -85,20 +90,17 @@ func TestDaemonReloadAllowNondistributableArtifacts(t *testing.T) { for _, value := range serviceConfig.AllowNondistributableArtifactsCIDRs { actual = append(actual, value.String()) } - for _, value := range serviceConfig.AllowNondistributableArtifactsHostnames { - actual = append(actual, value) - } + actual = append(actual, serviceConfig.AllowNondistributableArtifactsHostnames...) sort.Strings(registries) sort.Strings(actual) - if !reflect.DeepEqual(registries, actual) { - t.Fatalf("expected %v, got %v\n", registries, actual) - } + assert.Equal(t, registries, actual) } func TestDaemonReloadMirrors(t *testing.T) { daemon := &Daemon{} - daemon.RegistryService = registry.NewService(registry.ServiceOptions{ + var err error + daemon.RegistryService, err = registry.NewService(registry.ServiceOptions{ InsecureRegistries: []string{}, Mirrors: []string{ "https://mirror.test1.com", @@ -106,6 +108,9 @@ func TestDaemonReloadMirrors(t *testing.T) { "https://mirror.test3.com", // this will be removed when reloading }, }) + if err != nil { + t.Fatal(err) + } daemon.configStore = &config.Config{} @@ -191,8 +196,9 @@ func TestDaemonReloadMirrors(t *testing.T) { func TestDaemonReloadInsecureRegistries(t *testing.T) { daemon := &Daemon{} + var err error // initialize daemon with existing insecure registries: "127.0.0.0/8", "10.10.1.11:5000", "10.10.1.22:5000" - daemon.RegistryService = registry.NewService(registry.ServiceOptions{ + daemon.RegistryService, err = registry.NewService(registry.ServiceOptions{ InsecureRegistries: []string{ "127.0.0.0/8", "10.10.1.11:5000", @@ -201,6 +207,9 @@ func TestDaemonReloadInsecureRegistries(t *testing.T) { "docker2.com", // this will be removed when reloading }, }) + if err != nil { + t.Fatal(err) + } daemon.configStore = &config.Config{} diff --git a/vendor/github.com/docker/docker/daemon/rename.go b/vendor/github.com/docker/docker/daemon/rename.go index b714ece7f..26ee9beae 100644 --- a/vendor/github.com/docker/docker/daemon/rename.go +++ b/vendor/github.com/docker/docker/daemon/rename.go @@ -1,12 +1,11 @@ package daemon import ( - "errors" - "fmt" "strings" dockercontainer "github.com/docker/docker/container" "github.com/docker/libnetwork" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -20,7 +19,7 @@ func (daemon *Daemon) ContainerRename(oldName, newName string) error { ) if oldName == "" || newName == "" { - return errors.New("Neither old nor new names may be empty") + return validationError{errors.New("Neither old nor new names may be empty")} } if newName[0] != '/' { @@ -39,19 +38,19 @@ func (daemon *Daemon) ContainerRename(oldName, newName string) error { oldIsAnonymousEndpoint := container.NetworkSettings.IsAnonymousEndpoint if oldName == newName { - return errors.New("Renaming a container with the same name as its current name") + return validationError{errors.New("Renaming a container with the same name as its current name")} } links := map[string]*dockercontainer.Container{} for k, v := range daemon.linkIndex.children(container) { if !strings.HasPrefix(k, oldName) { - return fmt.Errorf("Linked container %s does not match parent %s", k, oldName) + return validationError{errors.Errorf("Linked container %s does not match parent %s", k, oldName)} } links[strings.TrimPrefix(k, oldName)] = v } if newName, err = daemon.reserveName(container.ID, newName); err != nil { - return fmt.Errorf("Error when allocating new name: %v", err) + return errors.Wrap(err, "Error when allocating new name") } for k, v := range links { diff --git a/vendor/github.com/docker/docker/daemon/resize.go b/vendor/github.com/docker/docker/daemon/resize.go index 747353852..0923d0fe1 100644 --- a/vendor/github.com/docker/docker/daemon/resize.go +++ b/vendor/github.com/docker/docker/daemon/resize.go @@ -15,7 +15,7 @@ func (daemon *Daemon) ContainerResize(name string, height, width int) error { } if !container.IsRunning() { - return errNotRunning{container.ID} + return errNotRunning(container.ID) } if err = daemon.containerd.Resize(container.ID, libcontainerd.InitFriendlyName, width, height); err == nil { diff --git a/vendor/github.com/docker/docker/daemon/search.go b/vendor/github.com/docker/docker/daemon/search.go index 5d2ac5d22..540e247fe 100644 --- a/vendor/github.com/docker/docker/daemon/search.go +++ b/vendor/github.com/docker/docker/daemon/search.go @@ -1,7 +1,6 @@ package daemon import ( - "fmt" "strconv" "golang.org/x/net/context" @@ -38,14 +37,14 @@ func (daemon *Daemon) SearchRegistryForImages(ctx context.Context, filtersArgs s if searchFilters.UniqueExactMatch("is-automated", "true") { isAutomated = true } else if !searchFilters.UniqueExactMatch("is-automated", "false") { - return nil, fmt.Errorf("Invalid filter 'is-automated=%s'", searchFilters.Get("is-automated")) + return nil, invalidFilter{"is-automated", searchFilters.Get("is-automated")} } } if searchFilters.Include("is-official") { if searchFilters.UniqueExactMatch("is-official", "true") { isOfficial = true } else if !searchFilters.UniqueExactMatch("is-official", "false") { - return nil, fmt.Errorf("Invalid filter 'is-official=%s'", searchFilters.Get("is-official")) + return nil, invalidFilter{"is-official", searchFilters.Get("is-official")} } } if searchFilters.Include("stars") { @@ -53,7 +52,7 @@ func (daemon *Daemon) SearchRegistryForImages(ctx context.Context, filtersArgs s for _, hasStar := range hasStars { iHasStar, err := strconv.Atoi(hasStar) if err != nil { - return nil, fmt.Errorf("Invalid filter 'stars=%s'", hasStar) + return nil, invalidFilter{"stars", hasStar} } if iHasStar > hasStarFilter { hasStarFilter = iHasStar diff --git a/vendor/github.com/docker/docker/daemon/start.go b/vendor/github.com/docker/docker/daemon/start.go index 290b099e3..de32a649d 100644 --- a/vendor/github.com/docker/docker/daemon/start.go +++ b/vendor/github.com/docker/docker/daemon/start.go @@ -1,26 +1,20 @@ package daemon import ( - "fmt" - "net/http" "runtime" - "strings" - "syscall" "time" - "google.golang.org/grpc" - - apierrors "github.com/docker/docker/api/errors" "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) // ContainerStart starts a container. func (daemon *Daemon) ContainerStart(name string, hostConfig *containertypes.HostConfig, checkpoint string, checkpointDir string) error { if checkpoint != "" && !daemon.HasExperimental() { - return apierrors.NewBadRequestError(fmt.Errorf("checkpoint is only supported in experimental mode")) + return validationError{errors.New("checkpoint is only supported in experimental mode")} } container, err := daemon.GetContainer(name) @@ -28,13 +22,26 @@ func (daemon *Daemon) ContainerStart(name string, hostConfig *containertypes.Hos return err } - if container.IsPaused() { - return fmt.Errorf("Cannot start a paused container, try unpause instead.") + validateState := func() error { + container.Lock() + defer container.Unlock() + + if container.Paused { + return stateConflictError{errors.New("cannot start a paused container, try unpause instead")} + } + + if container.Running { + return containerNotModifiedError{running: true} + } + + if container.RemovalInProgress || container.Dead { + return stateConflictError{errors.New("container is marked for removal and cannot be started")} + } + return nil } - if container.IsRunning() { - err := fmt.Errorf("Container already started") - return apierrors.NewErrorWithStatusCode(err, http.StatusNotModified) + if err := validateState(); err != nil { + return err } // Windows does not have the backwards compatibility issue here. @@ -45,13 +52,13 @@ func (daemon *Daemon) ContainerStart(name string, hostConfig *containertypes.Hos logrus.Warn("DEPRECATED: Setting host configuration options when the container starts is deprecated and has been removed in Docker 1.12") oldNetworkMode := container.HostConfig.NetworkMode if err := daemon.setSecurityOptions(container, hostConfig); err != nil { - return err + return validationError{err} } if err := daemon.mergeAndVerifyLogConfig(&hostConfig.LogConfig); err != nil { - return err + return validationError{err} } if err := daemon.setHostConfig(container, hostConfig); err != nil { - return err + return validationError{err} } newNetworkMode := container.HostConfig.NetworkMode if string(oldNetworkMode) != string(newNetworkMode) { @@ -59,31 +66,34 @@ func (daemon *Daemon) ContainerStart(name string, hostConfig *containertypes.Hos // old networks. It is a deprecated feature and has been removed in Docker 1.12 container.NetworkSettings.Networks = nil if err := container.CheckpointTo(daemon.containersReplica); err != nil { - return err + return systemError{err} } } container.InitDNSHostConfig() } } else { if hostConfig != nil { - return fmt.Errorf("Supplying a hostconfig on start is not supported. It should be supplied on create") + return validationError{errors.New("Supplying a hostconfig on start is not supported. It should be supplied on create")} } } // check if hostConfig is in line with the current system settings. // It may happen cgroups are umounted or the like. - if _, err = daemon.verifyContainerSettings(container.HostConfig, nil, false); err != nil { - return err + if _, err = daemon.verifyContainerSettings(container.Platform, container.HostConfig, nil, false); err != nil { + return validationError{err} } // Adapt for old containers in case we have updates in this function and // old containers never have chance to call the new function in create stage. if hostConfig != nil { if err := daemon.adaptContainerSettings(container.HostConfig, false); err != nil { - return err + return validationError{err} } } - return daemon.containerStart(container, checkpoint, checkpointDir, true) + if err := daemon.containerStart(container, checkpoint, checkpointDir, true); err != nil { + return err + } + return nil } // containerStart prepares the container to run by setting up everything the @@ -100,7 +110,7 @@ func (daemon *Daemon) containerStart(container *container.Container, checkpoint } if container.RemovalInProgress || container.Dead { - return fmt.Errorf("Container is marked for removal and cannot be started.") + return stateConflictError{errors.New("container is marked for removal and cannot be started")} } // if we encounter an error during start we need to ensure that any other @@ -139,7 +149,7 @@ func (daemon *Daemon) containerStart(container *container.Container, checkpoint spec, err := daemon.createSpec(container) if err != nil { - return err + return systemError{err} } createOptions, err := daemon.getLibcontainerdCreateOptions(container) @@ -160,32 +170,8 @@ func (daemon *Daemon) containerStart(container *container.Container, checkpoint } if err := daemon.containerd.Create(container.ID, checkpoint, checkpointDir, *spec, container.InitializeStdio, createOptions...); err != nil { - errDesc := grpc.ErrorDesc(err) - contains := func(s1, s2 string) bool { - return strings.Contains(strings.ToLower(s1), s2) - } - logrus.Errorf("Create container failed with error: %s", errDesc) - // if we receive an internal error from the initial start of a container then lets - // return it instead of entering the restart loop - // set to 127 for container cmd not found/does not exist) - if contains(errDesc, container.Path) && - (contains(errDesc, "executable file not found") || - contains(errDesc, "no such file or directory") || - contains(errDesc, "system cannot find the file specified")) { - container.SetExitCode(127) - } - // set to 126 for container cmd can't be invoked errors - if contains(errDesc, syscall.EACCES.Error()) { - container.SetExitCode(126) - } + return translateContainerdStartErr(container.Path, container.SetExitCode, err) - // attempted to mount a file onto a directory, or a directory onto a file, maybe from user specified bind mounts - if contains(errDesc, syscall.ENOTDIR.Error()) { - errDesc += ": Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type" - container.SetExitCode(127) - } - - return fmt.Errorf("%s", errDesc) } containerActions.WithValues("start").UpdateSince(start) @@ -198,7 +184,9 @@ func (daemon *Daemon) containerStart(container *container.Container, checkpoint func (daemon *Daemon) Cleanup(container *container.Container) { daemon.releaseNetwork(container) - container.UnmountIpcMounts(detachMounted) + if err := container.UnmountIpcMount(detachMounted); err != nil { + logrus.Warnf("%s cleanup: failed to unmount IPC: %s", container.ID, err) + } if err := daemon.conditionalUnmountOnCleanup(container); err != nil { // FIXME: remove once reference counting for graphdrivers has been refactored @@ -216,7 +204,7 @@ func (daemon *Daemon) Cleanup(container *container.Container) { daemon.unregisterExecCommand(container, eConfig) } - if container.BaseFS != "" { + if container.BaseFS != nil && container.BaseFS.Path() != "" { if err := container.UnmountVolumes(daemon.LogVolumeEvent); err != nil { logrus.Warnf("%s cleanup: Failed to umount volumes: %v", container.ID, err) } diff --git a/vendor/github.com/docker/docker/daemon/start_unix.go b/vendor/github.com/docker/docker/daemon/start_unix.go index 12ecdab2d..87ab0850c 100644 --- a/vendor/github.com/docker/docker/daemon/start_unix.go +++ b/vendor/github.com/docker/docker/daemon/start_unix.go @@ -3,10 +3,9 @@ package daemon import ( - "fmt" - "github.com/docker/docker/container" "github.com/docker/docker/libcontainerd" + "github.com/pkg/errors" ) // getLibcontainerdCreateOptions callers must hold a lock on the container @@ -21,7 +20,7 @@ func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Contain rt := daemon.configStore.GetRuntime(container.HostConfig.Runtime) if rt == nil { - return nil, fmt.Errorf("no such runtime '%s'", container.HostConfig.Runtime) + return nil, validationError{errors.Errorf("no such runtime '%s'", container.HostConfig.Runtime)} } if UsingSystemd(daemon.configStore) { rt.Args = append(rt.Args, "--systemd-cgroup=true") diff --git a/vendor/github.com/docker/docker/daemon/start_windows.go b/vendor/github.com/docker/docker/daemon/start_windows.go index 74129bd61..9082a93ff 100644 --- a/vendor/github.com/docker/docker/daemon/start_windows.go +++ b/vendor/github.com/docker/docker/daemon/start_windows.go @@ -1,214 +1,43 @@ package daemon import ( - "fmt" - "io/ioutil" - "path/filepath" - "strings" - + "github.com/Microsoft/opengcs/client" "github.com/docker/docker/container" - "github.com/docker/docker/layer" "github.com/docker/docker/libcontainerd" - "golang.org/x/sys/windows/registry" -) - -const ( - credentialSpecRegistryLocation = `SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\Containers\CredentialSpecs` - credentialSpecFileLocation = "CredentialSpecs" ) func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Container) ([]libcontainerd.CreateOption, error) { createOptions := []libcontainerd.CreateOption{} - // Are we going to run as a Hyper-V container? - hvOpts := &libcontainerd.HyperVIsolationOption{} - if container.HostConfig.Isolation.IsDefault() { - // Container is set to use the default, so take the default from the daemon configuration - hvOpts.IsHyperV = daemon.defaultIsolation.IsHyperV() - } else { - // Container is requesting an isolation mode. Honour it. - hvOpts.IsHyperV = container.HostConfig.Isolation.IsHyperV() - } - - dnsSearch := daemon.getDNSSearchSettings(container) - - // Generate the layer folder of the layer options - layerOpts := &libcontainerd.LayerOption{} - m, err := container.RWLayer.Metadata() - if err != nil { - return nil, fmt.Errorf("failed to get layer metadata - %s", err) - } - layerOpts.LayerFolderPath = m["dir"] - - // Generate the layer paths of the layer options - img, err := daemon.stores[container.Platform].imageStore.Get(container.ImageID) - if err != nil { - return nil, fmt.Errorf("failed to graph.Get on ImageID %s - %s", container.ImageID, err) - } - // Get the layer path for each layer. - max := len(img.RootFS.DiffIDs) - for i := 1; i <= max; i++ { - img.RootFS.DiffIDs = img.RootFS.DiffIDs[:i] - layerPath, err := layer.GetLayerPath(daemon.stores[container.Platform].layerStore, img.RootFS.ChainID()) - if err != nil { - return nil, fmt.Errorf("failed to get layer path from graphdriver %s for ImageID %s - %s", daemon.stores[container.Platform].layerStore, img.RootFS.ChainID(), err) + // LCOW options. + if container.Platform == "linux" { + config := &client.Config{} + if err := config.GenerateDefault(daemon.configStore.GraphOptions); err != nil { + return nil, err } - // Reverse order, expecting parent most first - layerOpts.LayerPaths = append([]string{layerPath}, layerOpts.LayerPaths...) - } - - // Get endpoints for the libnetwork allocated networks to the container - var epList []string - AllowUnqualifiedDNSQuery := false - gwHNSID := "" - if container.NetworkSettings != nil { - for n := range container.NetworkSettings.Networks { - sn, err := daemon.FindNetwork(n) - if err != nil { - continue - } - - ep, err := container.GetEndpointInNetwork(sn) - if err != nil { - continue - } - - data, err := ep.DriverInfo() - if err != nil { - continue - } - - if data["GW_INFO"] != nil { - gwInfo := data["GW_INFO"].(map[string]interface{}) - if gwInfo["hnsid"] != nil { - gwHNSID = gwInfo["hnsid"].(string) - } - } - - if data["hnsid"] != nil { - epList = append(epList, data["hnsid"].(string)) - } - - if data["AllowUnqualifiedDNSQuery"] != nil { - AllowUnqualifiedDNSQuery = true + // Override from user-supplied options. + for k, v := range container.HostConfig.StorageOpt { + switch k { + case "lcow.kirdpath": + config.KirdPath = v + case "lcow.kernel": + config.KernelFile = v + case "lcow.initrd": + config.InitrdFile = v + case "lcow.vhdx": + config.Vhdx = v + case "lcow.bootparameters": + config.BootParameters = v } } - } - - if gwHNSID != "" { - epList = append(epList, gwHNSID) - } - - // Read and add credentials from the security options if a credential spec has been provided. - if container.HostConfig.SecurityOpt != nil { - for _, sOpt := range container.HostConfig.SecurityOpt { - sOpt = strings.ToLower(sOpt) - if !strings.Contains(sOpt, "=") { - return nil, fmt.Errorf("invalid security option: no equals sign in supplied value %s", sOpt) - } - var splitsOpt []string - splitsOpt = strings.SplitN(sOpt, "=", 2) - if len(splitsOpt) != 2 { - return nil, fmt.Errorf("invalid security option: %s", sOpt) - } - if splitsOpt[0] != "credentialspec" { - return nil, fmt.Errorf("security option not supported: %s", splitsOpt[0]) - } - - credentialsOpts := &libcontainerd.CredentialsOption{} - var ( - match bool - csValue string - err error - ) - if match, csValue = getCredentialSpec("file://", splitsOpt[1]); match { - if csValue == "" { - return nil, fmt.Errorf("no value supplied for file:// credential spec security option") - } - if credentialsOpts.Credentials, err = readCredentialSpecFile(container.ID, daemon.root, filepath.Clean(csValue)); err != nil { - return nil, err - } - } else if match, csValue = getCredentialSpec("registry://", splitsOpt[1]); match { - if csValue == "" { - return nil, fmt.Errorf("no value supplied for registry:// credential spec security option") - } - if credentialsOpts.Credentials, err = readCredentialSpecRegistry(container.ID, csValue); err != nil { - return nil, err - } - } else { - return nil, fmt.Errorf("invalid credential spec security option - value must be prefixed file:// or registry:// followed by a value") - } - createOptions = append(createOptions, credentialsOpts) + if err := config.Validate(); err != nil { + return nil, err } - } - - // Now add the remaining options. - createOptions = append(createOptions, &libcontainerd.FlushOption{IgnoreFlushesDuringBoot: !container.HasBeenStartedBefore}) - createOptions = append(createOptions, hvOpts) - createOptions = append(createOptions, layerOpts) - - var networkSharedContainerID string - if container.HostConfig.NetworkMode.IsContainer() { - networkSharedContainerID = container.NetworkSharedContainerID - for _, ep := range container.SharedEndpointList { - epList = append(epList, ep) + lcowOpts := &libcontainerd.LCOWOption{ + Config: config, } + createOptions = append(createOptions, lcowOpts) } - createOptions = append(createOptions, &libcontainerd.NetworkEndpointsOption{ - Endpoints: epList, - AllowUnqualifiedDNSQuery: AllowUnqualifiedDNSQuery, - DNSSearchList: dnsSearch, - NetworkSharedContainerID: networkSharedContainerID, - }) return createOptions, nil } - -// getCredentialSpec is a helper function to get the value of a credential spec supplied -// on the CLI, stripping the prefix -func getCredentialSpec(prefix, value string) (bool, string) { - if strings.HasPrefix(value, prefix) { - return true, strings.TrimPrefix(value, prefix) - } - return false, "" -} - -// readCredentialSpecRegistry is a helper function to read a credential spec from -// the registry. If not found, we return an empty string and warn in the log. -// This allows for staging on machines which do not have the necessary components. -func readCredentialSpecRegistry(id, name string) (string, error) { - var ( - k registry.Key - err error - val string - ) - if k, err = registry.OpenKey(registry.LOCAL_MACHINE, credentialSpecRegistryLocation, registry.QUERY_VALUE); err != nil { - return "", fmt.Errorf("failed handling spec %q for container %s - %s could not be opened", name, id, credentialSpecRegistryLocation) - } - if val, _, err = k.GetStringValue(name); err != nil { - if err == registry.ErrNotExist { - return "", fmt.Errorf("credential spec %q for container %s as it was not found", name, id) - } - return "", fmt.Errorf("error %v reading credential spec %q from registry for container %s", err, name, id) - } - return val, nil -} - -// readCredentialSpecFile is a helper function to read a credential spec from -// a file. If not found, we return an empty string and warn in the log. -// This allows for staging on machines which do not have the necessary components. -func readCredentialSpecFile(id, root, location string) (string, error) { - if filepath.IsAbs(location) { - return "", fmt.Errorf("invalid credential spec - file:// path cannot be absolute") - } - base := filepath.Join(root, credentialSpecFileLocation) - full := filepath.Join(base, location) - if !strings.HasPrefix(full, base) { - return "", fmt.Errorf("invalid credential spec - file:// path must be under %s", base) - } - bcontents, err := ioutil.ReadFile(full) - if err != nil { - return "", fmt.Errorf("credential spec '%s' for container %s as the file could not be read: %q", full, id, err) - } - return string(bcontents[:]), nil -} diff --git a/vendor/github.com/docker/docker/daemon/stats/collector.go b/vendor/github.com/docker/docker/daemon/stats/collector.go index c06d80c17..c930bc756 100644 --- a/vendor/github.com/docker/docker/daemon/stats/collector.go +++ b/vendor/github.com/docker/docker/daemon/stats/collector.go @@ -113,10 +113,10 @@ func (s *Collector) Run() { type notRunningErr interface { error - ContainerIsRunning() bool + Conflict() } type notFoundErr interface { error - ContainerNotFound() bool + NotFound() } diff --git a/vendor/github.com/docker/docker/daemon/stats_unix.go b/vendor/github.com/docker/docker/daemon/stats_unix.go index d875607b3..4831b84ab 100644 --- a/vendor/github.com/docker/docker/daemon/stats_unix.go +++ b/vendor/github.com/docker/docker/daemon/stats_unix.go @@ -3,10 +3,9 @@ package daemon import ( - "fmt" - "github.com/docker/docker/api/types" "github.com/docker/docker/container" + "github.com/pkg/errors" ) // Resolve Network SandboxID in case the container reuse another container's network stack @@ -16,7 +15,7 @@ func (daemon *Daemon) getNetworkSandboxID(c *container.Container) (string, error containerID := curr.HostConfig.NetworkMode.ConnectedContainer() connected, err := daemon.GetContainer(containerID) if err != nil { - return "", fmt.Errorf("Could not get container for %s", containerID) + return "", errors.Wrapf(err, "Could not get container for %s", containerID) } curr = connected } diff --git a/vendor/github.com/docker/docker/daemon/stop.go b/vendor/github.com/docker/docker/daemon/stop.go index af3020eab..7eadba7e2 100644 --- a/vendor/github.com/docker/docker/daemon/stop.go +++ b/vendor/github.com/docker/docker/daemon/stop.go @@ -2,12 +2,10 @@ package daemon import ( "context" - "fmt" - "net/http" "time" - "github.com/docker/docker/api/errors" containerpkg "github.com/docker/docker/container" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -23,15 +21,14 @@ func (daemon *Daemon) ContainerStop(name string, seconds *int) error { return err } if !container.IsRunning() { - err := fmt.Errorf("Container %s is already stopped", name) - return errors.NewErrorWithStatusCode(err, http.StatusNotModified) + return containerNotModifiedError{running: false} } if seconds == nil { stopTimeout := container.StopTimeout() seconds = &stopTimeout } if err := daemon.containerStop(container, *seconds); err != nil { - return fmt.Errorf("Cannot stop container %s: %v", name, err) + return errors.Wrapf(systemError{err}, "cannot stop container: %s", name) } return nil } @@ -81,7 +78,7 @@ func (daemon *Daemon) containerStop(container *containerpkg.Container, seconds i // 3. If it doesn't, then send SIGKILL if err := daemon.Kill(container); err != nil { // Wait without a timeout, ignore result. - _ = <-container.Wait(context.Background(), containerpkg.WaitConditionNotRunning) + <-container.Wait(context.Background(), containerpkg.WaitConditionNotRunning) logrus.Warn(err) // Don't return error because we only care that container is stopped, not what function stopped it } } diff --git a/vendor/github.com/docker/docker/api/fixtures/keyfile b/vendor/github.com/docker/docker/daemon/testdata/keyfile similarity index 100% rename from vendor/github.com/docker/docker/api/fixtures/keyfile rename to vendor/github.com/docker/docker/daemon/testdata/keyfile diff --git a/vendor/github.com/docker/docker/daemon/top_unix.go b/vendor/github.com/docker/docker/daemon/top_unix.go index 4d94d4a62..22e88b702 100644 --- a/vendor/github.com/docker/docker/daemon/top_unix.go +++ b/vendor/github.com/docker/docker/daemon/top_unix.go @@ -16,6 +16,7 @@ func validatePSArgs(psArgs string) error { // NOTE: \\s does not detect unicode whitespaces. // So we use fieldsASCII instead of strings.Fields in parsePSOutput. // See https://github.com/docker/docker/pull/24358 + // nolint: gosimple re := regexp.MustCompile("\\s+([^\\s]*)=\\s*(PID[^\\s]*)") for _, group := range re.FindAllStringSubmatch(psArgs, -1) { if len(group) >= 3 { @@ -130,7 +131,7 @@ func (daemon *Daemon) ContainerTop(name string, psArgs string) (*container.Conta } if !container.IsRunning() { - return nil, errNotRunning{container.ID} + return nil, errNotRunning(container.ID) } if container.IsRestarting() { diff --git a/vendor/github.com/docker/docker/daemon/trustkey.go b/vendor/github.com/docker/docker/daemon/trustkey.go new file mode 100644 index 000000000..cb33146f9 --- /dev/null +++ b/vendor/github.com/docker/docker/daemon/trustkey.go @@ -0,0 +1,57 @@ +package daemon + +import ( + "encoding/json" + "encoding/pem" + "fmt" + "os" + "path/filepath" + + "github.com/docker/docker/pkg/ioutils" + "github.com/docker/docker/pkg/system" + "github.com/docker/libtrust" +) + +// LoadOrCreateTrustKey attempts to load the libtrust key at the given path, +// otherwise generates a new one +// TODO: this should use more of libtrust.LoadOrCreateTrustKey which may need +// a refactor or this function to be moved into libtrust +func loadOrCreateTrustKey(trustKeyPath string) (libtrust.PrivateKey, error) { + err := system.MkdirAll(filepath.Dir(trustKeyPath), 0700, "") + if err != nil { + return nil, err + } + trustKey, err := libtrust.LoadKeyFile(trustKeyPath) + if err == libtrust.ErrKeyFileDoesNotExist { + trustKey, err = libtrust.GenerateECP256PrivateKey() + if err != nil { + return nil, fmt.Errorf("Error generating key: %s", err) + } + encodedKey, err := serializePrivateKey(trustKey, filepath.Ext(trustKeyPath)) + if err != nil { + return nil, fmt.Errorf("Error serializing key: %s", err) + } + if err := ioutils.AtomicWriteFile(trustKeyPath, encodedKey, os.FileMode(0600)); err != nil { + return nil, fmt.Errorf("Error saving key file: %s", err) + } + } else if err != nil { + return nil, fmt.Errorf("Error loading key file %s: %s", trustKeyPath, err) + } + return trustKey, nil +} + +func serializePrivateKey(key libtrust.PrivateKey, ext string) (encoded []byte, err error) { + if ext == ".json" || ext == ".jwk" { + encoded, err = json.Marshal(key) + if err != nil { + return nil, fmt.Errorf("unable to encode private key JWK: %s", err) + } + } else { + pemBlock, err := key.PEMBlock() + if err != nil { + return nil, fmt.Errorf("unable to encode private key PEM: %s", err) + } + encoded = pem.EncodeToMemory(pemBlock) + } + return +} diff --git a/vendor/github.com/docker/docker/daemon/trustkey_test.go b/vendor/github.com/docker/docker/daemon/trustkey_test.go new file mode 100644 index 000000000..2ade2aa80 --- /dev/null +++ b/vendor/github.com/docker/docker/daemon/trustkey_test.go @@ -0,0 +1,72 @@ +package daemon + +import ( + "io/ioutil" + "os" + "path/filepath" + "testing" + + "github.com/docker/docker/internal/testutil" + "github.com/gotestyourself/gotestyourself/fs" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// LoadOrCreateTrustKey +func TestLoadOrCreateTrustKeyInvalidKeyFile(t *testing.T) { + tmpKeyFolderPath, err := ioutil.TempDir("", "api-trustkey-test") + require.NoError(t, err) + defer os.RemoveAll(tmpKeyFolderPath) + + tmpKeyFile, err := ioutil.TempFile(tmpKeyFolderPath, "keyfile") + require.NoError(t, err) + + _, err = loadOrCreateTrustKey(tmpKeyFile.Name()) + testutil.ErrorContains(t, err, "Error loading key file") +} + +func TestLoadOrCreateTrustKeyCreateKeyWhenFileDoesNotExist(t *testing.T) { + tmpKeyFolderPath := fs.NewDir(t, "api-trustkey-test") + defer tmpKeyFolderPath.Remove() + + // Without the need to create the folder hierarchy + tmpKeyFile := tmpKeyFolderPath.Join("keyfile") + + key, err := loadOrCreateTrustKey(tmpKeyFile) + require.NoError(t, err) + assert.NotNil(t, key) + + _, err = os.Stat(tmpKeyFile) + require.NoError(t, err, "key file doesn't exist") +} + +func TestLoadOrCreateTrustKeyCreateKeyWhenDirectoryDoesNotExist(t *testing.T) { + tmpKeyFolderPath := fs.NewDir(t, "api-trustkey-test") + defer tmpKeyFolderPath.Remove() + tmpKeyFile := tmpKeyFolderPath.Join("folder/hierarchy/keyfile") + + key, err := loadOrCreateTrustKey(tmpKeyFile) + require.NoError(t, err) + assert.NotNil(t, key) + + _, err = os.Stat(tmpKeyFile) + require.NoError(t, err, "key file doesn't exist") +} + +func TestLoadOrCreateTrustKeyCreateKeyNoPath(t *testing.T) { + defer os.Remove("keyfile") + key, err := loadOrCreateTrustKey("keyfile") + require.NoError(t, err) + assert.NotNil(t, key) + + _, err = os.Stat("keyfile") + require.NoError(t, err, "key file doesn't exist") +} + +func TestLoadOrCreateTrustKeyLoadValidKey(t *testing.T) { + tmpKeyFile := filepath.Join("testdata", "keyfile") + key, err := loadOrCreateTrustKey(tmpKeyFile) + require.NoError(t, err) + expected := "AWX2:I27X:WQFX:IOMK:CNAK:O7PW:VYNB:ZLKC:CVAE:YJP2:SI4A:XXAY" + assert.Contains(t, key.String(), expected) +} diff --git a/vendor/github.com/docker/docker/daemon/update.go b/vendor/github.com/docker/docker/daemon/update.go index a65cbd51b..42d732f26 100644 --- a/vendor/github.com/docker/docker/daemon/update.go +++ b/vendor/github.com/docker/docker/daemon/update.go @@ -4,17 +4,23 @@ import ( "fmt" "github.com/docker/docker/api/types/container" + "github.com/pkg/errors" ) // ContainerUpdate updates configuration of the container func (daemon *Daemon) ContainerUpdate(name string, hostConfig *container.HostConfig) (container.ContainerUpdateOKBody, error) { var warnings []string - warnings, err := daemon.verifyContainerSettings(hostConfig, nil, true) + c, err := daemon.GetContainer(name) if err != nil { return container.ContainerUpdateOKBody{Warnings: warnings}, err } + warnings, err = daemon.verifyContainerSettings(c.Platform, hostConfig, nil, true) + if err != nil { + return container.ContainerUpdateOKBody{Warnings: warnings}, validationError{err} + } + if err := daemon.update(name, hostConfig); err != nil { return container.ContainerUpdateOKBody{Warnings: warnings}, err } @@ -44,7 +50,7 @@ func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) erro }() if container.RemovalInProgress || container.Dead { - return errCannotUpdate(container.ID, fmt.Errorf("Container is marked for removal and cannot be \"update\".")) + return errCannotUpdate(container.ID, fmt.Errorf("container is marked for removal and cannot be \"update\"")) } container.Lock() @@ -72,7 +78,8 @@ func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) erro if container.IsRunning() && !container.IsRestarting() { if err := daemon.containerd.UpdateResources(container.ID, toContainerdResources(hostConfig.Resources)); err != nil { restoreConfig = true - return errCannotUpdate(container.ID, err) + // TODO: it would be nice if containerd responded with better errors here so we can classify this better. + return errCannotUpdate(container.ID, systemError{err}) } } @@ -82,5 +89,5 @@ func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) erro } func errCannotUpdate(containerID string, err error) error { - return fmt.Errorf("Cannot update container %s: %v", containerID, err) + return errors.Wrap(err, "Cannot update container "+containerID) } diff --git a/vendor/github.com/docker/docker/daemon/volumes.go b/vendor/github.com/docker/docker/daemon/volumes.go index c2372ef57..d5d31b260 100644 --- a/vendor/github.com/docker/docker/daemon/volumes.go +++ b/vendor/github.com/docker/docker/daemon/volumes.go @@ -1,7 +1,6 @@ package daemon import ( - "errors" "fmt" "os" "path/filepath" @@ -9,13 +8,13 @@ import ( "strings" "time" - dockererrors "github.com/docker/docker/api/errors" "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" mounttypes "github.com/docker/docker/api/types/mount" "github.com/docker/docker/container" "github.com/docker/docker/volume" "github.com/docker/docker/volume/drivers" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -76,6 +75,7 @@ func (m mounts) parts(i int) int { func (daemon *Daemon) registerMountPoints(container *container.Container, hostConfig *containertypes.HostConfig) (retErr error) { binds := map[string]bool{} mountPoints := map[string]*volume.MountPoint{} + parser := volume.NewParser(container.Platform) defer func() { // clean up the container mountpoints once return with error if retErr != nil { @@ -104,7 +104,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo // 2. Read volumes from other containers. for _, v := range hostConfig.VolumesFrom { - containerID, mode, err := volume.ParseVolumesFrom(v) + containerID, mode, err := parser.ParseVolumesFrom(v) if err != nil { return err } @@ -119,7 +119,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo Type: m.Type, Name: m.Name, Source: m.Source, - RW: m.RW && volume.ReadWrite(mode), + RW: m.RW && parser.ReadWrite(mode), Driver: m.Driver, Destination: m.Destination, Propagation: m.Propagation, @@ -141,7 +141,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo // 3. Read bind mounts for _, b := range hostConfig.Binds { - bind, err := volume.ParseMountRaw(b, hostConfig.VolumeDriver) + bind, err := parser.ParseMountRaw(b, hostConfig.VolumeDriver) if err != nil { return err } @@ -149,7 +149,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo // #10618 _, tmpfsExists := hostConfig.Tmpfs[bind.Destination] if binds[bind.Destination] || tmpfsExists { - return fmt.Errorf("Duplicate mount point '%s'", bind.Destination) + return duplicateMountPointError(bind.Destination) } if bind.Type == mounttypes.TypeVolume { @@ -173,13 +173,13 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo } for _, cfg := range hostConfig.Mounts { - mp, err := volume.ParseMountSpec(cfg) + mp, err := parser.ParseMountSpec(cfg) if err != nil { - return dockererrors.NewBadRequestError(err) + return validationError{err} } if binds[mp.Destination] { - return fmt.Errorf("Duplicate mount point '%s'", cfg.Target) + return duplicateMountPointError(cfg.Target) } if mp.Type == mounttypes.TypeVolume { @@ -207,6 +207,9 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo }); ok { mp.Source = cv.CachedPath() } + if mp.Driver == volume.DefaultDriverName { + setBindModeIfNull(mp) + } } binds[mp.Destination] = true @@ -218,7 +221,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo // 4. Cleanup old volumes that are about to be reassigned. for _, m := range mountPoints { - if m.BackwardsCompatible() { + if parser.IsBackwardCompatible(m) { if mp, exists := container.MountPoints[m.Destination]; exists && mp.Volume != nil { daemon.volumes.Dereference(mp.Volume, container.ID) } @@ -253,6 +256,8 @@ func (daemon *Daemon) backportMountSpec(container *container.Container) { container.Lock() defer container.Unlock() + parser := volume.NewParser(container.Platform) + maybeUpdate := make(map[string]bool) for _, mp := range container.MountPoints { if mp.Spec.Source != "" && mp.Type != "" { @@ -271,7 +276,7 @@ func (daemon *Daemon) backportMountSpec(container *container.Container) { binds := make(map[string]*volume.MountPoint, len(container.HostConfig.Binds)) for _, rawSpec := range container.HostConfig.Binds { - mp, err := volume.ParseMountRaw(rawSpec, container.HostConfig.VolumeDriver) + mp, err := parser.ParseMountRaw(rawSpec, container.HostConfig.VolumeDriver) if err != nil { logrus.WithError(err).Error("Got unexpected error while re-parsing raw volume spec during spec backport") continue @@ -281,7 +286,7 @@ func (daemon *Daemon) backportMountSpec(container *container.Container) { volumesFrom := make(map[string]volume.MountPoint) for _, fromSpec := range container.HostConfig.VolumesFrom { - from, _, err := volume.ParseVolumesFrom(fromSpec) + from, _, err := parser.ParseVolumesFrom(fromSpec) if err != nil { logrus.WithError(err).WithField("id", container.ID).Error("Error reading volumes-from spec during mount spec backport") continue diff --git a/vendor/github.com/docker/docker/daemon/volumes_unit_test.go b/vendor/github.com/docker/docker/daemon/volumes_unit_test.go index 450d17f97..3f57f0cee 100644 --- a/vendor/github.com/docker/docker/daemon/volumes_unit_test.go +++ b/vendor/github.com/docker/docker/daemon/volumes_unit_test.go @@ -1,6 +1,7 @@ package daemon import ( + "runtime" "testing" "github.com/docker/docker/volume" @@ -20,8 +21,10 @@ func TestParseVolumesFrom(t *testing.T) { {"foobar:baz", "", "", true}, } + parser := volume.NewParser(runtime.GOOS) + for _, c := range cases { - id, mode, err := volume.ParseVolumesFrom(c.spec) + id, mode, err := parser.ParseVolumesFrom(c.spec) if c.fail { if err == nil { t.Fatalf("Expected error, was nil, for spec %s\n", c.spec) diff --git a/vendor/github.com/docker/docker/distribution/errors.go b/vendor/github.com/docker/docker/distribution/errors.go index 0e4942d6a..dd6ff0a9a 100644 --- a/vendor/github.com/docker/docker/distribution/errors.go +++ b/vendor/github.com/docker/docker/distribution/errors.go @@ -1,6 +1,7 @@ package distribution import ( + "fmt" "net/url" "strings" "syscall" @@ -12,7 +13,6 @@ import ( "github.com/docker/distribution/registry/client" "github.com/docker/distribution/registry/client/auth" "github.com/docker/docker/distribution/xfer" - "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -60,6 +60,45 @@ func shouldV2Fallback(err errcode.Error) bool { return false } +type notFoundError struct { + cause errcode.Error + ref reference.Named +} + +func (e notFoundError) Error() string { + switch e.cause.Code { + case errcode.ErrorCodeDenied: + // ErrorCodeDenied is used when access to the repository was denied + return fmt.Sprintf("pull access denied for %s, repository does not exist or may require 'docker login'", reference.FamiliarName(e.ref)) + case v2.ErrorCodeManifestUnknown: + return fmt.Sprintf("manifest for %s not found", reference.FamiliarString(e.ref)) + case v2.ErrorCodeNameUnknown: + return fmt.Sprintf("repository %s not found", reference.FamiliarName(e.ref)) + } + // Shouldn't get here, but this is better than returning an empty string + return e.cause.Message +} + +func (e notFoundError) NotFound() {} + +func (e notFoundError) Cause() error { + return e.cause +} + +type unknownError struct { + cause error +} + +func (e unknownError) Error() string { + return e.cause.Error() +} + +func (e unknownError) Cause() error { + return e.cause +} + +func (e unknownError) Unknown() {} + // TranslatePullError is used to convert an error from a registry pull // operation to an error representing the entire pull operation. Any error // information which is not used by the returned error gets output to @@ -74,25 +113,15 @@ func TranslatePullError(err error, ref reference.Named) error { return TranslatePullError(v[0], ref) } case errcode.Error: - var newErr error switch v.Code { - case errcode.ErrorCodeDenied: - // ErrorCodeDenied is used when access to the repository was denied - newErr = errors.Errorf("pull access denied for %s, repository does not exist or may require 'docker login'", reference.FamiliarName(ref)) - case v2.ErrorCodeManifestUnknown: - newErr = errors.Errorf("manifest for %s not found", reference.FamiliarString(ref)) - case v2.ErrorCodeNameUnknown: - newErr = errors.Errorf("repository %s not found", reference.FamiliarName(ref)) - } - if newErr != nil { - logrus.Infof("Translating %q to %q", err, newErr) - return newErr + case errcode.ErrorCodeDenied, v2.ErrorCodeManifestUnknown, v2.ErrorCodeNameUnknown: + return notFoundError{v, ref} } case xfer.DoNotRetry: return TranslatePullError(v.Err, ref) } - return err + return unknownError{err} } // continueOnError returns true if we should fallback to the next endpoint @@ -157,3 +186,30 @@ func retryOnError(err error) error { // add them to the switch above. return err } + +type invalidManifestClassError struct { + mediaType string + class string +} + +func (e invalidManifestClassError) Error() string { + return fmt.Sprintf("Encountered remote %q(%s) when fetching", e.mediaType, e.class) +} + +func (e invalidManifestClassError) InvalidParameter() {} + +type invalidManifestFormatError struct{} + +func (invalidManifestFormatError) Error() string { + return "unsupported manifest format" +} + +func (invalidManifestFormatError) InvalidParameter() {} + +type reservedNameError string + +func (e reservedNameError) Error() string { + return "'" + string(e) + "' is a reserved name" +} + +func (e reservedNameError) Forbidden() {} diff --git a/vendor/github.com/docker/docker/distribution/metadata/v2_metadata_service.go b/vendor/github.com/docker/docker/distribution/metadata/v2_metadata_service.go index 7524f63ce..af599be04 100644 --- a/vendor/github.com/docker/docker/distribution/metadata/v2_metadata_service.go +++ b/vendor/github.com/docker/docker/distribution/metadata/v2_metadata_service.go @@ -84,7 +84,7 @@ func ComputeV2MetadataHMACKey(authConfig *types.AuthConfig) ([]byte, error) { if err != nil { return nil, err } - return []byte(digest.FromBytes([]byte(buf))), nil + return []byte(digest.FromBytes(buf)), nil } // authConfigKeyInput is a reduced AuthConfig structure holding just relevant credential data eligible for diff --git a/vendor/github.com/docker/docker/distribution/pull.go b/vendor/github.com/docker/docker/distribution/pull.go index 690551c84..68144df79 100644 --- a/vendor/github.com/docker/docker/distribution/pull.go +++ b/vendor/github.com/docker/docker/distribution/pull.go @@ -10,6 +10,7 @@ import ( refstore "github.com/docker/docker/reference" "github.com/docker/docker/registry" "github.com/opencontainers/go-digest" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/net/context" ) @@ -173,7 +174,7 @@ func writeStatus(requestedTag string, out progress.Output, layersDownloaded bool // ValidateRepoName validates the name of a repository. func ValidateRepoName(name reference.Named) error { if reference.FamiliarName(name) == api.NoBaseImageSpecifier { - return fmt.Errorf("'%s' is a reserved name", api.NoBaseImageSpecifier) + return errors.WithStack(reservedNameError(api.NoBaseImageSpecifier)) } return nil } diff --git a/vendor/github.com/docker/docker/distribution/pull_v1.go b/vendor/github.com/docker/docker/distribution/pull_v1.go index eb6214642..19a8792a4 100644 --- a/vendor/github.com/docker/docker/distribution/pull_v1.go +++ b/vendor/github.com/docker/docker/distribution/pull_v1.go @@ -52,11 +52,7 @@ func (p *v1Puller) Pull(ctx context.Context, ref reference.Named) error { registry.DockerHeaders(dockerversion.DockerUserAgent(ctx), p.config.MetaHeaders)..., ) client := registry.HTTPClient(tr) - v1Endpoint, err := p.endpoint.ToV1Endpoint(dockerversion.DockerUserAgent(ctx), p.config.MetaHeaders) - if err != nil { - logrus.Debugf("Could not get v1 endpoint: %v", err) - return fallbackError{err: err} - } + v1Endpoint := p.endpoint.ToV1Endpoint(dockerversion.DockerUserAgent(ctx), p.config.MetaHeaders) p.session, err = registry.NewSession(client, p.config.AuthConfig, v1Endpoint) if err != nil { // TODO(dmcgowan): Check if should fallback diff --git a/vendor/github.com/docker/docker/distribution/pull_v2.go b/vendor/github.com/docker/docker/distribution/pull_v2.go index 713e9b7da..39bf78249 100644 --- a/vendor/github.com/docker/docker/distribution/pull_v2.go +++ b/vendor/github.com/docker/docker/distribution/pull_v2.go @@ -2,7 +2,6 @@ package distribution import ( "encoding/json" - "errors" "fmt" "io" "io/ioutil" @@ -29,7 +28,8 @@ import ( "github.com/docker/docker/pkg/system" refstore "github.com/docker/docker/reference" "github.com/docker/docker/registry" - "github.com/opencontainers/go-digest" + digest "github.com/opencontainers/go-digest" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/net/context" ) @@ -368,7 +368,7 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named) (tagUpdat if configClass == "" { configClass = "unknown" } - return false, fmt.Errorf("Encountered remote %q(%s) when fetching", m.Manifest.Config.MediaType, configClass) + return false, invalidManifestClassError{m.Manifest.Config.MediaType, configClass} } } @@ -404,7 +404,7 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named) (tagUpdat return false, err } default: - return false, errors.New("unsupported manifest format") + return false, invalidManifestFormatError{} } progress.Message(p.config.ProgressOutput, "", "Digest: "+manifestDigest.String()) @@ -435,7 +435,7 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named) (tagUpdat return true, nil } -func (p *v2Puller) pullSchema1(ctx context.Context, ref reference.Named, unverifiedManifest *schema1.SignedManifest) (id digest.Digest, manifestDigest digest.Digest, err error) { +func (p *v2Puller) pullSchema1(ctx context.Context, ref reference.Reference, unverifiedManifest *schema1.SignedManifest) (id digest.Digest, manifestDigest digest.Digest, err error) { var verifiedManifest *schema1.Manifest verifiedManifest, err = verifySchema1Manifest(unverifiedManifest, ref) if err != nil { @@ -709,11 +709,16 @@ func (p *v2Puller) pullManifestList(ctx context.Context, ref reference.Named, mf logrus.Debugf("%s resolved to a manifestList object with %d entries; looking for a os/arch match", ref, len(mfstList.Manifests)) var manifestDigest digest.Digest + // TODO @jhowardmsft LCOW Support: Need to remove the hard coding in LCOW mode. + lookingForOS := runtime.GOOS + if system.LCOWSupported() { + lookingForOS = "linux" + } for _, manifestDescriptor := range mfstList.Manifests { // TODO(aaronl): The manifest list spec supports optional // "features" and "variant" fields. These are not yet used. // Once they are, their values should be interpreted here. - if manifestDescriptor.Platform.Architecture == runtime.GOARCH && manifestDescriptor.Platform.OS == runtime.GOOS { + if manifestDescriptor.Platform.Architecture == runtime.GOARCH && manifestDescriptor.Platform.OS == lookingForOS { manifestDigest = manifestDescriptor.Digest logrus.Debugf("found match for %s/%s with media type %s, digest %s", runtime.GOOS, runtime.GOARCH, manifestDescriptor.MediaType, manifestDigest.String()) break @@ -838,7 +843,7 @@ func allowV1Fallback(err error) error { return err } -func verifySchema1Manifest(signedManifest *schema1.SignedManifest, ref reference.Named) (m *schema1.Manifest, err error) { +func verifySchema1Manifest(signedManifest *schema1.SignedManifest, ref reference.Reference) (m *schema1.Manifest, err error) { // If pull by digest, then verify the manifest digest. NOTE: It is // important to do this first, before any other content validation. If the // digest cannot be verified, don't even bother with those other things. @@ -908,7 +913,7 @@ func fixManifestLayers(m *schema1.Manifest) error { m.FSLayers = append(m.FSLayers[:i], m.FSLayers[i+1:]...) m.History = append(m.History[:i], m.History[i+1:]...) } else if imgs[i].Parent != imgs[i+1].ID { - return fmt.Errorf("Invalid parent ID. Expected %v, got %v.", imgs[i+1].ID, imgs[i].Parent) + return fmt.Errorf("invalid parent ID. Expected %v, got %v", imgs[i+1].ID, imgs[i].Parent) } } diff --git a/vendor/github.com/docker/docker/distribution/pull_v2_test.go b/vendor/github.com/docker/docker/distribution/pull_v2_test.go index df93c1ef8..7355fb96e 100644 --- a/vendor/github.com/docker/docker/distribution/pull_v2_test.go +++ b/vendor/github.com/docker/docker/distribution/pull_v2_test.go @@ -10,6 +10,7 @@ import ( "github.com/docker/distribution/manifest/schema1" "github.com/docker/distribution/reference" + "github.com/docker/docker/internal/testutil" "github.com/opencontainers/go-digest" ) @@ -102,9 +103,8 @@ func TestFixManifestLayersBadParent(t *testing.T) { }, } - if err := fixManifestLayers(&duplicateLayerManifest); err == nil || !strings.Contains(err.Error(), "Invalid parent ID.") { - t.Fatalf("expected an invalid parent ID error from fixManifestLayers") - } + err := fixManifestLayers(&duplicateLayerManifest) + testutil.ErrorContains(t, err, "invalid parent ID") } // TestValidateManifest verifies the validateManifest function diff --git a/vendor/github.com/docker/docker/distribution/push_v1.go b/vendor/github.com/docker/docker/distribution/push_v1.go index 4da4d5eac..6cc4f1588 100644 --- a/vendor/github.com/docker/docker/distribution/push_v1.go +++ b/vendor/github.com/docker/docker/distribution/push_v1.go @@ -41,11 +41,7 @@ func (p *v1Pusher) Push(ctx context.Context) error { registry.DockerHeaders(dockerversion.DockerUserAgent(ctx), p.config.MetaHeaders)..., ) client := registry.HTTPClient(tr) - v1Endpoint, err := p.endpoint.ToV1Endpoint(dockerversion.DockerUserAgent(ctx), p.config.MetaHeaders) - if err != nil { - logrus.Debugf("Could not get v1 endpoint: %v", err) - return fallbackError{err: err} - } + v1Endpoint := p.endpoint.ToV1Endpoint(dockerversion.DockerUserAgent(ctx), p.config.MetaHeaders) p.session, err = registry.NewSession(client, p.config.AuthConfig, v1Endpoint) if err != nil { // TODO(dmcgowan): Check if should fallback diff --git a/vendor/github.com/docker/docker/distribution/push_v2.go b/vendor/github.com/docker/docker/distribution/push_v2.go index 3d32061e8..1dfa881b4 100644 --- a/vendor/github.com/docker/docker/distribution/push_v2.go +++ b/vendor/github.com/docker/docker/distribution/push_v2.go @@ -24,7 +24,7 @@ import ( "github.com/docker/docker/pkg/progress" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/registry" - "github.com/opencontainers/go-digest" + digest "github.com/opencontainers/go-digest" "github.com/sirupsen/logrus" ) @@ -395,12 +395,7 @@ func (pd *v2PushDescriptor) Upload(ctx context.Context, progressOutput progress. defer layerUpload.Close() // upload the blob - desc, err := pd.uploadUsingSession(ctx, progressOutput, diffID, layerUpload) - if err != nil { - return desc, err - } - - return desc, nil + return pd.uploadUsingSession(ctx, progressOutput, diffID, layerUpload) } func (pd *v2PushDescriptor) SetRemoteDescriptor(descriptor distribution.Descriptor) { @@ -651,6 +646,7 @@ func (bla byLikeness) Swap(i, j int) { } func (bla byLikeness) Len() int { return len(bla.arr) } +// nolint: interfacer func sortV2MetadataByLikenessAndAge(repoInfo reference.Named, hmacKey []byte, marr []metadata.V2Metadata) { // reverse the metadata array to shift the newest entries to the beginning for i := 0; i < len(marr)/2; i++ { diff --git a/vendor/github.com/docker/docker/distribution/registry_unit_test.go b/vendor/github.com/docker/docker/distribution/registry_unit_test.go index d6b6ee883..9653f29c0 100644 --- a/vendor/github.com/docker/docker/distribution/registry_unit_test.go +++ b/vendor/github.com/docker/docker/distribution/registry_unit_test.go @@ -1,21 +1,15 @@ package distribution import ( - "fmt" - "io/ioutil" "net/http" "net/http/httptest" "net/url" - "os" - "runtime" "strings" "testing" "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" registrytypes "github.com/docker/docker/api/types/registry" - "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/registry" "github.com/sirupsen/logrus" "golang.org/x/net/context" @@ -42,12 +36,6 @@ func (h *tokenPassThruHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) } func testTokenPassThru(t *testing.T, ts *httptest.Server) { - tmp, err := testDirectory("") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tmp) - uri, err := url.Parse(ts.URL) if err != nil { t.Fatalf("could not parse url from test server: %v", err) @@ -137,36 +125,3 @@ func TestTokenPassThruDifferentHost(t *testing.T) { t.Fatal("Redirect should not forward Authorization header to another host") } } - -// testDirectory creates a new temporary directory and returns its path. -// The contents of directory at path `templateDir` is copied into the -// new directory. -func testDirectory(templateDir string) (dir string, err error) { - testID := stringid.GenerateNonCryptoID()[:4] - prefix := fmt.Sprintf("docker-test%s-%s-", testID, getCallerName(2)) - if prefix == "" { - prefix = "docker-test-" - } - dir, err = ioutil.TempDir("", prefix) - if err = os.Remove(dir); err != nil { - return - } - if templateDir != "" { - if err = archive.NewDefaultArchiver().CopyWithTar(templateDir, dir); err != nil { - return - } - } - return -} - -// getCallerName introspects the call stack and returns the name of the -// function `depth` levels down in the stack. -func getCallerName(depth int) string { - // Use the caller function name as a prefix. - // This helps trace temp directories back to their test. - pc, _, _, _ := runtime.Caller(depth + 1) - callerLongName := runtime.FuncForPC(pc).Name() - parts := strings.Split(callerLongName, ".") - callerShortName := parts[len(parts)-1] - return callerShortName -} diff --git a/vendor/github.com/docker/docker/docs/api/v1.18.md b/vendor/github.com/docker/docker/docs/api/v1.18.md index 3c82371b4..973dca9f9 100644 --- a/vendor/github.com/docker/docker/docs/api/v1.18.md +++ b/vendor/github.com/docker/docker/docs/api/v1.18.md @@ -232,11 +232,11 @@ Create a container - **ExposedPorts** - An object mapping ports to an empty object in the form of: `"ExposedPorts": { "/: {}" }` - **HostConfig** - - **Binds** – A list of bind-mounts for this container. Each item is a string in one of these forms: + - **Binds** – A list of bind mounts for this container. Each item is a string in one of these forms: + `host-src:container-dest` to bind-mount a host path into the container. Both `host-src`, and `container-dest` must be an _absolute_ path. - + `host-src:container-dest:ro` to make the bind-mount read-only + + `host-src:container-dest:ro` to make the bind mount read-only inside the container. Both `host-src`, and `container-dest` must be an _absolute_ path. - **Links** - A list of links for the container. Each link entry should be diff --git a/vendor/github.com/docker/docker/docs/api/v1.19.md b/vendor/github.com/docker/docker/docs/api/v1.19.md index bd5f09f67..3bcf7668f 100644 --- a/vendor/github.com/docker/docker/docs/api/v1.19.md +++ b/vendor/github.com/docker/docker/docs/api/v1.19.md @@ -239,11 +239,11 @@ Create a container - **ExposedPorts** - An object mapping ports to an empty object in the form of: `"ExposedPorts": { "/: {}" }` - **HostConfig** - - **Binds** – A list of bind-mounts for this container. Each item is a string in one of these forms: + - **Binds** – A list of bind mounts for this container. Each item is a string in one of these forms: + `host-src:container-dest` to bind-mount a host path into the container. Both `host-src`, and `container-dest` must be an _absolute_ path. - + `host-src:container-dest:ro` to make the bind-mount read-only + + `host-src:container-dest:ro` to make the bind mount read-only inside the container. Both `host-src`, and `container-dest` must be an _absolute_ path. - **Links** - A list of links for the container. Each link entry should be diff --git a/vendor/github.com/docker/docker/docs/api/v1.20.md b/vendor/github.com/docker/docker/docs/api/v1.20.md index a7fc999ae..e5b8f32fc 100644 --- a/vendor/github.com/docker/docker/docs/api/v1.20.md +++ b/vendor/github.com/docker/docker/docs/api/v1.20.md @@ -239,11 +239,11 @@ Create a container - **ExposedPorts** - An object mapping ports to an empty object in the form of: `"ExposedPorts": { "/: {}" }` - **HostConfig** - - **Binds** – A list of bind-mounts for this container. Each item is a string in one of these forms: + - **Binds** – A list of bind mounts for this container. Each item is a string in one of these forms: + `host-src:container-dest` to bind-mount a host path into the container. Both `host-src`, and `container-dest` must be an _absolute_ path. - + `host-src:container-dest:ro` to make the bind-mount read-only + + `host-src:container-dest:ro` to make the bind mount read-only inside the container. Both `host-src`, and `container-dest` must be an _absolute_ path. - **Links** - A list of links for the container. Each link entry should be diff --git a/vendor/github.com/docker/docker/docs/api/v1.21.md b/vendor/github.com/docker/docker/docs/api/v1.21.md index 1d42fd0ec..f1863b8c1 100644 --- a/vendor/github.com/docker/docker/docs/api/v1.21.md +++ b/vendor/github.com/docker/docker/docs/api/v1.21.md @@ -255,7 +255,7 @@ Create a container + `host-src:container-dest` to bind-mount a host path into the container. Both `host-src`, and `container-dest` must be an _absolute_ path. - + `host-src:container-dest:ro` to make the bind-mount read-only + + `host-src:container-dest:ro` to make the bind mount read-only inside the container. Both `host-src`, and `container-dest` must be an _absolute_ path. + `volume-name:container-dest` to bind-mount a volume managed by a diff --git a/vendor/github.com/docker/docker/docs/api/v1.22.md b/vendor/github.com/docker/docker/docs/api/v1.22.md index 9bf64b7e9..473ffd3c9 100644 --- a/vendor/github.com/docker/docker/docs/api/v1.22.md +++ b/vendor/github.com/docker/docker/docs/api/v1.22.md @@ -357,7 +357,7 @@ Create a container + `host-src:container-dest` to bind-mount a host path into the container. Both `host-src`, and `container-dest` must be an _absolute_ path. - + `host-src:container-dest:ro` to make the bind-mount read-only + + `host-src:container-dest:ro` to make the bind mount read-only inside the container. Both `host-src`, and `container-dest` must be an _absolute_ path. + `volume-name:container-dest` to bind-mount a volume managed by a diff --git a/vendor/github.com/docker/docker/docs/api/v1.23.md b/vendor/github.com/docker/docker/docs/api/v1.23.md index 508a721c7..c040d2460 100644 --- a/vendor/github.com/docker/docker/docs/api/v1.23.md +++ b/vendor/github.com/docker/docker/docs/api/v1.23.md @@ -382,7 +382,7 @@ Create a container + `host-src:container-dest` to bind-mount a host path into the container. Both `host-src`, and `container-dest` must be an _absolute_ path. - + `host-src:container-dest:ro` to make the bind-mount read-only + + `host-src:container-dest:ro` to make the bind mount read-only inside the container. Both `host-src`, and `container-dest` must be an _absolute_ path. + `volume-name:container-dest` to bind-mount a volume managed by a diff --git a/vendor/github.com/docker/docker/docs/api/v1.24.md b/vendor/github.com/docker/docker/docs/api/v1.24.md index d07ea84b3..29fed46a2 100644 --- a/vendor/github.com/docker/docker/docs/api/v1.24.md +++ b/vendor/github.com/docker/docker/docs/api/v1.24.md @@ -414,7 +414,7 @@ Create a container + `host-src:container-dest` to bind-mount a host path into the container. Both `host-src`, and `container-dest` must be an _absolute_ path. - + `host-src:container-dest:ro` to make the bind-mount read-only + + `host-src:container-dest:ro` to make the bind mount read-only inside the container. Both `host-src`, and `container-dest` must be an _absolute_ path. + `volume-name:container-dest` to bind-mount a volume managed by a diff --git a/vendor/github.com/docker/docker/docs/api/version-history.md b/vendor/github.com/docker/docker/docs/api/version-history.md index 4fed59bf2..6921e1eec 100644 --- a/vendor/github.com/docker/docker/docs/api/version-history.md +++ b/vendor/github.com/docker/docker/docs/api/version-history.md @@ -17,6 +17,9 @@ keywords: "API, Docker, rcli, REST, documentation" [Docker Engine API v1.32](https://docs.docker.com/engine/api/v1.32/) documentation +* `POST /containers/create` now accepts additional values for the + `HostConfig.IpcMode` property. New values are `private`, `shareable`, + and `none`. ## v1.31 API changes @@ -67,8 +70,8 @@ keywords: "API, Docker, rcli, REST, documentation" * `POST /containers/(name)/wait` now accepts a `condition` query parameter to indicate which state change condition to wait for. Also, response headers are now returned immediately to acknowledge that the server has registered a wait callback for the client. * `POST /swarm/init` now accepts a `DataPathAddr` property to set the IP-address or network interface to use for data traffic * `POST /swarm/join` now accepts a `DataPathAddr` property to set the IP-address or network interface to use for data traffic -* `GET /events` now supports service, node and secret events which are emmited when users create, update and remove service, node and secret -* `GET /events` now supports network remove event which is emmitted when users remove a swarm scoped network +* `GET /events` now supports service, node and secret events which are emitted when users create, update and remove service, node and secret +* `GET /events` now supports network remove event which is emitted when users remove a swarm scoped network * `GET /events` now supports a filter type `scope` in which supported value could be swarm and local ## v1.29 API changes diff --git a/vendor/github.com/docker/docker/hack/README.md b/vendor/github.com/docker/docker/hack/README.md index 802395d53..9e588db25 100644 --- a/vendor/github.com/docker/docker/hack/README.md +++ b/vendor/github.com/docker/docker/hack/README.md @@ -37,14 +37,14 @@ More information is found within `make.ps1` by the author, @jhowardmsft - Referenced via `make test` when running tests on a local machine, or directly referenced when running tests inside a Docker development container. - When running on a local machine, `make test` to run all tests found in -`test`, `test-unit`, `test-integration-cli`, and `test-docker-py` on +`test`, `test-unit`, `test-integration`, and `test-docker-py` on your local machine. The default timeout is set in `make.sh` to 60 minutes (`${TIMEOUT:=60m}`), since it currently takes up to an hour to run all of the tests. - When running inside a Docker development container, `hack/make.sh` does not have a single target that runs all the tests. You need to provide a single command line with multiple targets that performs the same thing. -An example referenced from [Run targets inside a development container](https://docs.docker.com/opensource/project/test-and-docs/#run-targets-inside-a-development-container): `root@5f8630b873fe:/go/src/github.com/moby/moby# hack/make.sh dynbinary binary cross test-unit test-integration-cli test-docker-py` +An example referenced from [Run targets inside a development container](https://docs.docker.com/opensource/project/test-and-docs/#run-targets-inside-a-development-container): `root@5f8630b873fe:/go/src/github.com/moby/moby# hack/make.sh dynbinary binary cross test-unit test-integration test-docker-py` - For more information related to testing outside the scope of this README, refer to [Run tests and test documentation](https://docs.docker.com/opensource/project/test-and-docs/) diff --git a/vendor/github.com/docker/docker/hack/dockerfile/binaries-commits b/vendor/github.com/docker/docker/hack/dockerfile/binaries-commits index 84c5c0faa..4338a3b48 100644 --- a/vendor/github.com/docker/docker/hack/dockerfile/binaries-commits +++ b/vendor/github.com/docker/docker/hack/dockerfile/binaries-commits @@ -3,12 +3,11 @@ TOMLV_COMMIT=9baf8a8a9f2ed20a8e54160840c492f937eeaf9a # When updating RUNC_COMMIT, also update runc in vendor.conf accordingly -RUNC_COMMIT=2d41c047c83e09a6d61d464906feb2a2f3c52aa4 -CONTAINERD_COMMIT=3addd840653146c90a254301d6c3a663c7fd6429 +RUNC_COMMIT=1c81e2a794c6e26a4c650142ae8893c47f619764 +CONTAINERD_COMMIT=06b9cb35161009dcb7123345749fef02f7cea8e0 TINI_COMMIT=949e6facb77383876aeff8a6944dde66b3089574 LIBNETWORK_COMMIT=7b2b1feb1de4817d522cc372af149ff48d25028e VNDR_COMMIT=9909bb2b8a0b7ea464527b376dc50389c90df587 -# CLI -DOCKERCLI_REPO=https://github.com/docker/cli -DOCKERCLI_COMMIT=3dfb8343b139d6342acfd9975d7f1068b5b1c3d3 +# Linting +GOMETALINTER_COMMIT=bfcc1d6942136fd86eb6f1a6fb328de8398fbd80 diff --git a/vendor/github.com/docker/docker/hack/dockerfile/install-binaries.sh b/vendor/github.com/docker/docker/hack/dockerfile/install-binaries.sh index 370ec7ce4..4debd3a5b 100755 --- a/vendor/github.com/docker/docker/hack/dockerfile/install-binaries.sh +++ b/vendor/github.com/docker/docker/hack/dockerfile/install-binaries.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash set -e set -x @@ -20,7 +20,7 @@ RUNC_BUILDTAGS="${RUNC_BUILDTAGS:-"seccomp apparmor selinux"}" install_runc() { echo "Install runc version $RUNC_COMMIT" - git clone https://github.com/docker/runc.git "$GOPATH/src/github.com/opencontainers/runc" + git clone https://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" cd "$GOPATH/src/github.com/opencontainers/runc" git checkout -q "$RUNC_COMMIT" make BUILDTAGS="$RUNC_BUILDTAGS" $1 @@ -47,13 +47,43 @@ install_proxy() { } install_dockercli() { - echo "Install docker/cli version $DOCKERCLI_COMMIT" - git clone "$DOCKERCLI_REPO" "$GOPATH/src/github.com/docker/cli" - cd "$GOPATH/src/github.com/docker/cli" - git checkout -q "$DOCKERCLI_COMMIT" + DOCKERCLI_CHANNEL=${DOCKERCLI_CHANNEL:-edge} + DOCKERCLI_VERSION=${DOCKERCLI_VERSION:-17.06.0-ce} + echo "Install docker/cli version $DOCKERCLI_VERSION from $DOCKERCLI_CHANNEL" + + arch=$(uname -m) + # No official release of these platforms + if [[ "$arch" != "x86_64" ]] && [[ "$arch" != "s390x" ]]; then + build_dockercli + return + fi + + url=https://download.docker.com/linux/static + curl -Ls $url/$DOCKERCLI_CHANNEL/$arch/docker-$DOCKERCLI_VERSION.tgz | \ + tar -xz docker/docker + mv docker/docker /usr/local/bin/ + rmdir docker +} + +build_dockercli() { + DOCKERCLI_VERSION=${DOCKERCLI_VERSION:-17.06.0-ce} + git clone https://github.com/docker/docker-ce "$GOPATH/tmp/docker-ce" + cd "$GOPATH/tmp/docker-ce" + git checkout -q "v$DOCKERCLI_VERSION" + mkdir -p "$GOPATH/src/github.com/docker" + mv components/cli "$GOPATH/src/github.com/docker/cli" go build -o /usr/local/bin/docker github.com/docker/cli/cmd/docker } +install_gometalinter() { + echo "Installing gometalinter version $GOMETALINTER_COMMIT" + go get -d github.com/alecthomas/gometalinter + cd "$GOPATH/src/github.com/alecthomas/gometalinter" + git checkout -q "$GOMETALINTER_COMMIT" + go build -o /usr/local/bin/gometalinter github.com/alecthomas/gometalinter + GOBIN=/usr/local/bin gometalinter --install +} + for prog in "$@" do case $prog in @@ -80,6 +110,10 @@ do install_containerd ;; + gometalinter) + install_gometalinter + ;; + tini) echo "Install tini version $TINI_COMMIT" git clone https://github.com/krallin/tini.git "$GOPATH/tini" @@ -114,7 +148,7 @@ do ;; *) - echo echo "Usage: $0 [tomlv|runc|runc-dynamic|containerd|containerd-dynamic|tini|proxy|proxy-dynamic|vndr|dockercli]" + echo echo "Usage: $0 [tomlv|runc|runc-dynamic|containerd|containerd-dynamic|tini|proxy|proxy-dynamic|vndr|dockercli|gometalinter]" exit 1 esac diff --git a/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/agent/master/call.go b/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/agent/master/call.go index 858c2c072..dab9c6707 100644 --- a/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/agent/master/call.go +++ b/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/agent/master/call.go @@ -73,14 +73,14 @@ func executeTests(funkerName string, testChunks [][]string) error { } log.Printf("Finished chunk %d [%d/%d] with %d test filters in %s, code=%d.", chunkID, passed+failed, len(testChunks), len(tests), - time.Now().Sub(chunkBegin), result.Code) + time.Since(chunkBegin), result.Code) } }(chunkID, tests) } wg.Wait() // TODO: print actual tests rather than chunks log.Printf("Executed %d chunks in %s. PASS: %d, FAIL: %d.", - len(testChunks), time.Now().Sub(begin), passed, failed) + len(testChunks), time.Since(begin), passed, failed) if failed > 0 { return fmt.Errorf("%d chunks failed", failed) } @@ -103,7 +103,7 @@ func executeTestChunk(funkerName string, args types.Args) (types.Result, error) func executeTestChunkWithRetry(funkerName string, args types.Args) (types.Result, error) { begin := time.Now() - for i := 0; time.Now().Sub(begin) < funkerRetryTimeout; i++ { + for i := 0; time.Since(begin) < funkerRetryTimeout; i++ { result, err := executeTestChunk(funkerName, args) if err == nil { log.Printf("executeTestChunk(%q, %d) returned code %d in trial %d", funkerName, args.ChunkID, result.Code, i) diff --git a/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/agent/worker/worker.go b/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/agent/worker/worker.go index 36ab3684d..ea8bb3fe2 100644 --- a/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/agent/worker/worker.go +++ b/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/agent/worker/worker.go @@ -58,7 +58,7 @@ func handle(workerImageDigest string, executor testChunkExecutor) error { RawLog: rawLog, } } - elapsed := time.Now().Sub(begin) + elapsed := time.Since(begin) log.Printf("Finished chunk %d, code=%d, elapsed=%v", args.ChunkID, code, elapsed) return types.Result{ ChunkID: args.ChunkID, diff --git a/vendor/github.com/docker/docker/hack/make.ps1 b/vendor/github.com/docker/docker/hack/make.ps1 index ac3e36904..73c9577a0 100644 --- a/vendor/github.com/docker/docker/hack/make.ps1 +++ b/vendor/github.com/docker/docker/hack/make.ps1 @@ -88,6 +88,7 @@ param( ) $ErrorActionPreference = "Stop" +$ProgressPreference = "SilentlyContinue" $pushed=$False # To restore the directory if we have temporarily pushed to one. # Utility function to get the commit ID of the repository @@ -318,7 +319,7 @@ Function Run-UnitTests() { $pkgList = $pkgList | Select-String -Pattern "github.com/docker/docker" $pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/vendor" $pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/man" - $pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/integration-cli" + $pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/integration" $pkgList = $pkgList -replace "`r`n", " " $goTestCommand = "go test" + $raceParm + " -cover -ldflags -w -tags """ + "autogen daemon" + """ -a """ + "-test.timeout=10m" + """ $pkgList" Invoke-Expression $goTestCommand @@ -398,39 +399,29 @@ Try { # Perform the actual build if ($Daemon) { Execute-Build "daemon" "daemon" "dockerd" } if ($Client) { - # Get the repo and commit of the client to build. - "hack\dockerfile\binaries-commits" | ForEach-Object { - $dockerCliRepo = ((Get-Content $_ | Select-String "DOCKERCLI_REPO") -split "=")[1] - $dockerCliCommit = ((Get-Content $_ | Select-String "DOCKERCLI_COMMIT") -split "=")[1] - } - - # Build from a temporary directory. - $tempLocation = "$env:TEMP\$(New-Guid)" - New-Item -ItemType Directory $tempLocation | Out-Null - - # Temporarily override GOPATH, then clone, checkout, and build. - $saveGOPATH = $env:GOPATH + # Get the Docker channel and version from the environment, or use the defaults. + if (-not ($channel = $env:DOCKERCLI_CHANNEL)) { $channel = "edge" } + if (-not ($version = $env:DOCKERCLI_VERSION)) { $version = "17.06.0-ce" } + + # Download the zip file and extract the client executable. + Write-Host "INFO: Downloading docker/cli version $version from $channel..." + $url = "https://download.docker.com/win/static/$channel/x86_64/docker-$version.zip" + Invoke-WebRequest $url -OutFile "docker.zip" Try { - $env:GOPATH = $tempLocation - $dockerCliRoot = "$env:GOPATH\src\github.com\docker\cli" - Write-Host "INFO: Cloning client repository..." - Invoke-Expression "git clone -q $dockerCliRepo $dockerCliRoot" - if ($LASTEXITCODE -ne 0) { Throw "Failed to clone client repository $dockerCliRepo" } - Invoke-Expression "git -C $dockerCliRoot checkout -q $dockerCliCommit" - if ($LASTEXITCODE -ne 0) { Throw "Failed to checkout client commit $dockerCliCommit" } - Write-Host "INFO: Building client..." - Push-Location "$dockerCliRoot\cmd\docker"; $global:pushed=$True - Invoke-Expression "go build -o $root\bundles\docker.exe" - if ($LASTEXITCODE -ne 0) { Throw "Failed to compile client" } - Pop-Location; $global:pushed=$False - } - Catch [Exception] { - Throw $_ + Add-Type -AssemblyName System.IO.Compression.FileSystem + $zip = [System.IO.Compression.ZipFile]::OpenRead("$PWD\docker.zip") + Try { + if (-not ($entry = $zip.Entries | Where-Object { $_.Name -eq "docker.exe" })) { + Throw "Cannot find docker.exe in $url" + } + [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, "$PWD\bundles\docker.exe", $true) + } + Finally { + $zip.Dispose() + } } Finally { - # Always restore GOPATH and remove the temporary directory. - $env:GOPATH = $saveGOPATH - Remove-Item -Force -Recurse $tempLocation + Remove-Item -Force "docker.zip" } } } diff --git a/vendor/github.com/docker/docker/hack/make.sh b/vendor/github.com/docker/docker/hack/make.sh index e625b863d..c52e634f9 100755 --- a/vendor/github.com/docker/docker/hack/make.sh +++ b/vendor/github.com/docker/docker/hack/make.sh @@ -60,18 +60,18 @@ DEFAULT_BUNDLES=( dynbinary test-unit - test-integration-cli + test-integration test-docker-py cross tgz ) -VERSION=$(< ./VERSION) +VERSION=${VERSION:-$(< ./VERSION)} ! BUILDTIME=$(date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/') if [ "$DOCKER_GITCOMMIT" ]; then GITCOMMIT="$DOCKER_GITCOMMIT" -elif command -v git &> /dev/null && [ -d .git ] && git rev-parse &> /dev/null; then +elif command -v git &> /dev/null && [ -e .git ] && git rev-parse &> /dev/null; then GITCOMMIT=$(git rev-parse --short HEAD) if [ -n "$(git status --porcelain --untracked-files=no)" ]; then GITCOMMIT="$GITCOMMIT-unsupported" @@ -130,7 +130,7 @@ fi # functionality. if \ command -v gcc &> /dev/null \ - && ! ( echo -e '#include \nint main() { dm_task_deferred_remove(NULL); }'| gcc -xc - -o /dev/null -ldevmapper &> /dev/null ) \ + && ! ( echo -e '#include \nint main() { dm_task_deferred_remove(NULL); }'| gcc -xc - -o /dev/null $(pkg-config --libs devmapper) &> /dev/null ) \ ; then DOCKER_BUILDTAGS+=' libdm_no_deferred_remove' fi @@ -190,20 +190,18 @@ bundle() { } main() { - # We want this to fail if the bundles already exist and cannot be removed. - # This is to avoid mixing bundles from different versions of the code. - mkdir -p bundles - if [ -e "bundles/$VERSION" ] && [ -z "$KEEPBUNDLE" ]; then - echo "bundles/$VERSION already exists. Removing." - rm -fr "bundles/$VERSION" && mkdir "bundles/$VERSION" || exit 1 + if [ -z "${KEEPBUNDLE-}" ]; then + echo "Removing bundles/" + rm -rf "bundles/*" echo fi + mkdir -p bundles + # Windows and symlinks don't get along well if [ "$(go env GOHOSTOS)" != 'windows' ]; then - # Windows and symlinks don't get along well - rm -f bundles/latest - ln -s "$VERSION" bundles/latest + # preserve latest symlink for backward compatibility + ln -sf . bundles/latest fi if [ $# -lt 1 ]; then @@ -212,7 +210,7 @@ main() { bundles=($@) fi for bundle in ${bundles[@]}; do - export DEST="bundles/$VERSION/$(basename "$bundle")" + export DEST="bundles/$(basename "$bundle")" # Cygdrive paths don't play well with go build -o. if [[ "$(uname -s)" == CYGWIN* ]]; then export DEST="$(cygpath -mw "$DEST")" diff --git a/vendor/github.com/docker/docker/hack/make/.ensure-emptyfs b/vendor/github.com/docker/docker/hack/make/.ensure-emptyfs index 7b00b9d45..898cc2283 100644 --- a/vendor/github.com/docker/docker/hack/make/.ensure-emptyfs +++ b/vendor/github.com/docker/docker/hack/make/.ensure-emptyfs @@ -1,23 +1,23 @@ #!/usr/bin/env bash set -e -if ! docker inspect -t image emptyfs &> /dev/null; then - # let's build a "docker save" tarball for "emptyfs" +if ! docker image inspect emptyfs > /dev/null; then + # build a "docker save" tarball for "emptyfs" # see https://github.com/docker/docker/pull/5262 # and also https://github.com/docker/docker/issues/4242 dir="$DEST/emptyfs" - mkdir -p "$dir" + uuid=511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158 + mkdir -p "$dir/$uuid" ( - cd "$dir" - echo '{"emptyfs":{"latest":"511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158"}}' > repositories - mkdir -p 511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158 - ( - cd 511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158 - echo '{"id":"511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158","comment":"Imported from -","created":"2013-06-13T14:03:50.821769-07:00","container_config":{"Hostname":"","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"PortSpecs":null,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":null,"Cmd":null,"Image":"","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":null},"docker_version":"0.4.0","architecture":"x86_64","Size":0}' > json - echo '1.0' > VERSION - tar -cf layer.tar --files-from /dev/null - ) + echo '{"emptyfs":{"latest":"511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158"}}' > "$dir/repositories" + cd "$dir/$uuid" + echo '{"id":"511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158","comment":"Imported from -","created":"2013-06-13T14:03:50.821769-07:00","container_config":{"Hostname":"","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"PortSpecs":null,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":null,"Cmd":null,"Image":"","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":null},"docker_version":"0.4.0","architecture":"x86_64","Size":0}' > json + echo '1.0' > VERSION + tar -cf layer.tar --files-from /dev/null + ) + ( + [ -n "$TESTDEBUG" ] && set -x + tar -cC "$dir" . | docker load ) - ( set -x; tar -cC "$dir" . | docker load ) rm -rf "$dir" fi diff --git a/vendor/github.com/docker/docker/hack/make/.integration-daemon-setup b/vendor/github.com/docker/docker/hack/make/.integration-daemon-setup index 5134e4c2d..c130e2356 100644 --- a/vendor/github.com/docker/docker/hack/make/.integration-daemon-setup +++ b/vendor/github.com/docker/docker/hack/make/.integration-daemon-setup @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -bundle .detect-daemon-osarch +source "$MAKEDIR/.detect-daemon-osarch" if [ "$DOCKER_ENGINE_GOOS" != "windows" ]; then bundle .ensure-emptyfs fi diff --git a/vendor/github.com/docker/docker/hack/make/.integration-daemon-start b/vendor/github.com/docker/docker/hack/make/.integration-daemon-start index dafd0533d..7314f71c5 100644 --- a/vendor/github.com/docker/docker/hack/make/.integration-daemon-start +++ b/vendor/github.com/docker/docker/hack/make/.integration-daemon-start @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# see test-integration-cli for example usage of this script +# see test-integration for example usage of this script base="$ABS_DEST/.." export PATH="$base/binary-daemon:$base/dynbinary-daemon:$PATH" @@ -21,8 +21,6 @@ if ! command -v "$TEST_CLIENT_BINARY" &> /dev/null; then false fi -export DOCKER_CLI_VERSION=$(${TEST_CLIENT_BINARY} --version | awk '{ gsub(",", " "); print $3 }') - # This is a temporary hack for split-binary mode. It can be removed once # https://github.com/docker/docker/pull/22134 is merged into docker master if [ "$(go env GOOS)" = 'windows' ]; then @@ -76,24 +74,26 @@ if [ -z "$DOCKER_TEST_HOST" ]; then # see https://github.com/docker/libcontainer/blob/master/apparmor/apparmor.go#L16 export container="" ( - set -x + [ -n "$TESTDEBUG" ] && set -x /etc/init.d/apparmor start ) fi - export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" # "pwd" tricks to make sure $DEST is an absolute path, not a relative one - ( set -x; exec \ - dockerd --debug \ - --host "$DOCKER_HOST" \ - --storage-driver "$DOCKER_GRAPHDRIVER" \ - --pidfile "$DEST/docker.pid" \ - --userland-proxy="$DOCKER_USERLANDPROXY" \ - $storage_params \ - $extra_params \ - &> "$DEST/docker.log" + # "pwd" tricks to make sure $DEST is an absolute path, not a relative one + export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" + ( + echo "Starting dockerd" + [ -n "$TESTDEBUG" ] && set -x + exec \ + dockerd --debug \ + --host "$DOCKER_HOST" \ + --storage-driver "$DOCKER_GRAPHDRIVER" \ + --pidfile "$DEST/docker.pid" \ + --userland-proxy="$DOCKER_USERLANDPROXY" \ + $storage_params \ + $extra_params \ + &> "$DEST/docker.log" ) & - # make sure that if the script exits unexpectedly, we stop this daemon we just started - trap 'bundle .integration-daemon-stop' EXIT else export DOCKER_HOST="$DOCKER_TEST_HOST" fi diff --git a/vendor/github.com/docker/docker/hack/make/.integration-daemon-stop b/vendor/github.com/docker/docker/hack/make/.integration-daemon-stop index 591a8d6be..c1d43e1a5 100644 --- a/vendor/github.com/docker/docker/hack/make/.integration-daemon-stop +++ b/vendor/github.com/docker/docker/hack/make/.integration-daemon-stop @@ -1,11 +1,12 @@ #!/usr/bin/env bash if [ ! "$(go env GOOS)" = 'windows' ]; then - trap - EXIT # reset EXIT trap applied in .integration-daemon-start - for pidFile in $(find "$DEST" -name docker.pid); do - pid=$(set -x; cat "$pidFile") - ( set -x; kill "$pid" ) + pid=$([ -n "$TESTDEBUG" ] && set -x; cat "$pidFile") + ( + [ -n "$TESTDEBUG" ] && set -x + kill "$pid" + ) if ! wait "$pid"; then echo >&2 "warning: PID $pid from $pidFile had a nonzero exit code" fi @@ -15,7 +16,7 @@ if [ ! "$(go env GOOS)" = 'windows' ]; then # Stop apparmor if it is enabled if [ -e "/sys/module/apparmor/parameters/enabled" ] && [ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]; then ( - set -x + [ -n "$TESTDEBUG" ] && set -x /etc/init.d/apparmor stop ) fi diff --git a/vendor/github.com/docker/docker/hack/make/.integration-test-helpers b/vendor/github.com/docker/docker/hack/make/.integration-test-helpers index 4ff9677c7..e3cb7d84a 100644 --- a/vendor/github.com/docker/docker/hack/make/.integration-test-helpers +++ b/vendor/github.com/docker/docker/hack/make/.integration-test-helpers @@ -1,66 +1,86 @@ #!/usr/bin/env bash - -: ${TEST_REPEAT:=0} - -bundle_test_integration_cli() { - TESTFLAGS="$TESTFLAGS -check.v -check.timeout=${TIMEOUT} -test.timeout=360m" - go_test_dir integration-cli $DOCKER_INTEGRATION_TESTS_VERIFIED -} - -# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'. -# You can use this to select certain tests to run, e.g. -# -# TESTFLAGS='-test.run ^TestBuild$' ./hack/make.sh test-unit # # For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want # to run certain tests on your local host, you should run with command: # -# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration-cli +# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration # -go_test_dir() { - dir=$1 - precompiled=$2 - testbinary="$ABS_DEST/test.main" - testcover=() - testcoverprofile=() - ( - set -e - mkdir -p "$DEST/coverprofiles" - export DEST="$ABS_DEST" # in a subshell this is safe -- our integration-cli tests need DEST, and "cd" screws it up - if [ -z $precompiled ]; then - ensure_test_dir $1 $testbinary - fi - cd "$dir" - i=0 - while ((++i)); do - test_env "$testbinary" $TESTFLAGS - if [ $i -gt "$TEST_REPEAT" ]; then - break - fi - echo "Repeating test ($i)" - done - ) + +source "$SCRIPTDIR/make/.go-autogen" + +# Set defaults +: ${TEST_REPEAT:=1} +: ${TESTFLAGS:=} +: ${TESTDEBUG:=} + +integration_api_dirs=${TEST_INTEGRATION_DIR:-"$( + find ./integration -type d | + grep -vE '^(./integration$|./integration/util)')"} + +run_test_integration() { + [[ "$TESTFLAGS" != *-check.f* ]] && run_test_integration_suites + run_test_integration_legacy_suites +} + +run_test_integration_suites() { + local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS" + for dir in $integration_api_dirs; do + if ! ( + cd $dir + echo "Running $PWD" + test_env ./test.main $flags + ); then exit 1; fi + done } -ensure_test_dir() { +run_test_integration_legacy_suites() { ( - # make sure a test dir will compile - dir="$1" - out="$2" - echo Building test dir: "$dir" - set -xe - cd "$dir" - go test -c -o "$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" + flags="-check.v -check.timeout=${TIMEOUT} -test.timeout=360m $TESTFLAGS" + cd integration-cli + echo "Running $PWD" + test_env ./test.main $flags ) } +build_test_suite_binaries() { + if [ ${DOCKER_INTEGRATION_TESTS_VERIFIED-} ]; then + echo "Skipping building test binaries; as DOCKER_INTEGRATION_TESTS_VERIFIED is set" + return + fi + build_test_suite_binary ./integration-cli "test.main" + for dir in $integration_api_dirs; do + build_test_suite_binary "$dir" "test.main" + done +} + +# Build a binary for a test suite package +build_test_suite_binary() { + local dir="$1" + local out="$2" + echo Building test suite binary "$dir/$out" + go test -c -o "$dir/$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" "$dir" +} + +cleanup_test_suite_binaries() { + [ -n "$TESTDEBUG" ] && return + echo "Removing test suite binaries" + find integration* -name test.main | xargs -r rm +} + +repeat() { + for i in $(seq 1 $TEST_REPEAT); do + echo "Running integration-test (iteration $i)" + $@ + done +} + +# use "env -i" to tightly control the environment variables that bleed into the tests test_env() { ( - set -xe - # use "env -i" to tightly control the environment variables that bleed into the tests + set -e + [ -n "$TESTDEBUG" ] && set -x env -i \ - DEST="$DEST" \ - DOCKER_CLI_VERSION="$DOCKER_CLI_VERSION" \ + DEST="$ABS_DEST" \ DOCKER_API_VERSION="$DOCKER_API_VERSION" \ DOCKER_INTEGRATION_DAEMON_DEST="$DOCKER_INTEGRATION_DAEMON_DEST" \ DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \ @@ -82,3 +102,19 @@ test_env() { "$@" ) } + + +error_on_leaked_containerd_shims() { + if [ "$(go env GOOS)" == 'windows' ]; then + return + fi + + leftovers=$(ps -ax -o pid,cmd | + awk '$2 == "docker-containerd-shim" && $4 ~ /.*\/bundles\/.*\/test-integration/ { print $1 }') + if [ -n "$leftovers" ]; then + ps aux + kill -9 $leftovers 2> /dev/null + echo "!!!! WARNING you have left over shim(s), Cleanup your test !!!!" + exit 1 + fi +} diff --git a/vendor/github.com/docker/docker/hack/make/build-integration-test-binary b/vendor/github.com/docker/docker/hack/make/build-integration-test-binary old mode 100644 new mode 100755 index a842e8cce..ad3e8c212 --- a/vendor/github.com/docker/docker/hack/make/build-integration-test-binary +++ b/vendor/github.com/docker/docker/hack/make/build-integration-test-binary @@ -1,13 +1,8 @@ #!/usr/bin/env bash +# required by `make build-integration-cli-on-swarm` set -e -rm -rf "$DEST" -DEST="$ABS_DEST/../test-integration-cli" +source "${MAKEDIR}/.go-autogen" +source hack/make/.integration-test-helpers -source "$SCRIPTDIR/make/.go-autogen" - -if [ -z $DOCKER_INTEGRATION_TESTS_VERIFIED ]; then - source ${MAKEDIR}/.integration-test-helpers - ensure_test_dir integration-cli "$DEST/test.main" - export DOCKER_INTEGRATION_TESTS_VERIFIED=1 -fi +build_test_suite_binaries diff --git a/vendor/github.com/docker/docker/hack/make/test-integration b/vendor/github.com/docker/docker/hack/make/test-integration new file mode 100755 index 000000000..0100ac9cc --- /dev/null +++ b/vendor/github.com/docker/docker/hack/make/test-integration @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -e -o pipefail + +source "${MAKEDIR}/.go-autogen" +source hack/make/.integration-test-helpers + +( + build_test_suite_binaries + bundle .integration-daemon-start + bundle .integration-daemon-setup + + local testexit=0 + ( repeat run_test_integration ) || testexit=$? + + # Always run cleanup, even if the subshell fails + bundle .integration-daemon-stop + cleanup_test_suite_binaries + error_on_leaked_containerd_shims + + exit $testexit + +) 2>&1 | tee -a "$DEST/test.log" diff --git a/vendor/github.com/docker/docker/hack/make/test-integration-cli b/vendor/github.com/docker/docker/hack/make/test-integration-cli index 61e2f7a7f..4cc79d095 100755 --- a/vendor/github.com/docker/docker/hack/make/test-integration-cli +++ b/vendor/github.com/docker/docker/hack/make/test-integration-cli @@ -1,29 +1,6 @@ #!/usr/bin/env bash set -e +echo "WARNING: test-integration-cli is DEREPCATED. Use test-integration." >&2 -source "${MAKEDIR}/.go-autogen" -source hack/make/.integration-test-helpers - -# subshell so that we can export PATH without breaking other things -( - bundle .integration-daemon-start - - bundle .integration-daemon-setup - - bundle_test_integration_cli - - bundle .integration-daemon-stop - - if [ "$(go env GOOS)" != 'windows' ] - then - leftovers=$(ps -ax -o pid,cmd | awk '$2 == "docker-containerd-shim" && $4 ~ /.*\/bundles\/.*\/test-integration-cli/ { print $1 }') - if [ -n "$leftovers" ] - then - ps aux - kill -9 $leftovers 2> /dev/null - echo "!!!! WARNING you have left over shim(s), Cleanup your test !!!!" - exit 1 - fi - fi - -) 2>&1 | tee -a "$DEST/test.log" +# TODO: remove this and exit 1 once CI has changed to use test-integration +bundle test-integration diff --git a/vendor/github.com/docker/docker/hack/make/test-integration-shell b/vendor/github.com/docker/docker/hack/make/test-integration-shell index 2201f5eb3..bcfa4682e 100644 --- a/vendor/github.com/docker/docker/hack/make/test-integration-shell +++ b/vendor/github.com/docker/docker/hack/make/test-integration-shell @@ -5,3 +5,5 @@ bundle .integration-daemon-setup export ABS_DEST bash +e + +bundle .integration-daemon-stop diff --git a/vendor/github.com/docker/docker/hack/release.sh b/vendor/github.com/docker/docker/hack/release.sh index 5d7363044..04f15be02 100755 --- a/vendor/github.com/docker/docker/hack/release.sh +++ b/vendor/github.com/docker/docker/hack/release.sh @@ -57,7 +57,7 @@ if [ "$1" != '--release-regardless-of-test-failure' ]; then RELEASE_BUNDLES=( test-unit "${RELEASE_BUNDLES[@]}" - test-integration-cli + test-integration ) fi diff --git a/vendor/github.com/docker/docker/hack/test/e2e-run.sh b/vendor/github.com/docker/docker/hack/test/e2e-run.sh new file mode 100755 index 000000000..bfcc03f62 --- /dev/null +++ b/vendor/github.com/docker/docker/hack/test/e2e-run.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -e + +TESTFLAGS=${TESTFLAGS:-""} +# Currently only DockerSuite and DockerNetworkSuite have been adapted for E2E testing +TESTFLAGS_LEGACY=${TESTFLAGS_LEGACY:-""} +TIMEOUT=${TIMEOUT:-60m} + +SCRIPTDIR="$(dirname ${BASH_SOURCE[0]})" + +export DOCKER_ENGINE_GOARCH=${DOCKER_ENGINE_GOARCH:-amd64} + +run_test_integration() { + run_test_integration_suites + run_test_integration_legacy_suites +} + +run_test_integration_suites() { + local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS" + for dir in /tests/integration/*; do + if ! ( + cd $dir + echo "Running $PWD" + ./test.main $flags + ); then exit 1; fi + done +} + +run_test_integration_legacy_suites() { + ( + flags="-check.v -check.timeout=${TIMEOUT} -test.timeout=360m $TESTFLAGS_LEGACY" + cd /tests/integration-cli + echo "Running $PWD" + ./test.main $flags + ) +} + +bash $SCRIPTDIR/ensure-emptyfs.sh + +echo "Run integration tests" +run_test_integration diff --git a/vendor/github.com/docker/docker/hack/test/unit b/vendor/github.com/docker/docker/hack/test/unit index 0018e8845..2b07089bc 100755 --- a/vendor/github.com/docker/docker/hack/test/unit +++ b/vendor/github.com/docker/docker/hack/test/unit @@ -16,7 +16,7 @@ TESTFLAGS+=" -test.timeout=${TIMEOUT:-5m}" BUILDFLAGS=( -tags "netgo seccomp libdm_no_deferred_remove" ) TESTDIRS="${TESTDIRS:-"./..."}" -exclude_paths="/vendor/|/integration-cli" +exclude_paths="/vendor/|/integration" if [ "$(go env GOHOSTOS)" = 'solaris' ]; then exclude_paths="$exclude_paths|/daemon/graphdriver" fi diff --git a/vendor/github.com/docker/docker/hack/validate/default b/vendor/github.com/docker/docker/hack/validate/default index e243f4383..8ec978876 100755 --- a/vendor/github.com/docker/docker/hack/validate/default +++ b/vendor/github.com/docker/docker/hack/validate/default @@ -6,13 +6,12 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" . $SCRIPTDIR/dco . $SCRIPTDIR/default-seccomp -. $SCRIPTDIR/gofmt -. $SCRIPTDIR/lint +. $SCRIPTDIR/gometalinter . $SCRIPTDIR/pkg-imports . $SCRIPTDIR/swagger . $SCRIPTDIR/swagger-gen . $SCRIPTDIR/test-imports . $SCRIPTDIR/toml -. $SCRIPTDIR/vet . $SCRIPTDIR/changelog-well-formed . $SCRIPTDIR/changelog-date-descending +. $SCRIPTDIR/deprecate-integration-cli diff --git a/vendor/github.com/docker/docker/hack/validate/deprecate-integration-cli b/vendor/github.com/docker/docker/hack/validate/deprecate-integration-cli new file mode 100755 index 000000000..da6f8310f --- /dev/null +++ b/vendor/github.com/docker/docker/hack/validate/deprecate-integration-cli @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Check that no new tests are being added to integration-cli + +export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPTDIR}/.validate" + +new_tests=$( + validate_diff --diff-filter=ACMR --unified=0 -- 'integration-cli/*_cli_*.go' | + grep -E '^\+func (.*) Test' || true +) + +if [ -z "$new_tests" ]; then + echo 'Congratulations! No new tests added to integration-cli.' + exit +fi + +echo "The following new tests were added to integration-cli:" +echo +echo "$new_tests" +echo +echo "integration-cli is deprecated. Please add an API integration test to" +echo "./integration/COMPONENT/. See ./TESTING.md for more details." +echo + +exit 1 diff --git a/vendor/github.com/docker/docker/hack/validate/gofmt b/vendor/github.com/docker/docker/hack/validate/gofmt deleted file mode 100755 index 38027a9f7..000000000 --- a/vendor/github.com/docker/docker/hack/validate/gofmt +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source "${SCRIPTDIR}/.validate" - -IFS=$'\n' -files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | - grep -v '^vendor/' | - grep -v '\.pb\.go$' || true) ) -unset IFS - -badFiles=() -for f in "${files[@]}"; do - # we use "git show" here to validate that what's committed is formatted - if [ "$(git show "$VALIDATE_HEAD:$f" | gofmt -s -l)" ]; then - badFiles+=( "$f" ) - fi -done - -if [ ${#badFiles[@]} -eq 0 ]; then - echo 'Congratulations! All Go source files are properly formatted.' -else - { - echo "These files are not properly gofmt'd:" - for f in "${badFiles[@]}"; do - echo " - $f" - done - echo - echo 'Please reformat the above files using "gofmt -s -w" and commit the result.' - echo - } >&2 - false -fi diff --git a/vendor/github.com/docker/docker/hack/validate/gometalinter b/vendor/github.com/docker/docker/hack/validate/gometalinter new file mode 100755 index 000000000..ae411e864 --- /dev/null +++ b/vendor/github.com/docker/docker/hack/validate/gometalinter @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -e -o pipefail + +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# CI platforms differ, so per-platform GOMETALINTER_OPTS can be set +# from a platform-specific Dockerfile, otherwise let's just set +# (somewhat pessimistic) default of 10 minutes. +gometalinter \ + ${GOMETALINTER_OPTS:--deadine 10m} \ + --config $SCRIPTDIR/gometalinter.json ./... diff --git a/vendor/github.com/docker/docker/hack/validate/gometalinter.json b/vendor/github.com/docker/docker/hack/validate/gometalinter.json new file mode 100644 index 000000000..8e8da10a3 --- /dev/null +++ b/vendor/github.com/docker/docker/hack/validate/gometalinter.json @@ -0,0 +1,26 @@ +{ + "Vendor": true, + "EnableGC": true, + "Sort": ["linter", "severity", "path"], + "Exclude": [ + ".*\\.pb\\.go", + "dockerversion/version_autogen.go", + "api/types/container/container_.*", + "integration-cli/" + ], + "Skip": ["integration-cli/"], + + "Enable": [ + "deadcode", + "gofmt", + "goimports", + "golint", + "gosimple", + "ineffassign", + "interfacer", + "unconvert", + "vet" + ], + + "LineLength": 200 +} diff --git a/vendor/github.com/docker/docker/hack/validate/lint b/vendor/github.com/docker/docker/hack/validate/lint deleted file mode 100755 index 341490a04..000000000 --- a/vendor/github.com/docker/docker/hack/validate/lint +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash - -export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source "${SCRIPTDIR}/.validate" - -IFS=$'\n' -files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' | grep -v '^api/types/container/' | grep -v '\.pb\.go$' || true) ) -unset IFS - -errors=() -for f in "${files[@]}"; do - failedLint=$(golint "$f") - if [ "$failedLint" ]; then - errors+=( "$failedLint" ) - fi -done - -if [ ${#errors[@]} -eq 0 ]; then - echo 'Congratulations! All Go source files have been linted.' -else - { - echo "Errors from golint:" - for err in "${errors[@]}"; do - echo "$err" - done - echo - echo 'Please fix the above errors. You can test via "golint" and commit the result.' - echo - } >&2 - false -fi diff --git a/vendor/github.com/docker/docker/hack/validate/vet b/vendor/github.com/docker/docker/hack/validate/vet deleted file mode 100755 index 95dc7a718..000000000 --- a/vendor/github.com/docker/docker/hack/validate/vet +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source "${SCRIPTDIR}/.validate" - -IFS=$'\n' -files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' | grep -v '^api/types/container/' || true) ) -unset IFS - -errors=() -for f in "${files[@]}"; do - failedVet=$(go vet "$f") - if [ "$failedVet" ]; then - errors+=( "$failedVet" ) - fi -done - - -if [ ${#errors[@]} -eq 0 ]; then - echo 'Congratulations! All Go source files have been vetted.' -else - { - echo "Errors from go vet:" - for err in "${errors[@]}"; do - echo " - $err" - done - echo - echo 'Please fix the above errors. You can test via "go vet" and commit the result.' - echo - } >&2 - false -fi diff --git a/vendor/github.com/docker/docker/image/fs_test.go b/vendor/github.com/docker/docker/image/fs_test.go index 5f2437cad..267252403 100644 --- a/vendor/github.com/docker/docker/image/fs_test.go +++ b/vendor/github.com/docker/docker/image/fs_test.go @@ -1,7 +1,6 @@ package image import ( - "bytes" "crypto/rand" "crypto/sha256" "encoding/hex" @@ -11,8 +10,8 @@ import ( "path/filepath" "testing" - "github.com/docker/docker/pkg/testutil" - "github.com/opencontainers/go-digest" + "github.com/docker/docker/internal/testutil" + digest "github.com/opencontainers/go-digest" "github.com/stretchr/testify/assert" ) @@ -112,9 +111,7 @@ func TestFSMetadataGetSet(t *testing.T) { actual, err := store.GetMetadata(tc.id, tc.key) assert.NoError(t, err) - if bytes.Compare(actual, tc.value) != 0 { - t.Fatalf("Metadata expected %q, got %q", tc.value, actual) - } + assert.Equal(t, tc.value, actual) } _, err = store.GetMetadata(id2, "tkey2") @@ -183,9 +180,7 @@ func TestFSGetSet(t *testing.T) { for _, tc := range tcases { data, err := store.Get(tc.expected) assert.NoError(t, err) - if bytes.Compare(data, tc.input) != 0 { - t.Fatalf("expected data %q, got %q", tc.input, data) - } + assert.Equal(t, tc.input, data) } } diff --git a/vendor/github.com/docker/docker/image/store.go b/vendor/github.com/docker/docker/image/store.go index 1a3045f58..17769f4c3 100644 --- a/vendor/github.com/docker/docker/image/store.go +++ b/vendor/github.com/docker/docker/image/store.go @@ -180,13 +180,21 @@ func (is *store) Create(config []byte) (ID, error) { return imageID, nil } +type imageNotFoundError string + +func (e imageNotFoundError) Error() string { + return "No such image: " + string(e) +} + +func (imageNotFoundError) NotFound() {} + func (is *store) Search(term string) (ID, error) { dgst, err := is.digestSet.Lookup(term) if err != nil { if err == digestset.ErrDigestNotFound { - err = fmt.Errorf("No such image: %s", term) + err = imageNotFoundError(term) } - return "", err + return "", errors.WithStack(err) } return IDFromDigest(dgst), nil } diff --git a/vendor/github.com/docker/docker/image/store_test.go b/vendor/github.com/docker/docker/image/store_test.go index fc6d461d9..23a60a98f 100644 --- a/vendor/github.com/docker/docker/image/store_test.go +++ b/vendor/github.com/docker/docker/image/store_test.go @@ -4,8 +4,8 @@ import ( "runtime" "testing" + "github.com/docker/docker/internal/testutil" "github.com/docker/docker/layer" - "github.com/docker/docker/pkg/testutil" "github.com/opencontainers/go-digest" "github.com/stretchr/testify/assert" ) @@ -41,10 +41,10 @@ func TestRestore(t *testing.T) { assert.Equal(t, "abc", img1.Comment) assert.Equal(t, "def", img2.Comment) - p, err := is.GetParent(ID(id1)) + _, err = is.GetParent(ID(id1)) testutil.ErrorContains(t, err, "failed to read metadata") - p, err = is.GetParent(ID(id2)) + p, err := is.GetParent(ID(id2)) assert.NoError(t, err) assert.Equal(t, ID(id1), p) diff --git a/vendor/github.com/docker/docker/image/tarexport/load.go b/vendor/github.com/docker/docker/image/tarexport/load.go index d69c9342a..8bb1ac166 100644 --- a/vendor/github.com/docker/docker/image/tarexport/load.go +++ b/vendor/github.com/docker/docker/image/tarexport/load.go @@ -23,7 +23,7 @@ import ( "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/pkg/system" - "github.com/opencontainers/go-digest" + digest "github.com/opencontainers/go-digest" "github.com/sirupsen/logrus" ) @@ -82,8 +82,7 @@ func (l *tarexporter) Load(inTar io.ReadCloser, outStream io.Writer, quiet bool) if err := checkCompatibleOS(img.OS); err != nil { return err } - var rootFS image.RootFS - rootFS = *img.RootFS + rootFS := *img.RootFS rootFS.DiffIDs = nil if expected, actual := len(m.Layers), len(img.RootFS.DiffIDs); expected != actual { @@ -212,15 +211,12 @@ func (l *tarexporter) loadLayer(filename string, rootFS image.RootFS, id string, return l.ls.Register(inflatedLayerData, rootFS.ChainID(), platform) } -func (l *tarexporter) setLoadedTag(ref reference.NamedTagged, imgID digest.Digest, outStream io.Writer) error { +func (l *tarexporter) setLoadedTag(ref reference.Named, imgID digest.Digest, outStream io.Writer) error { if prevID, err := l.rs.Get(ref); err == nil && prevID != imgID { fmt.Fprintf(outStream, "The image %s already exists, renaming the old one with ID %s to empty string\n", reference.FamiliarString(ref), string(prevID)) // todo: this message is wrong in case of multiple tags } - if err := l.rs.AddTag(ref, imgID, true); err != nil { - return err - } - return nil + return l.rs.AddTag(ref, imgID, true) } func (l *tarexporter) legacyLoad(tmpDir string, outStream io.Writer, progressOutput progress.Output) error { diff --git a/vendor/github.com/docker/docker/integration-cli/check_test.go b/vendor/github.com/docker/docker/integration-cli/check_test.go index f05b6504e..2e57e00b3 100644 --- a/vendor/github.com/docker/docker/integration-cli/check_test.go +++ b/vendor/github.com/docker/docker/integration-cli/check_test.go @@ -2,12 +2,12 @@ package main import ( "fmt" + "io/ioutil" "net/http/httptest" "os" - "os/exec" "path" "path/filepath" - "strings" + "strconv" "sync" "syscall" "testing" @@ -22,6 +22,7 @@ import ( "github.com/docker/docker/integration-cli/environment" "github.com/docker/docker/integration-cli/fixtures/plugin" "github.com/docker/docker/integration-cli/registry" + ienv "github.com/docker/docker/internal/test/environment" "github.com/docker/docker/pkg/reexec" "github.com/go-check/check" "golang.org/x/net/context" @@ -59,30 +60,14 @@ func init() { func TestMain(m *testing.M) { dockerBinary = testEnv.DockerBinary() - - if testEnv.LocalDaemon() { - fmt.Println("INFO: Testing against a local daemon") - } else { - fmt.Println("INFO: Testing against a remote daemon") - } - exitCode := m.Run() - os.Exit(exitCode) + testEnv.Print() + os.Exit(m.Run()) } func Test(t *testing.T) { - cli.EnsureTestEnvIsLoaded(t) - fakestorage.EnsureTestEnvIsLoaded(t) - cmd := exec.Command(dockerBinary, "images", "-f", "dangling=false", "--format", "{{.Repository}}:{{.Tag}}") - cmd.Env = appendBaseEnv(true) - out, err := cmd.CombinedOutput() - if err != nil { - panic(fmt.Errorf("err=%v\nout=%s\n", err, out)) - } - images := strings.Split(strings.TrimSpace(string(out)), "\n") - testEnv.ProtectImage(t, images...) - if testEnv.DaemonPlatform() == "linux" { - ensureFrozenImagesLinux(t) - } + cli.SetTestEnvironment(testEnv) + fakestorage.SetTestEnvironment(&testEnv.Execution) + ienv.ProtectAll(t, &testEnv.Execution) check.TestingT(t) } @@ -94,13 +79,28 @@ type DockerSuite struct { } func (s *DockerSuite) OnTimeout(c *check.C) { - if testEnv.DaemonPID() > 0 && testEnv.LocalDaemon() { - daemon.SignalDaemonDump(testEnv.DaemonPID()) + if !testEnv.IsLocalDaemon() { + return + } + path := filepath.Join(os.Getenv("DEST"), "docker.pid") + b, err := ioutil.ReadFile(path) + if err != nil { + c.Fatalf("Failed to get daemon PID from %s\n", path) + } + + rawPid, err := strconv.ParseInt(string(b), 10, 32) + if err != nil { + c.Fatalf("Failed to parse pid from %s: %s\n", path, err) + } + + daemonPid := int(rawPid) + if daemonPid > 0 { + daemon.SignalDaemonDump(daemonPid) } } func (s *DockerSuite) TearDownTest(c *check.C) { - testEnv.Clean(c, dockerBinary) + testEnv.Clean(c) } func init() { @@ -120,7 +120,7 @@ func (s *DockerRegistrySuite) OnTimeout(c *check.C) { } func (s *DockerRegistrySuite) SetUpTest(c *check.C) { - testRequires(c, DaemonIsLinux, registry.Hosting) + testRequires(c, DaemonIsLinux, registry.Hosting, SameHostDaemon) s.reg = setupRegistry(c, false, "", "") s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ Experimental: testEnv.ExperimentalDaemon(), @@ -154,7 +154,7 @@ func (s *DockerSchema1RegistrySuite) OnTimeout(c *check.C) { } func (s *DockerSchema1RegistrySuite) SetUpTest(c *check.C) { - testRequires(c, DaemonIsLinux, registry.Hosting, NotArm64) + testRequires(c, DaemonIsLinux, registry.Hosting, NotArm64, SameHostDaemon) s.reg = setupRegistry(c, true, "", "") s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ Experimental: testEnv.ExperimentalDaemon(), @@ -188,7 +188,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) OnTimeout(c *check.C) { } func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(c *check.C) { - testRequires(c, DaemonIsLinux, registry.Hosting) + testRequires(c, DaemonIsLinux, registry.Hosting, SameHostDaemon) s.reg = setupRegistry(c, false, "htpasswd", "") s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ Experimental: testEnv.ExperimentalDaemon(), @@ -224,7 +224,7 @@ func (s *DockerRegistryAuthTokenSuite) OnTimeout(c *check.C) { } func (s *DockerRegistryAuthTokenSuite) SetUpTest(c *check.C) { - testRequires(c, DaemonIsLinux, registry.Hosting) + testRequires(c, DaemonIsLinux, registry.Hosting, SameHostDaemon) s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ Experimental: testEnv.ExperimentalDaemon(), }) @@ -319,7 +319,7 @@ func (s *DockerSwarmSuite) OnTimeout(c *check.C) { } func (s *DockerSwarmSuite) SetUpTest(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, SameHostDaemon) } func (s *DockerSwarmSuite) AddDaemon(c *check.C, joinSwarm, manager bool) *daemon.Swarm { @@ -471,7 +471,7 @@ func (ps *DockerPluginSuite) getPluginRepoWithTag() string { } func (ps *DockerPluginSuite) SetUpSuite(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, registry.Hosting) ps.registry = setupRegistry(c, false, "", "") ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) diff --git a/vendor/github.com/docker/docker/integration-cli/cli/build/build.go b/vendor/github.com/docker/docker/integration-cli/cli/build/build.go index 8ffaa35b4..da55df35c 100644 --- a/vendor/github.com/docker/docker/integration-cli/cli/build/build.go +++ b/vendor/github.com/docker/docker/integration-cli/cli/build/build.go @@ -5,7 +5,7 @@ import ( "strings" "github.com/docker/docker/integration-cli/cli/build/fakecontext" - icmd "github.com/docker/docker/pkg/testutil/cmd" + "github.com/gotestyourself/gotestyourself/icmd" ) type testingT interface { diff --git a/vendor/github.com/docker/docker/integration-cli/cli/build/fakegit/fakegit.go b/vendor/github.com/docker/docker/integration-cli/cli/build/fakegit/fakegit.go index 74faffd92..ad028dc72 100644 --- a/vendor/github.com/docker/docker/integration-cli/cli/build/fakegit/fakegit.go +++ b/vendor/github.com/docker/docker/integration-cli/cli/build/fakegit/fakegit.go @@ -11,9 +11,11 @@ import ( "github.com/docker/docker/integration-cli/cli/build/fakecontext" "github.com/docker/docker/integration-cli/cli/build/fakestorage" + "github.com/stretchr/testify/require" ) type testingT interface { + require.TestingT logT Fatal(args ...interface{}) Fatalf(string, ...interface{}) diff --git a/vendor/github.com/docker/docker/integration-cli/cli/build/fakestorage/fixtures.go b/vendor/github.com/docker/docker/integration-cli/cli/build/fakestorage/fixtures.go index f6a63dcf0..b76a7d920 100644 --- a/vendor/github.com/docker/docker/integration-cli/cli/build/fakestorage/fixtures.go +++ b/vendor/github.com/docker/docker/integration-cli/cli/build/fakestorage/fixtures.go @@ -30,7 +30,7 @@ func ensureHTTPServerImage(t testingT) { } defer os.RemoveAll(tmp) - goos := testEnv.DaemonPlatform() + goos := testEnv.DaemonInfo.OSType if goos == "" { goos = "linux" } @@ -39,27 +39,34 @@ func ensureHTTPServerImage(t testingT) { goarch = "amd64" } - goCmd, lookErr := exec.LookPath("go") + cpCmd, lookErr := exec.LookPath("cp") if lookErr != nil { t.Fatalf("could not build http server: %v", lookErr) } - cmd := exec.Command(goCmd, "build", "-o", filepath.Join(tmp, "httpserver"), "github.com/docker/docker/contrib/httpserver") - cmd.Env = append(os.Environ(), []string{ - "CGO_ENABLED=0", - "GOOS=" + goos, - "GOARCH=" + goarch, - }...) - var out []byte - if out, err = cmd.CombinedOutput(); err != nil { - t.Fatalf("could not build http server: %s", string(out)) - } + if _, err = os.Stat("../contrib/httpserver/httpserver"); os.IsNotExist(err) { + goCmd, lookErr := exec.LookPath("go") + if lookErr != nil { + t.Fatalf("could not build http server: %v", lookErr) + } - cpCmd, lookErr := exec.LookPath("cp") - if lookErr != nil { - t.Fatalf("could not build http server: %v", lookErr) + cmd := exec.Command(goCmd, "build", "-o", filepath.Join(tmp, "httpserver"), "github.com/docker/docker/contrib/httpserver") + cmd.Env = append(os.Environ(), []string{ + "CGO_ENABLED=0", + "GOOS=" + goos, + "GOARCH=" + goarch, + }...) + var out []byte + if out, err = cmd.CombinedOutput(); err != nil { + t.Fatalf("could not build http server: %s", string(out)) + } + } else { + if out, err := exec.Command(cpCmd, "../contrib/httpserver/httpserver", filepath.Join(tmp, "httpserver")).CombinedOutput(); err != nil { + t.Fatalf("could not copy http server: %v", string(out)) + } } - if out, err = exec.Command(cpCmd, "../contrib/httpserver/Dockerfile", filepath.Join(tmp, "Dockerfile")).CombinedOutput(); err != nil { + + if out, err := exec.Command(cpCmd, "../contrib/httpserver/Dockerfile", filepath.Join(tmp, "Dockerfile")).CombinedOutput(); err != nil { t.Fatalf("could not build http server: %v", string(out)) } diff --git a/vendor/github.com/docker/docker/integration-cli/cli/build/fakestorage/storage.go b/vendor/github.com/docker/docker/integration-cli/cli/build/fakestorage/storage.go index 49f47e436..25cd872f5 100644 --- a/vendor/github.com/docker/docker/integration-cli/cli/build/fakestorage/storage.go +++ b/vendor/github.com/docker/docker/integration-cli/cli/build/fakestorage/storage.go @@ -8,39 +8,20 @@ import ( "net/url" "os" "strings" - "sync" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" "github.com/docker/docker/integration-cli/cli/build/fakecontext" - "github.com/docker/docker/integration-cli/environment" "github.com/docker/docker/integration-cli/request" + "github.com/docker/docker/internal/test/environment" "github.com/docker/docker/pkg/stringutils" + "github.com/stretchr/testify/require" ) -var ( - testEnv *environment.Execution - onlyOnce sync.Once -) - -// EnsureTestEnvIsLoaded make sure the test environment is loaded for this package -func EnsureTestEnvIsLoaded(t testingT) { - var doIt bool - var err error - onlyOnce.Do(func() { - doIt = true - }) - - if !doIt { - return - } - testEnv, err = environment.New() - if err != nil { - t.Fatalf("error loading testenv : %v", err) - } -} +var testEnv *environment.Execution type testingT interface { + require.TestingT logT Fatal(args ...interface{}) Fatalf(string, ...interface{}) @@ -58,11 +39,20 @@ type Fake interface { CtxDir() string } +// SetTestEnvironment sets a static test environment +// TODO: decouple this package from environment +func SetTestEnvironment(env *environment.Execution) { + testEnv = env +} + // New returns a static file server that will be use as build context. func New(t testingT, dir string, modifiers ...func(*fakecontext.Fake) error) Fake { + if testEnv == nil { + t.Fatal("fakstorage package requires SetTestEnvironment() to be called before use.") + } ctx := fakecontext.New(t, dir, modifiers...) - if testEnv.LocalDaemon() { - return newLocalFakeStorage(t, ctx) + if testEnv.IsLocalDaemon() { + return newLocalFakeStorage(ctx) } return newRemoteFileServer(t, ctx) } @@ -86,7 +76,7 @@ func (s *localFileStorage) Close() error { return s.Fake.Close() } -func newLocalFakeStorage(t testingT, ctx *fakecontext.Fake) *localFileStorage { +func newLocalFakeStorage(ctx *fakecontext.Fake) *localFileStorage { handler := http.FileServer(http.Dir(ctx.Dir)) server := httptest.NewServer(handler) return &localFileStorage{ diff --git a/vendor/github.com/docker/docker/integration-cli/cli/cli.go b/vendor/github.com/docker/docker/integration-cli/cli/cli.go index d8355217e..b8230b2da 100644 --- a/vendor/github.com/docker/docker/integration-cli/cli/cli.go +++ b/vendor/github.com/docker/docker/integration-cli/cli/cli.go @@ -4,35 +4,20 @@ import ( "fmt" "io" "strings" - "sync" "time" "github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/integration-cli/environment" - icmd "github.com/docker/docker/pkg/testutil/cmd" + "github.com/gotestyourself/gotestyourself/icmd" "github.com/pkg/errors" ) -var ( - testEnv *environment.Execution - onlyOnce sync.Once -) - -// EnsureTestEnvIsLoaded make sure the test environment is loaded for this package -func EnsureTestEnvIsLoaded(t testingT) { - var doIt bool - var err error - onlyOnce.Do(func() { - doIt = true - }) +var testEnv *environment.Execution - if !doIt { - return - } - testEnv, err = environment.New() - if err != nil { - t.Fatalf("error loading testenv : %v", err) - } +// SetTestEnvironment sets a static test environment +// TODO: decouple this package from environment +func SetTestEnvironment(env *environment.Execution) { + testEnv = env } // CmdOperator defines functions that can modify a command @@ -130,7 +115,7 @@ func Docker(cmd icmd.Cmd, cmdOperators ...CmdOperator) *icmd.Result { // validateArgs is a checker to ensure tests are not running commands which are // not supported on platforms. Specifically on Windows this is 'busybox top'. func validateArgs(args ...string) error { - if testEnv.DaemonPlatform() != "windows" { + if testEnv.DaemonInfo.OSType != "windows" { return nil } foundBusybox := -1 @@ -229,3 +214,11 @@ func WithStdout(writer io.Writer) func(*icmd.Cmd) func() { return nil } } + +// WithStdin sets the standard input reader for the command +func WithStdin(stdin io.Reader) func(*icmd.Cmd) func() { + return func(cmd *icmd.Cmd) func() { + cmd.Stdin = stdin + return nil + } +} diff --git a/vendor/github.com/docker/docker/integration-cli/daemon/daemon.go b/vendor/github.com/docker/docker/integration-cli/daemon/daemon.go index 8b086c942..06bf504fa 100644 --- a/vendor/github.com/docker/docker/integration-cli/daemon/daemon.go +++ b/vendor/github.com/docker/docker/integration-cli/daemon/daemon.go @@ -14,21 +14,26 @@ import ( "strings" "time" + "github.com/docker/docker/api" + "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/events" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/request" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/stringid" - "github.com/docker/docker/pkg/testutil" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/docker/go-connections/sockets" "github.com/docker/go-connections/tlsconfig" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" "github.com/pkg/errors" + "github.com/stretchr/testify/require" + "golang.org/x/net/context" ) type testingT interface { + require.TestingT logT Fatalf(string, ...interface{}) } @@ -325,9 +330,7 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error { // then save the busybox image from the main daemon and load it into this Daemon instance. func (d *Daemon) StartWithBusybox(t testingT, arg ...string) { d.Start(t, arg...) - if err := d.LoadBusybox(); err != nil { - t.Fatalf("Error loading busybox image to current daemon: %s\n%v", d.id, err) - } + d.LoadBusybox(t) } // Kill will send a SIGKILL to the daemon @@ -489,27 +492,24 @@ func (d *Daemon) handleUserns() { } } -// LoadBusybox will load the stored busybox into a newly started daemon -func (d *Daemon) LoadBusybox() error { - bb := filepath.Join(d.Folder, "busybox.tar") - if _, err := os.Stat(bb); err != nil { - if !os.IsNotExist(err) { - return errors.Errorf("unexpected error on busybox.tar stat: %v", err) - } - // saving busybox image from main daemon - if out, err := exec.Command(d.dockerBinary, "save", "--output", bb, "busybox:latest").CombinedOutput(); err != nil { - imagesOut, _ := exec.Command(d.dockerBinary, "images", "--format", "{{ .Repository }}:{{ .Tag }}").CombinedOutput() - return errors.Errorf("could not save busybox image: %s\n%s", string(out), strings.TrimSpace(string(imagesOut))) - } - } - // loading busybox image to this daemon - if out, err := d.Cmd("load", "--input", bb); err != nil { - return errors.Errorf("could not load busybox image: %s", out) - } - if err := os.Remove(bb); err != nil { - return err - } - return nil +// LoadBusybox image into the daemon +func (d *Daemon) LoadBusybox(t testingT) { + clientHost, err := client.NewEnvClient() + require.NoError(t, err, "failed to create client") + defer clientHost.Close() + + ctx := context.Background() + reader, err := clientHost.ImageSave(ctx, []string{"busybox:latest"}) + require.NoError(t, err, "failed to download busybox") + defer reader.Close() + + client, err := d.NewClient() + require.NoError(t, err, "failed to create client") + defer client.Close() + + resp, err := client.ImageLoad(ctx, reader, true) + require.NoError(t, err, "failed to load busybox") + defer resp.Body.Close() } func (d *Daemon) queryRootDir() (string, error) { @@ -545,7 +545,7 @@ func (d *Daemon) queryRootDir() (string, error) { } var b []byte var i Info - b, err = testutil.ReadBody(body) + b, err = request.ReadBody(body) if err == nil && resp.StatusCode == http.StatusOK { // read the docker root dir if err = json.Unmarshal(b, &i); err == nil { @@ -570,20 +570,13 @@ func (d *Daemon) WaitRun(contID string) error { return WaitInspectWithArgs(d.dockerBinary, contID, "{{.State.Running}}", "true", 10*time.Second, args...) } -// GetBaseDeviceSize returns the base device size of the daemon -func (d *Daemon) GetBaseDeviceSize(c *check.C) int64 { - infoCmdOutput, _, err := testutil.RunCommandPipelineWithOutput( - exec.Command(d.dockerBinary, "-H", d.Sock(), "info"), - exec.Command("grep", "Base Device Size"), - ) - c.Assert(err, checker.IsNil) - basesizeSlice := strings.Split(infoCmdOutput, ":") - basesize := strings.Trim(basesizeSlice[1], " ") - basesize = strings.Trim(basesize, "\n")[:len(basesize)-3] - basesizeFloat, err := strconv.ParseFloat(strings.Trim(basesize, " "), 64) - c.Assert(err, checker.IsNil) - basesizeBytes := int64(basesizeFloat) * (1024 * 1024 * 1024) - return basesizeBytes +// Info returns the info struct for this daemon +func (d *Daemon) Info(t require.TestingT) types.Info { + apiclient, err := request.NewClientForHost(d.Sock()) + require.NoError(t, err) + info, err := apiclient.Info(context.Background()) + require.NoError(t, err) + return info } // Cmd executes a docker CLI command against this daemon. @@ -620,7 +613,7 @@ func (d *Daemon) SockRequest(method, endpoint string, data interface{}) (int, [] if err != nil { return -1, nil, err } - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) return res.StatusCode, b, err } @@ -757,6 +750,16 @@ func (d *Daemon) ReloadConfig() error { return nil } +// NewClient creates new client based on daemon's socket path +func (d *Daemon) NewClient() (*client.Client, error) { + httpClient, err := request.NewHTTPClient(d.Sock()) + if err != nil { + return nil, err + } + + return client.NewClient(d.Sock(), api.DefaultVersion, httpClient, nil) +} + // WaitInspectWithArgs waits for the specified expression to be equals to the specified expected string in the given time. // Deprecated: use cli.WaitCmd instead func WaitInspectWithArgs(dockerBinary, name, expr, expected string, timeout time.Duration, arg ...string) error { diff --git a/vendor/github.com/docker/docker/integration-cli/daemon/daemon_swarm.go b/vendor/github.com/docker/docker/integration-cli/daemon/daemon_swarm.go index ba414066c..c37c7269f 100644 --- a/vendor/github.com/docker/docker/integration-cli/daemon/daemon_swarm.go +++ b/vendor/github.com/docker/docker/integration-cli/daemon/daemon_swarm.go @@ -1,7 +1,6 @@ package daemon import ( - "context" "encoding/json" "fmt" "net/http" @@ -11,10 +10,10 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" - "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/go-check/check" "github.com/pkg/errors" + "golang.org/x/net/context" ) // Swarm is a test daemon with helpers for participating in a swarm. @@ -30,10 +29,12 @@ func (d *Swarm) Init(req swarm.InitRequest) error { if req.ListenAddr == "" { req.ListenAddr = d.ListenAddr } - status, out, err := d.SockRequest("POST", "/swarm/init", req) - if status != http.StatusOK { - return fmt.Errorf("initializing swarm: invalid statuscode %v, %q", status, out) + cli, err := d.NewClient() + if err != nil { + return fmt.Errorf("initializing swarm: failed to create client %v", err) } + defer cli.Close() + _, err = cli.SwarmInit(context.Background(), req) if err != nil { return fmt.Errorf("initializing swarm: %v", err) } @@ -50,10 +51,12 @@ func (d *Swarm) Join(req swarm.JoinRequest) error { if req.ListenAddr == "" { req.ListenAddr = d.ListenAddr } - status, out, err := d.SockRequest("POST", "/swarm/join", req) - if status != http.StatusOK { - return fmt.Errorf("joining swarm: invalid statuscode %v, %q", status, out) + cli, err := d.NewClient() + if err != nil { + return fmt.Errorf("joining swarm: failed to create client %v", err) } + defer cli.Close() + err = cli.SwarmJoin(context.Background(), req) if err != nil { return fmt.Errorf("joining swarm: %v", err) } @@ -67,14 +70,12 @@ func (d *Swarm) Join(req swarm.JoinRequest) error { // Leave forces daemon to leave current cluster. func (d *Swarm) Leave(force bool) error { - url := "/swarm/leave" - if force { - url += "?force=1" - } - status, out, err := d.SockRequest("POST", url, nil) - if status != http.StatusOK { - return fmt.Errorf("leaving swarm: invalid statuscode %v, %q", status, out) + cli, err := d.NewClient() + if err != nil { + return fmt.Errorf("leaving swarm: failed to create client %v", err) } + defer cli.Close() + err = cli.SwarmLeave(context.Background(), force) if err != nil { err = fmt.Errorf("leaving swarm: %v", err) } @@ -83,28 +84,27 @@ func (d *Swarm) Leave(force bool) error { // SwarmInfo returns the swarm information of the daemon func (d *Swarm) SwarmInfo() (swarm.Info, error) { - var info struct { - Swarm swarm.Info - } - status, dt, err := d.SockRequest("GET", "/info", nil) - if status != http.StatusOK { - return info.Swarm, fmt.Errorf("get swarm info: invalid statuscode %v", status) - } + cli, err := d.NewClient() if err != nil { - return info.Swarm, fmt.Errorf("get swarm info: %v", err) + return swarm.Info{}, fmt.Errorf("get swarm info: %v", err) } - if err := json.Unmarshal(dt, &info); err != nil { - return info.Swarm, err + + info, err := cli.Info(context.Background()) + if err != nil { + return swarm.Info{}, fmt.Errorf("get swarm info: %v", err) } + return info.Swarm, nil } // Unlock tries to unlock a locked swarm func (d *Swarm) Unlock(req swarm.UnlockRequest) error { - status, out, err := d.SockRequest("POST", "/swarm/unlock", req) - if status != http.StatusOK { - return fmt.Errorf("unlocking swarm: invalid statuscode %v, %q", status, out) + cli, err := d.NewClient() + if err != nil { + return fmt.Errorf("unlocking swarm: failed to create client %v", err) } + defer cli.Close() + err = cli.SwarmUnlock(context.Background(), req) if err != nil { err = errors.Wrap(err, "unlocking swarm") } @@ -129,19 +129,19 @@ type SpecConstructor func(*swarm.Spec) // CreateServiceWithOptions creates a swarm service given the specified service constructors // and auth config func (d *Swarm) CreateServiceWithOptions(c *check.C, opts types.ServiceCreateOptions, f ...ServiceConstructor) string { - cl, err := client.NewClient(d.Sock(), "", nil, nil) - c.Assert(err, checker.IsNil, check.Commentf("failed to create client")) - defer cl.Close() - var service swarm.Service for _, fn := range f { fn(&service) } + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() - res, err := cl.ServiceCreate(ctx, service.Spec, opts) + res, err := cli.ServiceCreate(ctx, service.Spec, opts) c.Assert(err, checker.IsNil) return res.ID } @@ -153,28 +153,31 @@ func (d *Swarm) CreateService(c *check.C, f ...ServiceConstructor) string { // GetService returns the swarm service corresponding to the specified id func (d *Swarm) GetService(c *check.C, id string) *swarm.Service { - var service swarm.Service - status, out, err := d.SockRequest("GET", "/services/"+id, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) - c.Assert(json.Unmarshal(out, &service), checker.IsNil) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + service, _, err := cli.ServiceInspectWithRaw(context.Background(), id, types.ServiceInspectOptions{}) + c.Assert(err, checker.IsNil) return &service } // GetServiceTasks returns the swarm tasks for the specified service func (d *Swarm) GetServiceTasks(c *check.C, service string) []swarm.Task { - var tasks []swarm.Task + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() filterArgs := filters.NewArgs() filterArgs.Add("desired-state", "running") filterArgs.Add("service", service) - filters, err := filters.ToParam(filterArgs) - c.Assert(err, checker.IsNil) - status, out, err := d.SockRequest("GET", "/tasks?filters="+filters, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) - c.Assert(json.Unmarshal(out, &tasks), checker.IsNil) + options := types.TaskListOptions{ + Filters: filterArgs, + } + + tasks, err := cli.TaskList(context.Background(), options) + c.Assert(err, checker.IsNil) return tasks } @@ -252,17 +255,19 @@ func (d *Swarm) CheckServiceTasks(service string) func(*check.C) (interface{}, c // CheckRunningTaskNetworks returns the number of times each network is referenced from a task. func (d *Swarm) CheckRunningTaskNetworks(c *check.C) (interface{}, check.CommentInterface) { - var tasks []swarm.Task + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() filterArgs := filters.NewArgs() filterArgs.Add("desired-state", "running") - filters, err := filters.ToParam(filterArgs) - c.Assert(err, checker.IsNil) - status, out, err := d.SockRequest("GET", "/tasks?filters="+filters, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) - c.Assert(json.Unmarshal(out, &tasks), checker.IsNil) + options := types.TaskListOptions{ + Filters: filterArgs, + } + + tasks, err := cli.TaskList(context.Background(), options) + c.Assert(err, checker.IsNil) result := make(map[string]int) for _, task := range tasks { @@ -275,17 +280,19 @@ func (d *Swarm) CheckRunningTaskNetworks(c *check.C) (interface{}, check.Comment // CheckRunningTaskImages returns the times each image is running as a task. func (d *Swarm) CheckRunningTaskImages(c *check.C) (interface{}, check.CommentInterface) { - var tasks []swarm.Task + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() filterArgs := filters.NewArgs() filterArgs.Add("desired-state", "running") - filters, err := filters.ToParam(filterArgs) - c.Assert(err, checker.IsNil) - status, out, err := d.SockRequest("GET", "/tasks?filters="+filters, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) - c.Assert(json.Unmarshal(out, &tasks), checker.IsNil) + options := types.TaskListOptions{ + Filters: filterArgs, + } + + tasks, err := cli.TaskList(context.Background(), options) + c.Assert(err, checker.IsNil) result := make(map[string]int) for _, task := range tasks { @@ -310,246 +317,281 @@ func (d *Swarm) CheckNodeReadyCount(c *check.C) (interface{}, check.CommentInter // GetTask returns the swarm task identified by the specified id func (d *Swarm) GetTask(c *check.C, id string) swarm.Task { - var task swarm.Task + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - status, out, err := d.SockRequest("GET", "/tasks/"+id, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) - c.Assert(json.Unmarshal(out, &task), checker.IsNil) + task, _, err := cli.TaskInspectWithRaw(context.Background(), id) + c.Assert(err, checker.IsNil) return task } // UpdateService updates a swarm service with the specified service constructor func (d *Swarm) UpdateService(c *check.C, service *swarm.Service, f ...ServiceConstructor) { + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + for _, fn := range f { fn(service) } - url := fmt.Sprintf("/services/%s/update?version=%d", service.ID, service.Version.Index) - status, out, err := d.SockRequest("POST", url, service.Spec) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) + + _, err = cli.ServiceUpdate(context.Background(), service.ID, service.Version, service.Spec, types.ServiceUpdateOptions{}) + c.Assert(err, checker.IsNil) } // RemoveService removes the specified service func (d *Swarm) RemoveService(c *check.C, id string) { - status, out, err := d.SockRequest("DELETE", "/services/"+id, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + err = cli.ServiceRemove(context.Background(), id) + c.Assert(err, checker.IsNil) } // GetNode returns a swarm node identified by the specified id func (d *Swarm) GetNode(c *check.C, id string) *swarm.Node { - var node swarm.Node - status, out, err := d.SockRequest("GET", "/nodes/"+id, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) - c.Assert(json.Unmarshal(out, &node), checker.IsNil) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + node, _, err := cli.NodeInspectWithRaw(context.Background(), id) + c.Assert(err, checker.IsNil) c.Assert(node.ID, checker.Equals, id) return &node } // RemoveNode removes the specified node func (d *Swarm) RemoveNode(c *check.C, id string, force bool) { - url := "/nodes/" + id - if force { - url += "?force=1" - } + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - status, out, err := d.SockRequest("DELETE", url, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) + options := types.NodeRemoveOptions{ + Force: force, + } + err = cli.NodeRemove(context.Background(), id, options) + c.Assert(err, checker.IsNil) } // UpdateNode updates a swarm node with the specified node constructor func (d *Swarm) UpdateNode(c *check.C, id string, f ...NodeConstructor) { + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + for i := 0; ; i++ { node := d.GetNode(c, id) for _, fn := range f { fn(node) } - url := fmt.Sprintf("/nodes/%s/update?version=%d", node.ID, node.Version.Index) - status, out, err := d.SockRequest("POST", url, node.Spec) - if i < 10 && strings.Contains(string(out), "update out of sequence") { + + err = cli.NodeUpdate(context.Background(), node.ID, node.Version, node.Spec) + if i < 10 && err != nil && strings.Contains(err.Error(), "update out of sequence") { time.Sleep(100 * time.Millisecond) continue } - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) + c.Assert(err, checker.IsNil) return } } // ListNodes returns the list of the current swarm nodes func (d *Swarm) ListNodes(c *check.C) []swarm.Node { - status, out, err := d.SockRequest("GET", "/nodes", nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + nodes, err := cli.NodeList(context.Background(), types.NodeListOptions{}) + c.Assert(err, checker.IsNil) - nodes := []swarm.Node{} - c.Assert(json.Unmarshal(out, &nodes), checker.IsNil) return nodes } // ListServices returns the list of the current swarm services func (d *Swarm) ListServices(c *check.C) []swarm.Service { - status, out, err := d.SockRequest("GET", "/services", nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - services := []swarm.Service{} - c.Assert(json.Unmarshal(out, &services), checker.IsNil) + services, err := cli.ServiceList(context.Background(), types.ServiceListOptions{}) + c.Assert(err, checker.IsNil) return services } // CreateSecret creates a secret given the specified spec func (d *Swarm) CreateSecret(c *check.C, secretSpec swarm.SecretSpec) string { - status, out, err := d.SockRequest("POST", "/secrets/create", secretSpec) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf("output: %q", string(out))) + scr, err := cli.SecretCreate(context.Background(), secretSpec) + c.Assert(err, checker.IsNil) - var scr types.SecretCreateResponse - c.Assert(json.Unmarshal(out, &scr), checker.IsNil) return scr.ID } // ListSecrets returns the list of the current swarm secrets func (d *Swarm) ListSecrets(c *check.C) []swarm.Secret { - status, out, err := d.SockRequest("GET", "/secrets", nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - secrets := []swarm.Secret{} - c.Assert(json.Unmarshal(out, &secrets), checker.IsNil) + secrets, err := cli.SecretList(context.Background(), types.SecretListOptions{}) + c.Assert(err, checker.IsNil) return secrets } // GetSecret returns a swarm secret identified by the specified id func (d *Swarm) GetSecret(c *check.C, id string) *swarm.Secret { - var secret swarm.Secret - status, out, err := d.SockRequest("GET", "/secrets/"+id, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) - c.Assert(json.Unmarshal(out, &secret), checker.IsNil) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + secret, _, err := cli.SecretInspectWithRaw(context.Background(), id) + c.Assert(err, checker.IsNil) return &secret } // DeleteSecret removes the swarm secret identified by the specified id func (d *Swarm) DeleteSecret(c *check.C, id string) { - status, out, err := d.SockRequest("DELETE", "/secrets/"+id, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusNoContent, check.Commentf("output: %q", string(out))) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + err = cli.SecretRemove(context.Background(), id) + c.Assert(err, checker.IsNil) } // UpdateSecret updates the swarm secret identified by the specified id // Currently, only label update is supported. func (d *Swarm) UpdateSecret(c *check.C, id string, f ...SecretConstructor) { + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + secret := d.GetSecret(c, id) for _, fn := range f { fn(secret) } - url := fmt.Sprintf("/secrets/%s/update?version=%d", secret.ID, secret.Version.Index) - status, out, err := d.SockRequest("POST", url, secret.Spec) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) + + err = cli.SecretUpdate(context.Background(), secret.ID, secret.Version, secret.Spec) + + c.Assert(err, checker.IsNil) } // CreateConfig creates a config given the specified spec func (d *Swarm) CreateConfig(c *check.C, configSpec swarm.ConfigSpec) string { - status, out, err := d.SockRequest("POST", "/configs/create", configSpec) - - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf("output: %q", string(out))) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - var scr types.ConfigCreateResponse - c.Assert(json.Unmarshal(out, &scr), checker.IsNil) + scr, err := cli.ConfigCreate(context.Background(), configSpec) + c.Assert(err, checker.IsNil) return scr.ID } // ListConfigs returns the list of the current swarm configs func (d *Swarm) ListConfigs(c *check.C) []swarm.Config { - status, out, err := d.SockRequest("GET", "/configs", nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - configs := []swarm.Config{} - c.Assert(json.Unmarshal(out, &configs), checker.IsNil) + configs, err := cli.ConfigList(context.Background(), types.ConfigListOptions{}) + c.Assert(err, checker.IsNil) return configs } // GetConfig returns a swarm config identified by the specified id func (d *Swarm) GetConfig(c *check.C, id string) *swarm.Config { - var config swarm.Config - status, out, err := d.SockRequest("GET", "/configs/"+id, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) - c.Assert(json.Unmarshal(out, &config), checker.IsNil) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + config, _, err := cli.ConfigInspectWithRaw(context.Background(), id) + c.Assert(err, checker.IsNil) return &config } // DeleteConfig removes the swarm config identified by the specified id func (d *Swarm) DeleteConfig(c *check.C, id string) { - status, out, err := d.SockRequest("DELETE", "/configs/"+id, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusNoContent, check.Commentf("output: %q", string(out))) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + err = cli.ConfigRemove(context.Background(), id) + c.Assert(err, checker.IsNil) } // UpdateConfig updates the swarm config identified by the specified id // Currently, only label update is supported. func (d *Swarm) UpdateConfig(c *check.C, id string, f ...ConfigConstructor) { + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + config := d.GetConfig(c, id) for _, fn := range f { fn(config) } - url := fmt.Sprintf("/configs/%s/update?version=%d", config.ID, config.Version.Index) - status, out, err := d.SockRequest("POST", url, config.Spec) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) + + err = cli.ConfigUpdate(context.Background(), config.ID, config.Version, config.Spec) + c.Assert(err, checker.IsNil) } // GetSwarm returns the current swarm object func (d *Swarm) GetSwarm(c *check.C) swarm.Swarm { - var sw swarm.Swarm - status, out, err := d.SockRequest("GET", "/swarm", nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) - c.Assert(json.Unmarshal(out, &sw), checker.IsNil) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + sw, err := cli.SwarmInspect(context.Background()) + c.Assert(err, checker.IsNil) return sw } // UpdateSwarm updates the current swarm object with the specified spec constructors func (d *Swarm) UpdateSwarm(c *check.C, f ...SpecConstructor) { + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + sw := d.GetSwarm(c) for _, fn := range f { fn(&sw.Spec) } - url := fmt.Sprintf("/swarm/update?version=%d", sw.Version.Index) - status, out, err := d.SockRequest("POST", url, sw.Spec) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) + + err = cli.SwarmUpdate(context.Background(), sw.Version, sw.Spec, swarm.UpdateFlags{}) + c.Assert(err, checker.IsNil) } // RotateTokens update the swarm to rotate tokens func (d *Swarm) RotateTokens(c *check.C) { - var sw swarm.Swarm - status, out, err := d.SockRequest("GET", "/swarm", nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) - c.Assert(json.Unmarshal(out, &sw), checker.IsNil) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + sw, err := cli.SwarmInspect(context.Background()) + c.Assert(err, checker.IsNil) - url := fmt.Sprintf("/swarm/update?version=%d&rotateWorkerToken=true&rotateManagerToken=true", sw.Version.Index) - status, out, err = d.SockRequest("POST", url, sw.Spec) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) + flags := swarm.UpdateFlags{ + RotateManagerToken: true, + RotateWorkerToken: true, + } + + err = cli.SwarmUpdate(context.Background(), sw.Version, sw.Spec, flags) + c.Assert(err, checker.IsNil) } // JoinTokens returns the current swarm join tokens func (d *Swarm) JoinTokens(c *check.C) swarm.JoinTokens { - var sw swarm.Swarm - status, out, err := d.SockRequest("GET", "/swarm", nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) - c.Assert(json.Unmarshal(out, &sw), checker.IsNil) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + sw, err := cli.SwarmInspect(context.Background()) + c.Assert(err, checker.IsNil) return sw.JoinTokens } @@ -570,17 +612,14 @@ func (d *Swarm) CheckControlAvailable(c *check.C) (interface{}, check.CommentInt // CheckLeader returns whether there is a leader on the swarm or not func (d *Swarm) CheckLeader(c *check.C) (interface{}, check.CommentInterface) { + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + errList := check.Commentf("could not get node list") - status, out, err := d.SockRequest("GET", "/nodes", nil) - if err != nil { - return err, errList - } - if status != http.StatusOK { - return fmt.Errorf("expected http status OK, got: %d", status), errList - } - var ls []swarm.Node - if err := json.Unmarshal(out, &ls); err != nil { + ls, err := cli.NodeList(context.Background(), types.NodeListOptions{}) + if err != nil { return err, errList } diff --git a/vendor/github.com/docker/docker/integration-cli/daemon/daemon_windows.go b/vendor/github.com/docker/docker/integration-cli/daemon/daemon_windows.go index f8df27cf5..e445aa68c 100644 --- a/vendor/github.com/docker/docker/integration-cli/daemon/daemon_windows.go +++ b/vendor/github.com/docker/docker/integration-cli/daemon/daemon_windows.go @@ -3,47 +3,19 @@ package daemon import ( "fmt" "strconv" - "syscall" - "unsafe" "github.com/go-check/check" "golang.org/x/sys/windows" ) -func openEvent(desiredAccess uint32, inheritHandle bool, name string, proc *windows.LazyProc) (handle windows.Handle, err error) { - namep, _ := windows.UTF16PtrFromString(name) - var _p2 uint32 - if inheritHandle { - _p2 = 1 - } - r0, _, e1 := proc.Call(uintptr(desiredAccess), uintptr(_p2), uintptr(unsafe.Pointer(namep))) - handle = windows.Handle(r0) - if handle == windows.InvalidHandle { - err = e1 - } - return -} - -func pulseEvent(handle windows.Handle, proc *windows.LazyProc) (err error) { - r0, _, _ := proc.Call(uintptr(handle)) - if r0 != 0 { - err = syscall.Errno(r0) - } - return -} - // SignalDaemonDump sends a signal to the daemon to write a dump file func SignalDaemonDump(pid int) { - modkernel32 := windows.NewLazySystemDLL("kernel32.dll") - procOpenEvent := modkernel32.NewProc("OpenEventW") - procPulseEvent := modkernel32.NewProc("PulseEvent") - - ev := "Global\\docker-daemon-" + strconv.Itoa(pid) - h2, _ := openEvent(0x0002, false, ev, procOpenEvent) - if h2 == 0 { + ev, _ := windows.UTF16PtrFromString("Global\\docker-daemon-" + strconv.Itoa(pid)) + h2, err := windows.OpenEvent(0x0002, false, ev) + if h2 == 0 || err != nil { return } - pulseEvent(h2, procPulseEvent) + windows.PulseEvent(h2) } func signalDaemonReload(pid int) error { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_attach_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_attach_test.go index 11f7340c1..a3aa40f6a 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_attach_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_attach_test.go @@ -15,7 +15,6 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/request" "github.com/docker/docker/pkg/stdcopy" - "github.com/docker/docker/pkg/testutil" "github.com/go-check/check" "golang.org/x/net/websocket" ) @@ -80,18 +79,20 @@ func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *check.C) { resp, err := client.Do(req) // connection will shutdown, err should be "persistent connection closed" c.Assert(resp.StatusCode, checker.Equals, http.StatusNotFound) - content, err := testutil.ReadBody(resp.Body) + content, err := request.ReadBody(resp.Body) c.Assert(err, checker.IsNil) expected := "No such container: doesnotexist\r\n" c.Assert(string(content), checker.Equals, expected) } func (s *DockerSuite) TestGetContainersWsAttachContainerNotFound(c *check.C) { - status, body, err := request.SockRequest("GET", "/containers/doesnotexist/attach/ws", nil, daemonHost()) - c.Assert(status, checker.Equals, http.StatusNotFound) + res, body, err := request.Get("/containers/doesnotexist/attach/ws") + c.Assert(res.StatusCode, checker.Equals, http.StatusNotFound) + c.Assert(err, checker.IsNil) + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) expected := "No such container: doesnotexist" - c.Assert(getErrorMessage(c, body), checker.Contains, expected) + c.Assert(getErrorMessage(c, b), checker.Contains, expected) } func (s *DockerSuite) TestPostContainersAttach(c *check.C) { @@ -178,6 +179,7 @@ func (s *DockerSuite) TestPostContainersAttach(c *check.C) { // Make sure we don't see "hello" if Logs is false client, err := client.NewEnvClient() c.Assert(err, checker.IsNil) + defer client.Close() cid, _ = dockerCmd(c, "run", "-di", "busybox", "/bin/sh", "-c", "echo hello; cat") cid = strings.TrimSpace(cid) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_auth_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_auth_test.go index cc903c01f..a1f7a098c 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_auth_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_auth_test.go @@ -1,12 +1,11 @@ package main import ( - "net/http" - "github.com/docker/docker/api/types" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/integration-cli/request" "github.com/go-check/check" + "golang.org/x/net/context" ) // Test case for #22244 @@ -16,11 +15,11 @@ func (s *DockerSuite) TestAuthAPI(c *check.C) { Username: "no-user", Password: "no-password", } + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + _, err = cli.RegistryLogin(context.Background(), config) expected := "Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password" - status, body, err := request.SockRequest("POST", "/auth", config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusUnauthorized) - msg := getErrorMessage(c, body) - c.Assert(msg, checker.Contains, expected, check.Commentf("Expected: %v, got: %v", expected, msg)) + c.Assert(err.Error(), checker.Contains, expected) } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_build_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_build_test.go index fb6291782..423ebcf9f 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_build_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_build_test.go @@ -17,7 +17,6 @@ import ( "github.com/docker/docker/integration-cli/cli/build/fakegit" "github.com/docker/docker/integration-cli/cli/build/fakestorage" "github.com/docker/docker/integration-cli/request" - "github.com/docker/docker/pkg/testutil" "github.com/go-check/check" "github.com/moby/buildkit/session" "github.com/moby/buildkit/session/filesync" @@ -29,6 +28,7 @@ import ( func (s *DockerSuite) TestBuildAPIDockerFileRemote(c *check.C) { testRequires(c, NotUserNamespace) + var testD string if testEnv.DaemonPlatform() == "windows" { testD = `FROM busybox @@ -47,7 +47,7 @@ RUN find /tmp/` c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusOK) - buf, err := testutil.ReadBody(body) + buf, err := request.ReadBody(body) c.Assert(err, checker.IsNil) // Make sure Dockerfile exists. @@ -135,7 +135,7 @@ RUN echo 'right' c.Assert(res.StatusCode, checker.Equals, http.StatusOK) defer body.Close() - content, err := testutil.ReadBody(body) + content, err := request.ReadBody(body) c.Assert(err, checker.IsNil) // Build used the wrong dockerfile. @@ -153,7 +153,7 @@ RUN echo from dockerfile`, c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusOK) - buf, err := testutil.ReadBody(body) + buf, err := request.ReadBody(body) c.Assert(err, checker.IsNil) out := string(buf) @@ -174,7 +174,7 @@ RUN echo from Dockerfile`, c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusOK) - buf, err := testutil.ReadBody(body) + buf, err := request.ReadBody(body) c.Assert(err, checker.IsNil) out := string(buf) @@ -196,7 +196,7 @@ RUN echo from dockerfile`, c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusOK) - buf, err := testutil.ReadBody(body) + buf, err := request.ReadBody(body) c.Assert(err, checker.IsNil) out := string(buf) @@ -243,7 +243,7 @@ func (s *DockerSuite) TestBuildAPIUnnormalizedTarPaths(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusOK) - out, err := testutil.ReadBody(body) + out, err := request.ReadBody(body) c.Assert(err, checker.IsNil) lines := strings.Split(string(out), "\n") c.Assert(len(lines), checker.GreaterThan, 1) @@ -280,7 +280,7 @@ func (s *DockerSuite) TestBuildOnBuildWithCopy(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusOK) - out, err := testutil.ReadBody(body) + out, err := request.ReadBody(body) c.Assert(err, checker.IsNil) c.Assert(string(out), checker.Contains, "Successfully built") } @@ -299,7 +299,7 @@ func (s *DockerSuite) TestBuildOnBuildCache(c *check.C) { require.NoError(c, err) assert.Equal(c, http.StatusOK, res.StatusCode) - out, err := testutil.ReadBody(body) + out, err := request.ReadBody(body) require.NoError(c, err) assert.Contains(c, string(out), "Successfully built") return out @@ -361,7 +361,7 @@ func (s *DockerRegistrySuite) TestBuildCopyFromForcePull(c *check.C) { require.NoError(c, err) assert.Equal(c, http.StatusOK, res.StatusCode) - out, err := testutil.ReadBody(body) + out, err := request.ReadBody(body) require.NoError(c, err) assert.Contains(c, string(out), "Successfully built") } @@ -405,11 +405,116 @@ func (s *DockerSuite) TestBuildAddRemoteNoDecompress(c *check.C) { require.NoError(c, err) assert.Equal(c, http.StatusOK, res.StatusCode) - out, err := testutil.ReadBody(body) + out, err := request.ReadBody(body) + require.NoError(c, err) + assert.Contains(c, string(out), "Successfully built") +} + +func (s *DockerSuite) TestBuildChownOnCopy(c *check.C) { + testRequires(c, DaemonIsLinux) + dockerfile := `FROM busybox + RUN echo 'test1:x:1001:1001::/bin:/bin/false' >> /etc/passwd + RUN echo 'test1:x:1001:' >> /etc/group + RUN echo 'test2:x:1002:' >> /etc/group + COPY --chown=test1:1002 . /new_dir + RUN ls -l / + RUN [ $(ls -l / | grep new_dir | awk '{print $3":"$4}') = 'test1:test2' ] + RUN [ $(ls -nl / | grep new_dir | awk '{print $3":"$4}') = '1001:1002' ] + ` + ctx := fakecontext.New(c, "", + fakecontext.WithDockerfile(dockerfile), + fakecontext.WithFile("test_file1", "some test content"), + ) + defer ctx.Close() + + res, body, err := request.Post( + "/build", + request.RawContent(ctx.AsTarReader(c)), + request.ContentType("application/x-tar")) + c.Assert(err, checker.IsNil) + c.Assert(res.StatusCode, checker.Equals, http.StatusOK) + + out, err := request.ReadBody(body) require.NoError(c, err) assert.Contains(c, string(out), "Successfully built") } +func (s *DockerSuite) TestBuildCopyCacheOnFileChange(c *check.C) { + + dockerfile := `FROM busybox +COPY file /file` + + ctx1 := fakecontext.New(c, "", + fakecontext.WithDockerfile(dockerfile), + fakecontext.WithFile("file", "foo")) + ctx2 := fakecontext.New(c, "", + fakecontext.WithDockerfile(dockerfile), + fakecontext.WithFile("file", "bar")) + + var build = func(ctx *fakecontext.Fake) string { + res, body, err := request.Post("/build", + request.RawContent(ctx.AsTarReader(c)), + request.ContentType("application/x-tar")) + + require.NoError(c, err) + assert.Equal(c, http.StatusOK, res.StatusCode) + + out, err := request.ReadBody(body) + + ids := getImageIDsFromBuild(c, out) + return ids[len(ids)-1] + } + + id1 := build(ctx1) + id2 := build(ctx1) + id3 := build(ctx2) + + if id1 != id2 { + c.Fatal("didn't use the cache") + } + if id1 == id3 { + c.Fatal("COPY With different source file should not share same cache") + } +} + +func (s *DockerSuite) TestBuildAddCacheOnFileChange(c *check.C) { + + dockerfile := `FROM busybox +ADD file /file` + + ctx1 := fakecontext.New(c, "", + fakecontext.WithDockerfile(dockerfile), + fakecontext.WithFile("file", "foo")) + ctx2 := fakecontext.New(c, "", + fakecontext.WithDockerfile(dockerfile), + fakecontext.WithFile("file", "bar")) + + var build = func(ctx *fakecontext.Fake) string { + res, body, err := request.Post("/build", + request.RawContent(ctx.AsTarReader(c)), + request.ContentType("application/x-tar")) + + require.NoError(c, err) + assert.Equal(c, http.StatusOK, res.StatusCode) + + out, err := request.ReadBody(body) + + ids := getImageIDsFromBuild(c, out) + return ids[len(ids)-1] + } + + id1 := build(ctx1) + id2 := build(ctx1) + id3 := build(ctx2) + + if id1 != id2 { + c.Fatal("didn't use the cache") + } + if id1 == id3 { + c.Fatal("COPY With different source file should not share same cache") + } +} + func (s *DockerSuite) TestBuildWithSession(c *check.C) { testRequires(c, ExperimentalDaemon) @@ -461,7 +566,7 @@ func (s *DockerSuite) TestBuildWithSession(c *check.C) { require.NoError(c, err) assert.Equal(c, http.StatusOK, res.StatusCode) - outBytes, err := testutil.ReadBody(body) + outBytes, err := request.ReadBody(body) require.NoError(c, err) assert.Contains(c, string(outBytes), "Successfully built") assert.Equal(c, strings.Count(string(outBytes), "Using cache"), 4) @@ -499,7 +604,7 @@ func testBuildWithSession(c *check.C, dir, dockerfile string) (outStr string) { return err } assert.Equal(c, res.StatusCode, http.StatusOK) - out, err := testutil.ReadBody(body) + out, err := request.ReadBody(body) require.NoError(c, err) assert.Contains(c, string(out), "Successfully built") sess.Close() diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_containers_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_containers_test.go index 25c724425..cd3566f4b 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_containers_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_containers_test.go @@ -8,10 +8,10 @@ import ( "io" "io/ioutil" "net/http" - "net/url" "os" "path/filepath" "regexp" + "runtime" "strconv" "strings" "time" @@ -20,6 +20,7 @@ import ( containertypes "github.com/docker/docker/api/types/container" mounttypes "github.com/docker/docker/api/types/mount" networktypes "github.com/docker/docker/api/types/network" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" @@ -27,9 +28,13 @@ import ( "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/stringid" - "github.com/docker/docker/pkg/testutil" "github.com/docker/docker/volume" + "github.com/docker/go-connections/nat" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/poll" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "golang.org/x/net/context" ) func (s *DockerSuite) TestContainerAPIGetAll(c *check.C) { @@ -37,35 +42,42 @@ func (s *DockerSuite) TestContainerAPIGetAll(c *check.C) { name := "getall" dockerCmd(c, "run", "--name", name, "busybox", "true") - status, body, err := request.SockRequest("GET", "/containers/json?all=1", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) + defer cli.Close() - var inspectJSON []struct { - Names []string + options := types.ContainerListOptions{ + All: true, } - err = json.Unmarshal(body, &inspectJSON) - c.Assert(err, checker.IsNil, check.Commentf("unable to unmarshal response body")) - - c.Assert(inspectJSON, checker.HasLen, startCount+1) - - actual := inspectJSON[0].Names[0] + containers, err := cli.ContainerList(context.Background(), options) + c.Assert(err, checker.IsNil) + c.Assert(containers, checker.HasLen, startCount+1) + actual := containers[0].Names[0] c.Assert(actual, checker.Equals, "/"+name) } // regression test for empty json field being omitted #13691 func (s *DockerSuite) TestContainerAPIGetJSONNoFieldsOmitted(c *check.C) { + startCount := getContainerCount(c) dockerCmd(c, "run", "busybox", "true") - status, body, err := request.SockRequest("GET", "/containers/json?all=1", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) + defer cli.Close() + + options := types.ContainerListOptions{ + All: true, + } + containers, err := cli.ContainerList(context.Background(), options) + c.Assert(err, checker.IsNil) + c.Assert(containers, checker.HasLen, startCount+1) + actual := fmt.Sprintf("%+v", containers[0]) // empty Labels field triggered this bug, make sense to check for everything // cause even Ports for instance can trigger this bug // better safe than sorry.. fields := []string{ - "Id", + "ID", "Names", "Image", "Command", @@ -79,7 +91,7 @@ func (s *DockerSuite) TestContainerAPIGetJSONNoFieldsOmitted(c *check.C) { // decoding into types.Container do not work since it eventually unmarshal // and empty field to an empty go map, so we just check for a string for _, f := range fields { - if !strings.Contains(string(body), f) { + if !strings.Contains(actual, f) { c.Fatalf("Field %s is missing and it shouldn't", f) } } @@ -87,7 +99,7 @@ func (s *DockerSuite) TestContainerAPIGetJSONNoFieldsOmitted(c *check.C) { type containerPs struct { Names []string - Ports []map[string]interface{} + Ports []types.Port } // regression test for non-empty fields from #13901 @@ -98,30 +110,30 @@ func (s *DockerSuite) TestContainerAPIPsOmitFields(c *check.C) { port := 80 runSleepingContainer(c, "--name", name, "--expose", strconv.Itoa(port)) - status, body, err := request.SockRequest("GET", "/containers/json?all=1", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) + defer cli.Close() - var resp []containerPs - err = json.Unmarshal(body, &resp) + options := types.ContainerListOptions{ + All: true, + } + containers, err := cli.ContainerList(context.Background(), options) c.Assert(err, checker.IsNil) - - var foundContainer *containerPs - for _, container := range resp { - for _, testName := range container.Names { + var foundContainer containerPs + for _, c := range containers { + for _, testName := range c.Names { if "/"+name == testName { - foundContainer = &container + foundContainer.Names = c.Names + foundContainer.Ports = c.Ports break } } } c.Assert(foundContainer.Ports, checker.HasLen, 1) - c.Assert(foundContainer.Ports[0]["PrivatePort"], checker.Equals, float64(port)) - _, ok := foundContainer.Ports[0]["PublicPort"] - c.Assert(ok, checker.Not(checker.Equals), true) - _, ok = foundContainer.Ports[0]["IP"] - c.Assert(ok, checker.Not(checker.Equals), true) + c.Assert(foundContainer.Ports[0].PrivatePort, checker.Equals, uint16(port)) + c.Assert(foundContainer.Ports[0].PublicPort, checker.NotNil) + c.Assert(foundContainer.Ports[0].IP, checker.NotNil) } func (s *DockerSuite) TestContainerAPIGetExport(c *check.C) { @@ -130,12 +142,15 @@ func (s *DockerSuite) TestContainerAPIGetExport(c *check.C) { name := "exportcontainer" dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test") - status, body, err := request.SockRequest("GET", "/containers/"+name+"/export", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) + defer cli.Close() + body, err := cli.ContainerExport(context.Background(), name) + c.Assert(err, checker.IsNil) + defer body.Close() found := false - for tarReader := tar.NewReader(bytes.NewReader(body)); ; { + for tarReader := tar.NewReader(body); ; { h, err := tarReader.Next() if err != nil && err == io.EOF { break @@ -154,15 +169,12 @@ func (s *DockerSuite) TestContainerAPIGetChanges(c *check.C) { name := "changescontainer" dockerCmd(c, "run", "--name", name, "busybox", "rm", "/etc/passwd") - status, body, err := request.SockRequest("GET", "/containers/"+name+"/changes", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) + defer cli.Close() - changes := []struct { - Kind int - Path string - }{} - c.Assert(json.Unmarshal(body, &changes), checker.IsNil, check.Commentf("unable to unmarshal response body")) + changes, err := cli.ContainerDiff(context.Background(), name) + c.Assert(err, checker.IsNil) // Check the changelog for removal of /etc/passwd success := false @@ -181,14 +193,19 @@ func (s *DockerSuite) TestGetContainerStats(c *check.C) { runSleepingContainer(c, "--name", name) type b struct { - status int - body []byte - err error + stats types.ContainerStats + err error } + bc := make(chan b, 1) go func() { - status, body, err := request.SockRequest("GET", "/containers/"+name+"/stats", nil, daemonHost()) - bc <- b{status, body, err} + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + stats, err := cli.ContainerStats(context.Background(), name, true) + c.Assert(err, checker.IsNil) + bc <- b{stats, err} }() // allow some time to stream the stats from the container @@ -201,10 +218,8 @@ func (s *DockerSuite) TestGetContainerStats(c *check.C) { case <-time.After(2 * time.Second): c.Fatal("stream was not closed after container was removed") case sr := <-bc: - c.Assert(sr.err, checker.IsNil) - c.Assert(sr.status, checker.Equals, http.StatusOK) - - dec := json.NewDecoder(bytes.NewBuffer(sr.body)) + dec := json.NewDecoder(sr.stats.Body) + defer sr.stats.Body.Close() var s *types.Stats // decode only one object from the stream c.Assert(dec.Decode(&s), checker.IsNil) @@ -215,16 +230,20 @@ func (s *DockerSuite) TestGetContainerStatsRmRunning(c *check.C) { out := runSleepingContainer(c) id := strings.TrimSpace(out) - buf := &testutil.ChannelBuffer{C: make(chan []byte, 1)} + buf := &ChannelBuffer{C: make(chan []byte, 1)} defer buf.Close() - _, body, err := request.Get("/containers/"+id+"/stats?stream=1", request.JSON) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - defer body.Close() + defer cli.Close() + + stats, err := cli.ContainerStats(context.Background(), id, true) + c.Assert(err, checker.IsNil) + defer stats.Body.Close() chErr := make(chan error, 1) go func() { - _, err = io.Copy(buf, body) + _, err = io.Copy(buf, stats.Body) chErr <- err }() @@ -243,6 +262,34 @@ func (s *DockerSuite) TestGetContainerStatsRmRunning(c *check.C) { c.Assert(<-chErr, checker.IsNil) } +// ChannelBuffer holds a chan of byte array that can be populate in a goroutine. +type ChannelBuffer struct { + C chan []byte +} + +// Write implements Writer. +func (c *ChannelBuffer) Write(b []byte) (int, error) { + c.C <- b + return len(b), nil +} + +// Close closes the go channel. +func (c *ChannelBuffer) Close() error { + close(c.C) + return nil +} + +// ReadTimeout reads the content of the channel in the specified byte array with +// the specified duration as timeout. +func (c *ChannelBuffer) ReadTimeout(p []byte, n time.Duration) (int, error) { + select { + case b := <-c.C: + return copy(p[0:], b), nil + case <-time.After(n): + return -1, fmt.Errorf("timeout reading from channel") + } +} + // regression test for gh13421 // previous test was just checking one stat entry so it didn't fail (stats with // stream false always return one stat) @@ -251,14 +298,19 @@ func (s *DockerSuite) TestGetContainerStatsStream(c *check.C) { runSleepingContainer(c, "--name", name) type b struct { - status int - body io.ReadCloser - err error + stats types.ContainerStats + err error } + bc := make(chan b, 1) go func() { - status, body, err := request.Get("/containers/" + name + "/stats") - bc <- b{status.StatusCode, body, err} + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + stats, err := cli.ContainerStats(context.Background(), name, true) + c.Assert(err, checker.IsNil) + bc <- b{stats, err} }() // allow some time to stream the stats from the container @@ -271,10 +323,8 @@ func (s *DockerSuite) TestGetContainerStatsStream(c *check.C) { case <-time.After(2 * time.Second): c.Fatal("stream was not closed after container was removed") case sr := <-bc: - c.Assert(sr.err, checker.IsNil) - c.Assert(sr.status, checker.Equals, http.StatusOK) - - b, err := ioutil.ReadAll(sr.body) + b, err := ioutil.ReadAll(sr.stats.Body) + defer sr.stats.Body.Close() c.Assert(err, checker.IsNil) s := string(b) // count occurrences of "read" of types.Stats @@ -289,14 +339,20 @@ func (s *DockerSuite) TestGetContainerStatsNoStream(c *check.C) { runSleepingContainer(c, "--name", name) type b struct { - status int - body []byte - err error + stats types.ContainerStats + err error } + bc := make(chan b, 1) + go func() { - status, body, err := request.SockRequest("GET", "/containers/"+name+"/stats?stream=0", nil, daemonHost()) - bc <- b{status, body, err} + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + stats, err := cli.ContainerStats(context.Background(), name, false) + c.Assert(err, checker.IsNil) + bc <- b{stats, err} }() // allow some time to stream the stats from the container @@ -309,10 +365,10 @@ func (s *DockerSuite) TestGetContainerStatsNoStream(c *check.C) { case <-time.After(2 * time.Second): c.Fatal("stream was not closed after container was removed") case sr := <-bc: - c.Assert(sr.err, checker.IsNil) - c.Assert(sr.status, checker.Equals, http.StatusOK) - - s := string(sr.body) + b, err := ioutil.ReadAll(sr.stats.Body) + defer sr.stats.Body.Close() + c.Assert(err, checker.IsNil) + s := string(b) // count occurrences of `"read"` of types.Stats c.Assert(strings.Count(s, `"read"`), checker.Equals, 1, check.Commentf("Expected only one stat streamed, got %d", strings.Count(s, `"read"`))) } @@ -322,24 +378,23 @@ func (s *DockerSuite) TestGetStoppedContainerStats(c *check.C) { name := "statscontainer" dockerCmd(c, "create", "--name", name, "busybox", "ps") - type stats struct { - status int - err error - } - chResp := make(chan stats) + chResp := make(chan error) // We expect an immediate response, but if it's not immediate, the test would hang, so put it in a goroutine // below we'll check this on a timeout. go func() { - resp, body, err := request.Get("/containers/" + name + "/stats") - body.Close() - chResp <- stats{resp.StatusCode, err} + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + resp, err := cli.ContainerStats(context.Background(), name, false) + defer resp.Body.Close() + chResp <- err }() select { - case r := <-chResp: - c.Assert(r.err, checker.IsNil) - c.Assert(r.status, checker.Equals, http.StatusOK) + case err := <-chResp: + c.Assert(err, checker.IsNil) case <-time.After(10 * time.Second): c.Fatal("timeout waiting for stats response for stopped container") } @@ -356,9 +411,12 @@ func (s *DockerSuite) TestContainerAPIPause(c *check.C) { out := cli.DockerCmd(c, "run", "-d", "busybox", "sleep", "30").Combined() ContainerID := strings.TrimSpace(out) - resp, _, err := request.Post("/containers/" + ContainerID + "/pause") + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + err = cli.ContainerPause(context.Background(), ContainerID) c.Assert(err, checker.IsNil) - c.Assert(resp.StatusCode, checker.Equals, http.StatusNoContent) pausedContainers := getPaused(c) @@ -366,9 +424,8 @@ func (s *DockerSuite) TestContainerAPIPause(c *check.C) { c.Fatalf("there should be one paused container and not %d", len(pausedContainers)) } - resp, _, err = request.Post("/containers/" + ContainerID + "/unpause") + err = cli.ContainerUnpause(context.Background(), ContainerID) c.Assert(err, checker.IsNil) - c.Assert(resp.StatusCode, checker.Equals, http.StatusNoContent) pausedContainers = getPaused(c) c.Assert(pausedContainers, checker.HasLen, 0, check.Commentf("There should be no paused container.")) @@ -380,15 +437,12 @@ func (s *DockerSuite) TestContainerAPITop(c *check.C) { id := strings.TrimSpace(string(out)) c.Assert(waitRun(id), checker.IsNil) - type topResp struct { - Titles []string - Processes [][]string - } - var top topResp - status, b, err := request.SockRequest("GET", "/containers/"+id+"/top?ps_args=aux", nil, daemonHost()) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + top, err := cli.ContainerTop(context.Background(), id, []string{"aux"}) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) - c.Assert(json.Unmarshal(b, &top), checker.IsNil) c.Assert(top.Titles, checker.HasLen, 11, check.Commentf("expected 11 titles, found %d: %v", len(top.Titles), top.Titles)) if top.Titles[0] != "USER" || top.Titles[10] != "COMMAND" { @@ -405,15 +459,12 @@ func (s *DockerSuite) TestContainerAPITopWindows(c *check.C) { id := strings.TrimSpace(string(out)) c.Assert(waitRun(id), checker.IsNil) - type topResp struct { - Titles []string - Processes [][]string - } - var top topResp - status, b, err := request.SockRequest("GET", "/containers/"+id+"/top", nil, daemonHost()) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + top, err := cli.ContainerTop(context.Background(), id, nil) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) - c.Assert(json.Unmarshal(b, &top), checker.IsNil) c.Assert(top.Titles, checker.HasLen, 4, check.Commentf("expected 4 titles, found %d: %v", len(top.Titles), top.Titles)) if top.Titles[0] != "Name" || top.Titles[3] != "Private Working Set" { @@ -437,16 +488,16 @@ func (s *DockerSuite) TestContainerAPICommit(c *check.C) { cName := "testapicommit" dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test") - name := "testcontainerapicommit" - status, b, err := request.SockRequest("POST", "/commit?repo="+name+"&testtag=tag&container="+cName, nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) + defer cli.Close() - type resp struct { - ID string + options := types.ContainerCommitOptions{ + Reference: "testcontainerapicommit:testtag", } - var img resp - c.Assert(json.Unmarshal(b, &img), checker.IsNil) + + img, err := cli.ContainerCommit(context.Background(), cName, options) + c.Assert(err, checker.IsNil) cmd := inspectField(c, img.ID, "Config.Cmd") c.Assert(cmd, checker.Equals, "[/bin/sh -c touch /test]", check.Commentf("got wrong Cmd from commit: %q", cmd)) @@ -459,20 +510,20 @@ func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *check.C) { cName := "testapicommitwithconfig" dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test") - config := map[string]interface{}{ - "Labels": map[string]string{"key1": "value1", "key2": "value2"}, - } - - name := "testcontainerapicommitwithconfig" - status, b, err := request.SockRequest("POST", "/commit?repo="+name+"&container="+cName, config, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) + defer cli.Close() - type resp struct { - ID string + config := containertypes.Config{ + Labels: map[string]string{"key1": "value1", "key2": "value2"}} + + options := types.ContainerCommitOptions{ + Reference: "testcontainerapicommitwithconfig", + Config: &config, } - var img resp - c.Assert(json.Unmarshal(b, &img), checker.IsNil) + + img, err := cli.ContainerCommit(context.Background(), cName, options) + c.Assert(err, checker.IsNil) label1 := inspectFieldMap(c, img.ID, "Config.Labels", "key1") c.Assert(label1, checker.Equals, "value1") @@ -490,76 +541,79 @@ func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *check.C) { func (s *DockerSuite) TestContainerAPIBadPort(c *check.C) { // TODO Windows to Windows CI - Port this test testRequires(c, DaemonIsLinux) - config := map[string]interface{}{ - "Image": "busybox", - "Cmd": []string{"/bin/sh", "-c", "echo test"}, - "PortBindings": map[string]interface{}{ - "8080/tcp": []map[string]interface{}{ + + config := containertypes.Config{ + Image: "busybox", + Cmd: []string{"/bin/sh", "-c", "echo test"}, + } + + hostConfig := containertypes.HostConfig{ + PortBindings: nat.PortMap{ + "8080/tcp": []nat.PortBinding{ { - "HostIP": "", - "HostPort": "aa80", - }, + HostIP: "", + HostPort: "aa80"}, }, }, } - jsonData := bytes.NewBuffer(nil) - json.NewEncoder(jsonData).Encode(config) - - status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusInternalServerError) - c.Assert(getErrorMessage(c, body), checker.Equals, `invalid port specification: "aa80"`, check.Commentf("Incorrect error msg: %s", body)) + defer cli.Close() + + _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, "") + c.Assert(err.Error(), checker.Contains, `invalid port specification: "aa80"`) } func (s *DockerSuite) TestContainerAPICreate(c *check.C) { - config := map[string]interface{}{ - "Image": "busybox", - "Cmd": []string{"/bin/sh", "-c", "touch /test && ls /test"}, + config := containertypes.Config{ + Image: "busybox", + Cmd: []string{"/bin/sh", "-c", "touch /test && ls /test"}, } - status, b, err := request.SockRequest("POST", "/containers/create", config, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) + defer cli.Close() - type createResp struct { - ID string - } - var container createResp - c.Assert(json.Unmarshal(b, &container), checker.IsNil) + container, err := cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, "") + c.Assert(err, checker.IsNil) out, _ := dockerCmd(c, "start", "-a", container.ID) c.Assert(strings.TrimSpace(out), checker.Equals, "/test") } func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *check.C) { - config := map[string]interface{}{} - status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusInternalServerError) + defer cli.Close() - expected := "Config cannot be empty in order to create a container" - c.Assert(getErrorMessage(c, body), checker.Equals, expected) + _, err = cli.ContainerCreate(context.Background(), &containertypes.Config{}, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, "") + + expected := "No command specified" + c.Assert(err.Error(), checker.Contains, expected) } func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *check.C) { // Container creation must fail if client specified configurations for more than one network - config := map[string]interface{}{ - "Image": "busybox", - "NetworkingConfig": networktypes.NetworkingConfig{ - EndpointsConfig: map[string]*networktypes.EndpointSettings{ - "net1": {}, - "net2": {}, - "net3": {}, - }, + config := containertypes.Config{ + Image: "busybox", + } + + networkingConfig := networktypes.NetworkingConfig{ + EndpointsConfig: map[string]*networktypes.EndpointSettings{ + "net1": {}, + "net2": {}, + "net3": {}, }, } - status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusBadRequest) - msg := getErrorMessage(c, body) + defer cli.Close() + + _, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networkingConfig, "") + msg := err.Error() // network name order in error message is not deterministic c.Assert(msg, checker.Contains, "Container cannot be connected to network endpoints") c.Assert(msg, checker.Contains, "net1") @@ -570,25 +624,22 @@ func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *check.C) { func (s *DockerSuite) TestContainerAPICreateWithHostName(c *check.C) { domainName := "test-domain" hostName := "test-hostname" - config := map[string]interface{}{ - "Image": "busybox", - "Hostname": hostName, - "Domainname": domainName, + config := containertypes.Config{ + Image: "busybox", + Hostname: hostName, + Domainname: domainName, } - status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) + defer cli.Close() - var container containertypes.ContainerCreateCreatedBody - c.Assert(json.Unmarshal(body, &container), checker.IsNil) + container, err := cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, "") + c.Assert(err, checker.IsNil) - status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost()) + containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) - var containerJSON types.ContainerJSON - c.Assert(json.Unmarshal(body, &containerJSON), checker.IsNil) c.Assert(containerJSON.Config.Hostname, checker.Equals, hostName, check.Commentf("Mismatched Hostname")) c.Assert(containerJSON.Config.Domainname, checker.Equals, domainName, check.Commentf("Mismatched Domainname")) } @@ -606,51 +657,51 @@ func (s *DockerSuite) TestContainerAPICreateOtherNetworkModes(c *check.C) { UtilCreateNetworkMode(c, "container:web1") } -func UtilCreateNetworkMode(c *check.C, networkMode string) { - config := map[string]interface{}{ - "Image": "busybox", - "HostConfig": map[string]interface{}{"NetworkMode": networkMode}, +func UtilCreateNetworkMode(c *check.C, networkMode containertypes.NetworkMode) { + config := containertypes.Config{ + Image: "busybox", } - status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost()) + hostConfig := containertypes.HostConfig{ + NetworkMode: networkMode, + } + + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) + defer cli.Close() - var container containertypes.ContainerCreateCreatedBody - c.Assert(json.Unmarshal(body, &container), checker.IsNil) + container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, "") + c.Assert(err, checker.IsNil) - status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost()) + containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) - var containerJSON types.ContainerJSON - c.Assert(json.Unmarshal(body, &containerJSON), checker.IsNil) c.Assert(containerJSON.HostConfig.NetworkMode, checker.Equals, containertypes.NetworkMode(networkMode), check.Commentf("Mismatched NetworkMode")) } func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *check.C) { // TODO Windows to Windows CI. The CpuShares part could be ported. testRequires(c, DaemonIsLinux) - config := map[string]interface{}{ - "Image": "busybox", - "CpuShares": 512, - "CpusetCpus": "0", + config := containertypes.Config{ + Image: "busybox", } - status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost()) - c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) - - var container containertypes.ContainerCreateCreatedBody - c.Assert(json.Unmarshal(body, &container), checker.IsNil) + hostConfig := containertypes.HostConfig{ + Resources: containertypes.Resources{ + CPUShares: 512, + CpusetCpus: "0", + }, + } - status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) + defer cli.Close() - var containerJSON types.ContainerJSON + container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, "") + c.Assert(err, checker.IsNil) - c.Assert(json.Unmarshal(body, &containerJSON), checker.IsNil) + containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) + c.Assert(err, checker.IsNil) out := inspectField(c, containerJSON.ID, "HostConfig.CpuShares") c.Assert(out, checker.Equals, "512") @@ -673,13 +724,13 @@ func (s *DockerSuite) TestContainerAPIVerifyHeader(c *check.C) { // Try with no content-type res, body, err := create("") c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) body.Close() // Try with wrong content-type res, body, err = create("application/xml") c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) body.Close() // now application/json @@ -705,9 +756,9 @@ func (s *DockerSuite) TestContainerAPIInvalidPortSyntax(c *check.C) { res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) c.Assert(string(b[:]), checker.Contains, "invalid port") } @@ -725,9 +776,9 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *check.C) res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) c.Assert(string(b[:]), checker.Contains, "invalid restart policy") } @@ -745,9 +796,9 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *check.C) { res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) c.Assert(string(b[:]), checker.Contains, "maximum retry count cannot be used with restart policy") } @@ -765,9 +816,9 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *check.C res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) c.Assert(string(b[:]), checker.Contains, "maximum retry count cannot be negative") } @@ -818,7 +869,7 @@ func (s *DockerSuite) TestContainerAPIPostCreateNull(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusCreated) - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) type createResp struct { ID string @@ -847,10 +898,10 @@ func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *check.C) { res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON) c.Assert(err, checker.IsNil) - b, err2 := testutil.ReadBody(body) + b, err2 := request.ReadBody(body) c.Assert(err2, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) c.Assert(string(b), checker.Contains, "Minimum memory limit allowed is 4MB") } @@ -859,10 +910,13 @@ func (s *DockerSuite) TestContainerAPIRename(c *check.C) { containerID := strings.TrimSpace(out) newName := "TestContainerAPIRenameNew" - statusCode, _, err := request.SockRequest("POST", "/containers/"+containerID+"/rename?name="+newName, nil, daemonHost()) + + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + err = cli.ContainerRename(context.Background(), containerID, newName) c.Assert(err, checker.IsNil) - // 204 No Content is expected, not 200 - c.Assert(statusCode, checker.Equals, http.StatusNoContent) name := inspectField(c, containerID, "Name") c.Assert(name, checker.Equals, "/"+newName, check.Commentf("Failed to rename container")) @@ -872,9 +926,12 @@ func (s *DockerSuite) TestContainerAPIKill(c *check.C) { name := "test-api-kill" runSleepingContainer(c, "-i", "--name", name) - status, _, err := request.SockRequest("POST", "/containers/"+name+"/kill", nil, daemonHost()) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + err = cli.ContainerKill(context.Background(), name, "SIGKILL") c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNoContent) state := inspectField(c, name, "State.Running") c.Assert(state, checker.Equals, "false", check.Commentf("got wrong State from container %s: %q", name, state)) @@ -883,10 +940,14 @@ func (s *DockerSuite) TestContainerAPIKill(c *check.C) { func (s *DockerSuite) TestContainerAPIRestart(c *check.C) { name := "test-api-restart" runSleepingContainer(c, "-di", "--name", name) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - status, _, err := request.SockRequest("POST", "/containers/"+name+"/restart?t=1", nil, daemonHost()) + timeout := 1 * time.Second + err = cli.ContainerRestart(context.Background(), name, &timeout) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNoContent) + c.Assert(waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second), checker.IsNil) } @@ -896,51 +957,59 @@ func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *check.C) { id := strings.TrimSpace(out) c.Assert(waitRun(id), checker.IsNil) - status, _, err := request.SockRequest("POST", "/containers/"+name+"/restart", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNoContent) + defer cli.Close() + + err = cli.ContainerRestart(context.Background(), name, nil) + c.Assert(err, checker.IsNil) + c.Assert(waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second), checker.IsNil) } func (s *DockerSuite) TestContainerAPIStart(c *check.C) { name := "testing-start" - config := map[string]interface{}{ - "Image": "busybox", - "Cmd": append([]string{"/bin/sh", "-c"}, sleepCommandForDaemonPlatform()...), - "OpenStdin": true, + config := containertypes.Config{ + Image: "busybox", + Cmd: append([]string{"/bin/sh", "-c"}, sleepCommandForDaemonPlatform()...), + OpenStdin: true, } - status, _, err := request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) + defer cli.Close() - status, _, err = request.SockRequest("POST", "/containers/"+name+"/start", nil, daemonHost()) + _, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, name) + c.Assert(err, checker.IsNil) + + err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{}) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNoContent) // second call to start should give 304 - status, _, err = request.SockRequest("POST", "/containers/"+name+"/start", nil, daemonHost()) + // maybe add ContainerStartWithRaw to test it + err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{}) c.Assert(err, checker.IsNil) // TODO(tibor): figure out why this doesn't work on windows - if testEnv.LocalDaemon() { - c.Assert(status, checker.Equals, http.StatusNotModified) - } } func (s *DockerSuite) TestContainerAPIStop(c *check.C) { name := "test-api-stop" runSleepingContainer(c, "-i", "--name", name) + timeout := 30 * time.Second - status, _, err := request.SockRequest("POST", "/containers/"+name+"/stop?t=30", nil, daemonHost()) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + err = cli.ContainerStop(context.Background(), name, &timeout) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNoContent) c.Assert(waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second), checker.IsNil) // second call to start should give 304 - status, _, err = request.SockRequest("POST", "/containers/"+name+"/stop?t=30", nil, daemonHost()) + // maybe add ContainerStartWithRaw to test it + err = cli.ContainerStop(context.Background(), name, &timeout) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNotModified) } func (s *DockerSuite) TestContainerAPIWait(c *check.C) { @@ -952,14 +1021,18 @@ func (s *DockerSuite) TestContainerAPIWait(c *check.C) { } dockerCmd(c, "run", "--name", name, "busybox", sleepCmd, "2") - status, body, err := request.SockRequest("POST", "/containers/"+name+"/wait", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) - c.Assert(waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second), checker.IsNil) + defer cli.Close() - var waitres containertypes.ContainerWaitOKBody - c.Assert(json.Unmarshal(body, &waitres), checker.IsNil) - c.Assert(waitres.StatusCode, checker.Equals, int64(0)) + waitresC, errC := cli.ContainerWait(context.Background(), name, "") + + select { + case err = <-errC: + c.Assert(err, checker.IsNil) + case waitres := <-waitresC: + c.Assert(waitres.StatusCode, checker.Equals, int64(0)) + } } func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *check.C) { @@ -969,10 +1042,10 @@ func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *check.C) { postData := types.CopyConfig{ Resource: "/test.txt", } - - status, _, err := request.SockRequest("POST", "/containers/"+name+"/copy", postData, daemonHost()) + // no copy in client/ + res, _, err := request.Post("/containers/"+name+"/copy", request.JSONBody(postData)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNotFound) + c.Assert(res.StatusCode, checker.Equals, http.StatusNotFound) } func (s *DockerSuite) TestContainerAPICopyPre124(c *check.C) { @@ -984,12 +1057,12 @@ func (s *DockerSuite) TestContainerAPICopyPre124(c *check.C) { Resource: "/test.txt", } - status, body, err := request.SockRequest("POST", "/v1.23/containers/"+name+"/copy", postData, daemonHost()) + res, body, err := request.Post("/v1.23/containers/"+name+"/copy", request.JSONBody(postData)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) + c.Assert(res.StatusCode, checker.Equals, http.StatusOK) found := false - for tarReader := tar.NewReader(bytes.NewReader(body)); ; { + for tarReader := tar.NewReader(body); ; { h, err := tarReader.Next() if err != nil { if err == io.EOF { @@ -1005,7 +1078,7 @@ func (s *DockerSuite) TestContainerAPICopyPre124(c *check.C) { c.Assert(found, checker.True) } -func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPr124(c *check.C) { +func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPre124(c *check.C) { testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later name := "test-container-api-copy-resource-empty" dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt") @@ -1014,10 +1087,12 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPr124(c *check.C) { Resource: "", } - status, body, err := request.SockRequest("POST", "/v1.23/containers/"+name+"/copy", postData, daemonHost()) + res, body, err := request.Post("/v1.23/containers/"+name+"/copy", request.JSONBody(postData)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusInternalServerError) - c.Assert(string(body), checker.Matches, "Path cannot be empty\n") + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + b, err := request.ReadBody(body) + c.Assert(err, checker.IsNil) + c.Assert(string(b), checker.Matches, "Path cannot be empty\n") } func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *check.C) { @@ -1029,10 +1104,13 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *check.C) Resource: "/notexist", } - status, body, err := request.SockRequest("POST", "/v1.23/containers/"+name+"/copy", postData, daemonHost()) + res, body, err := request.Post("/v1.23/containers/"+name+"/copy", request.JSONBody(postData)) + c.Assert(err, checker.IsNil) + c.Assert(res.StatusCode, checker.Equals, http.StatusNotFound) + + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusInternalServerError) - c.Assert(string(body), checker.Matches, "Could not find the file /notexist in container "+name+"\n") + c.Assert(string(b), checker.Matches, "Could not find the file /notexist in container "+name+"\n") } func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *check.C) { @@ -1041,9 +1119,9 @@ func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *check.C) { Resource: "/something", } - status, _, err := request.SockRequest("POST", "/v1.23/containers/notexists/copy", postData, daemonHost()) + res, _, err := request.Post("/v1.23/containers/notexists/copy", request.JSONBody(postData)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNotFound) + c.Assert(res.StatusCode, checker.Equals, http.StatusNotFound) } func (s *DockerSuite) TestContainerAPIDelete(c *check.C) { @@ -1054,27 +1132,38 @@ func (s *DockerSuite) TestContainerAPIDelete(c *check.C) { dockerCmd(c, "stop", id) - status, _, err := request.SockRequest("DELETE", "/containers/"+id, nil, daemonHost()) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + err = cli.ContainerRemove(context.Background(), id, types.ContainerRemoveOptions{}) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNoContent) } func (s *DockerSuite) TestContainerAPIDeleteNotExist(c *check.C) { - status, body, err := request.SockRequest("DELETE", "/containers/doesnotexist", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNotFound) - c.Assert(getErrorMessage(c, body), checker.Matches, "No such container: doesnotexist") + defer cli.Close() + + err = cli.ContainerRemove(context.Background(), "doesnotexist", types.ContainerRemoveOptions{}) + c.Assert(err.Error(), checker.Contains, "No such container: doesnotexist") } func (s *DockerSuite) TestContainerAPIDeleteForce(c *check.C) { out := runSleepingContainer(c) - id := strings.TrimSpace(out) c.Assert(waitRun(id), checker.IsNil) - status, _, err := request.SockRequest("DELETE", "/containers/"+id+"?force=1", nil, daemonHost()) + removeOptions := types.ContainerRemoveOptions{ + Force: true, + } + + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + err = cli.ContainerRemove(context.Background(), id, removeOptions) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNoContent) } func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *check.C) { @@ -1093,9 +1182,16 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *check.C) { links := inspectFieldJSON(c, id2, "HostConfig.Links") c.Assert(links, checker.Equals, "[\"/tlink1:/tlink2/tlink1\"]", check.Commentf("expected to have links between containers")) - status, b, err := request.SockRequest("DELETE", "/containers/tlink2/tlink1?link=1", nil, daemonHost()) + removeOptions := types.ContainerRemoveOptions{ + RemoveLinks: true, + } + + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + err = cli.ContainerRemove(context.Background(), "tlink2/tlink1", removeOptions) c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusNoContent, check.Commentf(string(b))) linksPostRm := inspectFieldJSON(c, id2, "HostConfig.Links") c.Assert(linksPostRm, checker.Equals, "null", check.Commentf("call to api deleteContainer links should have removed the specified links")) @@ -1107,9 +1203,13 @@ func (s *DockerSuite) TestContainerAPIDeleteConflict(c *check.C) { id := strings.TrimSpace(out) c.Assert(waitRun(id), checker.IsNil) - status, _, err := request.SockRequest("DELETE", "/containers/"+id, nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusConflict) + defer cli.Close() + + err = cli.ContainerRemove(context.Background(), id, types.ContainerRemoveOptions{}) + expected := "cannot remove a running container" + c.Assert(err.Error(), checker.Contains, expected) } func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *check.C) { @@ -1129,9 +1229,18 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *check.C) { _, err = os.Stat(source) c.Assert(err, checker.IsNil) - status, _, err := request.SockRequest("DELETE", "/containers/"+id+"?v=1&force=1", nil, daemonHost()) + removeOptions := types.ContainerRemoveOptions{ + Force: true, + RemoveVolumes: true, + } + + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNoContent) + defer cli.Close() + + err = cli.ContainerRemove(context.Background(), id, removeOptions) + c.Assert(err, check.IsNil) + _, err = os.Stat(source) c.Assert(os.IsNotExist(err), checker.True, check.Commentf("expected to get ErrNotExist error, got %v", err)) } @@ -1163,31 +1272,38 @@ func (s *DockerSuite) TestContainerAPIPostContainerStop(c *check.C) { containerID := strings.TrimSpace(out) c.Assert(waitRun(containerID), checker.IsNil) - statusCode, _, err := request.SockRequest("POST", "/containers/"+containerID+"/stop", nil, daemonHost()) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + err = cli.ContainerStop(context.Background(), containerID, nil) c.Assert(err, checker.IsNil) - // 204 No Content is expected, not 200 - c.Assert(statusCode, checker.Equals, http.StatusNoContent) c.Assert(waitInspect(containerID, "{{ .State.Running }}", "false", 60*time.Second), checker.IsNil) } // #14170 func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *check.C) { - config := struct { - Image string - Entrypoint string - Cmd []string - }{"busybox", "echo", []string{"hello", "world"}} - _, _, err := request.SockRequest("POST", "/containers/create?name=echotest", config, daemonHost()) + config := containertypes.Config{ + Image: "busybox", + Entrypoint: []string{"echo"}, + Cmd: []string{"hello", "world"}, + } + + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + _, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, "echotest") c.Assert(err, checker.IsNil) out, _ := dockerCmd(c, "start", "-a", "echotest") c.Assert(strings.TrimSpace(out), checker.Equals, "hello world") config2 := struct { Image string - Entrypoint []string + Entrypoint string Cmd []string - }{"busybox", []string{"echo"}, []string{"hello", "world"}} - _, _, err = request.SockRequest("POST", "/containers/create?name=echotest2", config2, daemonHost()) + }{"busybox", "echo", []string{"hello", "world"}} + _, _, err = request.Post("/containers/create?name=echotest2", request.JSONBody(config2)) c.Assert(err, checker.IsNil) out, _ = dockerCmd(c, "start", "-a", "echotest2") c.Assert(strings.TrimSpace(out), checker.Equals, "hello world") @@ -1195,21 +1311,26 @@ func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *c // #14170 func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *check.C) { - config := struct { - Image string - Entrypoint string - Cmd string - }{"busybox", "echo", "hello world"} - _, _, err := request.SockRequest("POST", "/containers/create?name=echotest", config, daemonHost()) + config := containertypes.Config{ + Image: "busybox", + Cmd: []string{"echo", "hello", "world"}, + } + + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + _, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, "echotest") c.Assert(err, checker.IsNil) out, _ := dockerCmd(c, "start", "-a", "echotest") c.Assert(strings.TrimSpace(out), checker.Equals, "hello world") config2 := struct { - Image string - Cmd []string - }{"busybox", []string{"echo", "hello", "world"}} - _, _, err = request.SockRequest("POST", "/containers/create?name=echotest2", config2, daemonHost()) + Image string + Entrypoint string + Cmd string + }{"busybox", "echo", "hello world"} + _, _, err = request.Post("/containers/create?name=echotest2", request.JSONBody(config2)) c.Assert(err, checker.IsNil) out, _ = dockerCmd(c, "start", "-a", "echotest2") c.Assert(strings.TrimSpace(out), checker.Equals, "hello world") @@ -1224,29 +1345,37 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *che CapAdd string CapDrop string }{"busybox", "NET_ADMIN", "SYS_ADMIN"} - status, _, err := request.SockRequest("POST", "/containers/create?name=capaddtest0", config, daemonHost()) + res, _, err := request.Post("/containers/create?name=capaddtest0", request.JSONBody(config)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) + c.Assert(res.StatusCode, checker.Equals, http.StatusCreated) - config2 := struct { - Image string - CapAdd []string - CapDrop []string - }{"busybox", []string{"NET_ADMIN", "SYS_ADMIN"}, []string{"SETGID"}} - status, _, err = request.SockRequest("POST", "/containers/create?name=capaddtest1", config2, daemonHost()) + config2 := containertypes.Config{ + Image: "busybox", + } + hostConfig := containertypes.HostConfig{ + CapAdd: []string{"NET_ADMIN", "SYS_ADMIN"}, + CapDrop: []string{"SETGID"}, + } + + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + _, err = cli.ContainerCreate(context.Background(), &config2, &hostConfig, &networktypes.NetworkingConfig{}, "capaddtest1") c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) } // #14915 func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *check.C) { testRequires(c, DaemonIsLinux) // Windows only support 1.25 or later - config := struct { - Image string - }{"busybox"} - status, _, err := request.SockRequest("POST", "/v1.18/containers/create", config, daemonHost()) + config := containertypes.Config{ + Image: "busybox", + } + + cli, err := request.NewEnvClientWithVersion("v1.18") + + _, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, "") c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) } // Ensure an error occurs when you have a container read-only rootfs but you @@ -1271,88 +1400,83 @@ func (s *DockerSuite) TestPutContainerArchiveErrSymlinkInVolumeToReadOnlyRootfs( // Attempt to extract to a symlink in the volume which points to a // directory outside the volume. This should cause an error because the // rootfs is read-only. - query := make(url.Values, 1) - query.Set("path", "/vol2/symlinkToAbsDir") - urlPath := fmt.Sprintf("/v1.20/containers/%s/archive?%s", cID, query.Encode()) - - statusCode, body, err := request.SockRequest("PUT", urlPath, nil, daemonHost()) + var httpClient *http.Client + cli, err := client.NewClient(daemonHost(), "v1.20", httpClient, map[string]string{}) c.Assert(err, checker.IsNil) - if !isCpCannotCopyReadOnly(fmt.Errorf(string(body))) { - c.Fatalf("expected ErrContainerRootfsReadonly error, but got %d: %s", statusCode, string(body)) - } -} - -func (s *DockerSuite) TestContainerAPIGetContainersJSONEmpty(c *check.C) { - status, body, err := request.SockRequest("GET", "/containers/json?all=1", nil, daemonHost()) - c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) - c.Assert(string(body), checker.Equals, "[]\n") + err = cli.CopyToContainer(context.Background(), cID, "/vol2/symlinkToAbsDir", nil, types.CopyToContainerOptions{}) + c.Assert(err.Error(), checker.Contains, "container rootfs is marked read-only") } func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *check.C) { // Not supported on Windows testRequires(c, DaemonIsLinux) - c1 := struct { - Image string - CpusetCpus string - }{"busybox", "1-42,,"} - name := "wrong-cpuset-cpus" - status, body, err := request.SockRequest("POST", "/containers/create?name="+name, c1, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusInternalServerError) + defer cli.Close() + + config := containertypes.Config{ + Image: "busybox", + } + hostConfig1 := containertypes.HostConfig{ + Resources: containertypes.Resources{ + CpusetCpus: "1-42,,", + }, + } + name := "wrong-cpuset-cpus" + + _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig1, &networktypes.NetworkingConfig{}, name) expected := "Invalid value 1-42,, for cpuset cpus" - c.Assert(getErrorMessage(c, body), checker.Equals, expected) + c.Assert(err.Error(), checker.Contains, expected) - c2 := struct { - Image string - CpusetMems string - }{"busybox", "42-3,1--"} + hostConfig2 := containertypes.HostConfig{ + Resources: containertypes.Resources{ + CpusetMems: "42-3,1--", + }, + } name = "wrong-cpuset-mems" - status, body, err = request.SockRequest("POST", "/containers/create?name="+name, c2, daemonHost()) - c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusInternalServerError) + _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig2, &networktypes.NetworkingConfig{}, name) expected = "Invalid value 42-3,1-- for cpuset mems" - c.Assert(getErrorMessage(c, body), checker.Equals, expected) + c.Assert(err.Error(), checker.Contains, expected) } func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *check.C) { // ShmSize is not supported on Windows testRequires(c, DaemonIsLinux) - config := map[string]interface{}{ - "Image": "busybox", - "HostConfig": map[string]interface{}{"ShmSize": -1}, + config := containertypes.Config{ + Image: "busybox", + } + hostConfig := containertypes.HostConfig{ + ShmSize: -1, } - status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusInternalServerError) - c.Assert(getErrorMessage(c, body), checker.Contains, "SHM size can not be less than 0") + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, "") + c.Assert(err.Error(), checker.Contains, "SHM size can not be less than 0") } func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *check.C) { // ShmSize is not supported on Windows testRequires(c, DaemonIsLinux) var defaultSHMSize int64 = 67108864 - config := map[string]interface{}{ - "Image": "busybox", - "Cmd": "mount", + config := containertypes.Config{ + Image: "busybox", + Cmd: []string{"mount"}, } - status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusCreated) - - var container containertypes.ContainerCreateCreatedBody - c.Assert(json.Unmarshal(body, &container), check.IsNil) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost()) + container, err := cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, "") c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusOK) - var containerJSON types.ContainerJSON - c.Assert(json.Unmarshal(body, &containerJSON), check.IsNil) + containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) + c.Assert(err, check.IsNil) c.Assert(containerJSON.HostConfig.ShmSize, check.Equals, defaultSHMSize) @@ -1366,25 +1490,20 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *check. func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *check.C) { // ShmSize is not supported on Windows testRequires(c, DaemonIsLinux) - config := map[string]interface{}{ - "Image": "busybox", - "HostConfig": map[string]interface{}{}, - "Cmd": "mount", + config := containertypes.Config{ + Image: "busybox", + Cmd: []string{"mount"}, } - status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusCreated) - - var container containertypes.ContainerCreateCreatedBody - c.Assert(json.Unmarshal(body, &container), check.IsNil) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost()) + container, err := cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, "") c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusOK) - var containerJSON types.ContainerJSON - c.Assert(json.Unmarshal(body, &containerJSON), check.IsNil) + containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) + c.Assert(err, check.IsNil) c.Assert(containerJSON.HostConfig.ShmSize, check.Equals, int64(67108864)) @@ -1398,25 +1517,24 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *check.C) { func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *check.C) { // ShmSize is not supported on Windows testRequires(c, DaemonIsLinux) - config := map[string]interface{}{ - "Image": "busybox", - "Cmd": "mount", - "HostConfig": map[string]interface{}{"ShmSize": 1073741824}, + config := containertypes.Config{ + Image: "busybox", + Cmd: []string{"mount"}, } - status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusCreated) + hostConfig := containertypes.HostConfig{ + ShmSize: 1073741824, + } - var container containertypes.ContainerCreateCreatedBody - c.Assert(json.Unmarshal(body, &container), check.IsNil) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost()) + container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, "") c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusOK) - var containerJSON types.ContainerJSON - c.Assert(json.Unmarshal(body, &containerJSON), check.IsNil) + containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) + c.Assert(err, check.IsNil) c.Assert(containerJSON.HostConfig.ShmSize, check.Equals, int64(1073741824)) @@ -1430,23 +1548,19 @@ func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *check.C) { func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(c *check.C) { // Swappiness is not supported on Windows testRequires(c, DaemonIsLinux) - config := map[string]interface{}{ - "Image": "busybox", + config := containertypes.Config{ + Image: "busybox", } - status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusCreated) - - var container containertypes.ContainerCreateCreatedBody - c.Assert(json.Unmarshal(body, &container), check.IsNil) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost()) + container, err := cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, "") c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusOK) - var containerJSON types.ContainerJSON - c.Assert(json.Unmarshal(body, &containerJSON), check.IsNil) + containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) + c.Assert(err, check.IsNil) c.Assert(containerJSON.HostConfig.MemorySwappiness, check.IsNil) } @@ -1456,42 +1570,43 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *che // OomScoreAdj is not supported on Windows testRequires(c, DaemonIsLinux) - config := struct { - Image string - OomScoreAdj int - }{"busybox", 1001} + config := containertypes.Config{ + Image: "busybox", + } + + hostConfig := containertypes.HostConfig{ + OomScoreAdj: 1001, + } + + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + name := "oomscoreadj-over" - status, b, err := request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusInternalServerError) + _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, name) expected := "Invalid value 1001, range for oom score adj is [-1000, 1000]" - msg := getErrorMessage(c, b) - if !strings.Contains(msg, expected) { - c.Fatalf("Expected output to contain %q, got %q", expected, msg) + c.Assert(err.Error(), checker.Contains, expected) + + hostConfig = containertypes.HostConfig{ + OomScoreAdj: -1001, } - config = struct { - Image string - OomScoreAdj int - }{"busybox", -1001} name = "oomscoreadj-low" - status, b, err = request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusInternalServerError) + _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, name) + expected = "Invalid value -1001, range for oom score adj is [-1000, 1000]" - msg = getErrorMessage(c, b) - if !strings.Contains(msg, expected) { - c.Fatalf("Expected output to contain %q, got %q", expected, msg) - } + c.Assert(err.Error(), checker.Contains, expected) } // test case for #22210 where an empty container name caused panic. func (s *DockerSuite) TestContainerAPIDeleteWithEmptyName(c *check.C) { - status, out, err := request.SockRequest("DELETE", "/containers/", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusBadRequest) - c.Assert(string(out), checker.Contains, "No container name or ID supplied") + defer cli.Close() + + err = cli.ContainerRemove(context.Background(), "", types.ContainerRemoveOptions{}) + c.Assert(err.Error(), checker.Contains, "No such container") } func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *check.C) { @@ -1499,31 +1614,33 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *check.C) { testRequires(c, DaemonIsLinux) name := "testing-network-disabled" - config := map[string]interface{}{ - "Image": "busybox", - "Cmd": []string{"top"}, - "NetworkDisabled": true, + + config := containertypes.Config{ + Image: "busybox", + Cmd: []string{"top"}, + NetworkDisabled: true, } - status, _, err := request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) + defer cli.Close() - status, _, err = request.SockRequest("POST", "/containers/"+name+"/start", nil, daemonHost()) + _, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, name) + c.Assert(err, checker.IsNil) + + err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{}) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNoContent) c.Assert(waitRun(name), check.IsNil) type b struct { - status int - body []byte - err error + stats types.ContainerStats + err error } bc := make(chan b, 1) go func() { - status, body, err := request.SockRequest("GET", "/containers/"+name+"/stats", nil, daemonHost()) - bc <- b{status, body, err} + stats, err := cli.ContainerStats(context.Background(), name, false) + bc <- b{stats, err} }() // allow some time to stream the stats from the container @@ -1537,26 +1654,15 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *check.C) { c.Fatal("stream was not closed after container was removed") case sr := <-bc: c.Assert(sr.err, checker.IsNil) - c.Assert(sr.status, checker.Equals, http.StatusOK) - - // decode only one object from the stream - var s *types.Stats - dec := json.NewDecoder(bytes.NewBuffer(sr.body)) - c.Assert(dec.Decode(&s), checker.IsNil) + sr.stats.Body.Close() } } func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) { - type m mounttypes.Mount - type hc struct{ Mounts []m } - type cfg struct { - Image string - HostConfig hc - } type testCase struct { - config cfg - status int - msg string + config containertypes.Config + hostConfig containertypes.HostConfig + msg string } prefix, slash := getPrefixAndSlashFromDaemonPlatform() @@ -1565,78 +1671,82 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) { cases := []testCase{ { - config: cfg{ + config: containertypes.Config{ Image: "busybox", - HostConfig: hc{ - Mounts: []m{{ - Type: "notreal", - Target: destPath}}}}, - status: http.StatusBadRequest, - msg: "mount type unknown", + }, + hostConfig: containertypes.HostConfig{ + Mounts: []mounttypes.Mount{{ + Type: "notreal", + Target: destPath, + }, + }, + }, + + msg: "mount type unknown", }, { - config: cfg{ + config: containertypes.Config{ Image: "busybox", - HostConfig: hc{ - Mounts: []m{{ - Type: "bind"}}}}, - status: http.StatusBadRequest, - msg: "Target must not be empty", + }, + hostConfig: containertypes.HostConfig{ + Mounts: []mounttypes.Mount{{ + Type: "bind"}}}, + msg: "Target must not be empty", }, { - config: cfg{ + config: containertypes.Config{ Image: "busybox", - HostConfig: hc{ - Mounts: []m{{ - Type: "bind", - Target: destPath}}}}, - status: http.StatusBadRequest, - msg: "Source must not be empty", + }, + hostConfig: containertypes.HostConfig{ + Mounts: []mounttypes.Mount{{ + Type: "bind", + Target: destPath}}}, + msg: "Source must not be empty", }, { - config: cfg{ + config: containertypes.Config{ Image: "busybox", - HostConfig: hc{ - Mounts: []m{{ - Type: "bind", - Source: notExistPath, - Target: destPath}}}}, - status: http.StatusBadRequest, - msg: "bind source path does not exist", + }, + hostConfig: containertypes.HostConfig{ + Mounts: []mounttypes.Mount{{ + Type: "bind", + Source: notExistPath, + Target: destPath}}}, + msg: "bind source path does not exist", }, { - config: cfg{ + config: containertypes.Config{ Image: "busybox", - HostConfig: hc{ - Mounts: []m{{ - Type: "volume"}}}}, - status: http.StatusBadRequest, - msg: "Target must not be empty", + }, + hostConfig: containertypes.HostConfig{ + Mounts: []mounttypes.Mount{{ + Type: "volume"}}}, + msg: "Target must not be empty", }, { - config: cfg{ + config: containertypes.Config{ Image: "busybox", - HostConfig: hc{ - Mounts: []m{{ - Type: "volume", - Source: "hello", - Target: destPath}}}}, - status: http.StatusCreated, - msg: "", + }, + hostConfig: containertypes.HostConfig{ + Mounts: []mounttypes.Mount{{ + Type: "volume", + Source: "hello", + Target: destPath}}}, + msg: "", }, { - config: cfg{ + config: containertypes.Config{ Image: "busybox", - HostConfig: hc{ - Mounts: []m{{ - Type: "volume", - Source: "hello2", - Target: destPath, - VolumeOptions: &mounttypes.VolumeOptions{ - DriverConfig: &mounttypes.Driver{ - Name: "local"}}}}}}, - status: http.StatusCreated, - msg: "", + }, + hostConfig: containertypes.HostConfig{ + Mounts: []mounttypes.Mount{{ + Type: "volume", + Source: "hello2", + Target: destPath, + VolumeOptions: &mounttypes.VolumeOptions{ + DriverConfig: &mounttypes.Driver{ + Name: "local"}}}}}, + msg: "", }, } @@ -1646,27 +1756,27 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) { defer os.RemoveAll(tmpDir) cases = append(cases, []testCase{ { - config: cfg{ + config: containertypes.Config{ Image: "busybox", - HostConfig: hc{ - Mounts: []m{{ - Type: "bind", - Source: tmpDir, - Target: destPath}}}}, - status: http.StatusCreated, - msg: "", + }, + hostConfig: containertypes.HostConfig{ + Mounts: []mounttypes.Mount{{ + Type: "bind", + Source: tmpDir, + Target: destPath}}}, + msg: "", }, { - config: cfg{ + config: containertypes.Config{ Image: "busybox", - HostConfig: hc{ - Mounts: []m{{ - Type: "bind", - Source: tmpDir, - Target: destPath, - VolumeOptions: &mounttypes.VolumeOptions{}}}}}, - status: http.StatusBadRequest, - msg: "VolumeOptions must not be specified", + }, + hostConfig: containertypes.HostConfig{ + Mounts: []mounttypes.Mount{{ + Type: "bind", + Source: tmpDir, + Target: destPath, + VolumeOptions: &mounttypes.VolumeOptions{}}}}, + msg: "VolumeOptions must not be specified", }, }...) } @@ -1674,67 +1784,70 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) { if DaemonIsLinux() { cases = append(cases, []testCase{ { - config: cfg{ + config: containertypes.Config{ Image: "busybox", - HostConfig: hc{ - Mounts: []m{{ - Type: "volume", - Source: "hello3", - Target: destPath, - VolumeOptions: &mounttypes.VolumeOptions{ - DriverConfig: &mounttypes.Driver{ - Name: "local", - Options: map[string]string{"o": "size=1"}}}}}}}, - status: http.StatusCreated, - msg: "", + }, + hostConfig: containertypes.HostConfig{ + Mounts: []mounttypes.Mount{{ + Type: "volume", + Source: "hello3", + Target: destPath, + VolumeOptions: &mounttypes.VolumeOptions{ + DriverConfig: &mounttypes.Driver{ + Name: "local", + Options: map[string]string{"o": "size=1"}}}}}}, + msg: "", }, { - config: cfg{ + config: containertypes.Config{ Image: "busybox", - HostConfig: hc{ - Mounts: []m{{ - Type: "tmpfs", - Target: destPath}}}}, - status: http.StatusCreated, - msg: "", + }, + hostConfig: containertypes.HostConfig{ + Mounts: []mounttypes.Mount{{ + Type: "tmpfs", + Target: destPath}}}, + msg: "", }, { - config: cfg{ + config: containertypes.Config{ Image: "busybox", - HostConfig: hc{ - Mounts: []m{{ - Type: "tmpfs", - Target: destPath, - TmpfsOptions: &mounttypes.TmpfsOptions{ - SizeBytes: 4096 * 1024, - Mode: 0700, - }}}}}, - status: http.StatusCreated, - msg: "", + }, + hostConfig: containertypes.HostConfig{ + Mounts: []mounttypes.Mount{{ + Type: "tmpfs", + Target: destPath, + TmpfsOptions: &mounttypes.TmpfsOptions{ + SizeBytes: 4096 * 1024, + Mode: 0700, + }}}}, + msg: "", }, { - config: cfg{ + config: containertypes.Config{ Image: "busybox", - HostConfig: hc{ - Mounts: []m{{ - Type: "tmpfs", - Source: "/shouldnotbespecified", - Target: destPath}}}}, - status: http.StatusBadRequest, - msg: "Source must not be specified", + }, + hostConfig: containertypes.HostConfig{ + Mounts: []mounttypes.Mount{{ + Type: "tmpfs", + Source: "/shouldnotbespecified", + Target: destPath}}}, + msg: "Source must not be specified", }, }...) } + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() for i, x := range cases { c.Logf("case %d", i) - status, b, err := request.SockRequest("POST", "/containers/create", x.config, daemonHost()) - c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, x.status, check.Commentf("%s\n%v", string(b), cases[i].config)) + _, err = cli.ContainerCreate(context.Background(), &x.config, &x.hostConfig, &networktypes.NetworkingConfig{}, "") if len(x.msg) > 0 { - c.Assert(string(b), checker.Contains, x.msg, check.Commentf("%v", cases[i].config)) + c.Assert(err.Error(), checker.Contains, x.msg, check.Commentf("%v", cases[i].config)) + } else { + c.Assert(err, checker.IsNil) } } } @@ -1749,15 +1862,21 @@ func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *check.C) { defer os.RemoveAll(tmpDir) err = ioutil.WriteFile(filepath.Join(tmpDir, "bar"), []byte("hello"), 666) c.Assert(err, checker.IsNil) - - data := map[string]interface{}{ - "Image": "busybox", - "Cmd": []string{"/bin/sh", "-c", "cat /foo/bar"}, - "HostConfig": map[string]interface{}{"Mounts": []map[string]interface{}{{"Type": "bind", "Source": tmpDir, "Target": destPath}}}, + config := containertypes.Config{ + Image: "busybox", + Cmd: []string{"/bin/sh", "-c", "cat /foo/bar"}, } - status, resp, err := request.SockRequest("POST", "/containers/create?name=test", data, daemonHost()) - c.Assert(err, checker.IsNil, check.Commentf(string(resp))) - c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(resp))) + hostConfig := containertypes.HostConfig{ + Mounts: []mounttypes.Mount{ + {Type: "bind", Source: tmpDir, Target: destPath}, + }, + } + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, "test") + c.Assert(err, checker.IsNil) out, _ := dockerCmd(c, "start", "-a", "test") c.Assert(out, checker.Equals, "hello") @@ -1783,18 +1902,38 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) { } type testCase struct { - cfg mounttypes.Mount + spec mounttypes.Mount expected types.MountPoint } + var selinuxSharedLabel string + if runtime.GOOS == "linux" { + selinuxSharedLabel = "z" + } + cases := []testCase{ // use literal strings here for `Type` instead of the defined constants in the volume package to keep this honest // Validation of the actual `Mount` struct is done in another test is not needed here - {mounttypes.Mount{Type: "volume", Target: destPath}, types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath}}, - {mounttypes.Mount{Type: "volume", Target: destPath + slash}, types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath}}, - {mounttypes.Mount{Type: "volume", Target: destPath, Source: "test1"}, types.MountPoint{Type: "volume", Name: "test1", RW: true, Destination: destPath}}, - {mounttypes.Mount{Type: "volume", Target: destPath, ReadOnly: true, Source: "test2"}, types.MountPoint{Type: "volume", Name: "test2", RW: false, Destination: destPath}}, - {mounttypes.Mount{Type: "volume", Target: destPath, Source: "test3", VolumeOptions: &mounttypes.VolumeOptions{DriverConfig: &mounttypes.Driver{Name: volume.DefaultDriverName}}}, types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", Name: "test3", RW: true, Destination: destPath}}, + { + spec: mounttypes.Mount{Type: "volume", Target: destPath}, + expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, + }, + { + spec: mounttypes.Mount{Type: "volume", Target: destPath + slash}, + expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, + }, + { + spec: mounttypes.Mount{Type: "volume", Target: destPath, Source: "test1"}, + expected: types.MountPoint{Type: "volume", Name: "test1", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, + }, + { + spec: mounttypes.Mount{Type: "volume", Target: destPath, ReadOnly: true, Source: "test2"}, + expected: types.MountPoint{Type: "volume", Name: "test2", RW: false, Destination: destPath, Mode: selinuxSharedLabel}, + }, + { + spec: mounttypes.Mount{Type: "volume", Target: destPath, Source: "test3", VolumeOptions: &mounttypes.VolumeOptions{DriverConfig: &mounttypes.Driver{Name: volume.DefaultDriverName}}}, + expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", Name: "test3", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, + }, } if SameHostDaemon() { @@ -1803,8 +1942,23 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) { c.Assert(err, checker.IsNil) defer os.RemoveAll(tmpDir1) cases = append(cases, []testCase{ - {mounttypes.Mount{Type: "bind", Source: tmpDir1, Target: destPath}, types.MountPoint{Type: "bind", RW: true, Destination: destPath, Source: tmpDir1}}, - {mounttypes.Mount{Type: "bind", Source: tmpDir1, Target: destPath, ReadOnly: true}, types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir1}}, + { + spec: mounttypes.Mount{ + Type: "bind", + Source: tmpDir1, + Target: destPath, + }, + expected: types.MountPoint{ + Type: "bind", + RW: true, + Destination: destPath, + Source: tmpDir1, + }, + }, + { + spec: mounttypes.Mount{Type: "bind", Source: tmpDir1, Target: destPath, ReadOnly: true}, + expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir1}, + }, }...) // for modes only supported on Linux @@ -1817,19 +1971,40 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) { c.Assert(mount.ForceMount("", tmpDir3, "none", "shared"), checker.IsNil) cases = append(cases, []testCase{ - {mounttypes.Mount{Type: "bind", Source: tmpDir3, Target: destPath}, types.MountPoint{Type: "bind", RW: true, Destination: destPath, Source: tmpDir3}}, - {mounttypes.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true}, types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3}}, - {mounttypes.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true, BindOptions: &mounttypes.BindOptions{Propagation: "shared"}}, types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3, Propagation: "shared"}}, + { + spec: mounttypes.Mount{Type: "bind", Source: tmpDir3, Target: destPath}, + expected: types.MountPoint{Type: "bind", RW: true, Destination: destPath, Source: tmpDir3}, + }, + { + spec: mounttypes.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true}, + expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3}, + }, + { + spec: mounttypes.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true, BindOptions: &mounttypes.BindOptions{Propagation: "shared"}}, + expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3, Propagation: "shared"}, + }, }...) } } if testEnv.DaemonPlatform() != "windows" { // Windows does not support volume populate cases = append(cases, []testCase{ - {mounttypes.Mount{Type: "volume", Target: destPath, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath}}, - {mounttypes.Mount{Type: "volume", Target: destPath + slash, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath}}, - {mounttypes.Mount{Type: "volume", Target: destPath, Source: "test4", VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, types.MountPoint{Type: "volume", Name: "test4", RW: true, Destination: destPath}}, - {mounttypes.Mount{Type: "volume", Target: destPath, Source: "test5", ReadOnly: true, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, types.MountPoint{Type: "volume", Name: "test5", RW: false, Destination: destPath}}, + { + spec: mounttypes.Mount{Type: "volume", Target: destPath, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, + expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, + }, + { + spec: mounttypes.Mount{Type: "volume", Target: destPath + slash, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, + expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, + }, + { + spec: mounttypes.Mount{Type: "volume", Target: destPath, Source: "test4", VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, + expected: types.MountPoint{Type: "volume", Name: "test4", RW: true, Destination: destPath, Mode: selinuxSharedLabel}, + }, + { + spec: mounttypes.Mount{Type: "volume", Target: destPath, Source: "test5", ReadOnly: true, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}}, + expected: types.MountPoint{Type: "volume", Name: "test5", RW: false, Destination: destPath, Mode: selinuxSharedLabel}, + }, }...) } @@ -1840,93 +2015,124 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) { type createResp struct { ID string `json:"Id"` } - for i, x := range cases { - c.Logf("case %d - config: %v", i, x.cfg) - status, data, err := request.SockRequest("POST", "/containers/create", wrapper{containertypes.Config{Image: testImg}, containertypes.HostConfig{Mounts: []mounttypes.Mount{x.cfg}}}, daemonHost()) - c.Assert(err, checker.IsNil, check.Commentf(string(data))) - c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(data))) - - var resp createResp - err = json.Unmarshal(data, &resp) - c.Assert(err, checker.IsNil, check.Commentf(string(data))) - id := resp.ID - - var mps []types.MountPoint - err = json.NewDecoder(strings.NewReader(inspectFieldJSON(c, id, "Mounts"))).Decode(&mps) - c.Assert(err, checker.IsNil) - c.Assert(mps, checker.HasLen, 1) - c.Assert(mps[0].Destination, checker.Equals, x.expected.Destination) - if len(x.expected.Source) > 0 { - c.Assert(mps[0].Source, checker.Equals, x.expected.Source) + ctx := context.Background() + apiclient := testEnv.APIClient() + for i, x := range cases { + c.Logf("case %d - config: %v", i, x.spec) + container, err := apiclient.ContainerCreate( + ctx, + &containertypes.Config{Image: testImg}, + &containertypes.HostConfig{Mounts: []mounttypes.Mount{x.spec}}, + &networktypes.NetworkingConfig{}, + "") + require.NoError(c, err) + + containerInspect, err := apiclient.ContainerInspect(ctx, container.ID) + require.NoError(c, err) + mps := containerInspect.Mounts + require.Len(c, mps, 1) + mountPoint := mps[0] + + if x.expected.Source != "" { + assert.Equal(c, x.expected.Source, mountPoint.Source) } - if len(x.expected.Name) > 0 { - c.Assert(mps[0].Name, checker.Equals, x.expected.Name) + if x.expected.Name != "" { + assert.Equal(c, x.expected.Name, mountPoint.Name) } - if len(x.expected.Driver) > 0 { - c.Assert(mps[0].Driver, checker.Equals, x.expected.Driver) + if x.expected.Driver != "" { + assert.Equal(c, x.expected.Driver, mountPoint.Driver) } - c.Assert(mps[0].RW, checker.Equals, x.expected.RW) - c.Assert(mps[0].Type, checker.Equals, x.expected.Type) - c.Assert(mps[0].Mode, checker.Equals, x.expected.Mode) - if len(x.expected.Propagation) > 0 { - c.Assert(mps[0].Propagation, checker.Equals, x.expected.Propagation) + if x.expected.Propagation != "" { + assert.Equal(c, x.expected.Propagation, mountPoint.Propagation) } - - out, _, err := dockerCmdWithError("start", "-a", id) - if (x.cfg.Type != "volume" || (x.cfg.VolumeOptions != nil && x.cfg.VolumeOptions.NoCopy)) && testEnv.DaemonPlatform() != "windows" { - c.Assert(err, checker.NotNil, check.Commentf("%s\n%v", out, mps[0])) - } else { - c.Assert(err, checker.IsNil, check.Commentf("%s\n%v", out, mps[0])) + assert.Equal(c, x.expected.RW, mountPoint.RW) + assert.Equal(c, x.expected.Type, mountPoint.Type) + assert.Equal(c, x.expected.Mode, mountPoint.Mode) + assert.Equal(c, x.expected.Destination, mountPoint.Destination) + + err = apiclient.ContainerStart(ctx, container.ID, types.ContainerStartOptions{}) + require.NoError(c, err) + poll.WaitOn(c, containerExit(apiclient, container.ID), poll.WithDelay(time.Second)) + + err = apiclient.ContainerRemove(ctx, container.ID, types.ContainerRemoveOptions{ + RemoveVolumes: true, + Force: true, + }) + require.NoError(c, err) + + switch { + + // Named volumes still exist after the container is removed + case x.spec.Type == "volume" && len(x.spec.Source) > 0: + _, err := apiclient.VolumeInspect(ctx, mountPoint.Name) + require.NoError(c, err) + + // Bind mounts are never removed with the container + case x.spec.Type == "bind": + + // anonymous volumes are removed + default: + _, err := apiclient.VolumeInspect(ctx, mountPoint.Name) + assert.True(c, client.IsErrNotFound(err)) } + } +} - dockerCmd(c, "rm", "-fv", id) - if x.cfg.Type == "volume" && len(x.cfg.Source) > 0 { - // This should still exist even though we removed the container - dockerCmd(c, "volume", "inspect", mps[0].Name) - } else { - // This should be removed automatically when we removed the container - out, _, err := dockerCmdWithError("volume", "inspect", mps[0].Name) - c.Assert(err, checker.NotNil, check.Commentf(out)) +func containerExit(apiclient client.APIClient, name string) func(poll.LogT) poll.Result { + return func(logT poll.LogT) poll.Result { + container, err := apiclient.ContainerInspect(context.Background(), name) + if err != nil { + return poll.Error(err) + } + switch container.State.Status { + case "created", "running": + return poll.Continue("container %s is %s, waiting for exit", name, container.State.Status) } + return poll.Success() } } func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *check.C) { testRequires(c, DaemonIsLinux) type testCase struct { - cfg map[string]interface{} + cfg mounttypes.Mount expectedOptions []string } target := "/foo" cases := []testCase{ { - cfg: map[string]interface{}{ - "Type": "tmpfs", - "Target": target}, + cfg: mounttypes.Mount{ + Type: "tmpfs", + Target: target}, expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime"}, }, { - cfg: map[string]interface{}{ - "Type": "tmpfs", - "Target": target, - "TmpfsOptions": map[string]interface{}{ - "SizeBytes": 4096 * 1024, "Mode": 0700}}, + cfg: mounttypes.Mount{ + Type: "tmpfs", + Target: target, + TmpfsOptions: &mounttypes.TmpfsOptions{ + SizeBytes: 4096 * 1024, Mode: 0700}}, expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime", "size=4096k", "mode=700"}, }, } + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + config := containertypes.Config{ + Image: "busybox", + Cmd: []string{"/bin/sh", "-c", fmt.Sprintf("mount | grep 'tmpfs on %s'", target)}, + } for i, x := range cases { cName := fmt.Sprintf("test-tmpfs-%d", i) - data := map[string]interface{}{ - "Image": "busybox", - "Cmd": []string{"/bin/sh", "-c", - fmt.Sprintf("mount | grep 'tmpfs on %s'", target)}, - "HostConfig": map[string]interface{}{"Mounts": []map[string]interface{}{x.cfg}}, + hostConfig := containertypes.HostConfig{ + Mounts: []mounttypes.Mount{x.cfg}, } - status, resp, err := request.SockRequest("POST", "/containers/create?name="+cName, data, daemonHost()) - c.Assert(err, checker.IsNil, check.Commentf(string(resp))) - c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(resp))) + + _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, cName) + c.Assert(err, checker.IsNil) out, _ := dockerCmd(c, "start", "-a", cName) for _, option := range x.expectedOptions { c.Assert(out, checker.Contains, option) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_containers_windows_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_containers_windows_test.go new file mode 100644 index 000000000..4cbe067cd --- /dev/null +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_containers_windows_test.go @@ -0,0 +1,71 @@ +// +build windows + +package main + +import ( + "fmt" + "io/ioutil" + "math/rand" + "net/http" + "strings" + + winio "github.com/Microsoft/go-winio" + "github.com/docker/docker/integration-cli/checker" + "github.com/docker/docker/integration-cli/request" + "github.com/go-check/check" +) + +func (s *DockerSuite) TestContainersAPICreateMountsBindNamedPipe(c *check.C) { + testRequires(c, SameHostDaemon, DaemonIsWindowsAtLeastBuild(16210)) // Named pipe support was added in RS3 + + // Create a host pipe to map into the container + hostPipeName := fmt.Sprintf(`\\.\pipe\docker-cli-test-pipe-%x`, rand.Uint64()) + pc := &winio.PipeConfig{ + SecurityDescriptor: "D:P(A;;GA;;;AU)", // Allow all users access to the pipe + } + l, err := winio.ListenPipe(hostPipeName, pc) + if err != nil { + c.Fatal(err) + } + defer l.Close() + + // Asynchronously read data that the container writes to the mapped pipe. + var b []byte + ch := make(chan error) + go func() { + conn, err := l.Accept() + if err == nil { + b, err = ioutil.ReadAll(conn) + conn.Close() + } + ch <- err + }() + + containerPipeName := `\\.\pipe\docker-cli-test-pipe` + text := "hello from a pipe" + cmd := fmt.Sprintf("echo %s > %s", text, containerPipeName) + + name := "test-bind-npipe" + data := map[string]interface{}{ + "Image": testEnv.MinimalBaseImage(), + "Cmd": []string{"cmd", "/c", cmd}, + "HostConfig": map[string]interface{}{"Mounts": []map[string]interface{}{{"Type": "npipe", "Source": hostPipeName, "Target": containerPipeName}}}, + } + + status, resp, err := request.SockRequest("POST", "/containers/create?name="+name, data, daemonHost()) + c.Assert(err, checker.IsNil, check.Commentf(string(resp))) + c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(resp))) + + status, _, err = request.SockRequest("POST", "/containers/"+name+"/start", nil, daemonHost()) + c.Assert(err, checker.IsNil) + c.Assert(status, checker.Equals, http.StatusNoContent) + + err = <-ch + if err != nil { + c.Fatal(err) + } + result := strings.TrimSpace(string(b)) + if result != text { + c.Errorf("expected pipe to contain %s, got %s", text, result) + } +} diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_create_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_create_test.go index e404b6cf5..760e715b1 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_create_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_create_test.go @@ -11,82 +11,6 @@ import ( "github.com/go-check/check" ) -func (s *DockerSuite) TestAPICreateWithNotExistImage(c *check.C) { - name := "test" - config := map[string]interface{}{ - "Image": "test456:v1", - "Volumes": map[string]struct{}{"/tmp": {}}, - } - - status, body, err := request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusNotFound) - expected := "No such image: test456:v1" - c.Assert(getErrorMessage(c, body), checker.Contains, expected) - - config2 := map[string]interface{}{ - "Image": "test456", - "Volumes": map[string]struct{}{"/tmp": {}}, - } - - status, body, err = request.SockRequest("POST", "/containers/create?name="+name, config2, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusNotFound) - expected = "No such image: test456:latest" - c.Assert(getErrorMessage(c, body), checker.Equals, expected) - - config3 := map[string]interface{}{ - "Image": "sha256:0cb40641836c461bc97c793971d84d758371ed682042457523e4ae701efeaaaa", - } - - status, body, err = request.SockRequest("POST", "/containers/create?name="+name, config3, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusNotFound) - expected = "No such image: sha256:0cb40641836c461bc97c793971d84d758371ed682042457523e4ae701efeaaaa" - c.Assert(getErrorMessage(c, body), checker.Equals, expected) - -} - -// Test for #25099 -func (s *DockerSuite) TestAPICreateEmptyEnv(c *check.C) { - name := "test1" - config := map[string]interface{}{ - "Image": "busybox", - "Env": []string{"", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}, - "Cmd": []string{"true"}, - } - - status, body, err := request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusInternalServerError) - expected := "invalid environment variable:" - c.Assert(getErrorMessage(c, body), checker.Contains, expected) - - name = "test2" - config = map[string]interface{}{ - "Image": "busybox", - "Env": []string{"=", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}, - "Cmd": []string{"true"}, - } - status, body, err = request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusInternalServerError) - expected = "invalid environment variable: =" - c.Assert(getErrorMessage(c, body), checker.Contains, expected) - - name = "test3" - config = map[string]interface{}{ - "Image": "busybox", - "Env": []string{"=foo", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}, - "Cmd": []string{"true"}, - } - status, body, err = request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusInternalServerError) - expected = "invalid environment variable: =foo" - c.Assert(getErrorMessage(c, body), checker.Contains, expected) -} - func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) { // test invalid Interval in Healthcheck: less than 0s name := "test1" @@ -99,11 +23,15 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) { }, } - status, body, err := request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost()) + res, body, err := request.Post("/containers/create?name="+name, request.JSONBody(config)) c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + + buf, err := request.ReadBody(body) + c.Assert(err, checker.IsNil) + expected := fmt.Sprintf("Interval in Healthcheck cannot be less than %s", container.MinimumDuration) - c.Assert(getErrorMessage(c, body), checker.Contains, expected) + c.Assert(getErrorMessage(c, buf), checker.Contains, expected) // test invalid Interval in Healthcheck: larger than 0s but less than 1ms name = "test2" @@ -115,10 +43,14 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) { "Retries": int(1000), }, } - status, body, err = request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost()) + res, body, err = request.Post("/containers/create?name="+name, request.JSONBody(config)) c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusInternalServerError) - c.Assert(getErrorMessage(c, body), checker.Contains, expected) + + buf, err = request.ReadBody(body) + c.Assert(err, checker.IsNil) + + c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + c.Assert(getErrorMessage(c, buf), checker.Contains, expected) // test invalid Timeout in Healthcheck: less than 1ms name = "test3" @@ -130,11 +62,15 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) { "Retries": int(1000), }, } - status, body, err = request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost()) + res, body, err = request.Post("/containers/create?name="+name, request.JSONBody(config)) c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + + buf, err = request.ReadBody(body) + c.Assert(err, checker.IsNil) + expected = fmt.Sprintf("Timeout in Healthcheck cannot be less than %s", container.MinimumDuration) - c.Assert(getErrorMessage(c, body), checker.Contains, expected) + c.Assert(getErrorMessage(c, buf), checker.Contains, expected) // test invalid Retries in Healthcheck: less than 0 name = "test4" @@ -146,11 +82,15 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) { "Retries": int(-10), }, } - status, body, err = request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost()) + res, body, err = request.Post("/containers/create?name="+name, request.JSONBody(config)) c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + + buf, err = request.ReadBody(body) + c.Assert(err, checker.IsNil) + expected = "Retries in Healthcheck cannot be negative" - c.Assert(getErrorMessage(c, body), checker.Contains, expected) + c.Assert(getErrorMessage(c, buf), checker.Contains, expected) // test invalid StartPeriod in Healthcheck: not 0 and less than 1ms name = "test3" @@ -163,9 +103,13 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) { "StartPeriod": 100 * time.Microsecond, }, } - status, body, err = request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost()) + res, body, err = request.Post("/containers/create?name="+name, request.JSONBody(config)) c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + + buf, err = request.ReadBody(body) + c.Assert(err, checker.IsNil) + expected = fmt.Sprintf("StartPeriod in Healthcheck cannot be less than %s", container.MinimumDuration) - c.Assert(getErrorMessage(c, body), checker.Contains, expected) + c.Assert(getErrorMessage(c, buf), checker.Contains, expected) } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_exec_resize_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_exec_resize_test.go index f43bc2de0..961d911cb 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_exec_resize_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_exec_resize_test.go @@ -20,9 +20,9 @@ func (s *DockerSuite) TestExecResizeAPIHeightWidthNoInt(c *check.C) { cleanedContainerID := strings.TrimSpace(out) endpoint := "/exec/" + cleanedContainerID + "/resize?h=foo&w=bar" - status, _, err := request.SockRequest("POST", endpoint, nil, daemonHost()) + res, _, err := request.Post(endpoint) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) } // Part of #14845 @@ -36,16 +36,19 @@ func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *check.C) { "Cmd": []string{"/bin/sh"}, } uri := fmt.Sprintf("/containers/%s/exec", name) - status, body, err := request.SockRequest("POST", uri, data, daemonHost()) + res, body, err := request.Post(uri, request.JSONBody(data)) if err != nil { return err } - if status != http.StatusCreated { - return fmt.Errorf("POST %s is expected to return %d, got %d", uri, http.StatusCreated, status) + if res.StatusCode != http.StatusCreated { + return fmt.Errorf("POST %s is expected to return %d, got %d", uri, http.StatusCreated, res.StatusCode) } + buf, err := request.ReadBody(body) + c.Assert(err, checker.IsNil) + out := map[string]string{} - err = json.Unmarshal(body, &out) + err = json.Unmarshal(buf, &out) if err != nil { return fmt.Errorf("ExecCreate returned invalid json. Error: %q", err.Error()) } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_exec_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_exec_test.go index 25399343a..6e18df8fe 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_exec_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_exec_test.go @@ -10,10 +10,12 @@ import ( "net/http" "time" + "github.com/docker/docker/api/types" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/request" - "github.com/docker/docker/pkg/testutil" "github.com/go-check/check" + "golang.org/x/net/context" ) // Regression test for #9414 @@ -21,12 +23,15 @@ func (s *DockerSuite) TestExecAPICreateNoCmd(c *check.C) { name := "exec_test" dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") - status, body, err := request.SockRequest("POST", fmt.Sprintf("/containers/%s/exec", name), map[string]interface{}{"Cmd": nil}, daemonHost()) + res, body, err := request.Post(fmt.Sprintf("/containers/%s/exec", name), request.JSONBody(map[string]interface{}{"Cmd": nil})) + c.Assert(err, checker.IsNil) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusInternalServerError) comment := check.Commentf("Expected message when creating exec command with no Cmd specified") - c.Assert(getErrorMessage(c, body), checker.Contains, "No exec command specified", comment) + c.Assert(getErrorMessage(c, b), checker.Contains, "No exec command specified", comment) } func (s *DockerSuite) TestExecAPICreateNoValidContentType(c *check.C) { @@ -40,9 +45,9 @@ func (s *DockerSuite) TestExecAPICreateNoValidContentType(c *check.C) { res, body, err := request.Post(fmt.Sprintf("/containers/%s/exec", name), request.RawContent(ioutil.NopCloser(jsonData)), request.ContentType("test/plain")) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) comment := check.Commentf("Expected message when creating exec command with invalid Content-Type specified") @@ -56,12 +61,18 @@ func (s *DockerSuite) TestExecAPICreateContainerPaused(c *check.C) { dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") dockerCmd(c, "pause", name) - status, body, err := request.SockRequest("POST", fmt.Sprintf("/containers/%s/exec", name), map[string]interface{}{"Cmd": []string{"true"}}, daemonHost()) + + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusConflict) + defer cli.Close() + + config := types.ExecConfig{ + Cmd: []string{"true"}, + } + _, err = cli.ContainerExecCreate(context.Background(), name, config) comment := check.Commentf("Expected message when creating exec command with Container %s is paused", name) - c.Assert(getErrorMessage(c, body), checker.Contains, "Container "+name+" is paused, unpause the container before exec", comment) + c.Assert(err.Error(), checker.Contains, "Container "+name+" is paused, unpause the container before exec", comment) } func (s *DockerSuite) TestExecAPIStart(c *check.C) { @@ -109,7 +120,7 @@ func (s *DockerSuite) TestExecAPIStartBackwardsCompatible(c *check.C) { resp, body, err := request.Post(fmt.Sprintf("/v1.20/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.ContentType("text/plain")) c.Assert(err, checker.IsNil) - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) comment := check.Commentf("response body: %s", b) c.Assert(err, checker.IsNil, comment) c.Assert(resp.StatusCode, checker.Equals, http.StatusOK, comment) @@ -129,22 +140,23 @@ func (s *DockerSuite) TestExecAPIStartMultipleTimesError(c *check.C) { func (s *DockerSuite) TestExecAPIStartWithDetach(c *check.C) { name := "foo" runSleepingContainer(c, "-d", "-t", "--name", name) - data := map[string]interface{}{ - "cmd": []string{"true"}, - "AttachStdin": true, + + config := types.ExecConfig{ + Cmd: []string{"true"}, + AttachStderr: true, } - _, b, err := request.SockRequest("POST", fmt.Sprintf("/containers/%s/exec", name), data, daemonHost()) - c.Assert(err, checker.IsNil, check.Commentf(string(b))) - createResp := struct { - ID string `json:"Id"` - }{} - c.Assert(json.Unmarshal(b, &createResp), checker.IsNil, check.Commentf(string(b))) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + createResp, err := cli.ContainerExecCreate(context.Background(), name, config) + c.Assert(err, checker.IsNil) _, body, err := request.Post(fmt.Sprintf("/exec/%s/start", createResp.ID), request.RawString(`{"Detach": true}`), request.JSON) c.Assert(err, checker.IsNil) - b, err = testutil.ReadBody(body) + b, err := request.ReadBody(body) comment := check.Commentf("response body: %s", b) c.Assert(err, checker.IsNil, comment) @@ -177,7 +189,7 @@ func (s *DockerSuite) TestExecAPIStartInvalidCommand(c *check.C) { dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") id := createExecCmd(c, name, "invalid") - startExec(c, id, http.StatusNotFound) + startExec(c, id, http.StatusBadRequest) waitForExec(c, id) var inspectJSON struct{ ExecIDs []string } @@ -207,7 +219,7 @@ func startExec(c *check.C, id string, code int) { resp, body, err := request.Post(fmt.Sprintf("/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.JSON) c.Assert(err, checker.IsNil) - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) comment := check.Commentf("response body: %s", b) c.Assert(err, checker.IsNil, comment) c.Assert(resp.StatusCode, checker.Equals, code, comment) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_images_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_images_test.go index 0cdd50685..fba69dc68 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_images_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_images_test.go @@ -1,38 +1,40 @@ package main import ( - "encoding/json" "net/http" "net/http/httptest" - "net/url" "strings" "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/image" + "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" "github.com/docker/docker/integration-cli/request" "github.com/go-check/check" + "golang.org/x/net/context" ) func (s *DockerSuite) TestAPIImagesFilter(c *check.C) { + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + name := "utest:tag1" name2 := "utest/docker:tag2" name3 := "utest:5000/docker:tag3" for _, n := range []string{name, name2, name3} { dockerCmd(c, "tag", "busybox", n) } - type image types.ImageSummary - getImages := func(filter string) []image { - v := url.Values{} - v.Set("filter", filter) - status, b, err := request.SockRequest("GET", "/images/json?"+v.Encode(), nil, daemonHost()) - c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) - - var images []image - err = json.Unmarshal(b, &images) + getImages := func(filter string) []types.ImageSummary { + filters := filters.NewArgs() + filters.Add("reference", filter) + options := types.ImageListOptions{ + All: false, + Filters: filters, + } + images, err := cli.ImageList(context.Background(), options) c.Assert(err, checker.IsNil) return images @@ -74,6 +76,10 @@ func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *check.C) { } func (s *DockerSuite) TestAPIImagesDelete(c *check.C) { + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + if testEnv.DaemonPlatform() != "windows" { testRequires(c, Network) } @@ -83,20 +89,21 @@ func (s *DockerSuite) TestAPIImagesDelete(c *check.C) { dockerCmd(c, "tag", name, "test:tag1") - status, _, err := request.SockRequest("DELETE", "/images/"+id, nil, daemonHost()) - c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusConflict) + _, err = cli.ImageRemove(context.Background(), id, types.ImageRemoveOptions{}) + c.Assert(err.Error(), checker.Contains, "unable to delete") - status, _, err = request.SockRequest("DELETE", "/images/test:noexist", nil, daemonHost()) - c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNotFound) //Status Codes:404 – no such image + _, err = cli.ImageRemove(context.Background(), "test:noexist", types.ImageRemoveOptions{}) + c.Assert(err.Error(), checker.Contains, "No such image") - status, _, err = request.SockRequest("DELETE", "/images/test:tag1", nil, daemonHost()) + _, err = cli.ImageRemove(context.Background(), "test:tag1", types.ImageRemoveOptions{}) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) } func (s *DockerSuite) TestAPIImagesHistory(c *check.C) { + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + if testEnv.DaemonPlatform() != "windows" { testRequires(c, Network) } @@ -104,20 +111,15 @@ func (s *DockerSuite) TestAPIImagesHistory(c *check.C) { buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nENV FOO bar")) id := getIDByName(c, name) - status, body, err := request.SockRequest("GET", "/images/"+id+"/history", nil, daemonHost()) + historydata, err := cli.ImageHistory(context.Background(), id) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) - - var historydata []image.HistoryResponseItem - err = json.Unmarshal(body, &historydata) - c.Assert(err, checker.IsNil, check.Commentf("Error on unmarshal")) c.Assert(historydata, checker.Not(checker.HasLen), 0) c.Assert(historydata[0].Tags[0], checker.Equals, "test-api-images-history:latest") } func (s *DockerSuite) TestAPIImagesImportBadSrc(c *check.C) { - testRequires(c, Network) + testRequires(c, Network, SameHostDaemon) server := httptest.NewServer(http.NewServeMux()) defer server.Close() @@ -133,9 +135,8 @@ func (s *DockerSuite) TestAPIImagesImportBadSrc(c *check.C) { } for _, te := range tt { - res, b, err := request.SockRequestRaw("POST", strings.Join([]string{"/images/create?fromSrc=", te.fromSrc}, ""), nil, "application/json", daemonHost()) + res, _, err := request.Post(strings.Join([]string{"/images/create?fromSrc=", te.fromSrc}, ""), request.JSON) c.Assert(err, check.IsNil) - b.Close() c.Assert(res.StatusCode, checker.Equals, te.statusExp) c.Assert(res.Header.Get("Content-Type"), checker.Equals, "application/json") } @@ -156,11 +157,11 @@ func (s *DockerSuite) TestAPIImagesSearchJSONContentType(c *check.C) { // Test case for 30027: image size reported as -1 in v1.12 client against v1.13 daemon. // This test checks to make sure both v1.12 and v1.13 client against v1.13 daemon get correct `Size` after the fix. func (s *DockerSuite) TestAPIImagesSizeCompatibility(c *check.C) { - status, b, err := request.SockRequest("GET", "/images/json", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) - var images []types.ImageSummary - err = json.Unmarshal(b, &images) + defer cli.Close() + + images, err := cli.ImageList(context.Background(), types.ImageListOptions{}) c.Assert(err, checker.IsNil) c.Assert(len(images), checker.Not(checker.Equals), 0) for _, image := range images { @@ -177,11 +178,12 @@ func (s *DockerSuite) TestAPIImagesSizeCompatibility(c *check.C) { VirtualSize int64 Labels map[string]string } - status, b, err = request.SockRequest("GET", "/v1.24/images/json", nil, daemonHost()) + + cli, err = request.NewEnvClientWithVersion("v1.24") c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) - var v124Images []v124Image - err = json.Unmarshal(b, &v124Images) + defer cli.Close() + + v124Images, err := cli.ImageList(context.Background(), types.ImageListOptions{}) c.Assert(err, checker.IsNil) c.Assert(len(v124Images), checker.Not(checker.Equals), 0) for _, image := range v124Images { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_info_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_info_test.go index 9cb873d60..60ca4b928 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_info_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_info_test.go @@ -1,21 +1,26 @@ package main import ( + "encoding/json" "net/http" - "encoding/json" + "fmt" + "github.com/docker/docker/api/types" + + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/request" - "github.com/docker/docker/pkg/testutil" "github.com/go-check/check" + "golang.org/x/net/context" ) func (s *DockerSuite) TestInfoAPI(c *check.C) { - endpoint := "/info" + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - status, body, err := request.SockRequest("GET", endpoint, nil, daemonHost()) - c.Assert(status, checker.Equals, http.StatusOK) + info, err := cli.Info(context.Background()) c.Assert(err, checker.IsNil) // always shown fields @@ -37,7 +42,7 @@ func (s *DockerSuite) TestInfoAPI(c *check.C) { "ServerVersion", "SecurityOptions"} - out := string(body) + out := fmt.Sprintf("%+v", info) for _, linePrefix := range stringsToCheck { c.Assert(out, checker.Contains, linePrefix) } @@ -52,7 +57,7 @@ func (s *DockerSuite) TestInfoAPIRuncCommit(c *check.C) { c.Assert(res.StatusCode, checker.Equals, http.StatusOK) c.Assert(err, checker.IsNil) - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) var i types.Info @@ -64,13 +69,15 @@ func (s *DockerSuite) TestInfoAPIRuncCommit(c *check.C) { func (s *DockerSuite) TestInfoAPIVersioned(c *check.C) { testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later - endpoint := "/v1.20/info" - status, body, err := request.SockRequest("GET", endpoint, nil, daemonHost()) - c.Assert(status, checker.Equals, http.StatusOK) + res, body, err := request.Get("/v1.20/info") + c.Assert(res.StatusCode, checker.Equals, http.StatusOK) + c.Assert(err, checker.IsNil) + + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) - out := string(body) + out := string(b) c.Assert(out, checker.Contains, "ExecutionDriver") c.Assert(out, checker.Contains, "not supported") } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_inspect_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_inspect_test.go index f2aa883fa..638635494 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_inspect_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_inspect_test.go @@ -2,13 +2,14 @@ package main import ( "encoding/json" - "net/http" "strings" + "golang.org/x/net/context" + "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/versions/v1p20" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/integration-cli/request" "github.com/docker/docker/pkg/stringutils" "github.com/go-check/check" ) @@ -106,18 +107,14 @@ func (s *DockerSuite) TestInspectAPIContainerVolumeDriver(c *check.C) { func (s *DockerSuite) TestInspectAPIImageResponse(c *check.C) { dockerCmd(c, "tag", "busybox:latest", "busybox:mytag") + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - endpoint := "/images/busybox/json" - status, body, err := request.SockRequest("GET", endpoint, nil, daemonHost()) - + imageJSON, _, err := cli.ImageInspectWithRaw(context.Background(), "busybox") c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) - var imageJSON types.ImageInspect - err = json.Unmarshal(body, &imageJSON) - c.Assert(err, checker.IsNil, check.Commentf("Unable to unmarshal body for latest version")) c.Assert(imageJSON.RepoTags, checker.HasLen, 2) - c.Assert(stringutils.InSlice(imageJSON.RepoTags, "busybox:latest"), checker.Equals, true) c.Assert(stringutils.InSlice(imageJSON.RepoTags, "busybox:mytag"), checker.Equals, true) } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_inspect_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_inspect_unix_test.go index f7731f3d9..dae64be2a 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_inspect_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_inspect_unix_test.go @@ -4,12 +4,11 @@ package main import ( "encoding/json" - "fmt" - "net/http" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/request" "github.com/go-check/check" + "golang.org/x/net/context" ) // #16665 @@ -19,9 +18,10 @@ func (s *DockerSuite) TestInspectAPICpusetInConfigPre120(c *check.C) { name := "cpusetinconfig-pre120" dockerCmd(c, "run", "--name", name, "--cpuset-cpus", "0", "busybox", "true") - - status, body, err := request.SockRequest("GET", fmt.Sprintf("/v1.19/containers/%s/json", name), nil, daemonHost()) - c.Assert(status, check.Equals, http.StatusOK) + cli, err := request.NewEnvClientWithVersion("v1.19") + c.Assert(err, checker.IsNil) + defer cli.Close() + _, body, err := cli.ContainerInspectWithRaw(context.Background(), name, false) c.Assert(err, check.IsNil) var inspectJSON map[string]interface{} diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_ipcmode_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_ipcmode_test.go new file mode 100644 index 000000000..07fbbca7c --- /dev/null +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_ipcmode_test.go @@ -0,0 +1,222 @@ +// build +linux +package main + +import ( + "bufio" + "fmt" + "io/ioutil" + "os" + "strings" + + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/integration-cli/checker" + "github.com/docker/docker/integration-cli/cli" + "github.com/docker/docker/integration-cli/request" + "github.com/go-check/check" + "golang.org/x/net/context" +) + +/* testIpcCheckDevExists checks whether a given mount (identified by its + * major:minor pair from /proc/self/mountinfo) exists on the host system. + * + * The format of /proc/self/mountinfo is like: + * + * 29 23 0:24 / /dev/shm rw,nosuid,nodev shared:4 - tmpfs tmpfs rw + * ^^^^\ + * - this is the minor:major we look for + */ +func testIpcCheckDevExists(mm string) (bool, error) { + f, err := os.Open("/proc/self/mountinfo") + if err != nil { + return false, err + } + defer f.Close() + + s := bufio.NewScanner(f) + for s.Scan() { + fields := strings.Fields(s.Text()) + if len(fields) < 7 { + continue + } + if fields[2] == mm { + return true, nil + } + } + + if err := s.Err(); err != nil { + return false, err + } + + return false, nil +} + +// testIpcNonePrivateShareable is a helper function to test "none", +// "private" and "shareable" modes. +func testIpcNonePrivateShareable(c *check.C, mode string, mustBeMounted bool, mustBeShared bool) { + cfg := container.Config{ + Image: "busybox", + Cmd: []string{"top"}, + } + hostCfg := container.HostConfig{ + IpcMode: container.IpcMode(mode), + } + ctx := context.Background() + + client, err := request.NewClient() + c.Assert(err, checker.IsNil) + + resp, err := client.ContainerCreate(ctx, &cfg, &hostCfg, nil, "") + c.Assert(err, checker.IsNil) + c.Assert(len(resp.Warnings), checker.Equals, 0) + + err = client.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}) + c.Assert(err, checker.IsNil) + + // get major:minor pair for /dev/shm from container's /proc/self/mountinfo + cmd := "awk '($5 == \"/dev/shm\") {printf $3}' /proc/self/mountinfo" + mm := cli.DockerCmd(c, "exec", "-i", resp.ID, "sh", "-c", cmd).Combined() + if !mustBeMounted { + c.Assert(mm, checker.Equals, "") + // no more checks to perform + return + } + c.Assert(mm, checker.Matches, "^[0-9]+:[0-9]+$") + + shared, err := testIpcCheckDevExists(mm) + c.Assert(err, checker.IsNil) + c.Logf("[testIpcPrivateShareable] ipcmode: %v, ipcdev: %v, shared: %v, mustBeShared: %v\n", mode, mm, shared, mustBeShared) + c.Assert(shared, checker.Equals, mustBeShared) +} + +/* TestAPIIpcModeNone checks the container "none" IPC mode + * (--ipc none) works as expected. It makes sure there is no + * /dev/shm mount inside the container. + */ +func (s *DockerSuite) TestAPIIpcModeNone(c *check.C) { + testRequires(c, DaemonIsLinux) + testIpcNonePrivateShareable(c, "none", false, false) +} + +/* TestAPIIpcModePrivate checks the container private IPC mode + * (--ipc private) works as expected. It gets the minor:major pair + * of /dev/shm mount from the container, and makes sure there is no + * such pair on the host. + */ +func (s *DockerSuite) TestAPIIpcModePrivate(c *check.C) { + testRequires(c, DaemonIsLinux, SameHostDaemon) + testIpcNonePrivateShareable(c, "private", true, false) +} + +/* TestAPIIpcModeShareable checks the container shareable IPC mode + * (--ipc shareable) works as expected. It gets the minor:major pair + * of /dev/shm mount from the container, and makes sure such pair + * also exists on the host. + */ +func (s *DockerSuite) TestAPIIpcModeShareable(c *check.C) { + testRequires(c, DaemonIsLinux, SameHostDaemon) + testIpcNonePrivateShareable(c, "shareable", true, true) +} + +// testIpcContainer is a helper function to test --ipc container:NNN mode in various scenarios +func testIpcContainer(s *DockerSuite, c *check.C, donorMode string, mustWork bool) { + cfg := container.Config{ + Image: "busybox", + Cmd: []string{"top"}, + } + hostCfg := container.HostConfig{ + IpcMode: container.IpcMode(donorMode), + } + ctx := context.Background() + + client, err := request.NewClient() + c.Assert(err, checker.IsNil) + + // create and start the "donor" container + resp, err := client.ContainerCreate(ctx, &cfg, &hostCfg, nil, "") + c.Assert(err, checker.IsNil) + c.Assert(len(resp.Warnings), checker.Equals, 0) + name1 := resp.ID + + err = client.ContainerStart(ctx, name1, types.ContainerStartOptions{}) + c.Assert(err, checker.IsNil) + + // create and start the second container + hostCfg.IpcMode = container.IpcMode("container:" + name1) + resp, err = client.ContainerCreate(ctx, &cfg, &hostCfg, nil, "") + c.Assert(err, checker.IsNil) + c.Assert(len(resp.Warnings), checker.Equals, 0) + name2 := resp.ID + + err = client.ContainerStart(ctx, name2, types.ContainerStartOptions{}) + if !mustWork { + // start should fail with a specific error + c.Assert(err, checker.NotNil) + c.Assert(fmt.Sprintf("%v", err), checker.Contains, "non-shareable IPC") + // no more checks to perform here + return + } + + // start should succeed + c.Assert(err, checker.IsNil) + + // check that IPC is shared + // 1. create a file in the first container + cli.DockerCmd(c, "exec", name1, "sh", "-c", "printf covfefe > /dev/shm/bar") + // 2. check it's the same file in the second one + out := cli.DockerCmd(c, "exec", "-i", name2, "cat", "/dev/shm/bar").Combined() + c.Assert(out, checker.Matches, "^covfefe$") +} + +/* TestAPIIpcModeShareableAndContainer checks that a container created with + * --ipc container:ID can use IPC of another shareable container. + */ +func (s *DockerSuite) TestAPIIpcModeShareableAndContainer(c *check.C) { + testRequires(c, DaemonIsLinux) + testIpcContainer(s, c, "shareable", true) +} + +/* TestAPIIpcModePrivateAndContainer checks that a container created with + * --ipc container:ID can NOT use IPC of another private container. + */ +func (s *DockerSuite) TestAPIIpcModePrivateAndContainer(c *check.C) { + testRequires(c, DaemonIsLinux) + testIpcContainer(s, c, "private", false) +} + +/* TestAPIIpcModeHost checks that a container created with --ipc host + * can use IPC of the host system. + */ +func (s *DockerSuite) TestAPIIpcModeHost(c *check.C) { + testRequires(c, DaemonIsLinux, SameHostDaemon, NotUserNamespace) + + cfg := container.Config{ + Image: "busybox", + Cmd: []string{"top"}, + } + hostCfg := container.HostConfig{ + IpcMode: container.IpcMode("host"), + } + ctx := context.Background() + + client, err := request.NewClient() + c.Assert(err, checker.IsNil) + + resp, err := client.ContainerCreate(ctx, &cfg, &hostCfg, nil, "") + c.Assert(err, checker.IsNil) + c.Assert(len(resp.Warnings), checker.Equals, 0) + name := resp.ID + + err = client.ContainerStart(ctx, name, types.ContainerStartOptions{}) + c.Assert(err, checker.IsNil) + + // check that IPC is shared + // 1. create a file inside container + cli.DockerCmd(c, "exec", name, "sh", "-c", "printf covfefe > /dev/shm/."+name) + // 2. check it's the same on the host + bytes, err := ioutil.ReadFile("/dev/shm/." + name) + c.Assert(err, checker.IsNil) + c.Assert(string(bytes), checker.Matches, "^covfefe$") + // 3. clean up + cli.DockerCmd(c, "exec", name, "rm", "-f", "/dev/shm/."+name) +} diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_logs_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_logs_test.go index 5e953b79d..1f2a30a92 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_logs_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_logs_test.go @@ -7,9 +7,12 @@ import ( "strings" "time" + "github.com/docker/docker/api/types" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/request" "github.com/go-check/check" + "golang.org/x/net/context" ) func (s *DockerSuite) TestLogsAPIWithStdout(c *check.C) { @@ -51,13 +54,13 @@ func (s *DockerSuite) TestLogsAPIWithStdout(c *check.C) { func (s *DockerSuite) TestLogsAPINoStdoutNorStderr(c *check.C) { name := "logs_test" dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") - - status, body, err := request.SockRequest("GET", fmt.Sprintf("/containers/%s/logs", name), nil, daemonHost()) - c.Assert(status, checker.Equals, http.StatusBadRequest) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) + defer cli.Close() + _, err = cli.ContainerLogs(context.Background(), name, types.ContainerLogsOptions{}) expected := "Bad parameters: you must choose at least one stream" - c.Assert(getErrorMessage(c, body), checker.Contains, expected) + c.Assert(err.Error(), checker.Contains, expected) } // Regression test for #12704 diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_network_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_network_test.go index 129ec7ea6..a49fbae3d 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_network_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_network_test.go @@ -76,7 +76,7 @@ func (s *DockerSuite) TestAPINetworkFilter(c *check.C) { c.Assert(nr.Name, checker.Equals, "bridge") } -func (s *DockerSuite) TestAPINetworkInspect(c *check.C) { +func (s *DockerSuite) TestAPINetworkInspectBridge(c *check.C) { testRequires(c, DaemonIsLinux) // Inspect default bridge network nr := getNetworkResource(c, "bridge") @@ -94,13 +94,15 @@ func (s *DockerSuite) TestAPINetworkInspect(c *check.C) { c.Assert(nr.Internal, checker.Equals, false) c.Assert(nr.EnableIPv6, checker.Equals, false) c.Assert(nr.IPAM.Driver, checker.Equals, "default") - c.Assert(len(nr.Containers), checker.Equals, 1) c.Assert(nr.Containers[containerID], checker.NotNil) ip, _, err := net.ParseCIDR(nr.Containers[containerID].IPv4Address) c.Assert(err, checker.IsNil) c.Assert(ip.String(), checker.Equals, containerIP) +} +func (s *DockerSuite) TestAPINetworkInspectUserDefinedNetwork(c *check.C) { + testRequires(c, DaemonIsLinux) // IPAM configuration inspect ipam := &network.IPAM{ Driver: "default", @@ -117,7 +119,7 @@ func (s *DockerSuite) TestAPINetworkInspect(c *check.C) { id0 := createNetwork(c, config, true) c.Assert(isNetworkAvailable(c, "br0"), checker.Equals, true) - nr = getNetworkResource(c, id0) + nr := getNetworkResource(c, id0) c.Assert(len(nr.IPAM.Config), checker.Equals, 1) c.Assert(nr.IPAM.Config[0].Subnet, checker.Equals, "172.28.0.0/16") c.Assert(nr.IPAM.Config[0].IPRange, checker.Equals, "172.28.5.0/24") @@ -291,9 +293,16 @@ func getNetworkIDByName(c *check.C, name string) string { nJSON := []types.NetworkResource{} err = json.NewDecoder(body).Decode(&nJSON) c.Assert(err, checker.IsNil) - c.Assert(len(nJSON), checker.Equals, 1) + var res string + for _, n := range nJSON { + // Find exact match + if n.Name == name { + res = n.ID + } + } + c.Assert(res, checker.Not(checker.Equals), "") - return nJSON[0].ID + return res } func getNetworkResource(c *check.C, id string) *types.NetworkResource { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_resize_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_resize_test.go index 4a07fc737..8ecf540a7 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_resize_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_resize_test.go @@ -1,9 +1,12 @@ package main import ( + "context" "net/http" "strings" + "github.com/docker/docker/api/types" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/request" "github.com/go-check/check" @@ -12,10 +15,15 @@ import ( func (s *DockerSuite) TestResizeAPIResponse(c *check.C) { out := runSleepingContainer(c, "-d") cleanedContainerID := strings.TrimSpace(out) - - endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40" - status, _, err := request.SockRequest("POST", endpoint, nil, daemonHost()) - c.Assert(status, check.Equals, http.StatusOK) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + options := types.ResizeOptions{ + Height: 40, + Width: 40, + } + err = cli.ContainerResize(context.Background(), cleanedContainerID, options) c.Assert(err, check.IsNil) } @@ -24,8 +32,8 @@ func (s *DockerSuite) TestResizeAPIHeightWidthNoInt(c *check.C) { cleanedContainerID := strings.TrimSpace(out) endpoint := "/containers/" + cleanedContainerID + "/resize?h=foo&w=bar" - status, _, err := request.SockRequest("POST", endpoint, nil, daemonHost()) - c.Assert(status, check.Equals, http.StatusInternalServerError) + res, _, err := request.Post(endpoint) + c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) c.Assert(err, check.IsNil) } @@ -36,10 +44,15 @@ func (s *DockerSuite) TestResizeAPIResponseWhenContainerNotStarted(c *check.C) { // make sure the exited container is not running dockerCmd(c, "wait", cleanedContainerID) - endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40" - status, body, err := request.SockRequest("POST", endpoint, nil, daemonHost()) - c.Assert(status, check.Equals, http.StatusInternalServerError) - c.Assert(err, check.IsNil) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + options := types.ResizeOptions{ + Height: 40, + Width: 40, + } - c.Assert(getErrorMessage(c, body), checker.Contains, "is not running", check.Commentf("resize should fail with message 'Container is not running'")) + err = cli.ContainerResize(context.Background(), cleanedContainerID, options) + c.Assert(err.Error(), checker.Contains, "is not running") } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_session_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_session_test.go index e1ad880ea..f1c44892d 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_session_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_session_test.go @@ -5,7 +5,6 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/request" - "github.com/docker/docker/pkg/testutil" "github.com/go-check/check" ) @@ -29,7 +28,7 @@ func (s *DockerSuite) TestSessionCreateWithBadUpgrade(c *check.C) { res, body, err := request.Post("/session") c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) - buf, err := testutil.ReadBody(body) + buf, err := request.ReadBody(body) c.Assert(err, checker.IsNil) out := string(buf) @@ -41,7 +40,7 @@ func (s *DockerSuite) TestSessionCreateWithBadUpgrade(c *check.C) { }) c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) - buf, err = testutil.ReadBody(body) + buf, err = request.ReadBody(body) c.Assert(err, checker.IsNil) out = string(buf) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_stats_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_stats_test.go index f1cb5bb4a..2e8515a3f 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_stats_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_stats_test.go @@ -13,9 +13,11 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/versions" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/request" "github.com/go-check/check" + "golang.org/x/net/context" ) var expectedNetworkInterfaceStats = strings.Split("rx_bytes rx_dropped rx_errors rx_packets tx_bytes tx_dropped tx_errors tx_packets", " ") @@ -260,14 +262,16 @@ func jsonBlobHasGTE121NetworkStats(blob map[string]interface{}) bool { func (s *DockerSuite) TestAPIStatsContainerNotFound(c *check.C) { testRequires(c, DaemonIsLinux) - - status, _, err := request.SockRequest("GET", "/containers/nonexistent/stats", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNotFound) + defer cli.Close() - status, _, err = request.SockRequest("GET", "/containers/nonexistent/stats?stream=0", nil, daemonHost()) - c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNotFound) + expected := "No such container: nonexistent" + + _, err = cli.ContainerStats(context.Background(), "nonexistent", true) + c.Assert(err.Error(), checker.Contains, expected) + _, err = cli.ContainerStats(context.Background(), "nonexistent", false) + c.Assert(err.Error(), checker.Contains, expected) } func (s *DockerSuite) TestAPIStatsNoStreamConnectedContainers(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_config_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_config_test.go index fab65ccbd..c01d80ff7 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_config_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_config_test.go @@ -3,12 +3,10 @@ package main import ( - "fmt" - "net/http" - "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/integration-cli/checker" "github.com/go-check/check" + "golang.org/x/net/context" ) func (s *DockerSwarmSuite) TestAPISwarmConfigsEmptyList(c *check.C) { @@ -52,9 +50,13 @@ func (s *DockerSwarmSuite) TestAPISwarmConfigsDelete(c *check.C) { c.Assert(config.ID, checker.Equals, id, check.Commentf("config: %v", config)) d.DeleteConfig(c, config.ID) - status, out, err := d.SockRequest("GET", "/configs/"+id, nil) + + cli, err := d.NewClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNotFound, check.Commentf("config delete: %s", string(out))) + defer cli.Close() + + _, _, err = cli.ConfigInspectWithRaw(context.Background(), id) + c.Assert(err.Error(), checker.Contains, "No such config") } func (s *DockerSwarmSuite) TestAPISwarmConfigsUpdate(c *check.C) { @@ -110,9 +112,12 @@ func (s *DockerSwarmSuite) TestAPISwarmConfigsUpdate(c *check.C) { config = d.GetConfig(c, id) config.Spec.Data = []byte("TESTINGDATA2") - url := fmt.Sprintf("/configs/%s/update?version=%d", config.ID, config.Version.Index) - status, out, err := d.SockRequest("POST", url, config.Spec) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + expected := "only updates to Labels are allowed" - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusBadRequest, check.Commentf("output: %q", string(out))) + err = cli.ConfigUpdate(context.Background(), config.ID, config.Version, config.Spec) + c.Assert(err.Error(), checker.Contains, expected) } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_secret_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_secret_test.go index cb82af8e2..c30e2237d 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_secret_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_secret_test.go @@ -3,12 +3,12 @@ package main import ( - "fmt" "net/http" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/integration-cli/checker" "github.com/go-check/check" + "golang.org/x/net/context" ) func (s *DockerSwarmSuite) TestAPISwarmSecretsEmptyList(c *check.C) { @@ -59,16 +59,17 @@ func (s *DockerSwarmSuite) TestAPISwarmSecretsDelete(c *check.C) { c.Assert(secret.ID, checker.Equals, id, check.Commentf("secret: %v", secret)) d.DeleteSecret(c, secret.ID) - status, out, err := d.SockRequest("GET", "/secrets/"+id, nil) - c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNotFound, check.Commentf("secret delete: %s", string(out))) - // delete non-existing secret, daemon should return a status code of 404 - id = "non-existing" - status, out, err = d.SockRequest("DELETE", "/secrets/"+id, nil) + cli, err := d.NewClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNotFound, check.Commentf("secret delete: %s", string(out))) + defer cli.Close() + + _, _, err = cli.SecretInspectWithRaw(context.Background(), id) + c.Assert(err.Error(), checker.Contains, "No such secret") + id = "non-existing" + err = cli.SecretRemove(context.Background(), id) + c.Assert(err.Error(), checker.Contains, "No such secret: non-existing") } func (s *DockerSwarmSuite) TestAPISwarmSecretsUpdate(c *check.C) { @@ -124,9 +125,12 @@ func (s *DockerSwarmSuite) TestAPISwarmSecretsUpdate(c *check.C) { secret = d.GetSecret(c, id) secret.Spec.Data = []byte("TESTINGDATA2") - url := fmt.Sprintf("/secrets/%s/update?version=%d", secret.ID, secret.Version.Index) - status, out, err := d.SockRequest("POST", url, secret.Spec) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + expected := "only updates to Labels are allowed" - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusBadRequest, check.Commentf("output: %q", string(out))) + err = cli.SecretUpdate(context.Background(), secret.ID, secret.Version, secret.Spec) + c.Assert(err.Error(), checker.Contains, expected) } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_service_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_service_test.go index 2ec56ccd8..a9563f2de 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_service_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_service_test.go @@ -9,6 +9,7 @@ import ( "strings" "time" + "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm/runtime" "github.com/docker/docker/integration-cli/checker" @@ -64,14 +65,22 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesCreate(c *check.C) { id := d.CreateService(c, simpleTestService, setInstances(instances)) waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, instances) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + options := types.ServiceInspectOptions{InsertDefaults: true} + // insertDefaults inserts UpdateConfig when service is fetched by ID - _, out, err := d.SockRequest("GET", "/services/"+id+"?insertDefaults=true", nil) - c.Assert(err, checker.IsNil, check.Commentf("%s", out)) - c.Assert(string(out), checker.Contains, "UpdateConfig") + resp, _, err := cli.ServiceInspectWithRaw(context.Background(), id, options) + out := fmt.Sprintf("%+v", resp) + c.Assert(err, checker.IsNil) + c.Assert(out, checker.Contains, "UpdateConfig") // insertDefaults inserts UpdateConfig when service is fetched by ID - _, out, err = d.SockRequest("GET", "/services/top?insertDefaults=true", nil) - c.Assert(err, checker.IsNil, check.Commentf("%s", out)) + resp, _, err = cli.ServiceInspectWithRaw(context.Background(), "top", options) + out = fmt.Sprintf("%+v", resp) + c.Assert(err, checker.IsNil) c.Assert(string(out), checker.Contains, "UpdateConfig") service := d.GetService(c, id) @@ -195,7 +204,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateStartFirst(c *check.C) { // service image at start image1 := "busybox:latest" // target image in update - image2 := "testhealth" + image2 := "testhealth:latest" // service started from this image won't pass health check _, _, err := d.BuildImageWithOut(image2, @@ -603,7 +612,8 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesStateReporting(c *check.C) { // Test plugins deployed via swarm services func (s *DockerSwarmSuite) TestAPISwarmServicesPlugin(c *check.C) { - testRequires(c, DaemonIsLinux, IsAmd64) + testRequires(c, ExperimentalDaemon, DaemonIsLinux, IsAmd64) + reg := setupRegistry(c, false, "", "") defer reg.Close() diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_test.go index 9d24757b4..8f8b8eb13 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_swarm_test.go @@ -23,8 +23,10 @@ import ( "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/daemon" + "github.com/docker/docker/integration-cli/request" "github.com/docker/swarmkit/ca" "github.com/go-check/check" + "golang.org/x/net/context" ) var defaultReconciliationTimeout = 30 * time.Second @@ -228,17 +230,20 @@ func (s *DockerSwarmSuite) TestAPISwarmPromoteDemote(c *check.C) { node := d1.GetNode(c, d1.NodeID) node.Spec.Role = swarm.NodeRoleWorker url := fmt.Sprintf("/nodes/%s/update?version=%d", node.ID, node.Version.Index) - status, out, err := d1.SockRequest("POST", url, node.Spec) + res, body, err := request.DoOnHost(d1.Sock(), url, request.Method("POST"), request.JSONBody(node.Spec)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusBadRequest, check.Commentf("output: %q", string(out))) + b, err := request.ReadBody(body) + c.Assert(err, checker.IsNil) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest, check.Commentf("output: %q", string(b))) + // The warning specific to demoting the last manager is best-effort and // won't appear until the Role field of the demoted manager has been // updated. // Yes, I know this looks silly, but checker.Matches is broken, since // it anchors the regexp contrary to the documentation, and this makes // it impossible to match something that includes a line break. - if !strings.Contains(string(out), "last manager of the swarm") { - c.Assert(string(out), checker.Contains, "this would result in a loss of quorum") + if !strings.Contains(string(b), "last manager of the swarm") { + c.Assert(string(b), checker.Contains, "this would result in a loss of quorum") } info, err = d1.SwarmInfo() c.Assert(err, checker.IsNil) @@ -362,9 +367,11 @@ func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *check.C) { var service swarm.Service simpleTestService(&service) service.Spec.Name = "top2" - status, out, err := d1.SockRequest("POST", "/services/create", service.Spec) + cli, err := d1.NewClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusInternalServerError, check.Commentf("deadline exceeded", string(out))) + defer cli.Close() + _, err = cli.ServiceCreate(context.Background(), service.Spec, types.ServiceCreateOptions{}) + c.Assert(err.Error(), checker.Contains, "deadline exceeded") d2.Start(c) @@ -505,17 +512,17 @@ func (s *DockerSwarmSuite) TestAPISwarmInvalidAddress(c *check.C) { req := swarm.InitRequest{ ListenAddr: "", } - status, _, err := d.SockRequest("POST", "/swarm/init", req) + res, _, err := request.DoOnHost(d.Sock(), "/swarm/init", request.Method("POST"), request.JSONBody(req)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusBadRequest) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) req2 := swarm.JoinRequest{ ListenAddr: "0.0.0.0:2377", RemoteAddrs: []string{""}, } - status, _, err = d.SockRequest("POST", "/swarm/join", req2) + res, _, err = request.DoOnHost(d.Sock(), "/swarm/join", request.Method("POST"), request.JSONBody(req2)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusBadRequest) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) } func (s *DockerSwarmSuite) TestAPISwarmForceNewCluster(c *check.C) { @@ -836,10 +843,11 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateWithName(c *check.C) { instances = 5 setInstances(instances)(service) - url := fmt.Sprintf("/services/%s/update?version=%d", service.Spec.Name, service.Version.Index) - status, out, err := d.SockRequest("POST", url, service.Spec) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + _, err = cli.ServiceUpdate(context.Background(), service.Spec.Name, service.Version, service.Spec, types.ServiceUpdateOptions{}) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, instances) } @@ -867,51 +875,31 @@ func (s *DockerSwarmSuite) TestAPISwarmErrorHandling(c *check.C) { // This test makes sure the fixes correctly output scopes instead. func (s *DockerSwarmSuite) TestAPIDuplicateNetworks(c *check.C) { d := s.AddDaemon(c, true, true) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() name := "foo" - networkCreateRequest := types.NetworkCreateRequest{ - Name: name, - NetworkCreate: types.NetworkCreate{ - CheckDuplicate: false, - }, + networkCreate := types.NetworkCreate{ + CheckDuplicate: false, } - var n1 types.NetworkCreateResponse - networkCreateRequest.NetworkCreate.Driver = "bridge" + networkCreate.Driver = "bridge" - status, out, err := d.SockRequest("POST", "/networks/create", networkCreateRequest) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(out))) - - c.Assert(json.Unmarshal(out, &n1), checker.IsNil) - - var n2 types.NetworkCreateResponse - networkCreateRequest.NetworkCreate.Driver = "overlay" - - status, out, err = d.SockRequest("POST", "/networks/create", networkCreateRequest) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(out))) - - c.Assert(json.Unmarshal(out, &n2), checker.IsNil) + n1, err := cli.NetworkCreate(context.Background(), name, networkCreate) + c.Assert(err, checker.IsNil) - var r1 types.NetworkResource + networkCreate.Driver = "overlay" - status, out, err = d.SockRequest("GET", "/networks/"+n1.ID, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf(string(out))) - - c.Assert(json.Unmarshal(out, &r1), checker.IsNil) + n2, err := cli.NetworkCreate(context.Background(), name, networkCreate) + c.Assert(err, checker.IsNil) + r1, err := cli.NetworkInspect(context.Background(), n1.ID, types.NetworkInspectOptions{}) + c.Assert(err, checker.IsNil) c.Assert(r1.Scope, checker.Equals, "local") - var r2 types.NetworkResource - - status, out, err = d.SockRequest("GET", "/networks/"+n2.ID, nil) - c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf(string(out))) - - c.Assert(json.Unmarshal(out, &r2), checker.IsNil) - + r2, err := cli.NetworkInspect(context.Background(), n2.ID, types.NetworkInspectOptions{}) + c.Assert(err, checker.IsNil) c.Assert(r2.Scope, checker.Equals, "swarm") } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_test.go index 1af77ea51..af189b9d0 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_test.go @@ -4,17 +4,13 @@ import ( "fmt" "io/ioutil" "net/http" - "net/http/httptest" "runtime" "strconv" "strings" "github.com/docker/docker/api" "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/request" - "github.com/docker/docker/pkg/testutil" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" ) @@ -60,29 +56,12 @@ func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *check.C) { c.Assert(strings.TrimSpace(string(content)), checker.Contains, expected) } -func (s *DockerSuite) TestAPIDockerAPIVersion(c *check.C) { - var svrVersion string - - server := httptest.NewServer(http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("API-Version", api.DefaultVersion) - url := r.URL.Path - svrVersion = url - })) - defer server.Close() - - // Test using the env var first - result := cli.Docker(cli.Args("-H="+server.URL[7:], "version"), cli.WithEnvironmentVariables(appendBaseEnv(false, "DOCKER_API_VERSION=xxx")...)) - c.Assert(result, icmd.Matches, icmd.Expected{Out: "API version: xxx", ExitCode: 1}) - c.Assert(svrVersion, check.Equals, "/vxxx/version", check.Commentf("%s", result.Compare(icmd.Success))) -} - func (s *DockerSuite) TestAPIErrorJSON(c *check.C) { httpResp, body, err := request.Post("/containers/create", request.JSONBody(struct{}{})) c.Assert(err, checker.IsNil) - c.Assert(httpResp.StatusCode, checker.Equals, http.StatusInternalServerError) + c.Assert(httpResp.StatusCode, checker.Equals, http.StatusBadRequest) c.Assert(httpResp.Header.Get("Content-Type"), checker.Equals, "application/json") - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) c.Assert(getErrorMessage(c, b), checker.Equals, "Config cannot be empty in order to create a container") } @@ -93,9 +72,9 @@ func (s *DockerSuite) TestAPIErrorPlainText(c *check.C) { testRequires(c, DaemonIsLinux) httpResp, body, err := request.Post("/v1.23/containers/create", request.JSONBody(struct{}{})) c.Assert(err, checker.IsNil) - c.Assert(httpResp.StatusCode, checker.Equals, http.StatusInternalServerError) + c.Assert(httpResp.StatusCode, checker.Equals, http.StatusBadRequest) c.Assert(httpResp.Header.Get("Content-Type"), checker.Contains, "text/plain") - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) c.Assert(strings.TrimSpace(string(b)), checker.Equals, "Config cannot be empty in order to create a container") } @@ -106,7 +85,7 @@ func (s *DockerSuite) TestAPIErrorNotFoundJSON(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(httpResp.StatusCode, checker.Equals, http.StatusNotFound) c.Assert(httpResp.Header.Get("Content-Type"), checker.Equals, "application/json") - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) c.Assert(getErrorMessage(c, b), checker.Equals, "page not found") } @@ -116,7 +95,7 @@ func (s *DockerSuite) TestAPIErrorNotFoundPlainText(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(httpResp.StatusCode, checker.Equals, http.StatusNotFound) c.Assert(httpResp.Header.Get("Content-Type"), checker.Contains, "text/plain") - b, err := testutil.ReadBody(body) + b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) c.Assert(strings.TrimSpace(string(b)), checker.Equals, "page not found") } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_update_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_update_unix_test.go index 1af6ed1e7..e2e1b092b 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_update_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_update_unix_test.go @@ -5,9 +5,11 @@ package main import ( "strings" + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/integration-cli/request" "github.com/go-check/check" + "golang.org/x/net/context" ) func (s *DockerSuite) TestAPIUpdateContainer(c *check.C) { @@ -16,12 +18,19 @@ func (s *DockerSuite) TestAPIUpdateContainer(c *check.C) { testRequires(c, swapMemorySupport) name := "apiUpdateContainer" - hostConfig := map[string]interface{}{ - "Memory": 314572800, - "MemorySwap": 524288000, + updateConfig := container.UpdateConfig{ + Resources: container.Resources{ + Memory: 314572800, + MemorySwap: 524288000, + }, } dockerCmd(c, "run", "-d", "--name", name, "-m", "200M", "busybox", "top") - _, _, err := request.SockRequest("POST", "/containers/"+name+"/update", hostConfig, daemonHost()) + cli, err := client.NewEnvClient() + c.Assert(err, check.IsNil) + defer cli.Close() + + _, err = cli.ContainerUpdate(context.Background(), name, updateConfig) + c.Assert(err, check.IsNil) c.Assert(inspectField(c, name, "HostConfig.Memory"), checker.Equals, "314572800") diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_version_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_version_test.go deleted file mode 100644 index 5f919deb7..000000000 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_version_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package main - -import ( - "encoding/json" - "net/http" - - "github.com/docker/docker/api/types" - "github.com/docker/docker/dockerversion" - "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/integration-cli/request" - "github.com/go-check/check" -) - -func (s *DockerSuite) TestGetVersion(c *check.C) { - status, body, err := request.SockRequest("GET", "/version", nil, daemonHost()) - c.Assert(status, checker.Equals, http.StatusOK) - c.Assert(err, checker.IsNil) - - var v types.Version - - c.Assert(json.Unmarshal(body, &v), checker.IsNil) - - c.Assert(v.Version, checker.Equals, dockerversion.Version, check.Commentf("Version mismatch")) -} diff --git a/vendor/github.com/docker/docker/integration-cli/docker_api_volumes_test.go b/vendor/github.com/docker/docker/integration-cli/docker_api_volumes_test.go index f354856d3..65a965209 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_api_volumes_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_api_volumes_test.go @@ -1,96 +1,96 @@ package main import ( - "encoding/json" "fmt" - "net/http" "path/filepath" "strings" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/filters" volumetypes "github.com/docker/docker/api/types/volume" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/integration-cli/request" "github.com/go-check/check" + "golang.org/x/net/context" ) func (s *DockerSuite) TestVolumesAPIList(c *check.C) { prefix, _ := getPrefixAndSlashFromDaemonPlatform() - dockerCmd(c, "run", "-v", prefix+"/foo", "busybox") + cid, _ := dockerCmd(c, "run", "-d", "-v", prefix+"/foo", "busybox") - status, b, err := request.SockRequest("GET", "/volumes", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) + defer cli.Close() - var volumes volumetypes.VolumesListOKBody - c.Assert(json.Unmarshal(b, &volumes), checker.IsNil) + container, err := cli.ContainerInspect(context.Background(), strings.TrimSpace(cid)) + c.Assert(err, checker.IsNil) + vname := container.Mounts[0].Name + + volumes, err := cli.VolumeList(context.Background(), filters.Args{}) + c.Assert(err, checker.IsNil) - c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes)) + found := false + for _, vol := range volumes.Volumes { + if vol.Name == vname { + found = true + break + } + } + c.Assert(found, checker.Equals, true) } func (s *DockerSuite) TestVolumesAPICreate(c *check.C) { config := volumetypes.VolumesCreateBody{ Name: "test", } - status, b, err := request.SockRequest("POST", "/volumes/create", config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusCreated, check.Commentf(string(b))) - var vol types.Volume - err = json.Unmarshal(b, &vol) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) + defer cli.Close() + + vol, err := cli.VolumeCreate(context.Background(), config) + c.Assert(err, check.IsNil) c.Assert(filepath.Base(filepath.Dir(vol.Mountpoint)), checker.Equals, config.Name) } func (s *DockerSuite) TestVolumesAPIRemove(c *check.C) { prefix, _ := getPrefixAndSlashFromDaemonPlatform() - dockerCmd(c, "run", "-v", prefix+"/foo", "--name=test", "busybox") + cid, _ := dockerCmd(c, "run", "-d", "-v", prefix+"/foo", "--name=test", "busybox") - status, b, err := request.SockRequest("GET", "/volumes", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK) + defer cli.Close() - var volumes volumetypes.VolumesListOKBody - c.Assert(json.Unmarshal(b, &volumes), checker.IsNil) - c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes)) - - v := volumes.Volumes[0] - status, _, err = request.SockRequest("DELETE", "/volumes/"+v.Name, nil, daemonHost()) + container, err := cli.ContainerInspect(context.Background(), strings.TrimSpace(cid)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusConflict, check.Commentf("Should not be able to remove a volume that is in use")) + vname := container.Mounts[0].Name + + err = cli.VolumeRemove(context.Background(), vname, false) + c.Assert(err.Error(), checker.Contains, "volume is in use") dockerCmd(c, "rm", "-f", "test") - status, data, err := request.SockRequest("DELETE", "/volumes/"+v.Name, nil, daemonHost()) + err = cli.VolumeRemove(context.Background(), vname, false) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNoContent, check.Commentf(string(data))) - } func (s *DockerSuite) TestVolumesAPIInspect(c *check.C) { config := volumetypes.VolumesCreateBody{ Name: "test", } + // sampling current time minus a minute so to now have false positive in case of delays now := time.Now().Truncate(time.Minute) - status, b, err := request.SockRequest("POST", "/volumes/create", config, daemonHost()) - c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusCreated, check.Commentf(string(b))) - status, b, err = request.SockRequest("GET", "/volumes", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf(string(b))) + defer cli.Close() - var volumes volumetypes.VolumesListOKBody - c.Assert(json.Unmarshal(b, &volumes), checker.IsNil) - c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes)) + _, err = cli.VolumeCreate(context.Background(), config) + c.Assert(err, check.IsNil) - var vol types.Volume - status, b, err = request.SockRequest("GET", "/volumes/"+config.Name, nil, daemonHost()) + vol, err := cli.VolumeInspect(context.Background(), config.Name) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf(string(b))) - c.Assert(json.Unmarshal(b, &vol), checker.IsNil) c.Assert(vol.Name, checker.Equals, config.Name) // comparing CreatedAt field time for the new volume to now. Removing a minute from both to avoid false positive diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_attach_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_attach_test.go index ff319c0d8..db43beb7d 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_attach_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_attach_test.go @@ -11,8 +11,8 @@ import ( "time" "github.com/docker/docker/integration-cli/cli" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) const attachWait = 5 * time.Second @@ -168,7 +168,7 @@ func (s *DockerSuite) TestAttachPausedContainer(c *check.C) { dockerCmd(c, "pause", "test") result := dockerCmdWithResult("attach", "test") - c.Assert(result, icmd.Matches, icmd.Expected{ + result.Assert(c, icmd.Expected{ Error: "exit status 1", ExitCode: 1, Err: "You cannot attach to a paused container, unpause it first", diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_attach_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_attach_unix_test.go index 78f55e043..e40d7cf39 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_attach_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_attach_unix_test.go @@ -173,7 +173,7 @@ func (s *DockerSuite) TestAttachDetach(c *check.C) { c.Assert(running, checker.Equals, "true", check.Commentf("expected container to still be running")) go func() { - dockerCmd(c, "kill", id) + dockerCmdWithResult("kill", id) }() select { @@ -225,7 +225,7 @@ func (s *DockerSuite) TestAttachDetachTruncatedID(c *check.C) { c.Assert(running, checker.Equals, "true", check.Commentf("expected container to still be running")) go func() { - dockerCmd(c, "kill", id) + dockerCmdWithResult("kill", id) }() select { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_authz_plugin_v2_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_authz_plugin_v2_test.go index 0143f1c0f..30026f7fc 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_authz_plugin_v2_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_authz_plugin_v2_test.go @@ -4,7 +4,6 @@ package main import ( "fmt" - "strings" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/daemon" @@ -31,7 +30,7 @@ type DockerAuthzV2Suite struct { } func (s *DockerAuthzV2Suite) SetUpTest(c *check.C) { - testRequires(c, DaemonIsLinux, Network) + testRequires(c, DaemonIsLinux, Network, SameHostDaemon) s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ Experimental: testEnv.ExperimentalDaemon(), }) @@ -47,13 +46,14 @@ func (s *DockerAuthzV2Suite) TearDownTest(c *check.C) { func (s *DockerAuthzV2Suite) TestAuthZPluginAllowNonVolumeRequest(c *check.C) { testRequires(c, DaemonIsLinux, IsAmd64, Network) + // Install authz plugin _, err := s.d.Cmd("plugin", "install", "--grant-all-permissions", authzPluginNameWithTag) c.Assert(err, checker.IsNil) // start the daemon with the plugin and load busybox, --net=none build fails otherwise // because it needs to pull busybox s.d.Restart(c, "--authorization-plugin="+authzPluginNameWithTag) - c.Assert(s.d.LoadBusybox(), check.IsNil) + s.d.LoadBusybox(c) // defer disabling the plugin defer func() { @@ -65,14 +65,8 @@ func (s *DockerAuthzV2Suite) TestAuthZPluginAllowNonVolumeRequest(c *check.C) { }() // Ensure docker run command and accompanying docker ps are successful - out, err := s.d.Cmd("run", "-d", "busybox", "top") - c.Assert(err, check.IsNil) - - id := strings.TrimSpace(out) - - out, err = s.d.Cmd("ps") + _, err = s.d.Cmd("run", "-d", "busybox", "top") c.Assert(err, check.IsNil) - c.Assert(assertContainerList(out, []string{id}), check.Equals, true) } func (s *DockerAuthzV2Suite) TestAuthZPluginDisable(c *check.C) { @@ -83,7 +77,7 @@ func (s *DockerAuthzV2Suite) TestAuthZPluginDisable(c *check.C) { // start the daemon with the plugin and load busybox, --net=none build fails otherwise // because it needs to pull busybox s.d.Restart(c, "--authorization-plugin="+authzPluginNameWithTag) - c.Assert(s.d.LoadBusybox(), check.IsNil) + s.d.LoadBusybox(c) // defer removing the plugin defer func() { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_authz_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_authz_unix_test.go index 959292f05..8a1bd023e 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_authz_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_authz_unix_test.go @@ -64,6 +64,7 @@ type authorizationController struct { } func (s *DockerAuthzSuite) SetUpTest(c *check.C) { + testRequires(c, SameHostDaemon) s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ Experimental: testEnv.ExperimentalDaemon(), }) @@ -209,7 +210,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginAllowRequest(c *check.C) { s.d.Start(c, "--authorization-plugin="+testAuthZPlugin) s.ctrl.reqRes.Allow = true s.ctrl.resRes.Allow = true - c.Assert(s.d.LoadBusybox(), check.IsNil) + s.d.LoadBusybox(c) // Ensure command successful out, err := s.d.Cmd("run", "-d", "busybox", "top") @@ -218,12 +219,6 @@ func (s *DockerAuthzSuite) TestAuthZPluginAllowRequest(c *check.C) { id := strings.TrimSpace(out) assertURIRecorded(c, s.ctrl.requestsURIs, "/containers/create") assertURIRecorded(c, s.ctrl.requestsURIs, fmt.Sprintf("/containers/%s/start", id)) - - out, err = s.d.Cmd("ps") - c.Assert(err, check.IsNil) - c.Assert(assertContainerList(out, []string{id}), check.Equals, true) - c.Assert(s.ctrl.psRequestCnt, check.Equals, 1) - c.Assert(s.ctrl.psResponseCnt, check.Equals, 1) } func (s *DockerAuthzSuite) TestAuthZPluginTls(c *check.C) { @@ -322,7 +317,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginAllowEventStream(c *check.C) { s.d.Start(c, "--authorization-plugin="+testAuthZPlugin) s.ctrl.reqRes.Allow = true s.ctrl.resRes.Allow = true - c.Assert(s.d.LoadBusybox(), check.IsNil) + s.d.LoadBusybox(c) startTime := strconv.FormatInt(daemonTime(c).Unix(), 10) // Add another command to to enable event pipelining @@ -418,7 +413,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginEnsureLoadImportWorking(c *check.C) { s.d.Start(c, "--authorization-plugin="+testAuthZPlugin, "--authorization-plugin="+testAuthZPlugin) s.ctrl.reqRes.Allow = true s.ctrl.resRes.Allow = true - c.Assert(s.d.LoadBusybox(), check.IsNil) + s.d.LoadBusybox(c) tmp, err := ioutil.TempDir("", "test-authz-load-import") c.Assert(err, check.IsNil) @@ -445,7 +440,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginHeader(c *check.C) { s.d.Start(c, "--debug", "--authorization-plugin="+testAuthZPlugin) s.ctrl.reqRes.Allow = true s.ctrl.resRes.Allow = true - c.Assert(s.d.LoadBusybox(), check.IsNil) + s.d.LoadBusybox(c) daemonURL, err := url.Parse(s.d.Sock()) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_build_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_build_test.go index 5a3d3efc6..f6ab1923b 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_build_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_build_test.go @@ -25,10 +25,9 @@ import ( "github.com/docker/docker/integration-cli/cli/build/fakestorage" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/stringutils" - "github.com/docker/docker/pkg/testutil" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" - "github.com/opencontainers/go-digest" + "github.com/gotestyourself/gotestyourself/icmd" + digest "github.com/opencontainers/go-digest" ) func (s *DockerSuite) TestBuildJSONEmptyRun(c *check.C) { @@ -1174,12 +1173,13 @@ func (s *DockerSuite) TestBuildForceRm(c *check.C) { containerCountBefore := getContainerCount(c) name := "testbuildforcerm" - buildImage(name, cli.WithFlags("--force-rm"), build.WithBuildContext(c, - build.WithFile("Dockerfile", `FROM `+minimalBaseImage()+` + r := buildImage(name, cli.WithFlags("--force-rm"), build.WithBuildContext(c, + build.WithFile("Dockerfile", `FROM busybox RUN true - RUN thiswillfail`))).Assert(c, icmd.Expected{ - ExitCode: 1, - }) + RUN thiswillfail`))) + if r.ExitCode != 1 && r.ExitCode != 127 { // different on Linux / Windows + c.Fatalf("Wrong exit code") + } containerCountAfter := getContainerCount(c) if containerCountBefore != containerCountAfter { @@ -1526,7 +1526,7 @@ func (s *DockerSuite) TestBuildContextCleanup(c *check.C) { if err != nil { c.Fatalf("failed to list contents of tmp dir: %s", err) } - if err = testutil.CompareDirectoryEntries(entries, entriesFinal); err != nil { + if err = compareDirectoryEntries(entries, entriesFinal); err != nil { c.Fatalf("context should have been deleted, but wasn't") } @@ -1550,12 +1550,31 @@ func (s *DockerSuite) TestBuildContextCleanupFailedBuild(c *check.C) { if err != nil { c.Fatalf("failed to list contents of tmp dir: %s", err) } - if err = testutil.CompareDirectoryEntries(entries, entriesFinal); err != nil { + if err = compareDirectoryEntries(entries, entriesFinal); err != nil { c.Fatalf("context should have been deleted, but wasn't") } } +// compareDirectoryEntries compares two sets of FileInfo (usually taken from a directory) +// and returns an error if different. +func compareDirectoryEntries(e1 []os.FileInfo, e2 []os.FileInfo) error { + var ( + e1Entries = make(map[string]struct{}) + e2Entries = make(map[string]struct{}) + ) + for _, e := range e1 { + e1Entries[e.Name()] = struct{}{} + } + for _, e := range e2 { + e2Entries[e.Name()] = struct{}{} + } + if !reflect.DeepEqual(e1Entries, e2Entries) { + return fmt.Errorf("entries differ") + } + return nil +} + func (s *DockerSuite) TestBuildCmd(c *check.C) { name := "testbuildcmd" expected := "[/bin/echo Hello World]" @@ -3848,7 +3867,7 @@ func (s *DockerSuite) TestBuildDockerfileOutsideContext(c *check.C) { filepath.Join(ctx, "dockerfile2"), } { result := dockerCmdWithResult("build", "-t", name, "--no-cache", "-f", dockerfilePath, ".") - c.Assert(result, icmd.Matches, icmd.Expected{ + result.Assert(c, icmd.Expected{ Err: "must be within the build context", ExitCode: 1, }) @@ -4052,7 +4071,7 @@ func (s *DockerSuite) TestBuildContainerWithCgroupParent(c *check.C) { if err != nil { c.Fatalf("failed to read '/proc/self/cgroup - %v", err) } - selfCgroupPaths := testutil.ParseCgroupPaths(string(data)) + selfCgroupPaths := ParseCgroupPaths(string(data)) _, found := selfCgroupPaths["memory"] if !found { c.Fatalf("unable to find self memory cgroup path. CgroupsPath: %v", selfCgroupPaths) @@ -4524,7 +4543,6 @@ func (s *DockerSuite) TestBuildBuildTimeArgOverrideEnvDefinedBeforeArg(c *check. } func (s *DockerSuite) TestBuildBuildTimeArgExpansion(c *check.C) { - testRequires(c, DaemonIsLinux) // Windows does not support ARG imgName := "bldvarstest" wdVar := "WDIR" @@ -4541,6 +4559,10 @@ func (s *DockerSuite) TestBuildBuildTimeArgExpansion(c *check.C) { userVal := "testUser" volVar := "VOL" volVal := "/testVol/" + if DaemonIsWindows() { + volVal = "C:\\testVol" + wdVal = "C:\\tmp" + } buildImageSuccessfully(c, imgName, cli.WithFlags( @@ -4576,7 +4598,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgExpansion(c *check.C) { ) res := inspectField(c, imgName, "Config.WorkingDir") - c.Check(res, check.Equals, filepath.ToSlash(wdVal)) + c.Check(filepath.ToSlash(res), check.Equals, filepath.ToSlash(wdVal)) var resArr []string inspectFieldAndUnmarshall(c, imgName, "Config.Env", &resArr) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_build_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_build_unix_test.go index 11c682325..91a329fae 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_build_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_build_unix_test.go @@ -12,32 +12,33 @@ import ( "path/filepath" "regexp" "strings" + "syscall" "time" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" "github.com/docker/docker/integration-cli/cli/build/fakecontext" - "github.com/docker/docker/pkg/testutil" - icmd "github.com/docker/docker/pkg/testutil/cmd" - "github.com/docker/go-units" + units "github.com/docker/go-units" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *check.C) { testRequires(c, cpuCfsQuota) name := "testbuildresourceconstraints" + buildLabel := "DockerSuite.TestBuildResourceConstraintsAreUsed" ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(` FROM hello-world:frozen RUN ["/hello"] `)) cli.Docker( - cli.Args("build", "--no-cache", "--rm=false", "--memory=64m", "--memory-swap=-1", "--cpuset-cpus=0", "--cpuset-mems=0", "--cpu-shares=100", "--cpu-quota=8000", "--ulimit", "nofile=42", "-t", name, "."), + cli.Args("build", "--no-cache", "--rm=false", "--memory=64m", "--memory-swap=-1", "--cpuset-cpus=0", "--cpuset-mems=0", "--cpu-shares=100", "--cpu-quota=8000", "--ulimit", "nofile=42", "--label="+buildLabel, "-t", name, "."), cli.InDir(ctx.Dir), ).Assert(c, icmd.Success) - out := cli.DockerCmd(c, "ps", "-lq").Combined() + out := cli.DockerCmd(c, "ps", "-lq", "--filter", "label="+buildLabel).Combined() cID := strings.TrimSpace(out) type hostConfig struct { @@ -191,7 +192,7 @@ func (s *DockerSuite) TestBuildCancellationKillsSleep(c *check.C) { } // Get the exit status of `docker build`, check it exited because killed. - if err := buildCmd.Wait(); err != nil && !testutil.IsKilled(err) { + if err := buildCmd.Wait(); err != nil && !isKilled(err) { c.Fatalf("wait failed during build run: %T %s", err, err) } @@ -202,3 +203,17 @@ func (s *DockerSuite) TestBuildCancellationKillsSleep(c *check.C) { // ignore, done } } + +func isKilled(err error) bool { + if exitErr, ok := err.(*exec.ExitError); ok { + status, ok := exitErr.Sys().(syscall.WaitStatus) + if !ok { + return false + } + // status.ExitStatus() is required on Windows because it does not + // implement Signal() nor Signaled(). Just check it had a bad exit + // status could mean it was killed (and in tests we do kill) + return (status.Signaled() && status.Signal() == os.Kill) || status.ExitStatus() != 0 + } + return false +} diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_by_digest_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_by_digest_test.go index c7115c88c..0c682719a 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_by_digest_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_by_digest_test.go @@ -407,6 +407,8 @@ func (s *DockerRegistrySuite) TestInspectImageWithDigests(c *check.C) { } func (s *DockerRegistrySuite) TestPsListContainersFilterAncestorImageByDigest(c *check.C) { + existingContainers := ExistingContainerIDs(c) + digest, err := setupImage(c) c.Assert(err, checker.IsNil, check.Commentf("error setting up image")) @@ -438,7 +440,7 @@ func (s *DockerRegistrySuite) TestPsListContainersFilterAncestorImageByDigest(c // Valid imageReference out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=ancestor="+imageReference) - checkPsAncestorFilterOutput(c, out, imageReference, expectedIDs) + checkPsAncestorFilterOutput(c, RemoveOutputForExistingElements(out, existingContainers), imageReference, expectedIDs) } func (s *DockerRegistrySuite) TestDeleteImageByIDOnlyPulledByDigest(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_commit_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_commit_test.go index b054c79c3..58a50ce0b 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_commit_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_commit_test.go @@ -122,7 +122,7 @@ func (s *DockerSuite) TestCommitChange(c *check.C) { imageID = strings.TrimSpace(imageID) prefix, slash := getPrefixAndSlashFromDaemonPlatform() - prefix = strings.ToUpper(prefix) // Force C: as that's how WORKDIR is normalised on Windows + prefix = strings.ToUpper(prefix) // Force C: as that's how WORKDIR is normalized on Windows expected := map[string]string{ "Config.ExposedPorts": "map[8080/tcp:{}]", "Config.Env": "[DEBUG=true test=1 PATH=/foo]", diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_config_ls_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_config_ls_test.go index 5c0701261..5f002bcab 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_config_ls_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_config_ls_test.go @@ -11,6 +11,7 @@ import ( ) func (s *DockerSwarmSuite) TestConfigList(c *check.C) { + testRequires(c, SameHostDaemon) d := s.AddDaemon(c, true, true) testName0 := "test0" diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_config_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_config_test.go deleted file mode 100644 index 46fe456bd..000000000 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_config_test.go +++ /dev/null @@ -1,150 +0,0 @@ -package main - -import ( - "io/ioutil" - "net/http" - "net/http/httptest" - "os" - "path/filepath" - "runtime" - - "github.com/docker/docker/api" - "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/pkg/homedir" - icmd "github.com/docker/docker/pkg/testutil/cmd" - "github.com/go-check/check" -) - -func (s *DockerSuite) TestConfigHTTPHeader(c *check.C) { - testRequires(c, UnixCli) // Can't set/unset HOME on windows right now - // We either need a level of Go that supports Unsetenv (for cases - // when HOME/USERPROFILE isn't set), or we need to be able to use - // os/user but user.Current() only works if we aren't statically compiling - - var headers map[string][]string - - server := httptest.NewServer(http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("API-Version", api.DefaultVersion) - headers = r.Header - })) - defer server.Close() - - homeKey := homedir.Key() - homeVal := homedir.Get() - tmpDir, err := ioutil.TempDir("", "fake-home") - c.Assert(err, checker.IsNil) - defer os.RemoveAll(tmpDir) - - dotDocker := filepath.Join(tmpDir, ".docker") - os.Mkdir(dotDocker, 0600) - tmpCfg := filepath.Join(dotDocker, "config.json") - - defer func() { os.Setenv(homeKey, homeVal) }() - os.Setenv(homeKey, tmpDir) - - data := `{ - "HttpHeaders": { "MyHeader": "MyValue" } - }` - - err = ioutil.WriteFile(tmpCfg, []byte(data), 0600) - c.Assert(err, checker.IsNil) - - result := icmd.RunCommand(dockerBinary, "-H="+server.URL[7:], "ps") - result.Assert(c, icmd.Expected{ - ExitCode: 1, - Error: "exit status 1", - }) - - c.Assert(headers["User-Agent"], checker.NotNil, check.Commentf("Missing User-Agent")) - - c.Assert(headers["User-Agent"][0], checker.Equals, "Docker-Client/"+os.Getenv("DOCKER_CLI_VERSION")+" ("+runtime.GOOS+")", check.Commentf("Badly formatted User-Agent,out:%v", result.Combined())) - - c.Assert(headers["Myheader"], checker.NotNil) - c.Assert(headers["Myheader"][0], checker.Equals, "MyValue", check.Commentf("Missing/bad header,out:%v", result.Combined())) - -} - -func (s *DockerSuite) TestConfigDir(c *check.C) { - cDir, err := ioutil.TempDir("", "fake-home") - c.Assert(err, checker.IsNil) - defer os.RemoveAll(cDir) - - // First make sure pointing to empty dir doesn't generate an error - dockerCmd(c, "--config", cDir, "ps") - - // Test with env var too - icmd.RunCmd(icmd.Cmd{ - Command: []string{dockerBinary, "ps"}, - Env: appendBaseEnv(true, "DOCKER_CONFIG="+cDir), - }).Assert(c, icmd.Success) - - // Start a server so we can check to see if the config file was - // loaded properly - var headers map[string][]string - - server := httptest.NewServer(http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - headers = r.Header - })) - defer server.Close() - - // Create a dummy config file in our new config dir - data := `{ - "HttpHeaders": { "MyHeader": "MyValue" } - }` - - tmpCfg := filepath.Join(cDir, "config.json") - err = ioutil.WriteFile(tmpCfg, []byte(data), 0600) - c.Assert(err, checker.IsNil, check.Commentf("Err creating file")) - - env := appendBaseEnv(false) - - icmd.RunCmd(icmd.Cmd{ - Command: []string{dockerBinary, "--config", cDir, "-H=" + server.URL[7:], "ps"}, - Env: env, - }).Assert(c, icmd.Expected{ - ExitCode: 1, - Error: "exit status 1", - }) - c.Assert(headers["Myheader"], checker.NotNil) - c.Assert(headers["Myheader"][0], checker.Equals, "MyValue", check.Commentf("ps3 - Missing header")) - - // Reset headers and try again using env var this time - headers = map[string][]string{} - icmd.RunCmd(icmd.Cmd{ - Command: []string{dockerBinary, "--config", cDir, "-H=" + server.URL[7:], "ps"}, - Env: append(env, "DOCKER_CONFIG="+cDir), - }).Assert(c, icmd.Expected{ - ExitCode: 1, - }) - c.Assert(headers["Myheader"], checker.NotNil) - c.Assert(headers["Myheader"][0], checker.Equals, "MyValue", check.Commentf("ps4 - Missing header")) - - // FIXME(vdemeester) should be a unit test - // Reset headers and make sure flag overrides the env var - headers = map[string][]string{} - icmd.RunCmd(icmd.Cmd{ - Command: []string{dockerBinary, "--config", cDir, "-H=" + server.URL[7:], "ps"}, - Env: append(env, "DOCKER_CONFIG=MissingDir"), - }).Assert(c, icmd.Expected{ - ExitCode: 1, - }) - c.Assert(headers["Myheader"], checker.NotNil) - c.Assert(headers["Myheader"][0], checker.Equals, "MyValue", check.Commentf("ps5 - Missing header")) - - // FIXME(vdemeester) should be a unit test - // Reset headers and make sure flag overrides the env var. - // Almost same as previous but make sure the "MissingDir" isn't - // ignore - we don't want to default back to the env var. - headers = map[string][]string{} - icmd.RunCmd(icmd.Cmd{ - Command: []string{dockerBinary, "--config", "MissingDir", "-H=" + server.URL[7:], "ps"}, - Env: append(env, "DOCKER_CONFIG="+cDir), - }).Assert(c, icmd.Expected{ - ExitCode: 1, - Error: "exit status 1", - }) - - c.Assert(headers["Myheader"], checker.IsNil, check.Commentf("ps6 - Headers shouldn't be the expected value")) -} diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_from_container_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_from_container_test.go index 116f24610..687aec8b5 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_from_container_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_from_container_test.go @@ -64,19 +64,17 @@ func (s *DockerSuite) TestCpFromErrDstParentNotExists(c *check.C) { // Try with a file source. srcPath := containerCpPath(containerID, "/file1") dstPath := cpPath(tmpDir, "notExists", "file1") + _, dstStatErr := os.Lstat(filepath.Dir(dstPath)) + c.Assert(os.IsNotExist(dstStatErr), checker.True) err := runDockerCp(c, srcPath, dstPath, nil) - c.Assert(err, checker.NotNil) - - c.Assert(isCpNotExist(err), checker.True, check.Commentf("expected IsNotExist error, but got %T: %s", err, err)) + c.Assert(err.Error(), checker.Contains, dstStatErr.Error()) // Try with a directory source. srcPath = containerCpPath(containerID, "/dir1") err = runDockerCp(c, srcPath, dstPath, nil) - c.Assert(err, checker.NotNil) - - c.Assert(isCpNotExist(err), checker.True, check.Commentf("expected IsNotExist error, but got %T: %s", err, err)) + c.Assert(err.Error(), checker.Contains, dstStatErr.Error()) } // Test for error when DST ends in a trailing diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_test.go index f7ed45919..59248d04a 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_test.go @@ -11,9 +11,8 @@ import ( "strings" "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/pkg/testutil" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) const ( @@ -548,7 +547,7 @@ func (s *DockerSuite) TestCpToStdout(c *check.C) { // failed to set up container c.Assert(strings.TrimSpace(out), checker.Equals, "0") - out, _, err := testutil.RunCommandPipelineWithOutput( + out, err := RunCommandPipelineWithOutput( exec.Command(dockerBinary, "cp", containerID+":/test", "-"), exec.Command("tar", "-vtf", "-")) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_to_container_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_to_container_test.go index 97e9aa123..57a850c42 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_to_container_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_to_container_test.go @@ -2,6 +2,7 @@ package main import ( "os" + "strings" "github.com/docker/docker/integration-cli/checker" "github.com/go-check/check" @@ -30,11 +31,11 @@ func (s *DockerSuite) TestCpToErrSrcNotExists(c *check.C) { srcPath := cpPath(tmpDir, "file1") dstPath := containerCpPath(containerID, "file1") + _, srcStatErr := os.Stat(srcPath) + c.Assert(os.IsNotExist(srcStatErr), checker.True) err := runDockerCp(c, srcPath, dstPath, nil) - c.Assert(err, checker.NotNil) - - c.Assert(isCpNotExist(err), checker.True, check.Commentf("expected IsNotExist error, but got %T: %s", err, err)) + c.Assert(strings.ToLower(err.Error()), checker.Contains, strings.ToLower(srcStatErr.Error())) } // Test for error when SRC ends in a trailing diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_utils_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_utils_test.go index 48aff9061..402a87ea9 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_utils_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_cp_utils_test.go @@ -193,9 +193,7 @@ func runDockerCp(c *check.C, src, dst string, params []string) (err error) { args := []string{"cp"} - for _, param := range params { - args = append(args, param) - } + args = append(args, params...) args = append(args, src, dst) @@ -231,7 +229,7 @@ func getTestDir(c *check.C, label string) (tmpDir string) { } func isCpNotExist(err error) bool { - return strings.Contains(err.Error(), "no such file or directory") || strings.Contains(err.Error(), "cannot find the file specified") + return strings.Contains(strings.ToLower(err.Error()), "could not find the file") } func isCpDirNotExist(err error) bool { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_create_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_create_test.go index d4eb985a3..f5fe0da7f 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_create_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_create_test.go @@ -14,9 +14,9 @@ import ( "github.com/docker/docker/integration-cli/cli/build" "github.com/docker/docker/integration-cli/cli/build/fakecontext" "github.com/docker/docker/pkg/stringid" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/docker/go-connections/nat" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) // Make sure we can create a simple container with some args diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_daemon_plugins_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_daemon_plugins_test.go index 66c9f6ece..10aa514fe 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_daemon_plugins_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_daemon_plugins_test.go @@ -9,8 +9,8 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/pkg/mount" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" "golang.org/x/sys/unix" ) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_daemon_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_daemon_test.go index 6a98cabdf..ccf50543e 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_daemon_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_daemon_test.go @@ -34,12 +34,11 @@ import ( "github.com/docker/docker/opts" "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/stringid" - "github.com/docker/docker/pkg/testutil" - icmd "github.com/docker/docker/pkg/testutil/cmd" units "github.com/docker/go-units" "github.com/docker/libnetwork/iptables" "github.com/docker/libtrust" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" "github.com/kr/pty" "golang.org/x/sys/unix" ) @@ -202,7 +201,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithInvalidBasesize(c *check.C) { testRequires(c, Devicemapper) s.d.Start(c) - oldBasesizeBytes := s.d.GetBaseDeviceSize(c) + oldBasesizeBytes := getBaseDeviceSize(c, s.d) var newBasesizeBytes int64 = 1073741824 //1GB in bytes if newBasesizeBytes < oldBasesizeBytes { @@ -222,7 +221,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithIncreasedBasesize(c *check.C) { testRequires(c, Devicemapper) s.d.Start(c) - oldBasesizeBytes := s.d.GetBaseDeviceSize(c) + oldBasesizeBytes := getBaseDeviceSize(c, s.d) var newBasesizeBytes int64 = 53687091200 //50GB in bytes @@ -233,13 +232,31 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithIncreasedBasesize(c *check.C) { err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes)) c.Assert(err, check.IsNil, check.Commentf("we should have been able to start the daemon with increased base device size: %v", err)) - basesizeAfterRestart := s.d.GetBaseDeviceSize(c) + basesizeAfterRestart := getBaseDeviceSize(c, s.d) newBasesize, err := convertBasesize(newBasesizeBytes) c.Assert(err, check.IsNil, check.Commentf("Error in converting base device size: %v", err)) c.Assert(newBasesize, check.Equals, basesizeAfterRestart, check.Commentf("Basesize passed is not equal to Basesize set")) s.d.Stop(c) } +func getBaseDeviceSize(c *check.C, d *daemon.Daemon) int64 { + info := d.Info(c) + for _, statusLine := range info.DriverStatus { + key, value := statusLine[0], statusLine[1] + if key == "Base Device Size" { + return parseDeviceSize(c, value) + } + } + c.Fatal("failed to parse Base Device Size from info") + return int64(0) +} + +func parseDeviceSize(c *check.C, raw string) int64 { + size, err := units.RAMInBytes(strings.TrimSpace(raw)) + c.Assert(err, check.IsNil) + return size +} + func convertBasesize(basesizeBytes int64) (int64, error) { basesize := units.HumanSize(float64(basesizeBytes)) basesize = strings.Trim(basesize, " ")[:len(basesize)-3] @@ -817,7 +834,7 @@ func (s *DockerDaemonSuite) TestDaemonDefaultNetworkInvalidClusterConfig(c *chec // Start daemon with docker0 bridge result := icmd.RunCommand("ifconfig", defaultNetworkBridge) - c.Assert(result, icmd.Matches, icmd.Success) + result.Assert(c, icmd.Success) s.d.Restart(c, fmt.Sprintf("--cluster-store=%s", discoveryBackend)) } @@ -1808,7 +1825,7 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *check.C) { defer s.d.Stop(c) // pull a repository large enough to fill the mount point - pullOut, err := s.d.Cmd("pull", "registry:2") + pullOut, err := s.d.Cmd("pull", "debian:stretch") c.Assert(err, checker.NotNil, check.Commentf(pullOut)) c.Assert(pullOut, checker.Contains, "no space left on device") } @@ -1883,7 +1900,7 @@ func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *check.C) { out, err := s.d.Cmd("run", "--name", name, "busybox", "cat", "/proc/self/cgroup") c.Assert(err, checker.IsNil) - cgroupPaths := testutil.ParseCgroupPaths(string(out)) + cgroupPaths := ParseCgroupPaths(string(out)) c.Assert(len(cgroupPaths), checker.Not(checker.Equals), 0, check.Commentf("unexpected output - %q", string(out))) out, err = s.d.Cmd("inspect", "-f", "{{.Id}}", name) c.Assert(err, checker.IsNil) @@ -2088,7 +2105,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *che ctrBinary, "--address", "unix:///var/run/docker/libcontainerd/docker-containerd.sock", "containers", "resume", cid) - t.Assert(result, icmd.Matches, icmd.Success) + result.Assert(t, icmd.Success) // Give time to containerd to process the command if we don't // the resume event might be received after we do the inspect @@ -2142,9 +2159,9 @@ func (s *DockerDaemonSuite) TestRunLinksChanged(c *check.C) { } func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *check.C) { - testRequires(c, DaemonIsLinux, NotPpc64le) + testRequires(c, DaemonIsLinux) - infoLog := "\x1b[34mINFO\x1b" + infoLog := "\x1b[36mINFO\x1b" b := bytes.NewBuffer(nil) done := make(chan bool) @@ -2192,7 +2209,7 @@ func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *check.C) { } func (s *DockerDaemonSuite) TestDaemonDebugLog(c *check.C) { - testRequires(c, DaemonIsLinux, NotPpc64le) + testRequires(c, DaemonIsLinux) debugLog := "\x1b[37mDEBU\x1b" @@ -2985,6 +3002,167 @@ func (s *DockerDaemonSuite) TestShmSizeReload(c *check.C) { c.Assert(strings.TrimSpace(out), check.Equals, fmt.Sprintf("%v", size)) } +// this is used to test both "private" and "shareable" daemon default ipc modes +func testDaemonIpcPrivateShareable(d *daemon.Daemon, c *check.C, mustExist bool) { + name := "test-ipcmode" + _, err := d.Cmd("run", "-d", "--name", name, "busybox", "top") + c.Assert(err, checker.IsNil) + + // get major:minor pair for /dev/shm from container's /proc/self/mountinfo + cmd := "awk '($5 == \"/dev/shm\") {printf $3}' /proc/self/mountinfo" + mm, err := d.Cmd("exec", "-i", name, "sh", "-c", cmd) + c.Assert(err, checker.IsNil) + c.Assert(mm, checker.Matches, "^[0-9]+:[0-9]+$") + + exists, err := testIpcCheckDevExists(mm) + c.Assert(err, checker.IsNil) + c.Logf("[testDaemonIpcPrivateShareable] ipcdev: %v, exists: %v, mustExist: %v\n", mm, exists, mustExist) + c.Assert(exists, checker.Equals, mustExist) +} + +// TestDaemonIpcModeShareable checks that --default-ipc-mode shareable works as intended. +func (s *DockerDaemonSuite) TestDaemonIpcModeShareable(c *check.C) { + testRequires(c, DaemonIsLinux, SameHostDaemon) + + s.d.StartWithBusybox(c, "--default-ipc-mode", "shareable") + testDaemonIpcPrivateShareable(s.d, c, true) +} + +// TestDaemonIpcModePrivate checks that --default-ipc-mode private works as intended. +func (s *DockerDaemonSuite) TestDaemonIpcModePrivate(c *check.C) { + testRequires(c, DaemonIsLinux, SameHostDaemon) + + s.d.StartWithBusybox(c, "--default-ipc-mode", "private") + testDaemonIpcPrivateShareable(s.d, c, false) +} + +// used to check if an IpcMode given in config works as intended +func testDaemonIpcFromConfig(s *DockerDaemonSuite, c *check.C, mode string, mustExist bool) { + f, err := ioutil.TempFile("", "test-daemon-ipc-config") + c.Assert(err, checker.IsNil) + defer os.Remove(f.Name()) + + config := `{"default-ipc-mode": "` + mode + `"}` + _, err = f.WriteString(config) + c.Assert(f.Close(), checker.IsNil) + c.Assert(err, checker.IsNil) + + s.d.StartWithBusybox(c, "--config-file", f.Name()) + testDaemonIpcPrivateShareable(s.d, c, mustExist) +} + +// TestDaemonIpcModePrivateFromConfig checks that "default-ipc-mode: private" config works as intended. +func (s *DockerDaemonSuite) TestDaemonIpcModePrivateFromConfig(c *check.C) { + testRequires(c, DaemonIsLinux, SameHostDaemon) + testDaemonIpcFromConfig(s, c, "private", false) +} + +// TestDaemonIpcModeShareableFromConfig checks that "default-ipc-mode: shareable" config works as intended. +func (s *DockerDaemonSuite) TestDaemonIpcModeShareableFromConfig(c *check.C) { + testRequires(c, DaemonIsLinux, SameHostDaemon) + testDaemonIpcFromConfig(s, c, "shareable", true) +} + +func testDaemonStartIpcMode(c *check.C, from, mode string, valid bool) { + d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ + Experimental: testEnv.ExperimentalDaemon(), + }) + c.Logf("Checking IpcMode %s set from %s\n", mode, from) + var serr error + switch from { + case "config": + f, err := ioutil.TempFile("", "test-daemon-ipc-config") + c.Assert(err, checker.IsNil) + defer os.Remove(f.Name()) + config := `{"default-ipc-mode": "` + mode + `"}` + _, err = f.WriteString(config) + c.Assert(f.Close(), checker.IsNil) + c.Assert(err, checker.IsNil) + + serr = d.StartWithError("--config-file", f.Name()) + case "cli": + serr = d.StartWithError("--default-ipc-mode", mode) + default: + c.Fatalf("testDaemonStartIpcMode: invalid 'from' argument") + } + if serr == nil { + d.Stop(c) + } + + if valid { + c.Assert(serr, check.IsNil) + } else { + c.Assert(serr, check.NotNil) + icmd.RunCommand("grep", "-E", "IPC .* is (invalid|not supported)", d.LogFileName()).Assert(c, icmd.Success) + } +} + +// TestDaemonStartWithIpcModes checks that daemon starts fine given correct +// arguments for default IPC mode, and bails out with incorrect ones. +// Both CLI option (--default-ipc-mode) and config parameter are tested. +func (s *DockerDaemonSuite) TestDaemonStartWithIpcModes(c *check.C) { + testRequires(c, DaemonIsLinux, SameHostDaemon) + + ipcModes := []struct { + mode string + valid bool + }{ + {"private", true}, + {"shareable", true}, + + {"host", false}, + {"container:123", false}, + {"nosuchmode", false}, + } + + for _, from := range []string{"config", "cli"} { + for _, m := range ipcModes { + testDaemonStartIpcMode(c, from, m.mode, m.valid) + } + } +} + +// TestDaemonRestartIpcMode makes sure a container keeps its ipc mode +// (derived from daemon default) even after the daemon is restarted +// with a different default ipc mode. +func (s *DockerDaemonSuite) TestDaemonRestartIpcMode(c *check.C) { + f, err := ioutil.TempFile("", "test-daemon-ipc-config-restart") + c.Assert(err, checker.IsNil) + file := f.Name() + defer os.Remove(file) + c.Assert(f.Close(), checker.IsNil) + + config := []byte(`{"default-ipc-mode": "private"}`) + c.Assert(ioutil.WriteFile(file, config, 0644), checker.IsNil) + s.d.StartWithBusybox(c, "--config-file", file) + + // check the container is created with private ipc mode as per daemon default + name := "ipc1" + _, err = s.d.Cmd("run", "-d", "--name", name, "--restart=always", "busybox", "top") + c.Assert(err, checker.IsNil) + m, err := s.d.InspectField(name, ".HostConfig.IpcMode") + c.Assert(err, check.IsNil) + c.Assert(m, checker.Equals, "private") + + // restart the daemon with shareable default ipc mode + config = []byte(`{"default-ipc-mode": "shareable"}`) + c.Assert(ioutil.WriteFile(file, config, 0644), checker.IsNil) + s.d.Restart(c, "--config-file", file) + + // check the container is still having private ipc mode + m, err = s.d.InspectField(name, ".HostConfig.IpcMode") + c.Assert(err, check.IsNil) + c.Assert(m, checker.Equals, "private") + + // check a new container is created with shareable ipc mode as per new daemon default + name = "ipc2" + _, err = s.d.Cmd("run", "-d", "--name", name, "busybox", "top") + c.Assert(err, checker.IsNil) + m, err = s.d.InspectField(name, ".HostConfig.IpcMode") + c.Assert(err, check.IsNil) + c.Assert(m, checker.Equals, "shareable") +} + // TestFailedPluginRemove makes sure that a failed plugin remove does not block // the daemon from starting func (s *DockerDaemonSuite) TestFailedPluginRemove(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_events_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_events_test.go index 0bbc98684..e179a0ebd 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_events_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_events_test.go @@ -6,21 +6,21 @@ import ( "fmt" "io" "io/ioutil" - "net/http" "os" "os/exec" "strings" "time" + "github.com/docker/docker/api/types" eventtypes "github.com/docker/docker/api/types/events" + "github.com/docker/docker/client" eventstestutils "github.com/docker/docker/daemon/events/testutils" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" - "github.com/docker/docker/integration-cli/request" - "github.com/docker/docker/pkg/testutil" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" + "golang.org/x/net/context" ) func (s *DockerSuite) TestEventsTimestampFormats(c *check.C) { @@ -36,7 +36,7 @@ func (s *DockerSuite) TestEventsTimestampFormats(c *check.C) { // List of available time formats to --since unixTs := func(t time.Time) string { return fmt.Sprintf("%v", t.Unix()) } rfc3339 := func(t time.Time) string { return t.Format(time.RFC3339) } - duration := func(t time.Time) string { return time.Now().Sub(t).String() } + duration := func(t time.Time) string { return time.Since(t).String() } // --since=$start must contain only the 'untag' event for _, f := range []func(time.Time) string{unixTs, rfc3339, duration} { @@ -69,7 +69,7 @@ func (s *DockerSuite) TestEventsUntag(c *check.C) { Command: []string{dockerBinary, "events", "--since=1"}, Timeout: time.Millisecond * 2500, }) - c.Assert(result, icmd.Matches, icmd.Expected{Timeout: true}) + result.Assert(c, icmd.Expected{Timeout: true}) events := strings.Split(result.Stdout(), "\n") nEvents := len(events) @@ -230,7 +230,7 @@ func (s *DockerSuite) TestEventsImageImport(c *check.C) { cleanedContainerID := strings.TrimSpace(out) since := daemonUnixTime(c) - out, _, err := testutil.RunCommandPipelineWithOutput( + out, err := RunCommandPipelineWithOutput( exec.Command(dockerBinary, "export", cleanedContainerID), exec.Command(dockerBinary, "import", "-"), ) @@ -263,7 +263,7 @@ func (s *DockerSuite) TestEventsImageLoad(c *check.C) { dockerCmd(c, "load", "-i", "saveimg.tar") result := icmd.RunCommand("rm", "-rf", "saveimg.tar") - c.Assert(result, icmd.Matches, icmd.Success) + result.Assert(c, icmd.Success) out, _ = dockerCmd(c, "images", "-q", "--no-trunc", myImageName) imageID := strings.TrimSpace(out) @@ -499,9 +499,15 @@ func (s *DockerSuite) TestEventsResize(c *check.C) { cID := strings.TrimSpace(out) c.Assert(waitRun(cID), checker.IsNil) - endpoint := "/containers/" + cID + "/resize?h=80&w=24" - status, _, err := request.SockRequest("POST", endpoint, nil, daemonHost()) - c.Assert(status, checker.Equals, http.StatusOK) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + options := types.ResizeOptions{ + Height: 80, + Width: 24, + } + err = cli.ContainerResize(context.Background(), cID, options) c.Assert(err, checker.IsNil) dockerCmd(c, "stop", cID) @@ -781,7 +787,7 @@ func (s *DockerSuite) TestEventsFormat(c *check.C) { func (s *DockerSuite) TestEventsFormatBadFunc(c *check.C) { // make sure it fails immediately, without receiving any event result := dockerCmdWithResult("events", "--format", "{{badFuncString .}}") - c.Assert(result, icmd.Matches, icmd.Expected{ + result.Assert(c, icmd.Expected{ Error: "exit status 64", ExitCode: 64, Err: "Error parsing format: template: :1: function \"badFuncString\" not defined", @@ -791,7 +797,7 @@ func (s *DockerSuite) TestEventsFormatBadFunc(c *check.C) { func (s *DockerSuite) TestEventsFormatBadField(c *check.C) { // make sure it fails immediately, without receiving any event result := dockerCmdWithResult("events", "--format", "{{.badFieldString}}") - c.Assert(result, icmd.Matches, icmd.Expected{ + result.Assert(c, icmd.Expected{ Error: "exit status 64", ExitCode: 64, Err: "Error parsing format: template: :1:2: executing \"\" at <.badFieldString>: can't evaluate field badFieldString in type *events.Message", diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_events_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_events_unix_test.go index 1f87d5fe8..afac998e0 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_events_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_events_unix_test.go @@ -97,7 +97,7 @@ func (s *DockerSuite) TestEventsOOMDisableTrue(c *check.C) { }() c.Assert(waitRun("oomTrue"), checker.IsNil) - defer dockerCmd(c, "kill", "oomTrue") + defer dockerCmdWithResult("kill", "oomTrue") containerID := inspectField(c, "oomTrue", "Id") testActions := map[string]chan bool{ @@ -428,7 +428,32 @@ func (s *DockerDaemonSuite) TestDaemonEvents(c *check.C) { out, err = s.d.Cmd("events", "--since=0", "--until", daemonUnixTime(c)) c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, fmt.Sprintf("daemon reload %s (allow-nondistributable-artifacts=[], cluster-advertise=, cluster-store=, cluster-store-opts={}, debug=true, default-runtime=runc, default-shm-size=67108864, insecure-registries=[], labels=[\"bar=foo\"], live-restore=false, max-concurrent-downloads=1, max-concurrent-uploads=5, name=%s, registry-mirrors=[], runtimes=runc:{docker-runc []}, shutdown-timeout=10)", daemonID, daemonName)) + // only check for values known (daemon ID/name) or explicitly set above, + // otherwise just check for names being present. + expectedSubstrings := []string{ + " daemon reload " + daemonID + " ", + "(allow-nondistributable-artifacts=[", + " cluster-advertise=, ", + " cluster-store=, ", + " cluster-store-opts={", + " debug=true, ", + " default-ipc-mode=", + " default-runtime=", + " default-shm-size=", + " insecure-registries=[", + " labels=[\"bar=foo\"], ", + " live-restore=", + " max-concurrent-downloads=1, ", + " max-concurrent-uploads=5, ", + " name=" + daemonName, + " registry-mirrors=[", + " runtimes=", + " shutdown-timeout=10)", + } + + for _, s := range expectedSubstrings { + c.Assert(out, checker.Contains, s) + } } func (s *DockerDaemonSuite) TestDaemonEventsWithFilters(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_exec_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_exec_test.go index be228ab2d..4442ca2c4 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_exec_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_exec_test.go @@ -5,7 +5,6 @@ package main import ( "bufio" "fmt" - "net/http" "os" "os/exec" "reflect" @@ -15,12 +14,13 @@ import ( "sync" "time" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" - "github.com/docker/docker/integration-cli/request" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" + "golang.org/x/net/context" ) func (s *DockerSuite) TestExec(c *check.C) { @@ -133,7 +133,7 @@ func (s *DockerSuite) TestExecExitStatus(c *check.C) { runSleepingContainer(c, "-d", "--name", "top") result := icmd.RunCommand(dockerBinary, "exec", "top", "sh", "-c", "exit 23") - c.Assert(result, icmd.Matches, icmd.Expected{ExitCode: 23, Error: "exit status 23"}) + result.Assert(c, icmd.Expected{ExitCode: 23, Error: "exit status 23"}) } func (s *DockerSuite) TestExecPausedContainer(c *check.C) { @@ -357,16 +357,21 @@ func (s *DockerSuite) TestExecInspectID(c *check.C) { } // But we should still be able to query the execID - sc, body, _ := request.SockRequest("GET", "/exec/"+execID+"/json", nil, daemonHost()) + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() - c.Assert(sc, checker.Equals, http.StatusOK, check.Commentf("received status != 200 OK: %d\n%s", sc, body)) + _, err = cli.ContainerExecInspect(context.Background(), execID) + c.Assert(err, checker.IsNil) // Now delete the container and then an 'inspect' on the exec should // result in a 404 (not 'container not running') out, ec := dockerCmd(c, "rm", "-f", id) c.Assert(ec, checker.Equals, 0, check.Commentf("error removing container: %s", out)) - sc, body, _ = request.SockRequest("GET", "/exec/"+execID+"/json", nil, daemonHost()) - c.Assert(sc, checker.Equals, http.StatusNotFound, check.Commentf("received status != 404: %d\n%s", sc, body)) + + _, err = cli.ContainerExecInspect(context.Background(), execID) + expected := "No such exec instance" + c.Assert(err.Error(), checker.Contains, expected) } func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_experimental_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_experimental_test.go deleted file mode 100644 index 0a496fd26..000000000 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_experimental_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "strings" - - "github.com/docker/docker/integration-cli/checker" - "github.com/go-check/check" -) - -func (s *DockerSuite) TestExperimentalVersionTrue(c *check.C) { - testExperimentalInVersion(c, ExperimentalDaemon, "*true") -} - -func (s *DockerSuite) TestExperimentalVersionFalse(c *check.C) { - testExperimentalInVersion(c, NotExperimentalDaemon, "*false") -} - -func testExperimentalInVersion(c *check.C, requirement func() bool, expectedValue string) { - testRequires(c, requirement) - out, _ := dockerCmd(c, "version") - for _, line := range strings.Split(out, "\n") { - if strings.HasPrefix(strings.TrimSpace(line), "Experimental:") { - c.Assert(line, checker.Matches, expectedValue) - return - } - } - - c.Fatal(`"Experimental" not found in version output`) -} diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_export_import_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_export_import_test.go index fe117b9ae..45f29d54e 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_export_import_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_export_import_test.go @@ -5,8 +5,8 @@ import ( "strings" "github.com/docker/docker/integration-cli/checker" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) // export an image and try to import it into a new one diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_external_graphdriver_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_external_graphdriver_unix_test.go index 16023c9a7..8e766bcc3 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_external_graphdriver_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_external_graphdriver_unix_test.go @@ -198,12 +198,13 @@ func (s *DockerExternalGraphdriverSuite) setUpPlugin(c *check.C, name string, ex return } + // TODO @gupta-ak: Figure out what to do here. dir, err := driver.Get(req.ID, req.MountLabel) if err != nil { respond(w, err) return } - respond(w, &graphDriverResponse{Dir: dir}) + respond(w, &graphDriverResponse{Dir: dir.Path()}) }) mux.HandleFunc("/GraphDriver.Put", func(w http.ResponseWriter, r *http.Request) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_external_volume_driver_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_external_volume_driver_unix_test.go index 5fe417c2c..2e2de972d 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_external_volume_driver_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_external_volume_driver_unix_test.go @@ -50,6 +50,7 @@ type DockerExternalVolumeSuite struct { } func (s *DockerExternalVolumeSuite) SetUpTest(c *check.C) { + testRequires(c, SameHostDaemon) s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ Experimental: testEnv.ExperimentalDaemon(), }) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_health_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_health_test.go index 0f78a41d8..20b2bc255 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_health_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_health_test.go @@ -39,6 +39,8 @@ func getHealth(c *check.C, name string) *types.Health { func (s *DockerSuite) TestHealth(c *check.C) { testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows + existingContainers := ExistingContainerIDs(c) + imageName := "testhealth" buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox RUN echo OK > /status @@ -49,9 +51,10 @@ func (s *DockerSuite) TestHealth(c *check.C) { // No health status before starting name := "test_health" - dockerCmd(c, "create", "--name", name, imageName) - out, _ := dockerCmd(c, "ps", "-a", "--format={{.Status}}") - c.Check(out, checker.Equals, "Created\n") + cid, _ := dockerCmd(c, "create", "--name", name, imageName) + out, _ := dockerCmd(c, "ps", "-a", "--format={{.ID}} {{.Status}}") + out = RemoveOutputForExistingElements(out, existingContainers) + c.Check(out, checker.Equals, cid[:12]+" Created\n") // Inspect the options out, _ = dockerCmd(c, "inspect", diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_help_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_help_test.go deleted file mode 100644 index d1dcd8c7d..000000000 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_help_test.go +++ /dev/null @@ -1,319 +0,0 @@ -package main - -import ( - "fmt" - "runtime" - "strings" - "unicode" - - "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/integration-cli/cli" - "github.com/docker/docker/pkg/homedir" - icmd "github.com/docker/docker/pkg/testutil/cmd" - "github.com/go-check/check" -) - -func (s *DockerSuite) TestHelpTextVerify(c *check.C) { - // FIXME(vdemeester) should be a unit test, probably using golden files ? - testRequires(c, DaemonIsLinux) - - // Make sure main help text fits within 80 chars and that - // on non-windows system we use ~ when possible (to shorten things). - // Test for HOME set to its default value and set to "/" on linux - // Yes on windows setting up an array and looping (right now) isn't - // necessary because we just have one value, but we'll need the - // array/loop on linux so we might as well set it up so that we can - // test any number of home dirs later on and all we need to do is - // modify the array - the rest of the testing infrastructure should work - homes := []string{homedir.Get()} - - // Non-Windows machines need to test for this special case of $HOME - if runtime.GOOS != "windows" { - homes = append(homes, "/") - } - - homeKey := homedir.Key() - baseEnvs := appendBaseEnv(true) - - // Remove HOME env var from list so we can add a new value later. - for i, env := range baseEnvs { - if strings.HasPrefix(env, homeKey+"=") { - baseEnvs = append(baseEnvs[:i], baseEnvs[i+1:]...) - break - } - } - - for _, home := range homes { - - // Dup baseEnvs and add our new HOME value - newEnvs := make([]string, len(baseEnvs)+1) - copy(newEnvs, baseEnvs) - newEnvs[len(newEnvs)-1] = homeKey + "=" + home - - scanForHome := runtime.GOOS != "windows" && home != "/" - - // Check main help text to make sure its not over 80 chars - result := icmd.RunCmd(icmd.Cmd{ - Command: []string{dockerBinary, "help"}, - Env: newEnvs, - }) - result.Assert(c, icmd.Success) - lines := strings.Split(result.Combined(), "\n") - for _, line := range lines { - // All lines should not end with a space - c.Assert(line, checker.Not(checker.HasSuffix), " ", check.Commentf("Line should not end with a space")) - - if scanForHome && strings.Contains(line, `=`+home) { - c.Fatalf("Line should use '%q' instead of %q:\n%s", homedir.GetShortcutString(), home, line) - } - if runtime.GOOS != "windows" { - i := strings.Index(line, homedir.GetShortcutString()) - if i >= 0 && i != len(line)-1 && line[i+1] != '/' { - c.Fatalf("Main help should not have used home shortcut:\n%s", line) - } - } - } - - // Make sure each cmd's help text fits within 90 chars and that - // on non-windows system we use ~ when possible (to shorten things). - // Pull the list of commands from the "Commands:" section of docker help - // FIXME(vdemeester) Why re-run help ? - //helpCmd = exec.Command(dockerBinary, "help") - //helpCmd.Env = newEnvs - //out, _, err = runCommandWithOutput(helpCmd) - //c.Assert(err, checker.IsNil, check.Commentf(out)) - i := strings.Index(result.Combined(), "Commands:") - c.Assert(i, checker.GreaterOrEqualThan, 0, check.Commentf("Missing 'Commands:' in:\n%s", result.Combined())) - - cmds := []string{} - // Grab all chars starting at "Commands:" - helpOut := strings.Split(result.Combined()[i:], "\n") - // Skip first line, it is just "Commands:" - helpOut = helpOut[1:] - - // Create the list of commands we want to test - cmdsToTest := []string{} - for _, cmd := range helpOut { - // Stop on blank line or non-indented line - if cmd == "" || !unicode.IsSpace(rune(cmd[0])) { - break - } - - // Grab just the first word of each line - cmd = strings.Split(strings.TrimSpace(cmd), " ")[0] - cmds = append(cmds, cmd) // Saving count for later - - cmdsToTest = append(cmdsToTest, cmd) - } - - // Add some 'two word' commands - would be nice to automatically - // calculate this list - somehow - cmdsToTest = append(cmdsToTest, "volume create") - cmdsToTest = append(cmdsToTest, "volume inspect") - cmdsToTest = append(cmdsToTest, "volume ls") - cmdsToTest = append(cmdsToTest, "volume rm") - cmdsToTest = append(cmdsToTest, "network connect") - cmdsToTest = append(cmdsToTest, "network create") - cmdsToTest = append(cmdsToTest, "network disconnect") - cmdsToTest = append(cmdsToTest, "network inspect") - cmdsToTest = append(cmdsToTest, "network ls") - cmdsToTest = append(cmdsToTest, "network rm") - - if testEnv.ExperimentalDaemon() { - cmdsToTest = append(cmdsToTest, "checkpoint create") - cmdsToTest = append(cmdsToTest, "checkpoint ls") - cmdsToTest = append(cmdsToTest, "checkpoint rm") - } - - // Divide the list of commands into go routines and run the func testcommand on the commands in parallel - // to save runtime of test - - errChan := make(chan error) - - for index := 0; index < len(cmdsToTest); index++ { - go func(index int) { - errChan <- testCommand(cmdsToTest[index], newEnvs, scanForHome, home) - }(index) - } - - for index := 0; index < len(cmdsToTest); index++ { - err := <-errChan - if err != nil { - c.Fatal(err) - } - } - } -} - -func (s *DockerSuite) TestHelpExitCodesHelpOutput(c *check.C) { - // Test to make sure the exit code and output (stdout vs stderr) of - // various good and bad cases are what we expect - - // docker : stdout=all, stderr=empty, rc=0 - out := cli.DockerCmd(c).Combined() - // Be really pick - c.Assert(out, checker.Not(checker.HasSuffix), "\n\n", check.Commentf("Should not have a blank line at the end of 'docker'\n")) - - // docker help: stdout=all, stderr=empty, rc=0 - out = cli.DockerCmd(c, "help").Combined() - // Be really pick - c.Assert(out, checker.Not(checker.HasSuffix), "\n\n", check.Commentf("Should not have a blank line at the end of 'docker help'\n")) - - // docker --help: stdout=all, stderr=empty, rc=0 - out = cli.DockerCmd(c, "--help").Combined() - // Be really pick - c.Assert(out, checker.Not(checker.HasSuffix), "\n\n", check.Commentf("Should not have a blank line at the end of 'docker --help'\n")) - - // docker inspect busybox: stdout=all, stderr=empty, rc=0 - // Just making sure stderr is empty on valid cmd - out = cli.DockerCmd(c, "inspect", "busybox").Combined() - // Be really pick - c.Assert(out, checker.Not(checker.HasSuffix), "\n\n", check.Commentf("Should not have a blank line at the end of 'docker inspect busyBox'\n")) - - // docker rm: stdout=empty, stderr=all, rc!=0 - // testing the min arg error msg - cli.Docker(cli.Args("rm")).Assert(c, icmd.Expected{ - ExitCode: 1, - Error: "exit status 1", - Out: "", - // Should not contain full help text but should contain info about - // # of args and Usage line - Err: "requires at least 1 argument", - }) - - // docker rm NoSuchContainer: stdout=empty, stderr=all, rc=0 - // testing to make sure no blank line on error - result := cli.Docker(cli.Args("rm", "NoSuchContainer")).Assert(c, icmd.Expected{ - ExitCode: 1, - Error: "exit status 1", - Out: "", - }) - // Be really picky - c.Assert(len(result.Stderr()), checker.Not(checker.Equals), 0) - c.Assert(result.Stderr(), checker.Not(checker.HasSuffix), "\n\n", check.Commentf("Should not have a blank line at the end of 'docker rm'\n")) - - // docker BadCmd: stdout=empty, stderr=all, rc=0 - cli.Docker(cli.Args("BadCmd")).Assert(c, icmd.Expected{ - ExitCode: 1, - Error: "exit status 1", - Out: "", - Err: "docker: 'BadCmd' is not a docker command.\nSee 'docker --help'\n", - }) -} - -func testCommand(cmd string, newEnvs []string, scanForHome bool, home string) error { - - args := strings.Split(cmd+" --help", " ") - - // Check the full usage text - result := icmd.RunCmd(icmd.Cmd{ - Command: append([]string{dockerBinary}, args...), - Env: newEnvs, - }) - err := result.Error - out := result.Stdout() - stderr := result.Stderr() - if len(stderr) != 0 { - return fmt.Errorf("Error on %q help. non-empty stderr:%q\n", cmd, stderr) - } - if strings.HasSuffix(out, "\n\n") { - return fmt.Errorf("Should not have blank line on %q\n", cmd) - } - if !strings.Contains(out, "--help") { - return fmt.Errorf("All commands should mention '--help'. Command '%v' did not.\n", cmd) - } - - if err != nil { - return fmt.Errorf(out) - } - - // Check each line for lots of stuff - lines := strings.Split(out, "\n") - for _, line := range lines { - i := strings.Index(line, "~") - if i >= 0 && i != len(line)-1 && line[i+1] != '/' { - return fmt.Errorf("Help for %q should not have used ~:\n%s", cmd, line) - } - - // Options should NOT end with a period - if strings.HasPrefix(line, " -") && strings.HasSuffix(line, ".") { - return fmt.Errorf("Help for %q should not end with a period: %s", cmd, line) - } - - // Options should NOT end with a space - if strings.HasSuffix(line, " ") { - return fmt.Errorf("Help for %q should not end with a space: %s", cmd, line) - } - - } - - // For each command make sure we generate an error - // if we give a bad arg - args = strings.Split(cmd+" --badArg", " ") - - out, _, err = dockerCmdWithError(args...) - if err == nil { - return fmt.Errorf(out) - } - - // Be really picky - if strings.HasSuffix(stderr, "\n\n") { - return fmt.Errorf("Should not have a blank line at the end of 'docker rm'\n") - } - - // Now make sure that each command will print a short-usage - // (not a full usage - meaning no opts section) if we - // are missing a required arg or pass in a bad arg - - // These commands will never print a short-usage so don't test - noShortUsage := map[string]string{ - "images": "", - "login": "", - "logout": "", - "network": "", - "stats": "", - "volume create": "", - } - - if _, ok := noShortUsage[cmd]; !ok { - // skipNoArgs are ones that we don't want to try w/o - // any args. Either because it'll hang the test or - // lead to incorrect test result (like false negative). - // Whatever the reason, skip trying to run w/o args and - // jump to trying with a bogus arg. - skipNoArgs := map[string]struct{}{ - "daemon": {}, - "events": {}, - "load": {}, - } - - var result *icmd.Result - if _, ok := skipNoArgs[cmd]; !ok { - result = dockerCmdWithResult(strings.Split(cmd, " ")...) - } - - // If its ok w/o any args then try again with an arg - if result == nil || result.ExitCode == 0 { - result = dockerCmdWithResult(strings.Split(cmd+" badArg", " ")...) - } - - if err := result.Compare(icmd.Expected{ - Out: icmd.None, - Err: "\nUsage:", - ExitCode: 1, - }); err != nil { - return err - } - - stderr := result.Stderr() - // Shouldn't have full usage - if strings.Contains(stderr, "--help=false") { - return fmt.Errorf("Should not have full usage on %q:%v", result.Cmd.Args, stderr) - } - if strings.HasSuffix(stderr, "\n\n") { - return fmt.Errorf("Should not have a blank line on %q\n%v", result.Cmd.Args, stderr) - } - } - - return nil -} diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_images_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_images_test.go index dccbe1262..2a1152eb5 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_images_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_images_test.go @@ -13,8 +13,8 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli/build" "github.com/docker/docker/pkg/stringid" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) func (s *DockerSuite) TestImagesEnsureImageIsListed(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_import_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_import_test.go index 711f39b87..eb0fe2cf8 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_import_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_import_test.go @@ -11,9 +11,8 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" - "github.com/docker/docker/pkg/testutil" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) func (s *DockerSuite) TestImportDisplay(c *check.C) { @@ -21,7 +20,7 @@ func (s *DockerSuite) TestImportDisplay(c *check.C) { out, _ := dockerCmd(c, "run", "-d", "busybox", "true") cleanedContainerID := strings.TrimSpace(out) - out, _, err := testutil.RunCommandPipelineWithOutput( + out, err := RunCommandPipelineWithOutput( exec.Command(dockerBinary, "export", cleanedContainerID), exec.Command(dockerBinary, "import", "-"), ) @@ -139,5 +138,5 @@ func (s *DockerSuite) TestImportWithQuotedChanges(c *check.C) { image := strings.TrimSpace(result.Stdout()) result = cli.DockerCmd(c, "run", "--rm", image, "true") - c.Assert(result, icmd.Matches, icmd.Expected{Out: icmd.None}) + result.Assert(c, icmd.Expected{Out: icmd.None}) } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_info_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_info_test.go index d75974dfc..b6f867373 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_info_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_info_test.go @@ -135,42 +135,48 @@ func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) { func (s *DockerSuite) TestInfoDisplaysRunningContainers(c *check.C) { testRequires(c, DaemonIsLinux) + existing := existingContainerStates(c) + dockerCmd(c, "run", "-d", "busybox", "top") out, _ := dockerCmd(c, "info") - c.Assert(out, checker.Contains, fmt.Sprintf("Containers: %d\n", 1)) - c.Assert(out, checker.Contains, fmt.Sprintf(" Running: %d\n", 1)) - c.Assert(out, checker.Contains, fmt.Sprintf(" Paused: %d\n", 0)) - c.Assert(out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", 0)) + c.Assert(out, checker.Contains, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1)) + c.Assert(out, checker.Contains, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"]+1)) + c.Assert(out, checker.Contains, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"])) + c.Assert(out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"])) } func (s *DockerSuite) TestInfoDisplaysPausedContainers(c *check.C) { testRequires(c, IsPausable) + existing := existingContainerStates(c) + out := runSleepingContainer(c, "-d") cleanedContainerID := strings.TrimSpace(out) dockerCmd(c, "pause", cleanedContainerID) out, _ = dockerCmd(c, "info") - c.Assert(out, checker.Contains, fmt.Sprintf("Containers: %d\n", 1)) - c.Assert(out, checker.Contains, fmt.Sprintf(" Running: %d\n", 0)) - c.Assert(out, checker.Contains, fmt.Sprintf(" Paused: %d\n", 1)) - c.Assert(out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", 0)) + c.Assert(out, checker.Contains, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1)) + c.Assert(out, checker.Contains, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"])) + c.Assert(out, checker.Contains, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"]+1)) + c.Assert(out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"])) } func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *check.C) { testRequires(c, DaemonIsLinux) + existing := existingContainerStates(c) + out, _ := dockerCmd(c, "run", "-d", "busybox", "top") cleanedContainerID := strings.TrimSpace(out) dockerCmd(c, "stop", cleanedContainerID) out, _ = dockerCmd(c, "info") - c.Assert(out, checker.Contains, fmt.Sprintf("Containers: %d\n", 1)) - c.Assert(out, checker.Contains, fmt.Sprintf(" Running: %d\n", 0)) - c.Assert(out, checker.Contains, fmt.Sprintf(" Paused: %d\n", 0)) - c.Assert(out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", 1)) + c.Assert(out, checker.Contains, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1)) + c.Assert(out, checker.Contains, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"])) + c.Assert(out, checker.Contains, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"])) + c.Assert(out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]+1)) } func (s *DockerSuite) TestInfoDebug(c *check.C) { @@ -237,3 +243,16 @@ func (s *DockerDaemonSuite) TestInfoLabels(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(out, checker.Contains, "WARNING: labels with duplicate keys and conflicting values have been deprecated") } + +func existingContainerStates(c *check.C) map[string]int { + out, _ := dockerCmd(c, "info", "--format", "{{json .}}") + var m map[string]interface{} + err := json.Unmarshal([]byte(out), &m) + c.Assert(err, checker.IsNil) + res := map[string]int{} + res["Containers"] = int(m["Containers"].(float64)) + res["ContainersRunning"] = int(m["ContainersRunning"].(float64)) + res["ContainersPaused"] = int(m["ContainersPaused"].(float64)) + res["ContainersStopped"] = int(m["ContainersStopped"].(float64)) + return res +} diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_inspect_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_inspect_test.go index 96e2ee451..13eb2d38a 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_inspect_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_inspect_test.go @@ -11,8 +11,8 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/integration-cli/checker" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) func checkValidGraphDriver(c *check.C, name string) { @@ -463,6 +463,5 @@ func (s *DockerSuite) TestInspectInvalidReference(c *check.C) { // This test should work on both Windows and Linux out, _, err := dockerCmdWithError("inspect", "FooBar") c.Assert(err, checker.NotNil) - c.Assert(out, checker.Contains, "Error: No such object: FooBar") - c.Assert(err.Error(), checker.Contains, "Error: No such object: FooBar") + c.Assert(out, checker.Contains, "no such image: FooBar") } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_kill_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_kill_test.go index 3273ecf1f..0a5aac5f8 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_kill_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_kill_test.go @@ -1,16 +1,15 @@ package main import ( - "fmt" - "net/http" "strings" "time" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/request" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" + "golang.org/x/net/context" ) func (s *DockerSuite) TestKillContainer(c *check.C) { @@ -131,8 +130,9 @@ func (s *DockerSuite) TestKillStoppedContainerAPIPre120(c *check.C) { testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later runSleepingContainer(c, "--name", "docker-kill-test-api", "-d") dockerCmd(c, "stop", "docker-kill-test-api") - - status, _, err := request.SockRequest("POST", fmt.Sprintf("/v1.19/containers/%s/kill", "docker-kill-test-api"), nil, daemonHost()) + cli, err := request.NewEnvClientWithVersion("v1.19") + c.Assert(err, check.IsNil) + defer cli.Close() + err = cli.ContainerKill(context.Background(), "docker-kill-test-api", "SIGKILL") c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusNoContent) } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_links_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_links_test.go index b43c6d1fb..0b4f30cfe 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_links_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_links_test.go @@ -4,10 +4,10 @@ import ( "encoding/json" "fmt" "regexp" + "sort" "strings" "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/pkg/testutil" "github.com/docker/docker/runconfig" "github.com/go-check/check" ) @@ -28,7 +28,7 @@ func (s *DockerSuite) TestLinksInvalidContainerTarget(c *check.C) { // an invalid container target should produce an error c.Assert(err, checker.NotNil, check.Commentf("out: %s", out)) // an invalid container target should produce an error - c.Assert(out, checker.Contains, "Could not get container") + c.Assert(out, checker.Contains, "could not get container") } func (s *DockerSuite) TestLinksPingLinkedContainers(c *check.C) { @@ -90,40 +90,41 @@ func (s *DockerSuite) TestLinksPingLinkedContainersAfterRename(c *check.C) { func (s *DockerSuite) TestLinksInspectLinksStarted(c *check.C) { testRequires(c, DaemonIsLinux) - var ( - expected = map[string]struct{}{"/container1:/testinspectlink/alias1": {}, "/container2:/testinspectlink/alias2": {}} - result []string - ) dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "container2", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "testinspectlink", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "top") links := inspectFieldJSON(c, "testinspectlink", "HostConfig.Links") + var result []string err := json.Unmarshal([]byte(links), &result) c.Assert(err, checker.IsNil) - output := testutil.ConvertSliceOfStringsToMap(result) - - c.Assert(output, checker.DeepEquals, expected) + var expected = []string{ + "/container1:/testinspectlink/alias1", + "/container2:/testinspectlink/alias2", + } + sort.Strings(result) + c.Assert(result, checker.DeepEquals, expected) } func (s *DockerSuite) TestLinksInspectLinksStopped(c *check.C) { testRequires(c, DaemonIsLinux) - var ( - expected = map[string]struct{}{"/container1:/testinspectlink/alias1": {}, "/container2:/testinspectlink/alias2": {}} - result []string - ) + dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "container2", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "testinspectlink", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "true") links := inspectFieldJSON(c, "testinspectlink", "HostConfig.Links") + var result []string err := json.Unmarshal([]byte(links), &result) c.Assert(err, checker.IsNil) - output := testutil.ConvertSliceOfStringsToMap(result) - - c.Assert(output, checker.DeepEquals, expected) + var expected = []string{ + "/container1:/testinspectlink/alias1", + "/container2:/testinspectlink/alias2", + } + sort.Strings(result) + c.Assert(result, checker.DeepEquals, expected) } func (s *DockerSuite) TestLinksNotStartedParentNotFail(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_logs_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_logs_test.go index a8b8f9054..d9523bffc 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_logs_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_logs_test.go @@ -11,9 +11,8 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/pkg/jsonlog" - "github.com/docker/docker/pkg/testutil" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) // This used to work, it test a log of PageSize-1 (gh#4851) @@ -215,14 +214,15 @@ func (s *DockerSuite) TestLogsSinceFutureFollow(c *check.C) { func (s *DockerSuite) TestLogsFollowSlowStdoutConsumer(c *check.C) { // TODO Windows: Fix this test for TP5. testRequires(c, DaemonIsLinux) - out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", `usleep 600000;yes X | head -c 200000`) + expected := 150000 + out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", fmt.Sprintf("usleep 600000; yes X | head -c %d", expected)) id := strings.TrimSpace(out) stopSlowRead := make(chan bool) go func() { - exec.Command(dockerBinary, "wait", id).Run() + dockerCmd(c, "wait", id) stopSlowRead <- true }() @@ -232,18 +232,42 @@ func (s *DockerSuite) TestLogsFollowSlowStdoutConsumer(c *check.C) { c.Assert(logCmd.Start(), checker.IsNil) // First read slowly - bytes1, err := testutil.ConsumeWithSpeed(stdout, 10, 50*time.Millisecond, stopSlowRead) + bytes1, err := ConsumeWithSpeed(stdout, 10, 50*time.Millisecond, stopSlowRead) c.Assert(err, checker.IsNil) // After the container has finished we can continue reading fast - bytes2, err := testutil.ConsumeWithSpeed(stdout, 32*1024, 0, nil) + bytes2, err := ConsumeWithSpeed(stdout, 32*1024, 0, nil) c.Assert(err, checker.IsNil) + c.Assert(logCmd.Wait(), checker.IsNil) + actual := bytes1 + bytes2 - expected := 200000 c.Assert(actual, checker.Equals, expected) } +// ConsumeWithSpeed reads chunkSize bytes from reader before sleeping +// for interval duration. Returns total read bytes. Send true to the +// stop channel to return before reading to EOF on the reader. +func ConsumeWithSpeed(reader io.Reader, chunkSize int, interval time.Duration, stop chan bool) (n int, err error) { + buffer := make([]byte, chunkSize) + for { + var readBytes int + readBytes, err = reader.Read(buffer) + n += readBytes + if err != nil { + if err == io.EOF { + err = nil + } + return + } + select { + case <-stop: + return + case <-time.After(interval): + } + } +} + func (s *DockerSuite) TestLogsFollowGoroutinesWithStdout(c *check.C) { out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "while true; do echo hello; sleep 2; done") id := strings.TrimSpace(out) @@ -266,6 +290,7 @@ func (s *DockerSuite) TestLogsFollowGoroutinesWithStdout(c *check.C) { c.Assert(<-chErr, checker.IsNil) c.Assert(cmd.Process.Kill(), checker.IsNil) r.Close() + cmd.Wait() // NGoroutines is not updated right away, so we need to wait before failing c.Assert(waitForGoroutines(nroutines), checker.IsNil) } @@ -281,6 +306,7 @@ func (s *DockerSuite) TestLogsFollowGoroutinesNoOutput(c *check.C) { c.Assert(cmd.Start(), checker.IsNil) time.Sleep(200 * time.Millisecond) c.Assert(cmd.Process.Kill(), checker.IsNil) + cmd.Wait() // NGoroutines is not updated right away, so we need to wait before failing c.Assert(waitForGoroutines(nroutines), checker.IsNil) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_netmode_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_netmode_test.go index deb8f6916..abf1ff2cf 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_netmode_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_netmode_test.go @@ -1,6 +1,8 @@ package main import ( + "strings" + "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/runconfig" "github.com/go-check/check" @@ -47,7 +49,7 @@ func (s *DockerSuite) TestNetHostname(c *check.C) { c.Assert(out, checker.Contains, "Invalid network mode: invalid container format container:") out, _ = dockerCmdWithFail(c, "run", "--net=weird", "busybox", "ps") - c.Assert(out, checker.Contains, "network weird not found") + c.Assert(strings.ToLower(out), checker.Contains, "no such network") } func (s *DockerSuite) TestConflictContainerNetworkAndLinks(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_network_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_network_unix_test.go index 5685c7bd0..4762e3993 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_network_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_network_unix_test.go @@ -10,7 +10,6 @@ import ( "net/http" "net/http/httptest" "os" - "path/filepath" "strings" "time" @@ -20,7 +19,6 @@ import ( "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/pkg/stringid" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/docker/docker/runconfig" "github.com/docker/libnetwork/driverapi" remoteapi "github.com/docker/libnetwork/drivers/remote/api" @@ -28,6 +26,7 @@ import ( remoteipam "github.com/docker/libnetwork/ipams/remote/api" "github.com/docker/libnetwork/netlabel" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" "github.com/vishvananda/netlink" "golang.org/x/sys/unix" ) @@ -288,39 +287,6 @@ func (s *DockerNetworkSuite) TestDockerNetworkLsDefault(c *check.C) { } } -func (s *DockerSuite) TestNetworkLsFormat(c *check.C) { - testRequires(c, DaemonIsLinux) - out, _ := dockerCmd(c, "network", "ls", "--format", "{{.Name}}") - lines := strings.Split(strings.TrimSpace(string(out)), "\n") - - expected := []string{"bridge", "host", "none"} - var names []string - names = append(names, lines...) - c.Assert(expected, checker.DeepEquals, names, check.Commentf("Expected array with truncated names: %v, got: %v", expected, names)) -} - -func (s *DockerSuite) TestNetworkLsFormatDefaultFormat(c *check.C) { - testRequires(c, DaemonIsLinux) - - config := `{ - "networksFormat": "{{ .Name }} default" -}` - d, err := ioutil.TempDir("", "integration-cli-") - c.Assert(err, checker.IsNil) - defer os.RemoveAll(d) - - err = ioutil.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0644) - c.Assert(err, checker.IsNil) - - out, _ := dockerCmd(c, "--config", d, "network", "ls") - lines := strings.Split(strings.TrimSpace(string(out)), "\n") - - expected := []string{"bridge default", "host default", "none default"} - var names []string - names = append(names, lines...) - c.Assert(expected, checker.DeepEquals, names, check.Commentf("Expected array with truncated names: %v, got: %v", expected, names)) -} - func (s *DockerNetworkSuite) TestDockerNetworkCreatePredefined(c *check.C) { predefined := []string{"bridge", "host", "none", "default"} for _, net := range predefined { @@ -351,6 +317,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkRmPredefined(c *check.C) { } func (s *DockerNetworkSuite) TestDockerNetworkLsFilter(c *check.C) { + testRequires(c, OnlyDefaultNetworks) testNet := "testnet1" testLabel := "foo" testValue := "bar" @@ -482,7 +449,7 @@ func (s *DockerSuite) TestDockerNetworkInspectWithID(c *check.C) { func (s *DockerSuite) TestDockerInspectMultipleNetwork(c *check.C) { result := dockerCmdWithResult("network", "inspect", "host", "none") - c.Assert(result, icmd.Matches, icmd.Success) + result.Assert(c, icmd.Success) networkResources := []types.NetworkResource{} err := json.Unmarshal([]byte(result.Stdout()), &networkResources) @@ -494,7 +461,7 @@ func (s *DockerSuite) TestDockerInspectMultipleNetworksIncludingNonexistent(c *c // non-existent network was not at the beginning of the inspect list // This should print an error, return an exitCode 1 and print the host network result := dockerCmdWithResult("network", "inspect", "host", "nonexistent") - c.Assert(result, icmd.Matches, icmd.Expected{ + result.Assert(c, icmd.Expected{ ExitCode: 1, Err: "Error: No such network: nonexistent", Out: "host", @@ -508,7 +475,7 @@ func (s *DockerSuite) TestDockerInspectMultipleNetworksIncludingNonexistent(c *c // Only one non-existent network to inspect // Should print an error and return an exitCode, nothing else result = dockerCmdWithResult("network", "inspect", "nonexistent") - c.Assert(result, icmd.Matches, icmd.Expected{ + result.Assert(c, icmd.Expected{ ExitCode: 1, Err: "Error: No such network: nonexistent", Out: "[]", @@ -517,7 +484,7 @@ func (s *DockerSuite) TestDockerInspectMultipleNetworksIncludingNonexistent(c *c // non-existent network was at the beginning of the inspect list // Should not fail fast, and still print host network but print an error result = dockerCmdWithResult("network", "inspect", "nonexistent", "host") - c.Assert(result, icmd.Matches, icmd.Expected{ + result.Assert(c, icmd.Expected{ ExitCode: 1, Err: "Error: No such network: nonexistent", Out: "host", @@ -624,6 +591,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnect(c *check.C) { } func (s *DockerNetworkSuite) TestDockerNetworkIPAMMultipleNetworks(c *check.C) { + testRequires(c, SameHostDaemon) // test0 bridge network dockerCmd(c, "network", "create", "--subnet=192.168.0.0/16", "test1") assertNwIsAvailable(c, "test1") @@ -664,6 +632,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkIPAMMultipleNetworks(c *check.C) { } func (s *DockerNetworkSuite) TestDockerNetworkCustomIPAM(c *check.C) { + testRequires(c, SameHostDaemon) // Create a bridge network using custom ipam driver dockerCmd(c, "network", "create", "--ipam-driver", dummyIPAMDriver, "br0") assertNwIsAvailable(c, "br0") @@ -679,6 +648,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkCustomIPAM(c *check.C) { } func (s *DockerNetworkSuite) TestDockerNetworkIPAMOptions(c *check.C) { + testRequires(c, SameHostDaemon) // Create a bridge network using custom ipam driver and options dockerCmd(c, "network", "create", "--ipam-driver", dummyIPAMDriver, "--ipam-opt", "opt1=drv1", "--ipam-opt", "opt2=drv2", "br0") assertNwIsAvailable(c, "br0") @@ -691,6 +661,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkIPAMOptions(c *check.C) { } func (s *DockerNetworkSuite) TestDockerNetworkNullIPAMDriver(c *check.C) { + testRequires(c, SameHostDaemon) // Create a network with null ipam driver _, _, err := dockerCmdWithError("network", "create", "-d", dummyNetworkDriver, "--ipam-driver", "null", "test000") c.Assert(err, check.IsNil) @@ -796,6 +767,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkIPAMInvalidCombinations(c *check.C } func (s *DockerNetworkSuite) TestDockerNetworkDriverOptions(c *check.C) { + testRequires(c, SameHostDaemon) dockerCmd(c, "network", "create", "-d", dummyNetworkDriver, "-o", "opt1=drv1", "-o", "opt2=drv2", "testopt") assertNwIsAvailable(c, "testopt") gopts := remoteDriverNetworkRequest.Options[netlabel.GenericData] @@ -981,6 +953,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkLinkOnDefaultNetworkOnly(c *check. } func (s *DockerNetworkSuite) TestDockerNetworkOverlayPortMapping(c *check.C) { + testRequires(c, SameHostDaemon) // Verify exposed ports are present in ps output when running a container on // a network managed by a driver which does not provide the default gateway // for the container @@ -1007,7 +980,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkOverlayPortMapping(c *check.C) { } func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *check.C) { - testRequires(c, DaemonIsLinux, NotUserNamespace) + testRequires(c, DaemonIsLinux, NotUserNamespace, SameHostDaemon) dnd := "dnd" did := "did" @@ -1048,6 +1021,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *check.C } func (s *DockerNetworkSuite) TestDockerNetworkMacInspect(c *check.C) { + testRequires(c, SameHostDaemon) // Verify endpoint MAC address is correctly populated in container's network settings nwn := "ov" ctn := "bb" @@ -1113,6 +1087,7 @@ func verifyContainerIsConnectedToNetworks(c *check.C, d *daemon.Daemon, cName st } func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksGracefulDaemonRestart(c *check.C) { + testRequires(c, SameHostDaemon) cName := "bb" nwList := []string{"nw1", "nw2", "nw3"} @@ -1131,6 +1106,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksGracefulDaemonRest } func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksUngracefulDaemonRestart(c *check.C) { + testRequires(c, SameHostDaemon) cName := "cc" nwList := []string{"nw1", "nw2", "nw3"} @@ -1157,7 +1133,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkRunNetByID(c *check.C) { } func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c *check.C) { - testRequires(c, DaemonIsLinux, NotUserNamespace) + testRequires(c, DaemonIsLinux, NotUserNamespace, SameHostDaemon) s.d.StartWithBusybox(c) // Run a few containers on host network @@ -1283,6 +1259,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkRestartWithMultipleNetworks(c *che } func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectToStoppedContainer(c *check.C) { + testRequires(c, SameHostDaemon) dockerCmd(c, "network", "create", "test") dockerCmd(c, "create", "--name=foo", "busybox", "top") dockerCmd(c, "network", "connect", "test", "foo") @@ -1810,7 +1787,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromBridge(c *check.C) { // TestConntrackFlowsLeak covers the failure scenario of ticket: https://github.com/docker/docker/issues/8795 // Validates that conntrack is correctly cleaned once a container is destroyed func (s *DockerNetworkSuite) TestConntrackFlowsLeak(c *check.C) { - testRequires(c, IsAmd64, DaemonIsLinux, Network) + testRequires(c, IsAmd64, DaemonIsLinux, Network, SameHostDaemon) // Create a new network cli.DockerCmd(c, "network", "create", "--subnet=192.168.10.0/24", "--gateway=192.168.10.1", "-o", "com.docker.network.bridge.host_binding_ipv4=192.168.10.1", "testbind") diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_plugins_logdriver_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_plugins_logdriver_test.go index d74256656..8104b3b76 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_plugins_logdriver_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_plugins_logdriver_test.go @@ -1,14 +1,12 @@ package main import ( - "encoding/json" - "net/http" "strings" - "github.com/docker/docker/api/types" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/integration-cli/request" "github.com/go-check/check" + "golang.org/x/net/context" ) func (s *DockerSuite) TestPluginLogDriver(c *check.C) { @@ -36,13 +34,14 @@ func (s *DockerSuite) TestPluginLogDriverInfoList(c *check.C) { pluginName := "cpuguy83/docker-logdriver-test" dockerCmd(c, "plugin", "install", pluginName) - status, body, err := request.SockRequest("GET", "/info", nil, daemonHost()) - c.Assert(status, checker.Equals, http.StatusOK) + + cli, err := client.NewEnvClient() c.Assert(err, checker.IsNil) + defer cli.Close() - var info types.Info - err = json.Unmarshal(body, &info) + info, err := cli.Info(context.Background()) c.Assert(err, checker.IsNil) + drivers := strings.Join(info.Plugins.Log, " ") c.Assert(drivers, checker.Contains, "json-file") c.Assert(drivers, checker.Not(checker.Contains), pluginName) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_plugins_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_plugins_test.go index 38b4af8f1..13ae2b0eb 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_plugins_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_plugins_test.go @@ -16,8 +16,8 @@ import ( "github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/integration-cli/fixtures/plugin" "github.com/docker/docker/integration-cli/request" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" "golang.org/x/net/context" ) @@ -462,7 +462,7 @@ enabled: false`, id, name) } func (s *DockerSuite) TestPluginUpgrade(c *check.C) { - testRequires(c, DaemonIsLinux, Network, SameHostDaemon, IsAmd64) + testRequires(c, DaemonIsLinux, Network, SameHostDaemon, IsAmd64, NotUserNamespace) plugin := "cpuguy83/docker-volume-driver-plugin-local:latest" pluginV2 := "cpuguy83/docker-volume-driver-plugin-local:v2" diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_port_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_port_test.go index bcb87f5f3..84058cda1 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_port_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_port_test.go @@ -5,6 +5,7 @@ import ( "net" "regexp" "sort" + "strconv" "strings" "github.com/docker/docker/integration-cli/checker" @@ -148,9 +149,8 @@ func (s *DockerSuite) TestPortList(c *check.C) { out, _ = dockerCmd(c, "port", ID) - err = assertPortList(c, out, []string{ - "80/tcp -> 0.0.0.0:8000", - "80/udp -> 0.0.0.0:8000"}) + // Running this test multiple times causes the TCP port to increment. + err = assertPortRange(c, out, []int{8000, 8080}, []int{8000, 8080}) // Port list is not correct c.Assert(err, checker.IsNil) dockerCmd(c, "rm", "-f", ID) @@ -173,6 +173,38 @@ func assertPortList(c *check.C, out string, expected []string) error { return nil } +func assertPortRange(c *check.C, out string, expectedTcp, expectedUdp []int) error { + lines := strings.Split(strings.Trim(out, "\n "), "\n") + + var validTcp, validUdp bool + for _, l := range lines { + // 80/tcp -> 0.0.0.0:8015 + port, err := strconv.Atoi(strings.Split(l, ":")[1]) + if err != nil { + return err + } + if strings.Contains(l, "tcp") && expectedTcp != nil { + if port < expectedTcp[0] || port > expectedTcp[1] { + return fmt.Errorf("tcp port (%d) not in range expected range %d-%d", port, expectedTcp[0], expectedTcp[1]) + } + validTcp = true + } + if strings.Contains(l, "udp") && expectedUdp != nil { + if port < expectedUdp[0] || port > expectedUdp[1] { + return fmt.Errorf("udp port (%d) not in range expected range %d-%d", port, expectedUdp[0], expectedUdp[1]) + } + validUdp = true + } + } + if !validTcp { + return fmt.Errorf("tcp port not found") + } + if !validUdp { + return fmt.Errorf("udp port not found") + } + return nil +} + func stopRemoveContainer(id string, c *check.C) { dockerCmd(c, "rm", "-f", id) } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_proxy_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_proxy_test.go index 3344985a0..bdb477259 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_proxy_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_proxy_test.go @@ -5,8 +5,8 @@ import ( "strings" "github.com/docker/docker/integration-cli/checker" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) func (s *DockerSuite) TestCLIProxyDisableProxyUnixSock(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_prune_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_prune_unix_test.go index bea4f4fbd..edd3eab62 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_prune_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_prune_unix_test.go @@ -19,13 +19,21 @@ import ( func pruneNetworkAndVerify(c *check.C, d *daemon.Swarm, kept, pruned []string) { _, err := d.Cmd("network", "prune", "--force") c.Assert(err, checker.IsNil) - out, err := d.Cmd("network", "ls", "--format", "{{.Name}}") - c.Assert(err, checker.IsNil) + for _, s := range kept { - c.Assert(out, checker.Contains, s) + waitAndAssert(c, defaultReconciliationTimeout, func(*check.C) (interface{}, check.CommentInterface) { + out, err := d.Cmd("network", "ls", "--format", "{{.Name}}") + c.Assert(err, checker.IsNil) + return out, nil + }, checker.Contains, s) } + for _, s := range pruned { - c.Assert(out, checker.Not(checker.Contains), s) + waitAndAssert(c, defaultReconciliationTimeout, func(*check.C) (interface{}, check.CommentInterface) { + out, err := d.Cmd("network", "ls", "--format", "{{.Name}}") + c.Assert(err, checker.IsNil) + return out, nil + }, checker.Not(checker.Contains), s) } } @@ -64,6 +72,7 @@ func (s *DockerSwarmSuite) TestPruneNetwork(c *check.C) { _, err = d.Cmd("service", "rm", serviceName) c.Assert(err, checker.IsNil) waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 0) + pruneNetworkAndVerify(c, d, []string{}, []string{"n1", "n3"}) } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_ps_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_ps_test.go index 98a20f426..bea126120 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_ps_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_ps_test.go @@ -14,11 +14,13 @@ import ( "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" "github.com/docker/docker/pkg/stringid" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) func (s *DockerSuite) TestPsListContainersBase(c *check.C) { + existingContainers := ExistingContainerIDs(c) + out := runSleepingContainer(c, "-d") firstID := strings.TrimSpace(out) @@ -43,79 +45,79 @@ func (s *DockerSuite) TestPsListContainersBase(c *check.C) { // all out, _ = dockerCmd(c, "ps", "-a") - c.Assert(assertContainerList(out, []string{fourthID, thirdID, secondID, firstID}), checker.Equals, true, check.Commentf("ALL: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), []string{fourthID, thirdID, secondID, firstID}), checker.Equals, true, check.Commentf("ALL: Container list is not in the correct order: \n%s", out)) // running out, _ = dockerCmd(c, "ps") - c.Assert(assertContainerList(out, []string{fourthID, secondID, firstID}), checker.Equals, true, check.Commentf("RUNNING: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), []string{fourthID, secondID, firstID}), checker.Equals, true, check.Commentf("RUNNING: Container list is not in the correct order: \n%s", out)) // limit out, _ = dockerCmd(c, "ps", "-n=2", "-a") expected := []string{fourthID, thirdID} - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("LIMIT & ALL: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("LIMIT & ALL: Container list is not in the correct order: \n%s", out)) out, _ = dockerCmd(c, "ps", "-n=2") - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("LIMIT: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("LIMIT: Container list is not in the correct order: \n%s", out)) // filter since out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-a") expected = []string{fourthID, thirdID, secondID} - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE filter & ALL: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter & ALL: Container list is not in the correct order: \n%s", out)) out, _ = dockerCmd(c, "ps", "-f", "since="+firstID) expected = []string{fourthID, secondID} - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out)) out, _ = dockerCmd(c, "ps", "-f", "since="+thirdID) expected = []string{fourthID} - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out)) // filter before out, _ = dockerCmd(c, "ps", "-f", "before="+fourthID, "-a") expected = []string{thirdID, secondID, firstID} - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("BEFORE filter & ALL: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("BEFORE filter & ALL: Container list is not in the correct order: \n%s", out)) out, _ = dockerCmd(c, "ps", "-f", "before="+fourthID) expected = []string{secondID, firstID} - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("BEFORE filter: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("BEFORE filter: Container list is not in the correct order: \n%s", out)) out, _ = dockerCmd(c, "ps", "-f", "before="+thirdID) expected = []string{secondID, firstID} - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out)) // filter since & before out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-f", "before="+fourthID, "-a") expected = []string{thirdID, secondID} - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter & ALL: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter & ALL: Container list is not in the correct order: \n%s", out)) out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-f", "before="+fourthID) expected = []string{secondID} - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter: Container list is not in the correct order: \n%s", out)) // filter since & limit out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-n=2", "-a") expected = []string{fourthID, thirdID} - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out)) out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-n=2") - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE filter, LIMIT: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, LIMIT: Container list is not in the correct order: \n%s", out)) // filter before & limit out, _ = dockerCmd(c, "ps", "-f", "before="+fourthID, "-n=1", "-a") expected = []string{thirdID} - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("BEFORE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("BEFORE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out)) out, _ = dockerCmd(c, "ps", "-f", "before="+fourthID, "-n=1") - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("BEFORE filter, LIMIT: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("BEFORE filter, LIMIT: Container list is not in the correct order: \n%s", out)) // filter since & filter before & limit out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-f", "before="+fourthID, "-n=1", "-a") expected = []string{thirdID} - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out)) out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-f", "before="+fourthID, "-n=1") - c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter, LIMIT: Container list is not in the correct order: \n%s", out)) + c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter, LIMIT: Container list is not in the correct order: \n%s", out)) } @@ -185,6 +187,8 @@ func (s *DockerSuite) TestPsListContainersSize(c *check.C) { } func (s *DockerSuite) TestPsListContainersFilterStatus(c *check.C) { + existingContainers := ExistingContainerIDs(c) + // start exited container out := cli.DockerCmd(c, "run", "-d", "busybox").Combined() firstID := strings.TrimSpace(out) @@ -199,16 +203,16 @@ func (s *DockerSuite) TestPsListContainersFilterStatus(c *check.C) { // filter containers by exited out = cli.DockerCmd(c, "ps", "--no-trunc", "-q", "--filter=status=exited").Combined() containerOut := strings.TrimSpace(out) - c.Assert(containerOut, checker.Equals, firstID) + c.Assert(RemoveOutputForExistingElements(containerOut, existingContainers), checker.Equals, firstID) out = cli.DockerCmd(c, "ps", "-a", "--no-trunc", "-q", "--filter=status=running").Combined() containerOut = strings.TrimSpace(out) - c.Assert(containerOut, checker.Equals, secondID) + c.Assert(RemoveOutputForExistingElements(containerOut, existingContainers), checker.Equals, secondID) result := cli.Docker(cli.Args("ps", "-a", "-q", "--filter=status=rubbish"), cli.WithTimeout(time.Second*60)) - c.Assert(result, icmd.Matches, icmd.Expected{ + result.Assert(c, icmd.Expected{ ExitCode: 1, - Err: "Unrecognised filter value for status", + Err: "Invalid filter 'status=rubbish'", }) // Windows doesn't support pausing of containers @@ -222,11 +226,12 @@ func (s *DockerSuite) TestPsListContainersFilterStatus(c *check.C) { out = cli.DockerCmd(c, "ps", "--no-trunc", "-q", "--filter=status=paused").Combined() containerOut = strings.TrimSpace(out) - c.Assert(containerOut, checker.Equals, pausedID) + c.Assert(RemoveOutputForExistingElements(containerOut, existingContainers), checker.Equals, pausedID) } } func (s *DockerSuite) TestPsListContainersFilterHealth(c *check.C) { + existingContainers := ExistingContainerIDs(c) // Test legacy no health check out := runSleepingContainer(c, "--name=none_legacy") containerID := strings.TrimSpace(out) @@ -264,7 +269,7 @@ func (s *DockerSuite) TestPsListContainersFilterHealth(c *check.C) { waitForHealthStatus(c, "passing_container", "starting", "healthy") out = cli.DockerCmd(c, "ps", "-q", "--no-trunc", "--filter=health=healthy").Combined() - containerOut = strings.TrimSpace(out) + containerOut = strings.TrimSpace(RemoveOutputForExistingElements(out, existingContainers)) c.Assert(containerOut, checker.Equals, containerID, check.Commentf("Expected containerID %s, got %s for healthy filter, output: %q", containerID, containerOut, out)) } @@ -305,6 +310,8 @@ func (s *DockerSuite) TestPsListContainersFilterName(c *check.C) { // - Run containers for each of those image (busybox, images_ps_filter_test1, images_ps_filter_test2) // - Filter them out :P func (s *DockerSuite) TestPsListContainersFilterAncestorImage(c *check.C) { + existingContainers := ExistingContainerIDs(c) + // Build images imageName1 := "images_ps_filter_test1" buildImageSuccessfully(c, imageName1, build.WithDockerfile(`FROM busybox @@ -367,12 +374,12 @@ func (s *DockerSuite) TestPsListContainersFilterAncestorImage(c *check.C) { var out string for _, filter := range filterTestSuite { out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=ancestor="+filter.filterName) - checkPsAncestorFilterOutput(c, out, filter.filterName, filter.expectedIDs) + checkPsAncestorFilterOutput(c, RemoveOutputForExistingElements(out, existingContainers), filter.filterName, filter.expectedIDs) } // Multiple ancestor filter out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=ancestor="+imageName2, "--filter=ancestor="+imageName1Tagged) - checkPsAncestorFilterOutput(c, out, imageName2+","+imageName1Tagged, []string{fourthID, fifthID}) + checkPsAncestorFilterOutput(c, RemoveOutputForExistingElements(out, existingContainers), imageName2+","+imageName1Tagged, []string{fourthID, fifthID}) } func checkPsAncestorFilterOutput(c *check.C, out string, filterName string, expectedIDs []string) { @@ -469,6 +476,9 @@ func (s *DockerSuite) TestPsListContainersFilterExited(c *check.C) { func (s *DockerSuite) TestPsRightTagName(c *check.C) { // TODO Investigate further why this fails on Windows to Windows CI testRequires(c, DaemonIsLinux) + + existingContainers := ExistingContainerNames(c) + tag := "asybox:shmatest" dockerCmd(c, "tag", "busybox", tag) @@ -490,6 +500,7 @@ func (s *DockerSuite) TestPsRightTagName(c *check.C) { out, _ = dockerCmd(c, "ps", "--no-trunc") lines := strings.Split(strings.TrimSpace(string(out)), "\n") + lines = RemoveLinesForExistingElements(lines, existingContainers) // skip header lines = lines[1:] c.Assert(lines, checker.HasLen, 3, check.Commentf("There should be 3 running container, got %d", len(lines))) @@ -511,6 +522,7 @@ func (s *DockerSuite) TestPsRightTagName(c *check.C) { func (s *DockerSuite) TestPsLinkedWithNoTrunc(c *check.C) { // Problematic on Windows as it doesn't support links as of Jan 2016 testRequires(c, DaemonIsLinux) + existingContainers := ExistingContainerIDs(c) runSleepingContainer(c, "--name=first") runSleepingContainer(c, "--name=second", "--link=first:first") @@ -518,6 +530,7 @@ func (s *DockerSuite) TestPsLinkedWithNoTrunc(c *check.C) { lines := strings.Split(strings.TrimSpace(string(out)), "\n") // strip header lines = lines[1:] + lines = RemoveLinesForExistingElements(lines, existingContainers) expected := []string{"second", "first,second/first"} var names []string for _, l := range lines { @@ -581,12 +594,14 @@ func (s *DockerSuite) TestPsListContainersFilterCreated(c *check.C) { func (s *DockerSuite) TestPsFormatMultiNames(c *check.C) { // Problematic on Windows as it doesn't support link as of Jan 2016 testRequires(c, DaemonIsLinux) + existingContainers := ExistingContainerNames(c) //create 2 containers and link them dockerCmd(c, "run", "--name=child", "-d", "busybox", "top") dockerCmd(c, "run", "--name=parent", "--link=child:linkedone", "-d", "busybox", "top") //use the new format capabilities to only list the names and --no-trunc to get all names out, _ := dockerCmd(c, "ps", "--format", "{{.Names}}", "--no-trunc") + out = RemoveOutputForExistingElements(out, existingContainers) lines := strings.Split(strings.TrimSpace(string(out)), "\n") expected := []string{"parent", "child,parent/linkedone"} var names []string @@ -595,6 +610,7 @@ func (s *DockerSuite) TestPsFormatMultiNames(c *check.C) { //now list without turning off truncation and make sure we only get the non-link names out, _ = dockerCmd(c, "ps", "--format", "{{.Names}}") + out = RemoveOutputForExistingElements(out, existingContainers) lines = strings.Split(strings.TrimSpace(string(out)), "\n") expected = []string{"parent", "child"} var truncNames []string @@ -604,30 +620,22 @@ func (s *DockerSuite) TestPsFormatMultiNames(c *check.C) { // Test for GitHub issue #21772 func (s *DockerSuite) TestPsNamesMultipleTime(c *check.C) { + existingContainers := ExistingContainerNames(c) runSleepingContainer(c, "--name=test1") runSleepingContainer(c, "--name=test2") //use the new format capabilities to list the names twice out, _ := dockerCmd(c, "ps", "--format", "{{.Names}} {{.Names}}") lines := strings.Split(strings.TrimSpace(string(out)), "\n") + lines = RemoveLinesForExistingElements(lines, existingContainers) expected := []string{"test2 test2", "test1 test1"} var names []string names = append(names, lines...) c.Assert(expected, checker.DeepEquals, names, check.Commentf("Expected array with names displayed twice: %v, got: %v", expected, names)) } -func (s *DockerSuite) TestPsFormatHeaders(c *check.C) { - // make sure no-container "docker ps" still prints the header row - out, _ := dockerCmd(c, "ps", "--format", "table {{.ID}}") - c.Assert(out, checker.Equals, "CONTAINER ID\n", check.Commentf(`Expected 'CONTAINER ID\n', got %v`, out)) - - // verify that "docker ps" with a container still prints the header row also - runSleepingContainer(c, "--name=test") - out, _ = dockerCmd(c, "ps", "--format", "table {{.Names}}") - c.Assert(out, checker.Equals, "NAMES\ntest\n", check.Commentf(`Expected 'NAMES\ntest\n', got %v`, out)) -} - func (s *DockerSuite) TestPsDefaultFormatAndQuiet(c *check.C) { + existingContainers := ExistingContainerIDs(c) config := `{ "psFormat": "default {{ .ID }}" }` @@ -642,6 +650,7 @@ func (s *DockerSuite) TestPsDefaultFormatAndQuiet(c *check.C) { id := strings.TrimSpace(out) out, _ = dockerCmd(c, "--config", d, "ps", "-q") + out = RemoveOutputForExistingElements(out, existingContainers) c.Assert(id, checker.HasPrefix, strings.TrimSpace(out), check.Commentf("Expected to print only the container id, got %v\n", out)) } @@ -652,6 +661,8 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *check.C) { originalImageName := "busybox:TestPsImageIDAfterUpdate-original" updatedImageName := "busybox:TestPsImageIDAfterUpdate-updated" + existingContainers := ExistingContainerIDs(c) + icmd.RunCommand(dockerBinary, "tag", "busybox:latest", originalImageName).Assert(c, icmd.Success) originalImageID := getIDByName(c, originalImageName) @@ -664,6 +675,7 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *check.C) { result.Assert(c, icmd.Success) lines := strings.Split(strings.TrimSpace(string(result.Combined())), "\n") + lines = RemoveLinesForExistingElements(lines, existingContainers) // skip header lines = lines[1:] c.Assert(len(lines), checker.Equals, 1) @@ -680,6 +692,7 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *check.C) { result.Assert(c, icmd.Success) lines = strings.Split(strings.TrimSpace(string(result.Combined())), "\n") + lines = RemoveLinesForExistingElements(lines, existingContainers) // skip header lines = lines[1:] c.Assert(len(lines), checker.Equals, 1) @@ -710,6 +723,8 @@ func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *check.C) { } func (s *DockerSuite) TestPsShowMounts(c *check.C) { + existingContainers := ExistingContainerNames(c) + prefix, slash := getPrefixAndSlashFromDaemonPlatform() mp := prefix + slash + "test" @@ -736,6 +751,7 @@ func (s *DockerSuite) TestPsShowMounts(c *check.C) { out, _ := dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}") lines := strings.Split(strings.TrimSpace(string(out)), "\n") + lines = RemoveLinesForExistingElements(lines, existingContainers) c.Assert(lines, checker.HasLen, 3) fields := strings.Fields(lines[0]) @@ -755,6 +771,7 @@ func (s *DockerSuite) TestPsShowMounts(c *check.C) { out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume=ps-volume-test") lines = strings.Split(strings.TrimSpace(string(out)), "\n") + lines = RemoveLinesForExistingElements(lines, existingContainers) c.Assert(lines, checker.HasLen, 1) fields = strings.Fields(lines[0]) @@ -768,6 +785,7 @@ func (s *DockerSuite) TestPsShowMounts(c *check.C) { out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+mp) lines = strings.Split(strings.TrimSpace(string(out)), "\n") + lines = RemoveLinesForExistingElements(lines, existingContainers) c.Assert(lines, checker.HasLen, 2) fields = strings.Fields(lines[0]) @@ -779,6 +797,7 @@ func (s *DockerSuite) TestPsShowMounts(c *check.C) { out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountSource) lines = strings.Split(strings.TrimSpace(string(out)), "\n") + lines = RemoveLinesForExistingElements(lines, existingContainers) c.Assert(lines, checker.HasLen, 1) fields = strings.Fields(lines[0]) @@ -790,6 +809,7 @@ func (s *DockerSuite) TestPsShowMounts(c *check.C) { out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountDestination) lines = strings.Split(strings.TrimSpace(string(out)), "\n") + lines = RemoveLinesForExistingElements(lines, existingContainers) c.Assert(lines, checker.HasLen, 1) fields = strings.Fields(lines[0]) @@ -820,6 +840,8 @@ func (s *DockerSuite) TestPsFormatSize(c *check.C) { } func (s *DockerSuite) TestPsListContainersFilterNetwork(c *check.C) { + existing := ExistingContainerIDs(c) + // TODO default network on Windows is not called "bridge", and creating a // custom network fails on Windows fails with "Error response from daemon: plugin not found") testRequires(c, DaemonIsLinux) @@ -837,7 +859,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *check.C) { lines = lines[1:] // ps output should have no containers - c.Assert(lines, checker.HasLen, 0) + c.Assert(RemoveLinesForExistingElements(lines, existing), checker.HasLen, 0) // Filter docker ps on network bridge out, _ = dockerCmd(c, "ps", "--filter", "network=bridge") @@ -849,7 +871,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *check.C) { lines = lines[1:] // ps output should have only one container - c.Assert(lines, checker.HasLen, 1) + c.Assert(RemoveLinesForExistingElements(lines, existing), checker.HasLen, 1) // Making sure onbridgenetwork is on the output c.Assert(containerOut, checker.Contains, "onbridgenetwork", check.Commentf("Missing the container on network\n")) @@ -864,7 +886,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *check.C) { lines = lines[1:] //ps output should have both the containers - c.Assert(lines, checker.HasLen, 2) + c.Assert(RemoveLinesForExistingElements(lines, existing), checker.HasLen, 2) // Making sure onbridgenetwork and onnonenetwork is on the output c.Assert(containerOut, checker.Contains, "onnonenetwork", check.Commentf("Missing the container on none network\n")) @@ -885,11 +907,12 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *check.C) { containerOut = strings.TrimSpace(string(out)) lines = strings.Split(containerOut, "\n") + // skip header lines = lines[1:] // ps output should have only one container - c.Assert(lines, checker.HasLen, 1) + c.Assert(RemoveLinesForExistingElements(lines, existing), checker.HasLen, 1) // Making sure onbridgenetwork is on the output c.Assert(containerOut, checker.Contains, "onbridgenetwork", check.Commentf("Missing the container on network\n")) @@ -927,13 +950,16 @@ func (s *DockerSuite) TestPsFilterMissingArgErrorCode(c *check.C) { // Test case for 30291 func (s *DockerSuite) TestPsFormatTemplateWithArg(c *check.C) { + existingContainers := ExistingContainerNames(c) runSleepingContainer(c, "-d", "--name", "top", "--label", "some.label=label.foo-bar") out, _ := dockerCmd(c, "ps", "--format", `{{.Names}} {{.Label "some.label"}}`) + out = RemoveOutputForExistingElements(out, existingContainers) c.Assert(strings.TrimSpace(out), checker.Equals, "top label.foo-bar") } func (s *DockerSuite) TestPsListContainersFilterPorts(c *check.C) { testRequires(c, DaemonIsLinux) + existingContainers := ExistingContainerIDs(c) out, _ := dockerCmd(c, "run", "-d", "--publish=80", "busybox", "top") id1 := strings.TrimSpace(out) @@ -962,6 +988,30 @@ func (s *DockerSuite) TestPsListContainersFilterPorts(c *check.C) { c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), id2) out, _ = dockerCmd(c, "ps", "--no-trunc", "-q", "--filter", "expose=8080/tcp") + out = RemoveOutputForExistingElements(out, existingContainers) c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), id1) c.Assert(strings.TrimSpace(out), checker.Equals, id2) } + +func (s *DockerSuite) TestPsNotShowLinknamesOfDeletedContainer(c *check.C) { + testRequires(c, DaemonIsLinux) + + existingContainers := ExistingContainerNames(c) + + dockerCmd(c, "create", "--name=aaa", "busybox", "top") + dockerCmd(c, "create", "--name=bbb", "--link=aaa", "busybox", "top") + + out, _ := dockerCmd(c, "ps", "--no-trunc", "-a", "--format", "{{.Names}}") + lines := strings.Split(strings.TrimSpace(string(out)), "\n") + lines = RemoveLinesForExistingElements(lines, existingContainers) + expected := []string{"bbb", "aaa,bbb/aaa"} + var names []string + names = append(names, lines...) + c.Assert(expected, checker.DeepEquals, names, check.Commentf("Expected array with non-truncated names: %v, got: %v", expected, names)) + + dockerCmd(c, "rm", "bbb") + + out, _ = dockerCmd(c, "ps", "--no-trunc", "-a", "--format", "{{.Names}}") + out = RemoveOutputForExistingElements(out, existingContainers) + c.Assert(strings.TrimSpace(out), checker.Equals, "aaa") +} diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_pull_local_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_pull_local_test.go index a45e31359..79b9390d2 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_pull_local_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_pull_local_test.go @@ -15,8 +15,8 @@ import ( "github.com/docker/distribution/manifest/schema2" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli/build" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" "github.com/opencontainers/go-digest" ) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_pull_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_pull_test.go index fd91edb81..56e518b17 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_pull_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_pull_test.go @@ -193,25 +193,26 @@ func (s *DockerHubPullSuite) TestPullScratchNotAllowed(c *check.C) { // results in more images than a naked pull. func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *check.C) { testRequires(c, DaemonIsLinux) - s.Cmd(c, "pull", "busybox") - outImageCmd := s.Cmd(c, "images", "busybox") + s.Cmd(c, "pull", "dockercore/engine-pull-all-test-fixture") + outImageCmd := s.Cmd(c, "images", "dockercore/engine-pull-all-test-fixture") splitOutImageCmd := strings.Split(strings.TrimSpace(outImageCmd), "\n") c.Assert(splitOutImageCmd, checker.HasLen, 2) - s.Cmd(c, "pull", "--all-tags=true", "busybox") - outImageAllTagCmd := s.Cmd(c, "images", "busybox") + s.Cmd(c, "pull", "--all-tags=true", "dockercore/engine-pull-all-test-fixture") + outImageAllTagCmd := s.Cmd(c, "images", "dockercore/engine-pull-all-test-fixture") linesCount := strings.Count(outImageAllTagCmd, "\n") c.Assert(linesCount, checker.GreaterThan, 2, check.Commentf("pulling all tags should provide more than two images, got %s", outImageAllTagCmd)) - // Verify that the line for 'busybox:latest' is left unchanged. + // Verify that the line for 'dockercore/engine-pull-all-test-fixture:latest' is left unchanged. var latestLine string for _, line := range strings.Split(outImageAllTagCmd, "\n") { - if strings.HasPrefix(line, "busybox") && strings.Contains(line, "latest") { + if strings.HasPrefix(line, "dockercore/engine-pull-all-test-fixture") && strings.Contains(line, "latest") { latestLine = line break } } - c.Assert(latestLine, checker.Not(checker.Equals), "", check.Commentf("no entry for busybox:latest found after pulling all tags")) + c.Assert(latestLine, checker.Not(checker.Equals), "", check.Commentf("no entry for dockercore/engine-pull-all-test-fixture:latest found after pulling all tags")) + splitLatest := strings.Fields(latestLine) splitCurrent := strings.Fields(splitOutImageCmd[1]) @@ -227,7 +228,7 @@ func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *check.C) { splitCurrent[4] = "" splitCurrent[5] = "" - c.Assert(splitLatest, checker.DeepEquals, splitCurrent, check.Commentf("busybox:latest was changed after pulling all tags")) + c.Assert(splitLatest, checker.DeepEquals, splitCurrent, check.Commentf("dockercore/engine-pull-all-test-fixture:latest was changed after pulling all tags")) } // TestPullClientDisconnect kills the client during a pull operation and verifies that the operation @@ -273,7 +274,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullNoCredentialsNotFound(c *check func (s *DockerSuite) TestPullLinuxImageFailsOnWindows(c *check.C) { testRequires(c, DaemonIsWindows, Network) _, _, err := dockerCmdWithError("pull", "ubuntu") - c.Assert(err.Error(), checker.Contains, "cannot be used on this platform") + c.Assert(err.Error(), checker.Contains, "no matching manifest") } // Regression test for https://github.com/docker/docker/issues/28892 diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_pull_trusted_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_pull_trusted_test.go index d9628d971..60e1c3db1 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_pull_trusted_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_pull_trusted_test.go @@ -7,8 +7,8 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) func (s *DockerTrustSuite) TestTrustedPull(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_push_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_push_test.go index 2ae206df7..94efa08ea 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_push_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_push_test.go @@ -16,8 +16,8 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) // Pushing an image to a private registry. diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_rename_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_rename_test.go index ea430227d..de277596f 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_rename_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_rename_test.go @@ -5,8 +5,8 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/pkg/stringid" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) func (s *DockerSuite) TestRenameStoppedContainer(c *check.C) { @@ -63,12 +63,13 @@ func (s *DockerSuite) TestRenameCheckNames(c *check.C) { c.Assert(name, checker.Equals, "/"+newName, check.Commentf("Failed to rename container %s", name)) result := dockerCmdWithResult("inspect", "-f={{.Name}}", "--type=container", "first_name") - c.Assert(result, icmd.Matches, icmd.Expected{ + result.Assert(c, icmd.Expected{ ExitCode: 1, Err: "No such container: first_name", }) } +// TODO: move to unit test func (s *DockerSuite) TestRenameInvalidName(c *check.C) { runSleepingContainer(c, "--name", "myname") @@ -76,18 +77,6 @@ func (s *DockerSuite) TestRenameInvalidName(c *check.C) { c.Assert(err, checker.NotNil, check.Commentf("Renaming container to invalid name should have failed: %s", out)) c.Assert(out, checker.Contains, "Invalid container name", check.Commentf("%v", err)) - out, _, err = dockerCmdWithError("rename", "myname") - c.Assert(err, checker.NotNil, check.Commentf("Renaming container to invalid name should have failed: %s", out)) - c.Assert(out, checker.Contains, "requires exactly 2 argument(s).", check.Commentf("%v", err)) - - out, _, err = dockerCmdWithError("rename", "myname", "") - c.Assert(err, checker.NotNil, check.Commentf("Renaming container to invalid name should have failed: %s", out)) - c.Assert(out, checker.Contains, "may be empty", check.Commentf("%v", err)) - - out, _, err = dockerCmdWithError("rename", "", "newname") - c.Assert(err, checker.NotNil, check.Commentf("Renaming container with empty name should have failed: %s", out)) - c.Assert(out, checker.Contains, "may be empty", check.Commentf("%v", err)) - out, _ = dockerCmd(c, "ps", "-a") c.Assert(out, checker.Contains, "myname", check.Commentf("Output of docker ps should have included 'myname': %s", out)) } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_rmi_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_rmi_test.go index afbc4c2fa..52c8837d2 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_rmi_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_rmi_test.go @@ -9,8 +9,8 @@ import ( "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" "github.com/docker/docker/pkg/stringid" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) func (s *DockerSuite) TestRmiWithContainerFails(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_run_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_run_test.go index 544cfdf9a..1ad5ce7eb 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_run_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_run_test.go @@ -21,6 +21,7 @@ import ( "sync" "time" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" @@ -28,14 +29,14 @@ import ( "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringutils" - "github.com/docker/docker/pkg/testutil" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/docker/docker/runconfig" "github.com/docker/go-connections/nat" "github.com/docker/libnetwork/resolvconf" "github.com/docker/libnetwork/types" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" libcontainerUser "github.com/opencontainers/runc/libcontainer/user" + "golang.org/x/net/context" ) // "test123" should be printed by docker run @@ -495,7 +496,7 @@ func (s *DockerSuite) TestRunVolumesFromInReadWriteMode(c *check.C) { func (s *DockerSuite) TestVolumesFromGetsProperMode(c *check.C) { testRequires(c, SameHostDaemon) prefix, slash := getPrefixAndSlashFromDaemonPlatform() - hostpath := testutil.RandomTmpDirPath("test", testEnv.DaemonPlatform()) + hostpath := RandomTmpDirPath("test", testEnv.DaemonPlatform()) if err := os.MkdirAll(hostpath, 0755); err != nil { c.Fatalf("Failed to create %s: %q", hostpath, err) } @@ -518,8 +519,8 @@ func (s *DockerSuite) TestVolumesFromGetsProperMode(c *check.C) { // Test for GH#10618 func (s *DockerSuite) TestRunNoDupVolumes(c *check.C) { - path1 := testutil.RandomTmpDirPath("test1", testEnv.DaemonPlatform()) - path2 := testutil.RandomTmpDirPath("test2", testEnv.DaemonPlatform()) + path1 := RandomTmpDirPath("test1", testEnv.DaemonPlatform()) + path2 := RandomTmpDirPath("test2", testEnv.DaemonPlatform()) someplace := ":/someplace" if testEnv.DaemonPlatform() == "windows" { @@ -825,7 +826,7 @@ func (s *DockerSuite) TestRunEnvironment(c *check.C) { }) result.Assert(c, icmd.Success) - actualEnv := strings.Split(strings.TrimSpace(result.Combined()), "\n") + actualEnv := strings.Split(strings.TrimSuffix(result.Stdout(), "\n"), "\n") sort.Strings(actualEnv) goodEnv := []string{ @@ -1799,7 +1800,7 @@ func (s *DockerSuite) TestRunInteractiveWithRestartPolicy(c *check.C) { }() result = icmd.WaitOnCmd(60*time.Second, result) - c.Assert(result, icmd.Matches, icmd.Expected{ExitCode: 11}) + result.Assert(c, icmd.Expected{ExitCode: 11}) } // Test for #2267 @@ -2183,9 +2184,9 @@ func (s *DockerSuite) TestVolumesNoCopyData(c *check.C) { c.Fatalf("Data was copied on volumes-from but shouldn't be:\n%q", out) } - tmpDir := testutil.RandomTmpDirPath("docker_test_bind_mount_copy_data", testEnv.DaemonPlatform()) + tmpDir := RandomTmpDirPath("docker_test_bind_mount_copy_data", testEnv.DaemonPlatform()) if out, _, err := dockerCmdWithError("run", "-v", tmpDir+":/foo", "dataimage", "ls", "-lh", "/foo/bar"); err == nil || !strings.Contains(out, "No such file or directory") { - c.Fatalf("Data was copied on bind-mount but shouldn't be:\n%q", out) + c.Fatalf("Data was copied on bind mount but shouldn't be:\n%q", out) } } @@ -2216,7 +2217,7 @@ func (s *DockerSuite) TestRunVolumesCleanPaths(c *check.C) { out, err = inspectMountSourceField("dark_helmet", prefix+slash+`foo`) c.Assert(err, check.IsNil) - if !strings.Contains(strings.ToLower(out), strings.ToLower(testEnv.VolumesConfigPath())) { + if !strings.Contains(strings.ToLower(out), strings.ToLower(testEnv.PlatformDefaults.VolumesConfigPath)) { c.Fatalf("Volume was not defined for %s/foo\n%q", prefix, out) } @@ -2227,7 +2228,7 @@ func (s *DockerSuite) TestRunVolumesCleanPaths(c *check.C) { out, err = inspectMountSourceField("dark_helmet", prefix+slash+"bar") c.Assert(err, check.IsNil) - if !strings.Contains(strings.ToLower(out), strings.ToLower(testEnv.VolumesConfigPath())) { + if !strings.Contains(strings.ToLower(out), strings.ToLower(testEnv.PlatformDefaults.VolumesConfigPath)) { c.Fatalf("Volume was not defined for %s/bar\n%q", prefix, out) } } @@ -2247,7 +2248,7 @@ func (s *DockerSuite) TestRunSlowStdoutConsumer(c *check.C) { if err := cont.Start(); err != nil { c.Fatal(err) } - n, err := testutil.ConsumeWithSpeed(stdout, 10000, 5*time.Millisecond, nil) + n, err := ConsumeWithSpeed(stdout, 10000, 5*time.Millisecond, nil) if err != nil { c.Fatal(err) } @@ -2814,23 +2815,27 @@ func (s *DockerSuite) TestRunVolumesFromRestartAfterRemoved(c *check.C) { // run container with --rm should remove container if exit code != 0 func (s *DockerSuite) TestRunContainerWithRmFlagExitCodeNotEqualToZero(c *check.C) { + existingContainers := ExistingContainerIDs(c) name := "flowers" cli.Docker(cli.Args("run", "--name", name, "--rm", "busybox", "ls", "/notexists")).Assert(c, icmd.Expected{ ExitCode: 1, }) out := cli.DockerCmd(c, "ps", "-q", "-a").Combined() + out = RemoveOutputForExistingElements(out, existingContainers) if out != "" { c.Fatal("Expected not to have containers", out) } } func (s *DockerSuite) TestRunContainerWithRmFlagCannotStartContainer(c *check.C) { + existingContainers := ExistingContainerIDs(c) name := "sparkles" cli.Docker(cli.Args("run", "--name", name, "--rm", "busybox", "commandNotFound")).Assert(c, icmd.Expected{ ExitCode: 127, }) out := cli.DockerCmd(c, "ps", "-q", "-a").Combined() + out = RemoveOutputForExistingElements(out, existingContainers) if out != "" { c.Fatal("Expected not to have containers", out) } @@ -3337,7 +3342,7 @@ func testRunContainerWithCgroupParent(c *check.C, cgroupParent, name string) { if err != nil { c.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", string(out), err) } - cgroupPaths := testutil.ParseCgroupPaths(string(out)) + cgroupPaths := ParseCgroupPaths(string(out)) if len(cgroupPaths) == 0 { c.Fatalf("unexpected output - %q", string(out)) } @@ -3377,7 +3382,7 @@ func testRunInvalidCgroupParent(c *check.C, cgroupParent, cleanCgroupParent, nam c.Fatalf("SECURITY: --cgroup-parent with ../../ relative paths cause files to be created in the host (this is bad) !!") } - cgroupPaths := testutil.ParseCgroupPaths(string(out)) + cgroupPaths := ParseCgroupPaths(string(out)) if len(cgroupPaths) == 0 { c.Fatalf("unexpected output - %q", string(out)) } @@ -3964,29 +3969,44 @@ func (s *DockerSuite) TestRunNamedVolumeNotRemoved(c *check.C) { dockerCmd(c, "run", "--rm", "-v", "test:"+prefix+"/foo", "-v", prefix+"/bar", "busybox", "true") dockerCmd(c, "volume", "inspect", "test") out, _ := dockerCmd(c, "volume", "ls", "-q") - c.Assert(strings.TrimSpace(out), checker.Equals, "test") + c.Assert(strings.TrimSpace(out), checker.Contains, "test") dockerCmd(c, "run", "--name=test", "-v", "test:"+prefix+"/foo", "-v", prefix+"/bar", "busybox", "true") dockerCmd(c, "rm", "-fv", "test") dockerCmd(c, "volume", "inspect", "test") out, _ = dockerCmd(c, "volume", "ls", "-q") - c.Assert(strings.TrimSpace(out), checker.Equals, "test") + c.Assert(strings.TrimSpace(out), checker.Contains, "test") } func (s *DockerSuite) TestRunNamedVolumesFromNotRemoved(c *check.C) { prefix, _ := getPrefixAndSlashFromDaemonPlatform() dockerCmd(c, "volume", "create", "test") - dockerCmd(c, "run", "--name=parent", "-v", "test:"+prefix+"/foo", "-v", prefix+"/bar", "busybox", "true") + cid, _ := dockerCmd(c, "run", "-d", "--name=parent", "-v", "test:"+prefix+"/foo", "-v", prefix+"/bar", "busybox", "true") dockerCmd(c, "run", "--name=child", "--volumes-from=parent", "busybox", "true") + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + container, err := cli.ContainerInspect(context.Background(), strings.TrimSpace(cid)) + c.Assert(err, checker.IsNil) + var vname string + for _, v := range container.Mounts { + if v.Name != "test" { + vname = v.Name + } + } + c.Assert(vname, checker.Not(checker.Equals), "") + // Remove the parent so there are not other references to the volumes dockerCmd(c, "rm", "-f", "parent") // now remove the child and ensure the named volume (and only the named volume) still exists dockerCmd(c, "rm", "-fv", "child") dockerCmd(c, "volume", "inspect", "test") out, _ := dockerCmd(c, "volume", "ls", "-q") - c.Assert(strings.TrimSpace(out), checker.Equals, "test") + c.Assert(strings.TrimSpace(out), checker.Contains, "test") + c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), vname) } func (s *DockerSuite) TestRunAttachFailedNoLeak(c *check.C) { @@ -4124,7 +4144,7 @@ func (s *DockerSuite) TestRunRm(c *check.C) { // Test that auto-remove is performed by the client on API versions that do not support daemon-side api-remove (API < 1.25) func (s *DockerSuite) TestRunRmPre125Api(c *check.C) { name := "miss-me-when-im-gone" - envs := appendBaseEnv(false, "DOCKER_API_VERSION=1.24") + envs := appendBaseEnv(os.Getenv("DOCKER_TLS_VERIFY") != "", "DOCKER_API_VERSION=1.24") cli.Docker(cli.Args("run", "--name="+name, "--rm", "busybox"), cli.WithEnvironmentVariables(envs...)).Assert(c, icmd.Success) cli.Docker(cli.Inspect(name), cli.Format(".name")).Assert(c, icmd.Expected{ @@ -4610,10 +4630,7 @@ func (s *DockerSuite) TestRunAddDeviceCgroupRule(c *check.C) { // Verifies that running as local system is operating correctly on Windows func (s *DockerSuite) TestWindowsRunAsSystem(c *check.C) { - testRequires(c, DaemonIsWindows) - if testEnv.DaemonKernelVersionNumeric() < 15000 { - c.Skip("Requires build 15000 or later") - } + testRequires(c, DaemonIsWindowsAtLeastBuild(15000)) out, _ := dockerCmd(c, "run", "--net=none", `--user=nt authority\system`, "--hostname=XYZZY", minimalBaseImage(), "cmd", "/c", `@echo %USERNAME%`) c.Assert(strings.TrimSpace(out), checker.Equals, "XYZZY$") } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_run_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_run_unix_test.go index b3d1b0721..dd32a72d7 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_run_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_run_unix_test.go @@ -4,6 +4,7 @@ package main import ( "bufio" + "context" "encoding/json" "fmt" "io/ioutil" @@ -16,6 +17,7 @@ import ( "syscall" "time" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" @@ -23,8 +25,8 @@ import ( "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/sysinfo" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" "github.com/kr/pty" ) @@ -675,7 +677,7 @@ func (s *DockerSuite) TestRunWithSwappinessInvalid(c *check.C) { } func (s *DockerSuite) TestRunWithMemoryReservation(c *check.C) { - testRequires(c, memoryReservationSupport) + testRequires(c, SameHostDaemon, memoryReservationSupport) file := "/sys/fs/cgroup/memory/memory.soft_limit_in_bytes" out, _ := dockerCmd(c, "run", "--memory-reservation", "200M", "--name", "test", "busybox", "cat", file) @@ -687,7 +689,7 @@ func (s *DockerSuite) TestRunWithMemoryReservation(c *check.C) { func (s *DockerSuite) TestRunWithMemoryReservationInvalid(c *check.C) { testRequires(c, memoryLimitSupport) - testRequires(c, memoryReservationSupport) + testRequires(c, SameHostDaemon, memoryReservationSupport) out, _, err := dockerCmdWithError("run", "-m", "500M", "--memory-reservation", "800M", "busybox", "true") c.Assert(err, check.NotNil) expected := "Minimum memory limit can not be less than memory reservation limit" @@ -1058,7 +1060,7 @@ func (s *DockerSuite) TestRunSeccompProfileAllow32Bit(c *check.C) { testRequires(c, SameHostDaemon, seccompEnabled, IsAmd64) ensureSyscallTest(c) - icmd.RunCommand(dockerBinary, "run", "syscall-test", "exit32-test", "id").Assert(c, icmd.Success) + icmd.RunCommand(dockerBinary, "run", "syscall-test", "exit32-test").Assert(c, icmd.Success) } // TestRunSeccompAllowSetrlimit checks that 'docker run debian:jessie ulimit -v 1048510' succeeds. @@ -1399,7 +1401,7 @@ func (s *DockerSuite) TestRunDeviceSymlink(c *check.C) { // TestRunPIDsLimit makes sure the pids cgroup is set with --pids-limit func (s *DockerSuite) TestRunPIDsLimit(c *check.C) { - testRequires(c, pidsLimit) + testRequires(c, SameHostDaemon, pidsLimit) file := "/sys/fs/cgroup/pids/pids.max" out, _ := dockerCmd(c, "run", "--name", "skittles", "--pids-limit", "4", "busybox", "cat", file) @@ -1563,14 +1565,18 @@ func (s *DockerSuite) TestRunWithNanoCPUs(c *check.C) { out, _ := dockerCmd(c, "run", "--cpus", "0.5", "--name", "test", "busybox", "sh", "-c", fmt.Sprintf("cat %s && cat %s", file1, file2)) c.Assert(strings.TrimSpace(out), checker.Equals, "50000\n100000") - out = inspectField(c, "test", "HostConfig.NanoCpus") - c.Assert(out, checker.Equals, "5e+08", check.Commentf("setting the Nano CPUs failed")) + clt, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + inspect, err := clt.ContainerInspect(context.Background(), "test") + c.Assert(err, checker.IsNil) + c.Assert(inspect.HostConfig.NanoCPUs, checker.Equals, int64(500000000)) + out = inspectField(c, "test", "HostConfig.CpuQuota") c.Assert(out, checker.Equals, "0", check.Commentf("CPU CFS quota should be 0")) out = inspectField(c, "test", "HostConfig.CpuPeriod") c.Assert(out, checker.Equals, "0", check.Commentf("CPU CFS period should be 0")) - out, _, err := dockerCmdWithError("run", "--cpus", "0.5", "--cpu-quota", "50000", "--cpu-period", "100000", "busybox", "sh") + out, _, err = dockerCmdWithError("run", "--cpus", "0.5", "--cpu-quota", "50000", "--cpu-period", "100000", "busybox", "sh") c.Assert(err, check.NotNil) c.Assert(out, checker.Contains, "Conflicting options: Nano CPUs and CPU Period cannot both be set") } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_save_load_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_save_load_test.go index 3b14576f7..3e6dc2dd3 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_save_load_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_save_load_test.go @@ -1,8 +1,10 @@ package main import ( + "archive/tar" "encoding/json" "fmt" + "io" "io/ioutil" "os" "os/exec" @@ -15,10 +17,9 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli/build" - "github.com/docker/docker/pkg/testutil" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" - "github.com/opencontainers/go-digest" + "github.com/gotestyourself/gotestyourself/icmd" + digest "github.com/opencontainers/go-digest" ) // save a repo using gz compression and try to load it using stdout @@ -32,7 +33,7 @@ func (s *DockerSuite) TestSaveXzAndLoadRepoStdout(c *check.C) { dockerCmd(c, "inspect", repoName) - repoTarball, _, err := testutil.RunCommandPipelineWithOutput( + repoTarball, err := RunCommandPipelineWithOutput( exec.Command(dockerBinary, "save", repoName), exec.Command("xz", "-c"), exec.Command("gzip", "-c")) @@ -61,7 +62,7 @@ func (s *DockerSuite) TestSaveXzGzAndLoadRepoStdout(c *check.C) { dockerCmd(c, "inspect", repoName) - out, _, err := testutil.RunCommandPipelineWithOutput( + out, err := RunCommandPipelineWithOutput( exec.Command(dockerBinary, "save", repoName), exec.Command("xz", "-c"), exec.Command("gzip", "-c")) @@ -88,7 +89,7 @@ func (s *DockerSuite) TestSaveSingleTag(c *check.C) { out, _ := dockerCmd(c, "images", "-q", "--no-trunc", repoName) cleanedImageID := strings.TrimSpace(out) - out, _, err := testutil.RunCommandPipelineWithOutput( + out, err := RunCommandPipelineWithOutput( exec.Command(dockerBinary, "save", fmt.Sprintf("%v:latest", repoName)), exec.Command("tar", "t"), exec.Command("grep", "-E", fmt.Sprintf("(^repositories$|%v)", cleanedImageID))) @@ -107,7 +108,7 @@ func (s *DockerSuite) TestSaveCheckTimes(c *check.C) { c.Assert(err, checker.IsNil, check.Commentf("failed to marshal from %q: err %v", repoName, err)) c.Assert(len(data), checker.Not(checker.Equals), 0, check.Commentf("failed to marshal the data from %q", repoName)) tarTvTimeFormat := "2006-01-02 15:04" - out, _, err = testutil.RunCommandPipelineWithOutput( + out, err = RunCommandPipelineWithOutput( exec.Command(dockerBinary, "save", repoName), exec.Command("tar", "tv"), exec.Command("grep", "-E", fmt.Sprintf("%s %s", data[0].Created.Format(tarTvTimeFormat), digest.Digest(data[0].ID).Hex()))) @@ -165,7 +166,7 @@ func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *check.C) { before, _ := dockerCmd(c, "inspect", repoName) - out, _, err := testutil.RunCommandPipelineWithOutput( + out, err := RunCommandPipelineWithOutput( exec.Command(dockerBinary, "save", repoName), exec.Command(dockerBinary, "load")) c.Assert(err, checker.IsNil, check.Commentf("failed to save and load repo: %s, %v", out, err)) @@ -194,7 +195,7 @@ func (s *DockerSuite) TestSaveMultipleNames(c *check.C) { // Make two images dockerCmd(c, "tag", "emptyfs:latest", fmt.Sprintf("%v-two:latest", repoName)) - out, _, err := testutil.RunCommandPipelineWithOutput( + out, err := RunCommandPipelineWithOutput( exec.Command(dockerBinary, "save", fmt.Sprintf("%v-one", repoName), fmt.Sprintf("%v-two:latest", repoName)), exec.Command("tar", "xO", "repositories"), exec.Command("grep", "-q", "-E", "(-one|-two)"), @@ -226,7 +227,7 @@ func (s *DockerSuite) TestSaveRepoWithMultipleImages(c *check.C) { deleteImages(repoName) // create the archive - out, _, err := testutil.RunCommandPipelineWithOutput( + out, err := RunCommandPipelineWithOutput( exec.Command(dockerBinary, "save", repoName, "busybox:latest"), exec.Command("tar", "t")) c.Assert(err, checker.IsNil, check.Commentf("failed to save multiple images: %s, %v", out, err)) @@ -270,7 +271,7 @@ func (s *DockerSuite) TestSaveDirectoryPermissions(c *check.C) { RUN adduser -D user && mkdir -p /opt/a/b && chown -R user:user /opt/a RUN touch /opt/a/b/c && chown user:user /opt/a/b/c`)) - out, _, err := testutil.RunCommandPipelineWithOutput( + out, err := RunCommandPipelineWithOutput( exec.Command(dockerBinary, "save", name), exec.Command("tar", "-xf", "-", "-C", extractionDirectory), ) @@ -289,7 +290,7 @@ func (s *DockerSuite) TestSaveDirectoryPermissions(c *check.C) { c.Assert(err, checker.IsNil, check.Commentf("failed to open %s: %s", layerPath, err)) defer f.Close() - entries, err := testutil.ListTar(f) + entries, err := listTar(f) for _, e := range entries { if !strings.Contains(e, "dev/") { entriesSansDev = append(entriesSansDev, e) @@ -308,6 +309,23 @@ func (s *DockerSuite) TestSaveDirectoryPermissions(c *check.C) { } +func listTar(f io.Reader) ([]string, error) { + tr := tar.NewReader(f) + var entries []string + + for { + th, err := tr.Next() + if err == io.EOF { + // end of tar archive + return entries, nil + } + if err != nil { + return entries, err + } + entries = append(entries, th.Name) + } +} + // Test loading a weird image where one of the layers is of zero size. // The layer.tar file is actually zero bytes, no padding or anything else. // See issue: 18170 @@ -365,7 +383,7 @@ func (s *DockerSuite) TestSaveLoadNoTag(c *check.C) { id := inspectField(c, name, "Id") // Test to make sure that save w/o name just shows imageID during load - out, _, err := testutil.RunCommandPipelineWithOutput( + out, err := RunCommandPipelineWithOutput( exec.Command(dockerBinary, "save", id), exec.Command(dockerBinary, "load")) c.Assert(err, checker.IsNil, check.Commentf("failed to save and load repo: %s, %v", out, err)) @@ -376,7 +394,7 @@ func (s *DockerSuite) TestSaveLoadNoTag(c *check.C) { c.Assert(out, checker.Contains, id) // Test to make sure that save by name shows that name during load - out, _, err = testutil.RunCommandPipelineWithOutput( + out, err = RunCommandPipelineWithOutput( exec.Command(dockerBinary, "save", name), exec.Command(dockerBinary, "load")) c.Assert(err, checker.IsNil, check.Commentf("failed to save and load repo: %s, %v", out, err)) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_save_load_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_save_load_unix_test.go index deb061682..fcbfd7e62 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_save_load_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_save_load_unix_test.go @@ -13,8 +13,8 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli/build" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" "github.com/kr/pty" ) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_service_logs_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_service_logs_test.go index d2ce36def..1c8f3d80f 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_service_logs_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_service_logs_test.go @@ -12,8 +12,8 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/daemon" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) type logMessage struct { @@ -40,7 +40,7 @@ func (s *DockerSwarmSuite) TestServiceLogs(c *check.C) { // make sure task has been deployed. waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskImages, checker.DeepEquals, - map[string]int{"busybox": len(services)}) + map[string]int{"busybox:latest": len(services)}) for name, message := range services { out, err := d.Cmd("service", "logs", name) @@ -287,7 +287,7 @@ func (s *DockerSwarmSuite) TestServiceLogsTTY(c *check.C) { result = icmd.RunCmd(cmd) // for some reason there is carriage return in the output. i think this is // just expected. - c.Assert(result, icmd.Matches, icmd.Expected{Out: "out\r\nerr\r\n"}) + result.Assert(c, icmd.Expected{Out: "out\r\nerr\r\n"}) } func (s *DockerSwarmSuite) TestServiceLogsNoHangDeletedContainer(c *check.C) { @@ -307,7 +307,7 @@ func (s *DockerSwarmSuite) TestServiceLogsNoHangDeletedContainer(c *check.C) { )) // confirm that the command succeeded - c.Assert(result, icmd.Matches, icmd.Expected{}) + result.Assert(c, icmd.Expected{}) // get the service id id := strings.TrimSpace(result.Stdout()) c.Assert(id, checker.Not(checker.Equals), "") @@ -322,9 +322,9 @@ func (s *DockerSwarmSuite) TestServiceLogsNoHangDeletedContainer(c *check.C) { containerID := strings.TrimSpace(result.Stdout()) c.Assert(containerID, checker.Not(checker.Equals), "") result = icmd.RunCmd(d.Command("stop", containerID)) - c.Assert(result, icmd.Matches, icmd.Expected{Out: containerID}) + result.Assert(c, icmd.Expected{Out: containerID}) result = icmd.RunCmd(d.Command("rm", containerID)) - c.Assert(result, icmd.Matches, icmd.Expected{Out: containerID}) + result.Assert(c, icmd.Expected{Out: containerID}) // run logs. use tail 2 to make sure we don't try to get a bunch of logs // somehow and slow down execution time @@ -336,7 +336,7 @@ func (s *DockerSwarmSuite) TestServiceLogsNoHangDeletedContainer(c *check.C) { // then, assert that the result matches expected. if the command timed out, // if the command is timed out, result.Timeout will be true, but the // Expected defaults to false - c.Assert(result, icmd.Matches, icmd.Expected{}) + result.Assert(c, icmd.Expected{}) } func (s *DockerSwarmSuite) TestServiceLogsDetails(c *check.C) { @@ -376,12 +376,12 @@ func (s *DockerSwarmSuite) TestServiceLogsDetails(c *check.C) { // in this case, we should get details and we should get log message, but // there will also be context as details (which will fall after the detail // we inserted in alphabetical order - c.Assert(result, icmd.Matches, icmd.Expected{Out: "asdf=test1"}) - c.Assert(result, icmd.Matches, icmd.Expected{Out: "LogLine"}) + result.Assert(c, icmd.Expected{Out: "asdf=test1"}) + result.Assert(c, icmd.Expected{Out: "LogLine"}) // call service logs with details. this time, don't pass raw result = icmd.RunCmd(d.Command("service", "logs", "--details", id)) // in this case, we should get details space logmessage as well. the context // is part of the pretty part of the logline - c.Assert(result, icmd.Matches, icmd.Expected{Out: "asdf=test1 LogLine"}) + result.Assert(c, icmd.Expected{Out: "asdf=test1 LogLine"}) } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_stack_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_stack_test.go deleted file mode 100644 index 91fe4d75c..000000000 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_stack_test.go +++ /dev/null @@ -1,206 +0,0 @@ -// +build !windows - -package main - -import ( - "encoding/json" - "io/ioutil" - "os" - "sort" - "strings" - - "github.com/docker/docker/api/types/swarm" - "github.com/docker/docker/integration-cli/checker" - icmd "github.com/docker/docker/pkg/testutil/cmd" - "github.com/go-check/check" -) - -var cleanSpaces = func(s string) string { - lines := strings.Split(s, "\n") - for i, line := range lines { - spaceIx := strings.Index(line, " ") - if spaceIx > 0 { - lines[i] = line[:spaceIx+1] + strings.TrimLeft(line[spaceIx:], " ") - } - } - return strings.Join(lines, "\n") -} - -func (s *DockerSwarmSuite) TestStackRemoveUnknown(c *check.C) { - d := s.AddDaemon(c, true, true) - - stackArgs := append([]string{"stack", "remove", "UNKNOWN_STACK"}) - - out, err := d.Cmd(stackArgs...) - c.Assert(err, checker.IsNil) - c.Assert(out, check.Equals, "Nothing found in stack: UNKNOWN_STACK\n") -} - -func (s *DockerSwarmSuite) TestStackPSUnknown(c *check.C) { - d := s.AddDaemon(c, true, true) - - stackArgs := append([]string{"stack", "ps", "UNKNOWN_STACK"}) - - out, err := d.Cmd(stackArgs...) - c.Assert(err, checker.IsNil) - c.Assert(out, check.Equals, "Nothing found in stack: UNKNOWN_STACK\n") -} - -func (s *DockerSwarmSuite) TestStackServicesUnknown(c *check.C) { - d := s.AddDaemon(c, true, true) - - stackArgs := append([]string{"stack", "services", "UNKNOWN_STACK"}) - - out, err := d.Cmd(stackArgs...) - c.Assert(err, checker.IsNil) - c.Assert(out, check.Equals, "Nothing found in stack: UNKNOWN_STACK\n") -} - -func (s *DockerSwarmSuite) TestStackDeployComposeFile(c *check.C) { - d := s.AddDaemon(c, true, true) - - testStackName := "testdeploy" - stackArgs := []string{ - "stack", "deploy", - "--compose-file", "fixtures/deploy/default.yaml", - testStackName, - } - out, err := d.Cmd(stackArgs...) - c.Assert(err, checker.IsNil, check.Commentf(out)) - - out, err = d.Cmd("stack", "ls") - c.Assert(err, checker.IsNil) - c.Assert(cleanSpaces(out), check.Equals, "NAME SERVICES\n"+"testdeploy 2\n") - - out, err = d.Cmd("stack", "rm", testStackName) - c.Assert(err, checker.IsNil) - out, err = d.Cmd("stack", "ls") - c.Assert(err, checker.IsNil) - c.Assert(cleanSpaces(out), check.Equals, "NAME SERVICES\n") -} - -func (s *DockerSwarmSuite) TestStackDeployWithSecretsTwice(c *check.C) { - d := s.AddDaemon(c, true, true) - - out, err := d.Cmd("secret", "create", "outside", "fixtures/secrets/default") - c.Assert(err, checker.IsNil, check.Commentf(out)) - - testStackName := "testdeploy" - stackArgs := []string{ - "stack", "deploy", - "--compose-file", "fixtures/deploy/secrets.yaml", - testStackName, - } - out, err = d.Cmd(stackArgs...) - c.Assert(err, checker.IsNil, check.Commentf(out)) - - out, err = d.Cmd("service", "inspect", "--format", "{{ json .Spec.TaskTemplate.ContainerSpec.Secrets }}", "testdeploy_web") - c.Assert(err, checker.IsNil) - - var refs []swarm.SecretReference - c.Assert(json.Unmarshal([]byte(out), &refs), checker.IsNil) - c.Assert(refs, checker.HasLen, 3) - - sort.Sort(sortSecrets(refs)) - c.Assert(refs[0].SecretName, checker.Equals, "outside") - c.Assert(refs[1].SecretName, checker.Equals, "testdeploy_special") - c.Assert(refs[1].File.Name, checker.Equals, "special") - c.Assert(refs[2].SecretName, checker.Equals, "testdeploy_super") - c.Assert(refs[2].File.Name, checker.Equals, "foo.txt") - c.Assert(refs[2].File.Mode, checker.Equals, os.FileMode(0400)) - - // Deploy again to ensure there are no errors when secret hasn't changed - out, err = d.Cmd(stackArgs...) - c.Assert(err, checker.IsNil, check.Commentf(out)) -} - -func (s *DockerSwarmSuite) TestStackRemove(c *check.C) { - d := s.AddDaemon(c, true, true) - - stackName := "testdeploy" - stackArgs := []string{ - "stack", "deploy", - "--compose-file", "fixtures/deploy/remove.yaml", - stackName, - } - result := icmd.RunCmd(d.Command(stackArgs...)) - result.Assert(c, icmd.Expected{ - Err: icmd.None, - Out: "Creating service testdeploy_web", - }) - - result = icmd.RunCmd(d.Command("service", "ls")) - result.Assert(c, icmd.Success) - c.Assert( - strings.Split(strings.TrimSpace(result.Stdout()), "\n"), - checker.HasLen, 2) - - result = icmd.RunCmd(d.Command("stack", "rm", stackName)) - result.Assert(c, icmd.Success) - stderr := result.Stderr() - c.Assert(stderr, checker.Contains, "Removing service testdeploy_web") - c.Assert(stderr, checker.Contains, "Removing network testdeploy_default") - c.Assert(stderr, checker.Contains, "Removing secret testdeploy_special") -} - -type sortSecrets []swarm.SecretReference - -func (s sortSecrets) Len() int { return len(s) } -func (s sortSecrets) Swap(i, j int) { s[i], s[j] = s[j], s[i] } -func (s sortSecrets) Less(i, j int) bool { return s[i].SecretName < s[j].SecretName } - -// testDAB is the DAB JSON used for testing. -// TODO: Use template/text and substitute "Image" with the result of -// `docker inspect --format '{{index .RepoDigests 0}}' busybox:latest` -const testDAB = `{ - "Version": "0.1", - "Services": { - "srv1": { - "Image": "busybox@sha256:e4f93f6ed15a0cdd342f5aae387886fba0ab98af0a102da6276eaf24d6e6ade0", - "Command": ["top"] - }, - "srv2": { - "Image": "busybox@sha256:e4f93f6ed15a0cdd342f5aae387886fba0ab98af0a102da6276eaf24d6e6ade0", - "Command": ["tail"], - "Args": ["-f", "/dev/null"] - } - } -}` - -func (s *DockerSwarmSuite) TestStackDeployWithDAB(c *check.C) { - testRequires(c, ExperimentalDaemon) - // setup - testStackName := "test" - testDABFileName := testStackName + ".dab" - defer os.RemoveAll(testDABFileName) - err := ioutil.WriteFile(testDABFileName, []byte(testDAB), 0444) - c.Assert(err, checker.IsNil) - d := s.AddDaemon(c, true, true) - // deploy - stackArgs := []string{ - "stack", "deploy", - "--bundle-file", testDABFileName, - testStackName, - } - out, err := d.Cmd(stackArgs...) - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, "Loading bundle from test.dab\n") - c.Assert(out, checker.Contains, "Creating service test_srv1\n") - c.Assert(out, checker.Contains, "Creating service test_srv2\n") - // ls - stackArgs = []string{"stack", "ls"} - out, err = d.Cmd(stackArgs...) - c.Assert(err, checker.IsNil) - c.Assert(cleanSpaces(out), check.Equals, "NAME SERVICES\n"+"test 2\n") - // rm - stackArgs = []string{"stack", "rm", testStackName} - out, err = d.Cmd(stackArgs...) - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, "Removing service test_srv1\n") - c.Assert(out, checker.Contains, "Removing service test_srv2\n") - // ls (empty) - stackArgs = []string{"stack", "ls"} - out, err = d.Cmd(stackArgs...) - c.Assert(err, checker.IsNil) - c.Assert(cleanSpaces(out), check.Equals, "NAME SERVICES\n") -} diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_start_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_start_test.go index 2dd5fdf5f..13c1d8ef2 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_start_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_start_test.go @@ -7,8 +7,8 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) // Regression test for https://github.com/docker/docker/issues/7843 @@ -103,7 +103,7 @@ func (s *DockerSuite) TestStartPausedContainer(c *check.C) { // an error should have been shown that you cannot start paused container c.Assert(err, checker.NotNil, check.Commentf("out: %s", out)) // an error should have been shown that you cannot start paused container - c.Assert(out, checker.Contains, "Cannot start a paused container, try unpause instead.") + c.Assert(out, checker.Contains, "cannot start a paused container, try unpause instead") } func (s *DockerSuite) TestStartMultipleContainers(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_swarm_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_swarm_test.go index a0bb7a228..c56cf1fe6 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_swarm_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_swarm_test.go @@ -12,7 +12,6 @@ import ( "net/http" "net/http/httptest" "os" - "os/exec" "path/filepath" "strings" "time" @@ -23,14 +22,14 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/daemon" - "github.com/docker/docker/pkg/testutil" - icmd "github.com/docker/docker/pkg/testutil/cmd" - "github.com/docker/docker/pkg/testutil/tempfile" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/ipamapi" remoteipam "github.com/docker/libnetwork/ipams/remote/api" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/fs" + "github.com/gotestyourself/gotestyourself/icmd" "github.com/vishvananda/netlink" + "golang.org/x/net/context" ) func (s *DockerSwarmSuite) TestSwarmUpdate(c *check.C) { @@ -69,11 +68,11 @@ func (s *DockerSwarmSuite) TestSwarmUpdate(c *check.C) { c.Assert(spec.CAConfig.ExternalCAs[1].CACert, checker.Equals, string(expected)) // passing an invalid external CA fails - tempFile := tempfile.NewTempFile(c, "testfile", "fakecert") + tempFile := fs.NewFile(c, "testfile", fs.WithContent("fakecert")) defer tempFile.Remove() result := cli.Docker(cli.Args("swarm", "update", - "--external-ca", fmt.Sprintf("protocol=cfssl,url=https://something.org,cacert=%s", tempFile.Name())), + "--external-ca", fmt.Sprintf("protocol=cfssl,url=https://something.org,cacert=%s", tempFile.Path())), cli.Daemon(d.Daemon)) result.Assert(c, icmd.Expected{ ExitCode: 125, @@ -90,11 +89,11 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *check.C) { } // passing an invalid external CA fails - tempFile := tempfile.NewTempFile(c, "testfile", "fakecert") + tempFile := fs.NewFile(c, "testfile", fs.WithContent("fakecert")) defer tempFile.Remove() result := cli.Docker(cli.Args("swarm", "init", "--cert-expiry", "30h", "--dispatcher-heartbeat", "11s", - "--external-ca", fmt.Sprintf("protocol=cfssl,url=https://somethingelse.org,cacert=%s", tempFile.Name())), + "--external-ca", fmt.Sprintf("protocol=cfssl,url=https://somethingelse.org,cacert=%s", tempFile.Path())), cli.Daemon(d.Daemon)) result.Assert(c, icmd.Expected{ ExitCode: 125, @@ -170,8 +169,10 @@ func (s *DockerSwarmSuite) TestSwarmIncompatibleDaemon(c *check.C) { func (s *DockerSwarmSuite) TestSwarmServiceTemplatingHostname(c *check.C) { d := s.AddDaemon(c, true, true) + hostname, err := d.Cmd("node", "inspect", "--format", "{{.Description.Hostname}}", "self") + c.Assert(err, checker.IsNil, check.Commentf(hostname)) - out, err := d.Cmd("service", "create", "--no-resolve-image", "--name", "test", "--hostname", "{{.Service.Name}}-{{.Task.Slot}}", "busybox", "top") + out, err := d.Cmd("service", "create", "--no-resolve-image", "--name", "test", "--hostname", "{{.Service.Name}}-{{.Task.Slot}}-{{.Node.Hostname}}", "busybox", "top") c.Assert(err, checker.IsNil, check.Commentf(out)) // make sure task has been deployed. @@ -180,7 +181,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceTemplatingHostname(c *check.C) { containers := d.ActiveContainers() out, err = d.Cmd("inspect", "--type", "container", "--format", "{{.Config.Hostname}}", containers[0]) c.Assert(err, checker.IsNil, check.Commentf(out)) - c.Assert(strings.Split(out, "\n")[0], checker.Equals, "test-1", check.Commentf("hostname with templating invalid")) + c.Assert(strings.Split(out, "\n")[0], checker.Equals, "test-1-"+strings.Split(hostname, "\n")[0], check.Commentf("hostname with templating invalid")) } // Test case for #24270 @@ -467,14 +468,17 @@ func (s *DockerSwarmSuite) TestSwarmIngressNetwork(c *check.C) { d := s.AddDaemon(c, true, true) // Ingress network can be removed - out, _, err := testutil.RunCommandPipelineWithOutput( - exec.Command("echo", "Y"), - exec.Command("docker", "-H", d.Sock(), "network", "rm", "ingress"), - ) - c.Assert(err, checker.IsNil, check.Commentf(out)) + removeNetwork := func(name string) *icmd.Result { + return cli.Docker( + cli.Args("-H", d.Sock(), "network", "rm", name), + cli.WithStdin(strings.NewReader("Y"))) + } + + result := removeNetwork("ingress") + result.Assert(c, icmd.Success) // And recreated - out, err = d.Cmd("network", "create", "-d", "overlay", "--ingress", "new-ingress") + out, err := d.Cmd("network", "create", "-d", "overlay", "--ingress", "new-ingress") c.Assert(err, checker.IsNil, check.Commentf(out)) // But only one is allowed @@ -485,21 +489,19 @@ func (s *DockerSwarmSuite) TestSwarmIngressNetwork(c *check.C) { // It cannot be removed if it is being used out, err = d.Cmd("service", "create", "--no-resolve-image", "--name", "srv1", "-p", "9000:8000", "busybox", "top") c.Assert(err, checker.IsNil, check.Commentf(out)) - out, _, err = testutil.RunCommandPipelineWithOutput( - exec.Command("echo", "Y"), - exec.Command("docker", "-H", d.Sock(), "network", "rm", "new-ingress"), - ) - c.Assert(err, checker.NotNil) - c.Assert(strings.TrimSpace(out), checker.Contains, "ingress network cannot be removed because service") + + result = removeNetwork("new-ingress") + result.Assert(c, icmd.Expected{ + ExitCode: 1, + Err: "ingress network cannot be removed because service", + }) // But it can be removed once no more services depend on it out, err = d.Cmd("service", "update", "--publish-rm", "9000:8000", "srv1") c.Assert(err, checker.IsNil, check.Commentf(out)) - out, _, err = testutil.RunCommandPipelineWithOutput( - exec.Command("echo", "Y"), - exec.Command("docker", "-H", d.Sock(), "network", "rm", "new-ingress"), - ) - c.Assert(err, checker.IsNil, check.Commentf(out)) + + result = removeNetwork("new-ingress") + result.Assert(c, icmd.Success) // A service which needs the ingress network cannot be created if no ingress is present out, err = d.Cmd("service", "create", "--no-resolve-image", "--name", "srv2", "-p", "500:500", "busybox", "top") @@ -520,15 +522,14 @@ func (s *DockerSwarmSuite) TestSwarmCreateServiceWithNoIngressNetwork(c *check.C d := s.AddDaemon(c, true, true) // Remove ingress network - out, _, err := testutil.RunCommandPipelineWithOutput( - exec.Command("echo", "Y"), - exec.Command("docker", "-H", d.Sock(), "network", "rm", "ingress"), - ) - c.Assert(err, checker.IsNil, check.Commentf(out)) + result := cli.Docker( + cli.Args("-H", d.Sock(), "network", "rm", "ingress"), + cli.WithStdin(strings.NewReader("Y"))) + result.Assert(c, icmd.Success) // Create a overlay network and launch a service on it // Make sure nothing panics because ingress network is missing - out, err = d.Cmd("network", "create", "-d", "overlay", "another-network") + out, err := d.Cmd("network", "create", "-d", "overlay", "another-network") c.Assert(err, checker.IsNil, check.Commentf(out)) out, err = d.Cmd("service", "create", "--no-resolve-image", "--name", "srv4", "--network", "another-network", "busybox", "top") c.Assert(err, checker.IsNil, check.Commentf(out)) @@ -1535,22 +1536,6 @@ func (s *DockerSwarmSuite) TestSwarmManagerAddress(c *check.C) { c.Assert(out, checker.Contains, expectedOutput) } -func (s *DockerSwarmSuite) TestSwarmServiceInspectPretty(c *check.C) { - d := s.AddDaemon(c, true, true) - - name := "top" - out, err := d.Cmd("service", "create", "--no-resolve-image", "--name", name, "--limit-cpu=0.5", "busybox", "top") - c.Assert(err, checker.IsNil, check.Commentf(out)) - - expectedOutput := ` -Resources: - Limits: - CPU: 0.5` - out, err = d.Cmd("service", "inspect", "--pretty", name) - c.Assert(err, checker.IsNil, check.Commentf(out)) - c.Assert(out, checker.Contains, expectedOutput, check.Commentf(out)) -} - func (s *DockerSwarmSuite) TestSwarmNetworkIPAMOptions(c *check.C) { d := s.AddDaemon(c, true, true) @@ -1692,76 +1677,6 @@ func (s *DockerSwarmSuite) TestSwarmNetworkCreateDup(c *check.C) { } } -func (s *DockerSwarmSuite) TestSwarmServicePsMultipleServiceIDs(c *check.C) { - d := s.AddDaemon(c, true, true) - - name1 := "top1" - out, err := d.Cmd("service", "create", "--no-resolve-image", "--detach=true", "--name", name1, "--replicas=3", "busybox", "top") - c.Assert(err, checker.IsNil) - c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "") - id1 := strings.TrimSpace(out) - - name2 := "top2" - out, err = d.Cmd("service", "create", "--no-resolve-image", "--detach=true", "--name", name2, "--replicas=3", "busybox", "top") - c.Assert(err, checker.IsNil) - c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "") - id2 := strings.TrimSpace(out) - - // make sure task has been deployed. - waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 6) - - out, err = d.Cmd("service", "ps", name1) - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, name1+".1") - c.Assert(out, checker.Contains, name1+".2") - c.Assert(out, checker.Contains, name1+".3") - c.Assert(out, checker.Not(checker.Contains), name2+".1") - c.Assert(out, checker.Not(checker.Contains), name2+".2") - c.Assert(out, checker.Not(checker.Contains), name2+".3") - - out, err = d.Cmd("service", "ps", name1, name2) - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, name1+".1") - c.Assert(out, checker.Contains, name1+".2") - c.Assert(out, checker.Contains, name1+".3") - c.Assert(out, checker.Contains, name2+".1") - c.Assert(out, checker.Contains, name2+".2") - c.Assert(out, checker.Contains, name2+".3") - - // Name Prefix - out, err = d.Cmd("service", "ps", "to") - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, name1+".1") - c.Assert(out, checker.Contains, name1+".2") - c.Assert(out, checker.Contains, name1+".3") - c.Assert(out, checker.Contains, name2+".1") - c.Assert(out, checker.Contains, name2+".2") - c.Assert(out, checker.Contains, name2+".3") - - // Name Prefix (no hit) - out, err = d.Cmd("service", "ps", "noname") - c.Assert(err, checker.NotNil) - c.Assert(out, checker.Contains, "no such services: noname") - - out, err = d.Cmd("service", "ps", id1) - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, name1+".1") - c.Assert(out, checker.Contains, name1+".2") - c.Assert(out, checker.Contains, name1+".3") - c.Assert(out, checker.Not(checker.Contains), name2+".1") - c.Assert(out, checker.Not(checker.Contains), name2+".2") - c.Assert(out, checker.Not(checker.Contains), name2+".3") - - out, err = d.Cmd("service", "ps", id1, id2) - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, name1+".1") - c.Assert(out, checker.Contains, name1+".2") - c.Assert(out, checker.Contains, name1+".3") - c.Assert(out, checker.Contains, name2+".1") - c.Assert(out, checker.Contains, name2+".2") - c.Assert(out, checker.Contains, name2+".3") -} - func (s *DockerSwarmSuite) TestSwarmPublishDuplicatePorts(c *check.C) { d := s.AddDaemon(c, true, true) @@ -1845,19 +1760,17 @@ func (s *DockerSwarmSuite) TestNetworkInspectWithDuplicateNames(c *check.C) { d := s.AddDaemon(c, true, true) name := "foo" - networkCreateRequest := types.NetworkCreateRequest{ - Name: name, - NetworkCreate: types.NetworkCreate{ - CheckDuplicate: false, - Driver: "bridge", - }, + options := types.NetworkCreate{ + CheckDuplicate: false, + Driver: "bridge", } - var n1 types.NetworkCreateResponse - status, body, err := d.SockRequest("POST", "/networks/create", networkCreateRequest) - c.Assert(err, checker.IsNil, check.Commentf(string(body))) - c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(body))) - c.Assert(json.Unmarshal(body, &n1), checker.IsNil) + cli, err := d.NewClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + n1, err := cli.NetworkCreate(context.Background(), name, options) + c.Assert(err, checker.IsNil) // Full ID always works out, err := d.Cmd("network", "inspect", "--format", "{{.ID}}", n1.ID) @@ -1869,12 +1782,8 @@ func (s *DockerSwarmSuite) TestNetworkInspectWithDuplicateNames(c *check.C) { c.Assert(err, checker.IsNil, check.Commentf(out)) c.Assert(strings.TrimSpace(out), checker.Equals, n1.ID) - var n2 types.NetworkCreateResponse - status, body, err = d.SockRequest("POST", "/networks/create", networkCreateRequest) - c.Assert(err, checker.IsNil, check.Commentf(string(body))) - c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(body))) - c.Assert(json.Unmarshal(body, &n2), checker.IsNil) - + n2, err := cli.NetworkCreate(context.Background(), name, options) + c.Assert(err, checker.IsNil) // Full ID always works out, err = d.Cmd("network", "inspect", "--format", "{{.ID}}", n1.ID) c.Assert(err, checker.IsNil, check.Commentf(out)) @@ -1887,18 +1796,16 @@ func (s *DockerSwarmSuite) TestNetworkInspectWithDuplicateNames(c *check.C) { // Name with duplicates out, err = d.Cmd("network", "inspect", "--format", "{{.ID}}", name) c.Assert(err, checker.NotNil, check.Commentf(out)) - c.Assert(out, checker.Contains, "network foo is ambiguous (2 matches found based on name)") + c.Assert(out, checker.Contains, "2 matches found based on name") out, err = d.Cmd("network", "rm", n2.ID) c.Assert(err, checker.IsNil, check.Commentf(out)) - // Duplicates with name but with different driver - networkCreateRequest.NetworkCreate.Driver = "overlay" + // Dupliates with name but with different driver + options.Driver = "overlay" - status, body, err = d.SockRequest("POST", "/networks/create", networkCreateRequest) - c.Assert(err, checker.IsNil, check.Commentf(string(body))) - c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(body))) - c.Assert(json.Unmarshal(body, &n2), checker.IsNil) + n2, err = cli.NetworkCreate(context.Background(), name, options) + c.Assert(err, checker.IsNil) // Full ID always works out, err = d.Cmd("network", "inspect", "--format", "{{.ID}}", n1.ID) @@ -1912,7 +1819,7 @@ func (s *DockerSwarmSuite) TestNetworkInspectWithDuplicateNames(c *check.C) { // Name with duplicates out, err = d.Cmd("network", "inspect", "--format", "{{.ID}}", name) c.Assert(err, checker.NotNil, check.Commentf(out)) - c.Assert(out, checker.Contains, "network foo is ambiguous (2 matches found based on name)") + c.Assert(out, checker.Contains, "2 matches found based on name") } func (s *DockerSwarmSuite) TestSwarmStopSignal(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_swarm_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_swarm_unix_test.go index cffabcc2a..91ddd5f04 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_swarm_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_swarm_unix_test.go @@ -94,7 +94,7 @@ func (s *DockerSwarmSuite) TestSwarmNetworkPluginV2(c *check.C) { time.Sleep(20 * time.Second) - image := "busybox" + image := "busybox:latest" // create a new global service again. _, err = d1.Cmd("service", "create", "--no-resolve-image", "--name", serviceName, "--mode=global", "--network", networkName, image, "top") c.Assert(err, checker.IsNil) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_top_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_top_test.go index ea32fc672..f52f24014 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_top_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_top_test.go @@ -4,8 +4,8 @@ import ( "strings" "github.com/docker/docker/integration-cli/checker" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) func (s *DockerSuite) TestTopMultipleArgs(c *check.C) { @@ -20,7 +20,7 @@ func (s *DockerSuite) TestTopMultipleArgs(c *check.C) { expected = icmd.Expected{Out: "PID"} } result := dockerCmdWithResult("top", cleanedContainerID, "-o", "pid") - c.Assert(result, icmd.Matches, expected) + result.Assert(c, expected) } func (s *DockerSuite) TestTopNonPrivileged(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_update_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_update_test.go index c898690c5..5b9b7304c 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_update_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_update_test.go @@ -6,8 +6,8 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) func (s *DockerSuite) TestUpdateRestartPolicy(c *check.C) { diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_update_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_update_unix_test.go index be2274bb3..c3dfbcc9c 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_update_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_update_unix_test.go @@ -3,6 +3,7 @@ package main import ( + "context" "encoding/json" "fmt" "os/exec" @@ -10,6 +11,7 @@ import ( "time" "github.com/docker/docker/api/types" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/request" "github.com/docker/docker/pkg/parsers/kernel" @@ -137,7 +139,7 @@ func (s *DockerSuite) TestUpdateKernelMemory(c *check.C) { func (s *DockerSuite) TestUpdateKernelMemoryUninitialized(c *check.C) { testRequires(c, DaemonIsLinux, kernelMemorySupport) - isNewKernel := kernel.CheckKernelVersion(4, 6, 0) + isNewKernel := CheckKernelVersion(4, 6, 0) name := "test-update-container" dockerCmd(c, "run", "-d", "--name", name, "busybox", "top") _, _, err := dockerCmdWithError("update", "--kernel-memory", "100M", name) @@ -169,6 +171,18 @@ func (s *DockerSuite) TestUpdateKernelMemoryUninitialized(c *check.C) { c.Assert(strings.TrimSpace(out), checker.Equals, "314572800") } +// GetKernelVersion gets the current kernel version. +func GetKernelVersion() *kernel.VersionInfo { + v, _ := kernel.ParseRelease(testEnv.DaemonInfo.KernelVersion) + return v +} + +// CheckKernelVersion checks if current kernel is newer than (or equal to) +// the given version. +func CheckKernelVersion(k, major, minor int) bool { + return kernel.CompareKernelVersion(*GetKernelVersion(), kernel.VersionInfo{Kernel: k, Major: major, Minor: minor}) > 0 +} + func (s *DockerSuite) TestUpdateSwapMemoryOnly(c *check.C) { testRequires(c, DaemonIsLinux) testRequires(c, memoryLimitSupport) @@ -295,20 +309,26 @@ func (s *DockerSuite) TestUpdateWithNanoCPUs(c *check.C) { out, _ = dockerCmd(c, "exec", "top", "sh", "-c", fmt.Sprintf("cat %s && cat %s", file1, file2)) c.Assert(strings.TrimSpace(out), checker.Equals, "50000\n100000") - out = inspectField(c, "top", "HostConfig.NanoCpus") - c.Assert(out, checker.Equals, "5e+08", check.Commentf("setting the Nano CPUs failed")) + clt, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + inspect, err := clt.ContainerInspect(context.Background(), "top") + c.Assert(err, checker.IsNil) + c.Assert(inspect.HostConfig.NanoCPUs, checker.Equals, int64(500000000)) + out = inspectField(c, "top", "HostConfig.CpuQuota") c.Assert(out, checker.Equals, "0", check.Commentf("CPU CFS quota should be 0")) out = inspectField(c, "top", "HostConfig.CpuPeriod") c.Assert(out, checker.Equals, "0", check.Commentf("CPU CFS period should be 0")) - out, _, err := dockerCmdWithError("update", "--cpu-quota", "80000", "top") + out, _, err = dockerCmdWithError("update", "--cpu-quota", "80000", "top") c.Assert(err, checker.NotNil) c.Assert(out, checker.Contains, "Conflicting options: CPU Quota cannot be updated as NanoCPUs has already been set") out, _ = dockerCmd(c, "update", "--cpus", "0.8", "top") - out = inspectField(c, "top", "HostConfig.NanoCpus") - c.Assert(out, checker.Equals, "8e+08", check.Commentf("updating the Nano CPUs failed")) + inspect, err = clt.ContainerInspect(context.Background(), "top") + c.Assert(err, checker.IsNil) + c.Assert(inspect.HostConfig.NanoCPUs, checker.Equals, int64(800000000)) + out = inspectField(c, "top", "HostConfig.CpuQuota") c.Assert(out, checker.Equals, "0", check.Commentf("CPU CFS quota should be 0")) out = inspectField(c, "top", "HostConfig.CpuPeriod") diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_userns_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_userns_test.go index 8311401d0..54cfdd179 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_userns_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_userns_test.go @@ -15,7 +15,6 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/system" - "github.com/docker/docker/pkg/testutil" "github.com/go-check/check" ) @@ -62,15 +61,15 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *check.C) { c.Assert(err, checker.IsNil, check.Commentf("Could not inspect running container: out: %q", pid)) // check the uid and gid maps for the PID to ensure root is remapped // (cmd = cat /proc//uid_map | grep -E '0\s+9999\s+1') - out, rc1, err := testutil.RunCommandPipelineWithOutput( + out, err = RunCommandPipelineWithOutput( exec.Command("cat", "/proc/"+strings.TrimSpace(pid)+"/uid_map"), exec.Command("grep", "-E", fmt.Sprintf("0[[:space:]]+%d[[:space:]]+", uid))) - c.Assert(rc1, checker.Equals, 0, check.Commentf("Didn't match uid_map: output: %s", out)) + c.Assert(err, check.IsNil) - out, rc2, err := testutil.RunCommandPipelineWithOutput( + out, err = RunCommandPipelineWithOutput( exec.Command("cat", "/proc/"+strings.TrimSpace(pid)+"/gid_map"), exec.Command("grep", "-E", fmt.Sprintf("0[[:space:]]+%d[[:space:]]+", gid))) - c.Assert(rc2, checker.Equals, 0, check.Commentf("Didn't match gid_map: output: %s", out)) + c.Assert(err, check.IsNil) // check that the touched file is owned by remapped uid:gid stat, err := system.Stat(filepath.Join(tmpDir, "testfile")) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_version_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_version_test.go deleted file mode 100644 index 074a7db47..000000000 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_version_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package main - -import ( - "strings" - - "github.com/docker/docker/integration-cli/checker" - "github.com/go-check/check" -) - -// ensure docker version works -func (s *DockerSuite) TestVersionEnsureSucceeds(c *check.C) { - out, _ := dockerCmd(c, "version") - stringsToCheck := map[string]int{ - "Client:": 1, - "Server:": 1, - " Version:": 2, - " API version:": 2, - " Go version:": 2, - " Git commit:": 2, - " OS/Arch:": 2, - " Built:": 2, - } - - for k, v := range stringsToCheck { - c.Assert(strings.Count(out, k), checker.Equals, v, check.Commentf("The count of %v in %s does not match excepted", k, out)) - } -} - -// ensure the Windows daemon return the correct platform string -func (s *DockerSuite) TestVersionPlatform_w(c *check.C) { - testRequires(c, DaemonIsWindows) - testVersionPlatform(c, "windows/amd64") -} - -// ensure the Linux daemon return the correct platform string -func (s *DockerSuite) TestVersionPlatform_l(c *check.C) { - testRequires(c, DaemonIsLinux) - testVersionPlatform(c, "linux") -} - -func testVersionPlatform(c *check.C, platform string) { - out, _ := dockerCmd(c, "version") - expected := "OS/Arch: " + platform - - split := strings.Split(out, "\n") - c.Assert(len(split) >= 14, checker.Equals, true, check.Commentf("got %d lines from version", len(split))) - - // Verify the second 'OS/Arch' matches the platform. Experimental has - // more lines of output than 'regular' - bFound := false - for i := 14; i < len(split); i++ { - if strings.Contains(split[i], expected) { - bFound = true - break - } - } - c.Assert(bFound, checker.Equals, true, check.Commentf("Could not find server '%s' in '%s'", expected, out)) -} diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_volume_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_volume_test.go index e0bf7cafe..fc930d319 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_volume_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_volume_test.go @@ -3,17 +3,20 @@ package main import ( "fmt" "io/ioutil" - "net/http" "os" "os/exec" "path/filepath" "strings" + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/mount" + "github.com/docker/docker/api/types/network" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli/build" - "github.com/docker/docker/integration-cli/request" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" + "golang.org/x/net/context" ) func (s *DockerSuite) TestVolumeCLICreate(c *check.C) { @@ -55,15 +58,12 @@ func (s *DockerSuite) TestVolumeCLIInspectMulti(c *check.C) { dockerCmd(c, "volume", "create", "test3") result := dockerCmdWithResult("volume", "inspect", "--format={{ .Name }}", "test1", "test2", "doesnotexist", "test3") - c.Assert(result, icmd.Matches, icmd.Expected{ + result.Assert(c, icmd.Expected{ ExitCode: 1, Err: "No such volume: doesnotexist", }) out := result.Stdout() - outArr := strings.Split(strings.TrimSpace(out), "\n") - c.Assert(len(outArr), check.Equals, 3, check.Commentf("\n%s", out)) - c.Assert(out, checker.Contains, "test1") c.Assert(out, checker.Contains, "test2") c.Assert(out, checker.Contains, "test3") @@ -78,11 +78,8 @@ func (s *DockerSuite) TestVolumeCLILs(c *check.C) { dockerCmd(c, "volume", "create", "soo") dockerCmd(c, "run", "-v", "soo:"+prefix+"/foo", "busybox", "ls", "/") - out, _ := dockerCmd(c, "volume", "ls") - outArr := strings.Split(strings.TrimSpace(out), "\n") - c.Assert(len(outArr), check.Equals, 4, check.Commentf("\n%s", out)) - - assertVolList(c, out, []string{"aaa", "soo", "test"}) + out, _ := dockerCmd(c, "volume", "ls", "-q") + assertVolumesInList(c, out, []string{"aaa", "soo", "test"}) } func (s *DockerSuite) TestVolumeLsFormat(c *check.C) { @@ -91,12 +88,7 @@ func (s *DockerSuite) TestVolumeLsFormat(c *check.C) { dockerCmd(c, "volume", "create", "soo") out, _ := dockerCmd(c, "volume", "ls", "--format", "{{.Name}}") - lines := strings.Split(strings.TrimSpace(string(out)), "\n") - - expected := []string{"aaa", "soo", "test"} - var names []string - names = append(names, lines...) - c.Assert(expected, checker.DeepEquals, names, check.Commentf("Expected array with truncated names: %v, got: %v", expected, names)) + assertVolumesInList(c, out, []string{"aaa", "soo", "test"}) } func (s *DockerSuite) TestVolumeLsFormatDefaultFormat(c *check.C) { @@ -115,12 +107,7 @@ func (s *DockerSuite) TestVolumeLsFormatDefaultFormat(c *check.C) { c.Assert(err, checker.IsNil) out, _ := dockerCmd(c, "--config", d, "volume", "ls") - lines := strings.Split(strings.TrimSpace(string(out)), "\n") - - expected := []string{"aaa default", "soo default", "test default"} - var names []string - names = append(names, lines...) - c.Assert(expected, checker.DeepEquals, names, check.Commentf("Expected array with truncated names: %v, got: %v", expected, names)) + assertVolumesInList(c, out, []string{"aaa default", "soo default", "test default"}) } // assertVolList checks volume retrieved with ls command @@ -139,6 +126,20 @@ func assertVolList(c *check.C, out string, expectVols []string) { c.Assert(volList, checker.DeepEquals, expectVols) } +func assertVolumesInList(c *check.C, out string, expected []string) { + lines := strings.Split(strings.TrimSpace(string(out)), "\n") + for _, expect := range expected { + found := false + for _, v := range lines { + found = v == expect + if found { + break + } + } + c.Assert(found, checker.Equals, true, check.Commentf("Expected volume not found: %v, got: %v", expect, lines)) + } +} + func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *check.C) { prefix, _ := getPrefixAndSlashFromDaemonPlatform() dockerCmd(c, "volume", "create", "testnotinuse1") @@ -210,10 +211,6 @@ func (s *DockerSuite) TestVolumeCLIRm(c *check.C) { dockerCmd(c, "volume", "rm", id) dockerCmd(c, "volume", "rm", "test") - out, _ = dockerCmd(c, "volume", "ls") - outArr := strings.Split(strings.TrimSpace(out), "\n") - c.Assert(len(outArr), check.Equals, 1, check.Commentf("%s\n", out)) - volumeID := "testing" dockerCmd(c, "run", "-v", volumeID+":"+prefix+"/foo", "--name=test", "busybox", "sh", "-c", "echo hello > /foo/bar") @@ -404,10 +401,6 @@ func (s *DockerSuite) TestVolumeCLIRmForceUsage(c *check.C) { dockerCmd(c, "volume", "rm", "-f", id) dockerCmd(c, "volume", "rm", "--force", "nonexist") - - out, _ = dockerCmd(c, "volume", "ls") - outArr := strings.Split(strings.TrimSpace(out), "\n") - c.Assert(len(outArr), check.Equals, 1, check.Commentf("%s\n", out)) } func (s *DockerSuite) TestVolumeCLIRmForce(c *check.C) { @@ -607,25 +600,28 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c *check.C err := os.MkdirAll("/tmp/data", 0755) c.Assert(err, checker.IsNil) // Mounts is available in API - status, body, err := request.SockRequest("POST", "/containers/create?name=app", map[string]interface{}{ - "Image": "busybox", - "Cmd": []string{"top"}, - "HostConfig": map[string]interface{}{ - "VolumesFrom": []string{ - "data1", - "data2", + cli, err := client.NewEnvClient() + c.Assert(err, checker.IsNil) + defer cli.Close() + + config := container.Config{ + Cmd: []string{"top"}, + Image: "busybox", + } + + hostConfig := container.HostConfig{ + VolumesFrom: []string{"data1", "data2"}, + Mounts: []mount.Mount{ + { + Type: "bind", + Source: "/tmp/data", + Target: "/tmp/data", }, - "Mounts": []map[string]interface{}{ - { - "Type": "bind", - "Source": "/tmp/data", - "Target": "/tmp/data", - }, - }}, - }, daemonHost()) - - c.Assert(err, checker.IsNil, check.Commentf(string(body))) - c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(body))) + }, + } + _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, "app") + + c.Assert(err, checker.IsNil) // No volume will be referenced (mount is /tmp/data), this is backward compatible out, _ = dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "app") diff --git a/vendor/github.com/docker/docker/integration-cli/docker_cli_wait_test.go b/vendor/github.com/docker/docker/integration-cli/docker_cli_wait_test.go index 6f45bf07a..e8047042d 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_cli_wait_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_cli_wait_test.go @@ -7,8 +7,8 @@ import ( "time" "github.com/docker/docker/integration-cli/checker" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) // non-blocking wait with 0 exit code diff --git a/vendor/github.com/docker/docker/integration-cli/docker_deprecated_api_v124_test.go b/vendor/github.com/docker/docker/integration-cli/docker_deprecated_api_v124_test.go index a3a8fbdb6..edf3e570f 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_deprecated_api_v124_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_deprecated_api_v124_test.go @@ -9,7 +9,6 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/request" - "github.com/docker/docker/pkg/testutil" "github.com/go-check/check" ) @@ -23,10 +22,14 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartHostConfig(c *check.C) { config := map[string]interface{}{ "Binds": []string{"/aa:/bb"}, } - status, body, err := request.SockRequest("POST", "/containers/"+name+"/start", config, daemonHost()) + res, body, err := request.Post("/containers/"+name+"/start", request.JSONBody(config)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusBadRequest) - c.Assert(string(body), checker.Contains, "was deprecated since v1.10") + + buf, err := request.ReadBody(body) + c.Assert(err, checker.IsNil) + + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + c.Assert(string(buf), checker.Contains, "was deprecated since API v1.22") } func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumeBinds(c *check.C) { @@ -42,17 +45,17 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumeBinds(c *check.C) { "Volumes": map[string]struct{}{path: {}}, } - status, _, err := request.SockRequest("POST", formatV123StartAPIURL("/containers/create?name="+name), config, daemonHost()) + res, _, err := request.Post(formatV123StartAPIURL("/containers/create?name="+name), request.JSONBody(config)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) + c.Assert(res.StatusCode, checker.Equals, http.StatusCreated) - bindPath := testutil.RandomTmpDirPath("test", testEnv.DaemonPlatform()) + bindPath := RandomTmpDirPath("test", testEnv.DaemonPlatform()) config = map[string]interface{}{ "Binds": []string{bindPath + ":" + path}, } - status, _, err = request.SockRequest("POST", formatV123StartAPIURL("/containers/"+name+"/start"), config, daemonHost()) + res, _, err = request.Post(formatV123StartAPIURL("/containers/"+name+"/start"), request.JSONBody(config)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNoContent) + c.Assert(res.StatusCode, checker.Equals, http.StatusNoContent) pth, err := inspectMountSourceField(name, path) c.Assert(err, checker.IsNil) @@ -69,20 +72,24 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartDupVolumeBinds(c *check.C) "Volumes": map[string]struct{}{"/tmp": {}}, } - status, _, err := request.SockRequest("POST", formatV123StartAPIURL("/containers/create?name="+name), config, daemonHost()) + res, _, err := request.Post(formatV123StartAPIURL("/containers/create?name="+name), request.JSONBody(config)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) + c.Assert(res.StatusCode, checker.Equals, http.StatusCreated) - bindPath1 := testutil.RandomTmpDirPath("test1", testEnv.DaemonPlatform()) - bindPath2 := testutil.RandomTmpDirPath("test2", testEnv.DaemonPlatform()) + bindPath1 := RandomTmpDirPath("test1", testEnv.DaemonPlatform()) + bindPath2 := RandomTmpDirPath("test2", testEnv.DaemonPlatform()) config = map[string]interface{}{ "Binds": []string{bindPath1 + ":/tmp", bindPath2 + ":/tmp"}, } - status, body, err := request.SockRequest("POST", formatV123StartAPIURL("/containers/"+name+"/start"), config, daemonHost()) + res, body, err := request.Post(formatV123StartAPIURL("/containers/"+name+"/start"), request.JSONBody(config)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusInternalServerError) - c.Assert(string(body), checker.Contains, "Duplicate mount point", check.Commentf("Expected failure due to duplicate bind mounts to same path, instead got: %q with error: %v", string(body), err)) + + buf, err := request.ReadBody(body) + c.Assert(err, checker.IsNil) + + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + c.Assert(string(buf), checker.Contains, "Duplicate mount point", check.Commentf("Expected failure due to duplicate bind mounts to same path, instead got: %q with error: %v", string(buf), err)) } func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumesFrom(c *check.C) { @@ -99,16 +106,16 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumesFrom(c *check.C) { "Volumes": map[string]struct{}{volPath: {}}, } - status, _, err := request.SockRequest("POST", formatV123StartAPIURL("/containers/create?name="+name), config, daemonHost()) + res, _, err := request.Post(formatV123StartAPIURL("/containers/create?name="+name), request.JSONBody(config)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusCreated) + c.Assert(res.StatusCode, checker.Equals, http.StatusCreated) config = map[string]interface{}{ "VolumesFrom": []string{volName}, } - status, _, err = request.SockRequest("POST", formatV123StartAPIURL("/containers/"+name+"/start"), config, daemonHost()) + res, _, err = request.Post(formatV123StartAPIURL("/containers/"+name+"/start"), request.JSONBody(config)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNoContent) + c.Assert(res.StatusCode, checker.Equals, http.StatusNoContent) pth, err := inspectMountSourceField(name, volPath) c.Assert(err, checker.IsNil) @@ -129,9 +136,9 @@ func (s *DockerSuite) TestDeprecatedPostContainerBindNormalVolume(c *check.C) { dockerCmd(c, "create", "-v", "/foo", "--name=two", "busybox") bindSpec := map[string][]string{"Binds": {fooDir + ":/foo"}} - status, _, err := request.SockRequest("POST", formatV123StartAPIURL("/containers/two/start"), bindSpec, daemonHost()) + res, _, err := request.Post(formatV123StartAPIURL("/containers/two/start"), request.JSONBody(bindSpec)) c.Assert(err, checker.IsNil) - c.Assert(status, checker.Equals, http.StatusNoContent) + c.Assert(res.StatusCode, checker.Equals, http.StatusNoContent) fooDir2, err := inspectMountSourceField("two", "/foo") c.Assert(err, checker.IsNil) @@ -152,9 +159,9 @@ func (s *DockerSuite) TestDeprecatedStartWithTooLowMemoryLimit(c *check.C) { res, body, err := request.Post(formatV123StartAPIURL("/containers/"+containerID+"/start"), request.RawString(config), request.JSON) c.Assert(err, checker.IsNil) - b, err2 := testutil.ReadBody(body) + b, err2 := request.ReadBody(body) c.Assert(err2, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) c.Assert(string(b), checker.Contains, "Minimum memory limit allowed is 4MB") } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_deprecated_api_v124_unix_test.go b/vendor/github.com/docker/docker/integration-cli/docker_deprecated_api_v124_unix_test.go index 5fc6c2ddf..20a888590 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_deprecated_api_v124_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_deprecated_api_v124_unix_test.go @@ -22,7 +22,7 @@ func (s *DockerNetworkSuite) TestDeprecatedDockerNetworkStartAPIWithHostconfig(c "NetworkMode": netName, }, } - _, _, err := request.SockRequest("POST", formatV123StartAPIURL("/containers/"+conName+"/start"), config, daemonHost()) + _, _, err := request.Post(formatV123StartAPIURL("/containers/"+conName+"/start"), request.JSONBody(config)) c.Assert(err, checker.IsNil) c.Assert(waitRun(conName), checker.IsNil) networks := inspectField(c, conName, "NetworkSettings.Networks") diff --git a/vendor/github.com/docker/docker/integration-cli/docker_experimental_network_test.go b/vendor/github.com/docker/docker/integration-cli/docker_experimental_network_test.go index f352050d3..888970a0a 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_experimental_network_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_experimental_network_test.go @@ -9,8 +9,8 @@ import ( "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/pkg/parsers/kernel" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) // ensure Kernel version is >= v3.9 for macvlan support @@ -382,7 +382,7 @@ func (s *DockerSuite) TestDockerNetworkMacVlanBridgeInternalMode(c *check.C) { // access outside of the network should fail result := cli.Docker(cli.Args("exec", "first", "ping", "-c", "1", "-w", "1", "8.8.8.8"), cli.WithTimeout(time.Second)) - c.Assert(result, icmd.Matches, icmd.Expected{Timeout: true}) + result.Assert(c, icmd.Expected{Timeout: true}) // intra-network communications should succeed cli.DockerCmd(c, "exec", "second", "ping", "-c", "1", "first") @@ -421,7 +421,7 @@ func (s *DockerSuite) TestDockerNetworkIpvlanL2InternalMode(c *check.C) { // access outside of the network should fail result := cli.Docker(cli.Args("exec", "first", "ping", "-c", "1", "-w", "1", "8.8.8.8"), cli.WithTimeout(time.Second)) - c.Assert(result, icmd.Matches, icmd.Expected{Timeout: true}) + result.Assert(c, icmd.Expected{Timeout: true}) // intra-network communications should succeed cli.DockerCmd(c, "exec", "second", "ping", "-c", "1", "first") } @@ -461,7 +461,7 @@ func (s *DockerSuite) TestDockerNetworkIpvlanL3InternalMode(c *check.C) { // access outside of the network should fail result := cli.Docker(cli.Args("exec", "first", "ping", "-c", "1", "-w", "1", "8.8.8.8"), cli.WithTimeout(time.Second)) - c.Assert(result, icmd.Matches, icmd.Expected{Timeout: true}) + result.Assert(c, icmd.Expected{Timeout: true}) // intra-network communications should succeed cli.DockerCmd(c, "exec", "second", "ping", "-c", "1", "first") } diff --git a/vendor/github.com/docker/docker/integration-cli/docker_hub_pull_suite_test.go b/vendor/github.com/docker/docker/integration-cli/docker_hub_pull_suite_test.go index 263372087..286a3913c 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_hub_pull_suite_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_hub_pull_suite_test.go @@ -39,7 +39,7 @@ func newDockerHubPullSuite() *DockerHubPullSuite { // SetUpSuite starts the suite daemon. func (s *DockerHubPullSuite) SetUpSuite(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, SameHostDaemon) s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ Experimental: testEnv.ExperimentalDaemon(), }) diff --git a/vendor/github.com/docker/docker/integration-cli/docker_utils_test.go b/vendor/github.com/docker/docker/integration-cli/docker_utils_test.go index 0c0a16483..1bda2c723 100644 --- a/vendor/github.com/docker/docker/integration-cli/docker_utils_test.go +++ b/vendor/github.com/docker/docker/integration-cli/docker_utils_test.go @@ -6,7 +6,6 @@ import ( "fmt" "io" "io/ioutil" - "net/http" "os" "path" "path/filepath" @@ -15,13 +14,15 @@ import ( "time" "github.com/docker/docker/api/types" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/integration-cli/registry" "github.com/docker/docker/integration-cli/request" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" + "golang.org/x/net/context" ) // Deprecated @@ -232,7 +233,7 @@ func readFile(src string, c *check.C) (content string) { } func containerStorageFile(containerID, basename string) string { - return filepath.Join(testEnv.ContainerStoragePath(), containerID, basename) + return filepath.Join(testEnv.PlatformDefaults.ContainerStoragePath, containerID, basename) } // docker commands that use this function must be run with the '-d' switch. @@ -264,20 +265,15 @@ func readContainerFileWithExec(c *check.C, containerID, filename string) []byte // daemonTime provides the current time on the daemon host func daemonTime(c *check.C) time.Time { - if testEnv.LocalDaemon() { + if testEnv.IsLocalDaemon() { return time.Now() } - - status, body, err := request.SockRequest("GET", "/info", nil, daemonHost()) + cli, err := client.NewEnvClient() c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusOK) + defer cli.Close() - type infoJSON struct { - SystemTime string - } - var info infoJSON - err = json.Unmarshal(body, &info) - c.Assert(err, check.IsNil, check.Commentf("unable to unmarshal GET /info response")) + info, err := cli.Info(context.Background()) + c.Assert(err, check.IsNil) dt, err := time.Parse(time.RFC3339Nano, info.SystemTime) c.Assert(err, check.IsNil, check.Commentf("invalid time format in GET /info response")) @@ -376,10 +372,11 @@ func waitInspectWithArgs(name, expr, expected string, timeout time.Duration, arg } func getInspectBody(c *check.C, version, id string) []byte { - endpoint := fmt.Sprintf("/%s/containers/%s/json", version, id) - status, body, err := request.SockRequest("GET", endpoint, nil, daemonHost()) + cli, err := request.NewEnvClientWithVersion(version) + c.Assert(err, check.IsNil) + defer cli.Close() + _, body, err := cli.ContainerInspectWithRaw(context.Background(), id, false) c.Assert(err, check.IsNil) - c.Assert(status, check.Equals, http.StatusOK) return body } @@ -406,20 +403,17 @@ func minimalBaseImage() string { } func getGoroutineNumber() (int, error) { - i := struct { - NGoroutines int - }{} - status, b, err := request.SockRequest("GET", "/info", nil, daemonHost()) + cli, err := client.NewEnvClient() if err != nil { return 0, err } - if status != http.StatusOK { - return 0, fmt.Errorf("http status code: %d", status) - } - if err := json.Unmarshal(b, &i); err != nil { + defer cli.Close() + + info, err := cli.Info(context.Background()) + if err != nil { return 0, err } - return i.NGoroutines, nil + return info.NGoroutines, nil } func waitForGoroutines(expected int) error { diff --git a/vendor/github.com/docker/docker/integration-cli/environment/clean.go b/vendor/github.com/docker/docker/integration-cli/environment/clean.go deleted file mode 100644 index 809baa7b5..000000000 --- a/vendor/github.com/docker/docker/integration-cli/environment/clean.go +++ /dev/null @@ -1,216 +0,0 @@ -package environment - -import ( - "encoding/json" - "fmt" - "net/http" - "regexp" - "strings" - - "github.com/docker/docker/api/types" - volumetypes "github.com/docker/docker/api/types/volume" - "github.com/docker/docker/integration-cli/request" - icmd "github.com/docker/docker/pkg/testutil/cmd" -) - -type testingT interface { - logT - Fatalf(string, ...interface{}) -} - -type logT interface { - Logf(string, ...interface{}) -} - -// Clean the environment, preserving protected objects (images, containers, ...) -// and removing everything else. It's meant to run after any tests so that they don't -// depend on each others. -func (e *Execution) Clean(t testingT, dockerBinary string) { - if (e.DaemonPlatform() != "windows") || (e.DaemonPlatform() == "windows" && e.Isolation() == "hyperv") { - unpauseAllContainers(t, dockerBinary) - } - deleteAllContainers(t, dockerBinary) - deleteAllImages(t, dockerBinary, e.protectedElements.images) - deleteAllVolumes(t, dockerBinary) - deleteAllNetworks(t, dockerBinary, e.DaemonPlatform()) - if e.DaemonPlatform() == "linux" { - deleteAllPlugins(t, dockerBinary) - } -} - -func unpauseAllContainers(t testingT, dockerBinary string) { - containers := getPausedContainers(t, dockerBinary) - if len(containers) > 0 { - icmd.RunCommand(dockerBinary, append([]string{"unpause"}, containers...)...).Assert(t, icmd.Success) - } -} - -func getPausedContainers(t testingT, dockerBinary string) []string { - result := icmd.RunCommand(dockerBinary, "ps", "-f", "status=paused", "-q", "-a") - result.Assert(t, icmd.Success) - return strings.Fields(result.Combined()) -} - -var alreadyExists = regexp.MustCompile(`Error response from daemon: removal of container (\w+) is already in progress`) - -func deleteAllContainers(t testingT, dockerBinary string) { - containers := getAllContainers(t, dockerBinary) - if len(containers) > 0 { - result := icmd.RunCommand(dockerBinary, append([]string{"rm", "-fv"}, containers...)...) - if result.Error != nil { - // If the error is "No such container: ..." this means the container doesn't exists anymore, - // or if it is "... removal of container ... is already in progress" it will be removed eventually. - // We can safely ignore those. - if strings.Contains(result.Stderr(), "No such container") || alreadyExists.MatchString(result.Stderr()) { - return - } - t.Fatalf("error removing containers %v : %v (%s)", containers, result.Error, result.Combined()) - } - } -} - -func getAllContainers(t testingT, dockerBinary string) []string { - result := icmd.RunCommand(dockerBinary, "ps", "-q", "-a") - result.Assert(t, icmd.Success) - return strings.Fields(result.Combined()) -} - -func deleteAllImages(t testingT, dockerBinary string, protectedImages map[string]struct{}) { - result := icmd.RunCommand(dockerBinary, "images", "--digests") - result.Assert(t, icmd.Success) - lines := strings.Split(string(result.Combined()), "\n")[1:] - imgMap := map[string]struct{}{} - for _, l := range lines { - if l == "" { - continue - } - fields := strings.Fields(l) - imgTag := fields[0] + ":" + fields[1] - if _, ok := protectedImages[imgTag]; !ok { - if fields[0] == "" || fields[1] == "" { - if fields[2] != "" { - imgMap[fields[0]+"@"+fields[2]] = struct{}{} - } else { - imgMap[fields[3]] = struct{}{} - } - // continue - } else { - imgMap[imgTag] = struct{}{} - } - } - } - if len(imgMap) != 0 { - imgs := make([]string, 0, len(imgMap)) - for k := range imgMap { - imgs = append(imgs, k) - } - icmd.RunCommand(dockerBinary, append([]string{"rmi", "-f"}, imgs...)...).Assert(t, icmd.Success) - } -} - -func deleteAllVolumes(t testingT, dockerBinary string) { - volumes, err := getAllVolumes() - if err != nil { - t.Fatalf("%v", err) - } - var errs []string - for _, v := range volumes { - status, b, err := request.SockRequest("DELETE", "/volumes/"+v.Name, nil, request.DaemonHost()) - if err != nil { - errs = append(errs, err.Error()) - continue - } - if status != http.StatusNoContent { - errs = append(errs, fmt.Sprintf("error deleting volume %s: %s", v.Name, string(b))) - } - } - if len(errs) > 0 { - t.Fatalf("%v", strings.Join(errs, "\n")) - } -} - -func getAllVolumes() ([]*types.Volume, error) { - var volumes volumetypes.VolumesListOKBody - _, b, err := request.SockRequest("GET", "/volumes", nil, request.DaemonHost()) - if err != nil { - return nil, err - } - if err := json.Unmarshal(b, &volumes); err != nil { - return nil, err - } - return volumes.Volumes, nil -} - -func deleteAllNetworks(t testingT, dockerBinary string, daemonPlatform string) { - networks, err := getAllNetworks() - if err != nil { - t.Fatalf("%v", err) - } - var errs []string - for _, n := range networks { - if n.Name == "bridge" || n.Name == "none" || n.Name == "host" { - continue - } - if daemonPlatform == "windows" && strings.ToLower(n.Name) == "nat" { - // nat is a pre-defined network on Windows and cannot be removed - continue - } - status, b, err := request.SockRequest("DELETE", "/networks/"+n.Name, nil, request.DaemonHost()) - if err != nil { - errs = append(errs, err.Error()) - continue - } - if status != http.StatusNoContent { - errs = append(errs, fmt.Sprintf("error deleting network %s: %s", n.Name, string(b))) - } - } - if len(errs) > 0 { - t.Fatalf("%v", strings.Join(errs, "\n")) - } -} - -func getAllNetworks() ([]types.NetworkResource, error) { - var networks []types.NetworkResource - _, b, err := request.SockRequest("GET", "/networks", nil, request.DaemonHost()) - if err != nil { - return nil, err - } - if err := json.Unmarshal(b, &networks); err != nil { - return nil, err - } - return networks, nil -} - -func deleteAllPlugins(t testingT, dockerBinary string) { - plugins, err := getAllPlugins() - if err != nil { - t.Fatalf("%v", err) - } - var errs []string - for _, p := range plugins { - pluginName := p.Name - status, b, err := request.SockRequest("DELETE", "/plugins/"+pluginName+"?force=1", nil, request.DaemonHost()) - if err != nil { - errs = append(errs, err.Error()) - continue - } - if status != http.StatusOK { - errs = append(errs, fmt.Sprintf("error deleting plugin %s: %s", p.Name, string(b))) - } - } - if len(errs) > 0 { - t.Fatalf("%v", strings.Join(errs, "\n")) - } -} - -func getAllPlugins() (types.PluginsListResponse, error) { - var plugins types.PluginsListResponse - _, b, err := request.SockRequest("GET", "/plugins", nil, request.DaemonHost()) - if err != nil { - return nil, err - } - if err := json.Unmarshal(b, &plugins); err != nil { - return nil, err - } - return plugins, nil -} diff --git a/vendor/github.com/docker/docker/integration-cli/environment/environment.go b/vendor/github.com/docker/docker/integration-cli/environment/environment.go index a8a104590..4e04ba76f 100644 --- a/vendor/github.com/docker/docker/integration-cli/environment/environment.go +++ b/vendor/github.com/docker/docker/integration-cli/environment/environment.go @@ -1,19 +1,11 @@ package environment import ( - "fmt" - "io/ioutil" "os" + "os/exec" - "path/filepath" - "strconv" - "strings" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/client" - "github.com/docker/docker/opts" - "golang.org/x/net/context" + "github.com/docker/docker/internal/test/environment" ) var ( @@ -23,89 +15,28 @@ var ( func init() { if DefaultClientBinary == "" { - // TODO: to be removed once we no longer depend on the docker cli for integration tests - //panic("TEST_CLIENT_BINARY must be set") DefaultClientBinary = "docker" } } -// Execution holds informations about the test execution environment. +// Execution contains information about the current test execution and daemon +// under test type Execution struct { - daemonPlatform string - localDaemon bool - experimentalDaemon bool - daemonStorageDriver string - isolation container.Isolation - daemonPid int - daemonKernelVersion string - // For a local daemon on Linux, these values will be used for testing - // user namespace support as the standard graph path(s) will be - // appended with the root remapped uid.gid prefix - dockerBasePath string - volumesConfigPath string - containerStoragePath string - // baseImage is the name of the base image for testing - // Environment variable WINDOWS_BASE_IMAGE can override this - baseImage string + environment.Execution dockerBinary string +} - protectedElements protectedElements +// DockerBinary returns the docker binary for this testing environment +func (e *Execution) DockerBinary() string { + return e.dockerBinary } -// New creates a new Execution struct +// New returns details about the testing environment func New() (*Execution, error) { - localDaemon := true - // Deterministically working out the environment in which CI is running - // to evaluate whether the daemon is local or remote is not possible through - // a build tag. - // - // For example Windows to Linux CI under Jenkins tests the 64-bit - // Windows binary build with the daemon build tag, but calls a remote - // Linux daemon. - // - // We can't just say if Windows then assume the daemon is local as at - // some point, we will be testing the Windows CLI against a Windows daemon. - // - // Similarly, it will be perfectly valid to also run CLI tests from - // a Linux CLI (built with the daemon tag) against a Windows daemon. - if len(os.Getenv("DOCKER_REMOTE_DAEMON")) > 0 { - localDaemon = false - } - info, err := getDaemonDockerInfo() + env, err := environment.New() if err != nil { return nil, err } - daemonPlatform := info.OSType - if daemonPlatform != "linux" && daemonPlatform != "windows" { - return nil, fmt.Errorf("Cannot run tests against platform: %s", daemonPlatform) - } - baseImage := "scratch" - volumesConfigPath := filepath.Join(info.DockerRootDir, "volumes") - containerStoragePath := filepath.Join(info.DockerRootDir, "containers") - // Make sure in context of daemon, not the local platform. Note we can't - // use filepath.FromSlash or ToSlash here as they are a no-op on Unix. - if daemonPlatform == "windows" { - volumesConfigPath = strings.Replace(volumesConfigPath, `/`, `\`, -1) - containerStoragePath = strings.Replace(containerStoragePath, `/`, `\`, -1) - - baseImage = "microsoft/windowsservercore" - if len(os.Getenv("WINDOWS_BASE_IMAGE")) > 0 { - baseImage = os.Getenv("WINDOWS_BASE_IMAGE") - fmt.Println("INFO: Windows Base image is ", baseImage) - } - } else { - volumesConfigPath = strings.Replace(volumesConfigPath, `\`, `/`, -1) - containerStoragePath = strings.Replace(containerStoragePath, `\`, `/`, -1) - } - - var daemonPid int - dest := os.Getenv("DEST") - b, err := ioutil.ReadFile(filepath.Join(dest, "docker.pid")) - if err == nil { - if p, err := strconv.ParseInt(string(b), 10, 32); err == nil { - daemonPid = int(p) - } - } dockerBinary, err := exec.LookPath(DefaultClientBinary) if err != nil { @@ -113,117 +44,36 @@ func New() (*Execution, error) { } return &Execution{ - localDaemon: localDaemon, - daemonPlatform: daemonPlatform, - daemonStorageDriver: info.Driver, - daemonKernelVersion: info.KernelVersion, - dockerBasePath: info.DockerRootDir, - volumesConfigPath: volumesConfigPath, - containerStoragePath: containerStoragePath, - isolation: info.Isolation, - daemonPid: daemonPid, - experimentalDaemon: info.ExperimentalBuild, - baseImage: baseImage, - dockerBinary: dockerBinary, - protectedElements: protectedElements{ - images: map[string]struct{}{}, - }, + Execution: *env, + dockerBinary: dockerBinary, }, nil } -func getDaemonDockerInfo() (types.Info, error) { - // FIXME(vdemeester) should be safe to use as is - client, err := client.NewEnvClient() - if err != nil { - return types.Info{}, err - } - return client.Info(context.Background()) + +// DockerBasePath is the base path of the docker folder (by default it is -/var/run/docker) +// TODO: remove +// Deprecated: use Execution.DaemonInfo.DockerRootDir +func (e *Execution) DockerBasePath() string { + return e.DaemonInfo.DockerRootDir } -// LocalDaemon is true if the daemon under test is on the same -// host as the CLI. -func (e *Execution) LocalDaemon() bool { - return e.localDaemon +// ExperimentalDaemon tell whether the main daemon has +// experimental features enabled or not +// Deprecated: use DaemonInfo.ExperimentalBuild +func (e *Execution) ExperimentalDaemon() bool { + return e.DaemonInfo.ExperimentalBuild } // DaemonPlatform is held globally so that tests can make intelligent // decisions on how to configure themselves according to the platform // of the daemon. This is initialized in docker_utils by sending // a version call to the daemon and examining the response header. +// Deprecated: use Execution.DaemonInfo.OSType func (e *Execution) DaemonPlatform() string { - return e.daemonPlatform -} - -// DockerBasePath is the base path of the docker folder (by default it is -/var/run/docker) -func (e *Execution) DockerBasePath() string { - return e.dockerBasePath -} - -// VolumesConfigPath is the path of the volume configuration for the testing daemon -func (e *Execution) VolumesConfigPath() string { - return e.volumesConfigPath -} - -// ContainerStoragePath is the path where the container are stored for the testing daemon -func (e *Execution) ContainerStoragePath() string { - return e.containerStoragePath -} - -// DaemonStorageDriver is held globally so that tests can know the storage -// driver of the daemon. This is initialized in docker_utils by sending -// a version call to the daemon and examining the response header. -func (e *Execution) DaemonStorageDriver() string { - return e.daemonStorageDriver -} - -// Isolation is the isolation mode of the daemon under test -func (e *Execution) Isolation() container.Isolation { - return e.isolation -} - -// DaemonPID is the pid of the main test daemon -func (e *Execution) DaemonPID() int { - return e.daemonPid -} - -// ExperimentalDaemon tell whether the main daemon has -// experimental features enabled or not -func (e *Execution) ExperimentalDaemon() bool { - return e.experimentalDaemon + return e.DaemonInfo.OSType } // MinimalBaseImage is the image used for minimal builds (it depends on the platform) +// Deprecated: use Execution.PlatformDefaults.BaseImage func (e *Execution) MinimalBaseImage() string { - return e.baseImage -} - -// DaemonKernelVersion is the kernel version of the daemon as a string, as returned -// by an INFO call to the daemon. -func (e *Execution) DaemonKernelVersion() string { - return e.daemonKernelVersion -} - -// DaemonKernelVersionNumeric is the kernel version of the daemon as an integer. -// Mostly useful on Windows where DaemonKernelVersion holds the full string such -// as `10.0 14393 (14393.447.amd64fre.rs1_release_inmarket.161102-0100)`, but -// integration tests really only need the `14393` piece to make decisions. -func (e *Execution) DaemonKernelVersionNumeric() int { - if e.daemonPlatform != "windows" { - return -1 - } - v, _ := strconv.Atoi(strings.Split(e.daemonKernelVersion, " ")[1]) - return v -} - -// DockerBinary returns the docker binary for this testing environment -func (e *Execution) DockerBinary() string { - return e.dockerBinary -} - -// DaemonHost return the daemon host string for this test execution -func DaemonHost() string { - daemonURLStr := "unix://" + opts.DefaultUnixSocket - if daemonHostVar := os.Getenv("DOCKER_HOST"); daemonHostVar != "" { - daemonURLStr = daemonHostVar - } - return daemonURLStr + return e.PlatformDefaults.BaseImage } diff --git a/vendor/github.com/docker/docker/integration-cli/environment/protect.go b/vendor/github.com/docker/docker/integration-cli/environment/protect.go deleted file mode 100644 index 2b0dd6df2..000000000 --- a/vendor/github.com/docker/docker/integration-cli/environment/protect.go +++ /dev/null @@ -1,12 +0,0 @@ -package environment - -// ProtectImage adds the specified image(s) to be protected in case of clean -func (e *Execution) ProtectImage(t testingT, images ...string) { - for _, image := range images { - e.protectedElements.images[image] = struct{}{} - } -} - -type protectedElements struct { - images map[string]struct{} -} diff --git a/vendor/github.com/docker/docker/integration-cli/fixtures/load/frozen.go b/vendor/github.com/docker/docker/integration-cli/fixtures/load/frozen.go index 13cd393f3..4bec323b5 100644 --- a/vendor/github.com/docker/docker/integration-cli/fixtures/load/frozen.go +++ b/vendor/github.com/docker/docker/integration-cli/fixtures/load/frozen.go @@ -9,21 +9,27 @@ import ( "strings" "sync" + "context" + + "github.com/docker/docker/api/types" + "github.com/docker/docker/client" + "github.com/docker/docker/pkg/jsonmessage" + "github.com/docker/docker/pkg/term" "github.com/pkg/errors" ) -var frozenImgDir = "/docker-frozen-images" +const frozenImgDir = "/docker-frozen-images" // FrozenImagesLinux loads the frozen image set for the integration suite // If the images are not available locally it will download them // TODO: This loads whatever is in the frozen image dir, regardless of what // images were passed in. If the images need to be downloaded, then it will respect // the passed in images -func FrozenImagesLinux(dockerBinary string, images ...string) error { +func FrozenImagesLinux(client client.APIClient, images ...string) error { imgNS := os.Getenv("TEST_IMAGE_NAMESPACE") var loadImages []struct{ srcName, destName string } for _, img := range images { - if err := exec.Command(dockerBinary, "inspect", "--type=image", img).Run(); err != nil { + if !imageExists(client, img) { srcName := img // hello-world:latest gets re-tagged as hello-world:frozen // there are some tests that use hello-world:latest specifically so it pulls @@ -46,35 +52,41 @@ func FrozenImagesLinux(dockerBinary string, images ...string) error { return nil } + ctx := context.Background() fi, err := os.Stat(frozenImgDir) if err != nil || !fi.IsDir() { srcImages := make([]string, 0, len(loadImages)) for _, img := range loadImages { srcImages = append(srcImages, img.srcName) } - if err := pullImages(dockerBinary, srcImages); err != nil { + if err := pullImages(ctx, client, srcImages); err != nil { return errors.Wrap(err, "error pulling image list") } } else { - if err := loadFrozenImages(dockerBinary); err != nil { + if err := loadFrozenImages(ctx, client); err != nil { return err } } for _, img := range loadImages { if img.srcName != img.destName { - if out, err := exec.Command(dockerBinary, "tag", img.srcName, img.destName).CombinedOutput(); err != nil { - return errors.Errorf("%v: %s", err, string(out)) + if err := client.ImageTag(ctx, img.srcName, img.destName); err != nil { + return errors.Wrapf(err, "failed to tag %s as %s", img.srcName, img.destName) } - if out, err := exec.Command(dockerBinary, "rmi", img.srcName).CombinedOutput(); err != nil { - return errors.Errorf("%v: %s", err, string(out)) + if _, err := client.ImageRemove(ctx, img.srcName, types.ImageRemoveOptions{}); err != nil { + return errors.Wrapf(err, "failed to remove %s", img.srcName) } } } return nil } -func loadFrozenImages(dockerBinary string) error { +func imageExists(client client.APIClient, name string) bool { + _, _, err := client.ImageInspectWithRaw(context.Background(), name) + return err == nil +} + +func loadFrozenImages(ctx context.Context, client client.APIClient) error { tar, err := exec.LookPath("tar") if err != nil { return errors.Wrap(err, "could not find tar binary") @@ -90,15 +102,16 @@ func loadFrozenImages(dockerBinary string) error { tarCmd.Start() defer tarCmd.Wait() - cmd := exec.Command(dockerBinary, "load") - cmd.Stdin = out - if out, err := cmd.CombinedOutput(); err != nil { - return errors.Errorf("%v: %s", err, string(out)) + resp, err := client.ImageLoad(ctx, out, true) + if err != nil { + return errors.Wrap(err, "failed to load frozen images") } - return nil + defer resp.Body.Close() + fd, isTerminal := term.GetFdInfo(os.Stdout) + return jsonmessage.DisplayJSONMessagesStream(resp.Body, os.Stdout, fd, isTerminal, nil) } -func pullImages(dockerBinary string, images []string) error { +func pullImages(ctx context.Context, client client.APIClient, images []string) error { cwd, err := os.Getwd() if err != nil { return errors.Wrap(err, "error getting path to dockerfile") @@ -119,16 +132,8 @@ func pullImages(dockerBinary string, images []string) error { wg.Add(1) go func(tag, ref string) { defer wg.Done() - if out, err := exec.Command(dockerBinary, "pull", ref).CombinedOutput(); err != nil { - chErr <- errors.Errorf("%v: %s", string(out), err) - return - } - if out, err := exec.Command(dockerBinary, "tag", ref, tag).CombinedOutput(); err != nil { - chErr <- errors.Errorf("%v: %s", string(out), err) - return - } - if out, err := exec.Command(dockerBinary, "rmi", ref).CombinedOutput(); err != nil { - chErr <- errors.Errorf("%v: %s", string(out), err) + if err := pullTagAndRemove(ctx, client, ref, tag); err != nil { + chErr <- err return } }(tag, ref) @@ -138,6 +143,25 @@ func pullImages(dockerBinary string, images []string) error { return <-chErr } +func pullTagAndRemove(ctx context.Context, client client.APIClient, ref string, tag string) error { + resp, err := client.ImagePull(ctx, ref, types.ImagePullOptions{}) + if err != nil { + return errors.Wrapf(err, "failed to pull %s", ref) + } + defer resp.Close() + fd, isTerminal := term.GetFdInfo(os.Stdout) + if err := jsonmessage.DisplayJSONMessagesStream(resp, os.Stdout, fd, isTerminal, nil); err != nil { + return err + } + + if err := client.ImageTag(ctx, ref, tag); err != nil { + return errors.Wrapf(err, "failed to tag %s as %s", ref, tag) + } + _, err = client.ImageRemove(ctx, ref, types.ImageRemoveOptions{}) + return errors.Wrapf(err, "failed to remove %s", ref) + +} + func readFrozenImageList(dockerfilePath string, images []string) (map[string]string, error) { f, err := os.Open(dockerfilePath) if err != nil { @@ -156,11 +180,6 @@ func readFrozenImageList(dockerfilePath string, images []string) (map[string]str continue } - frozenImgDir = line[2] - if line[2] == frozenImgDir { - frozenImgDir = filepath.Join(os.Getenv("DEST"), "frozen-images") - } - for scanner.Scan() { img := strings.TrimSpace(scanner.Text()) img = strings.TrimSuffix(img, "\\") diff --git a/vendor/github.com/docker/docker/integration-cli/fixtures/plugin/plugin.go b/vendor/github.com/docker/docker/integration-cli/fixtures/plugin/plugin.go index c8259be1a..0b1313456 100644 --- a/vendor/github.com/docker/docker/integration-cli/fixtures/plugin/plugin.go +++ b/vendor/github.com/docker/docker/integration-cli/fixtures/plugin/plugin.go @@ -1,13 +1,23 @@ package plugin import ( + "encoding/json" "io" + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "time" "github.com/docker/docker/api/types" + "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/plugin" + "github.com/docker/docker/registry" + "github.com/pkg/errors" "golang.org/x/net/context" ) -// CreateOpt is is passed used to change the defualt plugin config before +// CreateOpt is is passed used to change the default plugin config before // creating it type CreateOpt func(*Config) @@ -32,3 +42,142 @@ func WithBinary(bin string) CreateOpt { type CreateClient interface { PluginCreate(context.Context, io.Reader, types.PluginCreateOptions) error } + +// Create creates a new plugin with the specified name +func Create(ctx context.Context, c CreateClient, name string, opts ...CreateOpt) error { + tmpDir, err := ioutil.TempDir("", "create-test-plugin") + if err != nil { + return err + } + defer os.RemoveAll(tmpDir) + + tar, err := makePluginBundle(tmpDir, opts...) + if err != nil { + return err + } + defer tar.Close() + + ctx, cancel := context.WithTimeout(ctx, 30*time.Second) + defer cancel() + + return c.PluginCreate(ctx, tar, types.PluginCreateOptions{RepoName: name}) +} + +// CreateInRegistry makes a plugin (locally) and pushes it to a registry. +// This does not use a dockerd instance to create or push the plugin. +// If you just want to create a plugin in some daemon, use `Create`. +// +// This can be useful when testing plugins on swarm where you don't really want +// the plugin to exist on any of the daemons (immediately) and there needs to be +// some way to distribute the plugin. +func CreateInRegistry(ctx context.Context, repo string, auth *types.AuthConfig, opts ...CreateOpt) error { + tmpDir, err := ioutil.TempDir("", "create-test-plugin-local") + if err != nil { + return err + } + defer os.RemoveAll(tmpDir) + + inPath := filepath.Join(tmpDir, "plugin") + if err := os.MkdirAll(inPath, 0755); err != nil { + return errors.Wrap(err, "error creating plugin root") + } + + tar, err := makePluginBundle(inPath, opts...) + if err != nil { + return err + } + defer tar.Close() + + dummyExec := func(m *plugin.Manager) (plugin.Executor, error) { + return nil, nil + } + + regService, err := registry.NewService(registry.ServiceOptions{V2Only: true}) + if err != nil { + return err + } + + managerConfig := plugin.ManagerConfig{ + Store: plugin.NewStore(), + RegistryService: regService, + Root: filepath.Join(tmpDir, "root"), + ExecRoot: "/run/docker", // manager init fails if not set + CreateExecutor: dummyExec, + LogPluginEvent: func(id, name, action string) {}, // panics when not set + } + manager, err := plugin.NewManager(managerConfig) + if err != nil { + return errors.Wrap(err, "error creating plugin manager") + } + + ctx, cancel := context.WithTimeout(ctx, 30*time.Second) + defer cancel() + if err := manager.CreateFromContext(ctx, tar, &types.PluginCreateOptions{RepoName: repo}); err != nil { + return err + } + + if auth == nil { + auth = &types.AuthConfig{} + } + err = manager.Push(ctx, repo, nil, auth, ioutil.Discard) + return errors.Wrap(err, "error pushing plugin") +} + +func makePluginBundle(inPath string, opts ...CreateOpt) (io.ReadCloser, error) { + p := &types.PluginConfig{ + Interface: types.PluginConfigInterface{ + Socket: "basic.sock", + Types: []types.PluginInterfaceType{{Capability: "docker.dummy/1.0"}}, + }, + Entrypoint: []string{"/basic"}, + } + cfg := &Config{ + PluginConfig: p, + } + for _, o := range opts { + o(cfg) + } + if cfg.binPath == "" { + binPath, err := ensureBasicPluginBin() + if err != nil { + return nil, err + } + cfg.binPath = binPath + } + + configJSON, err := json.Marshal(p) + if err != nil { + return nil, err + } + if err := ioutil.WriteFile(filepath.Join(inPath, "config.json"), configJSON, 0644); err != nil { + return nil, err + } + if err := os.MkdirAll(filepath.Join(inPath, "rootfs", filepath.Dir(p.Entrypoint[0])), 0755); err != nil { + return nil, errors.Wrap(err, "error creating plugin rootfs dir") + } + if err := archive.NewDefaultArchiver().CopyFileWithTar(cfg.binPath, filepath.Join(inPath, "rootfs", p.Entrypoint[0])); err != nil { + return nil, errors.Wrap(err, "error copying plugin binary to rootfs path") + } + tar, err := archive.Tar(inPath, archive.Uncompressed) + return tar, errors.Wrap(err, "error making plugin archive") +} + +func ensureBasicPluginBin() (string, error) { + name := "docker-basic-plugin" + p, err := exec.LookPath(name) + if err == nil { + return p, nil + } + + goBin, err := exec.LookPath("go") + if err != nil { + return "", err + } + installPath := filepath.Join(os.Getenv("GOPATH"), "bin", name) + cmd := exec.Command(goBin, "build", "-o", installPath, "./"+filepath.Join("fixtures", "plugin", "basic")) + cmd.Env = append(cmd.Env, "CGO_ENABLED=0") + if out, err := cmd.CombinedOutput(); err != nil { + return "", errors.Wrapf(err, "error building basic plugin bin: %s", string(out)) + } + return installPath, nil +} diff --git a/vendor/github.com/docker/docker/integration-cli/fixtures/plugin/plugin_linux.go b/vendor/github.com/docker/docker/integration-cli/fixtures/plugin/plugin_linux.go deleted file mode 100644 index 757694cd3..000000000 --- a/vendor/github.com/docker/docker/integration-cli/fixtures/plugin/plugin_linux.go +++ /dev/null @@ -1,157 +0,0 @@ -package plugin - -import ( - "encoding/json" - "io" - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "time" - - "github.com/docker/docker/api/types" - "github.com/docker/docker/libcontainerd" - "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/plugin" - "github.com/docker/docker/registry" - "github.com/pkg/errors" - "golang.org/x/net/context" -) - -// Create creates a new plugin with the specified name -func Create(ctx context.Context, c CreateClient, name string, opts ...CreateOpt) error { - tmpDir, err := ioutil.TempDir("", "create-test-plugin") - if err != nil { - return err - } - defer os.RemoveAll(tmpDir) - - tar, err := makePluginBundle(tmpDir, opts...) - if err != nil { - return err - } - defer tar.Close() - - ctx, cancel := context.WithTimeout(ctx, 30*time.Second) - defer cancel() - - return c.PluginCreate(ctx, tar, types.PluginCreateOptions{RepoName: name}) -} - -// TODO(@cpuguy83): we really shouldn't have to do this... -// The manager panics on init when `Executor` is not set. -type dummyExecutor struct{} - -func (dummyExecutor) Client(libcontainerd.Backend) (libcontainerd.Client, error) { return nil, nil } -func (dummyExecutor) Cleanup() {} -func (dummyExecutor) UpdateOptions(...libcontainerd.RemoteOption) error { return nil } - -// CreateInRegistry makes a plugin (locally) and pushes it to a registry. -// This does not use a dockerd instance to create or push the plugin. -// If you just want to create a plugin in some daemon, use `Create`. -// -// This can be useful when testing plugins on swarm where you don't really want -// the plugin to exist on any of the daemons (immediately) and there needs to be -// some way to distribute the plugin. -func CreateInRegistry(ctx context.Context, repo string, auth *types.AuthConfig, opts ...CreateOpt) error { - tmpDir, err := ioutil.TempDir("", "create-test-plugin-local") - if err != nil { - return err - } - defer os.RemoveAll(tmpDir) - - inPath := filepath.Join(tmpDir, "plugin") - if err := os.MkdirAll(inPath, 0755); err != nil { - return errors.Wrap(err, "error creating plugin root") - } - - tar, err := makePluginBundle(inPath, opts...) - if err != nil { - return err - } - defer tar.Close() - - managerConfig := plugin.ManagerConfig{ - Store: plugin.NewStore(), - RegistryService: registry.NewService(registry.ServiceOptions{V2Only: true}), - Root: filepath.Join(tmpDir, "root"), - ExecRoot: "/run/docker", // manager init fails if not set - Executor: dummyExecutor{}, - LogPluginEvent: func(id, name, action string) {}, // panics when not set - } - manager, err := plugin.NewManager(managerConfig) - if err != nil { - return errors.Wrap(err, "error creating plugin manager") - } - - ctx, cancel := context.WithTimeout(ctx, 30*time.Second) - defer cancel() - if err := manager.CreateFromContext(ctx, tar, &types.PluginCreateOptions{RepoName: repo}); err != nil { - return err - } - - if auth == nil { - auth = &types.AuthConfig{} - } - err = manager.Push(ctx, repo, nil, auth, ioutil.Discard) - return errors.Wrap(err, "error pushing plugin") -} - -func makePluginBundle(inPath string, opts ...CreateOpt) (io.ReadCloser, error) { - p := &types.PluginConfig{ - Interface: types.PluginConfigInterface{ - Socket: "basic.sock", - Types: []types.PluginInterfaceType{{Capability: "docker.dummy/1.0"}}, - }, - Entrypoint: []string{"/basic"}, - } - cfg := &Config{ - PluginConfig: p, - } - for _, o := range opts { - o(cfg) - } - if cfg.binPath == "" { - binPath, err := ensureBasicPluginBin() - if err != nil { - return nil, err - } - cfg.binPath = binPath - } - - configJSON, err := json.Marshal(p) - if err != nil { - return nil, err - } - if err := ioutil.WriteFile(filepath.Join(inPath, "config.json"), configJSON, 0644); err != nil { - return nil, err - } - if err := os.MkdirAll(filepath.Join(inPath, "rootfs", filepath.Dir(p.Entrypoint[0])), 0755); err != nil { - return nil, errors.Wrap(err, "error creating plugin rootfs dir") - } - if err := archive.NewDefaultArchiver().CopyFileWithTar(cfg.binPath, filepath.Join(inPath, "rootfs", p.Entrypoint[0])); err != nil { - return nil, errors.Wrap(err, "error copying plugin binary to rootfs path") - } - tar, err := archive.Tar(inPath, archive.Uncompressed) - return tar, errors.Wrap(err, "error making plugin archive") -} - -func ensureBasicPluginBin() (string, error) { - name := "docker-basic-plugin" - p, err := exec.LookPath(name) - if err == nil { - return p, nil - } - - goBin, err := exec.LookPath("go") - if err != nil { - return "", err - } - installPath := filepath.Join(os.Getenv("GOPATH"), "bin", name) - cmd := exec.Command(goBin, "build", "-o", installPath, "./"+filepath.Join("fixtures", "plugin", "basic")) - cmd.Env = append(cmd.Env, "CGO_ENABLED=0") - if out, err := cmd.CombinedOutput(); err != nil { - return "", errors.Wrapf(err, "error building basic plugin bin: %s", string(out)) - } - return installPath, nil -} diff --git a/vendor/github.com/docker/docker/integration-cli/fixtures/plugin/plugin_unsuported.go b/vendor/github.com/docker/docker/integration-cli/fixtures/plugin/plugin_unsuported.go deleted file mode 100644 index 7c272a317..000000000 --- a/vendor/github.com/docker/docker/integration-cli/fixtures/plugin/plugin_unsuported.go +++ /dev/null @@ -1,19 +0,0 @@ -// +build !linux - -package plugin - -import ( - "github.com/docker/docker/api/types" - "github.com/pkg/errors" - "golang.org/x/net/context" -) - -// Create is not supported on this platform -func Create(ctx context.Context, c CreateClient, name string, opts ...CreateOpt) error { - return errors.New("not supported on this platform") -} - -// CreateInRegistry is not supported on this platform -func CreateInRegistry(ctx context.Context, repo string, auth *types.AuthConfig, opts ...CreateOpt) error { - return errors.New("not supported on this platform") -} diff --git a/vendor/github.com/docker/docker/integration-cli/fixtures_linux_daemon_test.go b/vendor/github.com/docker/docker/integration-cli/fixtures_linux_daemon_test.go index 895f976a1..6ac451121 100644 --- a/vendor/github.com/docker/docker/integration-cli/fixtures_linux_daemon_test.go +++ b/vendor/github.com/docker/docker/integration-cli/fixtures_linux_daemon_test.go @@ -24,16 +24,6 @@ type logT interface { Logf(string, ...interface{}) } -func ensureFrozenImagesLinux(t testingT) { - images := []string{"busybox:latest", "hello-world:frozen", "debian:jessie"} - err := load.FrozenImagesLinux(dockerBinary, images...) - if err != nil { - t.Logf(dockerCmdWithError("images")) - t.Fatalf("%+v", err) - } - defer testEnv.ProtectImage(t, images...) -} - var ensureSyscallTestOnce sync.Once func ensureSyscallTest(c *check.C) { @@ -67,7 +57,7 @@ func ensureSyscallTest(c *check.C) { } if runtime.GOOS == "linux" && runtime.GOARCH == "amd64" { - out, err := exec.Command(gcc, "-s", "-m32", "-nostdlib", "../contrib/syscall-test/exit32.s", "-o", tmp+"/"+"exit32-test").CombinedOutput() + out, err := exec.Command(gcc, "-s", "-m32", "-nostdlib", "-static", "../contrib/syscall-test/exit32.s", "-o", tmp+"/"+"exit32-test").CombinedOutput() c.Assert(err, checker.IsNil, check.Commentf(string(out))) } @@ -89,7 +79,7 @@ func ensureSyscallTest(c *check.C) { } func ensureSyscallTestBuild(c *check.C) { - err := load.FrozenImagesLinux(dockerBinary, "buildpack-deps:jessie") + err := load.FrozenImagesLinux(testEnv.APIClient(), "buildpack-deps:jessie") c.Assert(err, checker.IsNil) var buildArgs []string @@ -136,7 +126,7 @@ func ensureNNPTest(c *check.C) { } func ensureNNPTestBuild(c *check.C) { - err := load.FrozenImagesLinux(dockerBinary, "buildpack-deps:jessie") + err := load.FrozenImagesLinux(testEnv.APIClient(), "buildpack-deps:jessie") c.Assert(err, checker.IsNil) var buildArgs []string diff --git a/vendor/github.com/docker/docker/integration-cli/request/request.go b/vendor/github.com/docker/docker/integration-cli/request/request.go index 6f2bf650d..f22b08d76 100644 --- a/vendor/github.com/docker/docker/integration-cli/request/request.go +++ b/vendor/github.com/docker/docker/integration-cli/request/request.go @@ -21,7 +21,6 @@ import ( dclient "github.com/docker/docker/client" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/ioutils" - "github.com/docker/docker/pkg/testutil" "github.com/docker/go-connections/sockets" "github.com/docker/go-connections/tlsconfig" "github.com/pkg/errors" @@ -130,7 +129,11 @@ func New(host, endpoint string, modifiers ...func(*http.Request) error) (*http.R return nil, fmt.Errorf("could not create new request: %v", err) } - req.URL.Scheme = "http" + if os.Getenv("DOCKER_TLS_VERIFY") != "" { + req.URL.Scheme = "https" + } else { + req.URL.Scheme = "http" + } req.URL.Host = addr for _, config := range modifiers { @@ -166,7 +169,11 @@ func NewHTTPClient(host string) (*http.Client, error) { // NewClient returns a new Docker API client func NewClient() (dclient.APIClient, error) { - host := DaemonHost() + return NewClientForHost(DaemonHost()) +} + +// NewClientForHost returns a Docker API client for the host +func NewClientForHost(host string) (dclient.APIClient, error) { httpClient, err := NewHTTPClient(host) if err != nil { return nil, err @@ -214,10 +221,16 @@ func SockRequest(method, endpoint string, data interface{}, daemon string, modif if err != nil { return -1, nil, err } - b, err := testutil.ReadBody(body) + b, err := ReadBody(body) return res.StatusCode, b, err } +// ReadBody read the specified ReadCloser content and returns it +func ReadBody(b io.ReadCloser) ([]byte, error) { + defer b.Close() + return ioutil.ReadAll(b) +} + // SockRequestRaw create a request against the specified host (with method, endpoint and other request modifier) and // returns the http response, the output as a io.ReadCloser // Deprecated: use request.Do (or Get, Delete, Post) instead @@ -310,3 +323,35 @@ func DaemonHost() string { } return daemonURLStr } + +// NewEnvClientWithVersion returns a docker client with a specified version. +// See: github.com/docker/docker/client `NewEnvClient()` +func NewEnvClientWithVersion(version string) (*dclient.Client, error) { + if version == "" { + return nil, errors.New("version not specified") + } + + var httpClient *http.Client + if os.Getenv("DOCKER_CERT_PATH") != "" { + tlsConfig, err := getTLSConfig() + if err != nil { + return nil, err + } + httpClient = &http.Client{ + Transport: &http.Transport{ + TLSClientConfig: tlsConfig, + }, + } + } + + host := os.Getenv("DOCKER_HOST") + if host == "" { + host = dclient.DefaultDockerHost + } + + cli, err := dclient.NewClient(host, version, httpClient, nil) + if err != nil { + return cli, err + } + return cli, nil +} diff --git a/vendor/github.com/docker/docker/integration-cli/requirement/requirement.go b/vendor/github.com/docker/docker/integration-cli/requirement/requirement.go index f60917447..9486c3252 100644 --- a/vendor/github.com/docker/docker/integration-cli/requirement/requirement.go +++ b/vendor/github.com/docker/docker/integration-cli/requirement/requirement.go @@ -8,7 +8,8 @@ import ( "strings" ) -type skipT interface { +// SkipT is the interface required to skip tests +type SkipT interface { Skip(reason string) } @@ -17,7 +18,7 @@ type Test func() bool // Is checks if the environment satisfies the requirements // for the test to run or skips the tests. -func Is(s skipT, requirements ...Test) { +func Is(s SkipT, requirements ...Test) { for _, r := range requirements { isValid := r() if !isValid { diff --git a/vendor/github.com/docker/docker/integration-cli/requirements_test.go b/vendor/github.com/docker/docker/integration-cli/requirements_test.go index 15b3df226..411248195 100644 --- a/vendor/github.com/docker/docker/integration-cli/requirements_test.go +++ b/vendor/github.com/docker/docker/integration-cli/requirements_test.go @@ -1,56 +1,67 @@ package main import ( + "context" "fmt" "io/ioutil" "net/http" "os" "os/exec" + "strconv" "strings" "time" + "github.com/docker/docker/api/types" + "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/requirement" - "github.com/go-check/check" ) -func PlatformIs(platform string) bool { - return testEnv.DaemonPlatform() == platform -} - -func ArchitectureIs(arch string) bool { - return os.Getenv("DOCKER_ENGINE_GOARCH") == arch -} - func ArchitectureIsNot(arch string) bool { return os.Getenv("DOCKER_ENGINE_GOARCH") != arch } -func StorageDriverIs(storageDriver string) bool { - return strings.HasPrefix(testEnv.DaemonStorageDriver(), storageDriver) +func DaemonIsWindows() bool { + return testEnv.DaemonInfo.OSType == "windows" } -func StorageDriverIsNot(storageDriver string) bool { - return !strings.HasPrefix(testEnv.DaemonStorageDriver(), storageDriver) +func DaemonIsWindowsAtLeastBuild(buildNumber int) func() bool { + return func() bool { + if testEnv.DaemonInfo.OSType != "windows" { + return false + } + version := testEnv.DaemonInfo.KernelVersion + numVersion, _ := strconv.Atoi(strings.Split(version, " ")[1]) + return numVersion >= buildNumber + } } -func DaemonIsWindows() bool { - return PlatformIs("windows") +func DaemonIsLinux() bool { + return testEnv.DaemonInfo.OSType == "linux" } -func DaemonIsLinux() bool { - return PlatformIs("linux") +func OnlyDefaultNetworks() bool { + cli, err := client.NewEnvClient() + if err != nil { + return false + } + networks, err := cli.NetworkList(context.TODO(), types.NetworkListOptions{}) + if err != nil || len(networks) > 0 { + return false + } + return true } +// Deprecated: use skip.IfCondition(t, !testEnv.DaemonInfo.ExperimentalBuild) func ExperimentalDaemon() bool { - return testEnv.ExperimentalDaemon() + return testEnv.DaemonInfo.ExperimentalBuild } func NotExperimentalDaemon() bool { - return !testEnv.ExperimentalDaemon() + return !testEnv.DaemonInfo.ExperimentalBuild } func IsAmd64() bool { - return ArchitectureIs("amd64") + return os.Getenv("DOCKER_ENGINE_GOARCH") == "amd64" } func NotArm() bool { @@ -70,7 +81,7 @@ func NotS390X() bool { } func SameHostDaemon() bool { - return testEnv.LocalDaemon() + return testEnv.IsLocalDaemon() } func UnixCli() bool { @@ -121,12 +132,8 @@ func NotaryServerHosting() bool { return err == nil } -func NotOverlay() bool { - return StorageDriverIsNot("overlay") -} - func Devicemapper() bool { - return StorageDriverIs("devicemapper") + return strings.HasPrefix(testEnv.DaemonInfo.Driver, "devicemapper") } func IPv6() bool { @@ -171,21 +178,21 @@ func UserNamespaceInKernel() bool { } func IsPausable() bool { - if testEnv.DaemonPlatform() == "windows" { - return testEnv.Isolation() == "hyperv" + if testEnv.DaemonInfo.OSType == "windows" { + return testEnv.DaemonInfo.Isolation == "hyperv" } return true } func NotPausable() bool { - if testEnv.DaemonPlatform() == "windows" { - return testEnv.Isolation() == "process" + if testEnv.DaemonInfo.OSType == "windows" { + return testEnv.DaemonInfo.Isolation == "process" } return false } func IsolationIs(expectedIsolation string) bool { - return testEnv.DaemonPlatform() == "windows" && string(testEnv.Isolation()) == expectedIsolation + return testEnv.DaemonInfo.OSType == "windows" && string(testEnv.DaemonInfo.Isolation) == expectedIsolation } func IsolationIsHyperv() bool { @@ -198,6 +205,6 @@ func IsolationIsProcess() bool { // testRequires checks if the environment satisfies the requirements // for the test to run or skips the tests. -func testRequires(c *check.C, requirements ...requirement.Test) { +func testRequires(c requirement.SkipT, requirements ...requirement.Test) { requirement.Is(c, requirements...) } diff --git a/vendor/github.com/docker/docker/integration-cli/requirements_unix_test.go b/vendor/github.com/docker/docker/integration-cli/requirements_unix_test.go index 2ed04f6e1..7c594f7db 100644 --- a/vendor/github.com/docker/docker/integration-cli/requirements_unix_test.go +++ b/vendor/github.com/docker/docker/integration-cli/requirements_unix_test.go @@ -18,19 +18,19 @@ var ( ) func cpuCfsPeriod() bool { - return SysInfo.CPUCfsPeriod + return testEnv.DaemonInfo.CPUCfsPeriod } func cpuCfsQuota() bool { - return SysInfo.CPUCfsQuota + return testEnv.DaemonInfo.CPUCfsQuota } func cpuShare() bool { - return SysInfo.CPUShares + return testEnv.DaemonInfo.CPUShares } func oomControl() bool { - return SysInfo.OomKillDisable + return testEnv.DaemonInfo.OomKillDisable } func pidsLimit() bool { @@ -38,11 +38,11 @@ func pidsLimit() bool { } func kernelMemorySupport() bool { - return SysInfo.KernelMemory + return testEnv.DaemonInfo.KernelMemory } func memoryLimitSupport() bool { - return SysInfo.MemoryLimit + return testEnv.DaemonInfo.MemoryLimit } func memoryReservationSupport() bool { @@ -50,19 +50,19 @@ func memoryReservationSupport() bool { } func swapMemorySupport() bool { - return SysInfo.SwapLimit + return testEnv.DaemonInfo.SwapLimit } func memorySwappinessSupport() bool { - return SysInfo.MemorySwappiness + return SameHostDaemon() && SysInfo.MemorySwappiness } func blkioWeight() bool { - return SysInfo.BlkioWeight + return SameHostDaemon() && SysInfo.BlkioWeight } func cgroupCpuset() bool { - return SysInfo.Cpuset + return testEnv.DaemonInfo.CPUSet } func seccompEnabled() bool { @@ -101,7 +101,7 @@ func overlay2Supported() bool { return false } - daemonV, err := kernel.ParseRelease(testEnv.DaemonKernelVersion()) + daemonV, err := kernel.ParseRelease(testEnv.DaemonInfo.KernelVersion) if err != nil { return false } @@ -111,5 +111,7 @@ func overlay2Supported() bool { } func init() { - SysInfo = sysinfo.New(true) + if SameHostDaemon() { + SysInfo = sysinfo.New(true) + } } diff --git a/vendor/github.com/docker/docker/integration-cli/trust_server_test.go b/vendor/github.com/docker/docker/integration-cli/trust_server_test.go index 9a999323f..19abe8719 100644 --- a/vendor/github.com/docker/docker/integration-cli/trust_server_test.go +++ b/vendor/github.com/docker/docker/integration-cli/trust_server_test.go @@ -18,9 +18,9 @@ import ( "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/fixtures/plugin" "github.com/docker/docker/integration-cli/request" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/docker/go-connections/tlsconfig" "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" ) var notaryBinary = "notary" diff --git a/vendor/github.com/docker/docker/integration-cli/utils_test.go b/vendor/github.com/docker/docker/integration-cli/utils_test.go index 2725ddf4f..d176c7f06 100644 --- a/vendor/github.com/docker/docker/integration-cli/utils_test.go +++ b/vendor/github.com/docker/docker/integration-cli/utils_test.go @@ -1,9 +1,16 @@ package main import ( + "fmt" + "os" "os/exec" + "path/filepath" + "strings" - "github.com/docker/docker/pkg/testutil/cmd" + "github.com/docker/docker/pkg/stringutils" + "github.com/go-check/check" + "github.com/gotestyourself/gotestyourself/icmd" + "github.com/pkg/errors" ) func getPrefixAndSlashFromDaemonPlatform() (prefix, slash string) { @@ -14,15 +21,15 @@ func getPrefixAndSlashFromDaemonPlatform() (prefix, slash string) { } // TODO: update code to call cmd.RunCmd directly, and remove this function -// Deprecated: use pkg/testutil/cmd instead +// Deprecated: use gotestyourself/gotestyourself/icmd func runCommandWithOutput(execCmd *exec.Cmd) (string, int, error) { - result := cmd.RunCmd(transformCmd(execCmd)) + result := icmd.RunCmd(transformCmd(execCmd)) return result.Combined(), result.ExitCode, result.Error } // Temporary shim for migrating commands to the new function -func transformCmd(execCmd *exec.Cmd) cmd.Cmd { - return cmd.Cmd{ +func transformCmd(execCmd *exec.Cmd) icmd.Cmd { + return icmd.Cmd{ Command: execCmd.Args, Env: execCmd.Env, Dir: execCmd.Dir, @@ -30,3 +37,147 @@ func transformCmd(execCmd *exec.Cmd) cmd.Cmd { Stdout: execCmd.Stdout, } } + +// ParseCgroupPaths parses 'procCgroupData', which is output of '/proc//cgroup', and returns +// a map which cgroup name as key and path as value. +func ParseCgroupPaths(procCgroupData string) map[string]string { + cgroupPaths := map[string]string{} + for _, line := range strings.Split(procCgroupData, "\n") { + parts := strings.Split(line, ":") + if len(parts) != 3 { + continue + } + cgroupPaths[parts[1]] = parts[2] + } + return cgroupPaths +} + +// RandomTmpDirPath provides a temporary path with rand string appended. +// does not create or checks if it exists. +func RandomTmpDirPath(s string, platform string) string { + // TODO: why doesn't this use os.TempDir() ? + tmp := "/tmp" + if platform == "windows" { + tmp = os.Getenv("TEMP") + } + path := filepath.Join(tmp, fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10))) + if platform == "windows" { + return filepath.FromSlash(path) // Using \ + } + return filepath.ToSlash(path) // Using / +} + +// RunCommandPipelineWithOutput runs the array of commands with the output +// of each pipelined with the following (like cmd1 | cmd2 | cmd3 would do). +// It returns the final output, the exitCode different from 0 and the error +// if something bad happened. +// Deprecated: use icmd instead +func RunCommandPipelineWithOutput(cmds ...*exec.Cmd) (output string, err error) { + if len(cmds) < 2 { + return "", errors.New("pipeline does not have multiple cmds") + } + + // connect stdin of each cmd to stdout pipe of previous cmd + for i, cmd := range cmds { + if i > 0 { + prevCmd := cmds[i-1] + cmd.Stdin, err = prevCmd.StdoutPipe() + + if err != nil { + return "", fmt.Errorf("cannot set stdout pipe for %s: %v", cmd.Path, err) + } + } + } + + // start all cmds except the last + for _, cmd := range cmds[:len(cmds)-1] { + if err = cmd.Start(); err != nil { + return "", fmt.Errorf("starting %s failed with error: %v", cmd.Path, err) + } + } + + defer func() { + var pipeErrMsgs []string + // wait all cmds except the last to release their resources + for _, cmd := range cmds[:len(cmds)-1] { + if pipeErr := cmd.Wait(); pipeErr != nil { + pipeErrMsgs = append(pipeErrMsgs, fmt.Sprintf("command %s failed with error: %v", cmd.Path, pipeErr)) + } + } + if len(pipeErrMsgs) > 0 && err == nil { + err = fmt.Errorf("pipelineError from Wait: %v", strings.Join(pipeErrMsgs, ", ")) + } + }() + + // wait on last cmd + out, err := cmds[len(cmds)-1].CombinedOutput() + return string(out), err +} + +type elementListOptions struct { + element, format string +} + +func existingElements(c *check.C, opts elementListOptions) []string { + args := []string{} + switch opts.element { + case "container": + args = append(args, "ps", "-a") + case "image": + args = append(args, "images", "-a") + case "network": + args = append(args, "network", "ls") + case "plugin": + args = append(args, "plugin", "ls") + case "volume": + args = append(args, "volume", "ls") + } + if opts.format != "" { + args = append(args, "--format", opts.format) + } + out, _ := dockerCmd(c, args...) + lines := []string{} + for _, l := range strings.Split(out, "\n") { + if l != "" { + lines = append(lines, l) + } + } + return lines +} + +// ExistingContainerIDs returns a list of currently existing container IDs. +func ExistingContainerIDs(c *check.C) []string { + return existingElements(c, elementListOptions{element: "container", format: "{{.ID}}"}) +} + +// ExistingContainerNames returns a list of existing container names. +func ExistingContainerNames(c *check.C) []string { + return existingElements(c, elementListOptions{element: "container", format: "{{.Names}}"}) +} + +// RemoveLinesForExistingElements removes existing elements from the output of a +// docker command. +// This function takes an output []string and returns a []string. +func RemoveLinesForExistingElements(output, existing []string) []string { + for _, e := range existing { + index := -1 + for i, line := range output { + if strings.Contains(line, e) { + index = i + break + } + } + if index != -1 { + output = append(output[:index], output[index+1:]...) + } + } + return output +} + +// RemoveOutputForExistingElements removes existing elements from the output of +// a docker command. +// This function takes an output string and returns a string. +func RemoveOutputForExistingElements(output string, existing []string) string { + res := RemoveLinesForExistingElements(strings.Split(output, "\n"), existing) + return strings.Join(res, "\n") +} diff --git a/vendor/github.com/docker/docker/integration/container/create_test.go b/vendor/github.com/docker/docker/integration/container/create_test.go new file mode 100644 index 000000000..6c8a084e5 --- /dev/null +++ b/vendor/github.com/docker/docker/integration/container/create_test.go @@ -0,0 +1,93 @@ +package container + +import ( + "context" + "strconv" + "testing" + + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/network" + "github.com/docker/docker/integration/util/request" + "github.com/docker/docker/internal/testutil" +) + +func TestCreateFailsWhenIdentifierDoesNotExist(t *testing.T) { + defer setupTest(t)() + client := request.NewAPIClient(t) + + testCases := []struct { + doc string + image string + expectedError string + }{ + { + doc: "image and tag", + image: "test456:v1", + expectedError: "No such image: test456:v1", + }, + { + doc: "image no tag", + image: "test456", + expectedError: "No such image: test456", + }, + { + doc: "digest", + image: "sha256:0cb40641836c461bc97c793971d84d758371ed682042457523e4ae701efeaaaa", + expectedError: "No such image: sha256:0cb40641836c461bc97c793971d84d758371ed682042457523e4ae701efeaaaa", + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.doc, func(t *testing.T) { + t.Parallel() + _, err := client.ContainerCreate(context.Background(), + &container.Config{Image: tc.image}, + &container.HostConfig{}, + &network.NetworkingConfig{}, + "foo", + ) + testutil.ErrorContains(t, err, tc.expectedError) + }) + } +} + +func TestCreateWithInvalidEnv(t *testing.T) { + defer setupTest(t)() + client := request.NewAPIClient(t) + + testCases := []struct { + env string + expectedError string + }{ + { + env: "", + expectedError: "invalid environment variable:", + }, + { + env: "=", + expectedError: "invalid environment variable: =", + }, + { + env: "=foo", + expectedError: "invalid environment variable: =foo", + }, + } + + for index, tc := range testCases { + tc := tc + t.Run(strconv.Itoa(index), func(t *testing.T) { + t.Parallel() + _, err := client.ContainerCreate(context.Background(), + &container.Config{ + Image: "busybox", + Env: []string{tc.env}, + }, + &container.HostConfig{}, + &network.NetworkingConfig{}, + "foo", + ) + testutil.ErrorContains(t, err, tc.expectedError) + }) + } +} diff --git a/vendor/github.com/docker/docker/integration/container/main_test.go b/vendor/github.com/docker/docker/integration/container/main_test.go new file mode 100644 index 000000000..fbfed2ae4 --- /dev/null +++ b/vendor/github.com/docker/docker/integration/container/main_test.go @@ -0,0 +1,28 @@ +package container + +import ( + "fmt" + "os" + "testing" + + "github.com/docker/docker/internal/test/environment" +) + +var testEnv *environment.Execution + +func TestMain(m *testing.M) { + var err error + testEnv, err = environment.New() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + testEnv.Print() + os.Exit(m.Run()) +} + +func setupTest(t *testing.T) func() { + environment.ProtectAll(t, testEnv) + return func() { testEnv.Clean(t) } +} diff --git a/vendor/github.com/docker/docker/integration/doc.go b/vendor/github.com/docker/docker/integration/doc.go new file mode 100644 index 000000000..2fdf62eef --- /dev/null +++ b/vendor/github.com/docker/docker/integration/doc.go @@ -0,0 +1,3 @@ +// Package integration provides integrations tests for Moby (API). +// These tests require a daemon (dockerd for now) to run. +package integration diff --git a/vendor/github.com/docker/docker/integration/service/create_test.go b/vendor/github.com/docker/docker/integration/service/create_test.go new file mode 100644 index 000000000..cb0823dfb --- /dev/null +++ b/vendor/github.com/docker/docker/integration/service/create_test.go @@ -0,0 +1,129 @@ +package service + +import ( + "testing" + "time" + + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/client" + "github.com/docker/docker/integration-cli/request" + "github.com/gotestyourself/gotestyourself/poll" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "golang.org/x/net/context" +) + +func TestCreateWithLBSandbox(t *testing.T) { + defer setupTest(t)() + d := newSwarm(t) + defer d.Stop(t) + client, err := request.NewClientForHost(d.Sock()) + require.NoError(t, err) + + overlayName := "overlay1" + networkCreate := types.NetworkCreate{ + CheckDuplicate: true, + Driver: "overlay", + } + + netResp, err := client.NetworkCreate(context.Background(), overlayName, networkCreate) + require.NoError(t, err) + overlayID := netResp.ID + + var instances uint64 = 1 + serviceSpec := swarmServiceSpec("TestService", instances) + + serviceSpec.TaskTemplate.Networks = append(serviceSpec.TaskTemplate.Networks, swarm.NetworkAttachmentConfig{Target: overlayName}) + + serviceResp, err := client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{ + QueryRegistry: false, + }) + require.NoError(t, err) + + serviceID := serviceResp.ID + poll.WaitOn(t, serviceRunningTasksCount(client, serviceID, instances)) + + _, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{}) + require.NoError(t, err) + + network, err := client.NetworkInspect(context.Background(), overlayID, types.NetworkInspectOptions{}) + require.NoError(t, err) + assert.Contains(t, network.Containers, overlayName+"-sbox") + + err = client.ServiceRemove(context.Background(), serviceID) + require.NoError(t, err) + + poll.WaitOn(t, serviceIsRemoved(client, serviceID)) + err = client.NetworkRemove(context.Background(), overlayID) + require.NoError(t, err) + + poll.WaitOn(t, networkIsRemoved(client, overlayID), poll.WithTimeout(1*time.Minute), poll.WithDelay(10*time.Second)) +} + +func swarmServiceSpec(name string, replicas uint64) swarm.ServiceSpec { + return swarm.ServiceSpec{ + Annotations: swarm.Annotations{ + Name: name, + }, + TaskTemplate: swarm.TaskSpec{ + ContainerSpec: &swarm.ContainerSpec{ + Image: "busybox:latest", + Command: []string{"/bin/top"}, + }, + }, + Mode: swarm.ServiceMode{ + Replicated: &swarm.ReplicatedService{ + Replicas: &replicas, + }, + }, + } +} + +func serviceRunningTasksCount(client client.ServiceAPIClient, serviceID string, instances uint64) func(log poll.LogT) poll.Result { + return func(log poll.LogT) poll.Result { + filter := filters.NewArgs() + filter.Add("service", serviceID) + tasks, err := client.TaskList(context.Background(), types.TaskListOptions{ + Filters: filter, + }) + switch { + case err != nil: + return poll.Error(err) + case len(tasks) == int(instances): + for _, task := range tasks { + if task.Status.State != swarm.TaskStateRunning { + return poll.Continue("waiting for tasks to enter run state") + } + } + return poll.Success() + default: + return poll.Continue("task count at %d waiting for %d", len(tasks), instances) + } + } +} + +func serviceIsRemoved(client client.ServiceAPIClient, serviceID string) func(log poll.LogT) poll.Result { + return func(log poll.LogT) poll.Result { + filter := filters.NewArgs() + filter.Add("service", serviceID) + _, err := client.TaskList(context.Background(), types.TaskListOptions{ + Filters: filter, + }) + if err == nil { + return poll.Continue("waiting for service %s to be deleted", serviceID) + } + return poll.Success() + } +} + +func networkIsRemoved(client client.NetworkAPIClient, networkID string) func(log poll.LogT) poll.Result { + return func(log poll.LogT) poll.Result { + _, err := client.NetworkInspect(context.Background(), networkID, types.NetworkInspectOptions{}) + if err == nil { + return poll.Continue("waiting for network %s to be removed", networkID) + } + return poll.Success() + } +} diff --git a/vendor/github.com/docker/docker/integration/service/inspect_test.go b/vendor/github.com/docker/docker/integration/service/inspect_test.go new file mode 100644 index 000000000..61831b72f --- /dev/null +++ b/vendor/github.com/docker/docker/integration/service/inspect_test.go @@ -0,0 +1,148 @@ +package service + +import ( + "fmt" + "testing" + "time" + + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/client" + "github.com/docker/docker/integration-cli/daemon" + "github.com/docker/docker/integration-cli/request" + "github.com/gotestyourself/gotestyourself/poll" + "github.com/gotestyourself/gotestyourself/skip" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "golang.org/x/net/context" +) + +func TestInspect(t *testing.T) { + skip.IfCondition(t, !testEnv.IsLocalDaemon()) + defer setupTest(t)() + d := newSwarm(t) + defer d.Stop(t) + client, err := request.NewClientForHost(d.Sock()) + require.NoError(t, err) + + var before = time.Now() + var instances uint64 = 2 + serviceSpec := fullSwarmServiceSpec("test-service-inspect", instances) + + ctx := context.Background() + resp, err := client.ServiceCreate(ctx, serviceSpec, types.ServiceCreateOptions{ + QueryRegistry: false, + }) + require.NoError(t, err) + + id := resp.ID + poll.WaitOn(t, serviceContainerCount(client, id, instances)) + + service, _, err := client.ServiceInspectWithRaw(ctx, id, types.ServiceInspectOptions{}) + require.NoError(t, err) + assert.Equal(t, serviceSpec, service.Spec) + assert.Equal(t, uint64(11), service.Meta.Version.Index) + assert.Equal(t, id, service.ID) + assert.WithinDuration(t, before, service.CreatedAt, 30*time.Second) + assert.WithinDuration(t, before, service.UpdatedAt, 30*time.Second) +} + +func fullSwarmServiceSpec(name string, replicas uint64) swarm.ServiceSpec { + restartDelay := 100 * time.Millisecond + maxAttempts := uint64(4) + + return swarm.ServiceSpec{ + Annotations: swarm.Annotations{ + Name: name, + Labels: map[string]string{ + "service-label": "service-label-value", + }, + }, + TaskTemplate: swarm.TaskSpec{ + ContainerSpec: &swarm.ContainerSpec{ + Image: "busybox:latest", + Labels: map[string]string{"container-label": "container-value"}, + Command: []string{"/bin/top"}, + Args: []string{"-u", "root"}, + Hostname: "hostname", + Env: []string{"envvar=envvalue"}, + Dir: "/work", + User: "root", + StopSignal: "SIGINT", + StopGracePeriod: &restartDelay, + Hosts: []string{"8.8.8.8 google"}, + DNSConfig: &swarm.DNSConfig{ + Nameservers: []string{"8.8.8.8"}, + Search: []string{"somedomain"}, + }, + }, + RestartPolicy: &swarm.RestartPolicy{ + Delay: &restartDelay, + Condition: swarm.RestartPolicyConditionOnFailure, + MaxAttempts: &maxAttempts, + }, + Runtime: swarm.RuntimeContainer, + }, + Mode: swarm.ServiceMode{ + Replicated: &swarm.ReplicatedService{ + Replicas: &replicas, + }, + }, + UpdateConfig: &swarm.UpdateConfig{ + Parallelism: 2, + Delay: 200 * time.Second, + FailureAction: swarm.UpdateFailureActionContinue, + Monitor: 2 * time.Second, + MaxFailureRatio: 0.2, + Order: swarm.UpdateOrderStopFirst, + }, + RollbackConfig: &swarm.UpdateConfig{ + Parallelism: 3, + Delay: 300 * time.Second, + FailureAction: swarm.UpdateFailureActionPause, + Monitor: 3 * time.Second, + MaxFailureRatio: 0.3, + Order: swarm.UpdateOrderStartFirst, + }, + } +} + +const defaultSwarmPort = 2477 + +func newSwarm(t *testing.T) *daemon.Swarm { + d := &daemon.Swarm{ + Daemon: daemon.New(t, "", dockerdBinary, daemon.Config{ + Experimental: testEnv.DaemonInfo.ExperimentalBuild, + }), + // TODO: better method of finding an unused port + Port: defaultSwarmPort, + } + // TODO: move to a NewSwarm constructor + d.ListenAddr = fmt.Sprintf("0.0.0.0:%d", d.Port) + + // avoid networking conflicts + args := []string{"--iptables=false", "--swarm-default-advertise-addr=lo"} + d.StartWithBusybox(t, args...) + + require.NoError(t, d.Init(swarm.InitRequest{})) + return d +} + +func serviceContainerCount(client client.ServiceAPIClient, id string, count uint64) func(log poll.LogT) poll.Result { + return func(log poll.LogT) poll.Result { + filter := filters.NewArgs() + filter.Add("service", id) + tasks, err := client.TaskList(context.Background(), types.TaskListOptions{ + Filters: filter, + }) + switch { + case err != nil: + return poll.Error(err) + case len(tasks) == int(count): + return poll.Success() + default: + return poll.Continue("task count at %d waiting for %d", len(tasks), count) + } + } +} diff --git a/vendor/github.com/docker/docker/integration/service/main_test.go b/vendor/github.com/docker/docker/integration/service/main_test.go new file mode 100644 index 000000000..4cad6ed97 --- /dev/null +++ b/vendor/github.com/docker/docker/integration/service/main_test.go @@ -0,0 +1,30 @@ +package service + +import ( + "fmt" + "os" + "testing" + + "github.com/docker/docker/internal/test/environment" +) + +var testEnv *environment.Execution + +const dockerdBinary = "dockerd" + +func TestMain(m *testing.M) { + var err error + testEnv, err = environment.New() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + testEnv.Print() + os.Exit(m.Run()) +} + +func setupTest(t *testing.T) func() { + environment.ProtectAll(t, testEnv) + return func() { testEnv.Clean(t) } +} diff --git a/vendor/github.com/docker/docker/integration/system/main_test.go b/vendor/github.com/docker/docker/integration/system/main_test.go new file mode 100644 index 000000000..ad0d20375 --- /dev/null +++ b/vendor/github.com/docker/docker/integration/system/main_test.go @@ -0,0 +1,28 @@ +package system + +import ( + "fmt" + "os" + "testing" + + "github.com/docker/docker/internal/test/environment" +) + +var testEnv *environment.Execution + +func TestMain(m *testing.M) { + var err error + testEnv, err = environment.New() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + testEnv.Print() + os.Exit(m.Run()) +} + +func setupTest(t *testing.T) func() { + environment.ProtectImages(t, testEnv) + return func() { testEnv.Clean(t) } +} diff --git a/vendor/github.com/docker/docker/integration/system/version_test.go b/vendor/github.com/docker/docker/integration/system/version_test.go new file mode 100644 index 000000000..ac47891e9 --- /dev/null +++ b/vendor/github.com/docker/docker/integration/system/version_test.go @@ -0,0 +1,24 @@ +package system + +import ( + "testing" + + "github.com/docker/docker/integration-cli/request" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "golang.org/x/net/context" +) + +func TestVersion(t *testing.T) { + client, err := request.NewClient() + require.NoError(t, err) + + version, err := client.ServerVersion(context.Background()) + require.NoError(t, err) + + assert.NotNil(t, version.APIVersion) + assert.NotNil(t, version.Version) + assert.NotNil(t, version.MinAPIVersion) + assert.Equal(t, testEnv.DaemonInfo.ExperimentalBuild, version.Experimental) + assert.Equal(t, testEnv.DaemonInfo.OSType, version.Os) +} diff --git a/vendor/github.com/docker/docker/integration/util/request/client.go b/vendor/github.com/docker/docker/integration/util/request/client.go new file mode 100644 index 000000000..771563673 --- /dev/null +++ b/vendor/github.com/docker/docker/integration/util/request/client.go @@ -0,0 +1,15 @@ +package request + +import ( + "testing" + + "github.com/docker/docker/client" + "github.com/stretchr/testify/require" +) + +// NewAPIClient returns a docker API client configured from environment variables +func NewAPIClient(t *testing.T) client.APIClient { + clt, err := client.NewEnvClient() + require.NoError(t, err) + return clt +} diff --git a/vendor/github.com/docker/docker/internal/test/environment/clean.go b/vendor/github.com/docker/docker/internal/test/environment/clean.go new file mode 100644 index 000000000..702d10711 --- /dev/null +++ b/vendor/github.com/docker/docker/internal/test/environment/clean.go @@ -0,0 +1,176 @@ +package environment + +import ( + "regexp" + "strings" + + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/client" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "golang.org/x/net/context" +) + +type testingT interface { + require.TestingT + logT + Fatalf(string, ...interface{}) +} + +type logT interface { + Logf(string, ...interface{}) +} + +// Clean the environment, preserving protected objects (images, containers, ...) +// and removing everything else. It's meant to run after any tests so that they don't +// depend on each others. +func (e *Execution) Clean(t testingT) { + client := e.APIClient() + + platform := e.DaemonInfo.OSType + if (platform != "windows") || (platform == "windows" && e.DaemonInfo.Isolation == "hyperv") { + unpauseAllContainers(t, client) + } + deleteAllContainers(t, client, e.protectedElements.containers) + deleteAllImages(t, client, e.protectedElements.images) + deleteAllVolumes(t, client, e.protectedElements.volumes) + deleteAllNetworks(t, client, platform, e.protectedElements.networks) + if platform == "linux" { + deleteAllPlugins(t, client, e.protectedElements.plugins) + } +} + +func unpauseAllContainers(t assert.TestingT, client client.ContainerAPIClient) { + ctx := context.Background() + containers := getPausedContainers(ctx, t, client) + if len(containers) > 0 { + for _, container := range containers { + err := client.ContainerUnpause(ctx, container.ID) + assert.NoError(t, err, "failed to unpause container %s", container.ID) + } + } +} + +func getPausedContainers(ctx context.Context, t assert.TestingT, client client.ContainerAPIClient) []types.Container { + filter := filters.NewArgs() + filter.Add("status", "paused") + containers, err := client.ContainerList(ctx, types.ContainerListOptions{ + Filters: filter, + Quiet: true, + All: true, + }) + assert.NoError(t, err, "failed to list containers") + return containers +} + +var alreadyExists = regexp.MustCompile(`Error response from daemon: removal of container (\w+) is already in progress`) + +func deleteAllContainers(t assert.TestingT, apiclient client.ContainerAPIClient, protectedContainers map[string]struct{}) { + ctx := context.Background() + containers := getAllContainers(ctx, t, apiclient) + if len(containers) == 0 { + return + } + + for _, container := range containers { + if _, ok := protectedContainers[container.ID]; ok { + continue + } + err := apiclient.ContainerRemove(ctx, container.ID, types.ContainerRemoveOptions{ + Force: true, + RemoveVolumes: true, + }) + if err == nil || client.IsErrNotFound(err) || alreadyExists.MatchString(err.Error()) { + continue + } + assert.NoError(t, err, "failed to remove %s", container.ID) + } +} + +func getAllContainers(ctx context.Context, t assert.TestingT, client client.ContainerAPIClient) []types.Container { + containers, err := client.ContainerList(ctx, types.ContainerListOptions{ + Quiet: true, + All: true, + }) + assert.NoError(t, err, "failed to list containers") + return containers +} + +func deleteAllImages(t testingT, apiclient client.ImageAPIClient, protectedImages map[string]struct{}) { + images, err := apiclient.ImageList(context.Background(), types.ImageListOptions{}) + assert.NoError(t, err, "failed to list images") + + ctx := context.Background() + for _, image := range images { + tags := tagsFromImageSummary(image) + if len(tags) == 0 { + t.Logf("Removing image %s", image.ID) + removeImage(ctx, t, apiclient, image.ID) + continue + } + for _, tag := range tags { + if _, ok := protectedImages[tag]; !ok { + t.Logf("Removing image %s", tag) + removeImage(ctx, t, apiclient, tag) + continue + } + } + } +} + +func removeImage(ctx context.Context, t assert.TestingT, apiclient client.ImageAPIClient, ref string) { + _, err := apiclient.ImageRemove(ctx, ref, types.ImageRemoveOptions{ + Force: true, + }) + if client.IsErrNotFound(err) { + return + } + assert.NoError(t, err, "failed to remove image %s", ref) +} + +func deleteAllVolumes(t assert.TestingT, c client.VolumeAPIClient, protectedVolumes map[string]struct{}) { + volumes, err := c.VolumeList(context.Background(), filters.Args{}) + assert.NoError(t, err, "failed to list volumes") + + for _, v := range volumes.Volumes { + if _, ok := protectedVolumes[v.Name]; ok { + continue + } + err := c.VolumeRemove(context.Background(), v.Name, true) + assert.NoError(t, err, "failed to remove volume %s", v.Name) + } +} + +func deleteAllNetworks(t assert.TestingT, c client.NetworkAPIClient, daemonPlatform string, protectedNetworks map[string]struct{}) { + networks, err := c.NetworkList(context.Background(), types.NetworkListOptions{}) + assert.NoError(t, err, "failed to list networks") + + for _, n := range networks { + if n.Name == "bridge" || n.Name == "none" || n.Name == "host" { + continue + } + if _, ok := protectedNetworks[n.ID]; ok { + continue + } + if daemonPlatform == "windows" && strings.ToLower(n.Name) == "nat" { + // nat is a pre-defined network on Windows and cannot be removed + continue + } + err := c.NetworkRemove(context.Background(), n.ID) + assert.NoError(t, err, "failed to remove network %s", n.ID) + } +} + +func deleteAllPlugins(t assert.TestingT, c client.PluginAPIClient, protectedPlugins map[string]struct{}) { + plugins, err := c.PluginList(context.Background(), filters.Args{}) + assert.NoError(t, err, "failed to list plugins") + + for _, p := range plugins { + if _, ok := protectedPlugins[p.Name]; ok { + continue + } + err := c.PluginRemove(context.Background(), p.Name, types.PluginRemoveOptions{Force: true}) + assert.NoError(t, err, "failed to remove plugin %s", p.ID) + } +} diff --git a/vendor/github.com/docker/docker/internal/test/environment/environment.go b/vendor/github.com/docker/docker/internal/test/environment/environment.go new file mode 100644 index 000000000..afe892935 --- /dev/null +++ b/vendor/github.com/docker/docker/internal/test/environment/environment.go @@ -0,0 +1,117 @@ +package environment + +import ( + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/docker/docker/api/types" + "github.com/docker/docker/client" + "github.com/pkg/errors" + "golang.org/x/net/context" +) + +// Execution contains information about the current test execution and daemon +// under test +type Execution struct { + client client.APIClient + DaemonInfo types.Info + PlatformDefaults PlatformDefaults + protectedElements protectedElements +} + +// PlatformDefaults are defaults values for the platform of the daemon under test +type PlatformDefaults struct { + BaseImage string + VolumesConfigPath string + ContainerStoragePath string +} + +// New creates a new Execution struct +func New() (*Execution, error) { + client, err := client.NewEnvClient() + if err != nil { + return nil, errors.Wrapf(err, "failed to create client") + } + + info, err := client.Info(context.Background()) + if err != nil { + return nil, errors.Wrapf(err, "failed to get info from daemon") + } + + return &Execution{ + client: client, + DaemonInfo: info, + PlatformDefaults: getPlatformDefaults(info), + protectedElements: newProtectedElements(), + }, nil +} + +func getPlatformDefaults(info types.Info) PlatformDefaults { + volumesPath := filepath.Join(info.DockerRootDir, "volumes") + containersPath := filepath.Join(info.DockerRootDir, "containers") + + switch info.OSType { + case "linux": + return PlatformDefaults{ + BaseImage: "scratch", + VolumesConfigPath: toSlash(volumesPath), + ContainerStoragePath: toSlash(containersPath), + } + case "windows": + baseImage := "microsoft/windowsservercore" + if override := os.Getenv("WINDOWS_BASE_IMAGE"); override != "" { + baseImage = override + fmt.Println("INFO: Windows Base image is ", baseImage) + } + return PlatformDefaults{ + BaseImage: baseImage, + VolumesConfigPath: filepath.FromSlash(volumesPath), + ContainerStoragePath: filepath.FromSlash(containersPath), + } + default: + panic(fmt.Sprintf("unknown info.OSType for daemon: %s", info.OSType)) + } +} + +// Make sure in context of daemon, not the local platform. Note we can't +// use filepath.FromSlash or ToSlash here as they are a no-op on Unix. +func toSlash(path string) string { + return strings.Replace(path, `\`, `/`, -1) +} + +// IsLocalDaemon is true if the daemon under test is on the same +// host as the CLI. +// +// Deterministically working out the environment in which CI is running +// to evaluate whether the daemon is local or remote is not possible through +// a build tag. +// +// For example Windows to Linux CI under Jenkins tests the 64-bit +// Windows binary build with the daemon build tag, but calls a remote +// Linux daemon. +// +// We can't just say if Windows then assume the daemon is local as at +// some point, we will be testing the Windows CLI against a Windows daemon. +// +// Similarly, it will be perfectly valid to also run CLI tests from +// a Linux CLI (built with the daemon tag) against a Windows daemon. +func (e *Execution) IsLocalDaemon() bool { + return os.Getenv("DOCKER_REMOTE_DAEMON") == "" +} + +// Print the execution details to stdout +// TODO: print everything +func (e *Execution) Print() { + if e.IsLocalDaemon() { + fmt.Println("INFO: Testing against a local daemon") + } else { + fmt.Println("INFO: Testing against a remote daemon") + } +} + +// APIClient returns an APIClient connected to the daemon under test +func (e *Execution) APIClient() client.APIClient { + return e.client +} diff --git a/vendor/github.com/docker/docker/internal/test/environment/protect.go b/vendor/github.com/docker/docker/internal/test/environment/protect.go new file mode 100644 index 000000000..2e882c847 --- /dev/null +++ b/vendor/github.com/docker/docker/internal/test/environment/protect.go @@ -0,0 +1,208 @@ +package environment + +import ( + "context" + + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/integration-cli/fixtures/load" + "github.com/stretchr/testify/require" +) + +type protectedElements struct { + containers map[string]struct{} + images map[string]struct{} + networks map[string]struct{} + plugins map[string]struct{} + volumes map[string]struct{} +} + +func newProtectedElements() protectedElements { + return protectedElements{ + containers: map[string]struct{}{}, + images: map[string]struct{}{}, + networks: map[string]struct{}{}, + plugins: map[string]struct{}{}, + volumes: map[string]struct{}{}, + } +} + +// ProtectAll protects the existing environment (containers, images, networks, +// volumes, and, on Linux, plugins) from being cleaned up at the end of test +// runs +func ProtectAll(t testingT, testEnv *Execution) { + ProtectContainers(t, testEnv) + ProtectImages(t, testEnv) + ProtectNetworks(t, testEnv) + ProtectVolumes(t, testEnv) + if testEnv.DaemonInfo.OSType == "linux" { + ProtectPlugins(t, testEnv) + } +} + +// ProtectContainer adds the specified container(s) to be protected in case of +// clean +func (e *Execution) ProtectContainer(t testingT, containers ...string) { + for _, container := range containers { + e.protectedElements.containers[container] = struct{}{} + } +} + +// ProtectContainers protects existing containers from being cleaned up at the +// end of test runs +func ProtectContainers(t testingT, testEnv *Execution) { + containers := getExistingContainers(t, testEnv) + testEnv.ProtectContainer(t, containers...) +} + +func getExistingContainers(t require.TestingT, testEnv *Execution) []string { + client := testEnv.APIClient() + containerList, err := client.ContainerList(context.Background(), types.ContainerListOptions{ + All: true, + }) + require.NoError(t, err, "failed to list containers") + + containers := []string{} + for _, container := range containerList { + containers = append(containers, container.ID) + } + return containers +} + +// ProtectImage adds the specified image(s) to be protected in case of clean +func (e *Execution) ProtectImage(t testingT, images ...string) { + for _, image := range images { + e.protectedElements.images[image] = struct{}{} + } +} + +// ProtectImages protects existing images and on linux frozen images from being +// cleaned up at the end of test runs +func ProtectImages(t testingT, testEnv *Execution) { + images := getExistingImages(t, testEnv) + + if testEnv.DaemonInfo.OSType == "linux" { + images = append(images, ensureFrozenImagesLinux(t, testEnv)...) + } + testEnv.ProtectImage(t, images...) +} + +func getExistingImages(t require.TestingT, testEnv *Execution) []string { + client := testEnv.APIClient() + filter := filters.NewArgs() + filter.Add("dangling", "false") + imageList, err := client.ImageList(context.Background(), types.ImageListOptions{ + All: true, + Filters: filter, + }) + require.NoError(t, err, "failed to list images") + + images := []string{} + for _, image := range imageList { + images = append(images, tagsFromImageSummary(image)...) + } + return images +} + +func tagsFromImageSummary(image types.ImageSummary) []string { + result := []string{} + for _, tag := range image.RepoTags { + if tag != ":" { + result = append(result, tag) + } + } + for _, digest := range image.RepoDigests { + if digest != "@" { + result = append(result, digest) + } + } + return result +} + +func ensureFrozenImagesLinux(t testingT, testEnv *Execution) []string { + images := []string{"busybox:latest", "hello-world:frozen", "debian:jessie"} + err := load.FrozenImagesLinux(testEnv.APIClient(), images...) + if err != nil { + t.Fatalf("Failed to load frozen images: %s", err) + } + return images +} + +// ProtectNetwork adds the specified network(s) to be protected in case of +// clean +func (e *Execution) ProtectNetwork(t testingT, networks ...string) { + for _, network := range networks { + e.protectedElements.networks[network] = struct{}{} + } +} + +// ProtectNetworks protects existing networks from being cleaned up at the end +// of test runs +func ProtectNetworks(t testingT, testEnv *Execution) { + networks := getExistingNetworks(t, testEnv) + testEnv.ProtectNetwork(t, networks...) +} + +func getExistingNetworks(t require.TestingT, testEnv *Execution) []string { + client := testEnv.APIClient() + networkList, err := client.NetworkList(context.Background(), types.NetworkListOptions{}) + require.NoError(t, err, "failed to list networks") + + networks := []string{} + for _, network := range networkList { + networks = append(networks, network.ID) + } + return networks +} + +// ProtectPlugin adds the specified plugin(s) to be protected in case of clean +func (e *Execution) ProtectPlugin(t testingT, plugins ...string) { + for _, plugin := range plugins { + e.protectedElements.plugins[plugin] = struct{}{} + } +} + +// ProtectPlugins protects existing plugins from being cleaned up at the end of +// test runs +func ProtectPlugins(t testingT, testEnv *Execution) { + plugins := getExistingPlugins(t, testEnv) + testEnv.ProtectPlugin(t, plugins...) +} + +func getExistingPlugins(t require.TestingT, testEnv *Execution) []string { + client := testEnv.APIClient() + pluginList, err := client.PluginList(context.Background(), filters.Args{}) + require.NoError(t, err, "failed to list plugins") + + plugins := []string{} + for _, plugin := range pluginList { + plugins = append(plugins, plugin.Name) + } + return plugins +} + +// ProtectVolume adds the specified volume(s) to be protected in case of clean +func (e *Execution) ProtectVolume(t testingT, volumes ...string) { + for _, volume := range volumes { + e.protectedElements.volumes[volume] = struct{}{} + } +} + +// ProtectVolumes protects existing volumes from being cleaned up at the end of +// test runs +func ProtectVolumes(t testingT, testEnv *Execution) { + volumes := getExistingVolumes(t, testEnv) + testEnv.ProtectVolume(t, volumes...) +} + +func getExistingVolumes(t require.TestingT, testEnv *Execution) []string { + client := testEnv.APIClient() + volumeList, err := client.VolumeList(context.Background(), filters.Args{}) + require.NoError(t, err, "failed to list volumes") + + volumes := []string{} + for _, volume := range volumeList.Volumes { + volumes = append(volumes, volume.Name) + } + return volumes +} diff --git a/vendor/github.com/docker/docker/internal/testutil/helpers.go b/vendor/github.com/docker/docker/internal/testutil/helpers.go new file mode 100644 index 000000000..a76056924 --- /dev/null +++ b/vendor/github.com/docker/docker/internal/testutil/helpers.go @@ -0,0 +1,13 @@ +package testutil + +import ( + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// ErrorContains checks that the error is not nil, and contains the expected +// substring. +func ErrorContains(t require.TestingT, err error, expectedError string, msgAndArgs ...interface{}) { + require.Error(t, err, msgAndArgs...) + assert.Contains(t, err.Error(), expectedError, msgAndArgs...) +} diff --git a/vendor/github.com/docker/docker/layer/empty_test.go b/vendor/github.com/docker/docker/layer/empty_test.go index 5555dbd8a..abafc23ac 100644 --- a/vendor/github.com/docker/docker/layer/empty_test.go +++ b/vendor/github.com/docker/docker/layer/empty_test.go @@ -28,6 +28,12 @@ func TestEmptyLayer(t *testing.T) { t.Fatal("expected zero diffsize for empty layer") } + meta, err := EmptyLayer.Metadata() + + if len(meta) != 0 || err != nil { + t.Fatal("expected zero length metadata for empty layer") + } + tarStream, err := EmptyLayer.TarStream() if err != nil { t.Fatalf("error streaming tar for empty layer: %v", err) diff --git a/vendor/github.com/docker/docker/layer/layer.go b/vendor/github.com/docker/docker/layer/layer.go index e269ef8a4..4ff159e9f 100644 --- a/vendor/github.com/docker/docker/layer/layer.go +++ b/vendor/github.com/docker/docker/layer/layer.go @@ -15,6 +15,7 @@ import ( "github.com/docker/distribution" "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/containerfs" "github.com/opencontainers/go-digest" "github.com/sirupsen/logrus" ) @@ -137,7 +138,7 @@ type RWLayer interface { // Mount mounts the RWLayer and returns the filesystem path // the to the writable layer. - Mount(mountLabel string) (string, error) + Mount(mountLabel string) (containerfs.ContainerFS, error) // Unmount unmounts the RWLayer. This should be called // for every mount. If there are multiple mount calls @@ -178,7 +179,7 @@ type Metadata struct { // writable mount. Changes made here will // not be included in the Tar stream of the // RWLayer. -type MountInit func(root string) error +type MountInit func(root containerfs.ContainerFS) error // CreateRWLayerOpts contains optional arguments to be passed to CreateRWLayer type CreateRWLayerOpts struct { diff --git a/vendor/github.com/docker/docker/layer/layer_store.go b/vendor/github.com/docker/docker/layer/layer_store.go index 728301445..c3973cef7 100644 --- a/vendor/github.com/docker/docker/layer/layer_store.go +++ b/vendor/github.com/docker/docker/layer/layer_store.go @@ -749,5 +749,5 @@ func (n *naiveDiffPathDriver) DiffGetter(id string) (graphdriver.FileGetCloser, if err != nil { return nil, err } - return &fileGetPutter{storage.NewPathFileGetter(p), n.Driver, id}, nil + return &fileGetPutter{storage.NewPathFileGetter(p.Path()), n.Driver, id}, nil } diff --git a/vendor/github.com/docker/docker/layer/layer_test.go b/vendor/github.com/docker/docker/layer/layer_test.go index 8ec5b4df5..5839ac385 100644 --- a/vendor/github.com/docker/docker/layer/layer_test.go +++ b/vendor/github.com/docker/docker/layer/layer_test.go @@ -10,9 +10,11 @@ import ( "strings" "testing" + "github.com/containerd/continuity/driver" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/daemon/graphdriver/vfs" "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/stringid" "github.com/opencontainers/go-digest" @@ -82,7 +84,7 @@ func newTestStore(t *testing.T) (Store, string, func()) { } } -type layerInit func(root string) error +type layerInit func(root containerfs.ContainerFS) error func createLayer(ls Store, parent ChainID, layerFunc layerInit) (Layer, error) { containerID := stringid.GenerateRandomID() @@ -91,12 +93,12 @@ func createLayer(ls Store, parent ChainID, layerFunc layerInit) (Layer, error) { return nil, err } - path, err := mount.Mount("") + pathFS, err := mount.Mount("") if err != nil { return nil, err } - if err := layerFunc(path); err != nil { + if err := layerFunc(pathFS); err != nil { return nil, err } @@ -123,7 +125,7 @@ func createLayer(ls Store, parent ChainID, layerFunc layerInit) (Layer, error) { } type FileApplier interface { - ApplyFile(root string) error + ApplyFile(root containerfs.ContainerFS) error } type testFile struct { @@ -140,25 +142,25 @@ func newTestFile(name string, content []byte, perm os.FileMode) FileApplier { } } -func (tf *testFile) ApplyFile(root string) error { - fullPath := filepath.Join(root, tf.name) - if err := os.MkdirAll(filepath.Dir(fullPath), 0755); err != nil { +func (tf *testFile) ApplyFile(root containerfs.ContainerFS) error { + fullPath := root.Join(root.Path(), tf.name) + if err := root.MkdirAll(root.Dir(fullPath), 0755); err != nil { return err } // Check if already exists - if stat, err := os.Stat(fullPath); err == nil && stat.Mode().Perm() != tf.permission { - if err := os.Chmod(fullPath, tf.permission); err != nil { + if stat, err := root.Stat(fullPath); err == nil && stat.Mode().Perm() != tf.permission { + if err := root.Lchmod(fullPath, tf.permission); err != nil { return err } } - if err := ioutil.WriteFile(fullPath, tf.content, tf.permission); err != nil { + if err := driver.WriteFile(root, fullPath, tf.content, tf.permission); err != nil { return err } return nil } func initWithFiles(files ...FileApplier) layerInit { - return func(root string) error { + return func(root containerfs.ContainerFS) error { for _, f := range files { if err := f.ApplyFile(root); err != nil { return err @@ -288,7 +290,7 @@ func TestMountAndRegister(t *testing.T) { t.Fatal(err) } - b, err := ioutil.ReadFile(filepath.Join(path2, "testfile.txt")) + b, err := driver.ReadFile(path2, path2.Join(path2.Path(), "testfile.txt")) if err != nil { t.Fatal(err) } @@ -391,12 +393,12 @@ func TestStoreRestore(t *testing.T) { t.Fatal(err) } - path, err := m.Mount("") + pathFS, err := m.Mount("") if err != nil { t.Fatal(err) } - if err := ioutil.WriteFile(filepath.Join(path, "testfile.txt"), []byte("nothing here"), 0644); err != nil { + if err := driver.WriteFile(pathFS, pathFS.Join(pathFS.Path(), "testfile.txt"), []byte("nothing here"), 0644); err != nil { t.Fatal(err) } @@ -430,20 +432,20 @@ func TestStoreRestore(t *testing.T) { if mountPath, err := m2.Mount(""); err != nil { t.Fatal(err) - } else if path != mountPath { - t.Fatalf("Unexpected path %s, expected %s", mountPath, path) + } else if pathFS.Path() != mountPath.Path() { + t.Fatalf("Unexpected path %s, expected %s", mountPath.Path(), pathFS.Path()) } if mountPath, err := m2.Mount(""); err != nil { t.Fatal(err) - } else if path != mountPath { - t.Fatalf("Unexpected path %s, expected %s", mountPath, path) + } else if pathFS.Path() != mountPath.Path() { + t.Fatalf("Unexpected path %s, expected %s", mountPath.Path(), pathFS.Path()) } if err := m2.Unmount(); err != nil { t.Fatal(err) } - b, err := ioutil.ReadFile(filepath.Join(path, "testfile.txt")) + b, err := driver.ReadFile(pathFS, pathFS.Join(pathFS.Path(), "testfile.txt")) if err != nil { t.Fatal(err) } @@ -618,7 +620,7 @@ func tarFromFiles(files ...FileApplier) ([]byte, error) { defer os.RemoveAll(td) for _, f := range files { - if err := f.ApplyFile(td); err != nil { + if err := f.ApplyFile(containerfs.NewLocalContainerFS(td)); err != nil { return nil, err } } diff --git a/vendor/github.com/docker/docker/layer/layer_windows.go b/vendor/github.com/docker/docker/layer/layer_windows.go index a1c195311..d02d4d0dd 100644 --- a/vendor/github.com/docker/docker/layer/layer_windows.go +++ b/vendor/github.com/docker/docker/layer/layer_windows.go @@ -1,6 +1,15 @@ package layer -import "errors" +import ( + "errors" +) + +// Getter is an interface to get the path to a layer on the host. +type Getter interface { + // GetLayerPath gets the path for the layer. This is different from Get() + // since that returns an interface to account for umountable layers. + GetLayerPath(id string) (string, error) +} // GetLayerPath returns the path to a layer func GetLayerPath(s Store, layer ChainID) (string, error) { @@ -16,6 +25,10 @@ func GetLayerPath(s Store, layer ChainID) (string, error) { return "", ErrLayerDoesNotExist } + if layerGetter, ok := ls.driver.(Getter); ok { + return layerGetter.GetLayerPath(rl.cacheID) + } + path, err := ls.driver.Get(rl.cacheID, "") if err != nil { return "", err @@ -25,7 +38,7 @@ func GetLayerPath(s Store, layer ChainID) (string, error) { return "", err } - return path, nil + return path.Path(), nil } func (ls *layerStore) mountID(name string) string { diff --git a/vendor/github.com/docker/docker/layer/mount_test.go b/vendor/github.com/docker/docker/layer/mount_test.go index f5799e7cd..44d461f9b 100644 --- a/vendor/github.com/docker/docker/layer/mount_test.go +++ b/vendor/github.com/docker/docker/layer/mount_test.go @@ -2,13 +2,13 @@ package layer import ( "io/ioutil" - "os" - "path/filepath" "runtime" "sort" "testing" + "github.com/containerd/continuity/driver" "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/containerfs" ) func TestMountInit(t *testing.T) { @@ -28,7 +28,7 @@ func TestMountInit(t *testing.T) { t.Fatal(err) } - mountInit := func(root string) error { + mountInit := func(root containerfs.ContainerFS) error { return initfile.ApplyFile(root) } @@ -40,21 +40,21 @@ func TestMountInit(t *testing.T) { t.Fatal(err) } - path, err := m.Mount("") + pathFS, err := m.Mount("") if err != nil { t.Fatal(err) } - f, err := os.Open(filepath.Join(path, "testfile.txt")) + fi, err := pathFS.Stat(pathFS.Join(pathFS.Path(), "testfile.txt")) if err != nil { t.Fatal(err) } - defer f.Close() - fi, err := f.Stat() + f, err := pathFS.Open(pathFS.Join(pathFS.Path(), "testfile.txt")) if err != nil { t.Fatal(err) } + defer f.Close() b, err := ioutil.ReadAll(f) if err != nil { @@ -88,7 +88,7 @@ func TestMountSize(t *testing.T) { t.Fatal(err) } - mountInit := func(root string) error { + mountInit := func(root containerfs.ContainerFS) error { return newTestFile("file-init", contentInit, 0777).ApplyFile(root) } rwLayerOpts := &CreateRWLayerOpts{ @@ -100,12 +100,12 @@ func TestMountSize(t *testing.T) { t.Fatal(err) } - path, err := m.Mount("") + pathFS, err := m.Mount("") if err != nil { t.Fatal(err) } - if err := ioutil.WriteFile(filepath.Join(path, "file2"), content2, 0755); err != nil { + if err := driver.WriteFile(pathFS, pathFS.Join(pathFS.Path(), "file2"), content2, 0755); err != nil { t.Fatal(err) } @@ -140,7 +140,7 @@ func TestMountChanges(t *testing.T) { t.Fatal(err) } - mountInit := func(root string) error { + mountInit := func(root containerfs.ContainerFS) error { return initfile.ApplyFile(root) } rwLayerOpts := &CreateRWLayerOpts{ @@ -152,28 +152,28 @@ func TestMountChanges(t *testing.T) { t.Fatal(err) } - path, err := m.Mount("") + pathFS, err := m.Mount("") if err != nil { t.Fatal(err) } - if err := os.Chmod(filepath.Join(path, "testfile1.txt"), 0755); err != nil { + if err := pathFS.Lchmod(pathFS.Join(pathFS.Path(), "testfile1.txt"), 0755); err != nil { t.Fatal(err) } - if err := ioutil.WriteFile(filepath.Join(path, "testfile1.txt"), []byte("mount data!"), 0755); err != nil { + if err := driver.WriteFile(pathFS, pathFS.Join(pathFS.Path(), "testfile1.txt"), []byte("mount data!"), 0755); err != nil { t.Fatal(err) } - if err := os.Remove(filepath.Join(path, "testfile2.txt")); err != nil { + if err := pathFS.Remove(pathFS.Join(pathFS.Path(), "testfile2.txt")); err != nil { t.Fatal(err) } - if err := os.Chmod(filepath.Join(path, "testfile3.txt"), 0755); err != nil { + if err := pathFS.Lchmod(pathFS.Join(pathFS.Path(), "testfile3.txt"), 0755); err != nil { t.Fatal(err) } - if err := ioutil.WriteFile(filepath.Join(path, "testfile4.txt"), []byte("mount data!"), 0644); err != nil { + if err := driver.WriteFile(pathFS, pathFS.Join(pathFS.Path(), "testfile4.txt"), []byte("mount data!"), 0644); err != nil { t.Fatal(err) } diff --git a/vendor/github.com/docker/docker/layer/mounted_layer.go b/vendor/github.com/docker/docker/layer/mounted_layer.go index a5cfcfa9b..47ef96698 100644 --- a/vendor/github.com/docker/docker/layer/mounted_layer.go +++ b/vendor/github.com/docker/docker/layer/mounted_layer.go @@ -4,6 +4,7 @@ import ( "io" "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/containerfs" ) type mountedLayer struct { @@ -88,7 +89,7 @@ type referencedRWLayer struct { *mountedLayer } -func (rl *referencedRWLayer) Mount(mountLabel string) (string, error) { +func (rl *referencedRWLayer) Mount(mountLabel string) (containerfs.ContainerFS, error) { return rl.layerStore.driver.Get(rl.mountedLayer.mountID, mountLabel) } diff --git a/vendor/github.com/docker/docker/libcontainerd/client_linux.go b/vendor/github.com/docker/docker/libcontainerd/client_linux.go index 6c3460a8c..12808fd0c 100644 --- a/vendor/github.com/docker/docker/libcontainerd/client_linux.go +++ b/vendor/github.com/docker/docker/libcontainerd/client_linux.go @@ -296,10 +296,7 @@ func (clnt *client) UpdateResources(containerID string, resources Resources) err Pid: InitFriendlyName, Resources: (*containerd.UpdateResource)(&resources), }) - if err != nil { - return err - } - return nil + return err } func (clnt *client) getExitNotifier(containerID string) *exitNotifier { diff --git a/vendor/github.com/docker/docker/libcontainerd/client_solaris.go b/vendor/github.com/docker/docker/libcontainerd/client_solaris.go index cb939975f..c54cea3bf 100644 --- a/vendor/github.com/docker/docker/libcontainerd/client_solaris.go +++ b/vendor/github.com/docker/docker/libcontainerd/client_solaris.go @@ -1,6 +1,9 @@ package libcontainerd -import "golang.org/x/net/context" +import ( + containerd "github.com/containerd/containerd/api/grpc/types" + "golang.org/x/net/context" +) type client struct { clientCommon diff --git a/vendor/github.com/docker/docker/libcontainerd/client_unix.go b/vendor/github.com/docker/docker/libcontainerd/client_unix.go index 129e87bd7..202a5b09b 100644 --- a/vendor/github.com/docker/docker/libcontainerd/client_unix.go +++ b/vendor/github.com/docker/docker/libcontainerd/client_unix.go @@ -50,7 +50,7 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir return fmt.Errorf("Container %s is already active", containerID) } - uid, gid, err := getRootIDs(specs.Spec(spec)) + uid, gid, err := getRootIDs(spec) if err != nil { return err } diff --git a/vendor/github.com/docker/docker/libcontainerd/client_windows.go b/vendor/github.com/docker/docker/libcontainerd/client_windows.go index d1fd2d8f9..df9e40ea3 100644 --- a/vendor/github.com/docker/docker/libcontainerd/client_windows.go +++ b/vendor/github.com/docker/docker/libcontainerd/client_windows.go @@ -7,7 +7,9 @@ import ( "io" "io/ioutil" "os" + "path" "path/filepath" + "regexp" "strings" "syscall" "time" @@ -15,7 +17,9 @@ import ( "golang.org/x/net/context" "github.com/Microsoft/hcsshim" + opengcs "github.com/Microsoft/opengcs/client" "github.com/docker/docker/pkg/sysinfo" + "github.com/docker/docker/pkg/system" specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" ) @@ -100,8 +104,11 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir if b, err := json.Marshal(spec); err == nil { logrus.Debugln("libcontainerd: client.Create() with spec", string(b)) } - osName := spec.Platform.OS - if osName == "windows" { + + // spec.Linux must be nil for Windows containers, but spec.Windows will be filled in regardless of container platform. + // This is a temporary workaround due to LCOW requiring layer folder paths, which are stored under spec.Windows. + // TODO: @darrenstahlmsft fix this once the OCI spec is updated to support layer folder paths for LCOW + if spec.Linux == nil { return clnt.createWindows(containerID, checkpoint, checkpointDir, spec, attachStdio, options...) } return clnt.createLinux(containerID, checkpoint, checkpointDir, spec, attachStdio, options...) @@ -112,9 +119,10 @@ func (clnt *client) createWindows(containerID string, checkpoint string, checkpo SystemType: "Container", Name: containerID, Owner: defaultOwner, - IgnoreFlushesDuringBoot: false, + IgnoreFlushesDuringBoot: spec.Windows.IgnoreFlushesDuringBoot, HostName: spec.Hostname, HvPartition: false, + Servicing: spec.Windows.Servicing, } if spec.Windows.Resources != nil { @@ -153,49 +161,43 @@ func (clnt *client) createWindows(containerID string, checkpoint string, checkpo } } - var layerOpt *LayerOption - for _, option := range options { - if s, ok := option.(*ServicingOption); ok { - configuration.Servicing = s.IsServicing - continue - } - if f, ok := option.(*FlushOption); ok { - configuration.IgnoreFlushesDuringBoot = f.IgnoreFlushesDuringBoot - continue - } - if h, ok := option.(*HyperVIsolationOption); ok { - configuration.HvPartition = h.IsHyperV - continue - } - if l, ok := option.(*LayerOption); ok { - layerOpt = l - } - if n, ok := option.(*NetworkEndpointsOption); ok { - configuration.EndpointList = n.Endpoints - configuration.AllowUnqualifiedDNSQuery = n.AllowUnqualifiedDNSQuery - if n.DNSSearchList != nil { - configuration.DNSSearchList = strings.Join(n.DNSSearchList, ",") - } - configuration.NetworkSharedContainerName = n.NetworkSharedContainerID - continue - } - if c, ok := option.(*CredentialsOption); ok { - configuration.Credentials = c.Credentials - continue + if spec.Windows.HyperV != nil { + configuration.HvPartition = true + } + + if spec.Windows.Network != nil { + configuration.EndpointList = spec.Windows.Network.EndpointList + configuration.AllowUnqualifiedDNSQuery = spec.Windows.Network.AllowUnqualifiedDNSQuery + if spec.Windows.Network.DNSSearchList != nil { + configuration.DNSSearchList = strings.Join(spec.Windows.Network.DNSSearchList, ",") } + configuration.NetworkSharedContainerName = spec.Windows.Network.NetworkSharedContainerName } - // We must have a layer option with at least one path - if layerOpt == nil || layerOpt.LayerPaths == nil { - return fmt.Errorf("no layer option or paths were supplied to the runtime") + if cs, ok := spec.Windows.CredentialSpec.(string); ok { + configuration.Credentials = cs } + // We must have least two layers in the spec, the bottom one being a base image, + // the top one being the RW layer. + if spec.Windows.LayerFolders == nil || len(spec.Windows.LayerFolders) < 2 { + return fmt.Errorf("OCI spec is invalid - at least two LayerFolders must be supplied to the runtime") + } + + // Strip off the top-most layer as that's passed in separately to HCS + configuration.LayerFolderPath = spec.Windows.LayerFolders[len(spec.Windows.LayerFolders)-1] + layerFolders := spec.Windows.LayerFolders[:len(spec.Windows.LayerFolders)-1] + if configuration.HvPartition { - // Find the upper-most utility VM image, since the utility VM does not - // use layering in RS1. - // TODO @swernli/jhowardmsft at some point post RS1 this may be re-locatable. + // We don't currently support setting the utility VM image explicitly. + // TODO @swernli/jhowardmsft circa RS3/4, this may be re-locatable. + if spec.Windows.HyperV.UtilityVMPath != "" { + return errors.New("runtime does not support an explicit utility VM path for Hyper-V containers") + } + + // Find the upper-most utility VM image. var uvmImagePath string - for _, path := range layerOpt.LayerPaths { + for _, path := range layerFolders { fullPath := filepath.Join(path, "UtilityVM") _, err := os.Stat(fullPath) if err == nil { @@ -210,13 +212,24 @@ func (clnt *client) createWindows(containerID string, checkpoint string, checkpo return errors.New("utility VM image could not be found") } configuration.HvRuntime = &hcsshim.HvRuntime{ImagePath: uvmImagePath} + + if spec.Root.Path != "" { + return errors.New("OCI spec is invalid - Root.Path must be omitted for a Hyper-V container") + } } else { - configuration.VolumePath = spec.Root.Path + const volumeGUIDRegex = `^\\\\\?\\(Volume)\{{0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}\}\\$` + if _, err := regexp.MatchString(volumeGUIDRegex, spec.Root.Path); err != nil { + return fmt.Errorf(`OCI spec is invalid - Root.Path '%s' must be a volume GUID path in the format '\\?\Volume{GUID}\'`, spec.Root.Path) + } + // HCS API requires the trailing backslash to be removed + configuration.VolumePath = spec.Root.Path[:len(spec.Root.Path)-1] } - configuration.LayerFolderPath = layerOpt.LayerFolderPath + if spec.Root.Readonly { + return errors.New(`OCI spec is invalid - Root.Readonly must not be set on Windows`) + } - for _, layerPath := range layerOpt.LayerPaths { + for _, layerPath := range layerFolders { _, filename := filepath.Split(layerPath) g, err := hcsshim.NameToGuid(filename) if err != nil { @@ -229,20 +242,38 @@ func (clnt *client) createWindows(containerID string, checkpoint string, checkpo } // Add the mounts (volumes, bind mounts etc) to the structure - mds := make([]hcsshim.MappedDir, len(spec.Mounts)) - for i, mount := range spec.Mounts { - mds[i] = hcsshim.MappedDir{ - HostPath: mount.Source, - ContainerPath: mount.Destination, - ReadOnly: false, + var mds []hcsshim.MappedDir + var mps []hcsshim.MappedPipe + for _, mount := range spec.Mounts { + const pipePrefix = `\\.\pipe\` + if mount.Type != "" { + return fmt.Errorf("OCI spec is invalid - Mount.Type '%s' must not be set", mount.Type) } - for _, o := range mount.Options { - if strings.ToLower(o) == "ro" { - mds[i].ReadOnly = true + if strings.HasPrefix(mount.Destination, pipePrefix) { + mp := hcsshim.MappedPipe{ + HostPath: mount.Source, + ContainerPipeName: mount.Destination[len(pipePrefix):], + } + mps = append(mps, mp) + } else { + md := hcsshim.MappedDir{ + HostPath: mount.Source, + ContainerPath: mount.Destination, + ReadOnly: false, } + for _, o := range mount.Options { + if strings.ToLower(o) == "ro" { + md.ReadOnly = true + } + } + mds = append(mds, md) } } configuration.MappedDirectories = mds + if len(mps) > 0 && system.GetOSVersion().Build < 16210 { // replace with Win10 RS3 build number at RTM + return errors.New("named pipe mounts are not supported on this version of Windows") + } + configuration.MappedPipes = mps hcsContainer, err := hcsshim.CreateContainer(containerID, configuration) if err != nil { @@ -261,6 +292,7 @@ func (clnt *client) createWindows(containerID string, checkpoint string, checkpo }, processes: make(map[string]*process), }, + isWindows: true, ociSpec: spec, hcsContainer: hcsContainer, } @@ -289,8 +321,16 @@ func (clnt *client) createWindows(containerID string, checkpoint string, checkpo func (clnt *client) createLinux(containerID string, checkpoint string, checkpointDir string, spec specs.Spec, attachStdio StdioCallback, options ...CreateOption) error { logrus.Debugf("libcontainerd: createLinux(): containerId %s ", containerID) - // TODO @jhowardmsft LCOW Support: This needs to be configurable, not hard-coded. - // However, good-enough for the LCOW bring-up. + var lcowOpt *LCOWOption + for _, option := range options { + if lcow, ok := option.(*LCOWOption); ok { + lcowOpt = lcow + } + } + if lcowOpt == nil || lcowOpt.Config == nil { + return fmt.Errorf("lcow option must be supplied to the runtime") + } + configuration := &hcsshim.ContainerConfig{ HvPartition: true, Name: containerID, @@ -298,28 +338,37 @@ func (clnt *client) createLinux(containerID string, checkpoint string, checkpoin ContainerType: "linux", Owner: defaultOwner, TerminateOnLastHandleClosed: true, - HvRuntime: &hcsshim.HvRuntime{ - ImagePath: `c:\Program Files\Linux Containers`, - LinuxKernelFile: `bootx64.efi`, - LinuxInitrdFile: `initrd.img`, - }, } - var layerOpt *LayerOption - for _, option := range options { - if l, ok := option.(*LayerOption); ok { - layerOpt = l + if lcowOpt.Config.ActualMode == opengcs.ModeActualVhdx { + configuration.HvRuntime = &hcsshim.HvRuntime{ + ImagePath: lcowOpt.Config.Vhdx, + BootSource: "Vhd", + WritableBootSource: false, + } + } else { + configuration.HvRuntime = &hcsshim.HvRuntime{ + ImagePath: lcowOpt.Config.KirdPath, + LinuxKernelFile: lcowOpt.Config.KernelFile, + LinuxInitrdFile: lcowOpt.Config.InitrdFile, + LinuxBootParameters: lcowOpt.Config.BootParameters, } } - // We must have a layer option with at least one path - if layerOpt == nil || layerOpt.LayerPaths == nil { - return fmt.Errorf("no layer option or paths were supplied to the runtime") + if spec.Windows == nil { + return fmt.Errorf("spec.Windows must not be nil for LCOW containers") } - // LayerFolderPath (writeable layer) + Layers (Guid + path) - configuration.LayerFolderPath = layerOpt.LayerFolderPath - for _, layerPath := range layerOpt.LayerPaths { + // We must have least one layer in the spec + if spec.Windows.LayerFolders == nil || len(spec.Windows.LayerFolders) == 0 { + return fmt.Errorf("OCI spec is invalid - at least one LayerFolders must be supplied to the runtime") + } + + // Strip off the top-most layer as that's passed in separately to HCS + configuration.LayerFolderPath = spec.Windows.LayerFolders[len(spec.Windows.LayerFolders)-1] + layerFolders := spec.Windows.LayerFolders[:len(spec.Windows.LayerFolders)-1] + + for _, layerPath := range layerFolders { _, filename := filepath.Split(layerPath) g, err := hcsshim.NameToGuid(filename) if err != nil { @@ -331,23 +380,110 @@ func (clnt *client) createLinux(containerID string, checkpoint string, checkpoin }) } - for _, option := range options { - if n, ok := option.(*NetworkEndpointsOption); ok { - configuration.EndpointList = n.Endpoints - configuration.AllowUnqualifiedDNSQuery = n.AllowUnqualifiedDNSQuery - if n.DNSSearchList != nil { - configuration.DNSSearchList = strings.Join(n.DNSSearchList, ",") + if spec.Windows.Network != nil { + configuration.EndpointList = spec.Windows.Network.EndpointList + configuration.AllowUnqualifiedDNSQuery = spec.Windows.Network.AllowUnqualifiedDNSQuery + if spec.Windows.Network.DNSSearchList != nil { + configuration.DNSSearchList = strings.Join(spec.Windows.Network.DNSSearchList, ",") + } + configuration.NetworkSharedContainerName = spec.Windows.Network.NetworkSharedContainerName + } + + // Add the mounts (volumes, bind mounts etc) to the structure. We have to do + // some translation for both the mapped directories passed into HCS and in + // the spec. + // + // For HCS, we only pass in the mounts from the spec which are type "bind". + // Further, the "ContainerPath" field (which is a little mis-leadingly + // named when it applies to the utility VM rather than the container in the + // utility VM) is moved to under /tmp/gcs//binds, where this is passed + // by the caller through a 'uvmpath' option. + // + // We do similar translation for the mounts in the spec by stripping out + // the uvmpath option, and translating the Source path to the location in the + // utility VM calculated above. + // + // From inside the utility VM, you would see a 9p mount such as in the following + // where a host folder has been mapped to /target. The line with /tmp/gcs//binds + // specifically: + // + // / # mount + // rootfs on / type rootfs (rw,size=463736k,nr_inodes=115934) + // proc on /proc type proc (rw,relatime) + // sysfs on /sys type sysfs (rw,relatime) + // udev on /dev type devtmpfs (rw,relatime,size=498100k,nr_inodes=124525,mode=755) + // tmpfs on /run type tmpfs (rw,relatime) + // cgroup on /sys/fs/cgroup type cgroup (rw,relatime,cpuset,cpu,cpuacct,blkio,memory,devices,freezer,net_cls,perf_event,net_prio,hugetlb,pids,rdma) + // mqueue on /dev/mqueue type mqueue (rw,relatime) + // devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000) + // /binds/b3ea9126d67702173647ece2744f7c11181c0150e9890fc9a431849838033edc/target on /binds/b3ea9126d67702173647ece2744f7c11181c0150e9890fc9a431849838033edc/target type 9p (rw,sync,dirsync,relatime,trans=fd,rfdno=6,wfdno=6) + // /dev/pmem0 on /tmp/gcs/b3ea9126d67702173647ece2744f7c11181c0150e9890fc9a431849838033edc/layer0 type ext4 (ro,relatime,block_validity,delalloc,norecovery,barrier,dax,user_xattr,acl) + // /dev/sda on /tmp/gcs/b3ea9126d67702173647ece2744f7c11181c0150e9890fc9a431849838033edc/scratch type ext4 (rw,relatime,block_validity,delalloc,barrier,user_xattr,acl) + // overlay on /tmp/gcs/b3ea9126d67702173647ece2744f7c11181c0150e9890fc9a431849838033edc/rootfs type overlay (rw,relatime,lowerdir=/tmp/base/:/tmp/gcs/b3ea9126d67702173647ece2744f7c11181c0150e9890fc9a431849838033edc/layer0,upperdir=/tmp/gcs/b3ea9126d67702173647ece2744f7c11181c0150e9890fc9a431849838033edc/scratch/upper,workdir=/tmp/gcs/b3ea9126d67702173647ece2744f7c11181c0150e9890fc9a431849838033edc/scratch/work) + // + // /tmp/gcs/b3ea9126d67702173647ece2744f7c11181c0150e9890fc9a431849838033edc # ls -l + // total 16 + // drwx------ 3 0 0 60 Sep 7 18:54 binds + // -rw-r--r-- 1 0 0 3345 Sep 7 18:54 config.json + // drwxr-xr-x 10 0 0 4096 Sep 6 17:26 layer0 + // drwxr-xr-x 1 0 0 4096 Sep 7 18:54 rootfs + // drwxr-xr-x 5 0 0 4096 Sep 7 18:54 scratch + // + // /tmp/gcs/b3ea9126d67702173647ece2744f7c11181c0150e9890fc9a431849838033edc # ls -l binds + // total 0 + // drwxrwxrwt 2 0 0 4096 Sep 7 16:51 target + + mds := []hcsshim.MappedDir{} + specMounts := []specs.Mount{} + for _, mount := range spec.Mounts { + specMount := mount + if mount.Type == "bind" { + // Strip out the uvmpath from the options + updatedOptions := []string{} + uvmPath := "" + readonly := false + for _, opt := range mount.Options { + dropOption := false + elements := strings.SplitN(opt, "=", 2) + switch elements[0] { + case "uvmpath": + uvmPath = elements[1] + dropOption = true + case "rw": + case "ro": + readonly = true + case "rbind": + default: + return fmt.Errorf("unsupported option %q", opt) + } + if !dropOption { + updatedOptions = append(updatedOptions, opt) + } } - configuration.NetworkSharedContainerName = n.NetworkSharedContainerID - break + mount.Options = updatedOptions + if uvmPath == "" { + return fmt.Errorf("no uvmpath for bind mount %+v", mount) + } + md := hcsshim.MappedDir{ + HostPath: mount.Source, + ContainerPath: path.Join(uvmPath, mount.Destination), + CreateInUtilityVM: true, + ReadOnly: readonly, + } + mds = append(mds, md) + specMount.Source = path.Join(uvmPath, mount.Destination) } + specMounts = append(specMounts, specMount) } + configuration.MappedDirectories = mds hcsContainer, err := hcsshim.CreateContainer(containerID, configuration) if err != nil { return err } + spec.Mounts = specMounts + // Construct a container object for calling start on it. container := &container{ containerCommon: containerCommon{ @@ -394,6 +530,9 @@ func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendly if err != nil { return -1, err } + + defer container.debugGCS() + // Note we always tell HCS to // create stdout as it's required regardless of '-i' or '-t' options, so that // docker can always grab the output through logs. We also tell HCS to always @@ -406,8 +545,10 @@ func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendly } if procToAdd.Terminal { createProcessParms.EmulateConsole = true - createProcessParms.ConsoleSize[0] = uint(procToAdd.ConsoleSize.Height) - createProcessParms.ConsoleSize[1] = uint(procToAdd.ConsoleSize.Width) + if procToAdd.ConsoleSize != nil { + createProcessParms.ConsoleSize[0] = uint(procToAdd.ConsoleSize.Height) + createProcessParms.ConsoleSize[1] = uint(procToAdd.ConsoleSize.Width) + } } // Take working directory from the process to add if it is defined, @@ -420,7 +561,7 @@ func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendly // Configure the environment for the process createProcessParms.Environment = setupEnvironmentVariables(procToAdd.Env) - if container.ociSpec.Platform.OS == "windows" { + if container.isWindows { createProcessParms.CommandLine = strings.Join(procToAdd.Args, " ") } else { createProcessParms.CommandArgs = procToAdd.Args @@ -584,13 +725,8 @@ func (clnt *client) Pause(containerID string) error { return err } - for _, option := range container.options { - if h, ok := option.(*HyperVIsolationOption); ok { - if !h.IsHyperV { - return errors.New("cannot pause Windows Server Containers") - } - break - } + if container.ociSpec.Windows.HyperV == nil { + return errors.New("cannot pause Windows Server Containers") } err = container.hcsContainer.Pause() @@ -624,13 +760,9 @@ func (clnt *client) Resume(containerID string) error { } // This should never happen, since Windows Server Containers cannot be paused - for _, option := range container.options { - if h, ok := option.(*HyperVIsolationOption); ok { - if !h.IsHyperV { - return errors.New("cannot resume Windows Server Containers") - } - break - } + + if container.ociSpec.Windows.HyperV == nil { + return errors.New("cannot resume Windows Server Containers") } err = container.hcsContainer.Resume() diff --git a/vendor/github.com/docker/docker/libcontainerd/container_windows.go b/vendor/github.com/docker/docker/libcontainerd/container_windows.go index b29ac3c5a..73fc6bd41 100644 --- a/vendor/github.com/docker/docker/libcontainerd/container_windows.go +++ b/vendor/github.com/docker/docker/libcontainerd/container_windows.go @@ -9,7 +9,6 @@ import ( "time" "github.com/Microsoft/hcsshim" - "github.com/docker/docker/pkg/system" "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" "golang.org/x/sys/windows" @@ -26,6 +25,7 @@ type container struct { // otherwise have access to the Spec ociSpec specs.Spec + isWindows bool manualStopRequested bool hcsContainer hcsshim.Container } @@ -44,19 +44,13 @@ func (ctr *container) newProcess(friendlyName string) *process { // Caller needs to lock container ID before calling this method. func (ctr *container) start(attachStdio StdioCallback) error { var err error - isServicing := false - - for _, option := range ctr.options { - if s, ok := option.(*ServicingOption); ok && s.IsServicing { - isServicing = true - } - } // Start the container. If this is a servicing container, this call will block // until the container is done with the servicing execution. logrus.Debugln("libcontainerd: starting container ", ctr.containerID) if err = ctr.hcsContainer.Start(); err != nil { logrus.Errorf("libcontainerd: failed to start container: %s", err) + ctr.debugGCS() // Before terminating! if err := ctr.terminate(); err != nil { logrus.Errorf("libcontainerd: failed to cleanup after a failed Start. %s", err) } else { @@ -65,24 +59,38 @@ func (ctr *container) start(attachStdio StdioCallback) error { return err } + defer ctr.debugGCS() + // Note we always tell HCS to // create stdout as it's required regardless of '-i' or '-t' options, so that // docker can always grab the output through logs. We also tell HCS to always // create stdin, even if it's not used - it will be closed shortly. Stderr // is only created if it we're not -t. + var ( + emulateConsole bool + createStdErrPipe bool + ) + if ctr.ociSpec.Process != nil { + emulateConsole = ctr.ociSpec.Process.Terminal + createStdErrPipe = !ctr.ociSpec.Process.Terminal && !ctr.ociSpec.Windows.Servicing + } + createProcessParms := &hcsshim.ProcessConfig{ - EmulateConsole: ctr.ociSpec.Process.Terminal, + EmulateConsole: emulateConsole, WorkingDirectory: ctr.ociSpec.Process.Cwd, - CreateStdInPipe: !isServicing, - CreateStdOutPipe: !isServicing, - CreateStdErrPipe: !ctr.ociSpec.Process.Terminal && !isServicing, + CreateStdInPipe: !ctr.ociSpec.Windows.Servicing, + CreateStdOutPipe: !ctr.ociSpec.Windows.Servicing, + CreateStdErrPipe: createStdErrPipe, + } + + if ctr.ociSpec.Process != nil && ctr.ociSpec.Process.ConsoleSize != nil { + createProcessParms.ConsoleSize[0] = uint(ctr.ociSpec.Process.ConsoleSize.Height) + createProcessParms.ConsoleSize[1] = uint(ctr.ociSpec.Process.ConsoleSize.Width) } - createProcessParms.ConsoleSize[0] = uint(ctr.ociSpec.Process.ConsoleSize.Height) - createProcessParms.ConsoleSize[1] = uint(ctr.ociSpec.Process.ConsoleSize.Width) // Configure the environment for the process createProcessParms.Environment = setupEnvironmentVariables(ctr.ociSpec.Process.Env) - if ctr.ociSpec.Platform.OS == "windows" { + if ctr.isWindows { createProcessParms.CommandLine = strings.Join(ctr.ociSpec.Process.Args, " ") } else { createProcessParms.CommandArgs = ctr.ociSpec.Process.Args @@ -90,7 +98,7 @@ func (ctr *container) start(attachStdio StdioCallback) error { createProcessParms.User = ctr.ociSpec.Process.User.Username // LCOW requires the raw OCI spec passed through HCS and onwards to GCS for the utility VM. - if system.LCOWSupported() && ctr.ociSpec.Platform.OS == "linux" { + if !ctr.isWindows { ociBuf, err := json.Marshal(ctr.ociSpec) if err != nil { return err @@ -119,7 +127,7 @@ func (ctr *container) start(attachStdio StdioCallback) error { // If this is a servicing container, wait on the process synchronously here and // if it succeeds, wait for it cleanly shutdown and merge into the parent container. - if isServicing { + if ctr.ociSpec.Windows.Servicing { exitCode := ctr.waitProcessExitCode(&ctr.process) if exitCode != 0 { @@ -245,7 +253,7 @@ func (ctr *container) waitExit(process *process, isFirstProcessToStart bool) err si.State = StateExitProcess } else { // Pending updates is only applicable for WCOW - if ctr.ociSpec.Platform.OS == "windows" { + if ctr.isWindows { updatePending, err := ctr.hcsContainer.HasPendingUpdates() if err != nil { logrus.Warnf("libcontainerd: HasPendingUpdates() failed (container may have been killed): %s", err) diff --git a/vendor/github.com/docker/docker/libcontainerd/types_linux.go b/vendor/github.com/docker/docker/libcontainerd/types_linux.go index 4f0635835..f21a85eec 100644 --- a/vendor/github.com/docker/docker/libcontainerd/types_linux.go +++ b/vendor/github.com/docker/docker/libcontainerd/types_linux.go @@ -21,7 +21,7 @@ type Process struct { // Capabilities are linux capabilities that are kept for the container. Capabilities []string `json:"capabilities,omitempty"` // Rlimits specifies rlimit options to apply to the process. - Rlimits []specs.LinuxRlimit `json:"rlimits,omitempty"` + Rlimits []specs.POSIXRlimit `json:"rlimits,omitempty"` // ApparmorProfile specifies the apparmor profile for the container. ApparmorProfile *string `json:"apparmorProfile,omitempty"` // SelinuxLabel specifies the selinux context that the container process is run as. diff --git a/vendor/github.com/docker/docker/libcontainerd/types_windows.go b/vendor/github.com/docker/docker/libcontainerd/types_windows.go index 317bfb020..f271ecd47 100644 --- a/vendor/github.com/docker/docker/libcontainerd/types_windows.go +++ b/vendor/github.com/docker/docker/libcontainerd/types_windows.go @@ -2,6 +2,7 @@ package libcontainerd import ( "github.com/Microsoft/hcsshim" + opengcs "github.com/Microsoft/opengcs/client" "github.com/opencontainers/runtime-spec/specs-go" ) @@ -25,47 +26,9 @@ type Stats hcsshim.Statistics // Resources defines updatable container resource values. type Resources struct{} -// ServicingOption is a CreateOption with a no-op application that signifies -// the container needs to be used for a Windows servicing operation. -type ServicingOption struct { - IsServicing bool -} - -// FlushOption is a CreateOption that signifies if the container should be -// started with flushes ignored until boot has completed. This is an optimisation -// for first boot of a container. -type FlushOption struct { - IgnoreFlushesDuringBoot bool -} - -// HyperVIsolationOption is a CreateOption that indicates whether the runtime -// should start the container as a Hyper-V container. -type HyperVIsolationOption struct { - IsHyperV bool -} - -// LayerOption is a CreateOption that indicates to the runtime the layer folder -// and layer paths for a container. -type LayerOption struct { - // LayerFolderPath is the path to the current layer folder. Empty for Hyper-V containers. - LayerFolderPath string `json:",omitempty"` - // Layer paths of the parent layers - LayerPaths []string -} - -// NetworkEndpointsOption is a CreateOption that provides the runtime list -// of network endpoints to which a container should be attached during its creation. -type NetworkEndpointsOption struct { - Endpoints []string - AllowUnqualifiedDNSQuery bool - DNSSearchList []string - NetworkSharedContainerID string -} - -// CredentialsOption is a CreateOption that indicates the credentials from -// a credential spec to be used to the runtime -type CredentialsOption struct { - Credentials string +// LCOWOption is a CreateOption required for LCOW configuration +type LCOWOption struct { + Config *opengcs.Config } // Checkpoint holds the details of a checkpoint (not supported in windows) diff --git a/vendor/github.com/docker/docker/libcontainerd/utils_linux.go b/vendor/github.com/docker/docker/libcontainerd/utils_linux.go index 170f90b8e..5372b886c 100644 --- a/vendor/github.com/docker/docker/libcontainerd/utils_linux.go +++ b/vendor/github.com/docker/docker/libcontainerd/utils_linux.go @@ -43,7 +43,7 @@ func systemPid(ctr *containerd.Container) uint32 { return pid } -func convertRlimits(sr []specs.LinuxRlimit) (cr []*containerd.Rlimit) { +func convertRlimits(sr []specs.POSIXRlimit) (cr []*containerd.Rlimit) { for _, r := range sr { cr = append(cr, &containerd.Rlimit{ Type: r.Type, diff --git a/vendor/github.com/docker/docker/libcontainerd/utils_windows.go b/vendor/github.com/docker/docker/libcontainerd/utils_windows.go index 41ac40d2c..bca9fa208 100644 --- a/vendor/github.com/docker/docker/libcontainerd/utils_windows.go +++ b/vendor/github.com/docker/docker/libcontainerd/utils_windows.go @@ -1,6 +1,10 @@ package libcontainerd -import "strings" +import ( + "strings" + + opengcs "github.com/Microsoft/opengcs/client" +) // setupEnvironmentVariables converts a string array of environment variables // into a map as required by the HCS. Source array is in format [v1=k1] [v2=k2] etc. @@ -15,32 +19,20 @@ func setupEnvironmentVariables(a []string) map[string]string { return r } -// Apply for a servicing option is a no-op. -func (s *ServicingOption) Apply(interface{}) error { - return nil -} - -// Apply for the flush option is a no-op. -func (f *FlushOption) Apply(interface{}) error { - return nil -} - -// Apply for the hypervisolation option is a no-op. -func (h *HyperVIsolationOption) Apply(interface{}) error { - return nil -} - -// Apply for the layer option is a no-op. -func (h *LayerOption) Apply(interface{}) error { - return nil -} - -// Apply for the network endpoints option is a no-op. -func (s *NetworkEndpointsOption) Apply(interface{}) error { +// Apply for the LCOW option is a no-op. +func (s *LCOWOption) Apply(interface{}) error { return nil } -// Apply for the credentials option is a no-op. -func (s *CredentialsOption) Apply(interface{}) error { - return nil +// debugGCS is a dirty hack for debugging for Linux Utility VMs. It simply +// runs a bunch of commands inside the UVM, but seriously aides in advanced debugging. +func (c *container) debugGCS() { + if c == nil || c.isWindows || c.hcsContainer == nil { + return + } + cfg := opengcs.Config{ + Uvm: c.hcsContainer, + UvmTimeoutSeconds: 600, + } + cfg.DebugGCS() } diff --git a/vendor/github.com/docker/docker/oci/defaults.go b/vendor/github.com/docker/docker/oci/defaults.go index 083726e12..d706fafcc 100644 --- a/vendor/github.com/docker/docker/oci/defaults.go +++ b/vendor/github.com/docker/docker/oci/defaults.go @@ -50,11 +50,9 @@ func DefaultOSSpec(osName string) specs.Spec { func DefaultWindowsSpec() specs.Spec { return specs.Spec{ Version: specs.Version, - Platform: specs.Platform{ - OS: runtime.GOOS, - Arch: runtime.GOARCH, - }, Windows: &specs.Windows{}, + Process: &specs.Process{}, + Root: &specs.Root{}, } } @@ -62,10 +60,6 @@ func DefaultWindowsSpec() specs.Spec { func DefaultSolarisSpec() specs.Spec { s := specs.Spec{ Version: "0.6.0", - Platform: specs.Platform{ - OS: "SunOS", - Arch: runtime.GOARCH, - }, } s.Solaris = &specs.Solaris{} return s @@ -75,10 +69,8 @@ func DefaultSolarisSpec() specs.Spec { func DefaultLinuxSpec() specs.Spec { s := specs.Spec{ Version: specs.Version, - Platform: specs.Platform{ - OS: "linux", - Arch: runtime.GOARCH, - }, + Process: &specs.Process{}, + Root: &specs.Root{}, } s.Mounts = []specs.Mount{ { @@ -117,12 +109,20 @@ func DefaultLinuxSpec() specs.Spec { Source: "mqueue", Options: []string{"nosuid", "noexec", "nodev"}, }, + { + Destination: "/dev/shm", + Type: "tmpfs", + Source: "shm", + Options: []string{"nosuid", "noexec", "nodev", "mode=1777"}, + }, } - s.Process.Capabilities = &specs.LinuxCapabilities{ - Bounding: defaultCapabilities(), - Permitted: defaultCapabilities(), - Inheritable: defaultCapabilities(), - Effective: defaultCapabilities(), + s.Process = &specs.Process{ + Capabilities: &specs.LinuxCapabilities{ + Bounding: defaultCapabilities(), + Permitted: defaultCapabilities(), + Inheritable: defaultCapabilities(), + Effective: defaultCapabilities(), + }, } s.Linux = &specs.Linux{ @@ -150,7 +150,7 @@ func DefaultLinuxSpec() specs.Spec { }, // Devices implicitly contains the following devices: // null, zero, full, random, urandom, tty, console, and ptmx. - // ptmx is a bind-mount or symlink of the container's ptmx. + // ptmx is a bind mount or symlink of the container's ptmx. // See also: https://github.com/opencontainers/runtime-spec/blob/master/config-linux.md#default-devices Devices: []specs.LinuxDevice{}, Resources: &specs.LinuxResources{ @@ -212,6 +212,11 @@ func DefaultLinuxSpec() specs.Spec { }, } + // For LCOW support, populate a blank Windows spec + if runtime.GOOS == "windows" { + s.Windows = &specs.Windows{} + } + // For LCOW support, don't mask /sys/firmware if runtime.GOOS != "windows" { s.Linux.MaskedPaths = append(s.Linux.MaskedPaths, "/sys/firmware") diff --git a/vendor/github.com/docker/docker/opts/env.go b/vendor/github.com/docker/docker/opts/env.go index e6ddd7330..4fbd470bc 100644 --- a/vendor/github.com/docker/docker/opts/env.go +++ b/vendor/github.com/docker/docker/opts/env.go @@ -5,6 +5,8 @@ import ( "os" "runtime" "strings" + + "github.com/pkg/errors" ) // ValidateEnv validates an environment variable and returns it. @@ -18,7 +20,7 @@ import ( func ValidateEnv(val string) (string, error) { arr := strings.Split(val, "=") if arr[0] == "" { - return "", fmt.Errorf("invalid environment variable: %s", val) + return "", errors.Errorf("invalid environment variable: %s", val) } if len(arr) > 1 { return val, nil diff --git a/vendor/github.com/docker/docker/opts/env_test.go b/vendor/github.com/docker/docker/opts/env_test.go index 6f6c7a7a2..454e98943 100644 --- a/vendor/github.com/docker/docker/opts/env_test.go +++ b/vendor/github.com/docker/docker/opts/env_test.go @@ -8,35 +8,117 @@ import ( ) func TestValidateEnv(t *testing.T) { - valids := map[string]string{ - "a": "a", - "something": "something", - "_=a": "_=a", - "env1=value1": "env1=value1", - "_env1=value1": "_env1=value1", - "env2=value2=value3": "env2=value2=value3", - "env3=abc!qwe": "env3=abc!qwe", - "env_4=value 4": "env_4=value 4", - "PATH": fmt.Sprintf("PATH=%v", os.Getenv("PATH")), - "PATH=something": "PATH=something", - "asd!qwe": "asd!qwe", - "1asd": "1asd", - "123": "123", - "some space": "some space", - " some space before": " some space before", - "some space after ": "some space after ", + testcase := []struct { + value string + expected string + err error + }{ + { + value: "a", + expected: "a", + }, + { + value: "something", + expected: "something", + }, + { + value: "_=a", + expected: "_=a", + }, + { + value: "env1=value1", + expected: "env1=value1", + }, + { + value: "_env1=value1", + expected: "_env1=value1", + }, + { + value: "env2=value2=value3", + expected: "env2=value2=value3", + }, + { + value: "env3=abc!qwe", + expected: "env3=abc!qwe", + }, + { + value: "env_4=value 4", + expected: "env_4=value 4", + }, + { + value: "PATH", + expected: fmt.Sprintf("PATH=%v", os.Getenv("PATH")), + }, + { + value: "=a", + err: fmt.Errorf(fmt.Sprintf("invalid environment variable: %s", "=a")), + }, + { + value: "PATH=something", + expected: "PATH=something", + }, + { + value: "asd!qwe", + expected: "asd!qwe", + }, + { + value: "1asd", + expected: "1asd", + }, + { + value: "123", + expected: "123", + }, + { + value: "some space", + expected: "some space", + }, + { + value: " some space before", + expected: " some space before", + }, + { + value: "some space after ", + expected: "some space after ", + }, + { + value: "=", + err: fmt.Errorf(fmt.Sprintf("invalid environment variable: %s", "=")), + }, } + // Environment variables are case in-sensitive on Windows if runtime.GOOS == "windows" { - valids["PaTh"] = fmt.Sprintf("PaTh=%v", os.Getenv("PATH")) + tmp := struct { + value string + expected string + err error + }{ + value: "PaTh", + expected: fmt.Sprintf("PaTh=%v", os.Getenv("PATH")), + } + testcase = append(testcase, tmp) + } - for value, expected := range valids { - actual, err := ValidateEnv(value) + + for _, r := range testcase { + actual, err := ValidateEnv(r.value) + if err != nil { - t.Fatal(err) + if r.err == nil { + t.Fatalf("Expected err is nil, got err[%v]", err) + } + if err.Error() != r.err.Error() { + t.Fatalf("Expected err[%v], got err[%v]", r.err, err) + } + } + + if err == nil && r.err != nil { + t.Fatalf("Expected err[%v], but err is nil", r.err) } - if actual != expected { - t.Fatalf("Expected [%v], got [%v]", expected, actual) + + if actual != r.expected { + t.Fatalf("Expected [%v], got [%v]", r.expected, actual) } } } diff --git a/vendor/github.com/docker/docker/opts/opts.go b/vendor/github.com/docker/docker/opts/opts.go index 300fb426a..a86d74d60 100644 --- a/vendor/github.com/docker/docker/opts/opts.go +++ b/vendor/github.com/docker/docker/opts/opts.go @@ -7,10 +7,7 @@ import ( "regexp" "strings" - "github.com/docker/docker/api/types/swarm" - "github.com/docker/docker/daemon/cluster/convert" units "github.com/docker/go-units" - "github.com/docker/swarmkit/api/genericresource" ) var ( @@ -180,7 +177,7 @@ func (opts *MapOpts) GetAll() map[string]string { } func (opts *MapOpts) String() string { - return fmt.Sprintf("%v", map[string]string((opts.values))) + return fmt.Sprintf("%v", opts.values) } // Type returns a string name for this Option type @@ -328,19 +325,3 @@ func (m *MemBytes) UnmarshalJSON(s []byte) error { *m = MemBytes(val) return err } - -// ParseGenericResources parses and validates the specified string as a list of GenericResource -func ParseGenericResources(value string) ([]swarm.GenericResource, error) { - if value == "" { - return nil, nil - } - - resources, err := genericresource.Parse(value) - if err != nil { - return nil, err - } - - obj := convert.GenericResourcesFromGRPC(resources) - - return obj, nil -} diff --git a/vendor/github.com/docker/docker/opts/quotedstring.go b/vendor/github.com/docker/docker/opts/quotedstring.go index fb1e5374b..09c68a526 100644 --- a/vendor/github.com/docker/docker/opts/quotedstring.go +++ b/vendor/github.com/docker/docker/opts/quotedstring.go @@ -18,7 +18,7 @@ func (s *QuotedString) Type() string { } func (s *QuotedString) String() string { - return string(*s.value) + return *s.value } func trimQuotes(value string) string { diff --git a/vendor/github.com/docker/docker/pkg/archive/archive.go b/vendor/github.com/docker/docker/pkg/archive/archive.go index b3c84ee15..876e60568 100644 --- a/vendor/github.com/docker/docker/pkg/archive/archive.go +++ b/vendor/github.com/docker/docker/pkg/archive/archive.go @@ -55,18 +55,17 @@ type ( } ) -// Archiver allows the reuse of most utility functions of this package -// with a pluggable Untar function. Also, to facilitate the passing of -// specific id mappings for untar, an archiver can be created with maps -// which will then be passed to Untar operations +// Archiver implements the Archiver interface and allows the reuse of most utility functions of +// this package with a pluggable Untar function. Also, to facilitate the passing of specific id +// mappings for untar, an Archiver can be created with maps which will then be passed to Untar operations. type Archiver struct { - Untar func(io.Reader, string, *TarOptions) error - IDMappings *idtools.IDMappings + Untar func(io.Reader, string, *TarOptions) error + IDMappingsVar *idtools.IDMappings } // NewDefaultArchiver returns a new Archiver without any IDMappings func NewDefaultArchiver() *Archiver { - return &Archiver{Untar: Untar, IDMappings: &idtools.IDMappings{}} + return &Archiver{Untar: Untar, IDMappingsVar: &idtools.IDMappings{}} } // breakoutError is used to differentiate errors related to breaking out @@ -382,6 +381,7 @@ type tarAppender struct { // for hardlink mapping SeenFiles map[uint64]string IDMappings *idtools.IDMappings + ChownOpts *idtools.IDPair // For packing and unpacking whiteout files in the // non standard format. The whiteout files defined @@ -390,12 +390,13 @@ type tarAppender struct { WhiteoutConverter tarWhiteoutConverter } -func newTarAppender(idMapping *idtools.IDMappings, writer io.Writer) *tarAppender { +func newTarAppender(idMapping *idtools.IDMappings, writer io.Writer, chownOpts *idtools.IDPair) *tarAppender { return &tarAppender{ SeenFiles: make(map[uint64]string), TarWriter: tar.NewWriter(writer), Buffer: pools.BufioWriter32KPool.Get(nil), IDMappings: idMapping, + ChownOpts: chownOpts, } } @@ -470,6 +471,12 @@ func (ta *tarAppender) addTarFile(path, name string) error { } } + // explicitly override with ChownOpts + if ta.ChownOpts != nil { + hdr.Uid = ta.ChownOpts.UID + hdr.Gid = ta.ChownOpts.GID + } + if ta.WhiteoutConverter != nil { wo, err := ta.WhiteoutConverter.ConvertWrite(hdr, path, fi) if err != nil { @@ -595,7 +602,7 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L return nil default: - return fmt.Errorf("Unhandled tar header type %d\n", hdr.Typeflag) + return fmt.Errorf("unhandled tar header type %d", hdr.Typeflag) } // Lchown is not supported on Windows. @@ -692,6 +699,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error) ta := newTarAppender( idtools.NewIDMappingsFromMaps(options.UIDMaps, options.GIDMaps), compressWriter, + options.ChownOpts, ) ta.WhiteoutConverter = getWhiteoutConverter(options.WhiteoutFormat) @@ -1016,8 +1024,8 @@ func (archiver *Archiver) TarUntar(src, dst string) error { } defer archive.Close() options := &TarOptions{ - UIDMaps: archiver.IDMappings.UIDs(), - GIDMaps: archiver.IDMappings.GIDs(), + UIDMaps: archiver.IDMappingsVar.UIDs(), + GIDMaps: archiver.IDMappingsVar.GIDs(), } return archiver.Untar(archive, dst, options) } @@ -1030,8 +1038,8 @@ func (archiver *Archiver) UntarPath(src, dst string) error { } defer archive.Close() options := &TarOptions{ - UIDMaps: archiver.IDMappings.UIDs(), - GIDMaps: archiver.IDMappings.GIDs(), + UIDMaps: archiver.IDMappingsVar.UIDs(), + GIDMaps: archiver.IDMappingsVar.GIDs(), } return archiver.Untar(archive, dst, options) } @@ -1049,10 +1057,10 @@ func (archiver *Archiver) CopyWithTar(src, dst string) error { return archiver.CopyFileWithTar(src, dst) } - // if this archiver is set up with ID mapping we need to create + // if this Archiver is set up with ID mapping we need to create // the new destination directory with the remapped root UID/GID pair // as owner - rootIDs := archiver.IDMappings.RootPair() + rootIDs := archiver.IDMappingsVar.RootPair() // Create dst, copy src's content into it logrus.Debugf("Creating dest directory: %s", dst) if err := idtools.MkdirAllAndChownNew(dst, 0755, rootIDs); err != nil { @@ -1103,7 +1111,7 @@ func (archiver *Archiver) CopyFileWithTar(src, dst string) (err error) { hdr.Name = filepath.Base(dst) hdr.Mode = int64(chmodTarEntry(os.FileMode(hdr.Mode))) - if err := remapIDs(archiver.IDMappings, hdr); err != nil { + if err := remapIDs(archiver.IDMappingsVar, hdr); err != nil { return err } @@ -1130,6 +1138,11 @@ func (archiver *Archiver) CopyFileWithTar(src, dst string) (err error) { return err } +// IDMappings returns the IDMappings of the archiver. +func (archiver *Archiver) IDMappings() *idtools.IDMappings { + return archiver.IDMappingsVar +} + func remapIDs(idMappings *idtools.IDMappings, hdr *tar.Header) error { ids, err := idMappings.ToHost(idtools.IDPair{UID: hdr.Uid, GID: hdr.Gid}) hdr.Uid, hdr.Gid = ids.UID, ids.GID diff --git a/vendor/github.com/docker/docker/pkg/archive/archive_linux_test.go b/vendor/github.com/docker/docker/pkg/archive/archive_linux_test.go index f219b3e67..da683c8c9 100644 --- a/vendor/github.com/docker/docker/pkg/archive/archive_linux_test.go +++ b/vendor/github.com/docker/docker/pkg/archive/archive_linux_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/docker/docker/pkg/system" + "github.com/stretchr/testify/require" "golang.org/x/sys/unix" ) @@ -22,46 +23,37 @@ import ( // └── f1 # whiteout, 0644 func setupOverlayTestDir(t *testing.T, src string) { // Create opaque directory containing single file and permission 0700 - if err := os.Mkdir(filepath.Join(src, "d1"), 0700); err != nil { - t.Fatal(err) - } + err := os.Mkdir(filepath.Join(src, "d1"), 0700) + require.NoError(t, err) - if err := system.Lsetxattr(filepath.Join(src, "d1"), "trusted.overlay.opaque", []byte("y"), 0); err != nil { - t.Fatal(err) - } + err = system.Lsetxattr(filepath.Join(src, "d1"), "trusted.overlay.opaque", []byte("y"), 0) + require.NoError(t, err) - if err := ioutil.WriteFile(filepath.Join(src, "d1", "f1"), []byte{}, 0600); err != nil { - t.Fatal(err) - } + err = ioutil.WriteFile(filepath.Join(src, "d1", "f1"), []byte{}, 0600) + require.NoError(t, err) // Create another opaque directory containing single file but with permission 0750 - if err := os.Mkdir(filepath.Join(src, "d2"), 0750); err != nil { - t.Fatal(err) - } + err = os.Mkdir(filepath.Join(src, "d2"), 0750) + require.NoError(t, err) - if err := system.Lsetxattr(filepath.Join(src, "d2"), "trusted.overlay.opaque", []byte("y"), 0); err != nil { - t.Fatal(err) - } + err = system.Lsetxattr(filepath.Join(src, "d2"), "trusted.overlay.opaque", []byte("y"), 0) + require.NoError(t, err) - if err := ioutil.WriteFile(filepath.Join(src, "d2", "f1"), []byte{}, 0660); err != nil { - t.Fatal(err) - } + err = ioutil.WriteFile(filepath.Join(src, "d2", "f1"), []byte{}, 0660) + require.NoError(t, err) // Create regular directory with deleted file - if err := os.Mkdir(filepath.Join(src, "d3"), 0700); err != nil { - t.Fatal(err) - } + err = os.Mkdir(filepath.Join(src, "d3"), 0700) + require.NoError(t, err) - if err := system.Mknod(filepath.Join(src, "d3", "f1"), unix.S_IFCHR, 0); err != nil { - t.Fatal(err) - } + err = system.Mknod(filepath.Join(src, "d3", "f1"), unix.S_IFCHR, 0) + require.NoError(t, err) } func checkOpaqueness(t *testing.T, path string, opaque string) { xattrOpaque, err := system.Lgetxattr(path, "trusted.overlay.opaque") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) + if string(xattrOpaque) != opaque { t.Fatalf("Unexpected opaque value: %q, expected %q", string(xattrOpaque), opaque) } @@ -70,9 +62,8 @@ func checkOpaqueness(t *testing.T, path string, opaque string) { func checkOverlayWhiteout(t *testing.T, path string) { stat, err := os.Stat(path) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) + statT, ok := stat.Sys().(*syscall.Stat_t) if !ok { t.Fatalf("Unexpected type: %t, expected *syscall.Stat_t", stat.Sys()) @@ -84,9 +75,8 @@ func checkOverlayWhiteout(t *testing.T, path string) { func checkFileMode(t *testing.T, path string, perm os.FileMode) { stat, err := os.Stat(path) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) + if stat.Mode() != perm { t.Fatalf("Unexpected file mode for %s: %o, expected %o", path, stat.Mode(), perm) } @@ -94,23 +84,17 @@ func checkFileMode(t *testing.T, path string, perm os.FileMode) { func TestOverlayTarUntar(t *testing.T) { oldmask, err := system.Umask(0) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer system.Umask(oldmask) src, err := ioutil.TempDir("", "docker-test-overlay-tar-src") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(src) setupOverlayTestDir(t, src) dst, err := ioutil.TempDir("", "docker-test-overlay-tar-dst") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(dst) options := &TarOptions{ @@ -118,14 +102,11 @@ func TestOverlayTarUntar(t *testing.T) { WhiteoutFormat: OverlayWhiteoutFormat, } archive, err := TarWithOptions(src, options) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer archive.Close() - if err := Untar(archive, dst, options); err != nil { - t.Fatal(err) - } + err = Untar(archive, dst, options) + require.NoError(t, err) checkFileMode(t, filepath.Join(dst, "d1"), 0700|os.ModeDir) checkFileMode(t, filepath.Join(dst, "d2"), 0750|os.ModeDir) @@ -142,40 +123,31 @@ func TestOverlayTarUntar(t *testing.T) { func TestOverlayTarAUFSUntar(t *testing.T) { oldmask, err := system.Umask(0) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer system.Umask(oldmask) src, err := ioutil.TempDir("", "docker-test-overlay-tar-src") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(src) setupOverlayTestDir(t, src) dst, err := ioutil.TempDir("", "docker-test-overlay-tar-dst") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(dst) archive, err := TarWithOptions(src, &TarOptions{ Compression: Uncompressed, WhiteoutFormat: OverlayWhiteoutFormat, }) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer archive.Close() - if err := Untar(archive, dst, &TarOptions{ + err = Untar(archive, dst, &TarOptions{ Compression: Uncompressed, WhiteoutFormat: AUFSWhiteoutFormat, - }); err != nil { - t.Fatal(err) - } + }) + require.NoError(t, err) checkFileMode(t, filepath.Join(dst, "d1"), 0700|os.ModeDir) checkFileMode(t, filepath.Join(dst, "d1", WhiteoutOpaqueDir), 0700) diff --git a/vendor/github.com/docker/docker/pkg/archive/archive_test.go b/vendor/github.com/docker/docker/pkg/archive/archive_test.go index 1371b8ab1..20a07fb40 100644 --- a/vendor/github.com/docker/docker/pkg/archive/archive_test.go +++ b/vendor/github.com/docker/docker/pkg/archive/archive_test.go @@ -14,6 +14,7 @@ import ( "testing" "time" + "github.com/docker/docker/pkg/idtools" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -263,9 +264,7 @@ func TestCmdStreamGood(t *testing.T) { func TestUntarPathWithInvalidDest(t *testing.T) { tempFolder, err := ioutil.TempDir("", "docker-archive-test") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(tempFolder) invalidDestFolder := filepath.Join(tempFolder, "invalidDest") // Create a src file @@ -284,9 +283,7 @@ func TestUntarPathWithInvalidDest(t *testing.T) { cmd := exec.Command("sh", "-c", "tar cf "+tarFileU+" "+srcFileU) _, err = cmd.CombinedOutput() - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) err = defaultUntarPath(tarFile, invalidDestFolder) if err == nil { @@ -308,9 +305,7 @@ func TestUntarPathWithInvalidSrc(t *testing.T) { func TestUntarPath(t *testing.T) { tmpFolder, err := ioutil.TempDir("", "docker-archive-test") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(tmpFolder) srcFile := filepath.Join(tmpFolder, "src") tarFile := filepath.Join(tmpFolder, "src.tar") @@ -331,9 +326,7 @@ func TestUntarPath(t *testing.T) { } cmd := exec.Command("sh", "-c", "tar cf "+tarFileU+" "+srcFileU) _, err = cmd.CombinedOutput() - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) err = defaultUntarPath(tarFile, destFolder) if err != nil { @@ -732,6 +725,57 @@ func TestTarUntar(t *testing.T) { } } +func TestTarWithOptionsChownOptsAlwaysOverridesIdPair(t *testing.T) { + origin, err := ioutil.TempDir("", "docker-test-tar-chown-opt") + require.NoError(t, err) + + defer os.RemoveAll(origin) + filePath := filepath.Join(origin, "1") + err = ioutil.WriteFile(filePath, []byte("hello world"), 0700) + require.NoError(t, err) + + idMaps := []idtools.IDMap{ + 0: { + ContainerID: 0, + HostID: 0, + Size: 65536, + }, + 1: { + ContainerID: 0, + HostID: 100000, + Size: 65536, + }, + } + + cases := []struct { + opts *TarOptions + expectedUID int + expectedGID int + }{ + {&TarOptions{ChownOpts: &idtools.IDPair{UID: 1337, GID: 42}}, 1337, 42}, + {&TarOptions{ChownOpts: &idtools.IDPair{UID: 100001, GID: 100001}, UIDMaps: idMaps, GIDMaps: idMaps}, 100001, 100001}, + {&TarOptions{ChownOpts: &idtools.IDPair{UID: 0, GID: 0}, NoLchown: false}, 0, 0}, + {&TarOptions{ChownOpts: &idtools.IDPair{UID: 1, GID: 1}, NoLchown: true}, 1, 1}, + {&TarOptions{ChownOpts: &idtools.IDPair{UID: 1000, GID: 1000}, NoLchown: true}, 1000, 1000}, + } + for _, testCase := range cases { + reader, err := TarWithOptions(filePath, testCase.opts) + require.NoError(t, err) + tr := tar.NewReader(reader) + defer reader.Close() + for { + hdr, err := tr.Next() + if err == io.EOF { + // end of tar archive + break + } + require.NoError(t, err) + assert.Equal(t, hdr.Uid, testCase.expectedUID, "Uid equals expected value") + assert.Equal(t, hdr.Gid, testCase.expectedGID, "Gid equals expected value") + } + } +} + func TestTarWithOptions(t *testing.T) { // TODO Windows: Figure out how to fix this test. if runtime.GOOS == "windows" { @@ -1139,8 +1183,10 @@ func TestUntarInvalidSymlink(t *testing.T) { func TestTempArchiveCloseMultipleTimes(t *testing.T) { reader := ioutil.NopCloser(strings.NewReader("hello")) tempArchive, err := NewTempArchive(reader, "") + require.NoError(t, err) buf := make([]byte, 10) n, err := tempArchive.Read(buf) + require.NoError(t, err) if n != 5 { t.Fatalf("Expected to read 5 bytes. Read %d instead", n) } diff --git a/vendor/github.com/docker/docker/pkg/archive/archive_unix.go b/vendor/github.com/docker/docker/pkg/archive/archive_unix.go index 121317432..ac4a348d5 100644 --- a/vendor/github.com/docker/docker/pkg/archive/archive_unix.go +++ b/vendor/github.com/docker/docker/pkg/archive/archive_unix.go @@ -50,8 +50,8 @@ func setHeaderForSpecialDevice(hdr *tar.Header, name string, stat interface{}) ( // Currently go does not fill in the major/minors if s.Mode&unix.S_IFBLK != 0 || s.Mode&unix.S_IFCHR != 0 { - hdr.Devmajor = int64(major(uint64(s.Rdev))) - hdr.Devminor = int64(minor(uint64(s.Rdev))) + hdr.Devmajor = int64(major(uint64(s.Rdev))) // nolint: unconvert + hdr.Devminor = int64(minor(uint64(s.Rdev))) // nolint: unconvert } } @@ -62,7 +62,7 @@ func getInodeFromStat(stat interface{}) (inode uint64, err error) { s, ok := stat.(*syscall.Stat_t) if ok { - inode = uint64(s.Ino) + inode = s.Ino } return diff --git a/vendor/github.com/docker/docker/pkg/archive/archive_unix_test.go b/vendor/github.com/docker/docker/pkg/archive/archive_unix_test.go index 90f8adaa5..a6d957bfa 100644 --- a/vendor/github.com/docker/docker/pkg/archive/archive_unix_test.go +++ b/vendor/github.com/docker/docker/pkg/archive/archive_unix_test.go @@ -9,10 +9,13 @@ import ( "os" "path/filepath" "runtime" + "strings" "syscall" "testing" "github.com/docker/docker/pkg/system" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "golang.org/x/sys/unix" ) @@ -70,60 +73,89 @@ func TestChmodTarEntry(t *testing.T) { func TestTarWithHardLink(t *testing.T) { origin, err := ioutil.TempDir("", "docker-test-tar-hardlink") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(origin) - if err := ioutil.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700); err != nil { - t.Fatal(err) - } - if err := os.Link(filepath.Join(origin, "1"), filepath.Join(origin, "2")); err != nil { - t.Fatal(err) - } + + err = ioutil.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700) + require.NoError(t, err) + + err = os.Link(filepath.Join(origin, "1"), filepath.Join(origin, "2")) + require.NoError(t, err) var i1, i2 uint64 - if i1, err = getNlink(filepath.Join(origin, "1")); err != nil { - t.Fatal(err) - } + i1, err = getNlink(filepath.Join(origin, "1")) + require.NoError(t, err) + // sanity check that we can hardlink if i1 != 2 { t.Skipf("skipping since hardlinks don't work here; expected 2 links, got %d", i1) } dest, err := ioutil.TempDir("", "docker-test-tar-hardlink-dest") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(dest) // we'll do this in two steps to separate failure fh, err := Tar(origin, Uncompressed) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) // ensure we can read the whole thing with no error, before writing back out buf, err := ioutil.ReadAll(fh) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) bRdr := bytes.NewReader(buf) err = Untar(bRdr, dest, &TarOptions{Compression: Uncompressed}) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) - if i1, err = getInode(filepath.Join(dest, "1")); err != nil { - t.Fatal(err) - } - if i2, err = getInode(filepath.Join(dest, "2")); err != nil { - t.Fatal(err) - } + i1, err = getInode(filepath.Join(dest, "1")) + require.NoError(t, err) - if i1 != i2 { - t.Errorf("expected matching inodes, but got %d and %d", i1, i2) + i2, err = getInode(filepath.Join(dest, "2")) + require.NoError(t, err) + + assert.Equal(t, i1, i2) +} + +func TestTarWithHardLinkAndRebase(t *testing.T) { + tmpDir, err := ioutil.TempDir("", "docker-test-tar-hardlink-rebase") + require.NoError(t, err) + defer os.RemoveAll(tmpDir) + + origin := filepath.Join(tmpDir, "origin") + err = os.Mkdir(origin, 0700) + require.NoError(t, err) + + err = ioutil.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700) + require.NoError(t, err) + + err = os.Link(filepath.Join(origin, "1"), filepath.Join(origin, "2")) + require.NoError(t, err) + + var i1, i2 uint64 + i1, err = getNlink(filepath.Join(origin, "1")) + require.NoError(t, err) + + // sanity check that we can hardlink + if i1 != 2 { + t.Skipf("skipping since hardlinks don't work here; expected 2 links, got %d", i1) } + + dest := filepath.Join(tmpDir, "dest") + bRdr, err := TarResourceRebase(origin, "origin") + require.NoError(t, err) + + dstDir, srcBase := SplitPathDirEntry(origin) + _, dstBase := SplitPathDirEntry(dest) + content := RebaseArchiveEntries(bRdr, srcBase, dstBase) + err = Untar(content, dstDir, &TarOptions{Compression: Uncompressed, NoLchown: true, NoOverwriteDirNonDir: true}) + require.NoError(t, err) + + i1, err = getInode(filepath.Join(dest, "1")) + require.NoError(t, err) + i2, err = getInode(filepath.Join(dest, "2")) + require.NoError(t, err) + + assert.Equal(t, i1, i2) } func getNlink(path string) (uint64, error) { @@ -153,51 +185,38 @@ func getInode(path string) (uint64, error) { func TestTarWithBlockCharFifo(t *testing.T) { origin, err := ioutil.TempDir("", "docker-test-tar-hardlink") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) + defer os.RemoveAll(origin) - if err := ioutil.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700); err != nil { - t.Fatal(err) - } - if err := system.Mknod(filepath.Join(origin, "2"), unix.S_IFBLK, int(system.Mkdev(int64(12), int64(5)))); err != nil { - t.Fatal(err) - } - if err := system.Mknod(filepath.Join(origin, "3"), unix.S_IFCHR, int(system.Mkdev(int64(12), int64(5)))); err != nil { - t.Fatal(err) - } - if err := system.Mknod(filepath.Join(origin, "4"), unix.S_IFIFO, int(system.Mkdev(int64(12), int64(5)))); err != nil { - t.Fatal(err) - } + err = ioutil.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700) + require.NoError(t, err) + + err = system.Mknod(filepath.Join(origin, "2"), unix.S_IFBLK, int(system.Mkdev(int64(12), int64(5)))) + require.NoError(t, err) + err = system.Mknod(filepath.Join(origin, "3"), unix.S_IFCHR, int(system.Mkdev(int64(12), int64(5)))) + require.NoError(t, err) + err = system.Mknod(filepath.Join(origin, "4"), unix.S_IFIFO, int(system.Mkdev(int64(12), int64(5)))) + require.NoError(t, err) dest, err := ioutil.TempDir("", "docker-test-tar-hardlink-dest") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(dest) // we'll do this in two steps to separate failure fh, err := Tar(origin, Uncompressed) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) // ensure we can read the whole thing with no error, before writing back out buf, err := ioutil.ReadAll(fh) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) bRdr := bytes.NewReader(buf) err = Untar(bRdr, dest, &TarOptions{Compression: Uncompressed}) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) changes, err := ChangesDirs(origin, dest) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) + if len(changes) > 0 { t.Fatalf("Tar with special device (block, char, fifo) should keep them (recreate them when untar) : %v", changes) } @@ -209,22 +228,17 @@ func TestTarUntarWithXattr(t *testing.T) { t.Skip() } origin, err := ioutil.TempDir("", "docker-test-untar-origin") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(origin) - if err := ioutil.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700); err != nil { - t.Fatal(err) - } - if err := ioutil.WriteFile(filepath.Join(origin, "2"), []byte("welcome!"), 0700); err != nil { - t.Fatal(err) - } - if err := ioutil.WriteFile(filepath.Join(origin, "3"), []byte("will be ignored"), 0700); err != nil { - t.Fatal(err) - } - if err := system.Lsetxattr(filepath.Join(origin, "2"), "security.capability", []byte{0x00}, 0); err != nil { - t.Fatal(err) - } + err = ioutil.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700) + require.NoError(t, err) + + err = ioutil.WriteFile(filepath.Join(origin, "2"), []byte("welcome!"), 0700) + require.NoError(t, err) + err = ioutil.WriteFile(filepath.Join(origin, "3"), []byte("will be ignored"), 0700) + require.NoError(t, err) + err = system.Lsetxattr(filepath.Join(origin, "2"), "security.capability", []byte{0x00}, 0) + require.NoError(t, err) for _, c := range []Compression{ Uncompressed, @@ -248,3 +262,58 @@ func TestTarUntarWithXattr(t *testing.T) { } } } + +func TestCopyInfoDestinationPathSymlink(t *testing.T) { + tmpDir, _ := getTestTempDirs(t) + defer removeAllPaths(tmpDir) + + root := strings.TrimRight(tmpDir, "/") + "/" + + type FileTestData struct { + resource FileData + file string + expected CopyInfo + } + + testData := []FileTestData{ + //Create a directory: /tmp/archive-copy-test*/dir1 + //Test will "copy" file1 to dir1 + {resource: FileData{filetype: Dir, path: "dir1", permissions: 0740}, file: "file1", expected: CopyInfo{Path: root + "dir1/file1", Exists: false, IsDir: false}}, + + //Create a symlink directory to dir1: /tmp/archive-copy-test*/dirSymlink -> dir1 + //Test will "copy" file2 to dirSymlink + {resource: FileData{filetype: Symlink, path: "dirSymlink", contents: root + "dir1", permissions: 0600}, file: "file2", expected: CopyInfo{Path: root + "dirSymlink/file2", Exists: false, IsDir: false}}, + + //Create a file in tmp directory: /tmp/archive-copy-test*/file1 + //Test to cover when the full file path already exists. + {resource: FileData{filetype: Regular, path: "file1", permissions: 0600}, file: "", expected: CopyInfo{Path: root + "file1", Exists: true}}, + + //Create a directory: /tmp/archive-copy*/dir2 + //Test to cover when the full directory path already exists + {resource: FileData{filetype: Dir, path: "dir2", permissions: 0740}, file: "", expected: CopyInfo{Path: root + "dir2", Exists: true, IsDir: true}}, + + //Create a symlink to a non-existent target: /tmp/archive-copy*/symlink1 -> noSuchTarget + //Negative test to cover symlinking to a target that does not exit + {resource: FileData{filetype: Symlink, path: "symlink1", contents: "noSuchTarget", permissions: 0600}, file: "", expected: CopyInfo{Path: root + "noSuchTarget", Exists: false}}, + + //Create a file in tmp directory for next test: /tmp/existingfile + {resource: FileData{filetype: Regular, path: "existingfile", permissions: 0600}, file: "", expected: CopyInfo{Path: root + "existingfile", Exists: true}}, + + //Create a symlink to an existing file: /tmp/archive-copy*/symlink2 -> /tmp/existingfile + //Test to cover when the parent directory of a new file is a symlink + {resource: FileData{filetype: Symlink, path: "symlink2", contents: "existingfile", permissions: 0600}, file: "", expected: CopyInfo{Path: root + "existingfile", Exists: true}}, + } + + var dirs []FileData + for _, data := range testData { + dirs = append(dirs, data.resource) + } + provisionSampleDir(t, tmpDir, dirs) + + for _, info := range testData { + p := filepath.Join(tmpDir, info.resource.path, info.file) + ci, err := CopyInfoDestinationPath(p) + assert.NoError(t, err) + assert.Equal(t, info.expected, ci) + } +} diff --git a/vendor/github.com/docker/docker/pkg/archive/changes.go b/vendor/github.com/docker/docker/pkg/archive/changes.go index 341c66dea..d78fe6ac6 100644 --- a/vendor/github.com/docker/docker/pkg/archive/changes.go +++ b/vendor/github.com/docker/docker/pkg/archive/changes.go @@ -394,7 +394,7 @@ func ChangesSize(newDir string, changes []Change) int64 { func ExportChanges(dir string, changes []Change, uidMaps, gidMaps []idtools.IDMap) (io.ReadCloser, error) { reader, writer := io.Pipe() go func() { - ta := newTarAppender(idtools.NewIDMappingsFromMaps(uidMaps, gidMaps), writer) + ta := newTarAppender(idtools.NewIDMappingsFromMaps(uidMaps, gidMaps), writer, nil) // this buffer is needed for the duration of this piped stream defer pools.BufioWriter32KPool.Put(ta.Buffer) diff --git a/vendor/github.com/docker/docker/pkg/archive/changes_linux.go b/vendor/github.com/docker/docker/pkg/archive/changes_linux.go index b987e5224..8e96d961f 100644 --- a/vendor/github.com/docker/docker/pkg/archive/changes_linux.go +++ b/vendor/github.com/docker/docker/pkg/archive/changes_linux.go @@ -294,7 +294,7 @@ func OverlayChanges(layers []string, rw string) ([]Change, error) { func overlayDeletedFile(root, path string, fi os.FileInfo) (string, error) { if fi.Mode()&os.ModeCharDevice != 0 { s := fi.Sys().(*syscall.Stat_t) - if major(uint64(s.Rdev)) == 0 && minor(uint64(s.Rdev)) == 0 { + if major(s.Rdev) == 0 && minor(s.Rdev) == 0 { return path, nil } } diff --git a/vendor/github.com/docker/docker/pkg/archive/changes_test.go b/vendor/github.com/docker/docker/pkg/archive/changes_test.go index c5d1629e7..53490aa47 100644 --- a/vendor/github.com/docker/docker/pkg/archive/changes_test.go +++ b/vendor/github.com/docker/docker/pkg/archive/changes_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/docker/docker/pkg/system" + "github.com/stretchr/testify/require" ) func max(x, y int) int { @@ -49,54 +50,53 @@ type FileData struct { func createSampleDir(t *testing.T, root string) { files := []FileData{ - {Regular, "file1", "file1\n", 0600}, - {Regular, "file2", "file2\n", 0666}, - {Regular, "file3", "file3\n", 0404}, - {Regular, "file4", "file4\n", 0600}, - {Regular, "file5", "file5\n", 0600}, - {Regular, "file6", "file6\n", 0600}, - {Regular, "file7", "file7\n", 0600}, - {Dir, "dir1", "", 0740}, - {Regular, "dir1/file1-1", "file1-1\n", 01444}, - {Regular, "dir1/file1-2", "file1-2\n", 0666}, - {Dir, "dir2", "", 0700}, - {Regular, "dir2/file2-1", "file2-1\n", 0666}, - {Regular, "dir2/file2-2", "file2-2\n", 0666}, - {Dir, "dir3", "", 0700}, - {Regular, "dir3/file3-1", "file3-1\n", 0666}, - {Regular, "dir3/file3-2", "file3-2\n", 0666}, - {Dir, "dir4", "", 0700}, - {Regular, "dir4/file3-1", "file4-1\n", 0666}, - {Regular, "dir4/file3-2", "file4-2\n", 0666}, - {Symlink, "symlink1", "target1", 0666}, - {Symlink, "symlink2", "target2", 0666}, - {Symlink, "symlink3", root + "/file1", 0666}, - {Symlink, "symlink4", root + "/symlink3", 0666}, - {Symlink, "dirSymlink", root + "/dir1", 0740}, - } + {filetype: Regular, path: "file1", contents: "file1\n", permissions: 0600}, + {filetype: Regular, path: "file2", contents: "file2\n", permissions: 0666}, + {filetype: Regular, path: "file3", contents: "file3\n", permissions: 0404}, + {filetype: Regular, path: "file4", contents: "file4\n", permissions: 0600}, + {filetype: Regular, path: "file5", contents: "file5\n", permissions: 0600}, + {filetype: Regular, path: "file6", contents: "file6\n", permissions: 0600}, + {filetype: Regular, path: "file7", contents: "file7\n", permissions: 0600}, + {filetype: Dir, path: "dir1", contents: "", permissions: 0740}, + {filetype: Regular, path: "dir1/file1-1", contents: "file1-1\n", permissions: 01444}, + {filetype: Regular, path: "dir1/file1-2", contents: "file1-2\n", permissions: 0666}, + {filetype: Dir, path: "dir2", contents: "", permissions: 0700}, + {filetype: Regular, path: "dir2/file2-1", contents: "file2-1\n", permissions: 0666}, + {filetype: Regular, path: "dir2/file2-2", contents: "file2-2\n", permissions: 0666}, + {filetype: Dir, path: "dir3", contents: "", permissions: 0700}, + {filetype: Regular, path: "dir3/file3-1", contents: "file3-1\n", permissions: 0666}, + {filetype: Regular, path: "dir3/file3-2", contents: "file3-2\n", permissions: 0666}, + {filetype: Dir, path: "dir4", contents: "", permissions: 0700}, + {filetype: Regular, path: "dir4/file3-1", contents: "file4-1\n", permissions: 0666}, + {filetype: Regular, path: "dir4/file3-2", contents: "file4-2\n", permissions: 0666}, + {filetype: Symlink, path: "symlink1", contents: "target1", permissions: 0666}, + {filetype: Symlink, path: "symlink2", contents: "target2", permissions: 0666}, + {filetype: Symlink, path: "symlink3", contents: root + "/file1", permissions: 0666}, + {filetype: Symlink, path: "symlink4", contents: root + "/symlink3", permissions: 0666}, + {filetype: Symlink, path: "dirSymlink", contents: root + "/dir1", permissions: 0740}, + } + provisionSampleDir(t, root, files) +} +func provisionSampleDir(t *testing.T, root string, files []FileData) { now := time.Now() for _, info := range files { p := path.Join(root, info.path) if info.filetype == Dir { - if err := os.MkdirAll(p, info.permissions); err != nil { - t.Fatal(err) - } + err := os.MkdirAll(p, info.permissions) + require.NoError(t, err) } else if info.filetype == Regular { - if err := ioutil.WriteFile(p, []byte(info.contents), info.permissions); err != nil { - t.Fatal(err) - } + err := ioutil.WriteFile(p, []byte(info.contents), info.permissions) + require.NoError(t, err) } else if info.filetype == Symlink { - if err := os.Symlink(info.contents, p); err != nil { - t.Fatal(err) - } + err := os.Symlink(info.contents, p) + require.NoError(t, err) } if info.filetype != Symlink { // Set a consistent ctime, atime for all files and dirs - if err := system.Chtimes(p, now, now); err != nil { - t.Fatal(err) - } + err := system.Chtimes(p, now, now) + require.NoError(t, err) } } } @@ -126,20 +126,14 @@ func TestChangesWithNoChanges(t *testing.T) { t.Skip("symlinks on Windows") } rwLayer, err := ioutil.TempDir("", "docker-changes-test") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(rwLayer) layer, err := ioutil.TempDir("", "docker-changes-test-layer") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(layer) createSampleDir(t, layer) changes, err := Changes([]string{layer}, rwLayer) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) if len(changes) != 0 { t.Fatalf("Changes with no difference should have detect no changes, but detected %d", len(changes)) } @@ -153,18 +147,14 @@ func TestChangesWithChanges(t *testing.T) { } // Mock the readonly layer layer, err := ioutil.TempDir("", "docker-changes-test-layer") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(layer) createSampleDir(t, layer) os.MkdirAll(path.Join(layer, "dir1/subfolder"), 0740) // Mock the RW layer rwLayer, err := ioutil.TempDir("", "docker-changes-test") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(rwLayer) // Create a folder in RW layer @@ -181,9 +171,7 @@ func TestChangesWithChanges(t *testing.T) { ioutil.WriteFile(newFile, []byte{}, 0740) changes, err := Changes([]string{layer}, rwLayer) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) expectedChanges := []Change{ {"/dir1", ChangeModify}, @@ -203,6 +191,7 @@ func TestChangesWithChangesGH13590(t *testing.T) { t.Skip("symlinks on Windows") } baseLayer, err := ioutil.TempDir("", "docker-changes-test.") + require.NoError(t, err) defer os.RemoveAll(baseLayer) dir3 := path.Join(baseLayer, "dir1/dir2/dir3") @@ -212,6 +201,7 @@ func TestChangesWithChangesGH13590(t *testing.T) { ioutil.WriteFile(file, []byte("hello"), 0666) layer, err := ioutil.TempDir("", "docker-changes-test2.") + require.NoError(t, err) defer os.RemoveAll(layer) // Test creating a new file @@ -224,9 +214,7 @@ func TestChangesWithChangesGH13590(t *testing.T) { ioutil.WriteFile(file, []byte("bye"), 0666) changes, err := Changes([]string{baseLayer}, layer) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) expectedChanges := []Change{ {"/dir1/dir2/dir3", ChangeModify}, @@ -236,6 +224,7 @@ func TestChangesWithChangesGH13590(t *testing.T) { // Now test changing a file layer, err = ioutil.TempDir("", "docker-changes-test3.") + require.NoError(t, err) defer os.RemoveAll(layer) if err := copyDir(baseLayer+"/dir1", layer+"/"); err != nil { @@ -246,9 +235,7 @@ func TestChangesWithChangesGH13590(t *testing.T) { ioutil.WriteFile(file, []byte("bye"), 0666) changes, err = Changes([]string{baseLayer}, layer) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) expectedChanges = []Change{ {"/dir1/dir2/dir3/file.txt", ChangeModify}, @@ -265,20 +252,15 @@ func TestChangesDirsEmpty(t *testing.T) { t.Skip("symlinks on Windows; gcp failure on Solaris") } src, err := ioutil.TempDir("", "docker-changes-test") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(src) createSampleDir(t, src) dst := src + "-copy" - if err := copyDir(src, dst); err != nil { - t.Fatal(err) - } + err = copyDir(src, dst) + require.NoError(t, err) defer os.RemoveAll(dst) changes, err := ChangesDirs(dst, src) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) if len(changes) != 0 { t.Fatalf("Reported changes for identical dirs: %v", changes) @@ -289,81 +271,65 @@ func TestChangesDirsEmpty(t *testing.T) { func mutateSampleDir(t *testing.T, root string) { // Remove a regular file - if err := os.RemoveAll(path.Join(root, "file1")); err != nil { - t.Fatal(err) - } + err := os.RemoveAll(path.Join(root, "file1")) + require.NoError(t, err) // Remove a directory - if err := os.RemoveAll(path.Join(root, "dir1")); err != nil { - t.Fatal(err) - } + err = os.RemoveAll(path.Join(root, "dir1")) + require.NoError(t, err) // Remove a symlink - if err := os.RemoveAll(path.Join(root, "symlink1")); err != nil { - t.Fatal(err) - } + err = os.RemoveAll(path.Join(root, "symlink1")) + require.NoError(t, err) // Rewrite a file - if err := ioutil.WriteFile(path.Join(root, "file2"), []byte("fileNN\n"), 0777); err != nil { - t.Fatal(err) - } + err = ioutil.WriteFile(path.Join(root, "file2"), []byte("fileNN\n"), 0777) + require.NoError(t, err) // Replace a file - if err := os.RemoveAll(path.Join(root, "file3")); err != nil { - t.Fatal(err) - } - if err := ioutil.WriteFile(path.Join(root, "file3"), []byte("fileMM\n"), 0404); err != nil { - t.Fatal(err) - } + err = os.RemoveAll(path.Join(root, "file3")) + require.NoError(t, err) + err = ioutil.WriteFile(path.Join(root, "file3"), []byte("fileMM\n"), 0404) + require.NoError(t, err) // Touch file - if err := system.Chtimes(path.Join(root, "file4"), time.Now().Add(time.Second), time.Now().Add(time.Second)); err != nil { - t.Fatal(err) - } + err = system.Chtimes(path.Join(root, "file4"), time.Now().Add(time.Second), time.Now().Add(time.Second)) + require.NoError(t, err) // Replace file with dir - if err := os.RemoveAll(path.Join(root, "file5")); err != nil { - t.Fatal(err) - } - if err := os.MkdirAll(path.Join(root, "file5"), 0666); err != nil { - t.Fatal(err) - } + err = os.RemoveAll(path.Join(root, "file5")) + require.NoError(t, err) + err = os.MkdirAll(path.Join(root, "file5"), 0666) + require.NoError(t, err) // Create new file - if err := ioutil.WriteFile(path.Join(root, "filenew"), []byte("filenew\n"), 0777); err != nil { - t.Fatal(err) - } + err = ioutil.WriteFile(path.Join(root, "filenew"), []byte("filenew\n"), 0777) + require.NoError(t, err) // Create new dir - if err := os.MkdirAll(path.Join(root, "dirnew"), 0766); err != nil { - t.Fatal(err) - } + err = os.MkdirAll(path.Join(root, "dirnew"), 0766) + require.NoError(t, err) // Create a new symlink - if err := os.Symlink("targetnew", path.Join(root, "symlinknew")); err != nil { - t.Fatal(err) - } + err = os.Symlink("targetnew", path.Join(root, "symlinknew")) + require.NoError(t, err) // Change a symlink - if err := os.RemoveAll(path.Join(root, "symlink2")); err != nil { - t.Fatal(err) - } - if err := os.Symlink("target2change", path.Join(root, "symlink2")); err != nil { - t.Fatal(err) - } + err = os.RemoveAll(path.Join(root, "symlink2")) + require.NoError(t, err) + + err = os.Symlink("target2change", path.Join(root, "symlink2")) + require.NoError(t, err) // Replace dir with file - if err := os.RemoveAll(path.Join(root, "dir2")); err != nil { - t.Fatal(err) - } - if err := ioutil.WriteFile(path.Join(root, "dir2"), []byte("dir2\n"), 0777); err != nil { - t.Fatal(err) - } + err = os.RemoveAll(path.Join(root, "dir2")) + require.NoError(t, err) + err = ioutil.WriteFile(path.Join(root, "dir2"), []byte("dir2\n"), 0777) + require.NoError(t, err) // Touch dir - if err := system.Chtimes(path.Join(root, "dir3"), time.Now().Add(time.Second), time.Now().Add(time.Second)); err != nil { - t.Fatal(err) - } + err = system.Chtimes(path.Join(root, "dir3"), time.Now().Add(time.Second), time.Now().Add(time.Second)) + require.NoError(t, err) } func TestChangesDirsMutated(t *testing.T) { @@ -374,23 +340,18 @@ func TestChangesDirsMutated(t *testing.T) { t.Skip("symlinks on Windows; gcp failures on Solaris") } src, err := ioutil.TempDir("", "docker-changes-test") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) createSampleDir(t, src) dst := src + "-copy" - if err := copyDir(src, dst); err != nil { - t.Fatal(err) - } + err = copyDir(src, dst) + require.NoError(t, err) defer os.RemoveAll(src) defer os.RemoveAll(dst) mutateSampleDir(t, dst) changes, err := ChangesDirs(dst, src) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) sort.Sort(changesByPath(changes)) @@ -436,41 +397,29 @@ func TestApplyLayer(t *testing.T) { t.Skip("symlinks on Windows; gcp failures on Solaris") } src, err := ioutil.TempDir("", "docker-changes-test") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) createSampleDir(t, src) defer os.RemoveAll(src) dst := src + "-copy" - if err := copyDir(src, dst); err != nil { - t.Fatal(err) - } + err = copyDir(src, dst) + require.NoError(t, err) mutateSampleDir(t, dst) defer os.RemoveAll(dst) changes, err := ChangesDirs(dst, src) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) layer, err := ExportChanges(dst, changes, nil, nil) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) layerCopy, err := NewTempArchive(layer, "") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) - if _, err := ApplyLayer(src, layerCopy); err != nil { - t.Fatal(err) - } + _, err = ApplyLayer(src, layerCopy) + require.NoError(t, err) changes2, err := ChangesDirs(src, dst) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) if len(changes2) != 0 { t.Fatalf("Unexpected differences after reapplying mutation: %v", changes2) @@ -484,26 +433,18 @@ func TestChangesSizeWithHardlinks(t *testing.T) { t.Skip("hardlinks on Windows") } srcDir, err := ioutil.TempDir("", "docker-test-srcDir") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(srcDir) destDir, err := ioutil.TempDir("", "docker-test-destDir") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) defer os.RemoveAll(destDir) creationSize, err := prepareUntarSourceDirectory(100, destDir, true) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) changes, err := ChangesDirs(destDir, srcDir) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) got := ChangesSize(destDir, changes) if got != int64(creationSize) { @@ -530,15 +471,15 @@ func TestChangesSizeWithOnlyDeleteChanges(t *testing.T) { func TestChangesSize(t *testing.T) { parentPath, err := ioutil.TempDir("", "docker-changes-test") + require.NoError(t, err) defer os.RemoveAll(parentPath) addition := path.Join(parentPath, "addition") - if err := ioutil.WriteFile(addition, []byte{0x01, 0x01, 0x01}, 0744); err != nil { - t.Fatal(err) - } + err = ioutil.WriteFile(addition, []byte{0x01, 0x01, 0x01}, 0744) + require.NoError(t, err) modification := path.Join(parentPath, "modification") - if err = ioutil.WriteFile(modification, []byte{0x01, 0x01, 0x01}, 0744); err != nil { - t.Fatal(err) - } + err = ioutil.WriteFile(modification, []byte{0x01, 0x01, 0x01}, 0744) + require.NoError(t, err) + changes := []Change{ {Path: "addition", Kind: ChangeAdd}, {Path: "modification", Kind: ChangeModify}, diff --git a/vendor/github.com/docker/docker/pkg/archive/changes_unix.go b/vendor/github.com/docker/docker/pkg/archive/changes_unix.go index 98e2b39ae..7aa1226d7 100644 --- a/vendor/github.com/docker/docker/pkg/archive/changes_unix.go +++ b/vendor/github.com/docker/docker/pkg/archive/changes_unix.go @@ -29,7 +29,7 @@ func (info *FileInfo) isDir() bool { } func getIno(fi os.FileInfo) uint64 { - return uint64(fi.Sys().(*syscall.Stat_t).Ino) + return fi.Sys().(*syscall.Stat_t).Ino } func hasHardlinks(fi os.FileInfo) bool { diff --git a/vendor/github.com/docker/docker/pkg/archive/copy.go b/vendor/github.com/docker/docker/pkg/archive/copy.go index 3adf8a275..d1e036d5c 100644 --- a/vendor/github.com/docker/docker/pkg/archive/copy.go +++ b/vendor/github.com/docker/docker/pkg/archive/copy.go @@ -27,23 +27,23 @@ var ( // path (from before being processed by utility functions from the path or // filepath stdlib packages) ends with a trailing `/.` or `/`. If the cleaned // path already ends in a `.` path segment, then another is not added. If the -// clean path already ends in a path separator, then another is not added. -func PreserveTrailingDotOrSeparator(cleanedPath, originalPath string) string { +// clean path already ends in the separator, then another is not added. +func PreserveTrailingDotOrSeparator(cleanedPath string, originalPath string, sep byte) string { // Ensure paths are in platform semantics - cleanedPath = normalizePath(cleanedPath) - originalPath = normalizePath(originalPath) + cleanedPath = strings.Replace(cleanedPath, "/", string(sep), -1) + originalPath = strings.Replace(originalPath, "/", string(sep), -1) if !specifiesCurrentDir(cleanedPath) && specifiesCurrentDir(originalPath) { - if !hasTrailingPathSeparator(cleanedPath) { + if !hasTrailingPathSeparator(cleanedPath, sep) { // Add a separator if it doesn't already end with one (a cleaned // path would only end in a separator if it is the root). - cleanedPath += string(filepath.Separator) + cleanedPath += string(sep) } cleanedPath += "." } - if !hasTrailingPathSeparator(cleanedPath) && hasTrailingPathSeparator(originalPath) { - cleanedPath += string(filepath.Separator) + if !hasTrailingPathSeparator(cleanedPath, sep) && hasTrailingPathSeparator(originalPath, sep) { + cleanedPath += string(sep) } return cleanedPath @@ -52,14 +52,14 @@ func PreserveTrailingDotOrSeparator(cleanedPath, originalPath string) string { // assertsDirectory returns whether the given path is // asserted to be a directory, i.e., the path ends with // a trailing '/' or `/.`, assuming a path separator of `/`. -func assertsDirectory(path string) bool { - return hasTrailingPathSeparator(path) || specifiesCurrentDir(path) +func assertsDirectory(path string, sep byte) bool { + return hasTrailingPathSeparator(path, sep) || specifiesCurrentDir(path) } // hasTrailingPathSeparator returns whether the given // path ends with the system's path separator character. -func hasTrailingPathSeparator(path string) bool { - return len(path) > 0 && os.IsPathSeparator(path[len(path)-1]) +func hasTrailingPathSeparator(path string, sep byte) bool { + return len(path) > 0 && path[len(path)-1] == sep } // specifiesCurrentDir returns whether the given path specifies @@ -72,10 +72,10 @@ func specifiesCurrentDir(path string) bool { // basename by first cleaning the path but preserves a trailing "." if the // original path specified the current directory. func SplitPathDirEntry(path string) (dir, base string) { - cleanedPath := filepath.Clean(normalizePath(path)) + cleanedPath := filepath.Clean(filepath.FromSlash(path)) if specifiesCurrentDir(path) { - cleanedPath += string(filepath.Separator) + "." + cleanedPath += string(os.PathSeparator) + "." } return filepath.Dir(cleanedPath), filepath.Base(cleanedPath) @@ -106,19 +106,24 @@ func TarResourceRebase(sourcePath, rebaseName string) (content io.ReadCloser, er // Separate the source path between its directory and // the entry in that directory which we are archiving. sourceDir, sourceBase := SplitPathDirEntry(sourcePath) - - filter := []string{sourceBase} + opts := TarResourceRebaseOpts(sourceBase, rebaseName) logrus.Debugf("copying %q from %q", sourceBase, sourceDir) + return TarWithOptions(sourceDir, opts) +} - return TarWithOptions(sourceDir, &TarOptions{ +// TarResourceRebaseOpts does not preform the Tar, but instead just creates the rebase +// parameters to be sent to TarWithOptions (the TarOptions struct) +func TarResourceRebaseOpts(sourceBase string, rebaseName string) *TarOptions { + filter := []string{sourceBase} + return &TarOptions{ Compression: Uncompressed, IncludeFiles: filter, IncludeSourceDir: true, RebaseNames: map[string]string{ sourceBase: rebaseName, }, - }) + } } // CopyInfo holds basic info about the source @@ -218,7 +223,7 @@ func CopyInfoDestinationPath(path string) (info CopyInfo, err error) { // Ensure destination parent dir exists. dstParent, _ := SplitPathDirEntry(path) - parentDirStat, err := os.Lstat(dstParent) + parentDirStat, err := os.Stat(dstParent) if err != nil { return CopyInfo{}, err } @@ -281,7 +286,7 @@ func PrepareArchiveCopy(srcContent io.Reader, srcInfo, dstInfo CopyInfo) (dstDir srcBase = srcInfo.RebaseName } return dstDir, RebaseArchiveEntries(srcContent, srcBase, dstBase), nil - case assertsDirectory(dstInfo.Path): + case assertsDirectory(dstInfo.Path, os.PathSeparator): // The destination does not exist and is asserted to be created as a // directory, but the source content is not a directory. This is an // error condition since you cannot create a directory from a file @@ -351,6 +356,9 @@ func RebaseArchiveEntries(srcContent io.Reader, oldBase, newBase string) io.Read return rebased } +// TODO @gupta-ak. These might have to be changed in the future to be +// continuity driver aware as well to support LCOW. + // CopyResource performs an archive copy from the given source path to the // given destination path. The source path MUST exist and the destination // path's parent directory must exist. @@ -365,8 +373,8 @@ func CopyResource(srcPath, dstPath string, followLink bool) error { dstPath = normalizePath(dstPath) // Clean the source and destination paths. - srcPath = PreserveTrailingDotOrSeparator(filepath.Clean(srcPath), srcPath) - dstPath = PreserveTrailingDotOrSeparator(filepath.Clean(dstPath), dstPath) + srcPath = PreserveTrailingDotOrSeparator(filepath.Clean(srcPath), srcPath, os.PathSeparator) + dstPath = PreserveTrailingDotOrSeparator(filepath.Clean(dstPath), dstPath, os.PathSeparator) if srcInfo, err = CopyInfoSourcePath(srcPath, followLink); err != nil { return err @@ -429,7 +437,8 @@ func ResolveHostSourcePath(path string, followLink bool) (resolvedPath, rebaseNa // resolvedDirPath will have been cleaned (no trailing path separators) so // we can manually join it with the base path element. resolvedPath = resolvedDirPath + string(filepath.Separator) + basePath - if hasTrailingPathSeparator(path) && filepath.Base(path) != filepath.Base(resolvedPath) { + if hasTrailingPathSeparator(path, os.PathSeparator) && + filepath.Base(path) != filepath.Base(resolvedPath) { rebaseName = filepath.Base(path) } } @@ -442,11 +451,13 @@ func GetRebaseName(path, resolvedPath string) (string, string) { // linkTarget will have been cleaned (no trailing path separators and dot) so // we can manually join it with them var rebaseName string - if specifiesCurrentDir(path) && !specifiesCurrentDir(resolvedPath) { + if specifiesCurrentDir(path) && + !specifiesCurrentDir(resolvedPath) { resolvedPath += string(filepath.Separator) + "." } - if hasTrailingPathSeparator(path) && !hasTrailingPathSeparator(resolvedPath) { + if hasTrailingPathSeparator(path, os.PathSeparator) && + !hasTrailingPathSeparator(resolvedPath, os.PathSeparator) { resolvedPath += string(filepath.Separator) } diff --git a/vendor/github.com/docker/docker/pkg/archive/copy_unix_test.go b/vendor/github.com/docker/docker/pkg/archive/copy_unix_test.go index 4d5ae79cd..e08bcb491 100644 --- a/vendor/github.com/docker/docker/pkg/archive/copy_unix_test.go +++ b/vendor/github.com/docker/docker/pkg/archive/copy_unix_test.go @@ -15,6 +15,8 @@ import ( "path/filepath" "strings" "testing" + + "github.com/stretchr/testify/require" ) func removeAllPaths(paths ...string) { @@ -26,13 +28,11 @@ func removeAllPaths(paths ...string) { func getTestTempDirs(t *testing.T) (tmpDirA, tmpDirB string) { var err error - if tmpDirA, err = ioutil.TempDir("", "archive-copy-test"); err != nil { - t.Fatal(err) - } + tmpDirA, err = ioutil.TempDir("", "archive-copy-test") + require.NoError(t, err) - if tmpDirB, err = ioutil.TempDir("", "archive-copy-test"); err != nil { - t.Fatal(err) - } + tmpDirB, err = ioutil.TempDir("", "archive-copy-test") + require.NoError(t, err) return } @@ -118,9 +118,8 @@ func logDirContents(t *testing.T, dirPath string) { t.Logf("logging directory contents: %q", dirPath) - if err := filepath.Walk(dirPath, logWalkedPaths); err != nil { - t.Fatal(err) - } + err := filepath.Walk(dirPath, logWalkedPaths) + require.NoError(t, err) } func testCopyHelper(t *testing.T, srcPath, dstPath string) (err error) { @@ -293,9 +292,8 @@ func TestCopyCaseA(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = fileContentsEqual(t, srcPath, dstPath); err != nil { - t.Fatal(err) - } + err = fileContentsEqual(t, srcPath, dstPath) + require.NoError(t, err) os.Remove(dstPath) symlinkPath := filepath.Join(tmpDirA, "symlink3") @@ -306,17 +304,15 @@ func TestCopyCaseA(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = fileContentsEqual(t, linkTarget, dstPath); err != nil { - t.Fatal(err) - } + err = fileContentsEqual(t, linkTarget, dstPath) + require.NoError(t, err) os.Remove(dstPath) if err = testCopyHelperFSym(t, symlinkPath1, dstPath); err != nil { t.Fatalf("unexpected error %T: %s", err, err) } - if err = fileContentsEqual(t, linkTarget, dstPath); err != nil { - t.Fatal(err) - } + err = fileContentsEqual(t, linkTarget, dstPath) + require.NoError(t, err) } // B. SRC specifies a file and DST (with trailing path separator) doesn't @@ -377,9 +373,8 @@ func TestCopyCaseC(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = fileContentsEqual(t, srcPath, dstPath); err != nil { - t.Fatal(err) - } + err = fileContentsEqual(t, srcPath, dstPath) + require.NoError(t, err) } // C. Symbol link following version: @@ -415,9 +410,8 @@ func TestCopyCaseCFSym(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = fileContentsEqual(t, linkTarget, dstPath); err != nil { - t.Fatal(err) - } + err = fileContentsEqual(t, linkTarget, dstPath) + require.NoError(t, err) } // D. SRC specifies a file and DST exists as a directory. This should place @@ -446,9 +440,8 @@ func TestCopyCaseD(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = fileContentsEqual(t, srcPath, dstPath); err != nil { - t.Fatal(err) - } + err = fileContentsEqual(t, srcPath, dstPath) + require.NoError(t, err) // Now try again but using a trailing path separator for dstDir. @@ -466,9 +459,8 @@ func TestCopyCaseD(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = fileContentsEqual(t, srcPath, dstPath); err != nil { - t.Fatal(err) - } + err = fileContentsEqual(t, srcPath, dstPath) + require.NoError(t, err) } // D. Symbol link following version: @@ -499,9 +491,8 @@ func TestCopyCaseDFSym(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = fileContentsEqual(t, linkTarget, dstPath); err != nil { - t.Fatal(err) - } + err = fileContentsEqual(t, linkTarget, dstPath) + require.NoError(t, err) // Now try again but using a trailing path separator for dstDir. @@ -519,9 +510,8 @@ func TestCopyCaseDFSym(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = fileContentsEqual(t, linkTarget, dstPath); err != nil { - t.Fatal(err) - } + err = fileContentsEqual(t, linkTarget, dstPath) + require.NoError(t, err) } // E. SRC specifies a directory and DST does not exist. This should create a @@ -563,9 +553,8 @@ func TestCopyCaseE(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = dirContentsEqual(t, dstDir, srcDir); err != nil { - t.Fatal(err) - } + err = dirContentsEqual(t, dstDir, srcDir) + require.NoError(t, err) } // E. Symbol link following version: @@ -609,9 +598,8 @@ func TestCopyCaseEFSym(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = dirContentsEqual(t, dstDir, linkTarget); err != nil { - t.Fatal(err) - } + err = dirContentsEqual(t, dstDir, linkTarget) + require.NoError(t, err) } // F. SRC specifies a directory and DST exists as a file. This should cause an @@ -669,9 +657,8 @@ func TestCopyCaseG(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = dirContentsEqual(t, resultDir, srcDir); err != nil { - t.Fatal(err) - } + err = dirContentsEqual(t, resultDir, srcDir) + require.NoError(t, err) // Now try again but using a trailing path separator for dstDir. @@ -689,9 +676,8 @@ func TestCopyCaseG(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = dirContentsEqual(t, resultDir, srcDir); err != nil { - t.Fatal(err) - } + err = dirContentsEqual(t, resultDir, srcDir) + require.NoError(t, err) } // G. Symbol link version: @@ -717,9 +703,8 @@ func TestCopyCaseGFSym(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = dirContentsEqual(t, resultDir, linkTarget); err != nil { - t.Fatal(err) - } + err = dirContentsEqual(t, resultDir, linkTarget) + require.NoError(t, err) // Now try again but using a trailing path separator for dstDir. @@ -737,9 +722,8 @@ func TestCopyCaseGFSym(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = dirContentsEqual(t, resultDir, linkTarget); err != nil { - t.Fatal(err) - } + err = dirContentsEqual(t, resultDir, linkTarget) + require.NoError(t, err) } // H. SRC specifies a directory's contents only and DST does not exist. This @@ -899,9 +883,8 @@ func TestCopyCaseJ(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = dirContentsEqual(t, dstDir, srcDir); err != nil { - t.Fatal(err) - } + err = dirContentsEqual(t, dstDir, srcDir) + require.NoError(t, err) // Now try again but using a trailing path separator for dstDir. @@ -919,9 +902,8 @@ func TestCopyCaseJ(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = dirContentsEqual(t, dstDir, srcDir); err != nil { - t.Fatal(err) - } + err = dirContentsEqual(t, dstDir, srcDir) + require.NoError(t, err) } // J. Symbol link following version: @@ -952,9 +934,8 @@ func TestCopyCaseJFSym(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = dirContentsEqual(t, dstDir, linkTarget); err != nil { - t.Fatal(err) - } + err = dirContentsEqual(t, dstDir, linkTarget) + require.NoError(t, err) // Now try again but using a trailing path separator for dstDir. @@ -972,7 +953,6 @@ func TestCopyCaseJFSym(t *testing.T) { t.Fatalf("unexpected error %T: %s", err, err) } - if err = dirContentsEqual(t, dstDir, linkTarget); err != nil { - t.Fatal(err) - } + err = dirContentsEqual(t, dstDir, linkTarget) + require.NoError(t, err) } diff --git a/vendor/github.com/docker/docker/pkg/archive/wrap_test.go b/vendor/github.com/docker/docker/pkg/archive/wrap_test.go index 46ab36697..bd26bda3a 100644 --- a/vendor/github.com/docker/docker/pkg/archive/wrap_test.go +++ b/vendor/github.com/docker/docker/pkg/archive/wrap_test.go @@ -5,13 +5,13 @@ import ( "bytes" "io" "testing" + + "github.com/stretchr/testify/require" ) func TestGenerateEmptyFile(t *testing.T) { archive, err := Generate("emptyFile") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) if archive == nil { t.Fatal("The generated archive should not be nil.") } @@ -28,9 +28,7 @@ func TestGenerateEmptyFile(t *testing.T) { if err == io.EOF { break } - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) buf := new(bytes.Buffer) buf.ReadFrom(tr) content := buf.String() @@ -54,9 +52,7 @@ func TestGenerateEmptyFile(t *testing.T) { func TestGenerateWithContent(t *testing.T) { archive, err := Generate("file", "content") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) if archive == nil { t.Fatal("The generated archive should not be nil.") } @@ -73,9 +69,7 @@ func TestGenerateWithContent(t *testing.T) { if err == io.EOF { break } - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) buf := new(bytes.Buffer) buf.ReadFrom(tr) content := buf.String() diff --git a/vendor/github.com/docker/docker/pkg/authorization/authz.go b/vendor/github.com/docker/docker/pkg/authorization/authz.go index b52446add..3bd2fc0bf 100644 --- a/vendor/github.com/docker/docker/pkg/authorization/authz.go +++ b/vendor/github.com/docker/docker/pkg/authorization/authz.go @@ -158,7 +158,7 @@ func sendBody(url string, header http.Header) bool { // headers returns flatten version of the http headers excluding authorization func headers(header http.Header) map[string]string { - v := make(map[string]string, 0) + v := make(map[string]string) for k, values := range header { // Skip authorization headers if strings.EqualFold(k, "Authorization") || strings.EqualFold(k, "X-Registry-Config") || strings.EqualFold(k, "X-Registry-Auth") { @@ -176,10 +176,7 @@ type authorizationError struct { error } -// HTTPErrorStatusCode returns the authorization error status code (forbidden) -func (e authorizationError) HTTPErrorStatusCode() int { - return http.StatusForbidden -} +func (authorizationError) Forbidden() {} func newAuthorizationError(plugin, msg string) authorizationError { return authorizationError{error: fmt.Errorf("authorization denied by plugin %s: %s", plugin, msg)} diff --git a/vendor/github.com/docker/docker/pkg/chrootarchive/archive.go b/vendor/github.com/docker/docker/pkg/chrootarchive/archive.go index 760441876..d6d07888e 100644 --- a/vendor/github.com/docker/docker/pkg/chrootarchive/archive.go +++ b/vendor/github.com/docker/docker/pkg/chrootarchive/archive.go @@ -16,7 +16,10 @@ func NewArchiver(idMappings *idtools.IDMappings) *archive.Archiver { if idMappings == nil { idMappings = &idtools.IDMappings{} } - return &archive.Archiver{Untar: Untar, IDMappings: idMappings} + return &archive.Archiver{ + Untar: Untar, + IDMappingsVar: idMappings, + } } // Untar reads a stream of bytes from `archive`, parses it as a tar archive, diff --git a/vendor/github.com/docker/docker/pkg/containerfs/archiver.go b/vendor/github.com/docker/docker/pkg/containerfs/archiver.go new file mode 100644 index 000000000..7fffa0003 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/containerfs/archiver.go @@ -0,0 +1,194 @@ +package containerfs + +import ( + "archive/tar" + "fmt" + "io" + "os" + "path/filepath" + + "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/idtools" + "github.com/docker/docker/pkg/promise" + "github.com/docker/docker/pkg/system" + "github.com/sirupsen/logrus" +) + +// TarFunc provides a function definition for a custom Tar function +type TarFunc func(string, *archive.TarOptions) (io.ReadCloser, error) + +// UntarFunc provides a function definition for a custom Untar function +type UntarFunc func(io.Reader, string, *archive.TarOptions) error + +// Archiver provides a similar implementation of the archive.Archiver package with the rootfs abstraction +type Archiver struct { + SrcDriver Driver + DstDriver Driver + Tar TarFunc + Untar UntarFunc + IDMappingsVar *idtools.IDMappings +} + +// TarUntar is a convenience function which calls Tar and Untar, with the output of one piped into the other. +// If either Tar or Untar fails, TarUntar aborts and returns the error. +func (archiver *Archiver) TarUntar(src, dst string) error { + logrus.Debugf("TarUntar(%s %s)", src, dst) + tarArchive, err := archiver.Tar(src, &archive.TarOptions{Compression: archive.Uncompressed}) + if err != nil { + return err + } + defer tarArchive.Close() + options := &archive.TarOptions{ + UIDMaps: archiver.IDMappingsVar.UIDs(), + GIDMaps: archiver.IDMappingsVar.GIDs(), + } + return archiver.Untar(tarArchive, dst, options) +} + +// UntarPath untar a file from path to a destination, src is the source tar file path. +func (archiver *Archiver) UntarPath(src, dst string) error { + tarArchive, err := archiver.SrcDriver.Open(src) + if err != nil { + return err + } + defer tarArchive.Close() + options := &archive.TarOptions{ + UIDMaps: archiver.IDMappingsVar.UIDs(), + GIDMaps: archiver.IDMappingsVar.GIDs(), + } + return archiver.Untar(tarArchive, dst, options) +} + +// CopyWithTar creates a tar archive of filesystem path `src`, and +// unpacks it at filesystem path `dst`. +// The archive is streamed directly with fixed buffering and no +// intermediary disk IO. +func (archiver *Archiver) CopyWithTar(src, dst string) error { + srcSt, err := archiver.SrcDriver.Stat(src) + if err != nil { + return err + } + if !srcSt.IsDir() { + return archiver.CopyFileWithTar(src, dst) + } + + // if this archiver is set up with ID mapping we need to create + // the new destination directory with the remapped root UID/GID pair + // as owner + rootIDs := archiver.IDMappingsVar.RootPair() + // Create dst, copy src's content into it + if err := idtools.MkdirAllAndChownNew(dst, 0755, rootIDs); err != nil { + return err + } + logrus.Debugf("Calling TarUntar(%s, %s)", src, dst) + return archiver.TarUntar(src, dst) +} + +// CopyFileWithTar emulates the behavior of the 'cp' command-line +// for a single file. It copies a regular file from path `src` to +// path `dst`, and preserves all its metadata. +func (archiver *Archiver) CopyFileWithTar(src, dst string) (err error) { + logrus.Debugf("CopyFileWithTar(%s, %s)", src, dst) + srcDriver := archiver.SrcDriver + dstDriver := archiver.DstDriver + + srcSt, err := srcDriver.Stat(src) + if err != nil { + return err + } + + if srcSt.IsDir() { + return fmt.Errorf("Can't copy a directory") + } + + // Clean up the trailing slash. This must be done in an operating + // system specific manner. + if dst[len(dst)-1] == dstDriver.Separator() { + dst = dstDriver.Join(dst, srcDriver.Base(src)) + } + + // The original call was system.MkdirAll, which is just + // os.MkdirAll on not-Windows and changed for Windows. + if dstDriver.OS() == "windows" { + // Now we are WCOW + if err := system.MkdirAll(filepath.Dir(dst), 0700, ""); err != nil { + return err + } + } else { + // We can just use the driver.MkdirAll function + if err := dstDriver.MkdirAll(dstDriver.Dir(dst), 0700); err != nil { + return err + } + } + + r, w := io.Pipe() + errC := promise.Go(func() error { + defer w.Close() + + srcF, err := srcDriver.Open(src) + if err != nil { + return err + } + defer srcF.Close() + + hdr, err := tar.FileInfoHeader(srcSt, "") + if err != nil { + return err + } + hdr.Name = dstDriver.Base(dst) + if dstDriver.OS() == "windows" { + hdr.Mode = int64(chmodTarEntry(os.FileMode(hdr.Mode))) + } else { + hdr.Mode = int64(os.FileMode(hdr.Mode)) + } + + if err := remapIDs(archiver.IDMappingsVar, hdr); err != nil { + return err + } + + tw := tar.NewWriter(w) + defer tw.Close() + if err := tw.WriteHeader(hdr); err != nil { + return err + } + if _, err := io.Copy(tw, srcF); err != nil { + return err + } + return nil + }) + defer func() { + if er := <-errC; err == nil && er != nil { + err = er + } + }() + + err = archiver.Untar(r, dstDriver.Dir(dst), nil) + if err != nil { + r.CloseWithError(err) + } + return err +} + +// IDMappings returns the IDMappings of the archiver. +func (archiver *Archiver) IDMappings() *idtools.IDMappings { + return archiver.IDMappingsVar +} + +func remapIDs(idMappings *idtools.IDMappings, hdr *tar.Header) error { + ids, err := idMappings.ToHost(idtools.IDPair{UID: hdr.Uid, GID: hdr.Gid}) + hdr.Uid, hdr.Gid = ids.UID, ids.GID + return err +} + +// chmodTarEntry is used to adjust the file permissions used in tar header based +// on the platform the archival is done. +func chmodTarEntry(perm os.FileMode) os.FileMode { + //perm &= 0755 // this 0-ed out tar flags (like link, regular file, directory marker etc.) + permPart := perm & os.ModePerm + noPermPart := perm &^ os.ModePerm + // Add the x bit: make everything +x from windows + permPart |= 0111 + permPart &= 0755 + + return noPermPart | permPart +} diff --git a/vendor/github.com/docker/docker/pkg/containerfs/containerfs.go b/vendor/github.com/docker/docker/pkg/containerfs/containerfs.go new file mode 100644 index 000000000..05842ac64 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/containerfs/containerfs.go @@ -0,0 +1,87 @@ +package containerfs + +import ( + "path/filepath" + "runtime" + + "github.com/containerd/continuity/driver" + "github.com/containerd/continuity/pathdriver" + "github.com/docker/docker/pkg/symlink" +) + +// ContainerFS is that represents a root file system +type ContainerFS interface { + // Path returns the path to the root. Note that this may not exist + // on the local system, so the continuity operations must be used + Path() string + + // ResolveScopedPath evaluates the given path scoped to the root. + // For example, if root=/a, and path=/b/c, then this function would return /a/b/c. + // If rawPath is true, then the function will not preform any modifications + // before path resolution. Otherwise, the function will clean the given path + // by making it an absolute path. + ResolveScopedPath(path string, rawPath bool) (string, error) + + Driver +} + +// Driver combines both continuity's Driver and PathDriver interfaces with a Platform +// field to determine the OS. +type Driver interface { + // OS returns the OS where the rootfs is located. Essentially, + // runtime.GOOS for everything aside from LCOW, which is "linux" + OS() string + + // Architecture returns the hardware architecture where the + // container is located. + Architecture() string + + // Driver & PathDriver provide methods to manipulate files & paths + driver.Driver + pathdriver.PathDriver +} + +// NewLocalContainerFS is a helper function to implement daemon's Mount interface +// when the graphdriver mount point is a local path on the machine. +func NewLocalContainerFS(path string) ContainerFS { + return &local{ + path: path, + Driver: driver.LocalDriver, + PathDriver: pathdriver.LocalPathDriver, + } +} + +// NewLocalDriver provides file and path drivers for a local file system. They are +// essentially a wrapper around the `os` and `filepath` functions. +func NewLocalDriver() Driver { + return &local{ + Driver: driver.LocalDriver, + PathDriver: pathdriver.LocalPathDriver, + } +} + +type local struct { + path string + driver.Driver + pathdriver.PathDriver +} + +func (l *local) Path() string { + return l.path +} + +func (l *local) ResolveScopedPath(path string, rawPath bool) (string, error) { + cleanedPath := path + if !rawPath { + cleanedPath = cleanScopedPath(path) + } + return symlink.FollowSymlinkInScope(filepath.Join(l.path, cleanedPath), l.path) +} + +func (l *local) OS() string { + return runtime.GOOS +} + +func (l *local) Architecture() string { + return runtime.GOARCH +} diff --git a/vendor/github.com/docker/docker/pkg/containerfs/containerfs_unix.go b/vendor/github.com/docker/docker/pkg/containerfs/containerfs_unix.go new file mode 100644 index 000000000..fbc418f01 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/containerfs/containerfs_unix.go @@ -0,0 +1,10 @@ +// +build !windows + +package containerfs + +import "path/filepath" + +// cleanScopedPath preappends a to combine with a mnt path. +func cleanScopedPath(path string) string { + return filepath.Join(string(filepath.Separator), path) +} diff --git a/vendor/github.com/docker/docker/pkg/containerfs/containerfs_windows.go b/vendor/github.com/docker/docker/pkg/containerfs/containerfs_windows.go new file mode 100644 index 000000000..56f5a7564 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/containerfs/containerfs_windows.go @@ -0,0 +1,15 @@ +package containerfs + +import "path/filepath" + +// cleanScopedPath removes the C:\ syntax, and prepares to combine +// with a volume path +func cleanScopedPath(path string) string { + if len(path) >= 2 { + c := path[0] + if path[1] == ':' && ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z') { + path = path[2:] + } + } + return filepath.Join(string(filepath.Separator), path) +} diff --git a/vendor/github.com/docker/docker/pkg/devicemapper/devmapper.go b/vendor/github.com/docker/docker/pkg/devicemapper/devmapper.go index 2254a6b53..48618765f 100644 --- a/vendor/github.com/docker/docker/pkg/devicemapper/devmapper.go +++ b/vendor/github.com/docker/docker/pkg/devicemapper/devmapper.go @@ -14,6 +14,7 @@ import ( ) // Same as DM_DEVICE_* enum values from libdevmapper.h +// nolint: deadcode const ( deviceCreate TaskType = iota deviceReload @@ -350,8 +351,7 @@ func RemoveDeviceDeferred(name string) error { // disable udev dm rules and delete the symlink under /dev/mapper by itself, // even if the removal is deferred by the kernel. cookie := new(uint) - var flags uint16 - flags = DmUdevDisableLibraryFallback + flags := uint16(DmUdevDisableLibraryFallback) if err := task.setCookie(cookie, flags); err != nil { return fmt.Errorf("devicemapper: Can not set cookie: %s", err) } @@ -464,8 +464,7 @@ func CreatePool(poolName string, dataFile, metadataFile *os.File, poolBlockSize } cookie := new(uint) - var flags uint16 - flags = DmUdevDisableSubsystemRulesFlag | DmUdevDisableDiskRulesFlag | DmUdevDisableOtherRulesFlag + flags := uint16(DmUdevDisableSubsystemRulesFlag | DmUdevDisableDiskRulesFlag | DmUdevDisableOtherRulesFlag) if err := task.setCookie(cookie, flags); err != nil { return fmt.Errorf("devicemapper: Can't set cookie %s", err) } diff --git a/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_log.go b/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_log.go index d2c0d4c76..f2ac7da87 100644 --- a/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_log.go +++ b/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_log.go @@ -12,7 +12,7 @@ import ( ) // DevmapperLogger defines methods required to register as a callback for -// logging events recieved from devicemapper. Note that devicemapper will send +// logging events received from devicemapper. Note that devicemapper will send // *all* logs regardless to callbacks (including debug logs) so it's // recommended to not spam the console with the outputs. type DevmapperLogger interface { @@ -74,7 +74,7 @@ type DefaultLogger struct { // DMLog is the logging callback containing all of the information from // devicemapper. The interface is identical to the C libdm counterpart. func (l DefaultLogger) DMLog(level int, file string, line, dmError int, message string) { - if int(level) <= l.Level { + if level <= l.Level { // Forward the log to the correct logrus level, if allowed by dmLogLevel. logMsg := fmt.Sprintf("libdevmapper(%d): %s:%d (%d) %s", level, file, line, dmError, message) switch level { diff --git a/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_wrapper.go b/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_wrapper.go index da3b43f79..64e82dfd0 100644 --- a/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_wrapper.go +++ b/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_wrapper.go @@ -3,7 +3,6 @@ package devicemapper /* -#cgo LDFLAGS: -L. -ldevmapper #define _GNU_SOURCE #include #include // FIXME: present only for BLKGETSIZE64, maybe we can remove it? diff --git a/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_wrapper_deferred_remove.go b/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_wrapper_deferred_remove.go index 7e231ddcb..7f793c270 100644 --- a/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_wrapper_deferred_remove.go +++ b/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_wrapper_deferred_remove.go @@ -2,10 +2,7 @@ package devicemapper -/* -#cgo LDFLAGS: -L. -ldevmapper -#include -*/ +// #include import "C" // LibraryDeferredRemovalSupport tells if the feature is enabled in the build diff --git a/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_wrapper_dynamic.go b/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_wrapper_dynamic.go new file mode 100644 index 000000000..7d8450898 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/devicemapper/devmapper_wrapper_dynamic.go @@ -0,0 +1,6 @@ +// +build linux,cgo,!static_build + +package devicemapper + +// #cgo pkg-config: devmapper +import "C" diff --git a/vendor/github.com/docker/docker/pkg/directory/directory_unix.go b/vendor/github.com/docker/docker/pkg/directory/directory_unix.go index 397251bdb..d4f2970a6 100644 --- a/vendor/github.com/docker/docker/pkg/directory/directory_unix.go +++ b/vendor/github.com/docker/docker/pkg/directory/directory_unix.go @@ -34,11 +34,11 @@ func Size(dir string) (size int64, err error) { // Check inode to handle hard links correctly inode := fileInfo.Sys().(*syscall.Stat_t).Ino // inode is not a uint64 on all platforms. Cast it to avoid issues. - if _, exists := data[uint64(inode)]; exists { + if _, exists := data[inode]; exists { return nil } // inode is not a uint64 on all platforms. Cast it to avoid issues. - data[uint64(inode)] = struct{}{} + data[inode] = struct{}{} size += s diff --git a/vendor/github.com/docker/docker/pkg/discovery/kv/kv_test.go b/vendor/github.com/docker/docker/pkg/discovery/kv/kv_test.go index dab3939dd..adc5c289a 100644 --- a/vendor/github.com/docker/docker/pkg/discovery/kv/kv_test.go +++ b/vendor/github.com/docker/docker/pkg/discovery/kv/kv_test.go @@ -11,7 +11,6 @@ import ( "github.com/docker/docker/pkg/discovery" "github.com/docker/libkv" "github.com/docker/libkv/store" - "github.com/go-check/check" ) @@ -130,7 +129,6 @@ func (s *Mock) AtomicDelete(key string, previous *store.KVPair) (bool, error) { // Close mock func (s *Mock) Close() { - return } func (ds *DiscoverySuite) TestInitializeWithCerts(c *check.C) { diff --git a/vendor/github.com/docker/docker/pkg/dmesg/dmesg_linux.go b/vendor/github.com/docker/docker/pkg/dmesg/dmesg_linux.go new file mode 100644 index 000000000..7df7f3d43 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/dmesg/dmesg_linux.go @@ -0,0 +1,20 @@ +// +build linux + +package dmesg + +import ( + "unsafe" + + "golang.org/x/sys/unix" +) + +// Dmesg returns last messages from the kernel log, up to size bytes +func Dmesg(size int) []byte { + t := uintptr(3) // SYSLOG_ACTION_READ_ALL + b := make([]byte, size) + amt, _, err := unix.Syscall(unix.SYS_SYSLOG, t, uintptr(unsafe.Pointer(&b[0])), uintptr(len(b))) + if err != 0 { + return []byte{} + } + return b[:amt] +} diff --git a/vendor/github.com/docker/docker/pkg/dmesg/dmesg_linux_test.go b/vendor/github.com/docker/docker/pkg/dmesg/dmesg_linux_test.go new file mode 100644 index 000000000..c5028aac1 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/dmesg/dmesg_linux_test.go @@ -0,0 +1,9 @@ +package dmesg + +import ( + "testing" +) + +func TestDmesg(t *testing.T) { + t.Logf("dmesg output follows:\n%v", string(Dmesg(512))) +} diff --git a/vendor/github.com/docker/docker/pkg/fileutils/fileutils_test.go b/vendor/github.com/docker/docker/pkg/fileutils/fileutils_test.go index 3d61d55c3..2df5bdd91 100644 --- a/vendor/github.com/docker/docker/pkg/fileutils/fileutils_test.go +++ b/vendor/github.com/docker/docker/pkg/fileutils/fileutils_test.go @@ -1,6 +1,7 @@ package fileutils import ( + "fmt" "io/ioutil" "os" "path" @@ -9,7 +10,6 @@ import ( "strings" "testing" - "fmt" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/vendor/github.com/docker/docker/pkg/ioutils/readers_test.go b/vendor/github.com/docker/docker/pkg/ioutils/readers_test.go index 9abc1054d..86e50d38f 100644 --- a/vendor/github.com/docker/docker/pkg/ioutils/readers_test.go +++ b/vendor/github.com/docker/docker/pkg/ioutils/readers_test.go @@ -7,6 +7,7 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" "golang.org/x/net/context" ) @@ -14,7 +15,7 @@ import ( type errorReader struct{} func (r *errorReader) Read(p []byte) (int, error) { - return 0, fmt.Errorf("Error reader always fail.") + return 0, fmt.Errorf("error reader always fail") } func TestReadCloserWrapperClose(t *testing.T) { @@ -35,9 +36,7 @@ func TestReaderErrWrapperReadOnError(t *testing.T) { called = true }) _, err := wrapper.Read([]byte{}) - if err == nil || !strings.Contains(err.Error(), "Error reader always fail.") { - t.Fatalf("readErrWrapper should returned an error") - } + assert.EqualError(t, err, "error reader always fail") if !called { t.Fatalf("readErrWrapper should have call the anonymous function on failure") } diff --git a/vendor/github.com/docker/docker/pkg/jsonmessage/jsonmessage.go b/vendor/github.com/docker/docker/pkg/jsonmessage/jsonmessage.go index dc785d618..09fc4cc74 100644 --- a/vendor/github.com/docker/docker/pkg/jsonmessage/jsonmessage.go +++ b/vendor/github.com/docker/docker/pkg/jsonmessage/jsonmessage.go @@ -8,11 +8,10 @@ import ( "strings" "time" - "github.com/Nvveen/Gotty" - + gotty "github.com/Nvveen/Gotty" "github.com/docker/docker/pkg/jsonlog" "github.com/docker/docker/pkg/term" - "github.com/docker/go-units" + units "github.com/docker/go-units" ) // JSONError wraps a concrete Code and Message, `Code` is @@ -187,7 +186,7 @@ func cursorDown(out io.Writer, ti termInfo, l int) { func (jm *JSONMessage) Display(out io.Writer, termInfo termInfo) error { if jm.Error != nil { if jm.Error.Code == 401 { - return fmt.Errorf("Authentication is required.") + return fmt.Errorf("authentication is required") } return jm.Error } diff --git a/vendor/github.com/docker/docker/pkg/jsonmessage/jsonmessage_test.go b/vendor/github.com/docker/docker/pkg/jsonmessage/jsonmessage_test.go index c3ed6c046..5206789ac 100644 --- a/vendor/github.com/docker/docker/pkg/jsonmessage/jsonmessage_test.go +++ b/vendor/github.com/docker/docker/pkg/jsonmessage/jsonmessage_test.go @@ -10,6 +10,7 @@ import ( "github.com/docker/docker/pkg/jsonlog" "github.com/docker/docker/pkg/term" + "github.com/stretchr/testify/assert" ) func TestError(t *testing.T) { @@ -198,9 +199,7 @@ func TestJSONMessageDisplayWithJSONError(t *testing.T) { jsonMessage = JSONMessage{Error: &JSONError{401, "Anything"}} err = jsonMessage.Display(data, &noTermInfo{}) - if err == nil || err.Error() != "Authentication is required." { - t.Fatalf("Expected an error \"Authentication is required.\", got %q", err) - } + assert.EqualError(t, err, "authentication is required") } func TestDisplayJSONMessagesStreamInvalidJSON(t *testing.T) { diff --git a/vendor/github.com/docker/docker/pkg/locker/README.md b/vendor/github.com/docker/docker/pkg/locker/README.md index c8dbddc57..ce787aefb 100644 --- a/vendor/github.com/docker/docker/pkg/locker/README.md +++ b/vendor/github.com/docker/docker/pkg/locker/README.md @@ -35,7 +35,7 @@ type important struct { func (i *important) Get(name string) interface{} { i.locks.Lock(name) defer i.locks.Unlock(name) - return data[name] + return i.data[name] } func (i *important) Create(name string, data interface{}) { @@ -44,9 +44,9 @@ func (i *important) Create(name string, data interface{}) { i.createImportant(data) - s.mu.Lock() + i.mu.Lock() i.data[name] = data - s.mu.Unlock() + i.mu.Unlock() } func (i *important) createImportant(data interface{}) { diff --git a/vendor/github.com/docker/docker/pkg/loopback/ioctl.go b/vendor/github.com/docker/docker/pkg/loopback/ioctl.go index fa744f0a6..84fcea669 100644 --- a/vendor/github.com/docker/docker/pkg/loopback/ioctl.go +++ b/vendor/github.com/docker/docker/pkg/loopback/ioctl.go @@ -17,10 +17,7 @@ func ioctlLoopCtlGetFree(fd uintptr) (int, error) { } func ioctlLoopSetFd(loopFd, sparseFd uintptr) error { - if err := unix.IoctlSetInt(int(loopFd), LoopSetFd, int(sparseFd)); err != nil { - return err - } - return nil + return unix.IoctlSetInt(int(loopFd), LoopSetFd, int(sparseFd)) } func ioctlLoopSetStatus64(loopFd uintptr, loopInfo *loopInfo64) error { @@ -47,8 +44,5 @@ func ioctlLoopGetStatus64(loopFd uintptr) (*loopInfo64, error) { } func ioctlLoopSetCapacity(loopFd uintptr, value int) error { - if err := unix.IoctlSetInt(int(loopFd), LoopSetCapacity, value); err != nil { - return err - } - return nil + return unix.IoctlSetInt(int(loopFd), LoopSetCapacity, value) } diff --git a/vendor/github.com/docker/docker/pkg/mount/mounter_solaris.go b/vendor/github.com/docker/docker/pkg/mount/mounter_solaris.go index c684aa81f..48b86771e 100644 --- a/vendor/github.com/docker/docker/pkg/mount/mounter_solaris.go +++ b/vendor/github.com/docker/docker/pkg/mount/mounter_solaris.go @@ -3,8 +3,9 @@ package mount import ( - "golang.org/x/sys/unix" "unsafe" + + "golang.org/x/sys/unix" ) // #include diff --git a/vendor/github.com/docker/docker/pkg/plugins/discovery_unix_test.go b/vendor/github.com/docker/docker/pkg/plugins/discovery_unix_test.go index 66f50353c..e4d156dbd 100644 --- a/vendor/github.com/docker/docker/pkg/plugins/discovery_unix_test.go +++ b/vendor/github.com/docker/docker/pkg/plugins/discovery_unix_test.go @@ -10,6 +10,8 @@ import ( "path/filepath" "reflect" "testing" + + "github.com/stretchr/testify/require" ) func TestLocalSocket(t *testing.T) { @@ -89,6 +91,7 @@ func TestScan(t *testing.T) { r := newLocalRegistry() p, err := r.Plugin(name) + require.NoError(t, err) pluginNamesNotEmpty, err := Scan() if err != nil { diff --git a/vendor/github.com/docker/docker/pkg/plugins/pluginrpc-gen/fixtures/foo.go b/vendor/github.com/docker/docker/pkg/plugins/pluginrpc-gen/fixtures/foo.go index 5695dcc2d..4dd1d6dd2 100644 --- a/vendor/github.com/docker/docker/pkg/plugins/pluginrpc-gen/fixtures/foo.go +++ b/vendor/github.com/docker/docker/pkg/plugins/pluginrpc-gen/fixtures/foo.go @@ -1,17 +1,11 @@ package foo import ( - "fmt" - aliasedio "io" "github.com/docker/docker/pkg/plugins/pluginrpc-gen/fixtures/otherfixture" ) -var ( - errFakeImport = fmt.Errorf("just to import fmt for imports tests") -) - type wobble struct { Some string Val string diff --git a/vendor/github.com/docker/docker/pkg/pools/pools_test.go b/vendor/github.com/docker/docker/pkg/pools/pools_test.go index d71cb99ac..544c49995 100644 --- a/vendor/github.com/docker/docker/pkg/pools/pools_test.go +++ b/vendor/github.com/docker/docker/pkg/pools/pools_test.go @@ -6,6 +6,9 @@ import ( "io" "strings" "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestBufioReaderPoolGetWithNoReaderShouldCreateOne(t *testing.T) { @@ -92,22 +95,16 @@ func TestBufioWriterPoolPutAndGet(t *testing.T) { buf := new(bytes.Buffer) bw := bufio.NewWriter(buf) writer := BufioWriter32KPool.Get(bw) - if writer == nil { - t.Fatalf("BufioReaderPool should not return a nil writer.") - } + require.NotNil(t, writer) + written, err := writer.Write([]byte("foobar")) - if err != nil { - t.Fatal(err) - } - if written != 6 { - t.Fatalf("Should have written 6 bytes, but wrote %v bytes", written) - } + require.NoError(t, err) + assert.Equal(t, 6, written) + // Make sure we Flush all the way ? writer.Flush() bw.Flush() - if len(buf.Bytes()) != 6 { - t.Fatalf("The buffer should contain 6 bytes ('foobar') but contains %v ('%v')", buf.Bytes(), string(buf.Bytes())) - } + assert.Len(t, buf.Bytes(), 6) // Reset the buffer buf.Reset() BufioWriter32KPool.Put(writer) diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_linux_test.go b/vendor/github.com/docker/docker/pkg/signal/signal_linux_test.go index 32c056fe4..da0e01054 100644 --- a/vendor/github.com/docker/docker/pkg/signal/signal_linux_test.go +++ b/vendor/github.com/docker/docker/pkg/signal/signal_linux_test.go @@ -41,7 +41,7 @@ func TestCatchAll(t *testing.T) { } func TestStopCatch(t *testing.T) { - signal, _ := SignalMap["HUP"] + signal := SignalMap["HUP"] channel := make(chan os.Signal, 1) CatchAll(channel) go func() { diff --git a/vendor/github.com/docker/docker/pkg/signal/testfiles/main.go b/vendor/github.com/docker/docker/pkg/signal/testfiles/main.go new file mode 100644 index 000000000..e56854c7c --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/signal/testfiles/main.go @@ -0,0 +1,43 @@ +package main + +import ( + "os" + "syscall" + "time" + + "github.com/docker/docker/pkg/signal" + "github.com/sirupsen/logrus" +) + +func main() { + sigmap := map[string]os.Signal{ + "TERM": syscall.SIGTERM, + "QUIT": syscall.SIGQUIT, + "INT": os.Interrupt, + } + signal.Trap(func() { + time.Sleep(time.Second) + os.Exit(99) + }, logrus.StandardLogger()) + go func() { + p, err := os.FindProcess(os.Getpid()) + if err != nil { + panic(err) + } + s := os.Getenv("SIGNAL_TYPE") + multiple := os.Getenv("IF_MULTIPLE") + switch s { + case "TERM", "INT": + if multiple == "1" { + for { + p.Signal(sigmap[s]) + } + } else { + p.Signal(sigmap[s]) + } + case "QUIT": + p.Signal(sigmap[s]) + } + }() + time.Sleep(2 * time.Second) +} diff --git a/vendor/github.com/docker/docker/pkg/signal/trap_linux_test.go b/vendor/github.com/docker/docker/pkg/signal/trap_linux_test.go new file mode 100644 index 000000000..2622766b5 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/signal/trap_linux_test.go @@ -0,0 +1,82 @@ +// +build linux + +package signal + +import ( + "fmt" + "io/ioutil" + "os" + "os/exec" + "syscall" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func buildTestBinary(t *testing.T, tmpdir string, prefix string) (string, string) { + tmpDir, err := ioutil.TempDir(tmpdir, prefix) + require.NoError(t, err) + exePath := tmpDir + "/" + prefix + wd, _ := os.Getwd() + testHelperCode := wd + "/testfiles/main.go" + cmd := exec.Command("go", "build", "-o", exePath, testHelperCode) + err = cmd.Run() + require.NoError(t, err) + return exePath, tmpDir +} + +func TestTrap(t *testing.T) { + var sigmap = []struct { + name string + signal os.Signal + multiple bool + }{ + {"TERM", syscall.SIGTERM, false}, + {"QUIT", syscall.SIGQUIT, true}, + {"INT", os.Interrupt, false}, + {"TERM", syscall.SIGTERM, true}, + {"INT", os.Interrupt, true}, + } + exePath, tmpDir := buildTestBinary(t, "", "main") + defer os.RemoveAll(tmpDir) + + for _, v := range sigmap { + cmd := exec.Command(exePath) + cmd.Env = append(os.Environ(), fmt.Sprintf("SIGNAL_TYPE=%s", v.name)) + if v.multiple { + cmd.Env = append(cmd.Env, "IF_MULTIPLE=1") + } + err := cmd.Start() + require.NoError(t, err) + err = cmd.Wait() + if e, ok := err.(*exec.ExitError); ok { + code := e.Sys().(syscall.WaitStatus).ExitStatus() + if v.multiple { + assert.Equal(t, 128+int(v.signal.(syscall.Signal)), code) + } else { + assert.Equal(t, 99, code) + } + continue + } + t.Fatal("process didn't end with any error") + } + +} + +func TestDumpStacks(t *testing.T) { + directory, err := ioutil.TempDir("", "test-dump-tasks") + assert.NoError(t, err) + defer os.RemoveAll(directory) + dumpPath, err := DumpStacks(directory) + assert.NoError(t, err) + readFile, _ := ioutil.ReadFile(dumpPath) + fileData := string(readFile) + assert.Contains(t, fileData, "goroutine") +} + +func TestDumpStacksWithEmptyInput(t *testing.T) { + path, err := DumpStacks("") + assert.NoError(t, err) + assert.Equal(t, os.Stderr.Name(), path) +} diff --git a/vendor/github.com/docker/docker/pkg/streamformatter/streamwriter_test.go b/vendor/github.com/docker/docker/pkg/streamformatter/streamwriter_test.go index 4935cc595..a3c026a5c 100644 --- a/vendor/github.com/docker/docker/pkg/streamformatter/streamwriter_test.go +++ b/vendor/github.com/docker/docker/pkg/streamformatter/streamwriter_test.go @@ -1,9 +1,9 @@ package streamformatter import ( + "bytes" "testing" - "bytes" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/vendor/github.com/docker/docker/pkg/system/events_windows.go b/vendor/github.com/docker/docker/pkg/system/events_windows.go deleted file mode 100644 index 192e36788..000000000 --- a/vendor/github.com/docker/docker/pkg/system/events_windows.go +++ /dev/null @@ -1,85 +0,0 @@ -package system - -// This file implements syscalls for Win32 events which are not implemented -// in golang. - -import ( - "syscall" - "unsafe" - - "golang.org/x/sys/windows" -) - -var ( - procCreateEvent = modkernel32.NewProc("CreateEventW") - procOpenEvent = modkernel32.NewProc("OpenEventW") - procSetEvent = modkernel32.NewProc("SetEvent") - procResetEvent = modkernel32.NewProc("ResetEvent") - procPulseEvent = modkernel32.NewProc("PulseEvent") -) - -// CreateEvent implements win32 CreateEventW func in golang. It will create an event object. -func CreateEvent(eventAttributes *windows.SecurityAttributes, manualReset bool, initialState bool, name string) (handle windows.Handle, err error) { - namep, _ := windows.UTF16PtrFromString(name) - var _p1 uint32 - if manualReset { - _p1 = 1 - } - var _p2 uint32 - if initialState { - _p2 = 1 - } - r0, _, e1 := procCreateEvent.Call(uintptr(unsafe.Pointer(eventAttributes)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(namep))) - use(unsafe.Pointer(namep)) - handle = windows.Handle(r0) - if handle == windows.InvalidHandle { - err = e1 - } - return -} - -// OpenEvent implements win32 OpenEventW func in golang. It opens an event object. -func OpenEvent(desiredAccess uint32, inheritHandle bool, name string) (handle windows.Handle, err error) { - namep, _ := windows.UTF16PtrFromString(name) - var _p1 uint32 - if inheritHandle { - _p1 = 1 - } - r0, _, e1 := procOpenEvent.Call(uintptr(desiredAccess), uintptr(_p1), uintptr(unsafe.Pointer(namep))) - use(unsafe.Pointer(namep)) - handle = windows.Handle(r0) - if handle == windows.InvalidHandle { - err = e1 - } - return -} - -// SetEvent implements win32 SetEvent func in golang. -func SetEvent(handle windows.Handle) (err error) { - return setResetPulse(handle, procSetEvent) -} - -// ResetEvent implements win32 ResetEvent func in golang. -func ResetEvent(handle windows.Handle) (err error) { - return setResetPulse(handle, procResetEvent) -} - -// PulseEvent implements win32 PulseEvent func in golang. -func PulseEvent(handle windows.Handle) (err error) { - return setResetPulse(handle, procPulseEvent) -} - -func setResetPulse(handle windows.Handle, proc *windows.LazyProc) (err error) { - r0, _, _ := proc.Call(uintptr(handle)) - if r0 != 0 { - err = syscall.Errno(r0) - } - return -} - -var temp unsafe.Pointer - -// use ensures a variable is kept alive without the GC freeing while still needed -func use(p unsafe.Pointer) { - temp = p -} diff --git a/vendor/github.com/docker/docker/pkg/system/init_unix.go b/vendor/github.com/docker/docker/pkg/system/init_unix.go new file mode 100644 index 000000000..a219895e6 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/system/init_unix.go @@ -0,0 +1,7 @@ +// +build !windows + +package system + +// InitLCOW does nothing since LCOW is a windows only feature +func InitLCOW(experimental bool) { +} diff --git a/vendor/github.com/docker/docker/pkg/system/init_windows.go b/vendor/github.com/docker/docker/pkg/system/init_windows.go index 019c66441..e75183726 100644 --- a/vendor/github.com/docker/docker/pkg/system/init_windows.go +++ b/vendor/github.com/docker/docker/pkg/system/init_windows.go @@ -8,9 +8,10 @@ import "os" // on build number. @jhowardmsft var lcowSupported = false -func init() { +// InitLCOW sets whether LCOW is supported or not +func InitLCOW(experimental bool) { // LCOW initialization - if os.Getenv("LCOW_SUPPORTED") != "" { + if experimental && os.Getenv("LCOW_SUPPORTED") != "" { lcowSupported = true } diff --git a/vendor/github.com/docker/docker/pkg/system/path.go b/vendor/github.com/docker/docker/pkg/system/path.go index f634a6be6..4160616f4 100644 --- a/vendor/github.com/docker/docker/pkg/system/path.go +++ b/vendor/github.com/docker/docker/pkg/system/path.go @@ -1,6 +1,13 @@ package system -import "runtime" +import ( + "fmt" + "path/filepath" + "runtime" + "strings" + + "github.com/containerd/continuity/pathdriver" +) const defaultUnixPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" @@ -19,3 +26,35 @@ func DefaultPathEnv(platform string) string { return defaultUnixPathEnv } + +// CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter, +// is the system drive. +// On Linux: this is a no-op. +// On Windows: this does the following> +// CheckSystemDriveAndRemoveDriveLetter verifies and manipulates a Windows path. +// This is used, for example, when validating a user provided path in docker cp. +// If a drive letter is supplied, it must be the system drive. The drive letter +// is always removed. Also, it translates it to OS semantics (IOW / to \). We +// need the path in this syntax so that it can ultimately be contatenated with +// a Windows long-path which doesn't support drive-letters. Examples: +// C: --> Fail +// C:\ --> \ +// a --> a +// /a --> \a +// d:\ --> Fail +func CheckSystemDriveAndRemoveDriveLetter(path string, driver pathdriver.PathDriver) (string, error) { + if runtime.GOOS != "windows" || LCOWSupported() { + return path, nil + } + + if len(path) == 2 && string(path[1]) == ":" { + return "", fmt.Errorf("No relative path specified in %q", path) + } + if !driver.IsAbs(path) || len(path) < 2 { + return filepath.FromSlash(path), nil + } + if string(path[1]) == ":" && !strings.EqualFold(string(path[0]), "c") { + return "", fmt.Errorf("The specified path is not on the system drive (C:)") + } + return filepath.FromSlash(path[2:]), nil +} diff --git a/vendor/github.com/docker/docker/pkg/system/path_unix.go b/vendor/github.com/docker/docker/pkg/system/path_unix.go deleted file mode 100644 index f3762e69d..000000000 --- a/vendor/github.com/docker/docker/pkg/system/path_unix.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build !windows - -package system - -// CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter, -// is the system drive. This is a no-op on Linux. -func CheckSystemDriveAndRemoveDriveLetter(path string) (string, error) { - return path, nil -} diff --git a/vendor/github.com/docker/docker/pkg/system/path_windows.go b/vendor/github.com/docker/docker/pkg/system/path_windows.go deleted file mode 100644 index aab891522..000000000 --- a/vendor/github.com/docker/docker/pkg/system/path_windows.go +++ /dev/null @@ -1,33 +0,0 @@ -// +build windows - -package system - -import ( - "fmt" - "path/filepath" - "strings" -) - -// CheckSystemDriveAndRemoveDriveLetter verifies and manipulates a Windows path. -// This is used, for example, when validating a user provided path in docker cp. -// If a drive letter is supplied, it must be the system drive. The drive letter -// is always removed. Also, it translates it to OS semantics (IOW / to \). We -// need the path in this syntax so that it can ultimately be concatenated with -// a Windows long-path which doesn't support drive-letters. Examples: -// C: --> Fail -// C:\ --> \ -// a --> a -// /a --> \a -// d:\ --> Fail -func CheckSystemDriveAndRemoveDriveLetter(path string) (string, error) { - if len(path) == 2 && string(path[1]) == ":" { - return "", fmt.Errorf("No relative path specified in %q", path) - } - if !filepath.IsAbs(path) || len(path) < 2 { - return filepath.FromSlash(path), nil - } - if string(path[1]) == ":" && !strings.EqualFold(string(path[0]), "c") { - return "", fmt.Errorf("The specified path is not on the system drive (C:)") - } - return filepath.FromSlash(path[2:]), nil -} diff --git a/vendor/github.com/docker/docker/pkg/system/path_windows_test.go b/vendor/github.com/docker/docker/pkg/system/path_windows_test.go index eccb26aae..0e6bcab52 100644 --- a/vendor/github.com/docker/docker/pkg/system/path_windows_test.go +++ b/vendor/github.com/docker/docker/pkg/system/path_windows_test.go @@ -2,18 +2,23 @@ package system -import "testing" +import ( + "testing" + + "github.com/containerd/continuity/pathdriver" +) // TestCheckSystemDriveAndRemoveDriveLetter tests CheckSystemDriveAndRemoveDriveLetter func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) { // Fails if not C drive. - path, err := CheckSystemDriveAndRemoveDriveLetter(`d:\`) + _, err := CheckSystemDriveAndRemoveDriveLetter(`d:\`, pathdriver.LocalPathDriver) if err == nil || (err != nil && err.Error() != "The specified path is not on the system drive (C:)") { t.Fatalf("Expected error for d:") } // Single character is unchanged - if path, err = CheckSystemDriveAndRemoveDriveLetter("z"); err != nil { + var path string + if path, err = CheckSystemDriveAndRemoveDriveLetter("z", pathdriver.LocalPathDriver); err != nil { t.Fatalf("Single character should pass") } if path != "z" { @@ -21,7 +26,7 @@ func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) { } // Two characters without colon is unchanged - if path, err = CheckSystemDriveAndRemoveDriveLetter("AB"); err != nil { + if path, err = CheckSystemDriveAndRemoveDriveLetter("AB", pathdriver.LocalPathDriver); err != nil { t.Fatalf("2 characters without colon should pass") } if path != "AB" { @@ -29,7 +34,7 @@ func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) { } // Abs path without drive letter - if path, err = CheckSystemDriveAndRemoveDriveLetter(`\l`); err != nil { + if path, err = CheckSystemDriveAndRemoveDriveLetter(`\l`, pathdriver.LocalPathDriver); err != nil { t.Fatalf("abs path no drive letter should pass") } if path != `\l` { @@ -37,7 +42,7 @@ func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) { } // Abs path without drive letter, linux style - if path, err = CheckSystemDriveAndRemoveDriveLetter(`/l`); err != nil { + if path, err = CheckSystemDriveAndRemoveDriveLetter(`/l`, pathdriver.LocalPathDriver); err != nil { t.Fatalf("abs path no drive letter linux style should pass") } if path != `\l` { @@ -45,7 +50,7 @@ func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) { } // Drive-colon should be stripped - if path, err = CheckSystemDriveAndRemoveDriveLetter(`c:\`); err != nil { + if path, err = CheckSystemDriveAndRemoveDriveLetter(`c:\`, pathdriver.LocalPathDriver); err != nil { t.Fatalf("An absolute path should pass") } if path != `\` { @@ -53,7 +58,7 @@ func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) { } // Verify with a linux-style path - if path, err = CheckSystemDriveAndRemoveDriveLetter(`c:/`); err != nil { + if path, err = CheckSystemDriveAndRemoveDriveLetter(`c:/`, pathdriver.LocalPathDriver); err != nil { t.Fatalf("An absolute path should pass") } if path != `\` { @@ -61,7 +66,7 @@ func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) { } // Failure on c: - if path, err = CheckSystemDriveAndRemoveDriveLetter(`c:`); err == nil { + if path, err = CheckSystemDriveAndRemoveDriveLetter(`c:`, pathdriver.LocalPathDriver); err == nil { t.Fatalf("c: should fail") } if err.Error() != `No relative path specified in "c:"` { @@ -69,7 +74,7 @@ func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) { } // Failure on d: - if path, err = CheckSystemDriveAndRemoveDriveLetter(`d:`); err == nil { + if path, err = CheckSystemDriveAndRemoveDriveLetter(`d:`, pathdriver.LocalPathDriver); err == nil { t.Fatalf("c: should fail") } if err.Error() != `No relative path specified in "d:"` { diff --git a/vendor/github.com/docker/docker/pkg/system/stat_linux.go b/vendor/github.com/docker/docker/pkg/system/stat_linux.go index 66bf6e28e..1939f9518 100644 --- a/vendor/github.com/docker/docker/pkg/system/stat_linux.go +++ b/vendor/github.com/docker/docker/pkg/system/stat_linux.go @@ -5,10 +5,10 @@ import "syscall" // fromStatT converts a syscall.Stat_t type to a system.Stat_t type func fromStatT(s *syscall.Stat_t) (*StatT, error) { return &StatT{size: s.Size, - mode: uint32(s.Mode), + mode: s.Mode, uid: s.Uid, gid: s.Gid, - rdev: uint64(s.Rdev), + rdev: s.Rdev, mtim: s.Mtim}, nil } diff --git a/vendor/github.com/docker/docker/pkg/system/stat_unix_test.go b/vendor/github.com/docker/docker/pkg/system/stat_unix_test.go index dee8d30a1..15c2e273b 100644 --- a/vendor/github.com/docker/docker/pkg/system/stat_unix_test.go +++ b/vendor/github.com/docker/docker/pkg/system/stat_unix_test.go @@ -6,6 +6,8 @@ import ( "os" "syscall" "testing" + + "github.com/stretchr/testify/require" ) // TestFromStatT tests fromStatT for a tempfile @@ -15,11 +17,10 @@ func TestFromStatT(t *testing.T) { stat := &syscall.Stat_t{} err := syscall.Lstat(file, stat) + require.NoError(t, err) s, err := fromStatT(stat) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) if stat.Mode != s.Mode() { t.Fatal("got invalid mode") diff --git a/vendor/github.com/docker/docker/pkg/tarsum/tarsum_test.go b/vendor/github.com/docker/docker/pkg/tarsum/tarsum_test.go index 86df0e2b8..05f00d36a 100644 --- a/vendor/github.com/docker/docker/pkg/tarsum/tarsum_test.go +++ b/vendor/github.com/docker/docker/pkg/tarsum/tarsum_test.go @@ -16,6 +16,9 @@ import ( "os" "strings" "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) type testLayer struct { @@ -222,17 +225,13 @@ func TestNewTarSumForLabel(t *testing.T) { func TestEmptyTar(t *testing.T) { // Test without gzip. ts, err := emptyTarSum(false) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) zeroBlock := make([]byte, 1024) buf := new(bytes.Buffer) n, err := io.Copy(buf, ts) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) if n != int64(len(zeroBlock)) || !bytes.Equal(buf.Bytes(), zeroBlock) { t.Fatalf("tarSum did not write the correct number of zeroed bytes: %d", n) @@ -247,19 +246,16 @@ func TestEmptyTar(t *testing.T) { // Test with gzip. ts, err = emptyTarSum(true) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) buf.Reset() - n, err = io.Copy(buf, ts) - if err != nil { - t.Fatal(err) - } + _, err = io.Copy(buf, ts) + require.NoError(t, err) bufgz := new(bytes.Buffer) gz := gzip.NewWriter(bufgz) n, err = io.Copy(gz, bytes.NewBuffer(zeroBlock)) + require.NoError(t, err) gz.Close() gzBytes := bufgz.Bytes() @@ -279,10 +275,7 @@ func TestEmptyTar(t *testing.T) { } resultSum = ts.Sum(nil) - - if resultSum != expectedSum { - t.Fatalf("expected [%s] but got [%s]", expectedSum, resultSum) - } + assert.Equal(t, expectedSum, resultSum) } var ( diff --git a/vendor/github.com/docker/docker/pkg/templates/templates_test.go b/vendor/github.com/docker/docker/pkg/templates/templates_test.go deleted file mode 100644 index 296bcb710..000000000 --- a/vendor/github.com/docker/docker/pkg/templates/templates_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package templates - -import ( - "bytes" - "testing" - - "github.com/stretchr/testify/assert" -) - -// Github #32120 -func TestParseJSONFunctions(t *testing.T) { - tm, err := Parse(`{{json .Ports}}`) - assert.NoError(t, err) - - var b bytes.Buffer - assert.NoError(t, tm.Execute(&b, map[string]string{"Ports": "0.0.0.0:2->8/udp"})) - want := "\"0.0.0.0:2->8/udp\"" - assert.Equal(t, want, b.String()) -} - -func TestParseStringFunctions(t *testing.T) { - tm, err := Parse(`{{join (split . ":") "/"}}`) - assert.NoError(t, err) - - var b bytes.Buffer - assert.NoError(t, tm.Execute(&b, "text:with:colon")) - want := "text/with/colon" - assert.Equal(t, want, b.String()) -} - -func TestNewParse(t *testing.T) { - tm, err := NewParse("foo", "this is a {{ . }}") - assert.NoError(t, err) - - var b bytes.Buffer - assert.NoError(t, tm.Execute(&b, "string")) - want := "this is a string" - assert.Equal(t, want, b.String()) -} - -func TestParseTruncateFunction(t *testing.T) { - source := "tupx5xzf6hvsrhnruz5cr8gwp" - - testCases := []struct { - template string - expected string - }{ - { - template: `{{truncate . 5}}`, - expected: "tupx5", - }, - { - template: `{{truncate . 25}}`, - expected: "tupx5xzf6hvsrhnruz5cr8gwp", - }, - { - template: `{{truncate . 30}}`, - expected: "tupx5xzf6hvsrhnruz5cr8gwp", - }, - { - template: `{{pad . 3 3}}`, - expected: " tupx5xzf6hvsrhnruz5cr8gwp ", - }, - } - - for _, testCase := range testCases { - tm, err := Parse(testCase.template) - assert.NoError(t, err) - - t.Run("Non Empty Source Test with template: "+testCase.template, func(t *testing.T) { - var b bytes.Buffer - assert.NoError(t, tm.Execute(&b, source)) - assert.Equal(t, testCase.expected, b.String()) - }) - - t.Run("Empty Source Test with template: "+testCase.template, func(t *testing.T) { - var c bytes.Buffer - assert.NoError(t, tm.Execute(&c, "")) - assert.Equal(t, "", c.String()) - }) - - t.Run("Nil Source Test with template: "+testCase.template, func(t *testing.T) { - var c bytes.Buffer - assert.Error(t, tm.Execute(&c, nil)) - assert.Equal(t, "", c.String()) - }) - } -} diff --git a/vendor/github.com/docker/docker/pkg/term/ascii.go b/vendor/github.com/docker/docker/pkg/term/ascii.go index f5262bccf..55873c055 100644 --- a/vendor/github.com/docker/docker/pkg/term/ascii.go +++ b/vendor/github.com/docker/docker/pkg/term/ascii.go @@ -59,7 +59,7 @@ next: return nil, fmt.Errorf("Unknown character: '%s'", key) } } else { - codes = append(codes, byte(key[0])) + codes = append(codes, key[0]) } } return codes, nil diff --git a/vendor/github.com/docker/docker/pkg/term/ascii_test.go b/vendor/github.com/docker/docker/pkg/term/ascii_test.go index 4a1e7f302..5078cb707 100644 --- a/vendor/github.com/docker/docker/pkg/term/ascii_test.go +++ b/vendor/github.com/docker/docker/pkg/term/ascii_test.go @@ -1,43 +1,25 @@ package term -import "testing" +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) func TestToBytes(t *testing.T) { codes, err := ToBytes("ctrl-a,a") - if err != nil { - t.Fatal(err) - } - if len(codes) != 2 { - t.Fatalf("Expected 2 codes, got %d", len(codes)) - } - if codes[0] != 1 || codes[1] != 97 { - t.Fatalf("Expected '1' '97', got '%d' '%d'", codes[0], codes[1]) - } + require.NoError(t, err) + assert.Equal(t, []byte{1, 97}, codes) - codes, err = ToBytes("shift-z") - if err == nil { - t.Fatalf("Expected error, got none") - } + _, err = ToBytes("shift-z") + assert.Error(t, err) codes, err = ToBytes("ctrl-@,ctrl-[,~,ctrl-o") - if err != nil { - t.Fatal(err) - } - if len(codes) != 4 { - t.Fatalf("Expected 4 codes, got %d", len(codes)) - } - if codes[0] != 0 || codes[1] != 27 || codes[2] != 126 || codes[3] != 15 { - t.Fatalf("Expected '0' '27' '126', '15', got '%d' '%d' '%d' '%d'", codes[0], codes[1], codes[2], codes[3]) - } + require.NoError(t, err) + assert.Equal(t, []byte{0, 27, 126, 15}, codes) codes, err = ToBytes("DEL,+") - if err != nil { - t.Fatal(err) - } - if len(codes) != 2 { - t.Fatalf("Expected 2 codes, got %d", len(codes)) - } - if codes[0] != 127 || codes[1] != 43 { - t.Fatalf("Expected '127 '43'', got '%d' '%d'", codes[0], codes[1]) - } + require.NoError(t, err) + assert.Equal(t, []byte{127, 43}, codes) } diff --git a/vendor/github.com/docker/docker/pkg/term/term_linux_test.go b/vendor/github.com/docker/docker/pkg/term/term_linux_test.go index f907ff53a..0bb6f1c95 100644 --- a/vendor/github.com/docker/docker/pkg/term/term_linux_test.go +++ b/vendor/github.com/docker/docker/pkg/term/term_linux_test.go @@ -68,6 +68,7 @@ func TestGetFdInfo(t *testing.T) { require.Equal(t, inFd, tty.Fd()) require.Equal(t, isTerminal, true) tmpFile, err := newTempFile() + require.NoError(t, err) defer tmpFile.Close() inFd, isTerminal = GetFdInfo(tmpFile) require.Equal(t, inFd, tmpFile.Fd()) @@ -81,6 +82,7 @@ func TestIsTerminal(t *testing.T) { isTerminal := IsTerminal(tty.Fd()) require.Equal(t, isTerminal, true) tmpFile, err := newTempFile() + require.NoError(t, err) defer tmpFile.Close() isTerminal = IsTerminal(tmpFile.Fd()) require.Equal(t, isTerminal, false) @@ -94,6 +96,7 @@ func TestSaveState(t *testing.T) { require.NoError(t, err) require.NotNil(t, state) tty, err = newTtyForTest(t) + require.NoError(t, err) defer tty.Close() err = RestoreTerminal(tty.Fd(), state) require.NoError(t, err) diff --git a/vendor/github.com/docker/docker/pkg/term/termios_linux.go b/vendor/github.com/docker/docker/pkg/term/termios_linux.go index 3e25eb7a4..0f21abcc2 100644 --- a/vendor/github.com/docker/docker/pkg/term/termios_linux.go +++ b/vendor/github.com/docker/docker/pkg/term/termios_linux.go @@ -29,6 +29,8 @@ func MakeRaw(fd uintptr) (*State, error) { termios.Lflag &^= (unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN) termios.Cflag &^= (unix.CSIZE | unix.PARENB) termios.Cflag |= unix.CS8 + termios.Cc[unix.VMIN] = 1 + termios.Cc[unix.VTIME] = 0 if err := unix.IoctlSetTermios(int(fd), setTermios, termios); err != nil { return nil, err diff --git a/vendor/github.com/docker/docker/pkg/term/winsize.go b/vendor/github.com/docker/docker/pkg/term/winsize.go index f58367fe6..85c4d9d67 100644 --- a/vendor/github.com/docker/docker/pkg/term/winsize.go +++ b/vendor/github.com/docker/docker/pkg/term/winsize.go @@ -3,28 +3,18 @@ package term import ( - "unsafe" - "golang.org/x/sys/unix" ) // GetWinsize returns the window size based on the specified file descriptor. func GetWinsize(fd uintptr) (*Winsize, error) { - ws := &Winsize{} - _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, uintptr(unix.TIOCGWINSZ), uintptr(unsafe.Pointer(ws))) - // Skipp errno = 0 - if err == 0 { - return ws, nil - } + uws, err := unix.IoctlGetWinsize(int(fd), unix.TIOCGWINSZ) + ws := &Winsize{Height: uws.Row, Width: uws.Col, x: uws.Xpixel, y: uws.Ypixel} return ws, err } // SetWinsize tries to set the specified window size for the specified file descriptor. func SetWinsize(fd uintptr, ws *Winsize) error { - _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, uintptr(unix.TIOCSWINSZ), uintptr(unsafe.Pointer(ws))) - // Skipp errno = 0 - if err == 0 { - return nil - } - return err + uws := &unix.Winsize{Row: ws.Height, Col: ws.Width, Xpixel: ws.x, Ypixel: ws.y} + return unix.IoctlSetWinsize(int(fd), unix.TIOCSWINSZ, uws) } diff --git a/vendor/github.com/docker/docker/pkg/testutil/cmd/command_test.go b/vendor/github.com/docker/docker/pkg/testutil/cmd/command_test.go deleted file mode 100644 index d24b42b72..000000000 --- a/vendor/github.com/docker/docker/pkg/testutil/cmd/command_test.go +++ /dev/null @@ -1,118 +0,0 @@ -package cmd - -import ( - "runtime" - "strings" - "testing" - "time" - - "github.com/stretchr/testify/assert" -) - -func TestRunCommand(t *testing.T) { - // TODO Windows: Port this test - if runtime.GOOS == "windows" { - t.Skip("Needs porting to Windows") - } - - var cmd string - if runtime.GOOS == "solaris" { - cmd = "gls" - } else { - cmd = "ls" - } - result := RunCommand(cmd) - result.Assert(t, Expected{}) - - result = RunCommand("doesnotexists") - expectedError := `exec: "doesnotexists": executable file not found` - result.Assert(t, Expected{ExitCode: 127, Error: expectedError}) - - result = RunCommand(cmd, "-z") - result.Assert(t, Expected{ - ExitCode: 2, - Error: "exit status 2", - Err: "invalid option", - }) - assert.Contains(t, result.Combined(), "invalid option") -} - -func TestRunCommandWithCombined(t *testing.T) { - // TODO Windows: Port this test - if runtime.GOOS == "windows" { - t.Skip("Needs porting to Windows") - } - - result := RunCommand("ls", "-a") - result.Assert(t, Expected{}) - - assert.Contains(t, result.Combined(), "..") - assert.Contains(t, result.Stdout(), "..") -} - -func TestRunCommandWithTimeoutFinished(t *testing.T) { - // TODO Windows: Port this test - if runtime.GOOS == "windows" { - t.Skip("Needs porting to Windows") - } - - result := RunCmd(Cmd{ - Command: []string{"ls", "-a"}, - Timeout: 50 * time.Millisecond, - }) - result.Assert(t, Expected{Out: ".."}) -} - -func TestRunCommandWithTimeoutKilled(t *testing.T) { - // TODO Windows: Port this test - if runtime.GOOS == "windows" { - t.Skip("Needs porting to Windows") - } - - command := []string{"sh", "-c", "while true ; do echo 1 ; sleep .5 ; done"} - result := RunCmd(Cmd{Command: command, Timeout: 1250 * time.Millisecond}) - result.Assert(t, Expected{Timeout: true}) - - ones := strings.Split(result.Stdout(), "\n") - assert.Len(t, ones, 4) -} - -func TestRunCommandWithErrors(t *testing.T) { - result := RunCommand("/foobar") - result.Assert(t, Expected{Error: "foobar", ExitCode: 127}) -} - -func TestRunCommandWithStdoutStderr(t *testing.T) { - result := RunCommand("echo", "hello", "world") - result.Assert(t, Expected{Out: "hello world\n", Err: None}) -} - -func TestRunCommandWithStdoutStderrError(t *testing.T) { - result := RunCommand("doesnotexists") - - expected := `exec: "doesnotexists": executable file not found` - result.Assert(t, Expected{Out: None, Err: None, ExitCode: 127, Error: expected}) - - switch runtime.GOOS { - case "windows": - expected = "ls: unknown option" - case "solaris": - expected = "gls: invalid option" - default: - expected = "ls: invalid option" - } - - var cmd string - if runtime.GOOS == "solaris" { - cmd = "gls" - } else { - cmd = "ls" - } - result = RunCommand(cmd, "-z") - result.Assert(t, Expected{ - Out: None, - Err: expected, - ExitCode: 2, - Error: "exit status 2", - }) -} diff --git a/vendor/github.com/docker/docker/pkg/testutil/golden/golden.go b/vendor/github.com/docker/docker/pkg/testutil/golden/golden.go deleted file mode 100644 index 8f725da7b..000000000 --- a/vendor/github.com/docker/docker/pkg/testutil/golden/golden.go +++ /dev/null @@ -1,28 +0,0 @@ -// Package golden provides function and helpers to use golden file for -// testing purpose. -package golden - -import ( - "flag" - "io/ioutil" - "path/filepath" - "testing" -) - -var update = flag.Bool("test.update", false, "update golden file") - -// Get returns the golden file content. If the `test.update` is specified, it updates the -// file with the current output and returns it. -func Get(t *testing.T, actual []byte, filename string) []byte { - golden := filepath.Join("testdata", filename) - if *update { - if err := ioutil.WriteFile(golden, actual, 0644); err != nil { - t.Fatal(err) - } - } - expected, err := ioutil.ReadFile(golden) - if err != nil { - t.Fatal(err) - } - return expected -} diff --git a/vendor/github.com/docker/docker/pkg/testutil/helpers.go b/vendor/github.com/docker/docker/pkg/testutil/helpers.go deleted file mode 100644 index c29114871..000000000 --- a/vendor/github.com/docker/docker/pkg/testutil/helpers.go +++ /dev/null @@ -1,33 +0,0 @@ -package testutil - -import ( - "strings" - "unicode" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -// ErrorContains checks that the error is not nil, and contains the expected -// substring. -func ErrorContains(t require.TestingT, err error, expectedError string) { - require.Error(t, err) - assert.Contains(t, err.Error(), expectedError) -} - -// EqualNormalizedString compare the actual value to the expected value after applying the specified -// transform function. It fails the test if these two transformed string are not equal. -// For example `EqualNormalizedString(t, RemoveSpace, "foo\n", "foo")` wouldn't fail the test as -// spaces (and thus '\n') are removed before comparing the string. -func EqualNormalizedString(t require.TestingT, transformFun func(rune) rune, actual, expected string) { - require.Equal(t, strings.Map(transformFun, expected), strings.Map(transformFun, actual)) -} - -// RemoveSpace returns -1 if the specified runes is considered as a space (unicode) -// and the rune itself otherwise. -func RemoveSpace(r rune) rune { - if unicode.IsSpace(r) { - return -1 - } - return r -} diff --git a/vendor/github.com/docker/docker/pkg/testutil/tempfile/tempfile.go b/vendor/github.com/docker/docker/pkg/testutil/tempfile/tempfile.go deleted file mode 100644 index 01474babf..000000000 --- a/vendor/github.com/docker/docker/pkg/testutil/tempfile/tempfile.go +++ /dev/null @@ -1,56 +0,0 @@ -package tempfile - -import ( - "io/ioutil" - "os" - - "github.com/stretchr/testify/require" -) - -// TempFile is a temporary file that can be used with unit tests. TempFile -// reduces the boilerplate setup required in each test case by handling -// setup errors. -type TempFile struct { - File *os.File -} - -// NewTempFile returns a new temp file with contents -func NewTempFile(t require.TestingT, prefix string, content string) *TempFile { - file, err := ioutil.TempFile("", prefix+"-") - require.NoError(t, err) - - _, err = file.Write([]byte(content)) - require.NoError(t, err) - file.Close() - return &TempFile{File: file} -} - -// Name returns the filename -func (f *TempFile) Name() string { - return f.File.Name() -} - -// Remove removes the file -func (f *TempFile) Remove() { - os.Remove(f.Name()) -} - -// TempDir is a temporary directory that can be used with unit tests. TempDir -// reduces the boilerplate setup required in each test case by handling -// setup errors. -type TempDir struct { - Path string -} - -// NewTempDir returns a new temp file with contents -func NewTempDir(t require.TestingT, prefix string) *TempDir { - path, err := ioutil.TempDir("", prefix+"-") - require.NoError(t, err) - - return &TempDir{Path: path} -} - -// Remove removes the file -func (f *TempDir) Remove() { - os.Remove(f.Path) -} diff --git a/vendor/github.com/docker/docker/pkg/testutil/utils.go b/vendor/github.com/docker/docker/pkg/testutil/utils.go deleted file mode 100644 index 0522dde2b..000000000 --- a/vendor/github.com/docker/docker/pkg/testutil/utils.go +++ /dev/null @@ -1,218 +0,0 @@ -package testutil - -import ( - "archive/tar" - "errors" - "fmt" - "io" - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "reflect" - "strings" - "syscall" - "time" - - "github.com/docker/docker/pkg/stringutils" - "github.com/docker/docker/pkg/system" -) - -// IsKilled process the specified error and returns whether the process was killed or not. -func IsKilled(err error) bool { - if exitErr, ok := err.(*exec.ExitError); ok { - status, ok := exitErr.Sys().(syscall.WaitStatus) - if !ok { - return false - } - // status.ExitStatus() is required on Windows because it does not - // implement Signal() nor Signaled(). Just check it had a bad exit - // status could mean it was killed (and in tests we do kill) - return (status.Signaled() && status.Signal() == os.Kill) || status.ExitStatus() != 0 - } - return false -} - -func runCommandWithOutput(cmd *exec.Cmd) (output string, exitCode int, err error) { - out, err := cmd.CombinedOutput() - exitCode = system.ProcessExitCode(err) - output = string(out) - return -} - -// RunCommandPipelineWithOutput runs the array of commands with the output -// of each pipelined with the following (like cmd1 | cmd2 | cmd3 would do). -// It returns the final output, the exitCode different from 0 and the error -// if something bad happened. -func RunCommandPipelineWithOutput(cmds ...*exec.Cmd) (output string, exitCode int, err error) { - if len(cmds) < 2 { - return "", 0, errors.New("pipeline does not have multiple cmds") - } - - // connect stdin of each cmd to stdout pipe of previous cmd - for i, cmd := range cmds { - if i > 0 { - prevCmd := cmds[i-1] - cmd.Stdin, err = prevCmd.StdoutPipe() - - if err != nil { - return "", 0, fmt.Errorf("cannot set stdout pipe for %s: %v", cmd.Path, err) - } - } - } - - // start all cmds except the last - for _, cmd := range cmds[:len(cmds)-1] { - if err = cmd.Start(); err != nil { - return "", 0, fmt.Errorf("starting %s failed with error: %v", cmd.Path, err) - } - } - - defer func() { - var pipeErrMsgs []string - // wait all cmds except the last to release their resources - for _, cmd := range cmds[:len(cmds)-1] { - if pipeErr := cmd.Wait(); pipeErr != nil { - pipeErrMsgs = append(pipeErrMsgs, fmt.Sprintf("command %s failed with error: %v", cmd.Path, pipeErr)) - } - } - if len(pipeErrMsgs) > 0 && err == nil { - err = fmt.Errorf("pipelineError from Wait: %v", strings.Join(pipeErrMsgs, ", ")) - } - }() - - // wait on last cmd - return runCommandWithOutput(cmds[len(cmds)-1]) -} - -// ConvertSliceOfStringsToMap converts a slices of string in a map -// with the strings as key and an empty string as values. -func ConvertSliceOfStringsToMap(input []string) map[string]struct{} { - output := make(map[string]struct{}) - for _, v := range input { - output[v] = struct{}{} - } - return output -} - -// CompareDirectoryEntries compares two sets of FileInfo (usually taken from a directory) -// and returns an error if different. -func CompareDirectoryEntries(e1 []os.FileInfo, e2 []os.FileInfo) error { - var ( - e1Entries = make(map[string]struct{}) - e2Entries = make(map[string]struct{}) - ) - for _, e := range e1 { - e1Entries[e.Name()] = struct{}{} - } - for _, e := range e2 { - e2Entries[e.Name()] = struct{}{} - } - if !reflect.DeepEqual(e1Entries, e2Entries) { - return fmt.Errorf("entries differ") - } - return nil -} - -// ListTar lists the entries of a tar. -func ListTar(f io.Reader) ([]string, error) { - tr := tar.NewReader(f) - var entries []string - - for { - th, err := tr.Next() - if err == io.EOF { - // end of tar archive - return entries, nil - } - if err != nil { - return entries, err - } - entries = append(entries, th.Name) - } -} - -// RandomTmpDirPath provides a temporary path with rand string appended. -// does not create or checks if it exists. -func RandomTmpDirPath(s string, platform string) string { - tmp := "/tmp" - if platform == "windows" { - tmp = os.Getenv("TEMP") - } - path := filepath.Join(tmp, fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10))) - if platform == "windows" { - return filepath.FromSlash(path) // Using \ - } - return filepath.ToSlash(path) // Using / -} - -// ConsumeWithSpeed reads chunkSize bytes from reader before sleeping -// for interval duration. Returns total read bytes. Send true to the -// stop channel to return before reading to EOF on the reader. -func ConsumeWithSpeed(reader io.Reader, chunkSize int, interval time.Duration, stop chan bool) (n int, err error) { - buffer := make([]byte, chunkSize) - for { - var readBytes int - readBytes, err = reader.Read(buffer) - n += readBytes - if err != nil { - if err == io.EOF { - err = nil - } - return - } - select { - case <-stop: - return - case <-time.After(interval): - } - } -} - -// ParseCgroupPaths parses 'procCgroupData', which is output of '/proc//cgroup', and returns -// a map which cgroup name as key and path as value. -func ParseCgroupPaths(procCgroupData string) map[string]string { - cgroupPaths := map[string]string{} - for _, line := range strings.Split(procCgroupData, "\n") { - parts := strings.Split(line, ":") - if len(parts) != 3 { - continue - } - cgroupPaths[parts[1]] = parts[2] - } - return cgroupPaths -} - -// ChannelBuffer holds a chan of byte array that can be populate in a goroutine. -type ChannelBuffer struct { - C chan []byte -} - -// Write implements Writer. -func (c *ChannelBuffer) Write(b []byte) (int, error) { - c.C <- b - return len(b), nil -} - -// Close closes the go channel. -func (c *ChannelBuffer) Close() error { - close(c.C) - return nil -} - -// ReadTimeout reads the content of the channel in the specified byte array with -// the specified duration as timeout. -func (c *ChannelBuffer) ReadTimeout(p []byte, n time.Duration) (int, error) { - select { - case b := <-c.C: - return copy(p[0:], b), nil - case <-time.After(n): - return -1, fmt.Errorf("timeout reading from channel") - } -} - -// ReadBody read the specified ReadCloser content and returns it -func ReadBody(b io.ReadCloser) ([]byte, error) { - defer b.Close() - return ioutil.ReadAll(b) -} diff --git a/vendor/github.com/docker/docker/pkg/testutil/utils_test.go b/vendor/github.com/docker/docker/pkg/testutil/utils_test.go deleted file mode 100644 index d37f3f4f8..000000000 --- a/vendor/github.com/docker/docker/pkg/testutil/utils_test.go +++ /dev/null @@ -1,341 +0,0 @@ -package testutil - -import ( - "io" - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "runtime" - "strings" - "testing" - "time" -) - -func TestIsKilledFalseWithNonKilledProcess(t *testing.T) { - var lsCmd *exec.Cmd - if runtime.GOOS != "windows" { - lsCmd = exec.Command("ls") - } else { - lsCmd = exec.Command("cmd", "/c", "dir") - } - - err := lsCmd.Run() - if IsKilled(err) { - t.Fatalf("Expected the ls command to not be killed, was.") - } -} - -func TestIsKilledTrueWithKilledProcess(t *testing.T) { - var longCmd *exec.Cmd - if runtime.GOOS != "windows" { - longCmd = exec.Command("top") - } else { - longCmd = exec.Command("powershell", "while ($true) { sleep 1 }") - } - - // Start a command - err := longCmd.Start() - if err != nil { - t.Fatal(err) - } - // Capture the error when *dying* - done := make(chan error, 1) - go func() { - done <- longCmd.Wait() - }() - // Then kill it - longCmd.Process.Kill() - // Get the error - err = <-done - if !IsKilled(err) { - t.Fatalf("Expected the command to be killed, was not.") - } -} - -func TestRunCommandPipelineWithOutputWithNotEnoughCmds(t *testing.T) { - _, _, err := RunCommandPipelineWithOutput(exec.Command("ls")) - expectedError := "pipeline does not have multiple cmds" - if err == nil || err.Error() != expectedError { - t.Fatalf("Expected an error with %s, got err:%s", expectedError, err) - } -} - -func TestRunCommandPipelineWithOutputErrors(t *testing.T) { - p := "$PATH" - if runtime.GOOS == "windows" { - p = "%PATH%" - } - cmd1 := exec.Command("ls") - cmd1.Stdout = os.Stdout - cmd2 := exec.Command("anything really") - _, _, err := RunCommandPipelineWithOutput(cmd1, cmd2) - if err == nil || err.Error() != "cannot set stdout pipe for anything really: exec: Stdout already set" { - t.Fatalf("Expected an error, got %v", err) - } - - cmdWithError := exec.Command("doesnotexists") - cmdCat := exec.Command("cat") - _, _, err = RunCommandPipelineWithOutput(cmdWithError, cmdCat) - if err == nil || err.Error() != `starting doesnotexists failed with error: exec: "doesnotexists": executable file not found in `+p { - t.Fatalf("Expected an error, got %v", err) - } -} - -func TestRunCommandPipelineWithOutput(t *testing.T) { - //TODO: Should run on Solaris - if runtime.GOOS == "solaris" { - t.Skip() - } - cmds := []*exec.Cmd{ - // Print 2 characters - exec.Command("echo", "-n", "11"), - // Count the number or char from stdin (previous command) - exec.Command("wc", "-m"), - } - out, exitCode, err := RunCommandPipelineWithOutput(cmds...) - expectedOutput := "2\n" - if out != expectedOutput || exitCode != 0 || err != nil { - t.Fatalf("Expected %s for commands %v, got out:%s, exitCode:%d, err:%v", expectedOutput, cmds, out, exitCode, err) - } -} - -func TestConvertSliceOfStringsToMap(t *testing.T) { - input := []string{"a", "b"} - actual := ConvertSliceOfStringsToMap(input) - for _, key := range input { - if _, ok := actual[key]; !ok { - t.Fatalf("Expected output to contains key %s, did not: %v", key, actual) - } - } -} - -func TestCompareDirectoryEntries(t *testing.T) { - tmpFolder, err := ioutil.TempDir("", "integration-cli-utils-compare-directories") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tmpFolder) - - file1 := filepath.Join(tmpFolder, "file1") - file2 := filepath.Join(tmpFolder, "file2") - os.Create(file1) - os.Create(file2) - - fi1, err := os.Stat(file1) - if err != nil { - t.Fatal(err) - } - fi1bis, err := os.Stat(file1) - if err != nil { - t.Fatal(err) - } - fi2, err := os.Stat(file2) - if err != nil { - t.Fatal(err) - } - - cases := []struct { - e1 []os.FileInfo - e2 []os.FileInfo - shouldError bool - }{ - // Empty directories - { - []os.FileInfo{}, - []os.FileInfo{}, - false, - }, - // Same FileInfos - { - []os.FileInfo{fi1}, - []os.FileInfo{fi1}, - false, - }, - // Different FileInfos but same names - { - []os.FileInfo{fi1}, - []os.FileInfo{fi1bis}, - false, - }, - // Different FileInfos, different names - { - []os.FileInfo{fi1}, - []os.FileInfo{fi2}, - true, - }, - } - for _, elt := range cases { - err := CompareDirectoryEntries(elt.e1, elt.e2) - if elt.shouldError && err == nil { - t.Fatalf("Should have return an error, did not with %v and %v", elt.e1, elt.e2) - } - if !elt.shouldError && err != nil { - t.Fatalf("Should have not returned an error, but did : %v with %v and %v", err, elt.e1, elt.e2) - } - } -} - -// FIXME make an "unhappy path" test for ListTar without "panicking" :-) -func TestListTar(t *testing.T) { - // TODO Windows: Figure out why this fails. Should be portable. - if runtime.GOOS == "windows" { - t.Skip("Failing on Windows - needs further investigation") - } - tmpFolder, err := ioutil.TempDir("", "integration-cli-utils-list-tar") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tmpFolder) - - // Let's create a Tar file - srcFile := filepath.Join(tmpFolder, "src") - tarFile := filepath.Join(tmpFolder, "src.tar") - os.Create(srcFile) - cmd := exec.Command("sh", "-c", "tar cf "+tarFile+" "+srcFile) - _, err = cmd.CombinedOutput() - if err != nil { - t.Fatal(err) - } - - reader, err := os.Open(tarFile) - if err != nil { - t.Fatal(err) - } - defer reader.Close() - - entries, err := ListTar(reader) - if err != nil { - t.Fatal(err) - } - if len(entries) != 1 && entries[0] != "src" { - t.Fatalf("Expected a tar file with 1 entry (%s), got %v", srcFile, entries) - } -} - -func TestRandomTmpDirPath(t *testing.T) { - path := RandomTmpDirPath("something", runtime.GOOS) - - prefix := "/tmp/something" - if runtime.GOOS == "windows" { - prefix = os.Getenv("TEMP") + `\something` - } - expectedSize := len(prefix) + 11 - - if !strings.HasPrefix(path, prefix) { - t.Fatalf("Expected generated path to have '%s' as prefix, got %s'", prefix, path) - } - if len(path) != expectedSize { - t.Fatalf("Expected generated path to be %d, got %d", expectedSize, len(path)) - } -} - -func TestConsumeWithSpeed(t *testing.T) { - reader := strings.NewReader("1234567890") - chunksize := 2 - - bytes1, err := ConsumeWithSpeed(reader, chunksize, 10*time.Millisecond, nil) - if err != nil { - t.Fatal(err) - } - - if bytes1 != 10 { - t.Fatalf("Expected to have read 10 bytes, got %d", bytes1) - } - -} - -func TestConsumeWithSpeedWithStop(t *testing.T) { - reader := strings.NewReader("1234567890") - chunksize := 2 - - stopIt := make(chan bool) - - go func() { - time.Sleep(1 * time.Millisecond) - stopIt <- true - }() - - bytes1, err := ConsumeWithSpeed(reader, chunksize, 20*time.Millisecond, stopIt) - if err != nil { - t.Fatal(err) - } - - if bytes1 != 2 { - t.Fatalf("Expected to have read 2 bytes, got %d", bytes1) - } - -} - -func TestParseCgroupPathsEmpty(t *testing.T) { - cgroupMap := ParseCgroupPaths("") - if len(cgroupMap) != 0 { - t.Fatalf("Expected an empty map, got %v", cgroupMap) - } - cgroupMap = ParseCgroupPaths("\n") - if len(cgroupMap) != 0 { - t.Fatalf("Expected an empty map, got %v", cgroupMap) - } - cgroupMap = ParseCgroupPaths("something:else\nagain:here") - if len(cgroupMap) != 0 { - t.Fatalf("Expected an empty map, got %v", cgroupMap) - } -} - -func TestParseCgroupPaths(t *testing.T) { - cgroupMap := ParseCgroupPaths("2:memory:/a\n1:cpuset:/b") - if len(cgroupMap) != 2 { - t.Fatalf("Expected a map with 2 entries, got %v", cgroupMap) - } - if value, ok := cgroupMap["memory"]; !ok || value != "/a" { - t.Fatalf("Expected cgroupMap to contains an entry for 'memory' with value '/a', got %v", cgroupMap) - } - if value, ok := cgroupMap["cpuset"]; !ok || value != "/b" { - t.Fatalf("Expected cgroupMap to contains an entry for 'cpuset' with value '/b', got %v", cgroupMap) - } -} - -func TestChannelBufferTimeout(t *testing.T) { - expected := "11" - - buf := &ChannelBuffer{make(chan []byte, 1)} - defer buf.Close() - - done := make(chan struct{}, 1) - go func() { - time.Sleep(100 * time.Millisecond) - io.Copy(buf, strings.NewReader(expected)) - done <- struct{}{} - }() - - // Wait long enough - b := make([]byte, 2) - _, err := buf.ReadTimeout(b, 50*time.Millisecond) - if err == nil && err.Error() != "timeout reading from channel" { - t.Fatalf("Expected an error, got %s", err) - } - <-done -} - -func TestChannelBuffer(t *testing.T) { - expected := "11" - - buf := &ChannelBuffer{make(chan []byte, 1)} - defer buf.Close() - - go func() { - time.Sleep(100 * time.Millisecond) - io.Copy(buf, strings.NewReader(expected)) - }() - - // Wait long enough - b := make([]byte, 2) - _, err := buf.ReadTimeout(b, 200*time.Millisecond) - if err != nil { - t.Fatal(err) - } - - if string(b) != expected { - t.Fatalf("Expected '%s', got '%s'", expected, string(b)) - } -} diff --git a/vendor/github.com/docker/docker/pkg/tlsconfig/tlsconfig_clone.go b/vendor/github.com/docker/docker/pkg/tlsconfig/tlsconfig_clone.go deleted file mode 100644 index e4dec3a5d..000000000 --- a/vendor/github.com/docker/docker/pkg/tlsconfig/tlsconfig_clone.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build go1.8 - -package tlsconfig - -import "crypto/tls" - -// Clone returns a clone of tls.Config. This function is provided for -// compatibility for go1.7 that doesn't include this method in stdlib. -func Clone(c *tls.Config) *tls.Config { - return c.Clone() -} diff --git a/vendor/github.com/docker/docker/plugin/backend_linux.go b/vendor/github.com/docker/docker/plugin/backend_linux.go index 727a26862..8a31e97e5 100644 --- a/vendor/github.com/docker/docker/plugin/backend_linux.go +++ b/vendor/github.com/docker/docker/plugin/backend_linux.go @@ -6,7 +6,6 @@ import ( "archive/tar" "compress/gzip" "encoding/json" - "fmt" "io" "io/ioutil" "net/http" @@ -33,7 +32,7 @@ import ( "github.com/docker/docker/pkg/system" "github.com/docker/docker/plugin/v2" refstore "github.com/docker/docker/reference" - "github.com/opencontainers/go-digest" + digest "github.com/opencontainers/go-digest" "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/net/context" @@ -55,7 +54,7 @@ func (pm *Manager) Disable(refOrID string, config *types.PluginDisableConfig) er pm.mu.RUnlock() if !config.ForceDisable && p.GetRefCount() > 0 { - return fmt.Errorf("plugin %s is in use", p.Name()) + return errors.WithStack(inUseError(p.Name())) } for _, typ := range p.GetTypes() { @@ -142,7 +141,7 @@ func (s *tempConfigStore) Put(c []byte) (digest.Digest, error) { func (s *tempConfigStore) Get(d digest.Digest) ([]byte, error) { if d != s.configDigest { - return nil, fmt.Errorf("digest not found") + return nil, errNotFound("digest not found") } return s.config, nil } @@ -151,7 +150,7 @@ func (s *tempConfigStore) RootFSAndPlatformFromConfig(c []byte) (*image.RootFS, return configToRootFS(c) } -func computePrivileges(c types.PluginConfig) (types.PluginPrivileges, error) { +func computePrivileges(c types.PluginConfig) types.PluginPrivileges { var privileges types.PluginPrivileges if c.Network.Type != "null" && c.Network.Type != "bridge" && c.Network.Type != "" { privileges = append(privileges, types.PluginPrivilege{ @@ -207,7 +206,7 @@ func computePrivileges(c types.PluginConfig) (types.PluginPrivileges, error) { }) } - return privileges, nil + return privileges } // Privileges pulls a plugin config and computes the privileges required to install it. @@ -236,21 +235,21 @@ func (pm *Manager) Privileges(ctx context.Context, ref reference.Named, metaHead } var config types.PluginConfig if err := json.Unmarshal(cs.config, &config); err != nil { - return nil, err + return nil, systemError{err} } - return computePrivileges(config) + return computePrivileges(config), nil } // Upgrade upgrades a plugin func (pm *Manager) Upgrade(ctx context.Context, ref reference.Named, name string, metaHeader http.Header, authConfig *types.AuthConfig, privileges types.PluginPrivileges, outStream io.Writer) (err error) { p, err := pm.config.Store.GetV2Plugin(name) if err != nil { - return errors.Wrap(err, "plugin must be installed before upgrading") + return err } if p.IsEnabled() { - return fmt.Errorf("plugin must be disabled before upgrading") + return errors.Wrap(enabledError(p.Name()), "plugin must be disabled before upgrading") } pm.muGC.RLock() @@ -258,12 +257,12 @@ func (pm *Manager) Upgrade(ctx context.Context, ref reference.Named, name string // revalidate because Pull is public if _, err := reference.ParseNormalizedNamed(name); err != nil { - return errors.Wrapf(err, "failed to parse %q", name) + return errors.Wrapf(validationError{err}, "failed to parse %q", name) } tmpRootFSDir, err := ioutil.TempDir(pm.tmpDir(), ".rootfs") if err != nil { - return err + return errors.Wrap(systemError{err}, "error preparing upgrade") } defer os.RemoveAll(tmpRootFSDir) @@ -305,17 +304,17 @@ func (pm *Manager) Pull(ctx context.Context, ref reference.Named, name string, m // revalidate because Pull is public nameref, err := reference.ParseNormalizedNamed(name) if err != nil { - return errors.Wrapf(err, "failed to parse %q", name) + return errors.Wrapf(validationError{err}, "failed to parse %q", name) } name = reference.FamiliarString(reference.TagNameOnly(nameref)) if err := pm.config.Store.validateName(name); err != nil { - return err + return validationError{err} } tmpRootFSDir, err := ioutil.TempDir(pm.tmpDir(), ".rootfs") if err != nil { - return err + return errors.Wrap(systemError{err}, "error preparing pull") } defer os.RemoveAll(tmpRootFSDir) @@ -372,7 +371,7 @@ func (pm *Manager) List(pluginFilters filters.Args) ([]types.Plugin, error) { } else if pluginFilters.ExactMatch("enabled", "false") { disabledOnly = true } else { - return nil, fmt.Errorf("Invalid filter 'enabled=%s'", pluginFilters.Get("enabled")) + return nil, invalidFilter{"enabled", pluginFilters.Get("enabled")} } } @@ -615,10 +614,10 @@ func (pm *Manager) Remove(name string, config *types.PluginRmConfig) error { if !config.ForceRemove { if p.GetRefCount() > 0 { - return fmt.Errorf("plugin %s is in use", p.Name()) + return inUseError(p.Name()) } if p.IsEnabled() { - return fmt.Errorf("plugin %s is enabled", p.Name()) + return enabledError(p.Name()) } } @@ -653,22 +652,6 @@ func (pm *Manager) Remove(name string, config *types.PluginRmConfig) error { return nil } -func getMounts(root string) ([]string, error) { - infos, err := mount.GetMounts() - if err != nil { - return nil, errors.Wrap(err, "failed to read mount table") - } - - var mounts []string - for _, m := range infos { - if strings.HasPrefix(m.Mountpoint, root) { - mounts = append(mounts, m.Mountpoint) - } - } - - return mounts, nil -} - // Set sets plugin args func (pm *Manager) Set(name string, args []string) error { p, err := pm.config.Store.GetV2Plugin(name) diff --git a/vendor/github.com/docker/docker/plugin/errors.go b/vendor/github.com/docker/docker/plugin/errors.go new file mode 100644 index 000000000..0a101d4dc --- /dev/null +++ b/vendor/github.com/docker/docker/plugin/errors.go @@ -0,0 +1,94 @@ +package plugin + +import "fmt" + +type errNotFound string + +func (name errNotFound) Error() string { + return fmt.Sprintf("plugin %q not found", string(name)) +} + +func (errNotFound) NotFound() {} + +type errAmbiguous string + +func (name errAmbiguous) Error() string { + return fmt.Sprintf("multiple plugins found for %q", string(name)) +} + +func (name errAmbiguous) InvalidParameter() {} + +type errDisabled string + +func (name errDisabled) Error() string { + return fmt.Sprintf("plugin %s found but disabled", string(name)) +} + +func (name errDisabled) Conflict() {} + +type validationError struct { + cause error +} + +func (e validationError) Error() string { + return e.cause.Error() +} + +func (validationError) Conflict() {} + +func (e validationError) Cause() error { + return e.cause +} + +type systemError struct { + cause error +} + +func (e systemError) Error() string { + return e.cause.Error() +} + +func (systemError) SystemError() {} + +func (e systemError) Cause() error { + return e.cause +} + +type invalidFilter struct { + filter string + value []string +} + +func (e invalidFilter) Error() string { + msg := "Invalid filter '" + e.filter + if len(e.value) > 0 { + msg += fmt.Sprintf("=%s", e.value) + } + return msg + "'" +} + +func (invalidFilter) InvalidParameter() {} + +type inUseError string + +func (e inUseError) Error() string { + return "plugin " + string(e) + " is in use" +} + +func (inUseError) Conflict() {} + +type enabledError string + +func (e enabledError) Error() string { + return "plugin " + string(e) + " is enabled" +} + +func (enabledError) Conflict() {} + +type alreadyExistsError string + +func (e alreadyExistsError) Error() string { + return "plugin " + string(e) + " already exists" +} + +func (alreadyExistsError) Conflict() {} diff --git a/vendor/github.com/docker/docker/plugin/executor/containerd/containerd.go b/vendor/github.com/docker/docker/plugin/executor/containerd/containerd.go new file mode 100644 index 000000000..74cf530cf --- /dev/null +++ b/vendor/github.com/docker/docker/plugin/executor/containerd/containerd.go @@ -0,0 +1,77 @@ +package containerd + +import ( + "io" + + "github.com/docker/docker/libcontainerd" + "github.com/opencontainers/runtime-spec/specs-go" + "github.com/pkg/errors" +) + +// ExitHandler represents an object that is called when the exit event is received from containerd +type ExitHandler interface { + HandleExitEvent(id string) error +} + +// New creates a new containerd plugin executor +func New(remote libcontainerd.Remote, exitHandler ExitHandler) (*Executor, error) { + e := &Executor{exitHandler: exitHandler} + client, err := remote.Client(e) + if err != nil { + return nil, errors.Wrap(err, "error creating containerd exec client") + } + e.client = client + return e, nil +} + +// Executor is the containerd client implementation of a plugin executor +type Executor struct { + client libcontainerd.Client + exitHandler ExitHandler +} + +// Create creates a new container +func (e *Executor) Create(id string, spec specs.Spec, stdout, stderr io.WriteCloser) error { + return e.client.Create(id, "", "", spec, attachStreamsFunc(stdout, stderr)) +} + +// Restore restores a container +func (e *Executor) Restore(id string, stdout, stderr io.WriteCloser) error { + return e.client.Restore(id, attachStreamsFunc(stdout, stderr)) +} + +// IsRunning returns if the container with the given id is running +func (e *Executor) IsRunning(id string) (bool, error) { + pids, err := e.client.GetPidsForContainer(id) + return len(pids) > 0, err +} + +// Signal sends the specified signal to the container +func (e *Executor) Signal(id string, signal int) error { + return e.client.Signal(id, signal) +} + +// StateChanged handles state changes from containerd +// All events are ignored except the exit event, which is sent of to the stored handler +func (e *Executor) StateChanged(id string, event libcontainerd.StateInfo) error { + switch event.State { + case libcontainerd.StateExit: + return e.exitHandler.HandleExitEvent(id) + } + return nil +} + +func attachStreamsFunc(stdout, stderr io.WriteCloser) func(libcontainerd.IOPipe) error { + return func(iop libcontainerd.IOPipe) error { + iop.Stdin.Close() + go func() { + io.Copy(stdout, iop.Stdout) + stdout.Close() + }() + go func() { + io.Copy(stderr, iop.Stderr) + stderr.Close() + }() + return nil + } +} diff --git a/vendor/github.com/docker/docker/plugin/manager.go b/vendor/github.com/docker/docker/plugin/manager.go index 2281dfdd6..0c03192d7 100644 --- a/vendor/github.com/docker/docker/plugin/manager.go +++ b/vendor/github.com/docker/docker/plugin/manager.go @@ -17,7 +17,6 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/image" "github.com/docker/docker/layer" - "github.com/docker/docker/libcontainerd" "github.com/docker/docker/pkg/authorization" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/mount" @@ -26,6 +25,7 @@ import ( "github.com/docker/docker/plugin/v2" "github.com/docker/docker/registry" "github.com/opencontainers/go-digest" + specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -35,6 +35,14 @@ const rootFSFileName = "rootfs" var validFullID = regexp.MustCompile(`^([a-f0-9]{64})$`) +// Executor is the interface that the plugin manager uses to interact with for starting/stopping plugins +type Executor interface { + Create(id string, spec specs.Spec, stdout, stderr io.WriteCloser) error + Restore(id string, stdout, stderr io.WriteCloser) error + IsRunning(id string) (bool, error) + Signal(id string, signal int) error +} + func (pm *Manager) restorePlugin(p *v2.Plugin) error { if p.IsEnabled() { return pm.restore(p) @@ -47,24 +55,27 @@ type eventLogger func(id, name, action string) // ManagerConfig defines configuration needed to start new manager. type ManagerConfig struct { Store *Store // remove - Executor libcontainerd.Remote RegistryService registry.Service LiveRestoreEnabled bool // TODO: remove LogPluginEvent eventLogger Root string ExecRoot string + CreateExecutor ExecutorCreator AuthzMiddleware *authorization.Middleware } +// ExecutorCreator is used in the manager config to pass in an `Executor` +type ExecutorCreator func(*Manager) (Executor, error) + // Manager controls the plugin subsystem. type Manager struct { - config ManagerConfig - mu sync.RWMutex // protects cMap - muGC sync.RWMutex // protects blobstore deletions - cMap map[*v2.Plugin]*controller - containerdClient libcontainerd.Client - blobStore *basicBlobStore - publisher *pubsub.Publisher + config ManagerConfig + mu sync.RWMutex // protects cMap + muGC sync.RWMutex // protects blobstore deletions + cMap map[*v2.Plugin]*controller + blobStore *basicBlobStore + publisher *pubsub.Publisher + executor Executor } // controller represents the manager's control on a plugin. @@ -111,10 +122,11 @@ func NewManager(config ManagerConfig) (*Manager, error) { } var err error - manager.containerdClient, err = config.Executor.Client(manager) // todo: move to another struct + manager.executor, err = config.CreateExecutor(manager) if err != nil { - return nil, errors.Wrap(err, "failed to create containerd client") + return nil, err } + manager.blobStore, err = newBasicBlobStore(filepath.Join(manager.config.Root, "storage/blobs")) if err != nil { return nil, err @@ -133,42 +145,37 @@ func (pm *Manager) tmpDir() string { return filepath.Join(pm.config.Root, "tmp") } -// StateChanged updates plugin internals using libcontainerd events. -func (pm *Manager) StateChanged(id string, e libcontainerd.StateInfo) error { - logrus.Debugf("plugin state changed %s %#v", id, e) - - switch e.State { - case libcontainerd.StateExit: - p, err := pm.config.Store.GetV2Plugin(id) - if err != nil { - return err - } +// HandleExitEvent is called when the executor receives the exit event +// In the future we may change this, but for now all we care about is the exit event. +func (pm *Manager) HandleExitEvent(id string) error { + p, err := pm.config.Store.GetV2Plugin(id) + if err != nil { + return err + } - os.RemoveAll(filepath.Join(pm.config.ExecRoot, id)) + os.RemoveAll(filepath.Join(pm.config.ExecRoot, id)) - if p.PropagatedMount != "" { - if err := mount.Unmount(p.PropagatedMount); err != nil { - logrus.Warnf("Could not unmount %s: %v", p.PropagatedMount, err) - } - propRoot := filepath.Join(filepath.Dir(p.Rootfs), "propagated-mount") - if err := mount.Unmount(propRoot); err != nil { - logrus.Warn("Could not unmount %s: %v", propRoot, err) - } + if p.PropagatedMount != "" { + if err := mount.Unmount(p.PropagatedMount); err != nil { + logrus.Warnf("Could not unmount %s: %v", p.PropagatedMount, err) } - - pm.mu.RLock() - c := pm.cMap[p] - if c.exitChan != nil { - close(c.exitChan) + propRoot := filepath.Join(filepath.Dir(p.Rootfs), "propagated-mount") + if err := mount.Unmount(propRoot); err != nil { + logrus.Warn("Could not unmount %s: %v", propRoot, err) } - restart := c.restart - pm.mu.RUnlock() + } - if restart { - pm.enable(p, c, true) - } + pm.mu.RLock() + c := pm.cMap[p] + if c.exitChan != nil { + close(c.exitChan) } + restart := c.restart + pm.mu.RUnlock() + if restart { + pm.enable(p, c, true) + } return nil } @@ -333,23 +340,10 @@ func (l logHook) Fire(entry *logrus.Entry) error { return nil } -func attachToLog(id string) func(libcontainerd.IOPipe) error { - return func(iop libcontainerd.IOPipe) error { - iop.Stdin.Close() - - logger := logrus.New() - logger.Hooks.Add(logHook{id}) - // TODO: cache writer per id - w := logger.Writer() - go func() { - io.Copy(w, iop.Stdout) - }() - go func() { - // TODO: update logrus and use logger.WriterLevel - io.Copy(w, iop.Stderr) - }() - return nil - } +func makeLoggerStreams(id string) (stdout, stderr io.WriteCloser) { + logger := logrus.New() + logger.Hooks.Add(logHook{id}) + return logger.WriterLevel(logrus.InfoLevel), logger.WriterLevel(logrus.ErrorLevel) } func validatePrivileges(requiredPrivileges, privileges types.PluginPrivileges) error { diff --git a/vendor/github.com/docker/docker/plugin/manager_linux.go b/vendor/github.com/docker/docker/plugin/manager_linux.go index 301b12c81..beefc3dfb 100644 --- a/vendor/github.com/docker/docker/plugin/manager_linux.go +++ b/vendor/github.com/docker/docker/plugin/manager_linux.go @@ -4,7 +4,6 @@ package plugin import ( "encoding/json" - "fmt" "net" "os" "path/filepath" @@ -12,14 +11,13 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/daemon/initlayer" - "github.com/docker/docker/libcontainerd" + "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/plugins" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/plugin/v2" "github.com/opencontainers/go-digest" - specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/sys/unix" @@ -28,7 +26,7 @@ import ( func (pm *Manager) enable(p *v2.Plugin, c *controller, force bool) error { p.Rootfs = filepath.Join(pm.config.Root, p.PluginObj.ID, "rootfs") if p.IsEnabled() && !force { - return fmt.Errorf("plugin %s is already enabled", p.Name()) + return errors.Wrap(enabledError(p.Name()), "plugin already enabled") } spec, err := p.InitSpec(pm.config.ExecRoot) if err != nil { @@ -59,11 +57,13 @@ func (pm *Manager) enable(p *v2.Plugin, c *controller, force bool) error { } } - if err := initlayer.Setup(filepath.Join(pm.config.Root, p.PluginObj.ID, rootFSFileName), idtools.IDPair{0, 0}); err != nil { + rootFS := containerfs.NewLocalContainerFS(filepath.Join(pm.config.Root, p.PluginObj.ID, rootFSFileName)) + if err := initlayer.Setup(rootFS, idtools.IDPair{0, 0}); err != nil { return errors.WithStack(err) } - if err := pm.containerdClient.Create(p.GetID(), "", "", specs.Spec(*spec), attachToLog(p.GetID())); err != nil { + stdout, stderr := makeLoggerStreams(p.GetID()) + if err := pm.executor.Create(p.GetID(), *spec, stdout, stderr); err != nil { if p.PropagatedMount != "" { if err := mount.Unmount(p.PropagatedMount); err != nil { logrus.Warnf("Could not unmount %s: %v", p.PropagatedMount, err) @@ -83,7 +83,7 @@ func (pm *Manager) pluginPostStart(p *v2.Plugin, c *controller) error { client, err := plugins.NewClientWithTimeout("unix://"+sockAddr, nil, time.Duration(c.timeoutInSecs)*time.Second) if err != nil { c.restart = false - shutdownPlugin(p, c, pm.containerdClient) + shutdownPlugin(p, c, pm.executor) return errors.WithStack(err) } @@ -109,7 +109,7 @@ func (pm *Manager) pluginPostStart(p *v2.Plugin, c *controller) error { c.restart = false // While restoring plugins, we need to explicitly set the state to disabled pm.config.Store.SetState(p, false) - shutdownPlugin(p, c, pm.containerdClient) + shutdownPlugin(p, c, pm.executor) return err } @@ -121,13 +121,14 @@ func (pm *Manager) pluginPostStart(p *v2.Plugin, c *controller) error { } func (pm *Manager) restore(p *v2.Plugin) error { - if err := pm.containerdClient.Restore(p.GetID(), attachToLog(p.GetID())); err != nil { + stdout, stderr := makeLoggerStreams(p.GetID()) + if err := pm.executor.Restore(p.GetID(), stdout, stderr); err != nil { return err } if pm.config.LiveRestoreEnabled { c := &controller{} - if pids, _ := pm.containerdClient.GetPidsForContainer(p.GetID()); len(pids) == 0 { + if isRunning, _ := pm.executor.IsRunning(p.GetID()); !isRunning { // plugin is not running, so follow normal startup procedure return pm.enable(p, c, true) } @@ -143,10 +144,10 @@ func (pm *Manager) restore(p *v2.Plugin) error { return nil } -func shutdownPlugin(p *v2.Plugin, c *controller, containerdClient libcontainerd.Client) { +func shutdownPlugin(p *v2.Plugin, c *controller, executor Executor) { pluginID := p.GetID() - err := containerdClient.Signal(pluginID, int(unix.SIGTERM)) + err := executor.Signal(pluginID, int(unix.SIGTERM)) if err != nil { logrus.Errorf("Sending SIGTERM to plugin failed with error: %v", err) } else { @@ -155,7 +156,7 @@ func shutdownPlugin(p *v2.Plugin, c *controller, containerdClient libcontainerd. logrus.Debug("Clean shutdown of plugin") case <-time.After(time.Second * 10): logrus.Debug("Force shutdown plugin") - if err := containerdClient.Signal(pluginID, int(unix.SIGKILL)); err != nil { + if err := executor.Signal(pluginID, int(unix.SIGKILL)); err != nil { logrus.Errorf("Sending SIGKILL to plugin failed with error: %v", err) } } @@ -171,11 +172,11 @@ func setupRoot(root string) error { func (pm *Manager) disable(p *v2.Plugin, c *controller) error { if !p.IsEnabled() { - return fmt.Errorf("plugin %s is already disabled", p.Name()) + return errors.Wrap(errDisabled(p.Name()), "plugin is already disabled") } c.restart = false - shutdownPlugin(p, c, pm.containerdClient) + shutdownPlugin(p, c, pm.executor) pm.config.Store.SetState(p, false) return pm.save(p) } @@ -192,9 +193,9 @@ func (pm *Manager) Shutdown() { logrus.Debug("Plugin active when liveRestore is set, skipping shutdown") continue } - if pm.containerdClient != nil && p.IsEnabled() { + if pm.executor != nil && p.IsEnabled() { c.restart = false - shutdownPlugin(p, c, pm.containerdClient) + shutdownPlugin(p, c, pm.executor) } } mount.Unmount(pm.config.Root) @@ -213,12 +214,12 @@ func (pm *Manager) upgradePlugin(p *v2.Plugin, configDigest digest.Digest, blobs // This could happen if the plugin was disabled with `-f` with active mounts. // If there is anything in `orig` is still mounted, this should error out. if err := mount.RecursiveUnmount(orig); err != nil { - return err + return systemError{err} } backup := orig + "-old" if err := os.Rename(orig, backup); err != nil { - return errors.Wrap(err, "error backing up plugin data before upgrade") + return errors.Wrap(systemError{err}, "error backing up plugin data before upgrade") } defer func() { @@ -244,7 +245,7 @@ func (pm *Manager) upgradePlugin(p *v2.Plugin, configDigest digest.Digest, blobs }() if err := os.Rename(tmpRootFSDir, orig); err != nil { - return errors.Wrap(err, "error upgrading") + return errors.Wrap(systemError{err}, "error upgrading") } p.PluginObj.Config = config @@ -268,7 +269,7 @@ func (pm *Manager) setupNewPlugin(configDigest digest.Digest, blobsums []digest. return types.PluginConfig{}, errors.New("invalid config json") } - requiredPrivileges, err := computePrivileges(config) + requiredPrivileges := computePrivileges(config) if err != nil { return types.PluginConfig{}, err } @@ -284,7 +285,7 @@ func (pm *Manager) setupNewPlugin(configDigest digest.Digest, blobsums []digest. // createPlugin creates a new plugin. take lock before calling. func (pm *Manager) createPlugin(name string, configDigest digest.Digest, blobsums []digest.Digest, rootFSDir string, privileges *types.PluginPrivileges, opts ...CreateOpt) (p *v2.Plugin, err error) { if err := pm.config.Store.validateName(name); err != nil { // todo: this check is wrong. remove store - return nil, err + return nil, validationError{err} } config, err := pm.setupNewPlugin(configDigest, blobsums, privileges) diff --git a/vendor/github.com/docker/docker/plugin/store.go b/vendor/github.com/docker/docker/plugin/store.go index acb92d2e5..adc0e2650 100644 --- a/vendor/github.com/docker/docker/plugin/store.go +++ b/vendor/github.com/docker/docker/plugin/store.go @@ -24,25 +24,6 @@ const allowV1PluginsFallback bool = true */ const defaultAPIVersion string = "1.0" -// ErrNotFound indicates that a plugin was not found locally. -type ErrNotFound string - -func (name ErrNotFound) Error() string { return fmt.Sprintf("plugin %q not found", string(name)) } - -// ErrAmbiguous indicates that more than one plugin was found -type ErrAmbiguous string - -func (name ErrAmbiguous) Error() string { - return fmt.Sprintf("multiple plugins found for %q", string(name)) -} - -// ErrDisabled indicates that a plugin was found but it is disabled -type ErrDisabled string - -func (name ErrDisabled) Error() string { - return fmt.Sprintf("plugin %s found but disabled", string(name)) -} - // GetV2Plugin retrieves a plugin by name, id or partial ID. func (ps *Store) GetV2Plugin(refOrID string) (*v2.Plugin, error) { ps.RLock() @@ -55,7 +36,7 @@ func (ps *Store) GetV2Plugin(refOrID string) (*v2.Plugin, error) { p, idOk := ps.plugins[id] if !idOk { - return nil, errors.WithStack(ErrNotFound(id)) + return nil, errors.WithStack(errNotFound(id)) } return p, nil @@ -65,7 +46,7 @@ func (ps *Store) GetV2Plugin(refOrID string) (*v2.Plugin, error) { func (ps *Store) validateName(name string) error { for _, p := range ps.plugins { if p.Name() == name { - return errors.Errorf("plugin %q already exists", name) + return alreadyExistsError(name) } } return nil @@ -145,9 +126,9 @@ func (ps *Store) Get(name, capability string, mode int) (plugingetter.CompatPlug } // Plugin was found but it is disabled, so we should not fall back to legacy plugins // but we should error out right away - return nil, ErrDisabled(name) + return nil, errDisabled(name) } - if _, ok := errors.Cause(err).(ErrNotFound); !ok { + if _, ok := errors.Cause(err).(errNotFound); !ok { return nil, err } } @@ -156,7 +137,10 @@ func (ps *Store) Get(name, capability string, mode int) (plugingetter.CompatPlug if allowV1PluginsFallback { p, err := plugins.Get(name, capability) if err != nil { - return nil, fmt.Errorf("legacy plugin: %v", err) + if errors.Cause(err) == plugins.ErrNotFound { + return nil, errNotFound(name) + } + return nil, errors.Wrap(systemError{err}, "legacy plugin") } return p, nil } @@ -189,7 +173,7 @@ func (ps *Store) GetAllByCap(capability string) ([]plugingetter.CompatPlugin, er if allowV1PluginsFallback { pl, err := plugins.GetAll(capability) if err != nil { - return nil, fmt.Errorf("legacy plugin: %v", err) + return nil, errors.Wrap(systemError{err}, "legacy plugin") } for _, p := range pl { result = append(result, p) @@ -239,11 +223,11 @@ func (ps *Store) resolvePluginID(idOrName string) (string, error) { ref, err := reference.ParseNormalizedNamed(idOrName) if err != nil { - return "", errors.WithStack(ErrNotFound(idOrName)) + return "", errors.WithStack(errNotFound(idOrName)) } if _, ok := ref.(reference.Canonical); ok { logrus.Warnf("canonical references cannot be resolved: %v", reference.FamiliarString(ref)) - return "", errors.WithStack(ErrNotFound(idOrName)) + return "", errors.WithStack(errNotFound(idOrName)) } ref = reference.TagNameOnly(ref) @@ -258,13 +242,13 @@ func (ps *Store) resolvePluginID(idOrName string) (string, error) { for id, p := range ps.plugins { // this can be optimized if strings.HasPrefix(id, idOrName) { if found != nil { - return "", errors.WithStack(ErrAmbiguous(idOrName)) + return "", errors.WithStack(errAmbiguous(idOrName)) } found = p } } if found == nil { - return "", errors.WithStack(ErrNotFound(idOrName)) + return "", errors.WithStack(errNotFound(idOrName)) } return found.PluginObj.ID, nil } diff --git a/vendor/github.com/docker/docker/plugin/v2/plugin_linux.go b/vendor/github.com/docker/docker/plugin/v2/plugin_linux.go index 9cae180e3..be8236324 100644 --- a/vendor/github.com/docker/docker/plugin/v2/plugin_linux.go +++ b/vendor/github.com/docker/docker/plugin/v2/plugin_linux.go @@ -18,7 +18,7 @@ import ( // InitSpec creates an OCI spec from the plugin's config. func (p *Plugin) InitSpec(execRoot string) (*specs.Spec, error) { s := oci.DefaultSpec() - s.Root = specs.Root{ + s.Root = &specs.Root{ Path: p.Rootfs, Readonly: false, // TODO: all plugins should be readonly? settable in config? } diff --git a/vendor/github.com/docker/docker/profiles/apparmor/apparmor.go b/vendor/github.com/docker/docker/profiles/apparmor/apparmor.go index 48b41c5b2..e957727d5 100644 --- a/vendor/github.com/docker/docker/profiles/apparmor/apparmor.go +++ b/vendor/github.com/docker/docker/profiles/apparmor/apparmor.go @@ -9,9 +9,9 @@ import ( "os" "path" "strings" + "text/template" "github.com/docker/docker/pkg/aaparser" - "github.com/docker/docker/pkg/templates" ) var ( @@ -33,7 +33,7 @@ type profileData struct { // generateDefault creates an apparmor profile from ProfileData. func (p *profileData) generateDefault(out io.Writer) error { - compiled, err := templates.NewParse("apparmor_profile", baseTemplate) + compiled, err := template.New("apparmor_profile").Parse(baseTemplate) if err != nil { return err } diff --git a/vendor/github.com/docker/docker/profiles/seccomp/default.json b/vendor/github.com/docker/docker/profiles/seccomp/default.json index b71a8718a..38467c7be 100755 --- a/vendor/github.com/docker/docker/profiles/seccomp/default.json +++ b/vendor/github.com/docker/docker/profiles/seccomp/default.json @@ -57,7 +57,6 @@ "access", "adjtimex", "alarm", - "alarm", "bind", "brk", "capget", @@ -557,6 +556,7 @@ "mount", "name_to_handle_at", "perf_event_open", + "quotactl", "setdomainname", "sethostname", "setns", diff --git a/vendor/github.com/docker/docker/profiles/seccomp/seccomp_default.go b/vendor/github.com/docker/docker/profiles/seccomp/seccomp_default.go index 1e6ea90e3..1b5179c70 100644 --- a/vendor/github.com/docker/docker/profiles/seccomp/seccomp_default.go +++ b/vendor/github.com/docker/docker/profiles/seccomp/seccomp_default.go @@ -50,7 +50,6 @@ func DefaultProfile() *types.Seccomp { "access", "adjtimex", "alarm", - "alarm", "bind", "brk", "capget", @@ -488,6 +487,7 @@ func DefaultProfile() *types.Seccomp { "mount", "name_to_handle_at", "perf_event_open", + "quotactl", "setdomainname", "sethostname", "setns", diff --git a/vendor/github.com/docker/docker/project/ARM.md b/vendor/github.com/docker/docker/project/ARM.md index e61e3b184..c876231d1 100644 --- a/vendor/github.com/docker/docker/project/ARM.md +++ b/vendor/github.com/docker/docker/project/ARM.md @@ -17,7 +17,7 @@ From the root of the Docker/Docker repo one can use make to execute the followin - make default - make shell - make test-unit -- make test-integration-cli +- make test-integration - make The Makefile does include logic to determine on which OS and architecture the Docker Development Image is built. diff --git a/vendor/github.com/docker/docker/reference/errors.go b/vendor/github.com/docker/docker/reference/errors.go new file mode 100644 index 000000000..a16f124e9 --- /dev/null +++ b/vendor/github.com/docker/docker/reference/errors.go @@ -0,0 +1,25 @@ +package reference + +type notFoundError string + +func (e notFoundError) Error() string { + return string(e) +} + +func (notFoundError) NotFound() {} + +type invalidTagError string + +func (e invalidTagError) Error() string { + return string(e) +} + +func (invalidTagError) InvalidParameter() {} + +type conflictingTagError string + +func (e conflictingTagError) Error() string { + return string(e) +} + +func (conflictingTagError) Conflict() {} diff --git a/vendor/github.com/docker/docker/reference/store.go b/vendor/github.com/docker/docker/reference/store.go index 5b68c437c..bde595192 100644 --- a/vendor/github.com/docker/docker/reference/store.go +++ b/vendor/github.com/docker/docker/reference/store.go @@ -2,7 +2,6 @@ package reference import ( "encoding/json" - "errors" "fmt" "os" "path/filepath" @@ -12,12 +11,13 @@ import ( "github.com/docker/distribution/reference" "github.com/docker/docker/pkg/ioutils" "github.com/opencontainers/go-digest" + "github.com/pkg/errors" ) var ( // ErrDoesNotExist is returned if a reference is not found in the // store. - ErrDoesNotExist = errors.New("reference does not exist") + ErrDoesNotExist notFoundError = "reference does not exist" ) // An Association is a tuple associating a reference with an image ID. @@ -26,7 +26,7 @@ type Association struct { ID digest.Digest } -// Store provides the set of methods which can operate on a tag store. +// Store provides the set of methods which can operate on a reference store. type Store interface { References(id digest.Digest) []reference.Named ReferencesByName(ref reference.Named) []Association @@ -46,9 +46,6 @@ type store struct { // referencesByIDCache is a cache of references indexed by ID, to speed // up References. referencesByIDCache map[digest.Digest]map[string]reference.Named - // platform is the container target platform for this store (which may be - // different to the host operating system - platform string } // Repository maps tags to digests. The key is a stringified Reference, @@ -73,7 +70,7 @@ func (a lexicalAssociations) Less(i, j int) bool { // NewReferenceStore creates a new reference store, tied to a file path where // the set of references are serialized in JSON format. -func NewReferenceStore(jsonPath, platform string) (Store, error) { +func NewReferenceStore(jsonPath string) (Store, error) { abspath, err := filepath.Abs(jsonPath) if err != nil { return nil, err @@ -83,7 +80,6 @@ func NewReferenceStore(jsonPath, platform string) (Store, error) { jsonPath: abspath, Repositories: make(map[string]repository), referencesByIDCache: make(map[digest.Digest]map[string]reference.Named), - platform: platform, } // Load the json file if it exists, otherwise create it. if err := store.reload(); os.IsNotExist(err) { @@ -100,7 +96,7 @@ func NewReferenceStore(jsonPath, platform string) (Store, error) { // references can be overwritten. This only works for tags, not digests. func (store *store) AddTag(ref reference.Named, id digest.Digest, force bool) error { if _, isCanonical := ref.(reference.Canonical); isCanonical { - return errors.New("refusing to create a tag with a digest reference") + return errors.WithStack(invalidTagError("refusing to create a tag with a digest reference")) } return store.addReference(reference.TagNameOnly(ref), id, force) } @@ -138,7 +134,7 @@ func (store *store) addReference(ref reference.Named, id digest.Digest, force bo refStr := reference.FamiliarString(ref) if refName == string(digest.Canonical) { - return errors.New("refusing to create an ambiguous tag using digest algorithm as name") + return errors.WithStack(invalidTagError("refusing to create an ambiguous tag using digest algorithm as name")) } store.mu.Lock() @@ -155,11 +151,15 @@ func (store *store) addReference(ref reference.Named, id digest.Digest, force bo if exists { // force only works for tags if digested, isDigest := ref.(reference.Canonical); isDigest { - return fmt.Errorf("Cannot overwrite digest %s", digested.Digest().String()) + return errors.WithStack(conflictingTagError("Cannot overwrite digest " + digested.Digest().String())) } if !force { - return fmt.Errorf("Conflict: Tag %s is already set to image %s, if you want to replace it, please use -f option", refStr, oldID.String()) + return errors.WithStack( + conflictingTagError( + fmt.Sprintf("Conflict: Tag %s is already set to image %s, if you want to replace it, please use the force option", refStr, oldID.String()), + ), + ) } if store.referencesByIDCache[oldID] != nil { diff --git a/vendor/github.com/docker/docker/reference/store_test.go b/vendor/github.com/docker/docker/reference/store_test.go index 2c796e76f..72a19d6b8 100644 --- a/vendor/github.com/docker/docker/reference/store_test.go +++ b/vendor/github.com/docker/docker/reference/store_test.go @@ -5,12 +5,13 @@ import ( "io/ioutil" "os" "path/filepath" - "runtime" "strings" "testing" "github.com/docker/distribution/reference" - "github.com/opencontainers/go-digest" + digest "github.com/opencontainers/go-digest" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) var ( @@ -41,7 +42,7 @@ func TestLoad(t *testing.T) { } jsonFile.Close() - store, err := NewReferenceStore(jsonFile.Name(), runtime.GOOS) + store, err := NewReferenceStore(jsonFile.Name()) if err != nil { t.Fatalf("error creating tag store: %v", err) } @@ -63,14 +64,14 @@ func TestLoad(t *testing.T) { func TestSave(t *testing.T) { jsonFile, err := ioutil.TempFile("", "tag-store-test") - if err != nil { - t.Fatalf("error creating temp file: %v", err) - } + require.NoError(t, err) + _, err = jsonFile.Write([]byte(`{}`)) + require.NoError(t, err) jsonFile.Close() defer os.RemoveAll(jsonFile.Name()) - store, err := NewReferenceStore(jsonFile.Name(), runtime.GOOS) + store, err := NewReferenceStore(jsonFile.Name()) if err != nil { t.Fatalf("error creating tag store: %v", err) } @@ -112,7 +113,7 @@ func TestAddDeleteGet(t *testing.T) { jsonFile.Close() defer os.RemoveAll(jsonFile.Name()) - store, err := NewReferenceStore(jsonFile.Name(), runtime.GOOS) + store, err := NewReferenceStore(jsonFile.Name()) if err != nil { t.Fatalf("error creating tag store: %v", err) } @@ -305,19 +306,19 @@ func TestAddDeleteGet(t *testing.T) { } // Delete a few references - if deleted, err := store.Delete(ref1); err != nil || deleted != true { + if deleted, err := store.Delete(ref1); err != nil || !deleted { t.Fatal("Delete failed") } if _, err := store.Get(ref1); err != ErrDoesNotExist { t.Fatal("Expected ErrDoesNotExist from Get") } - if deleted, err := store.Delete(ref5); err != nil || deleted != true { + if deleted, err := store.Delete(ref5); err != nil || !deleted { t.Fatal("Delete failed") } if _, err := store.Get(ref5); err != ErrDoesNotExist { t.Fatal("Expected ErrDoesNotExist from Get") } - if deleted, err := store.Delete(nameOnly); err != nil || deleted != true { + if deleted, err := store.Delete(nameOnly); err != nil || !deleted { t.Fatal("Delete failed") } if _, err := store.Get(nameOnly); err != ErrDoesNotExist { @@ -327,32 +328,23 @@ func TestAddDeleteGet(t *testing.T) { func TestInvalidTags(t *testing.T) { tmpDir, err := ioutil.TempDir("", "tag-store-test") + require.NoError(t, err) defer os.RemoveAll(tmpDir) - store, err := NewReferenceStore(filepath.Join(tmpDir, "repositories.json"), runtime.GOOS) - if err != nil { - t.Fatalf("error creating tag store: %v", err) - } + store, err := NewReferenceStore(filepath.Join(tmpDir, "repositories.json")) + require.NoError(t, err) id := digest.Digest("sha256:470022b8af682154f57a2163d030eb369549549cba00edc69e1b99b46bb924d6") // sha256 as repo name ref, err := reference.ParseNormalizedNamed("sha256:abc") - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) err = store.AddTag(ref, id, true) - if err == nil { - t.Fatalf("expected setting tag %q to fail", ref) - } + assert.Error(t, err) // setting digest as a tag ref, err = reference.ParseNormalizedNamed("registry@sha256:367eb40fd0330a7e464777121e39d2f5b3e8e23a1e159342e53ab05c9e4d94e6") - if err != nil { - t.Fatal(err) - } - err = store.AddTag(ref, id, true) - if err == nil { - t.Fatalf("expected setting tag %q to fail", ref) - } + require.NoError(t, err) + err = store.AddTag(ref, id, true) + assert.Error(t, err) } diff --git a/vendor/github.com/docker/docker/registry/auth.go b/vendor/github.com/docker/docker/registry/auth.go index f7a8fdc93..b0a03d048 100644 --- a/vendor/github.com/docker/docker/registry/auth.go +++ b/vendor/github.com/docker/docker/registry/auth.go @@ -1,7 +1,6 @@ package registry import ( - "fmt" "io/ioutil" "net/http" "net/url" @@ -13,6 +12,7 @@ import ( "github.com/docker/distribution/registry/client/transport" "github.com/docker/docker/api/types" registrytypes "github.com/docker/docker/api/types/registry" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -23,21 +23,15 @@ const ( // loginV1 tries to register/login to the v1 registry server. func loginV1(authConfig *types.AuthConfig, apiEndpoint APIEndpoint, userAgent string) (string, string, error) { - registryEndpoint, err := apiEndpoint.ToV1Endpoint(userAgent, nil) - if err != nil { - return "", "", err - } - + registryEndpoint := apiEndpoint.ToV1Endpoint(userAgent, nil) serverAddress := registryEndpoint.String() logrus.Debugf("attempting v1 login to registry endpoint %s", serverAddress) if serverAddress == "" { - return "", "", fmt.Errorf("Server Error: Server Address not set.") + return "", "", systemError{errors.New("server Error: Server Address not set")} } - loginAgainstOfficialIndex := serverAddress == IndexServer - req, err := http.NewRequest("GET", serverAddress+"users/", nil) if err != nil { return "", "", err @@ -53,27 +47,23 @@ func loginV1(authConfig *types.AuthConfig, apiEndpoint APIEndpoint, userAgent st defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { - return "", "", err + return "", "", systemError{err} } - if resp.StatusCode == http.StatusOK { + + switch resp.StatusCode { + case http.StatusOK: return "Login Succeeded", "", nil - } else if resp.StatusCode == http.StatusUnauthorized { - if loginAgainstOfficialIndex { - return "", "", fmt.Errorf("Wrong login/password, please try again. Haven't got a Docker ID? Create one at https://hub.docker.com") - } - return "", "", fmt.Errorf("Wrong login/password, please try again") - } else if resp.StatusCode == http.StatusForbidden { - if loginAgainstOfficialIndex { - return "", "", fmt.Errorf("Login: Account is not active. Please check your e-mail for a confirmation link.") - } + case http.StatusUnauthorized: + return "", "", unauthorizedError{errors.New("Wrong login/password, please try again")} + case http.StatusForbidden: // *TODO: Use registry configuration to determine what this says, if anything? - return "", "", fmt.Errorf("Login: Account is not active. Please see the documentation of the registry %s for instructions how to activate it.", serverAddress) - } else if resp.StatusCode == http.StatusInternalServerError { // Issue #14326 + return "", "", notActivatedError{errors.Errorf("Login: Account is not active. Please see the documentation of the registry %s for instructions how to activate it.", serverAddress)} + case http.StatusInternalServerError: logrus.Errorf("%s returned status code %d. Response Body :\n%s", req.URL.String(), resp.StatusCode, body) - return "", "", fmt.Errorf("Internal Server Error") + return "", "", systemError{errors.New("Internal Server Error")} } - return "", "", fmt.Errorf("Login: %s (Code: %d; Headers: %s)", body, - resp.StatusCode, resp.Header) + return "", "", systemError{errors.Errorf("Login: %s (Code: %d; Headers: %s)", body, + resp.StatusCode, resp.Header)} } type loginCredentialStore struct { @@ -159,24 +149,25 @@ func loginV2(authConfig *types.AuthConfig, endpoint APIEndpoint, userAgent strin resp, err := loginClient.Do(req) if err != nil { + err = translateV2AuthError(err) if !foundV2 { err = fallbackError{err: err} } + return "", "", err } defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - // TODO(dmcgowan): Attempt to further interpret result, status code and error code string - err := fmt.Errorf("login attempt to %s failed with status: %d %s", endpointStr, resp.StatusCode, http.StatusText(resp.StatusCode)) - if !foundV2 { - err = fallbackError{err: err} - } - return "", "", err + if resp.StatusCode == http.StatusOK { + return "Login Succeeded", credentialAuthConfig.IdentityToken, nil } - return "Login Succeeded", credentialAuthConfig.IdentityToken, nil - + // TODO(dmcgowan): Attempt to further interpret result, status code and error code string + err = errors.Errorf("login attempt to %s failed with status: %d %s", endpointStr, resp.StatusCode, http.StatusText(resp.StatusCode)) + if !foundV2 { + err = fallbackError{err: err} + } + return "", "", err } func v2AuthHTTPClient(endpoint *url.URL, authTransport http.RoundTripper, modifiers []transport.RequestModifier, creds auth.CredentialStore, scopes []auth.Scope) (*http.Client, bool, error) { @@ -256,6 +247,7 @@ func (err PingResponseError) Error() string { // challenge manager for the supported authentication types and // whether v2 was confirmed by the response. If a response is received but // cannot be interpreted a PingResponseError will be returned. +// nolint: interfacer func PingV2Registry(endpoint *url.URL, transport http.RoundTripper) (challenge.Manager, bool, error) { var ( foundV2 = false diff --git a/vendor/github.com/docker/docker/registry/config.go b/vendor/github.com/docker/docker/registry/config.go index f4b3bff94..5246faa4e 100644 --- a/vendor/github.com/docker/docker/registry/config.go +++ b/vendor/github.com/docker/docker/registry/config.go @@ -10,10 +10,8 @@ import ( "github.com/docker/distribution/reference" registrytypes "github.com/docker/docker/api/types/registry" - "github.com/docker/docker/opts" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/spf13/pflag" ) // ServiceOptions holds command line options. @@ -62,7 +60,7 @@ var ( // not have the correct form ErrInvalidRepositoryName = errors.New("Invalid repository name (ex: \"registry.domain.tld/myrepos\")") - emptyServiceConfig = newServiceConfig(ServiceOptions{}) + emptyServiceConfig, _ = newServiceConfig(ServiceOptions{}) ) var ( @@ -72,37 +70,28 @@ var ( // for mocking in unit tests var lookupIP = net.LookupIP -// InstallCliFlags adds command-line options to the top-level flag parser for -// the current process. -func (options *ServiceOptions) InstallCliFlags(flags *pflag.FlagSet) { - ana := opts.NewNamedListOptsRef("allow-nondistributable-artifacts", &options.AllowNondistributableArtifacts, ValidateIndexName) - mirrors := opts.NewNamedListOptsRef("registry-mirrors", &options.Mirrors, ValidateMirror) - insecureRegistries := opts.NewNamedListOptsRef("insecure-registries", &options.InsecureRegistries, ValidateIndexName) - - flags.Var(ana, "allow-nondistributable-artifacts", "Allow push of nondistributable artifacts to registry") - flags.Var(mirrors, "registry-mirror", "Preferred Docker registry mirror") - flags.Var(insecureRegistries, "insecure-registry", "Enable insecure registry communication") - - options.installCliPlatformFlags(flags) -} - // newServiceConfig returns a new instance of ServiceConfig -func newServiceConfig(options ServiceOptions) *serviceConfig { +func newServiceConfig(options ServiceOptions) (*serviceConfig, error) { config := &serviceConfig{ ServiceConfig: registrytypes.ServiceConfig{ InsecureRegistryCIDRs: make([]*registrytypes.NetIPNet, 0), - IndexConfigs: make(map[string]*registrytypes.IndexInfo, 0), + IndexConfigs: make(map[string]*registrytypes.IndexInfo), // Hack: Bypass setting the mirrors to IndexConfigs since they are going away // and Mirrors are only for the official registry anyways. }, V2Only: options.V2Only, } + if err := config.LoadAllowNondistributableArtifacts(options.AllowNondistributableArtifacts); err != nil { + return nil, err + } + if err := config.LoadMirrors(options.Mirrors); err != nil { + return nil, err + } + if err := config.LoadInsecureRegistries(options.InsecureRegistries); err != nil { + return nil, err + } - config.LoadAllowNondistributableArtifacts(options.AllowNondistributableArtifacts) - config.LoadMirrors(options.Mirrors) - config.LoadInsecureRegistries(options.InsecureRegistries) - - return config + return config, nil } // LoadAllowNondistributableArtifacts loads allow-nondistributable-artifacts registries into config. @@ -187,7 +176,7 @@ func (config *serviceConfig) LoadInsecureRegistries(registries []string) error { originalIndexInfos := config.ServiceConfig.IndexConfigs config.ServiceConfig.InsecureRegistryCIDRs = make([]*registrytypes.NetIPNet, 0) - config.ServiceConfig.IndexConfigs = make(map[string]*registrytypes.IndexInfo, 0) + config.ServiceConfig.IndexConfigs = make(map[string]*registrytypes.IndexInfo) skip: for _, r := range registries { @@ -354,7 +343,7 @@ func ValidateIndexName(val string) (string, error) { val = "docker.io" } if strings.HasPrefix(val, "-") || strings.HasSuffix(val, "-") { - return "", fmt.Errorf("Invalid index name (%s). Cannot begin or end with a hyphen.", val) + return "", fmt.Errorf("invalid index name (%s). Cannot begin or end with a hyphen", val) } return val, nil } diff --git a/vendor/github.com/docker/docker/registry/config_test.go b/vendor/github.com/docker/docker/registry/config_test.go index 8cb7e5a54..0899e17f6 100644 --- a/vendor/github.com/docker/docker/registry/config_test.go +++ b/vendor/github.com/docker/docker/registry/config_test.go @@ -5,6 +5,8 @@ import ( "sort" "strings" "testing" + + "github.com/stretchr/testify/assert" ) func TestLoadAllowNondistributableArtifacts(t *testing.T) { @@ -90,7 +92,7 @@ func TestLoadAllowNondistributableArtifacts(t *testing.T) { }, } for _, testCase := range testCases { - config := newServiceConfig(ServiceOptions{}) + config := emptyServiceConfig err := config.LoadAllowNondistributableArtifacts(testCase.registries) if testCase.err == "" { if err != nil { @@ -233,7 +235,7 @@ func TestLoadInsecureRegistries(t *testing.T) { }, } for _, testCase := range testCases { - config := newServiceConfig(ServiceOptions{}) + config := emptyServiceConfig err := config.LoadInsecureRegistries(testCase.registries) if testCase.err == "" { if err != nil { @@ -258,3 +260,60 @@ func TestLoadInsecureRegistries(t *testing.T) { } } } + +func TestNewServiceConfig(t *testing.T) { + testCases := []struct { + opts ServiceOptions + errStr string + }{ + { + ServiceOptions{}, + "", + }, + { + ServiceOptions{ + Mirrors: []string{"example.com:5000"}, + }, + `invalid mirror: unsupported scheme "example.com" in "example.com:5000"`, + }, + { + ServiceOptions{ + Mirrors: []string{"http://example.com:5000"}, + }, + "", + }, + { + ServiceOptions{ + InsecureRegistries: []string{"[fe80::]/64"}, + }, + `insecure registry [fe80::]/64 is not valid: invalid host "[fe80::]/64"`, + }, + { + ServiceOptions{ + InsecureRegistries: []string{"102.10.8.1/24"}, + }, + "", + }, + { + ServiceOptions{ + AllowNondistributableArtifacts: []string{"[fe80::]/64"}, + }, + `allow-nondistributable-artifacts registry [fe80::]/64 is not valid: invalid host "[fe80::]/64"`, + }, + { + ServiceOptions{ + AllowNondistributableArtifacts: []string{"102.10.8.1/24"}, + }, + "", + }, + } + + for _, testCase := range testCases { + _, err := newServiceConfig(testCase.opts) + if testCase.errStr != "" { + assert.EqualError(t, err, testCase.errStr) + } else { + assert.Nil(t, err) + } + } +} diff --git a/vendor/github.com/docker/docker/registry/config_unix.go b/vendor/github.com/docker/docker/registry/config_unix.go index fdc39a1d6..b81d24933 100644 --- a/vendor/github.com/docker/docker/registry/config_unix.go +++ b/vendor/github.com/docker/docker/registry/config_unix.go @@ -2,10 +2,6 @@ package registry -import ( - "github.com/spf13/pflag" -) - var ( // CertsDir is the directory where certificates are stored CertsDir = "/etc/docker/certs.d" @@ -18,8 +14,3 @@ var ( func cleanPath(s string) string { return s } - -// installCliPlatformFlags handles any platform specific flags for the service. -func (options *ServiceOptions) installCliPlatformFlags(flags *pflag.FlagSet) { - flags.BoolVar(&options.V2Only, "disable-legacy-registry", true, "Disable contacting legacy registries") -} diff --git a/vendor/github.com/docker/docker/registry/config_windows.go b/vendor/github.com/docker/docker/registry/config_windows.go index d1b313dc1..82bc4afea 100644 --- a/vendor/github.com/docker/docker/registry/config_windows.go +++ b/vendor/github.com/docker/docker/registry/config_windows.go @@ -4,8 +4,6 @@ import ( "os" "path/filepath" "strings" - - "github.com/spf13/pflag" ) // CertsDir is the directory where certificates are stored @@ -18,8 +16,3 @@ var CertsDir = os.Getenv("programdata") + `\docker\certs.d` func cleanPath(s string) string { return filepath.FromSlash(strings.Replace(s, ":", "", -1)) } - -// installCliPlatformFlags handles any platform specific flags for the service. -func (options *ServiceOptions) installCliPlatformFlags(flags *pflag.FlagSet) { - // No Windows specific flags. -} diff --git a/vendor/github.com/docker/docker/registry/endpoint_v1.go b/vendor/github.com/docker/docker/registry/endpoint_v1.go index 59fd72e93..d6a51bfaf 100644 --- a/vendor/github.com/docker/docker/registry/endpoint_v1.go +++ b/vendor/github.com/docker/docker/registry/endpoint_v1.go @@ -67,7 +67,7 @@ func validateEndpoint(endpoint *V1Endpoint) error { return nil } -func newV1Endpoint(address url.URL, tlsConfig *tls.Config, userAgent string, metaHeaders http.Header) (*V1Endpoint, error) { +func newV1Endpoint(address url.URL, tlsConfig *tls.Config, userAgent string, metaHeaders http.Header) *V1Endpoint { endpoint := &V1Endpoint{ IsSecure: (tlsConfig == nil || !tlsConfig.InsecureSkipVerify), URL: new(url.URL), @@ -78,7 +78,7 @@ func newV1Endpoint(address url.URL, tlsConfig *tls.Config, userAgent string, met // TODO(tiborvass): make sure a ConnectTimeout transport is used tr := NewTransport(tlsConfig) endpoint.client = HTTPClient(transport.NewTransport(tr, DockerHeaders(userAgent, metaHeaders)...)) - return endpoint, nil + return endpoint } // trimV1Address trims the version off the address and returns the @@ -123,7 +123,7 @@ func newV1EndpointFromStr(address string, tlsConfig *tls.Config, userAgent strin return nil, err } - endpoint, err := newV1Endpoint(*uri, tlsConfig, userAgent, metaHeaders) + endpoint := newV1Endpoint(*uri, tlsConfig, userAgent, metaHeaders) if err != nil { return nil, err } diff --git a/vendor/github.com/docker/docker/registry/errors.go b/vendor/github.com/docker/docker/registry/errors.go new file mode 100644 index 000000000..b388efca7 --- /dev/null +++ b/vendor/github.com/docker/docker/registry/errors.go @@ -0,0 +1,86 @@ +package registry + +import ( + "net/url" + + "github.com/docker/distribution/registry/api/errcode" +) + +type notFoundError string + +func (e notFoundError) Error() string { + return string(e) +} + +func (notFoundError) NotFound() {} + +type validationError struct { + cause error +} + +func (e validationError) Error() string { + return e.cause.Error() +} + +func (e validationError) InvalidParameter() {} + +func (e validationError) Cause() error { + return e.cause +} + +type unauthorizedError struct { + cause error +} + +func (e unauthorizedError) Error() string { + return e.cause.Error() +} + +func (e unauthorizedError) Unauthorized() {} + +func (e unauthorizedError) Cause() error { + return e.cause +} + +type systemError struct { + cause error +} + +func (e systemError) Error() string { + return e.cause.Error() +} + +func (e systemError) SystemError() {} + +func (e systemError) Cause() error { + return e.cause +} + +type notActivatedError struct { + cause error +} + +func (e notActivatedError) Error() string { + return e.cause.Error() +} + +func (e notActivatedError) Forbidden() {} + +func (e notActivatedError) Cause() error { + return e.cause +} + +func translateV2AuthError(err error) error { + switch e := err.(type) { + case *url.Error: + switch e2 := e.Err.(type) { + case errcode.Error: + switch e2.Code { + case errcode.ErrorCodeUnauthorized: + return unauthorizedError{err} + } + } + } + + return err +} diff --git a/vendor/github.com/docker/docker/registry/registry.go b/vendor/github.com/docker/docker/registry/registry.go index a676d6345..5fef0dbcc 100644 --- a/vendor/github.com/docker/docker/registry/registry.go +++ b/vendor/github.com/docker/docker/registry/registry.go @@ -81,7 +81,7 @@ func ReadCertsDirectory(tlsConfig *tls.Config, directory string) error { keyName := certName[:len(certName)-5] + ".key" logrus.Debugf("cert: %s", filepath.Join(directory, f.Name())) if !hasFile(fs, keyName) { - return fmt.Errorf("Missing key %s for client certificate %s. Note that CA certificates should use the extension .crt.", keyName, certName) + return fmt.Errorf("missing key %s for client certificate %s. Note that CA certificates should use the extension .crt", keyName, certName) } cert, err := tls.LoadX509KeyPair(filepath.Join(directory, certName), filepath.Join(directory, keyName)) if err != nil { diff --git a/vendor/github.com/docker/docker/registry/registry_mock_test.go b/vendor/github.com/docker/docker/registry/registry_mock_test.go index 204a98344..cf1cd19c1 100644 --- a/vendor/github.com/docker/docker/registry/registry_mock_test.go +++ b/vendor/github.com/docker/docker/registry/registry_mock_test.go @@ -175,7 +175,7 @@ func makePublicIndex() *registrytypes.IndexInfo { return index } -func makeServiceConfig(mirrors []string, insecureRegistries []string) *serviceConfig { +func makeServiceConfig(mirrors []string, insecureRegistries []string) (*serviceConfig, error) { options := ServiceOptions{ Mirrors: mirrors, InsecureRegistries: insecureRegistries, diff --git a/vendor/github.com/docker/docker/registry/registry_test.go b/vendor/github.com/docker/docker/registry/registry_test.go index d89c46c2c..e9c407d4b 100644 --- a/vendor/github.com/docker/docker/registry/registry_test.go +++ b/vendor/github.com/docker/docker/registry/registry_test.go @@ -14,6 +14,7 @@ import ( "github.com/docker/distribution/registry/client/transport" "github.com/docker/docker/api/types" registrytypes "github.com/docker/docker/api/types/registry" + "github.com/stretchr/testify/assert" ) var ( @@ -539,7 +540,7 @@ func TestNewIndexInfo(t *testing.T) { } } - config := newServiceConfig(ServiceOptions{}) + config := emptyServiceConfig noMirrors := []string{} expectedIndexInfos := map[string]*registrytypes.IndexInfo{ IndexName: { @@ -570,7 +571,11 @@ func TestNewIndexInfo(t *testing.T) { testIndexInfo(config, expectedIndexInfos) publicMirrors := []string{"http://mirror1.local", "http://mirror2.local"} - config = makeServiceConfig(publicMirrors, []string{"example.com"}) + var err error + config, err = makeServiceConfig(publicMirrors, []string{"example.com"}) + if err != nil { + t.Fatal(err) + } expectedIndexInfos = map[string]*registrytypes.IndexInfo{ IndexName: { @@ -618,7 +623,10 @@ func TestNewIndexInfo(t *testing.T) { } testIndexInfo(config, expectedIndexInfos) - config = makeServiceConfig(nil, []string{"42.42.0.0/16"}) + config, err = makeServiceConfig(nil, []string{"42.42.0.0/16"}) + if err != nil { + t.Fatal(err) + } expectedIndexInfos = map[string]*registrytypes.IndexInfo{ "example.com": { Name: "example.com", @@ -663,7 +671,11 @@ func TestMirrorEndpointLookup(t *testing.T) { } return false } - s := DefaultService{config: makeServiceConfig([]string{"https://my.mirror"}, nil)} + cfg, err := makeServiceConfig([]string{"https://my.mirror"}, nil) + if err != nil { + t.Fatal(err) + } + s := DefaultService{config: cfg} imageName, err := reference.WithName(IndexName + "/test/image") if err != nil { @@ -747,16 +759,12 @@ func TestSearchRepositories(t *testing.T) { func TestTrustedLocation(t *testing.T) { for _, url := range []string{"http://example.com", "https://example.com:7777", "http://docker.io", "http://test.docker.com", "https://fakedocker.com"} { req, _ := http.NewRequest("GET", url, nil) - if trustedLocation(req) == true { - t.Fatalf("'%s' shouldn't be detected as a trusted location", url) - } + assert.False(t, trustedLocation(req)) } for _, url := range []string{"https://docker.io", "https://test.docker.com:80"} { req, _ := http.NewRequest("GET", url, nil) - if trustedLocation(req) == false { - t.Fatalf("'%s' should be detected as a trusted location", url) - } + assert.True(t, trustedLocation(req)) } } @@ -844,9 +852,12 @@ func TestAllowNondistributableArtifacts(t *testing.T) { {"invalid.domain.com:5000", []string{"invalid.domain.com:5000"}, true}, } for _, tt := range tests { - config := newServiceConfig(ServiceOptions{ + config, err := newServiceConfig(ServiceOptions{ AllowNondistributableArtifacts: tt.registries, }) + if err != nil { + t.Error(err) + } if v := allowNondistributableArtifacts(config, tt.addr); v != tt.expected { t.Errorf("allowNondistributableArtifacts failed for %q %v, expected %v got %v", tt.addr, tt.registries, tt.expected, v) } @@ -886,7 +897,10 @@ func TestIsSecureIndex(t *testing.T) { {"invalid.domain.com:5000", []string{"invalid.domain.com:5000"}, false}, } for _, tt := range tests { - config := makeServiceConfig(nil, tt.insecureRegistries) + config, err := makeServiceConfig(nil, tt.insecureRegistries) + if err != nil { + t.Error(err) + } if sec := isSecureIndex(config, tt.addr); sec != tt.expected { t.Errorf("isSecureIndex failed for %q %v, expected %v got %v", tt.addr, tt.insecureRegistries, tt.expected, sec) } diff --git a/vendor/github.com/docker/docker/registry/resumable/resumablerequestreader_test.go b/vendor/github.com/docker/docker/registry/resumable/resumablerequestreader_test.go index a632bc673..9b3a6dc0c 100644 --- a/vendor/github.com/docker/docker/registry/resumable/resumablerequestreader_test.go +++ b/vendor/github.com/docker/docker/registry/resumable/resumablerequestreader_test.go @@ -2,8 +2,6 @@ package resumable import ( "fmt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "io" "io/ioutil" "net/http" @@ -11,6 +9,9 @@ import ( "strings" "testing" "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestResumableRequestHeaderSimpleErrors(t *testing.T) { diff --git a/vendor/github.com/docker/docker/registry/service.go b/vendor/github.com/docker/docker/registry/service.go index b4f747380..a991a8fc3 100644 --- a/vendor/github.com/docker/docker/registry/service.go +++ b/vendor/github.com/docker/docker/registry/service.go @@ -2,7 +2,6 @@ package registry import ( "crypto/tls" - "fmt" "net/http" "net/url" "strings" @@ -14,6 +13,7 @@ import ( "github.com/docker/distribution/registry/client/auth" "github.com/docker/docker/api/types" registrytypes "github.com/docker/docker/api/types/registry" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -45,10 +45,10 @@ type DefaultService struct { // NewService returns a new instance of DefaultService ready to be // installed into an engine. -func NewService(options ServiceOptions) *DefaultService { - return &DefaultService{ - config: newServiceConfig(options), - } +func NewService(options ServiceOptions) (*DefaultService, error) { + config, err := newServiceConfig(options) + + return &DefaultService{config: config}, err } // ServiceConfig returns the public registry service configuration. @@ -117,12 +117,12 @@ func (s *DefaultService) Auth(ctx context.Context, authConfig *types.AuthConfig, } u, err := url.Parse(serverAddress) if err != nil { - return "", "", fmt.Errorf("unable to parse server address: %v", err) + return "", "", validationError{errors.Errorf("unable to parse server address: %v", err)} } endpoints, err := s.LookupPushEndpoints(u.Host) if err != nil { - return "", "", err + return "", "", validationError{err} } for _, endpoint := range endpoints { @@ -140,6 +140,7 @@ func (s *DefaultService) Auth(ctx context.Context, authConfig *types.AuthConfig, logrus.Infof("Error logging in to %s endpoint, trying next endpoint: %v", endpoint.Version, err) continue } + return "", "", err } @@ -258,7 +259,7 @@ type APIEndpoint struct { } // ToV1Endpoint returns a V1 API endpoint based on the APIEndpoint -func (e APIEndpoint) ToV1Endpoint(userAgent string, metaHeaders http.Header) (*V1Endpoint, error) { +func (e APIEndpoint) ToV1Endpoint(userAgent string, metaHeaders http.Header) *V1Endpoint { return newV1Endpoint(*e.URL, e.TLSConfig, userAgent, metaHeaders) } diff --git a/vendor/github.com/docker/docker/registry/service_v1_test.go b/vendor/github.com/docker/docker/registry/service_v1_test.go index bd15dfffb..6ea846eed 100644 --- a/vendor/github.com/docker/docker/registry/service_v1_test.go +++ b/vendor/github.com/docker/docker/registry/service_v1_test.go @@ -3,7 +3,10 @@ package registry import "testing" func TestLookupV1Endpoints(t *testing.T) { - s := NewService(ServiceOptions{}) + s, err := NewService(ServiceOptions{}) + if err != nil { + t.Fatal(err) + } cases := []struct { hostname string diff --git a/vendor/github.com/docker/docker/registry/session.go b/vendor/github.com/docker/docker/registry/session.go index bc4a24403..e619d9f64 100644 --- a/vendor/github.com/docker/docker/registry/session.go +++ b/vendor/github.com/docker/docker/registry/session.go @@ -3,7 +3,6 @@ package registry import ( "bytes" "crypto/sha256" - "errors" "sync" // this is required for some certificates _ "crypto/sha512" @@ -27,13 +26,14 @@ import ( "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/tarsum" "github.com/docker/docker/registry/resumable" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) var ( // ErrRepoNotFound is returned if the repository didn't exist on the // remote side - ErrRepoNotFound = errors.New("Repository not found") + ErrRepoNotFound notFoundError = "Repository not found" ) // A Session is used to communicate with a V1 registry @@ -434,7 +434,7 @@ func (r *Session) GetRepositoryData(name reference.Named) (*RepositoryData, erro // "Get https://index.docker.io/v1/repositories/library/busybox/images: i/o timeout" // was a top search on the docker user forum if isTimeout(err) { - return nil, fmt.Errorf("Network timed out while trying to connect to %s. You may want to check your internet connection or if you are behind a proxy.", repositoryTarget) + return nil, fmt.Errorf("network timed out while trying to connect to %s. You may want to check your internet connection or if you are behind a proxy", repositoryTarget) } return nil, fmt.Errorf("Error while pulling image: %v", err) } @@ -734,27 +734,27 @@ func shouldRedirect(response *http.Response) bool { // SearchRepositories performs a search against the remote repository func (r *Session) SearchRepositories(term string, limit int) (*registrytypes.SearchResults, error) { if limit < 1 || limit > 100 { - return nil, fmt.Errorf("Limit %d is outside the range of [1, 100]", limit) + return nil, validationError{errors.Errorf("Limit %d is outside the range of [1, 100]", limit)} } logrus.Debugf("Index server: %s", r.indexEndpoint) u := r.indexEndpoint.String() + "search?q=" + url.QueryEscape(term) + "&n=" + url.QueryEscape(fmt.Sprintf("%d", limit)) req, err := http.NewRequest("GET", u, nil) if err != nil { - return nil, fmt.Errorf("Error while getting from the server: %v", err) + return nil, errors.Wrap(validationError{err}, "Error building request") } // Have the AuthTransport send authentication, when logged in. req.Header.Set("X-Docker-Token", "true") res, err := r.client.Do(req) if err != nil { - return nil, err + return nil, systemError{err} } defer res.Body.Close() if res.StatusCode != 200 { return nil, newJSONError(fmt.Sprintf("Unexpected status code %d", res.StatusCode), res) } result := new(registrytypes.SearchResults) - return result, json.NewDecoder(res.Body).Decode(result) + return result, errors.Wrap(json.NewDecoder(res.Body).Decode(result), "error decoding registry search results") } func isTimeout(err error) bool { diff --git a/vendor/github.com/docker/docker/runconfig/config.go b/vendor/github.com/docker/docker/runconfig/config.go index c9dc6e96e..56eb946cc 100644 --- a/vendor/github.com/docker/docker/runconfig/config.go +++ b/vendor/github.com/docker/docker/runconfig/config.go @@ -2,13 +2,11 @@ package runconfig import ( "encoding/json" - "fmt" "io" "github.com/docker/docker/api/types/container" networktypes "github.com/docker/docker/api/types/network" "github.com/docker/docker/pkg/sysinfo" - "github.com/docker/docker/volume" ) // ContainerDecoder implements httputils.ContainerDecoder @@ -17,19 +15,19 @@ type ContainerDecoder struct{} // DecodeConfig makes ContainerDecoder to implement httputils.ContainerDecoder func (r ContainerDecoder) DecodeConfig(src io.Reader) (*container.Config, *container.HostConfig, *networktypes.NetworkingConfig, error) { - return DecodeContainerConfig(src) + return decodeContainerConfig(src) } // DecodeHostConfig makes ContainerDecoder to implement httputils.ContainerDecoder func (r ContainerDecoder) DecodeHostConfig(src io.Reader) (*container.HostConfig, error) { - return DecodeHostConfig(src) + return decodeHostConfig(src) } -// DecodeContainerConfig decodes a json encoded config into a ContainerConfigWrapper +// decodeContainerConfig decodes a json encoded config into a ContainerConfigWrapper // struct and returns both a Config and a HostConfig struct // Be aware this function is not checking whether the resulted structs are nil, // it's your business to do so -func DecodeContainerConfig(src io.Reader) (*container.Config, *container.HostConfig, *networktypes.NetworkingConfig, error) { +func decodeContainerConfig(src io.Reader) (*container.Config, *container.HostConfig, *networktypes.NetworkingConfig, error) { var w ContainerConfigWrapper decoder := json.NewDecoder(src) @@ -46,11 +44,6 @@ func DecodeContainerConfig(src io.Reader) (*container.Config, *container.HostCon if w.Config.Volumes == nil { w.Config.Volumes = make(map[string]struct{}) } - - // Now validate all the volumes and binds - if err := validateMountSettings(w.Config, hc); err != nil { - return nil, nil, nil, err - } } // Certain parameters need daemon-side validation that cannot be done @@ -86,23 +79,3 @@ func DecodeContainerConfig(src io.Reader) (*container.Config, *container.HostCon return w.Config, hc, w.NetworkingConfig, nil } - -// validateMountSettings validates each of the volumes and bind settings -// passed by the caller to ensure they are valid. -func validateMountSettings(c *container.Config, hc *container.HostConfig) error { - // it is ok to have len(hc.Mounts) > 0 && (len(hc.Binds) > 0 || len (c.Volumes) > 0 || len (hc.Tmpfs) > 0 ) - - // Ensure all volumes and binds are valid. - for spec := range c.Volumes { - if _, err := volume.ParseMountRaw(spec, hc.VolumeDriver); err != nil { - return fmt.Errorf("invalid volume spec %q: %v", spec, err) - } - } - for _, spec := range hc.Binds { - if _, err := volume.ParseMountRaw(spec, hc.VolumeDriver); err != nil { - return fmt.Errorf("invalid bind mount spec %q: %v", spec, err) - } - } - - return nil -} diff --git a/vendor/github.com/docker/docker/runconfig/config_test.go b/vendor/github.com/docker/docker/runconfig/config_test.go index 83ec363a0..0a4ee1fa2 100644 --- a/vendor/github.com/docker/docker/runconfig/config_test.go +++ b/vendor/github.com/docker/docker/runconfig/config_test.go @@ -12,6 +12,8 @@ import ( "github.com/docker/docker/api/types/container" networktypes "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/strslice" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) type f struct { @@ -51,7 +53,7 @@ func TestDecodeContainerConfig(t *testing.T) { t.Fatal(err) } - c, h, _, err := DecodeContainerConfig(bytes.NewReader(b)) + c, h, _, err := decodeContainerConfig(bytes.NewReader(b)) if err != nil { t.Fatal(fmt.Errorf("Error parsing %s: %v", f, err)) } @@ -135,5 +137,59 @@ func callDecodeContainerConfigIsolation(isolation string) (*container.Config, *c if b, err = json.Marshal(w); err != nil { return nil, nil, nil, fmt.Errorf("Error on marshal %s", err.Error()) } - return DecodeContainerConfig(bytes.NewReader(b)) + return decodeContainerConfig(bytes.NewReader(b)) +} + +type decodeConfigTestcase struct { + doc string + wrapper ContainerConfigWrapper + expectedErr string + expectedConfig *container.Config + expectedHostConfig *container.HostConfig + goos string +} + +func runDecodeContainerConfigTestCase(testcase decodeConfigTestcase) func(t *testing.T) { + return func(t *testing.T) { + raw := marshal(t, testcase.wrapper, testcase.doc) + config, hostConfig, _, err := decodeContainerConfig(bytes.NewReader(raw)) + if testcase.expectedErr != "" { + if !assert.Error(t, err) { + return + } + assert.Contains(t, err.Error(), testcase.expectedErr) + return + } + assert.NoError(t, err) + assert.Equal(t, testcase.expectedConfig, config) + assert.Equal(t, testcase.expectedHostConfig, hostConfig) + } +} + +func marshal(t *testing.T, w ContainerConfigWrapper, doc string) []byte { + b, err := json.Marshal(w) + require.NoError(t, err, "%s: failed to encode config wrapper", doc) + return b +} + +func containerWrapperWithVolume(volume string) ContainerConfigWrapper { + return ContainerConfigWrapper{ + Config: &container.Config{ + Volumes: map[string]struct{}{ + volume: {}, + }, + }, + HostConfig: &container.HostConfig{}, + } +} + +func containerWrapperWithBind(bind string) ContainerConfigWrapper { + return ContainerConfigWrapper{ + Config: &container.Config{ + Volumes: map[string]struct{}{}, + }, + HostConfig: &container.HostConfig{ + Binds: []string{bind}, + }, + } } diff --git a/vendor/github.com/docker/docker/runconfig/errors.go b/vendor/github.com/docker/docker/runconfig/errors.go index c95a2919e..78b0a8817 100644 --- a/vendor/github.com/docker/docker/runconfig/errors.go +++ b/vendor/github.com/docker/docker/runconfig/errors.go @@ -1,38 +1,42 @@ package runconfig -import ( - "fmt" -) - -var ( +const ( // ErrConflictContainerNetworkAndLinks conflict between --net=container and links - ErrConflictContainerNetworkAndLinks = fmt.Errorf("conflicting options: container type network can't be used with links. This would result in undefined behavior") + ErrConflictContainerNetworkAndLinks validationError = "conflicting options: container type network can't be used with links. This would result in undefined behavior" // ErrConflictSharedNetwork conflict between private and other networks - ErrConflictSharedNetwork = fmt.Errorf("container sharing network namespace with another container or host cannot be connected to any other network") + ErrConflictSharedNetwork validationError = "container sharing network namespace with another container or host cannot be connected to any other network" // ErrConflictHostNetwork conflict from being disconnected from host network or connected to host network. - ErrConflictHostNetwork = fmt.Errorf("container cannot be disconnected from host network or connected to host network") + ErrConflictHostNetwork validationError = "container cannot be disconnected from host network or connected to host network" // ErrConflictNoNetwork conflict between private and other networks - ErrConflictNoNetwork = fmt.Errorf("container cannot be connected to multiple networks with one of the networks in private (none) mode") + ErrConflictNoNetwork validationError = "container cannot be connected to multiple networks with one of the networks in private (none) mode" // ErrConflictNetworkAndDNS conflict between --dns and the network mode - ErrConflictNetworkAndDNS = fmt.Errorf("conflicting options: dns and the network mode") + ErrConflictNetworkAndDNS validationError = "conflicting options: dns and the network mode" // ErrConflictNetworkHostname conflict between the hostname and the network mode - ErrConflictNetworkHostname = fmt.Errorf("conflicting options: hostname and the network mode") + ErrConflictNetworkHostname validationError = "conflicting options: hostname and the network mode" // ErrConflictHostNetworkAndLinks conflict between --net=host and links - ErrConflictHostNetworkAndLinks = fmt.Errorf("conflicting options: host type networking can't be used with links. This would result in undefined behavior") + ErrConflictHostNetworkAndLinks validationError = "conflicting options: host type networking can't be used with links. This would result in undefined behavior" // ErrConflictContainerNetworkAndMac conflict between the mac address and the network mode - ErrConflictContainerNetworkAndMac = fmt.Errorf("conflicting options: mac-address and the network mode") + ErrConflictContainerNetworkAndMac validationError = "conflicting options: mac-address and the network mode" // ErrConflictNetworkHosts conflict between add-host and the network mode - ErrConflictNetworkHosts = fmt.Errorf("conflicting options: custom host-to-IP mapping and the network mode") + ErrConflictNetworkHosts validationError = "conflicting options: custom host-to-IP mapping and the network mode" // ErrConflictNetworkPublishPorts conflict between the publish options and the network mode - ErrConflictNetworkPublishPorts = fmt.Errorf("conflicting options: port publishing and the container type network mode") + ErrConflictNetworkPublishPorts validationError = "conflicting options: port publishing and the container type network mode" // ErrConflictNetworkExposePorts conflict between the expose option and the network mode - ErrConflictNetworkExposePorts = fmt.Errorf("conflicting options: port exposing and the container type network mode") + ErrConflictNetworkExposePorts validationError = "conflicting options: port exposing and the container type network mode" // ErrUnsupportedNetworkAndIP conflict between network mode and requested ip address - ErrUnsupportedNetworkAndIP = fmt.Errorf("user specified IP address is supported on user defined networks only") + ErrUnsupportedNetworkAndIP validationError = "user specified IP address is supported on user defined networks only" // ErrUnsupportedNetworkNoSubnetAndIP conflict between network with no configured subnet and requested ip address - ErrUnsupportedNetworkNoSubnetAndIP = fmt.Errorf("user specified IP address is supported only when connecting to networks with user configured subnets") + ErrUnsupportedNetworkNoSubnetAndIP validationError = "user specified IP address is supported only when connecting to networks with user configured subnets" // ErrUnsupportedNetworkAndAlias conflict between network mode and alias - ErrUnsupportedNetworkAndAlias = fmt.Errorf("network-scoped alias is supported only for containers in user defined networks") + ErrUnsupportedNetworkAndAlias validationError = "network-scoped alias is supported only for containers in user defined networks" // ErrConflictUTSHostname conflict between the hostname and the UTS mode - ErrConflictUTSHostname = fmt.Errorf("conflicting options: hostname and the UTS mode") + ErrConflictUTSHostname validationError = "conflicting options: hostname and the UTS mode" ) + +type validationError string + +func (e validationError) Error() string { + return string(e) +} + +func (e validationError) InvalidParameter() {} diff --git a/vendor/github.com/docker/docker/runconfig/hostconfig.go b/vendor/github.com/docker/docker/runconfig/hostconfig.go index 24aed1935..cfc5383f0 100644 --- a/vendor/github.com/docker/docker/runconfig/hostconfig.go +++ b/vendor/github.com/docker/docker/runconfig/hostconfig.go @@ -2,7 +2,6 @@ package runconfig import ( "encoding/json" - "fmt" "io" "strings" @@ -11,7 +10,7 @@ import ( // DecodeHostConfig creates a HostConfig based on the specified Reader. // It assumes the content of the reader will be JSON, and decodes it. -func DecodeHostConfig(src io.Reader) (*container.HostConfig, error) { +func decodeHostConfig(src io.Reader) (*container.HostConfig, error) { decoder := json.NewDecoder(src) var w ContainerConfigWrapper @@ -45,7 +44,7 @@ func validateNetContainerMode(c *container.Config, hc *container.HostConfig) err parts := strings.Split(string(hc.NetworkMode), ":") if parts[0] == "container" { if len(parts) < 2 || parts[1] == "" { - return fmt.Errorf("Invalid network mode: invalid container format container:") + return validationError("Invalid network mode: invalid container format container:") } } @@ -69,7 +68,7 @@ func validateNetContainerMode(c *container.Config, hc *container.HostConfig) err return ErrConflictContainerNetworkAndMac } - if hc.NetworkMode.IsContainer() && (len(hc.PortBindings) > 0 || hc.PublishAllPorts == true) { + if hc.NetworkMode.IsContainer() && (len(hc.PortBindings) > 0 || hc.PublishAllPorts) { return ErrConflictNetworkPublishPorts } diff --git a/vendor/github.com/docker/docker/runconfig/hostconfig_test.go b/vendor/github.com/docker/docker/runconfig/hostconfig_test.go index a6a3eef7c..76c3fa2ce 100644 --- a/vendor/github.com/docker/docker/runconfig/hostconfig_test.go +++ b/vendor/github.com/docker/docker/runconfig/hostconfig_test.go @@ -10,6 +10,7 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/pkg/sysinfo" + "github.com/stretchr/testify/assert" ) // TODO Windows: This will need addressing for a Windows daemon. @@ -61,43 +62,33 @@ func TestNetworkModeTest(t *testing.T) { } func TestIpcModeTest(t *testing.T) { - ipcModes := map[container.IpcMode][]bool{ - // private, host, container, valid - "": {true, false, false, true}, - "something:weird": {true, false, false, false}, - ":weird": {true, false, false, true}, - "host": {false, true, false, true}, - "container:name": {false, false, true, true}, - "container:name:something": {false, false, true, false}, - "container:": {false, false, true, false}, + ipcModes := map[container.IpcMode]struct { + private bool + host bool + container bool + shareable bool + valid bool + ctrName string + }{ + "": {valid: true}, + "private": {private: true, valid: true}, + "something:weird": {}, + ":weird": {}, + "host": {host: true, valid: true}, + "container": {}, + "container:": {container: true, valid: true, ctrName: ""}, + "container:name": {container: true, valid: true, ctrName: "name"}, + "container:name1:name2": {container: true, valid: true, ctrName: "name1:name2"}, + "shareable": {shareable: true, valid: true}, } + for ipcMode, state := range ipcModes { - if ipcMode.IsPrivate() != state[0] { - t.Fatalf("IpcMode.IsPrivate for %v should have been %v but was %v", ipcMode, state[0], ipcMode.IsPrivate()) - } - if ipcMode.IsHost() != state[1] { - t.Fatalf("IpcMode.IsHost for %v should have been %v but was %v", ipcMode, state[1], ipcMode.IsHost()) - } - if ipcMode.IsContainer() != state[2] { - t.Fatalf("IpcMode.IsContainer for %v should have been %v but was %v", ipcMode, state[2], ipcMode.IsContainer()) - } - if ipcMode.Valid() != state[3] { - t.Fatalf("IpcMode.Valid for %v should have been %v but was %v", ipcMode, state[3], ipcMode.Valid()) - } - } - containerIpcModes := map[container.IpcMode]string{ - "": "", - "something": "", - "something:weird": "weird", - "container": "", - "container:": "", - "container:name": "name", - "container:name1:name2": "name1:name2", - } - for ipcMode, container := range containerIpcModes { - if ipcMode.Container() != container { - t.Fatalf("Expected %v for %v but was %v", container, ipcMode, ipcMode.Container()) - } + assert.Equal(t, state.private, ipcMode.IsPrivate(), "IpcMode.IsPrivate() parsing failed for %q", ipcMode) + assert.Equal(t, state.host, ipcMode.IsHost(), "IpcMode.IsHost() parsing failed for %q", ipcMode) + assert.Equal(t, state.container, ipcMode.IsContainer(), "IpcMode.IsContainer() parsing failed for %q", ipcMode) + assert.Equal(t, state.shareable, ipcMode.IsShareable(), "IpcMode.IsShareable() parsing failed for %q", ipcMode) + assert.Equal(t, state.valid, ipcMode.Valid(), "IpcMode.Valid() parsing failed for %q", ipcMode) + assert.Equal(t, state.ctrName, ipcMode.Container(), "IpcMode.Container() parsing failed for %q", ipcMode) } } @@ -199,14 +190,12 @@ func TestDecodeHostConfig(t *testing.T) { t.Fatal(err) } - c, err := DecodeHostConfig(bytes.NewReader(b)) + c, err := decodeHostConfig(bytes.NewReader(b)) if err != nil { t.Fatal(fmt.Errorf("Error parsing %s: %v", f, err)) } - if c.Privileged != false { - t.Fatalf("Expected privileged false, found %v\n", c.Privileged) - } + assert.False(t, c.Privileged) if l := len(c.Binds); l != 1 { t.Fatalf("Expected 1 bind, found %d\n", l) diff --git a/vendor/github.com/docker/docker/vendor.conf b/vendor/github.com/docker/docker/vendor.conf index 7608b0e33..e90550db3 100644 --- a/vendor/github.com/docker/docker/vendor.conf +++ b/vendor/github.com/docker/docker/vendor.conf @@ -1,33 +1,36 @@ # the following lines are in sorted order, FYI github.com/Azure/go-ansiterm 19f72df4d05d31cbe1c56bfc8045c96babff6c7e -github.com/Microsoft/hcsshim v0.6.2 -github.com/Microsoft/go-winio v0.4.4 +github.com/Microsoft/hcsshim v0.6.5 +github.com/Microsoft/go-winio v0.4.5 github.com/moby/buildkit da2b9dc7dab99e824b2b1067ad7d0523e32dd2d9 https://github.com/dmcgowan/buildkit.git github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76 github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git github.com/gorilla/context v1.1 github.com/gorilla/mux v1.1 -github.com/jhowardmsft/opengcs v0.0.12 +github.com/Microsoft/opengcs v0.3.4 github.com/kr/pty 5cf931ef8f github.com/mattn/go-shellwords v1.0.3 -github.com/sirupsen/logrus v1.0.1 +github.com/sirupsen/logrus v1.0.3 github.com/tchap/go-patricia v2.2.6 github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3 golang.org/x/net 7dcfb8076726a3fdd9353b6b8a1f1b6be6811bd6 -golang.org/x/sys 739734461d1c916b6c72a63d7efda2b27edb369f +golang.org/x/sys 07c182904dbd53199946ba614a412c61d3c548f5 github.com/docker/go-units 9e638d38cf6977a37a8ea0078f3ee75a7cdb2dd1 github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d golang.org/x/text f72d8390a633d5dfb0cc84043294db9f6c935756 github.com/stretchr/testify 4d4bfba8f1d1027c4fdbe371823030df51419987 github.com/pmezard/go-difflib v1.0.0 +github.com/gotestyourself/gotestyourself v1.1.0 github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5 github.com/imdario/mergo 0.2.1 golang.org/x/sync de49d9dcd27d4f764488181bea099dfe6179bcf0 +github.com/containerd/continuity 22694c680ee48fb8f50015b44618517e2bde77e8 + #get libnetwork packages -github.com/docker/libnetwork 248fd5ea6a67f8810da322e6e7441e8de96a9045 https://github.com/dmcgowan/libnetwork.git +github.com/docker/libnetwork 60e002dd61885e1cd909582f00f7eb4da634518a github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec @@ -62,9 +65,9 @@ github.com/pborman/uuid v1.0 google.golang.org/grpc v1.3.0 # When updating, also update RUNC_COMMIT in hack/dockerfile/binaries-commits accordingly -github.com/opencontainers/runc e9325d442f5979c4f79bfa9e09bdf7abb74ba03b https://github.com/dmcgowan/runc.git +github.com/opencontainers/runc 1c81e2a794c6e26a4c650142ae8893c47f619764 github.com/opencontainers/image-spec 372ad780f63454fbbbbcc7cf80e5b90245c13e13 -github.com/opencontainers/runtime-spec d42f1eb741e6361e858d83fc75aa6893b66292c4 # specs +github.com/opencontainers/runtime-spec v1.0.0 github.com/seccomp/libseccomp-golang 32f571b70023028bd57d9288c20efbcb237f3ce0 @@ -101,17 +104,17 @@ github.com/googleapis/gax-go da06d194a00e19ce00d9011a13931c3f6f6887c7 google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944 # containerd -github.com/containerd/containerd fc10004571bb9b26695ccbf2dd4a83213f60b93e https://github.com/dmcgowan/containerd.git +github.com/containerd/containerd 06b9cb35161009dcb7123345749fef02f7cea8e0 github.com/tonistiigi/fifo 1405643975692217d6720f8b54aeee1bf2cd5cf4 github.com/stevvooe/continuity cd7a8e21e2b6f84799f5dd4b65faf49c8d3ee02d github.com/tonistiigi/fsutil 0ac4c11b053b9c5c7c47558f81f96c7100ce50fb # cluster -github.com/docker/swarmkit 8bdecc57887ffc598b63d6433f58e0d2852112c3 https://github.com/dmcgowan/swarmkit.git +github.com/docker/swarmkit bd7bafb8a61de1f5f23c8215ce7b9ecbcb30ff21 github.com/gogo/protobuf v0.4 github.com/cloudflare/cfssl 7fb22c8cba7ecaf98e4082d22d65800cf45e042a github.com/google/certificate-transparency d90e65c3a07988180c5b1ece71791c0b6506826e -golang.org/x/crypto 3fbbcd23f1cb824e69491a5930cfeff09b12f4d2 +golang.org/x/crypto 558b6879de74bc843225cde5686419267ff707ca golang.org/x/time a4bde12657593d5e90d0533a3e4fd95e635124cb github.com/hashicorp/go-memdb cb9a474f84cc5e41b273b20c6927680b2a8776ad github.com/hashicorp/go-immutable-radix 8e8ed81f8f0bf1bdd829593fdd5c29922c1ea990 diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/backup.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/backup.go index 27d6ace0c..2be34af43 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/backup.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/backup.go @@ -68,10 +68,20 @@ func NewBackupStreamReader(r io.Reader) *BackupStreamReader { return &BackupStreamReader{r, 0} } -// Next returns the next backup stream and prepares for calls to Write(). It skips the remainder of the current stream if +// Next returns the next backup stream and prepares for calls to Read(). It skips the remainder of the current stream if // it was not completely read. func (r *BackupStreamReader) Next() (*BackupHeader, error) { if r.bytesLeft > 0 { + if s, ok := r.r.(io.Seeker); ok { + // Make sure Seek on io.SeekCurrent sometimes succeeds + // before trying the actual seek. + if _, err := s.Seek(0, io.SeekCurrent); err == nil { + if _, err = s.Seek(r.bytesLeft, io.SeekCurrent); err != nil { + return nil, err + } + r.bytesLeft = 0 + } + } if _, err := io.Copy(ioutil.Discard, r); err != nil { return nil, err } @@ -220,7 +230,7 @@ type BackupFileWriter struct { ctx uintptr } -// NewBackupFileWrtier returns a new BackupFileWriter from a file handle. If includeSecurity is true, +// NewBackupFileWriter returns a new BackupFileWriter from a file handle. If includeSecurity is true, // Write() will attempt to restore the security descriptor from the stream. func NewBackupFileWriter(f *os.File, includeSecurity bool) *BackupFileWriter { w := &BackupFileWriter{f, includeSecurity, 0} diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/backuptar/tar.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/backuptar/tar.go index cfbcedfe0..53da908f1 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/backuptar/tar.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/backuptar/tar.go @@ -36,6 +36,7 @@ const ( hdrSecurityDescriptor = "sd" hdrRawSecurityDescriptor = "rawsd" hdrMountPoint = "mountpoint" + hdrEaPrefix = "xattr." ) func writeZeroes(w io.Writer, count int64) error { @@ -118,6 +119,21 @@ func BasicInfoHeader(name string, size int64, fileInfo *winio.FileBasicInfo) *ta func WriteTarFileFromBackupStream(t *tar.Writer, r io.Reader, name string, size int64, fileInfo *winio.FileBasicInfo) error { name = filepath.ToSlash(name) hdr := BasicInfoHeader(name, size, fileInfo) + + // If r can be seeked, then this function is two-pass: pass 1 collects the + // tar header data, and pass 2 copies the data stream. If r cannot be + // seeked, then some header data (in particular EAs) will be silently lost. + var ( + restartPos int64 + err error + ) + sr, readTwice := r.(io.Seeker) + if readTwice { + if restartPos, err = sr.Seek(0, io.SeekCurrent); err != nil { + readTwice = false + } + } + br := winio.NewBackupStreamReader(r) var dataHdr *winio.BackupHeader for dataHdr == nil { @@ -131,7 +147,9 @@ func WriteTarFileFromBackupStream(t *tar.Writer, r io.Reader, name string, size switch bhdr.Id { case winio.BackupData: hdr.Mode |= c_ISREG - dataHdr = bhdr + if !readTwice { + dataHdr = bhdr + } case winio.BackupSecurity: sd, err := ioutil.ReadAll(br) if err != nil { @@ -151,18 +169,54 @@ func WriteTarFileFromBackupStream(t *tar.Writer, r io.Reader, name string, size hdr.Winheaders[hdrMountPoint] = "1" } hdr.Linkname = rp.Target - case winio.BackupEaData, winio.BackupLink, winio.BackupPropertyData, winio.BackupObjectId, winio.BackupTxfsData: + + case winio.BackupEaData: + eab, err := ioutil.ReadAll(br) + if err != nil { + return err + } + eas, err := winio.DecodeExtendedAttributes(eab) + if err != nil { + return err + } + for _, ea := range eas { + // Use base64 encoding for the binary value. Note that there + // is no way to encode the EA's flags, since their use doesn't + // make any sense for persisted EAs. + hdr.Winheaders[hdrEaPrefix+ea.Name] = base64.StdEncoding.EncodeToString(ea.Value) + } + + case winio.BackupAlternateData, winio.BackupLink, winio.BackupPropertyData, winio.BackupObjectId, winio.BackupTxfsData: // ignore these streams default: return fmt.Errorf("%s: unknown stream ID %d", name, bhdr.Id) } } - err := t.WriteHeader(hdr) + err = t.WriteHeader(hdr) if err != nil { return err } + if readTwice { + // Get back to the data stream. + if _, err = sr.Seek(restartPos, io.SeekStart); err != nil { + return err + } + for dataHdr == nil { + bhdr, err := br.Next() + if err == io.EOF { + break + } + if err != nil { + return err + } + if bhdr.Id == winio.BackupData { + dataHdr = bhdr + } + } + } + if dataHdr != nil { // A data stream was found. Copy the data. if (dataHdr.Attributes & winio.StreamSparseAttributes) == 0 { @@ -293,6 +347,38 @@ func WriteBackupStreamFromTarFile(w io.Writer, t *tar.Reader, hdr *tar.Header) ( return nil, err } } + var eas []winio.ExtendedAttribute + for k, v := range hdr.Winheaders { + if !strings.HasPrefix(k, hdrEaPrefix) { + continue + } + data, err := base64.StdEncoding.DecodeString(v) + if err != nil { + return nil, err + } + eas = append(eas, winio.ExtendedAttribute{ + Name: k[len(hdrEaPrefix):], + Value: data, + }) + } + if len(eas) != 0 { + eadata, err := winio.EncodeExtendedAttributes(eas) + if err != nil { + return nil, err + } + bhdr := winio.BackupHeader{ + Id: winio.BackupEaData, + Size: int64(len(eadata)), + } + err = bw.WriteHeader(&bhdr) + if err != nil { + return nil, err + } + _, err = bw.Write(eadata) + if err != nil { + return nil, err + } + } if hdr.Typeflag == tar.TypeSymlink { _, isMountPoint := hdr.Winheaders[hdrMountPoint] rp := winio.ReparsePoint{ diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/ea.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/ea.go new file mode 100644 index 000000000..4051c1b33 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/ea.go @@ -0,0 +1,137 @@ +package winio + +import ( + "bytes" + "encoding/binary" + "errors" +) + +type fileFullEaInformation struct { + NextEntryOffset uint32 + Flags uint8 + NameLength uint8 + ValueLength uint16 +} + +var ( + fileFullEaInformationSize = binary.Size(&fileFullEaInformation{}) + + errInvalidEaBuffer = errors.New("invalid extended attribute buffer") + errEaNameTooLarge = errors.New("extended attribute name too large") + errEaValueTooLarge = errors.New("extended attribute value too large") +) + +// ExtendedAttribute represents a single Windows EA. +type ExtendedAttribute struct { + Name string + Value []byte + Flags uint8 +} + +func parseEa(b []byte) (ea ExtendedAttribute, nb []byte, err error) { + var info fileFullEaInformation + err = binary.Read(bytes.NewReader(b), binary.LittleEndian, &info) + if err != nil { + err = errInvalidEaBuffer + return + } + + nameOffset := fileFullEaInformationSize + nameLen := int(info.NameLength) + valueOffset := nameOffset + int(info.NameLength) + 1 + valueLen := int(info.ValueLength) + nextOffset := int(info.NextEntryOffset) + if valueLen+valueOffset > len(b) || nextOffset < 0 || nextOffset > len(b) { + err = errInvalidEaBuffer + return + } + + ea.Name = string(b[nameOffset : nameOffset+nameLen]) + ea.Value = b[valueOffset : valueOffset+valueLen] + ea.Flags = info.Flags + if info.NextEntryOffset != 0 { + nb = b[info.NextEntryOffset:] + } + return +} + +// DecodeExtendedAttributes decodes a list of EAs from a FILE_FULL_EA_INFORMATION +// buffer retrieved from BackupRead, ZwQueryEaFile, etc. +func DecodeExtendedAttributes(b []byte) (eas []ExtendedAttribute, err error) { + for len(b) != 0 { + ea, nb, err := parseEa(b) + if err != nil { + return nil, err + } + + eas = append(eas, ea) + b = nb + } + return +} + +func writeEa(buf *bytes.Buffer, ea *ExtendedAttribute, last bool) error { + if int(uint8(len(ea.Name))) != len(ea.Name) { + return errEaNameTooLarge + } + if int(uint16(len(ea.Value))) != len(ea.Value) { + return errEaValueTooLarge + } + entrySize := uint32(fileFullEaInformationSize + len(ea.Name) + 1 + len(ea.Value)) + withPadding := (entrySize + 3) &^ 3 + nextOffset := uint32(0) + if !last { + nextOffset = withPadding + } + info := fileFullEaInformation{ + NextEntryOffset: nextOffset, + Flags: ea.Flags, + NameLength: uint8(len(ea.Name)), + ValueLength: uint16(len(ea.Value)), + } + + err := binary.Write(buf, binary.LittleEndian, &info) + if err != nil { + return err + } + + _, err = buf.Write([]byte(ea.Name)) + if err != nil { + return err + } + + err = buf.WriteByte(0) + if err != nil { + return err + } + + _, err = buf.Write(ea.Value) + if err != nil { + return err + } + + _, err = buf.Write([]byte{0, 0, 0}[0 : withPadding-entrySize]) + if err != nil { + return err + } + + return nil +} + +// EncodeExtendedAttributes encodes a list of EAs into a FILE_FULL_EA_INFORMATION +// buffer for use with BackupWrite, ZwSetEaFile, etc. +func EncodeExtendedAttributes(eas []ExtendedAttribute) ([]byte, error) { + var buf bytes.Buffer + for i := range eas { + last := false + if i == len(eas)-1 { + last = true + } + + err := writeEa(&buf, &eas[i], last) + if err != nil { + return nil, err + } + } + return buf.Bytes(), nil +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/file.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/file.go index 2a311d1f2..57ac3696a 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/file.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/file.go @@ -78,6 +78,7 @@ func initIo() { type win32File struct { handle syscall.Handle wg sync.WaitGroup + wgLock sync.RWMutex closing atomicBool readDeadline deadlineHandler writeDeadline deadlineHandler @@ -114,14 +115,18 @@ func MakeOpenFile(h syscall.Handle) (io.ReadWriteCloser, error) { // closeHandle closes the resources associated with a Win32 handle func (f *win32File) closeHandle() { + f.wgLock.Lock() // Atomically set that we are closing, releasing the resources only once. if !f.closing.swap(true) { + f.wgLock.Unlock() // cancel all IO and wait for it to complete cancelIoEx(f.handle, nil) f.wg.Wait() // at this point, no new IO can start syscall.Close(f.handle) f.handle = 0 + } else { + f.wgLock.Unlock() } } @@ -134,10 +139,13 @@ func (f *win32File) Close() error { // prepareIo prepares for a new IO operation. // The caller must call f.wg.Done() when the IO is finished, prior to Close() returning. func (f *win32File) prepareIo() (*ioOperation, error) { + f.wgLock.RLock() if f.closing.isSet() { + f.wgLock.RUnlock() return nil, ErrFileClosed } f.wg.Add(1) + f.wgLock.RUnlock() c := &ioOperation{} c.ch = make(chan ioResult) return c, nil diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/pipe.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/pipe.go index da706cc8a..44340b816 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/pipe.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/pipe.go @@ -265,9 +265,9 @@ func (l *win32PipeListener) listenerRoutine() { if err == nil { // Wait for the client to connect. ch := make(chan error) - go func() { + go func(p *win32File) { ch <- connectPipe(p) - }() + }(p) select { case err = <-ch: if err != nil { diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/container.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/container.go index b924d39f4..3354f70ef 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/container.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/container.go @@ -201,12 +201,18 @@ func createContainerWithJSON(id string, c *ContainerConfig, additionalJSON strin if createError == nil || IsPending(createError) { if err := container.registerCallback(); err != nil { + // Terminate the container if it still exists. We're okay to ignore a failure here. + container.Terminate() return nil, makeContainerError(container, operation, "", err) } } err = processAsyncHcsResult(createError, resultp, container.callbackNumber, hcsNotificationSystemCreateCompleted, &defaultTimeout) if err != nil { + if err == ErrTimeout { + // Terminate the container if it still exists. We're okay to ignore a failure here. + container.Terminate() + } return nil, makeContainerError(container, operation, configuration, err) } diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/hnspolicylist.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/hnspolicylist.go index 15653b4f4..bbd7e1edb 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/hnspolicylist.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/hnspolicylist.go @@ -139,16 +139,20 @@ func (policylist *PolicyList) RemoveEndpoint(endpoint *HNSEndpoint) (*PolicyList } // AddLoadBalancer policy list for the specified endpoints -func AddLoadBalancer(endpoints []HNSEndpoint, isILB bool, vip string, protocol uint16, internalPort uint16, externalPort uint16) (*PolicyList, error) { +func AddLoadBalancer(endpoints []HNSEndpoint, isILB bool, sourceVIP, vip string, protocol uint16, internalPort uint16, externalPort uint16) (*PolicyList, error) { operation := "AddLoadBalancer" title := "HCSShim::PolicyList::" + operation - logrus.Debugf(title+" Vip:%s", vip) + logrus.Debugf(title+" endpointId=%v, isILB=%v, sourceVIP=%s, vip=%s, protocol=%v, internalPort=%v, externalPort=%v", endpoints, isILB, sourceVIP, vip, protocol, internalPort, externalPort) policylist := &PolicyList{} elbPolicy := &ELBPolicy{ - VIPs: []string{vip}, - ILB: isILB, + SourceVIP: sourceVIP, + ILB: isILB, + } + + if len(vip) > 0 { + elbPolicy.VIPs = []string{vip} } elbPolicy.Type = ExternalLoadBalancer elbPolicy.Protocol = protocol diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/interface.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/interface.go index 9fc7852e4..e21f30025 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/interface.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/interface.go @@ -30,11 +30,12 @@ type Layer struct { } type MappedDir struct { - HostPath string - ContainerPath string - ReadOnly bool - BandwidthMaximum uint64 - IOPSMaximum uint64 + HostPath string + ContainerPath string + ReadOnly bool + BandwidthMaximum uint64 + IOPSMaximum uint64 + CreateInUtilityVM bool } type MappedPipe struct { diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/LICENSE b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/LICENSE new file mode 100644 index 000000000..21071075c --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. All rights reserved. + + 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 diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/README.md b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/README.md new file mode 100644 index 000000000..ab096bbb8 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/README.md @@ -0,0 +1,14 @@ + +# Open Guest Compute Service (opengcs) [![Build Status](https://travis-ci.org/Microsoft/opengcs.svg?branch=master)](https://travis-ci.org/Microsoft/opengcs) + +Open Guest Compute Service is a Linux open source project to further the development of a production quality implementation of Linux Hyper-V container on Windows (LCOW). It's designed to run inside a custom Linux OS for supporting Linux container payload. + +# Getting Started + + [How to build GCS binaries](./docs/gcsbuildinstructions.md/) + + [How to build custom Linux OS images](./docs/customosbuildinstructions.md/) + +# Contributing + +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. diff --git a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/config.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/config.go similarity index 96% rename from vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/config.go rename to vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/config.go index 141b77f20..5ece88b91 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/config.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/config.go @@ -93,10 +93,10 @@ func ParseOptions(options []string) (Options, error) { case "lcow.timeout": var err error if rOpts.TimeoutSeconds, err = strconv.Atoi(opt[1]); err != nil { - return rOpts, fmt.Errorf("opengcstimeoutsecs option could not be interpreted as an integer") + return rOpts, fmt.Errorf("lcow.timeout option could not be interpreted as an integer") } if rOpts.TimeoutSeconds < 0 { - return rOpts, fmt.Errorf("opengcstimeoutsecs option cannot be negative") + return rOpts, fmt.Errorf("lcow.timeout option cannot be negative") } } } @@ -157,6 +157,9 @@ func (config *Config) GenerateDefault(options []string) error { // Last priority is the default timeout config.UvmTimeoutSeconds = defaultUvmTimeoutSeconds + // Set the default requested mode + config.RequestedMode = ModeRequestAuto + return nil } @@ -237,7 +240,9 @@ func (config *Config) StartUtilityVM() error { if config.ActualMode == ModeActualVhdx { configuration.HvRuntime = &hcsshim.HvRuntime{ - ImagePath: config.Vhdx, + ImagePath: config.Vhdx, + BootSource: "Vhd", + WritableBootSource: false, } } else { configuration.HvRuntime = &hcsshim.HvRuntime{ diff --git a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/createext4vhdx.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/createext4vhdx.go similarity index 99% rename from vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/createext4vhdx.go rename to vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/createext4vhdx.go index b53ce2514..48daaeb04 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/createext4vhdx.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/createext4vhdx.go @@ -57,6 +57,8 @@ func (config *Config) CreateExt4Vhdx(destFile string, sizeGB uint32, cacheFile s return fmt.Errorf("failed to create VHDx %s: %s", destFile, err) } + defer config.DebugGCS() + // Attach it to the utility VM, but don't mount it (as there's no filesystem on it) if err := config.HotAddVhd(destFile, "", false, false); err != nil { return fmt.Errorf("opengcs: CreateExt4Vhdx: failed to hot-add %s to utility VM: %s", cacheFile, err) diff --git a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/hotaddvhd.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/hotaddvhd.go similarity index 97% rename from vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/hotaddvhd.go rename to vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/hotaddvhd.go index daf7c25f0..ef1e51fd6 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/hotaddvhd.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/hotaddvhd.go @@ -20,6 +20,8 @@ func (config *Config) HotAddVhd(hostPath string, containerPath string, readOnly return fmt.Errorf("cannot hot-add VHD as no utility VM is in configuration") } + defer config.DebugGCS() + modification := &hcsshim.ResourceModificationRequestResponse{ Resource: "MappedVirtualDisk", Data: hcsshim.MappedVirtualDisk{ diff --git a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/hotremovevhd.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/hotremovevhd.go similarity index 97% rename from vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/hotremovevhd.go rename to vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/hotremovevhd.go index cf1971244..be6318917 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/hotremovevhd.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/hotremovevhd.go @@ -18,6 +18,8 @@ func (config *Config) HotRemoveVhd(hostPath string) error { return fmt.Errorf("cannot hot-add VHD as no utility VM is in configuration") } + defer config.DebugGCS() + modification := &hcsshim.ResourceModificationRequestResponse{ Resource: "MappedVirtualDisk", Data: hcsshim.MappedVirtualDisk{ diff --git a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/layervhddetails.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/layervhddetails.go similarity index 100% rename from vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/layervhddetails.go rename to vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/layervhddetails.go diff --git a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/process.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/process.go similarity index 71% rename from vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/process.go rename to vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/process.go index 984a95a32..958fdb5d0 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/process.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/process.go @@ -3,8 +3,12 @@ package client import ( + "bytes" "fmt" "io" + "os" + "strings" + "time" "github.com/Microsoft/hcsshim" "github.com/sirupsen/logrus" @@ -110,3 +114,44 @@ func (config *Config) RunProcess(commandLine string, stdin io.Reader, stdout io. logrus.Debugf("opengcs: runProcess success: %s", commandLine) return process.Process, nil } + +func debugCommand(s string) string { + return fmt.Sprintf(`echo -e 'DEBUG COMMAND: %s\\n--------------\\n';%s;echo -e '\\n\\n';`, s, s) +} + +// DebugGCS extracts logs from the GCS. It's a useful hack for debugging, +// but not necessarily optimal, but all that is available to us in RS3. +func (config *Config) DebugGCS() { + if logrus.GetLevel() < logrus.DebugLevel || len(os.Getenv("OPENGCS_DEBUG_ENABLE")) == 0 { + return + } + + var out bytes.Buffer + cmd := os.Getenv("OPENGCS_DEBUG_COMMAND") + if cmd == "" { + cmd = `sh -c "` + cmd += debugCommand("ls -l /tmp") + cmd += debugCommand("cat /tmp/gcs.log") + cmd += debugCommand("ls -l /tmp/gcs") + cmd += debugCommand("ls -l /tmp/gcs/*") + cmd += debugCommand("cat /tmp/gcs/*/config.json") + cmd += debugCommand("ls -lR /var/run/gcsrunc") + cmd += debugCommand("cat /var/run/gcsrunc/log.log") + cmd += debugCommand("ps -ef") + cmd += `"` + } + proc, err := config.RunProcess(cmd, nil, &out, nil) + defer func() { + if proc != nil { + proc.Kill() + proc.Close() + } + }() + if err != nil { + logrus.Debugln("benign failure getting gcs logs: ", err) + } + if proc != nil { + proc.WaitTimeout(time.Duration(int(time.Second) * 30)) + } + logrus.Debugf("GCS Debugging:\n%s\n\nEnd GCS Debugging\n", strings.TrimSpace(out.String())) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/tartovhd.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/tartovhd.go similarity index 98% rename from vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/tartovhd.go rename to vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/tartovhd.go index 9aa6609d4..29ee48957 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/tartovhd.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/tartovhd.go @@ -17,6 +17,8 @@ func (config *Config) TarToVhd(targetVHDFile string, reader io.Reader) (int64, e return 0, fmt.Errorf("cannot Tar2Vhd as no utility VM is in configuration") } + defer config.DebugGCS() + process, err := config.createUtilsProcess("tar2vhd") if err != nil { return 0, fmt.Errorf("failed to start tar2vhd for %s: %s", targetVHDFile, err) diff --git a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/unsupported.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/unsupported.go similarity index 100% rename from vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/unsupported.go rename to vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/unsupported.go diff --git a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/utilities.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/utilities.go similarity index 100% rename from vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/utilities.go rename to vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/utilities.go diff --git a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/vhdtotar.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/vhdtotar.go similarity index 99% rename from vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/vhdtotar.go rename to vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/vhdtotar.go index 27225a71e..72e9a24ff 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/gogcs/client/vhdtotar.go +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/client/vhdtotar.go @@ -20,6 +20,8 @@ func (config *Config) VhdToTar(vhdFile string, uvmMountPath string, isSandbox bo return nil, fmt.Errorf("cannot VhdToTar as no utility VM is in configuration") } + defer config.DebugGCS() + vhdHandle, err := os.Open(vhdFile) if err != nil { return nil, fmt.Errorf("opengcs: VhdToTar: failed to open %s: %s", vhdFile, err) diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/README b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/README new file mode 100644 index 000000000..85e54428a --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/README @@ -0,0 +1,4 @@ +1. This program only runs in Linux. So you just first copy the files over to a Linux machine. +2. Get Go and and then run make get-deps && make. This is set the $GOPATH for you and build the binaries. +3. vhd_to_tar and tar_to_vhd are the standalone executables that read/write to stdin/out and do the tar <-> vhd conversion. + tar2vhd_server is the service VM server that takes client requests over hvsock. diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/defs.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/defs.go new file mode 100644 index 000000000..f1f2c04a4 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/defs.go @@ -0,0 +1,109 @@ +package remotefs + +import ( + "errors" + "os" + "time" +) + +// RemotefsCmd is the name of the remotefs meta command +const RemotefsCmd = "remotefs" + +// Name of the commands when called from the cli context (remotefs ...) +const ( + StatCmd = "stat" + LstatCmd = "lstat" + ReadlinkCmd = "readlink" + MkdirCmd = "mkdir" + MkdirAllCmd = "mkdirall" + RemoveCmd = "remove" + RemoveAllCmd = "removeall" + LinkCmd = "link" + SymlinkCmd = "symlink" + LchmodCmd = "lchmod" + LchownCmd = "lchown" + MknodCmd = "mknod" + MkfifoCmd = "mkfifo" + OpenFileCmd = "openfile" + ReadFileCmd = "readfile" + WriteFileCmd = "writefile" + ReadDirCmd = "readdir" + ResolvePathCmd = "resolvepath" + ExtractArchiveCmd = "extractarchive" + ArchivePathCmd = "archivepath" +) + +// ErrInvalid is returned if the parameters are invalid +var ErrInvalid = errors.New("invalid arguments") + +// ErrUnknown is returned for an unknown remotefs command +var ErrUnknown = errors.New("unkown command") + +// ExportedError is the serialized version of the a Go error. +// It also provides a trivial implementation of the error interface. +type ExportedError struct { + ErrString string + ErrNum int `json:",omitempty"` +} + +// Error returns an error string +func (ee *ExportedError) Error() string { + return ee.ErrString +} + +// FileInfo is the stat struct returned by the remotefs system. It +// fulfills the os.FileInfo interface. +type FileInfo struct { + NameVar string + SizeVar int64 + ModeVar os.FileMode + ModTimeVar int64 // Serialization of time.Time breaks in travis, so use an int + IsDirVar bool +} + +var _ os.FileInfo = &FileInfo{} + +// Name returns the filename from a FileInfo structure +func (f *FileInfo) Name() string { return f.NameVar } + +// Size returns the size from a FileInfo structure +func (f *FileInfo) Size() int64 { return f.SizeVar } + +// Mode returns the mode from a FileInfo structure +func (f *FileInfo) Mode() os.FileMode { return f.ModeVar } + +// ModTime returns the modification time from a FileInfo structure +func (f *FileInfo) ModTime() time.Time { return time.Unix(0, f.ModTimeVar) } + +// IsDir returns the is-directory indicator from a FileInfo structure +func (f *FileInfo) IsDir() bool { return f.IsDirVar } + +// Sys provides an interface to a FileInfo structure +func (f *FileInfo) Sys() interface{} { return nil } + +// FileHeader is a header for remote *os.File operations for remotefs.OpenFile +type FileHeader struct { + Cmd uint32 + Size uint64 +} + +const ( + // Read request command. + Read uint32 = iota + // Write request command. + Write + // Seek request command. + Seek + // Close request command. + Close + // CmdOK is a response meaning request succeeded. + CmdOK + // CmdFailed is a response meaning request failed. + CmdFailed +) + +// SeekHeader is header for the Seek operation for remotefs.OpenFile +type SeekHeader struct { + Offset int64 + Whence int32 +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/remotefs.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/remotefs.go new file mode 100644 index 000000000..2d4a9f2bf --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/remotefs.go @@ -0,0 +1,546 @@ +// +build !windows + +package remotefs + +import ( + "bytes" + "encoding/binary" + "encoding/json" + "io" + "os" + "path/filepath" + "strconv" + + "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/symlink" + "golang.org/x/sys/unix" +) + +// Func is the function definition for a generic remote fs function +// The input to the function is any serialized structs / data from in and the string slice +// from args. The output of the function will be serialized and written to out. +type Func func(stdin io.Reader, stdout io.Writer, args []string) error + +// Commands provide a string -> remotefs function mapping. +// This is useful for commandline programs that will receive a string +// as the function to execute. +var Commands = map[string]Func{ + StatCmd: Stat, + LstatCmd: Lstat, + ReadlinkCmd: Readlink, + MkdirCmd: Mkdir, + MkdirAllCmd: MkdirAll, + RemoveCmd: Remove, + RemoveAllCmd: RemoveAll, + LinkCmd: Link, + SymlinkCmd: Symlink, + LchmodCmd: Lchmod, + LchownCmd: Lchown, + MknodCmd: Mknod, + MkfifoCmd: Mkfifo, + OpenFileCmd: OpenFile, + ReadFileCmd: ReadFile, + WriteFileCmd: WriteFile, + ReadDirCmd: ReadDir, + ResolvePathCmd: ResolvePath, + ExtractArchiveCmd: ExtractArchive, + ArchivePathCmd: ArchivePath, +} + +// Stat functions like os.Stat. +// Args: +// - args[0] is the path +// Out: +// - out = FileInfo object +func Stat(in io.Reader, out io.Writer, args []string) error { + return stat(in, out, args, os.Stat) +} + +// Lstat functions like os.Lstat. +// Args: +// - args[0] is the path +// Out: +// - out = FileInfo object +func Lstat(in io.Reader, out io.Writer, args []string) error { + return stat(in, out, args, os.Lstat) +} + +func stat(in io.Reader, out io.Writer, args []string, statfunc func(string) (os.FileInfo, error)) error { + if len(args) < 1 { + return ErrInvalid + } + + fi, err := statfunc(args[0]) + if err != nil { + return err + } + + info := FileInfo{ + NameVar: fi.Name(), + SizeVar: fi.Size(), + ModeVar: fi.Mode(), + ModTimeVar: fi.ModTime().UnixNano(), + IsDirVar: fi.IsDir(), + } + + buf, err := json.Marshal(info) + if err != nil { + return err + } + + if _, err := out.Write(buf); err != nil { + return err + } + return nil +} + +// Readlink works like os.Readlink +// In: +// - args[0] is path +// Out: +// - Write link result to out +func Readlink(in io.Reader, out io.Writer, args []string) error { + if len(args) < 1 { + return ErrInvalid + } + + l, err := os.Readlink(args[0]) + if err != nil { + return err + } + + if _, err := out.Write([]byte(l)); err != nil { + return err + } + return nil +} + +// Mkdir works like os.Mkdir +// Args: +// - args[0] is the path +// - args[1] is the permissions in octal (like 0755) +func Mkdir(in io.Reader, out io.Writer, args []string) error { + return mkdir(in, out, args, os.Mkdir) +} + +// MkdirAll works like os.MkdirAll. +// Args: +// - args[0] is the path +// - args[1] is the permissions in octal (like 0755) +func MkdirAll(in io.Reader, out io.Writer, args []string) error { + return mkdir(in, out, args, os.MkdirAll) +} + +func mkdir(in io.Reader, out io.Writer, args []string, mkdirFunc func(string, os.FileMode) error) error { + if len(args) < 2 { + return ErrInvalid + } + + perm, err := strconv.ParseUint(args[1], 8, 32) + if err != nil { + return err + } + return mkdirFunc(args[0], os.FileMode(perm)) +} + +// Remove works like os.Remove +// Args: +// - args[0] is the path +func Remove(in io.Reader, out io.Writer, args []string) error { + return remove(in, out, args, os.Remove) +} + +// RemoveAll works like os.RemoveAll +// Args: +// - args[0] is the path +func RemoveAll(in io.Reader, out io.Writer, args []string) error { + return remove(in, out, args, os.RemoveAll) +} + +func remove(in io.Reader, out io.Writer, args []string, removefunc func(string) error) error { + if len(args) < 1 { + return ErrInvalid + } + return removefunc(args[0]) +} + +// Link works like os.Link +// Args: +// - args[0] = old path name (link source) +// - args[1] = new path name (link dest) +func Link(in io.Reader, out io.Writer, args []string) error { + return link(in, out, args, os.Link) +} + +// Symlink works like os.Symlink +// Args: +// - args[0] = old path name (link source) +// - args[1] = new path name (link dest) +func Symlink(in io.Reader, out io.Writer, args []string) error { + return link(in, out, args, os.Symlink) +} + +func link(in io.Reader, out io.Writer, args []string, linkfunc func(string, string) error) error { + if len(args) < 2 { + return ErrInvalid + } + return linkfunc(args[0], args[1]) +} + +// Lchmod changes permission of the given file without following symlinks +// Args: +// - args[0] = path +// - args[1] = permission mode in octal (like 0755) +func Lchmod(in io.Reader, out io.Writer, args []string) error { + if len(args) < 2 { + return ErrInvalid + } + + perm, err := strconv.ParseUint(args[1], 8, 32) + if err != nil { + return err + } + + path := args[0] + if !filepath.IsAbs(path) { + path, err = filepath.Abs(path) + if err != nil { + return err + } + } + return unix.Fchmodat(0, path, uint32(perm), unix.AT_SYMLINK_NOFOLLOW) +} + +// Lchown works like os.Lchown +// Args: +// - args[0] = path +// - args[1] = uid in base 10 +// - args[2] = gid in base 10 +func Lchown(in io.Reader, out io.Writer, args []string) error { + if len(args) < 3 { + return ErrInvalid + } + + uid, err := strconv.ParseInt(args[1], 10, 64) + if err != nil { + return err + } + + gid, err := strconv.ParseInt(args[2], 10, 64) + if err != nil { + return err + } + return os.Lchown(args[0], int(uid), int(gid)) +} + +// Mknod works like syscall.Mknod +// Args: +// - args[0] = path +// - args[1] = permission mode in octal (like 0755) +// - args[2] = major device number in base 10 +// - args[3] = minor device number in base 10 +func Mknod(in io.Reader, out io.Writer, args []string) error { + if len(args) < 4 { + return ErrInvalid + } + + perm, err := strconv.ParseUint(args[1], 8, 32) + if err != nil { + return err + } + + major, err := strconv.ParseInt(args[2], 10, 32) + if err != nil { + return err + } + + minor, err := strconv.ParseInt(args[3], 10, 32) + if err != nil { + return err + } + + dev := unix.Mkdev(uint32(major), uint32(minor)) + return unix.Mknod(args[0], uint32(perm), int(dev)) +} + +// Mkfifo creates a FIFO special file with the given path name and permissions +// Args: +// - args[0] = path +// - args[1] = permission mode in octal (like 0755) +func Mkfifo(in io.Reader, out io.Writer, args []string) error { + if len(args) < 2 { + return ErrInvalid + } + + perm, err := strconv.ParseUint(args[1], 8, 32) + if err != nil { + return err + } + return unix.Mkfifo(args[0], uint32(perm)) +} + +// OpenFile works like os.OpenFile. To manage the file pointer state, +// this function acts as a single file "file server" with Read/Write/Close +// being serialized control codes from in. +// Args: +// - args[0] = path +// - args[1] = flag in base 10 +// - args[2] = permission mode in octal (like 0755) +func OpenFile(in io.Reader, out io.Writer, args []string) (err error) { + defer func() { + if err != nil { + // error code will be serialized by the caller, so don't write it here + WriteFileHeader(out, &FileHeader{Cmd: CmdFailed}, nil) + } + }() + + if len(args) < 3 { + return ErrInvalid + } + + flag, err := strconv.ParseInt(args[1], 10, 32) + if err != nil { + return err + } + + perm, err := strconv.ParseUint(args[2], 8, 32) + if err != nil { + return err + } + + f, err := os.OpenFile(args[0], int(flag), os.FileMode(perm)) + if err != nil { + return err + } + + // Signal the client that OpenFile succeeded + if err := WriteFileHeader(out, &FileHeader{Cmd: CmdOK}, nil); err != nil { + return err + } + + for { + hdr, err := ReadFileHeader(in) + if err != nil { + return err + } + + var buf []byte + switch hdr.Cmd { + case Read: + buf = make([]byte, hdr.Size, hdr.Size) + n, err := f.Read(buf) + if err != nil { + return err + } + buf = buf[:n] + case Write: + if _, err := io.CopyN(f, in, int64(hdr.Size)); err != nil { + return err + } + case Seek: + seekHdr := &SeekHeader{} + if err := binary.Read(in, binary.BigEndian, seekHdr); err != nil { + return err + } + res, err := f.Seek(seekHdr.Offset, int(seekHdr.Whence)) + if err != nil { + return err + } + buffer := &bytes.Buffer{} + if err := binary.Write(buffer, binary.BigEndian, res); err != nil { + return err + } + buf = buffer.Bytes() + case Close: + if err := f.Close(); err != nil { + return err + } + default: + return ErrUnknown + } + + retHdr := &FileHeader{ + Cmd: CmdOK, + Size: uint64(len(buf)), + } + if err := WriteFileHeader(out, retHdr, buf); err != nil { + return err + } + + if hdr.Cmd == Close { + break + } + } + return nil +} + +// ReadFile works like ioutil.ReadFile but instead writes the file to a writer +// Args: +// - args[0] = path +// Out: +// - Write file contents to out +func ReadFile(in io.Reader, out io.Writer, args []string) error { + if len(args) < 1 { + return ErrInvalid + } + + f, err := os.Open(args[0]) + if err != nil { + return err + } + defer f.Close() + + if _, err := io.Copy(out, f); err != nil { + return nil + } + return nil +} + +// WriteFile works like ioutil.WriteFile but instead reads the file from a reader +// Args: +// - args[0] = path +// - args[1] = permission mode in octal (like 0755) +// - input data stream from in +func WriteFile(in io.Reader, out io.Writer, args []string) error { + if len(args) < 2 { + return ErrInvalid + } + + perm, err := strconv.ParseUint(args[1], 8, 32) + if err != nil { + return err + } + + f, err := os.OpenFile(args[0], os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.FileMode(perm)) + if err != nil { + return err + } + defer f.Close() + + if _, err := io.Copy(f, in); err != nil { + return err + } + return nil +} + +// ReadDir works like *os.File.Readdir but instead writes the result to a writer +// Args: +// - args[0] = path +// - args[1] = number of directory entries to return. If <= 0, return all entries in directory +func ReadDir(in io.Reader, out io.Writer, args []string) error { + if len(args) < 2 { + return ErrInvalid + } + + n, err := strconv.ParseInt(args[1], 10, 32) + if err != nil { + return err + } + + f, err := os.Open(args[0]) + if err != nil { + return err + } + defer f.Close() + + infos, err := f.Readdir(int(n)) + if err != nil { + return err + } + + fileInfos := make([]FileInfo, len(infos)) + for i := range infos { + fileInfos[i] = FileInfo{ + NameVar: infos[i].Name(), + SizeVar: infos[i].Size(), + ModeVar: infos[i].Mode(), + ModTimeVar: infos[i].ModTime().UnixNano(), + IsDirVar: infos[i].IsDir(), + } + } + + buf, err := json.Marshal(fileInfos) + if err != nil { + return err + } + + if _, err := out.Write(buf); err != nil { + return err + } + return nil +} + +// ResolvePath works like docker's symlink.FollowSymlinkInScope. +// It takens in a `path` and a `root` and evaluates symlinks in `path` +// as if they were scoped in `root`. `path` must be a child path of `root`. +// In other words, `path` must have `root` as a prefix. +// Example: +// path=/foo/bar -> /baz +// root=/foo, +// Expected result = /foo/baz +// +// Args: +// - args[0] is `path` +// - args[1] is `root` +// Out: +// - Write resolved path to stdout +func ResolvePath(in io.Reader, out io.Writer, args []string) error { + if len(args) < 2 { + return ErrInvalid + } + res, err := symlink.FollowSymlinkInScope(args[0], args[1]) + if err != nil { + return err + } + if _, err = out.Write([]byte(res)); err != nil { + return err + } + return nil +} + +// ExtractArchive extracts the archive read from in. +// Args: +// - in = size of json | json of archive.TarOptions | input tar stream +// - args[0] = extract directory name +func ExtractArchive(in io.Reader, out io.Writer, args []string) error { + if len(args) < 1 { + return ErrInvalid + } + + opts, err := ReadTarOptions(in) + if err != nil { + return err + } + + if err := archive.Untar(in, args[0], opts); err != nil { + return err + } + return nil +} + +// ArchivePath archives the given directory and writes it to out. +// Args: +// - in = size of json | json of archive.TarOptions +// - args[0] = source directory name +// Out: +// - out = tar file of the archive +func ArchivePath(in io.Reader, out io.Writer, args []string) error { + if len(args) < 1 { + return ErrInvalid + } + + opts, err := ReadTarOptions(in) + if err != nil { + return err + } + + r, err := archive.TarWithOptions(args[0], opts) + if err != nil { + return err + } + + if _, err := io.Copy(out, r); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/utils.go b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/utils.go new file mode 100644 index 000000000..a12827c93 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/utils.go @@ -0,0 +1,168 @@ +package remotefs + +import ( + "bytes" + "encoding/binary" + "encoding/json" + "io" + "io/ioutil" + "os" + "syscall" + + "github.com/docker/docker/pkg/archive" +) + +// ReadError is an utility function that reads a serialized error from the given reader +// and deserializes it. +func ReadError(in io.Reader) (*ExportedError, error) { + b, err := ioutil.ReadAll(in) + if err != nil { + return nil, err + } + + // No error + if len(b) == 0 { + return nil, nil + } + + var exportedErr ExportedError + if err := json.Unmarshal(b, &exportedErr); err != nil { + return nil, err + } + + return &exportedErr, nil +} + +// ExportedToError will convert a ExportedError to an error. It will try to match +// the error to any existing known error like os.ErrNotExist. Otherwise, it will just +// return an implementation of the error interface. +func ExportedToError(ee *ExportedError) error { + if ee.Error() == os.ErrNotExist.Error() { + return os.ErrNotExist + } else if ee.Error() == os.ErrExist.Error() { + return os.ErrExist + } else if ee.Error() == os.ErrPermission.Error() { + return os.ErrPermission + } + return ee +} + +// WriteError is an utility function that serializes the error +// and writes it to the output writer. +func WriteError(err error, out io.Writer) error { + if err == nil { + return nil + } + err = fixOSError(err) + + var errno int + switch typedError := err.(type) { + case *os.PathError: + if se, ok := typedError.Err.(syscall.Errno); ok { + errno = int(se) + } + case *os.LinkError: + if se, ok := typedError.Err.(syscall.Errno); ok { + errno = int(se) + } + case *os.SyscallError: + if se, ok := typedError.Err.(syscall.Errno); ok { + errno = int(se) + } + } + + exportedError := &ExportedError{ + ErrString: err.Error(), + ErrNum: errno, + } + + b, err1 := json.Marshal(exportedError) + if err1 != nil { + return err1 + } + + _, err1 = out.Write(b) + if err1 != nil { + return err1 + } + return nil +} + +// fixOSError converts possible platform dependent error into the portable errors in the +// Go os package if possible. +func fixOSError(err error) error { + // The os.IsExist, os.IsNotExist, and os.IsPermissions functions are platform + // dependent, so sending the raw error might break those functions on a different OS. + // Go defines portable errors for these. + if os.IsExist(err) { + return os.ErrExist + } else if os.IsNotExist(err) { + return os.ErrNotExist + } else if os.IsPermission(err) { + return os.ErrPermission + } + return err +} + +// ReadTarOptions reads from the specified reader and deserializes an archive.TarOptions struct. +func ReadTarOptions(r io.Reader) (*archive.TarOptions, error) { + var size uint64 + if err := binary.Read(r, binary.BigEndian, &size); err != nil { + return nil, err + } + + rawJSON := make([]byte, size) + if _, err := io.ReadFull(r, rawJSON); err != nil { + return nil, err + } + + var opts archive.TarOptions + if err := json.Unmarshal(rawJSON, &opts); err != nil { + return nil, err + } + return &opts, nil +} + +// WriteTarOptions serializes a archive.TarOptions struct and writes it to the writer. +func WriteTarOptions(w io.Writer, opts *archive.TarOptions) error { + optsBuf, err := json.Marshal(opts) + if err != nil { + return err + } + + optsSize := uint64(len(optsBuf)) + optsSizeBuf := &bytes.Buffer{} + if err := binary.Write(optsSizeBuf, binary.BigEndian, optsSize); err != nil { + return err + } + + if _, err := optsSizeBuf.WriteTo(w); err != nil { + return err + } + + if _, err := w.Write(optsBuf); err != nil { + return err + } + + return nil +} + +// ReadFileHeader reads from r and returns a deserialized FileHeader +func ReadFileHeader(r io.Reader) (*FileHeader, error) { + hdr := &FileHeader{} + if err := binary.Read(r, binary.BigEndian, hdr); err != nil { + return nil, err + } + return hdr, nil +} + +// WriteFileHeader serializes a FileHeader and writes it to w, along with any extra data +func WriteFileHeader(w io.Writer, hdr *FileHeader, extraData []byte) error { + if err := binary.Write(w, binary.BigEndian, hdr); err != nil { + return err + } + if _, err := w.Write(extraData); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/api/grpc/types/api.pb.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/api/grpc/types/api.pb.go index e6ef556a6..8f14a18de 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/api/grpc/types/api.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/api/grpc/types/api.pb.go @@ -1,6 +1,5 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. // source: api.proto -// DO NOT EDIT! /* Package types is a generated protocol buffer package. @@ -1052,6 +1051,8 @@ type UpdateResource struct { BlkioThrottleReadIopsDevice []*ThrottleDevice `protobuf:"bytes,16,rep,name=blkioThrottleReadIopsDevice" json:"blkioThrottleReadIopsDevice,omitempty"` BlkioThrottleWriteIopsDevice []*ThrottleDevice `protobuf:"bytes,17,rep,name=blkioThrottleWriteIopsDevice" json:"blkioThrottleWriteIopsDevice,omitempty"` PidsLimit uint64 `protobuf:"varint,18,opt,name=pidsLimit" json:"pidsLimit,omitempty"` + CpuRealtimePeriod uint64 `protobuf:"varint,19,opt,name=cpuRealtimePeriod" json:"cpuRealtimePeriod,omitempty"` + CpuRealtimeRuntime int64 `protobuf:"varint,20,opt,name=cpuRealtimeRuntime" json:"cpuRealtimeRuntime,omitempty"` } func (m *UpdateResource) Reset() { *m = UpdateResource{} } @@ -1185,6 +1186,20 @@ func (m *UpdateResource) GetPidsLimit() uint64 { return 0 } +func (m *UpdateResource) GetCpuRealtimePeriod() uint64 { + if m != nil { + return m.CpuRealtimePeriod + } + return 0 +} + +func (m *UpdateResource) GetCpuRealtimeRuntime() int64 { + if m != nil { + return m.CpuRealtimeRuntime + } + return 0 +} + type BlockIODevice struct { Major int64 `protobuf:"varint,1,opt,name=major" json:"major,omitempty"` Minor int64 `protobuf:"varint,2,opt,name=minor" json:"minor,omitempty"` @@ -2415,170 +2430,172 @@ var _API_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("api.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 2632 bytes of a gzipped FileDescriptorProto + // 2666 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x19, 0x4d, 0x6f, 0x24, 0x47, 0x75, 0x67, 0xa6, 0xed, 0xf1, 0xbc, 0xf9, 0xb0, 0xa7, 0xd6, 0xeb, 0xed, 0x9d, 0x24, 0xbb, 0x4e, 0x2b, 0x10, 0x03, 0x91, 0xb3, 0x78, 0x13, 0x58, 0x11, 0x09, 0x69, 0xd7, 0x1b, 0x82, 0xc9, 0x3a, - 0x99, 0xb4, 0x6d, 0x56, 0x48, 0x48, 0xa3, 0x76, 0x77, 0xed, 0x4c, 0xe1, 0x9e, 0xae, 0x4e, 0x75, - 0xb5, 0x3d, 0xbe, 0xe4, 0xc0, 0x01, 0x0e, 0x48, 0x70, 0x45, 0xe2, 0xc8, 0x8d, 0x3b, 0x07, 0xf8, - 0x03, 0x48, 0xfc, 0x10, 0x6e, 0xdc, 0x39, 0xa2, 0xfa, 0xe8, 0xea, 0xea, 0xf9, 0xf0, 0x6e, 0x90, - 0x10, 0x17, 0x2e, 0xad, 0x7a, 0xaf, 0xde, 0x57, 0xbd, 0x7a, 0xef, 0xd5, 0xab, 0x6a, 0x68, 0x05, - 0x29, 0xd9, 0x4f, 0x19, 0xe5, 0x14, 0xad, 0xf1, 0xeb, 0x14, 0x67, 0x83, 0x07, 0x63, 0x4a, 0xc7, - 0x31, 0x7e, 0x5f, 0x22, 0xcf, 0xf3, 0x97, 0xef, 0x73, 0x32, 0xc5, 0x19, 0x0f, 0xa6, 0xa9, 0xa2, - 0xf3, 0xee, 0xc1, 0xdd, 0x4f, 0x30, 0x3f, 0xc1, 0xec, 0x12, 0xb3, 0x9f, 0x62, 0x96, 0x11, 0x9a, - 0xf8, 0xf8, 0xcb, 0x1c, 0x67, 0xdc, 0x9b, 0x81, 0xbb, 0x38, 0x95, 0xa5, 0x34, 0xc9, 0x30, 0xda, - 0x86, 0xb5, 0x69, 0xf0, 0x0b, 0xca, 0xdc, 0xda, 0x6e, 0x6d, 0xaf, 0xeb, 0x2b, 0x40, 0x62, 0x49, - 0x42, 0x99, 0x5b, 0xd7, 0x58, 0x01, 0x08, 0x6c, 0x1a, 0xf0, 0x70, 0xe2, 0x36, 0x14, 0x56, 0x02, - 0x68, 0x00, 0x1b, 0x0c, 0x5f, 0x12, 0x21, 0xd5, 0x75, 0x76, 0x6b, 0x7b, 0x2d, 0xdf, 0xc0, 0xde, - 0xaf, 0x6a, 0xb0, 0x7d, 0x96, 0x46, 0x01, 0xc7, 0x43, 0x46, 0x43, 0x9c, 0x65, 0xda, 0x24, 0xd4, - 0x83, 0x3a, 0x89, 0xa4, 0xce, 0x96, 0x5f, 0x27, 0x11, 0xda, 0x82, 0x46, 0x4a, 0x22, 0xa9, 0xae, - 0xe5, 0x8b, 0x21, 0xba, 0x0f, 0x10, 0xc6, 0x34, 0xc3, 0x27, 0x3c, 0x22, 0x89, 0xd4, 0xb8, 0xe1, - 0x5b, 0x18, 0x61, 0xcc, 0x15, 0x89, 0xf8, 0x44, 0xea, 0xec, 0xfa, 0x0a, 0x40, 0x3b, 0xb0, 0x3e, - 0xc1, 0x64, 0x3c, 0xe1, 0xee, 0x9a, 0x44, 0x6b, 0xc8, 0xbb, 0x0b, 0x77, 0xe6, 0xec, 0x50, 0xeb, - 0xf7, 0xfe, 0x5e, 0x87, 0x9d, 0x43, 0x86, 0x03, 0x8e, 0x0f, 0x69, 0xc2, 0x03, 0x92, 0x60, 0xb6, - 0xca, 0xc6, 0xfb, 0x00, 0xe7, 0x79, 0x12, 0xc5, 0x78, 0x18, 0xf0, 0x89, 0x36, 0xd5, 0xc2, 0x48, - 0x8b, 0x27, 0x38, 0xbc, 0x48, 0x29, 0x49, 0xb8, 0xb4, 0xb8, 0xe5, 0x5b, 0x18, 0x61, 0x71, 0x26, - 0x17, 0xa3, 0xbc, 0xa4, 0x00, 0x61, 0x71, 0xc6, 0x23, 0x9a, 0x2b, 0x8b, 0x5b, 0xbe, 0x86, 0x34, - 0x1e, 0x33, 0xe6, 0xae, 0x1b, 0x3c, 0x66, 0x4c, 0xe0, 0xe3, 0xe0, 0x1c, 0xc7, 0x99, 0xdb, 0xdc, - 0x6d, 0x08, 0xbc, 0x82, 0xd0, 0x2e, 0xb4, 0x13, 0x3a, 0x24, 0x97, 0x94, 0xfb, 0x94, 0x72, 0x77, - 0x43, 0x3a, 0xcc, 0x46, 0x21, 0x17, 0x9a, 0x2c, 0x4f, 0x44, 0xdc, 0xb8, 0x2d, 0x29, 0xb2, 0x00, - 0x05, 0xaf, 0x1e, 0x3e, 0x61, 0xe3, 0xcc, 0x05, 0x29, 0xd8, 0x46, 0xa1, 0x77, 0xa0, 0x5b, 0xae, - 0xe4, 0x19, 0x61, 0x6e, 0x5b, 0x4a, 0xa8, 0x22, 0xbd, 0x23, 0xb8, 0xbb, 0xe0, 0x4b, 0x1d, 0x67, - 0xfb, 0xd0, 0x0a, 0x0b, 0xa4, 0xf4, 0x69, 0xfb, 0x60, 0x6b, 0x5f, 0x86, 0xf6, 0x7e, 0x49, 0x5c, - 0x92, 0x78, 0x47, 0xd0, 0x3d, 0x21, 0xe3, 0x24, 0x88, 0x5f, 0x3f, 0x62, 0x84, 0xc7, 0x24, 0x8b, - 0x8e, 0x4f, 0x0d, 0x79, 0x5b, 0xd0, 0x2b, 0x44, 0xe9, 0x4d, 0xff, 0x73, 0x03, 0xfa, 0x4f, 0xa2, - 0xe8, 0x15, 0x31, 0x39, 0x80, 0x0d, 0x8e, 0xd9, 0x94, 0x08, 0x89, 0x75, 0xe9, 0x4e, 0x03, 0xa3, - 0x07, 0xe0, 0xe4, 0x19, 0x66, 0x52, 0x53, 0xfb, 0xa0, 0xad, 0x57, 0x72, 0x96, 0x61, 0xe6, 0xcb, - 0x09, 0x84, 0xc0, 0x09, 0x84, 0x2f, 0x1d, 0xe9, 0x4b, 0x39, 0x16, 0x26, 0xe3, 0xe4, 0xd2, 0x5d, - 0x93, 0x28, 0x31, 0x14, 0x98, 0xf0, 0x2a, 0xd2, 0x3b, 0x2c, 0x86, 0xc5, 0xb2, 0x9a, 0xe5, 0xb2, - 0x4c, 0xd8, 0x6c, 0x2c, 0x0f, 0x9b, 0xd6, 0x8a, 0xb0, 0x81, 0x4a, 0xd8, 0x78, 0xd0, 0x09, 0x83, - 0x34, 0x38, 0x27, 0x31, 0xe1, 0x04, 0x67, 0x6e, 0x5b, 0x1a, 0x51, 0xc1, 0xa1, 0x3d, 0xd8, 0x0c, - 0xd2, 0x34, 0x60, 0x53, 0xca, 0x86, 0x8c, 0xbe, 0x24, 0x31, 0x76, 0x3b, 0x52, 0xc8, 0x3c, 0x5a, - 0x48, 0xcb, 0x70, 0x4c, 0x92, 0x7c, 0xf6, 0x5c, 0x44, 0x9f, 0xdb, 0x95, 0x64, 0x15, 0x9c, 0x90, - 0x96, 0xd0, 0xcf, 0xf0, 0xd5, 0x90, 0x91, 0x4b, 0x12, 0xe3, 0x31, 0xce, 0xdc, 0x9e, 0xf4, 0xe2, - 0x3c, 0x1a, 0xbd, 0x0b, 0x4d, 0x16, 0x93, 0x29, 0xe1, 0x99, 0xbb, 0xb9, 0xdb, 0xd8, 0x6b, 0x1f, - 0x74, 0xb5, 0x3f, 0x7d, 0x89, 0xf5, 0x8b, 0x59, 0xef, 0x19, 0xac, 0x2b, 0x94, 0x70, 0xaf, 0x20, - 0xd1, 0xbb, 0x25, 0xc7, 0x02, 0x97, 0xd1, 0x97, 0x5c, 0xee, 0x95, 0xe3, 0xcb, 0xb1, 0xc0, 0x4d, - 0x02, 0x16, 0xc9, 0x7d, 0x72, 0x7c, 0x39, 0xf6, 0x7c, 0x70, 0xc4, 0x46, 0x09, 0x57, 0xe7, 0x7a, - 0xc3, 0xbb, 0xbe, 0x18, 0x0a, 0xcc, 0x58, 0xc7, 0x54, 0xd7, 0x17, 0x43, 0xf4, 0x4d, 0xe8, 0x05, - 0x51, 0x44, 0x38, 0xa1, 0x49, 0x10, 0x7f, 0x42, 0xa2, 0xcc, 0x6d, 0xec, 0x36, 0xf6, 0xba, 0xfe, - 0x1c, 0xd6, 0x3b, 0x00, 0x64, 0x07, 0x94, 0x0e, 0xfa, 0x37, 0xa1, 0x95, 0x5d, 0x67, 0x1c, 0x4f, - 0x87, 0x46, 0x4f, 0x89, 0xf0, 0x7e, 0x59, 0x33, 0xe9, 0x62, 0xb2, 0x68, 0x55, 0x2c, 0x7e, 0xb7, - 0x52, 0x5b, 0xea, 0x32, 0xea, 0xfa, 0x45, 0xfe, 0x94, 0xdc, 0x76, 0xb9, 0x59, 0x48, 0xd9, 0xc6, - 0xb2, 0x94, 0x1d, 0x80, 0xbb, 0x68, 0x83, 0x4e, 0x93, 0x10, 0xee, 0x3e, 0xc3, 0x31, 0x7e, 0x1d, - 0xfb, 0x10, 0x38, 0x49, 0x30, 0xc5, 0x3a, 0x1d, 0xe5, 0xf8, 0xf5, 0x0d, 0x58, 0x54, 0xa2, 0x0d, - 0x38, 0x86, 0x3b, 0xcf, 0x49, 0xc6, 0x5f, 0xad, 0x7e, 0x41, 0x55, 0x7d, 0x99, 0xaa, 0xdf, 0xd7, - 0x00, 0x4a, 0x59, 0xc6, 0xe6, 0x9a, 0x65, 0x33, 0x02, 0x07, 0xcf, 0x08, 0xd7, 0xf9, 0x2e, 0xc7, - 0x22, 0x2a, 0x78, 0x98, 0xea, 0x23, 0x48, 0x0c, 0x45, 0xbd, 0xcc, 0x13, 0x32, 0x3b, 0xa1, 0xe1, - 0x05, 0xe6, 0x99, 0xac, 0xe7, 0x1b, 0xbe, 0x8d, 0x92, 0x49, 0x3b, 0xc1, 0x71, 0x2c, 0x8b, 0xfa, - 0x86, 0xaf, 0x00, 0x51, 0x81, 0xf1, 0x34, 0xe5, 0xd7, 0x9f, 0x9d, 0xb8, 0xeb, 0x32, 0xff, 0x0a, - 0xd0, 0x3b, 0x86, 0x9d, 0xf9, 0x95, 0xea, 0x18, 0x7a, 0x04, 0xed, 0x72, 0x15, 0x99, 0x5b, 0x93, - 0x09, 0xb2, 0x64, 0xeb, 0x6d, 0x2a, 0xef, 0x3e, 0x74, 0x4e, 0x78, 0xc0, 0xf1, 0x0a, 0x7f, 0x79, - 0x7b, 0xd0, 0x33, 0x55, 0x57, 0x12, 0xaa, 0xba, 0x11, 0xf0, 0x3c, 0xd3, 0x54, 0x1a, 0xf2, 0xfe, - 0xd2, 0x80, 0xa6, 0x0e, 0xeb, 0xa2, 0x36, 0xd5, 0xca, 0xda, 0xf4, 0x3f, 0x29, 0x91, 0x95, 0xac, - 0x6a, 0xce, 0x65, 0xd5, 0xff, 0xcb, 0x65, 0x59, 0x2e, 0xff, 0x56, 0x83, 0x96, 0xd9, 0xe6, 0xaf, - 0xdd, 0xce, 0xbc, 0x07, 0xad, 0x54, 0x6d, 0x3c, 0x56, 0x55, 0xaf, 0x7d, 0xd0, 0xd3, 0x8a, 0x8a, - 0x3a, 0x57, 0x12, 0x58, 0xf1, 0xe3, 0xd8, 0xf1, 0x63, 0xb5, 0x2b, 0x6b, 0x95, 0x76, 0x05, 0x81, - 0x93, 0x8a, 0x72, 0xba, 0x2e, 0xcb, 0xa9, 0x1c, 0xdb, 0x0d, 0x4a, 0xb3, 0xd2, 0xa0, 0x78, 0x1f, - 0x42, 0xf3, 0x38, 0x08, 0x27, 0x24, 0x91, 0x19, 0x1a, 0xa6, 0x3a, 0x4c, 0xbb, 0xbe, 0x1c, 0x0b, - 0x25, 0x53, 0x3c, 0xa5, 0xec, 0x5a, 0xd7, 0x7e, 0x0d, 0x79, 0x17, 0xd0, 0xd5, 0x69, 0xa0, 0x93, - 0xe9, 0x21, 0x80, 0x69, 0x31, 0x8a, 0x5c, 0x5a, 0x6c, 0x43, 0x2c, 0x1a, 0xb4, 0x07, 0xcd, 0xa9, - 0xd2, 0xac, 0xab, 0x6e, 0xe1, 0x03, 0x6d, 0x8f, 0x5f, 0x4c, 0x7b, 0xbf, 0xae, 0xc1, 0x8e, 0xea, - 0x31, 0x5f, 0xd9, 0x49, 0x2e, 0xef, 0x5d, 0x94, 0xfb, 0x1a, 0x15, 0xf7, 0x3d, 0x82, 0x16, 0xc3, - 0x19, 0xcd, 0x59, 0x88, 0x95, 0x67, 0xdb, 0x07, 0x77, 0x8a, 0x4c, 0x92, 0xba, 0x7c, 0x3d, 0xeb, - 0x97, 0x74, 0xde, 0x6f, 0x9a, 0xd0, 0xab, 0xce, 0x8a, 0x8a, 0x75, 0x1e, 0x5f, 0x10, 0xfa, 0x42, - 0x35, 0xc7, 0x35, 0xe9, 0x26, 0x1b, 0x25, 0xb2, 0x2a, 0x4c, 0xf3, 0x93, 0x49, 0xc0, 0x70, 0xa6, - 0xdd, 0x58, 0x22, 0xf4, 0xec, 0x10, 0x33, 0x42, 0x8b, 0xc3, 0xb4, 0x44, 0x88, 0x32, 0x10, 0xa6, - 0xf9, 0x17, 0x39, 0xe5, 0x81, 0x34, 0xd2, 0xf1, 0x0d, 0x2c, 0xbb, 0xe2, 0x34, 0xcf, 0x30, 0x3f, - 0x14, 0xbb, 0xb6, 0xa6, 0xbb, 0x62, 0x83, 0x29, 0xe7, 0x8f, 0xf1, 0x34, 0xd3, 0x69, 0x6e, 0x61, - 0x84, 0xe5, 0x6a, 0x37, 0x9f, 0x8b, 0xa0, 0x96, 0x81, 0xe1, 0xf8, 0x36, 0x4a, 0x48, 0x50, 0xe0, - 0xc9, 0x55, 0x90, 0xca, 0xb4, 0x77, 0x7c, 0x0b, 0x83, 0xde, 0x83, 0xbe, 0x82, 0x7c, 0x9c, 0x61, - 0x76, 0x19, 0x88, 0x63, 0x5b, 0x96, 0x01, 0xc7, 0x5f, 0x9c, 0x10, 0xd4, 0x17, 0x98, 0x25, 0x38, - 0x3e, 0xb6, 0xb4, 0x82, 0xa2, 0x5e, 0x98, 0x40, 0x07, 0xb0, 0xad, 0x90, 0xa7, 0x87, 0x43, 0x9b, - 0xa1, 0x2d, 0x19, 0x96, 0xce, 0x89, 0x4c, 0x97, 0x8e, 0x7f, 0x8e, 0x83, 0x97, 0x7a, 0x3f, 0x3a, - 0x92, 0x7c, 0x1e, 0x8d, 0x9e, 0x40, 0xdf, 0xda, 0xa2, 0x67, 0xf8, 0x92, 0x84, 0xd8, 0xed, 0xca, - 0xa8, 0xbd, 0xad, 0xa3, 0xc0, 0x9e, 0xf2, 0x17, 0xa9, 0xd1, 0x19, 0x0c, 0x24, 0xf2, 0x74, 0xc2, - 0x28, 0xe7, 0x31, 0xf6, 0x71, 0x10, 0x3d, 0x4d, 0x33, 0x2d, 0xab, 0x27, 0x65, 0x15, 0x11, 0x55, - 0xd0, 0x68, 0x69, 0x37, 0x30, 0xa2, 0x17, 0xf0, 0x46, 0x65, 0xf6, 0x05, 0x23, 0x1c, 0x97, 0x72, - 0x37, 0x6f, 0x92, 0x7b, 0x13, 0xe7, 0x82, 0x60, 0xa1, 0xf6, 0x88, 0x1a, 0xc1, 0x5b, 0xaf, 0x2f, - 0xb8, 0xca, 0x89, 0x7e, 0x06, 0x6f, 0x2e, 0xea, 0xb5, 0x24, 0xf7, 0x6f, 0x92, 0x7c, 0x23, 0xab, - 0x48, 0x0e, 0x51, 0xbf, 0xd4, 0xce, 0x23, 0x95, 0x1c, 0x06, 0xe1, 0x7d, 0x04, 0xdd, 0xa7, 0x31, - 0x0d, 0x2f, 0x8e, 0x3e, 0xd7, 0xe4, 0x95, 0x2b, 0x77, 0x63, 0xe9, 0x95, 0xbb, 0xa1, 0xaf, 0xdc, - 0xde, 0x57, 0xd0, 0xa9, 0x6c, 0xe7, 0xf7, 0x64, 0x1e, 0x17, 0xa2, 0xf4, 0x45, 0x6a, 0x5b, 0x1b, - 0x5d, 0x51, 0xe3, 0xdb, 0x84, 0xa2, 0xbe, 0x5c, 0xa9, 0x50, 0x53, 0xcd, 0xad, 0x86, 0x44, 0xee, - 0xc4, 0x65, 0x18, 0xaa, 0x7b, 0x93, 0x85, 0xf1, 0x7e, 0x0e, 0xbd, 0xaa, 0x2b, 0xfe, 0x63, 0x0b, - 0x10, 0x38, 0x2c, 0xe0, 0xb8, 0xe8, 0xce, 0xc5, 0xd8, 0xbb, 0x07, 0x77, 0x17, 0x2a, 0xa6, 0x6e, - 0xfd, 0xae, 0xa1, 0xfb, 0xf1, 0x25, 0x4e, 0xb8, 0xb9, 0x9d, 0x3d, 0x86, 0x96, 0x79, 0xf2, 0xd0, - 0xa5, 0x78, 0xb0, 0xaf, 0x1e, 0x45, 0xf6, 0x8b, 0x47, 0x91, 0xfd, 0xd3, 0x82, 0xc2, 0x2f, 0x89, - 0xc5, 0x1a, 0x33, 0x4e, 0x19, 0x8e, 0x3e, 0x4f, 0xe2, 0xeb, 0xe2, 0x25, 0xa1, 0xc4, 0xe8, 0xea, - 0xec, 0x98, 0xe6, 0xe8, 0x77, 0x35, 0x58, 0x93, 0xba, 0x97, 0xde, 0x32, 0x14, 0x75, 0xdd, 0xd4, - 0xf2, 0x6a, 0xe5, 0xee, 0x9a, 0xca, 0xad, 0x6b, 0xbc, 0x53, 0xd6, 0xf8, 0xca, 0x0a, 0xd6, 0xbf, - 0xc6, 0x0a, 0xbc, 0xdf, 0xd6, 0xa1, 0xf3, 0x19, 0xe6, 0x57, 0x94, 0x5d, 0x88, 0xf3, 0x2c, 0x5b, - 0xda, 0xba, 0xde, 0x83, 0x0d, 0x36, 0x1b, 0x9d, 0x5f, 0x73, 0x53, 0xbf, 0x9b, 0x6c, 0xf6, 0x54, - 0x80, 0xe8, 0x2d, 0x00, 0x36, 0x1b, 0x0d, 0x03, 0xd5, 0xae, 0xea, 0xf2, 0xcd, 0x66, 0x1a, 0x81, - 0xde, 0x80, 0x96, 0x3f, 0x1b, 0x61, 0xc6, 0x28, 0xcb, 0x8a, 0xfa, 0xed, 0xcf, 0x3e, 0x96, 0xb0, - 0xe0, 0xf5, 0x67, 0xa3, 0x88, 0xd1, 0x34, 0xc5, 0x91, 0xac, 0xdf, 0x8e, 0xdf, 0xf2, 0x67, 0xcf, - 0x14, 0x42, 0x68, 0x3d, 0x2d, 0xb4, 0xae, 0x2b, 0xad, 0xa7, 0xa5, 0xd6, 0xd3, 0xd9, 0x28, 0xd5, - 0x5a, 0x55, 0xe1, 0x6e, 0x9d, 0xda, 0x5a, 0x4f, 0x8d, 0x56, 0x55, 0xb5, 0x37, 0x4e, 0x2d, 0xad, - 0xa7, 0xa5, 0xd6, 0x56, 0xc1, 0xab, 0xb5, 0x7a, 0x7f, 0xaa, 0xc1, 0xc6, 0x61, 0x9a, 0x9f, 0x65, - 0xc1, 0x18, 0xa3, 0x07, 0xd0, 0xe6, 0x94, 0x07, 0xf1, 0x28, 0x17, 0xa0, 0x3e, 0xdb, 0x40, 0xa2, - 0x14, 0xc1, 0xdb, 0xd0, 0x49, 0x31, 0x0b, 0xd3, 0x5c, 0x53, 0xd4, 0x77, 0x1b, 0xe2, 0x0c, 0x51, - 0x38, 0x45, 0xb2, 0x0f, 0xb7, 0xe5, 0xdc, 0x88, 0x24, 0x23, 0x55, 0xb4, 0xa7, 0x34, 0xc2, 0xda, - 0x55, 0x7d, 0x39, 0x75, 0x94, 0x7c, 0x6a, 0x26, 0xd0, 0xb7, 0xa1, 0x6f, 0xe8, 0x45, 0x33, 0x2b, - 0xa9, 0x95, 0xeb, 0x36, 0x35, 0xf5, 0x99, 0x46, 0x7b, 0x5f, 0x99, 0x1c, 0x22, 0xc9, 0xf8, 0x59, - 0xc0, 0x03, 0xd1, 0xe8, 0xa4, 0xf2, 0xe4, 0xcc, 0xb4, 0xb5, 0x05, 0x88, 0xbe, 0x03, 0x7d, 0xae, - 0xf3, 0x2d, 0x1a, 0x15, 0x34, 0x6a, 0x37, 0xb7, 0xcc, 0xc4, 0x50, 0x13, 0x7f, 0x03, 0x7a, 0x25, - 0xb1, 0x6c, 0x9b, 0x94, 0xbd, 0x5d, 0x83, 0x15, 0xd1, 0xe4, 0xfd, 0x41, 0x39, 0x4b, 0x45, 0xce, - 0x7b, 0xf2, 0x20, 0xb7, 0x5c, 0xd5, 0x3e, 0xd8, 0x2c, 0x1a, 0x20, 0xed, 0x0c, 0x79, 0x78, 0x2b, - 0xb7, 0xfc, 0x10, 0x36, 0xb9, 0x31, 0x7d, 0x14, 0x05, 0x3c, 0xd0, 0xa9, 0x37, 0x57, 0x27, 0xf5, - 0xc2, 0xfc, 0x1e, 0xaf, 0x2e, 0xf4, 0x6d, 0xe8, 0xa8, 0xce, 0x5c, 0x2b, 0x54, 0xf6, 0xb5, 0x15, - 0x4e, 0xaa, 0xf0, 0x3e, 0x82, 0xd6, 0x90, 0x44, 0x99, 0xb2, 0xce, 0x85, 0x66, 0x98, 0x33, 0x86, - 0x93, 0xa2, 0x45, 0x29, 0x40, 0x51, 0x1e, 0x65, 0x57, 0xab, 0x9d, 0xa1, 0x00, 0x8f, 0x02, 0xa8, - 0x93, 0x55, 0x6a, 0xdb, 0x86, 0x35, 0x3b, 0x04, 0x14, 0x20, 0xe2, 0x6c, 0x1a, 0xcc, 0xcc, 0xd6, - 0xcb, 0x38, 0x9b, 0x06, 0x33, 0xb5, 0x40, 0x17, 0x9a, 0x2f, 0x03, 0x12, 0x87, 0xfa, 0xc1, 0xce, - 0xf1, 0x0b, 0xb0, 0x54, 0xe8, 0xd8, 0x0a, 0xff, 0x58, 0x87, 0xb6, 0xd2, 0xa8, 0x0c, 0xde, 0x86, - 0xb5, 0x30, 0x08, 0x27, 0x46, 0xa5, 0x04, 0xd0, 0xbb, 0x85, 0x21, 0xd5, 0x8b, 0x7a, 0x69, 0x6a, - 0x61, 0xdb, 0x43, 0x80, 0xec, 0x2a, 0x48, 0x2d, 0xef, 0x2c, 0xa5, 0x6e, 0x09, 0x22, 0x65, 0xf0, - 0x07, 0xd0, 0x51, 0xf1, 0xa9, 0x79, 0x9c, 0x55, 0x3c, 0x6d, 0x45, 0xa6, 0xb8, 0x1e, 0x89, 0x4b, - 0x51, 0xc0, 0x55, 0x13, 0xde, 0x3e, 0x78, 0xab, 0x42, 0x2e, 0x57, 0xb2, 0x2f, 0xbf, 0x1f, 0x27, - 0x9c, 0x5d, 0xfb, 0x8a, 0x76, 0xf0, 0x18, 0xa0, 0x44, 0x8a, 0x7a, 0x76, 0x81, 0xaf, 0x8b, 0xcb, - 0xdf, 0x05, 0xbe, 0x16, 0x6b, 0xbf, 0x0c, 0xe2, 0xbc, 0x70, 0xaa, 0x02, 0x7e, 0x50, 0x7f, 0x5c, - 0xf3, 0x42, 0xd8, 0x7c, 0x2a, 0x0e, 0x4c, 0x8b, 0xbd, 0x72, 0xe8, 0x39, 0x4b, 0x0f, 0x3d, 0xa7, - 0x78, 0x67, 0xee, 0x41, 0x9d, 0xa6, 0xba, 0x11, 0xae, 0xd3, 0xb4, 0x54, 0xe4, 0x58, 0x8a, 0xbc, - 0x7f, 0x38, 0x00, 0xa5, 0x16, 0x74, 0x02, 0x03, 0x42, 0x47, 0xa2, 0x8f, 0x23, 0x21, 0x56, 0x05, - 0x69, 0xc4, 0x70, 0x98, 0xb3, 0x8c, 0x5c, 0x62, 0xdd, 0xea, 0xef, 0x98, 0x63, 0xaa, 0x62, 0x9c, - 0x7f, 0x97, 0xd0, 0x13, 0xc5, 0x28, 0x2b, 0x97, 0x5f, 0xb0, 0xa1, 0x9f, 0xc0, 0x9d, 0x52, 0x68, - 0x64, 0xc9, 0xab, 0xdf, 0x28, 0xef, 0xb6, 0x91, 0x17, 0x95, 0xb2, 0x7e, 0x04, 0xb7, 0x09, 0x1d, - 0x7d, 0x99, 0xe3, 0xbc, 0x22, 0xa9, 0x71, 0xa3, 0xa4, 0x3e, 0xa1, 0x5f, 0x48, 0x8e, 0x52, 0xce, - 0x17, 0x70, 0xcf, 0x5a, 0xa8, 0x48, 0x7b, 0x4b, 0x9a, 0x73, 0xa3, 0xb4, 0x1d, 0x63, 0x97, 0x28, - 0x0c, 0xa5, 0xc8, 0x4f, 0x61, 0x87, 0xd0, 0xd1, 0x55, 0x40, 0xf8, 0xbc, 0xbc, 0xb5, 0x57, 0xad, - 0xf3, 0x45, 0x40, 0x78, 0x55, 0x98, 0x5a, 0xe7, 0x14, 0xb3, 0x71, 0x65, 0x9d, 0xeb, 0xaf, 0x5a, - 0xe7, 0xb1, 0xe4, 0x28, 0xe5, 0x3c, 0x85, 0x3e, 0xa1, 0xf3, 0xf6, 0x34, 0x6f, 0x94, 0xb2, 0x49, - 0x68, 0xd5, 0x96, 0x43, 0xe8, 0x67, 0x38, 0xe4, 0x94, 0xd9, 0xb1, 0xb0, 0x71, 0xa3, 0x8c, 0x2d, - 0xcd, 0x60, 0x84, 0x78, 0x5f, 0x42, 0xe7, 0xc7, 0xf9, 0x18, 0xf3, 0xf8, 0xdc, 0xe4, 0xfc, 0x7f, - 0xbb, 0xcc, 0xfc, 0xab, 0x0e, 0xed, 0xc3, 0x31, 0xa3, 0x79, 0x5a, 0xa9, 0xda, 0x2a, 0x87, 0x17, - 0xaa, 0xb6, 0xa4, 0x91, 0x55, 0x5b, 0x51, 0x7f, 0x08, 0x1d, 0x75, 0xaf, 0xd1, 0x0c, 0xaa, 0x0a, - 0xa1, 0xc5, 0xa4, 0x2f, 0xee, 0x51, 0x8a, 0xed, 0x40, 0xdf, 0x11, 0x35, 0x57, 0xb5, 0x1a, 0x95, - 0x6e, 0xf2, 0xe1, 0xbc, 0xcc, 0xba, 0x23, 0xe8, 0x4e, 0x94, 0x6f, 0x34, 0x97, 0x0a, 0xc0, 0x77, - 0x0a, 0xe3, 0xca, 0x35, 0xec, 0xdb, 0x3e, 0x54, 0xae, 0xee, 0x4c, 0x6c, 0xb7, 0xbe, 0x0f, 0x20, - 0x9a, 0xe6, 0x51, 0x51, 0xa8, 0xec, 0x5f, 0x04, 0xe6, 0x84, 0x50, 0x8d, 0xb5, 0x1c, 0x0e, 0x4e, - 0xa1, 0xbf, 0x20, 0x73, 0x49, 0x99, 0xfa, 0x96, 0x5d, 0xa6, 0xca, 0x8b, 0x93, 0xcd, 0x6a, 0xd7, - 0xae, 0xbf, 0xd6, 0xd4, 0xa3, 0x41, 0xf9, 0x8a, 0xfb, 0x18, 0xba, 0x89, 0x6a, 0xbe, 0xcc, 0x06, - 0xd8, 0x37, 0x30, 0xbb, 0x31, 0xf3, 0x3b, 0x89, 0xdd, 0xa6, 0x7d, 0x08, 0x9d, 0x50, 0x7a, 0x60, - 0xe9, 0x46, 0x58, 0xce, 0xf1, 0xdb, 0xa1, 0xb5, 0xdb, 0x95, 0x46, 0xd1, 0xf9, 0x3a, 0x8d, 0xa2, - 0x7e, 0xf7, 0x5b, 0xf5, 0x4b, 0xe3, 0xe0, 0x9f, 0xeb, 0xd0, 0x78, 0x32, 0x3c, 0x42, 0x67, 0xb0, - 0x35, 0xff, 0x47, 0x10, 0xdd, 0xd7, 0x66, 0xad, 0xf8, 0x8b, 0x38, 0x78, 0xb0, 0x72, 0x5e, 0xb7, - 0xec, 0xb7, 0x90, 0x0f, 0x9b, 0x73, 0xff, 0x7f, 0x50, 0x71, 0xd4, 0x2c, 0xff, 0xc7, 0x36, 0xb8, - 0xbf, 0x6a, 0xda, 0x96, 0x39, 0x77, 0x47, 0x30, 0x32, 0x97, 0xbf, 0xb6, 0x18, 0x99, 0xab, 0xae, - 0x16, 0xb7, 0xd0, 0xf7, 0x61, 0x5d, 0xfd, 0x11, 0x42, 0xc5, 0xc5, 0xa5, 0xf2, 0xaf, 0x69, 0x70, - 0x67, 0x0e, 0x6b, 0x18, 0x9f, 0x43, 0xb7, 0xf2, 0x1b, 0x11, 0xbd, 0x51, 0xd1, 0x55, 0xfd, 0xa1, - 0x34, 0x78, 0x73, 0xf9, 0xa4, 0x91, 0x76, 0x08, 0x50, 0xfe, 0x34, 0x40, 0xae, 0xa6, 0x5e, 0xf8, - 0x31, 0x35, 0xb8, 0xb7, 0x64, 0xc6, 0x08, 0x39, 0x83, 0xad, 0xf9, 0x07, 0x7c, 0x34, 0xe7, 0xd5, - 0xf9, 0xe7, 0x73, 0xb3, 0x95, 0x2b, 0x5f, 0xfe, 0xa5, 0xd8, 0xf9, 0x67, 0x79, 0x23, 0x76, 0xc5, - 0x4f, 0x01, 0x23, 0x76, 0xe5, 0x7b, 0xfe, 0x2d, 0xf4, 0x39, 0xf4, 0xaa, 0xef, 0xdc, 0xa8, 0x70, - 0xd2, 0xd2, 0x87, 0xfe, 0xc1, 0x5b, 0x2b, 0x66, 0x8d, 0xc0, 0x0f, 0x60, 0x4d, 0x3d, 0x60, 0x17, - 0xe9, 0x68, 0xbf, 0x7b, 0x0f, 0xb6, 0xab, 0x48, 0xc3, 0xf5, 0x10, 0xd6, 0xd5, 0xed, 0xd2, 0x04, - 0x40, 0xe5, 0xb2, 0x39, 0xe8, 0xd8, 0x58, 0xef, 0xd6, 0xc3, 0x5a, 0xa1, 0x27, 0xab, 0xe8, 0xc9, - 0x96, 0xe9, 0xb1, 0x36, 0xe7, 0x7c, 0x5d, 0xa6, 0xeb, 0xa3, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, - 0x4c, 0xa9, 0xa8, 0x4d, 0xd0, 0x1f, 0x00, 0x00, + 0x99, 0x94, 0x6d, 0x56, 0x48, 0x48, 0xa3, 0x76, 0x77, 0xed, 0x4c, 0xe1, 0x9e, 0xae, 0x4e, 0x75, + 0xb5, 0x3d, 0xbe, 0xe4, 0xc0, 0x01, 0x6e, 0x70, 0x45, 0xe2, 0xc8, 0x8d, 0x3b, 0x07, 0xf8, 0x03, + 0x48, 0xfc, 0x10, 0x24, 0x0e, 0xdc, 0x39, 0xa2, 0xfa, 0xe8, 0xee, 0xea, 0xf9, 0xf0, 0x6e, 0x90, + 0x10, 0x17, 0x2e, 0xad, 0x7a, 0xaf, 0xde, 0x57, 0xbd, 0x7a, 0xef, 0xd5, 0xab, 0x2e, 0x68, 0xf9, + 0x09, 0xdd, 0x4f, 0x38, 0x13, 0x0c, 0xad, 0x89, 0xeb, 0x84, 0xa4, 0x83, 0x07, 0x63, 0xc6, 0xc6, + 0x11, 0x79, 0x5f, 0x21, 0xcf, 0xb3, 0x97, 0xef, 0x0b, 0x3a, 0x25, 0xa9, 0xf0, 0xa7, 0x89, 0xa6, + 0xf3, 0xee, 0xc1, 0xdd, 0x4f, 0x88, 0x38, 0x21, 0xfc, 0x92, 0xf0, 0x9f, 0x12, 0x9e, 0x52, 0x16, + 0x63, 0xf2, 0x65, 0x46, 0x52, 0xe1, 0xcd, 0xc0, 0x5d, 0x9c, 0x4a, 0x13, 0x16, 0xa7, 0x04, 0x6d, + 0xc3, 0xda, 0xd4, 0xff, 0x05, 0xe3, 0x6e, 0x6d, 0xb7, 0xb6, 0xd7, 0xc5, 0x1a, 0x50, 0x58, 0x1a, + 0x33, 0xee, 0xd6, 0x0d, 0x56, 0x02, 0x12, 0x9b, 0xf8, 0x22, 0x98, 0xb8, 0x0d, 0x8d, 0x55, 0x00, + 0x1a, 0xc0, 0x06, 0x27, 0x97, 0x54, 0x4a, 0x75, 0x9d, 0xdd, 0xda, 0x5e, 0x0b, 0x17, 0xb0, 0xf7, + 0xab, 0x1a, 0x6c, 0x9f, 0x25, 0xa1, 0x2f, 0xc8, 0x90, 0xb3, 0x80, 0xa4, 0xa9, 0x31, 0x09, 0xf5, + 0xa0, 0x4e, 0x43, 0xa5, 0xb3, 0x85, 0xeb, 0x34, 0x44, 0x5b, 0xd0, 0x48, 0x68, 0xa8, 0xd4, 0xb5, + 0xb0, 0x1c, 0xa2, 0xfb, 0x00, 0x41, 0xc4, 0x52, 0x72, 0x22, 0x42, 0x1a, 0x2b, 0x8d, 0x1b, 0xd8, + 0xc2, 0x48, 0x63, 0xae, 0x68, 0x28, 0x26, 0x4a, 0x67, 0x17, 0x6b, 0x00, 0xed, 0xc0, 0xfa, 0x84, + 0xd0, 0xf1, 0x44, 0xb8, 0x6b, 0x0a, 0x6d, 0x20, 0xef, 0x2e, 0xdc, 0x99, 0xb3, 0x43, 0xaf, 0xdf, + 0xfb, 0x5b, 0x1d, 0x76, 0x0e, 0x39, 0xf1, 0x05, 0x39, 0x64, 0xb1, 0xf0, 0x69, 0x4c, 0xf8, 0x2a, + 0x1b, 0xef, 0x03, 0x9c, 0x67, 0x71, 0x18, 0x91, 0xa1, 0x2f, 0x26, 0xc6, 0x54, 0x0b, 0xa3, 0x2c, + 0x9e, 0x90, 0xe0, 0x22, 0x61, 0x34, 0x16, 0xca, 0xe2, 0x16, 0xb6, 0x30, 0xd2, 0xe2, 0x54, 0x2d, + 0x46, 0x7b, 0x49, 0x03, 0xd2, 0xe2, 0x54, 0x84, 0x2c, 0xd3, 0x16, 0xb7, 0xb0, 0x81, 0x0c, 0x9e, + 0x70, 0xee, 0xae, 0x17, 0x78, 0xc2, 0xb9, 0xc4, 0x47, 0xfe, 0x39, 0x89, 0x52, 0xb7, 0xb9, 0xdb, + 0x90, 0x78, 0x0d, 0xa1, 0x5d, 0x68, 0xc7, 0x6c, 0x48, 0x2f, 0x99, 0xc0, 0x8c, 0x09, 0x77, 0x43, + 0x39, 0xcc, 0x46, 0x21, 0x17, 0x9a, 0x3c, 0x8b, 0x65, 0xdc, 0xb8, 0x2d, 0x25, 0x32, 0x07, 0x25, + 0xaf, 0x19, 0x3e, 0xe1, 0xe3, 0xd4, 0x05, 0x25, 0xd8, 0x46, 0xa1, 0x77, 0xa0, 0x5b, 0xae, 0xe4, + 0x19, 0xe5, 0x6e, 0x5b, 0x49, 0xa8, 0x22, 0xbd, 0x23, 0xb8, 0xbb, 0xe0, 0x4b, 0x13, 0x67, 0xfb, + 0xd0, 0x0a, 0x72, 0xa4, 0xf2, 0x69, 0xfb, 0x60, 0x6b, 0x5f, 0x85, 0xf6, 0x7e, 0x49, 0x5c, 0x92, + 0x78, 0x47, 0xd0, 0x3d, 0xa1, 0xe3, 0xd8, 0x8f, 0x5e, 0x3f, 0x62, 0xa4, 0xc7, 0x14, 0x8b, 0x89, + 0x4f, 0x03, 0x79, 0x5b, 0xd0, 0xcb, 0x45, 0x99, 0x4d, 0xff, 0x53, 0x03, 0xfa, 0x4f, 0xc2, 0xf0, + 0x15, 0x31, 0x39, 0x80, 0x0d, 0x41, 0xf8, 0x94, 0x4a, 0x89, 0x75, 0xe5, 0xce, 0x02, 0x46, 0x0f, + 0xc0, 0xc9, 0x52, 0xc2, 0x95, 0xa6, 0xf6, 0x41, 0xdb, 0xac, 0xe4, 0x2c, 0x25, 0x1c, 0xab, 0x09, + 0x84, 0xc0, 0xf1, 0xa5, 0x2f, 0x1d, 0xe5, 0x4b, 0x35, 0x96, 0x26, 0x93, 0xf8, 0xd2, 0x5d, 0x53, + 0x28, 0x39, 0x94, 0x98, 0xe0, 0x2a, 0x34, 0x3b, 0x2c, 0x87, 0xf9, 0xb2, 0x9a, 0xe5, 0xb2, 0x8a, + 0xb0, 0xd9, 0x58, 0x1e, 0x36, 0xad, 0x15, 0x61, 0x03, 0x95, 0xb0, 0xf1, 0xa0, 0x13, 0xf8, 0x89, + 0x7f, 0x4e, 0x23, 0x2a, 0x28, 0x49, 0xdd, 0xb6, 0x32, 0xa2, 0x82, 0x43, 0x7b, 0xb0, 0xe9, 0x27, + 0x89, 0xcf, 0xa7, 0x8c, 0x0f, 0x39, 0x7b, 0x49, 0x23, 0xe2, 0x76, 0x94, 0x90, 0x79, 0xb4, 0x94, + 0x96, 0x92, 0x88, 0xc6, 0xd9, 0xec, 0xb9, 0x8c, 0x3e, 0xb7, 0xab, 0xc8, 0x2a, 0x38, 0x29, 0x2d, + 0x66, 0x9f, 0x91, 0xab, 0x21, 0xa7, 0x97, 0x34, 0x22, 0x63, 0x92, 0xba, 0x3d, 0xe5, 0xc5, 0x79, + 0x34, 0x7a, 0x17, 0x9a, 0x3c, 0xa2, 0x53, 0x2a, 0x52, 0x77, 0x73, 0xb7, 0xb1, 0xd7, 0x3e, 0xe8, + 0x1a, 0x7f, 0x62, 0x85, 0xc5, 0xf9, 0xac, 0xf7, 0x0c, 0xd6, 0x35, 0x4a, 0xba, 0x57, 0x92, 0x98, + 0xdd, 0x52, 0x63, 0x89, 0x4b, 0xd9, 0x4b, 0xa1, 0xf6, 0xca, 0xc1, 0x6a, 0x2c, 0x71, 0x13, 0x9f, + 0x87, 0x6a, 0x9f, 0x1c, 0xac, 0xc6, 0x1e, 0x06, 0x47, 0x6e, 0x94, 0x74, 0x75, 0x66, 0x36, 0xbc, + 0x8b, 0xe5, 0x50, 0x62, 0xc6, 0x26, 0xa6, 0xba, 0x58, 0x0e, 0xd1, 0x37, 0xa1, 0xe7, 0x87, 0x21, + 0x15, 0x94, 0xc5, 0x7e, 0xf4, 0x09, 0x0d, 0x53, 0xb7, 0xb1, 0xdb, 0xd8, 0xeb, 0xe2, 0x39, 0xac, + 0x77, 0x00, 0xc8, 0x0e, 0x28, 0x13, 0xf4, 0x6f, 0x42, 0x2b, 0xbd, 0x4e, 0x05, 0x99, 0x0e, 0x0b, + 0x3d, 0x25, 0xc2, 0xfb, 0x65, 0xad, 0x48, 0x97, 0x22, 0x8b, 0x56, 0xc5, 0xe2, 0x77, 0x2b, 0xb5, + 0xa5, 0xae, 0xa2, 0xae, 0x9f, 0xe7, 0x4f, 0xc9, 0x6d, 0x97, 0x9b, 0x85, 0x94, 0x6d, 0x2c, 0x4b, + 0xd9, 0x01, 0xb8, 0x8b, 0x36, 0x98, 0x34, 0x09, 0xe0, 0xee, 0x33, 0x12, 0x91, 0xd7, 0xb1, 0x0f, + 0x81, 0x13, 0xfb, 0x53, 0x62, 0xd2, 0x51, 0x8d, 0x5f, 0xdf, 0x80, 0x45, 0x25, 0xc6, 0x80, 0x63, + 0xb8, 0xf3, 0x9c, 0xa6, 0xe2, 0xd5, 0xea, 0x17, 0x54, 0xd5, 0x97, 0xa9, 0xfa, 0x5d, 0x0d, 0xa0, + 0x94, 0x55, 0xd8, 0x5c, 0xb3, 0x6c, 0x46, 0xe0, 0x90, 0x19, 0x15, 0x26, 0xdf, 0xd5, 0x58, 0x46, + 0x85, 0x08, 0x12, 0x73, 0x04, 0xc9, 0xa1, 0xac, 0x97, 0x59, 0x4c, 0x67, 0x27, 0x2c, 0xb8, 0x20, + 0x22, 0x55, 0xf5, 0x7c, 0x03, 0xdb, 0x28, 0x95, 0xb4, 0x13, 0x12, 0x45, 0xaa, 0xa8, 0x6f, 0x60, + 0x0d, 0xc8, 0x0a, 0x4c, 0xa6, 0x89, 0xb8, 0xfe, 0xec, 0xc4, 0x5d, 0x57, 0xf9, 0x97, 0x83, 0xde, + 0x31, 0xec, 0xcc, 0xaf, 0xd4, 0xc4, 0xd0, 0x23, 0x68, 0x97, 0xab, 0x48, 0xdd, 0x9a, 0x4a, 0x90, + 0x25, 0x5b, 0x6f, 0x53, 0x79, 0xf7, 0xa1, 0x73, 0x22, 0x7c, 0x41, 0x56, 0xf8, 0xcb, 0xdb, 0x83, + 0x5e, 0x51, 0x75, 0x15, 0xa1, 0xae, 0x1b, 0xbe, 0xc8, 0x52, 0x43, 0x65, 0x20, 0xef, 0xcf, 0x0d, + 0x68, 0x9a, 0xb0, 0xce, 0x6b, 0x53, 0xad, 0xac, 0x4d, 0xff, 0x93, 0x12, 0x59, 0xc9, 0xaa, 0xe6, + 0x5c, 0x56, 0xfd, 0xbf, 0x5c, 0x96, 0xe5, 0xf2, 0xaf, 0x35, 0x68, 0x15, 0xdb, 0xfc, 0xb5, 0xdb, + 0x99, 0xf7, 0xa0, 0x95, 0xe8, 0x8d, 0x27, 0xba, 0xea, 0xb5, 0x0f, 0x7a, 0x46, 0x51, 0x5e, 0xe7, + 0x4a, 0x02, 0x2b, 0x7e, 0x1c, 0x3b, 0x7e, 0xac, 0x76, 0x65, 0xad, 0xd2, 0xae, 0x20, 0x70, 0x12, + 0x59, 0x4e, 0xd7, 0x55, 0x39, 0x55, 0x63, 0xbb, 0x41, 0x69, 0x56, 0x1a, 0x14, 0xef, 0x43, 0x68, + 0x1e, 0xfb, 0xc1, 0x84, 0xc6, 0x2a, 0x43, 0x83, 0xc4, 0x84, 0x69, 0x17, 0xab, 0xb1, 0x54, 0x32, + 0x25, 0x53, 0xc6, 0xaf, 0x4d, 0xed, 0x37, 0x90, 0x77, 0x01, 0x5d, 0x93, 0x06, 0x26, 0x99, 0x1e, + 0x02, 0x14, 0x2d, 0x46, 0x9e, 0x4b, 0x8b, 0x6d, 0x88, 0x45, 0x83, 0xf6, 0xa0, 0x39, 0xd5, 0x9a, + 0x4d, 0xd5, 0xcd, 0x7d, 0x60, 0xec, 0xc1, 0xf9, 0xb4, 0xf7, 0xeb, 0x1a, 0xec, 0xe8, 0x1e, 0xf3, + 0x95, 0x9d, 0xe4, 0xf2, 0xde, 0x45, 0xbb, 0xaf, 0x51, 0x71, 0xdf, 0x23, 0x68, 0x71, 0x92, 0xb2, + 0x8c, 0x07, 0x44, 0x7b, 0xb6, 0x7d, 0x70, 0x27, 0xcf, 0x24, 0xa5, 0x0b, 0x9b, 0x59, 0x5c, 0xd2, + 0x79, 0xff, 0x68, 0x42, 0xaf, 0x3a, 0x2b, 0x2b, 0xd6, 0x79, 0x74, 0x41, 0xd9, 0x0b, 0xdd, 0x1c, + 0xd7, 0x94, 0x9b, 0x6c, 0x94, 0xcc, 0xaa, 0x20, 0xc9, 0x4e, 0x26, 0x3e, 0x27, 0xa9, 0x71, 0x63, + 0x89, 0x30, 0xb3, 0x43, 0xc2, 0x29, 0xcb, 0x0f, 0xd3, 0x12, 0x21, 0xcb, 0x40, 0x90, 0x64, 0x5f, + 0x64, 0x4c, 0xf8, 0xca, 0x48, 0x07, 0x17, 0xb0, 0xea, 0x8a, 0x93, 0x2c, 0x25, 0xe2, 0x50, 0xee, + 0xda, 0x9a, 0xe9, 0x8a, 0x0b, 0x4c, 0x39, 0x7f, 0x4c, 0xa6, 0xa9, 0x49, 0x73, 0x0b, 0x23, 0x2d, + 0xd7, 0xbb, 0xf9, 0x5c, 0x06, 0xb5, 0x0a, 0x0c, 0x07, 0xdb, 0x28, 0x29, 0x41, 0x83, 0x27, 0x57, + 0x7e, 0xa2, 0xd2, 0xde, 0xc1, 0x16, 0x06, 0xbd, 0x07, 0x7d, 0x0d, 0x61, 0x92, 0x12, 0x7e, 0xe9, + 0xcb, 0x63, 0x5b, 0x95, 0x01, 0x07, 0x2f, 0x4e, 0x48, 0xea, 0x0b, 0xc2, 0x63, 0x12, 0x1d, 0x5b, + 0x5a, 0x41, 0x53, 0x2f, 0x4c, 0xa0, 0x03, 0xd8, 0xd6, 0xc8, 0xd3, 0xc3, 0xa1, 0xcd, 0xd0, 0x56, + 0x0c, 0x4b, 0xe7, 0x64, 0xa6, 0x2b, 0xc7, 0x3f, 0x27, 0xfe, 0x4b, 0xb3, 0x1f, 0x1d, 0x45, 0x3e, + 0x8f, 0x46, 0x4f, 0xa0, 0x6f, 0x6d, 0xd1, 0x33, 0x72, 0x49, 0x03, 0xe2, 0x76, 0x55, 0xd4, 0xde, + 0x36, 0x51, 0x60, 0x4f, 0xe1, 0x45, 0x6a, 0x74, 0x06, 0x03, 0x85, 0x3c, 0x9d, 0x70, 0x26, 0x44, + 0x44, 0x30, 0xf1, 0xc3, 0xa7, 0x49, 0x6a, 0x64, 0xf5, 0x94, 0xac, 0x3c, 0xa2, 0x72, 0x1a, 0x23, + 0xed, 0x06, 0x46, 0xf4, 0x02, 0xde, 0xa8, 0xcc, 0xbe, 0xe0, 0x54, 0x90, 0x52, 0xee, 0xe6, 0x4d, + 0x72, 0x6f, 0xe2, 0x5c, 0x10, 0x2c, 0xd5, 0x1e, 0xb1, 0x42, 0xf0, 0xd6, 0xeb, 0x0b, 0xae, 0x72, + 0xa2, 0x9f, 0xc1, 0x9b, 0x8b, 0x7a, 0x2d, 0xc9, 0xfd, 0x9b, 0x24, 0xdf, 0xc8, 0x2a, 0x93, 0x43, + 0xd6, 0x2f, 0xbd, 0xf3, 0x48, 0x27, 0x47, 0x81, 0x90, 0x01, 0x15, 0x24, 0x19, 0x26, 0x7e, 0x24, + 0x4b, 0x99, 0x49, 0xa1, 0xdb, 0x3a, 0xa0, 0x16, 0x26, 0xd0, 0x3e, 0x20, 0x0b, 0x89, 0x4d, 0x39, + 0xdc, 0xde, 0xad, 0xed, 0x35, 0xf0, 0x92, 0x19, 0xef, 0x23, 0xe8, 0x3e, 0x8d, 0x58, 0x70, 0x71, + 0xf4, 0xb9, 0x31, 0xa6, 0x72, 0xa1, 0x6f, 0x2c, 0xbd, 0xd0, 0x37, 0xcc, 0x85, 0xde, 0xfb, 0x0a, + 0x3a, 0x95, 0x60, 0xf9, 0x9e, 0xaa, 0x12, 0xb9, 0x28, 0x73, 0x4d, 0xdb, 0x36, 0x2e, 0xa9, 0xa8, + 0xc1, 0x36, 0xa1, 0xac, 0x5e, 0x57, 0x3a, 0x90, 0x75, 0xeb, 0x6c, 0x20, 0x99, 0x99, 0x51, 0x19, + 0xe4, 0xfa, 0x56, 0x66, 0x61, 0xbc, 0x9f, 0x43, 0xaf, 0xea, 0xe8, 0xff, 0xd8, 0x02, 0x04, 0x0e, + 0xf7, 0x05, 0xc9, 0x7b, 0x7f, 0x39, 0xf6, 0xee, 0xc1, 0xdd, 0x85, 0x7a, 0x6c, 0x1a, 0xcb, 0x6b, + 0xe8, 0x7e, 0x7c, 0x49, 0x62, 0x51, 0xdc, 0xfd, 0x1e, 0x43, 0xab, 0xf8, 0xa1, 0x62, 0x0a, 0xfd, + 0x60, 0x5f, 0xff, 0x72, 0xd9, 0xcf, 0x7f, 0xb9, 0xec, 0x9f, 0xe6, 0x14, 0xb8, 0x24, 0x96, 0x6b, + 0x4c, 0x05, 0xe3, 0x24, 0xfc, 0x3c, 0x8e, 0xae, 0xf3, 0xff, 0x14, 0x25, 0xc6, 0xd4, 0x7e, 0xa7, + 0x68, 0xbd, 0x7e, 0x5b, 0x83, 0x35, 0xa5, 0x7b, 0xe9, 0x1d, 0x46, 0x53, 0xd7, 0x8b, 0x93, 0xa2, + 0x7a, 0x2e, 0x74, 0x8b, 0x73, 0xc1, 0x9c, 0x20, 0x4e, 0x79, 0x82, 0x54, 0x56, 0xb0, 0xfe, 0x35, + 0x56, 0xe0, 0xfd, 0xa6, 0x0e, 0x9d, 0xcf, 0x88, 0xb8, 0x62, 0xfc, 0x42, 0x9e, 0x96, 0xe9, 0xd2, + 0xc6, 0xf8, 0x1e, 0x6c, 0xf0, 0xd9, 0xe8, 0xfc, 0x5a, 0x14, 0xa7, 0x43, 0x93, 0xcf, 0x9e, 0x4a, + 0x10, 0xbd, 0x05, 0xc0, 0x67, 0xa3, 0xa1, 0xaf, 0x9b, 0x61, 0x73, 0x38, 0xf0, 0x99, 0x41, 0xa0, + 0x37, 0xa0, 0x85, 0x67, 0x23, 0xc2, 0x39, 0xe3, 0x69, 0x7e, 0x3a, 0xe0, 0xd9, 0xc7, 0x0a, 0x96, + 0xbc, 0x78, 0x36, 0x0a, 0x39, 0x4b, 0x12, 0x12, 0xaa, 0xd3, 0xc1, 0xc1, 0x2d, 0x3c, 0x7b, 0xa6, + 0x11, 0x52, 0xeb, 0x69, 0xae, 0x75, 0x5d, 0x6b, 0x3d, 0x2d, 0xb5, 0x9e, 0xce, 0x46, 0x89, 0xd1, + 0xaa, 0x8f, 0x85, 0xd6, 0xa9, 0xad, 0xf5, 0xb4, 0xd0, 0xaa, 0xcf, 0x84, 0x8d, 0x53, 0x4b, 0xeb, + 0x69, 0xa9, 0xb5, 0x95, 0xf3, 0x1a, 0xad, 0xde, 0x1f, 0x6b, 0xb0, 0x71, 0x98, 0x64, 0x67, 0xa9, + 0x3f, 0x26, 0xe8, 0x01, 0xb4, 0x05, 0x13, 0x7e, 0x34, 0xca, 0x24, 0x68, 0x4e, 0x4e, 0x50, 0x28, + 0x4d, 0xf0, 0x36, 0x74, 0x12, 0xc2, 0x83, 0x24, 0x33, 0x14, 0xf5, 0xdd, 0x86, 0x3c, 0xa1, 0x34, + 0x4e, 0x93, 0xec, 0xc3, 0x6d, 0x35, 0x37, 0xa2, 0xf1, 0x48, 0x1f, 0x09, 0x53, 0x16, 0x12, 0xe3, + 0xaa, 0xbe, 0x9a, 0x3a, 0x8a, 0x3f, 0x2d, 0x26, 0xd0, 0xb7, 0xa1, 0x5f, 0xd0, 0xcb, 0x56, 0x59, + 0x51, 0x6b, 0xd7, 0x6d, 0x1a, 0xea, 0x33, 0x83, 0xf6, 0xbe, 0x2a, 0x72, 0x88, 0xc6, 0xe3, 0x67, + 0xbe, 0xf0, 0x65, 0x1b, 0x95, 0xa8, 0x62, 0x92, 0x1a, 0x6b, 0x73, 0x10, 0x7d, 0x07, 0xfa, 0xc2, + 0xe4, 0x5b, 0x38, 0xca, 0x69, 0xf4, 0x6e, 0x6e, 0x15, 0x13, 0x43, 0x43, 0xfc, 0x0d, 0xe8, 0x95, + 0xc4, 0xaa, 0x0a, 0x69, 0x7b, 0xbb, 0x05, 0x56, 0x46, 0x93, 0xf7, 0x7b, 0xed, 0x2c, 0x1d, 0x39, + 0xef, 0xa9, 0x36, 0xc1, 0x72, 0x55, 0xfb, 0x60, 0x33, 0x6f, 0xaf, 0x8c, 0x33, 0x54, 0x6b, 0xa0, + 0xdd, 0xf2, 0x43, 0xd8, 0x14, 0x85, 0xe9, 0xa3, 0xd0, 0x17, 0xbe, 0x49, 0xbd, 0xb9, 0x2a, 0x6c, + 0x16, 0x86, 0x7b, 0xa2, 0xba, 0xd0, 0xb7, 0xa1, 0xa3, 0xfb, 0x7e, 0xa3, 0x50, 0xdb, 0xd7, 0xd6, + 0x38, 0xa5, 0xc2, 0xfb, 0x08, 0x5a, 0x43, 0x1a, 0xa6, 0xda, 0x3a, 0x17, 0x9a, 0x41, 0xc6, 0x39, + 0x89, 0xf3, 0x06, 0x28, 0x07, 0x65, 0x79, 0x54, 0x3d, 0xb3, 0x71, 0x86, 0x06, 0x3c, 0x06, 0xa0, + 0xcf, 0x6d, 0xa5, 0x6d, 0x1b, 0xd6, 0xec, 0x10, 0xd0, 0x80, 0x8c, 0xb3, 0xa9, 0x3f, 0x2b, 0xb6, + 0x5e, 0xc5, 0xd9, 0xd4, 0x9f, 0xe9, 0x05, 0xba, 0xd0, 0x7c, 0xe9, 0xd3, 0x28, 0x30, 0xbf, 0x03, + 0x1d, 0x9c, 0x83, 0xa5, 0x42, 0xc7, 0x56, 0xf8, 0x87, 0x3a, 0xb4, 0xb5, 0x46, 0x6d, 0xf0, 0x36, + 0xac, 0x05, 0x7e, 0x30, 0x29, 0x54, 0x2a, 0x00, 0xbd, 0x9b, 0x1b, 0x52, 0xfd, 0x0d, 0x50, 0x9a, + 0x9a, 0xdb, 0xf6, 0x10, 0x20, 0xbd, 0xf2, 0x13, 0xcb, 0x3b, 0x4b, 0xa9, 0x5b, 0x92, 0x48, 0x1b, + 0xfc, 0x01, 0x74, 0x74, 0x7c, 0x1a, 0x1e, 0x67, 0x15, 0x4f, 0x5b, 0x93, 0x69, 0xae, 0x47, 0xf2, + 0xca, 0xe5, 0x0b, 0xdd, 0xe2, 0xb7, 0x0f, 0xde, 0xaa, 0x90, 0xab, 0x95, 0xec, 0xab, 0xef, 0xc7, + 0xb1, 0xe0, 0xd7, 0x58, 0xd3, 0x0e, 0x1e, 0x03, 0x94, 0x48, 0x59, 0xcf, 0x2e, 0xc8, 0x75, 0x7e, + 0xb5, 0xbc, 0x20, 0xd7, 0x72, 0xed, 0x97, 0x7e, 0x94, 0xe5, 0x4e, 0xd5, 0xc0, 0x0f, 0xea, 0x8f, + 0x6b, 0x5e, 0x00, 0x9b, 0x4f, 0xe5, 0x71, 0x6c, 0xb1, 0x57, 0x0e, 0x3d, 0x67, 0xe9, 0xa1, 0xe7, + 0xe4, 0x7f, 0xb1, 0x7b, 0x50, 0x67, 0x89, 0x69, 0xb3, 0xeb, 0x2c, 0x29, 0x15, 0x39, 0x96, 0x22, + 0xef, 0xef, 0x0e, 0x40, 0xa9, 0x05, 0x9d, 0xc0, 0x80, 0xb2, 0x91, 0xec, 0x12, 0x69, 0x40, 0x74, + 0x41, 0x1a, 0x71, 0x12, 0x64, 0x3c, 0xa5, 0x97, 0xc4, 0x5c, 0x24, 0x76, 0x8a, 0x63, 0xaa, 0x62, + 0x1c, 0xbe, 0x4b, 0xd9, 0x89, 0x66, 0x54, 0x95, 0x0b, 0xe7, 0x6c, 0xe8, 0x27, 0x70, 0xa7, 0x14, + 0x1a, 0x5a, 0xf2, 0xea, 0x37, 0xca, 0xbb, 0x5d, 0xc8, 0x0b, 0x4b, 0x59, 0x3f, 0x82, 0xdb, 0x94, + 0x8d, 0xbe, 0xcc, 0x48, 0x56, 0x91, 0xd4, 0xb8, 0x51, 0x52, 0x9f, 0xb2, 0x2f, 0x14, 0x47, 0x29, + 0xe7, 0x0b, 0xb8, 0x67, 0x2d, 0x54, 0xa6, 0xbd, 0x25, 0xcd, 0xb9, 0x51, 0xda, 0x4e, 0x61, 0x97, + 0x2c, 0x0c, 0xa5, 0xc8, 0x4f, 0x61, 0x87, 0xb2, 0xd1, 0x95, 0x4f, 0xc5, 0xbc, 0xbc, 0xb5, 0x57, + 0xad, 0xf3, 0x85, 0x4f, 0x45, 0x55, 0x98, 0x5e, 0xe7, 0x94, 0xf0, 0x71, 0x65, 0x9d, 0xeb, 0xaf, + 0x5a, 0xe7, 0xb1, 0xe2, 0x28, 0xe5, 0x3c, 0x85, 0x3e, 0x65, 0xf3, 0xf6, 0x34, 0x6f, 0x94, 0xb2, + 0x49, 0x59, 0xd5, 0x96, 0x43, 0xe8, 0xa7, 0x24, 0x10, 0x8c, 0xdb, 0xb1, 0xb0, 0x71, 0xa3, 0x8c, + 0x2d, 0xc3, 0x50, 0x08, 0xf1, 0xbe, 0x84, 0xce, 0x8f, 0xb3, 0x31, 0x11, 0xd1, 0x79, 0x91, 0xf3, + 0xff, 0xed, 0x32, 0xf3, 0xaf, 0x3a, 0xb4, 0x0f, 0xc7, 0x9c, 0x65, 0x49, 0xa5, 0x6a, 0xeb, 0x1c, + 0x5e, 0xa8, 0xda, 0x8a, 0x46, 0x55, 0x6d, 0x4d, 0xfd, 0x21, 0x74, 0xf4, 0xad, 0xc9, 0x30, 0xe8, + 0x2a, 0x84, 0x16, 0x93, 0x3e, 0xbf, 0xa5, 0x69, 0xb6, 0x03, 0x73, 0x03, 0x35, 0x5c, 0xd5, 0x6a, + 0x54, 0xba, 0x09, 0xc3, 0x79, 0x99, 0x75, 0x47, 0xd0, 0x9d, 0x68, 0xdf, 0x18, 0x2e, 0x1d, 0x80, + 0xef, 0xe4, 0xc6, 0x95, 0x6b, 0xd8, 0xb7, 0x7d, 0xa8, 0x5d, 0xdd, 0x99, 0xd8, 0x6e, 0x7d, 0x1f, + 0x40, 0xb6, 0xe4, 0xa3, 0xbc, 0x50, 0xd9, 0x0f, 0x10, 0xc5, 0x09, 0xa1, 0xdb, 0x76, 0x35, 0x1c, + 0x9c, 0x42, 0x7f, 0x41, 0xe6, 0x92, 0x32, 0xf5, 0x2d, 0xbb, 0x4c, 0x95, 0xd7, 0x32, 0x9b, 0xd5, + 0xae, 0x5d, 0x7f, 0xa9, 0xe9, 0x5f, 0x12, 0xe5, 0x3f, 0xe2, 0xc7, 0xd0, 0x8d, 0x75, 0xf3, 0x55, + 0x6c, 0x80, 0x7d, 0xbf, 0xb3, 0x1b, 0x33, 0xdc, 0x89, 0xed, 0x36, 0xed, 0x43, 0xe8, 0x04, 0xca, + 0x03, 0x4b, 0x37, 0xc2, 0x72, 0x0e, 0x6e, 0x07, 0xd6, 0x6e, 0x57, 0x1a, 0x45, 0xe7, 0xeb, 0x34, + 0x8a, 0xe6, 0xaf, 0xe2, 0xaa, 0x07, 0x93, 0x83, 0x7f, 0xae, 0x43, 0xe3, 0xc9, 0xf0, 0x08, 0x9d, + 0xc1, 0xd6, 0xfc, 0x7b, 0x23, 0xba, 0x6f, 0xcc, 0x5a, 0xf1, 0x46, 0x39, 0x78, 0xb0, 0x72, 0xde, + 0xb4, 0xec, 0xb7, 0x10, 0x86, 0xcd, 0xb9, 0xd7, 0x25, 0x94, 0x1f, 0x35, 0xcb, 0x5f, 0xf0, 0x06, + 0xf7, 0x57, 0x4d, 0xdb, 0x32, 0xe7, 0xee, 0x08, 0x85, 0xcc, 0xe5, 0xff, 0x72, 0x0a, 0x99, 0xab, + 0xae, 0x16, 0xb7, 0xd0, 0xf7, 0x61, 0x5d, 0xbf, 0x37, 0xa1, 0xfc, 0xe2, 0x52, 0x79, 0xc9, 0x1a, + 0xdc, 0x99, 0xc3, 0x16, 0x8c, 0xcf, 0xa1, 0x5b, 0x79, 0xa4, 0x44, 0x6f, 0x54, 0x74, 0x55, 0x9f, + 0xab, 0x06, 0x6f, 0x2e, 0x9f, 0x2c, 0xa4, 0x1d, 0x02, 0x94, 0x4f, 0x12, 0xc8, 0x35, 0xd4, 0x0b, + 0xcf, 0x5e, 0x83, 0x7b, 0x4b, 0x66, 0x0a, 0x21, 0x67, 0xb0, 0x35, 0xff, 0x3c, 0x80, 0xe6, 0xbc, + 0x3a, 0xff, 0x73, 0xbe, 0xd8, 0xca, 0x95, 0xef, 0x0a, 0x4a, 0xec, 0xfc, 0x4f, 0xff, 0x42, 0xec, + 0x8a, 0x27, 0x87, 0x42, 0xec, 0xca, 0xd7, 0x82, 0x5b, 0xe8, 0x73, 0xe8, 0x55, 0xff, 0xa2, 0xa3, + 0xdc, 0x49, 0x4b, 0x9f, 0x11, 0x06, 0x6f, 0xad, 0x98, 0x2d, 0x04, 0x7e, 0x00, 0x6b, 0xfa, 0xf7, + 0x78, 0x9e, 0x8e, 0xf6, 0x5f, 0xf5, 0xc1, 0x76, 0x15, 0x59, 0x70, 0x3d, 0x84, 0x75, 0x7d, 0xbb, + 0x2c, 0x02, 0xa0, 0x72, 0xd9, 0x1c, 0x74, 0x6c, 0xac, 0x77, 0xeb, 0x61, 0x2d, 0xd7, 0x93, 0x56, + 0xf4, 0xa4, 0xcb, 0xf4, 0x58, 0x9b, 0x73, 0xbe, 0xae, 0xd2, 0xf5, 0xd1, 0xbf, 0x03, 0x00, 0x00, + 0xff, 0xff, 0x8c, 0xbd, 0xc2, 0x0b, 0x2e, 0x20, 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/api/grpc/types/api.proto b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/api/grpc/types/api.proto index 902f6c17c..e9a6d1074 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/api/grpc/types/api.proto +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/api/grpc/types/api.proto @@ -211,6 +211,8 @@ message UpdateResource { repeated ThrottleDevice blkioThrottleReadIopsDevice = 16; repeated ThrottleDevice blkioThrottleWriteIopsDevice = 17; uint64 pidsLimit = 18; + uint64 cpuRealtimePeriod = 19; + int64 cpuRealtimeRuntime = 20; } message BlockIODevice { diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/container.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/container.go index fe5fb3b28..9e1d24fde 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/container.go +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/container.go @@ -434,7 +434,7 @@ func (c *container) Start(ctx context.Context, checkpointPath string, s Stdio) ( c: c, stdio: s, spec: spec, - processSpec: specs.ProcessSpec(spec.Process), + processSpec: specs.ProcessSpec(*spec.Process), } p, err := newProcess(config) if err != nil { @@ -544,7 +544,6 @@ func (c *container) createCmd(ctx context.Context, pid string, cmd *exec.Cmd, p case err := <-ch: return err } - return nil } func hostIDFromMap(id uint32, mp []ocs.LinuxIDMapping) int { diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/container_linux.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/container_linux.go index 9f3526a10..265a38c4d 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/container_linux.go +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/container_linux.go @@ -112,18 +112,20 @@ func i64Ptr(i int64) *int64 { return &i } func (c *container) UpdateResources(r *Resource) error { sr := ocs.LinuxResources{ Memory: &ocs.LinuxMemory{ - Limit: u64Ptr(uint64(r.Memory)), - Reservation: u64Ptr(uint64(r.MemoryReservation)), - Swap: u64Ptr(uint64(r.MemorySwap)), - Kernel: u64Ptr(uint64(r.KernelMemory)), - KernelTCP: u64Ptr(uint64(r.KernelTCPMemory)), + Limit: i64Ptr(r.Memory), + Reservation: i64Ptr(r.MemoryReservation), + Swap: i64Ptr(r.MemorySwap), + Kernel: i64Ptr(r.KernelMemory), + KernelTCP: i64Ptr(r.KernelTCPMemory), }, CPU: &ocs.LinuxCPU{ - Shares: u64Ptr(uint64(r.CPUShares)), - Quota: i64Ptr(int64(r.CPUQuota)), - Period: u64Ptr(uint64(r.CPUPeriod)), - Cpus: r.CpusetCpus, - Mems: r.CpusetMems, + Shares: u64Ptr(uint64(r.CPUShares)), + Quota: i64Ptr(int64(r.CPUQuota)), + Period: u64Ptr(uint64(r.CPUPeriod)), + Cpus: r.CpusetCpus, + Mems: r.CpusetMems, + RealtimePeriod: u64Ptr(uint64(r.CPURealtimePeriod)), + RealtimeRuntime: i64Ptr(int64(r.CPURealtimdRuntime)), }, BlockIO: &ocs.LinuxBlockIO{ Weight: &r.BlkioWeight, diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/process.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/process.go index ea6ec0c37..903e831a8 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/process.go +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/process.go @@ -233,7 +233,7 @@ func (p *process) updateExitStatusFile(status uint32) (uint32, error) { p.stateLock.Lock() p.state = Stopped p.stateLock.Unlock() - err := ioutil.WriteFile(filepath.Join(p.root, ExitStatusFile), []byte(fmt.Sprintf("%u", status)), 0644) + err := ioutil.WriteFile(filepath.Join(p.root, ExitStatusFile), []byte(fmt.Sprintf("%d", status)), 0644) return status, err } @@ -262,10 +262,27 @@ func (p *process) handleSigkilledShim(rst uint32, rerr error) (uint32, error) { } if ppid == "1" { logrus.Warnf("containerd: %s:%s shim died, killing associated process", p.container.id, p.id) + // Before sending SIGKILL to container, we need to make sure + // the container is not in Paused state. If the container is + // Paused, the container will not response to any signal + // we should Resume it after sending SIGKILL + var ( + s State + err1 error + ) + if p.container != nil { + s, err1 = p.container.Status() + } + unix.Kill(p.pid, syscall.SIGKILL) if err != nil && err != syscall.ESRCH { return UnknownStatus, fmt.Errorf("containerd: unable to SIGKILL %s:%s (pid %v): %v", p.container.id, p.id, p.pid, err) } + if p.container != nil { + if err1 == nil && s == Paused { + p.container.Resume() + } + } // wait for the process to die for { @@ -283,14 +300,23 @@ func (p *process) handleSigkilledShim(rst uint32, rerr error) (uint32, error) { return rst, rerr } - // Possible that the shim was SIGKILLED - e := unix.Kill(p.cmd.Process.Pid, 0) - if e != syscall.ESRCH { - return rst, rerr + // The shim was SIGKILLED + // We should get the container state first + // to make sure the container is not in + // Pause state, if it's Paused, we should resume it + // and it will exit immediately because shim will send sigkill to + // container when died. + s, err1 := p.container.Status() + if err1 == nil && s == Paused { + p.container.Resume() } // Ensure we got the shim ProcessState - <-p.cmdDoneCh + select { + case <-p.cmdDoneCh: + case <-time.After(2 * time.Minute): + return rst, fmt.Errorf("could not get the shim ProcessState within two minutes") + } shimStatus := p.cmd.ProcessState.Sys().(syscall.WaitStatus) if shimStatus.Signaled() && shimStatus.Signal() == syscall.SIGKILL { diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/runtime.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/runtime.go index eaba45285..f7024879b 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/runtime.go +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/runtime/runtime.go @@ -84,18 +84,20 @@ type State string // Resource regroups the various container limits that can be updated type Resource struct { - CPUShares int64 - BlkioWeight uint16 - CPUPeriod int64 - CPUQuota int64 - CpusetCpus string - CpusetMems string - KernelMemory int64 - KernelTCPMemory int64 - Memory int64 - MemoryReservation int64 - MemorySwap int64 - PidsLimit int64 + CPUShares int64 + BlkioWeight uint16 + CPUPeriod int64 + CPUQuota int64 + CpusetCpus string + CpusetMems string + KernelMemory int64 + KernelTCPMemory int64 + Memory int64 + MemoryReservation int64 + MemorySwap int64 + PidsLimit int64 + CPURealtimePeriod uint64 + CPURealtimdRuntime int64 } // Possible container states diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/specs/spec_linux.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/specs/spec_linux.go index 0b3160475..d415c1dc5 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/specs/spec_linux.go +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/specs/spec_linux.go @@ -8,5 +8,5 @@ type ( // Spec aliases the platform oci spec Spec oci.Spec // Rlimit aliases the platform resource limit - Rlimit oci.LinuxRlimit + Rlimit oci.POSIXRlimit ) diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/vendor.conf b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/vendor.conf new file mode 100755 index 000000000..734f6964f --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/containerd/vendor.conf @@ -0,0 +1,33 @@ +github.com/sirupsen/logrus v1.0.1 +github.com/cloudfoundry/gosigar 3ed7c74352dae6dc00bdc8c74045375352e3ec05 +github.com/urfave/cli 8ba6f23b6e36d03666a14bd9421f5e3efcb59aca +github.com/coreos/go-systemd 7b2428fec40033549c68f54e26e89e7ca9a9ce31 +github.com/cyberdelia/go-metrics-graphite 7e54b5c2aa6eaff4286c44129c3def899dff528c +github.com/docker/docker f577caff19d486d8d01443507d891cb1b0891cdc +github.com/docker/go-units 5d2041e26a699eaca682e2ea41c8f891e1060444 +github.com/godbus/dbus e2cf28118e66a6a63db46cf6088a35d2054d3bb0 +github.com/golang/glog 23def4e6c14b4da8ac2ed8007337bc5eb5007998 +github.com/golang/protobuf 8ee79997227bf9b34611aee7946ae64735e6fd93 +github.com/opencontainers/runc d40db12e72a40109dfcf28539f5ee0930d2f0277 +github.com/opencontainers/runtime-spec v1.0.0 +github.com/rcrowley/go-metrics eeba7bd0dd01ace6e690fa833b3f22aaec29af43 +github.com/satori/go.uuid f9ab0dce87d815821e221626b772e3475a0d2749 +github.com/syndtr/gocapability 2c00daeb6c3b45114c80ac44119e7b8801fdd852 +github.com/vishvananda/netlink adb0f53af689dd38f1443eba79489feaacf0b22e +github.com/Azure/go-ansiterm 70b2c90b260171e829f1ebd7c17f600c11858dbe +golang.org/x/net 991d3e32f76f19ee6d9caadb3a22eae8d23315f7 https://github.com/golang/net.git +golang.org/x/sys 0e0164865330d5cf1c00247be08330bf96e2f87c https://github.com/golang/sys +google.golang.org/grpc v1.0.4 https://github.com/grpc/grpc-go.git +github.com/seccomp/libseccomp-golang 1b506fc7c24eec5a3693cdcbed40d9c226cfc6a1 +github.com/tonistiigi/fifo b45391ebcd3d282404092c04a2b015b37df12383 +github.com/pkg/errors 839d9e913e063e28dfd0e6c7b7512793e0a48be9 + +github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3 +github.com/go-check/check a625211d932a2a643d0d17352095f03fb7774663 https://github.com/cpuguy83/check.git + +github.com/containerd/console a3863895279f5104533fd999c1babf80faffd98c +github.com/containerd/go-runc 5fe4d8cb7fdc0fae5f5a7f4f1d65a565032401b2 + +# dependencies of docker/pkg/listeners +github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d +github.com/Microsoft/go-winio v0.3.2 diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/LICENSE b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/LICENSE new file mode 100644 index 000000000..8f71f43fe --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. + diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/README.md b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/README.md new file mode 100644 index 000000000..0e91ce07b --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/README.md @@ -0,0 +1,74 @@ +# continuity + +[![GoDoc](https://godoc.org/github.com/containerd/continuity?status.svg)](https://godoc.org/github.com/containerd/continuity) +[![Build Status](https://travis-ci.org/containerd/continuity.svg?branch=master)](https://travis-ci.org/containerd/continuity) + +A transport-agnostic, filesystem metadata manifest system + +This project is a staging area for experiments in providing transport agnostic +metadata storage. + +Please see https://github.com/opencontainers/specs/issues/11 for more details. + +## Manifest Format + +A continuity manifest encodes filesystem metadata in Protocol Buffers. +Please refer to [proto/manifest.proto](proto/manifest.proto). + +## Usage + +Build: + +```console +$ make +``` + +Create a manifest (of this repo itself): + +```console +$ ./bin/continuity build . > /tmp/a.pb +``` + +Dump a manifest: + +```console +$ ./bin/continuity ls /tmp/a.pb +... +-rw-rw-r-- 270 B /.gitignore +-rw-rw-r-- 88 B /.mailmap +-rw-rw-r-- 187 B /.travis.yml +-rw-rw-r-- 359 B /AUTHORS +-rw-rw-r-- 11 kB /LICENSE +-rw-rw-r-- 1.5 kB /Makefile +... +-rw-rw-r-- 986 B /testutil_test.go +drwxrwxr-x 0 B /version +-rw-rw-r-- 478 B /version/version.go +``` + +Verify a manifest: + +```console +$ ./bin/continuity verify . /tmp/a.pb +``` + +Break the directory and restore using the manifest: +```console +$ chmod 777 Makefile +$ ./bin/continuity verify . /tmp/a.pb +2017/06/23 08:00:34 error verifying manifest: resource "/Makefile" has incorrect mode: -rwxrwxrwx != -rw-rw-r-- +$ ./bin/continuity apply . /tmp/a.pb +$ stat -c %a Makefile +664 +$ ./bin/continuity verify . /tmp/a.pb +``` + + +## Contribution Guide +### Building Proto Package + +If you change the proto file you will need to rebuild the generated Go with `go generate`. + +```console +$ go generate ./proto +``` diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices.go new file mode 100644 index 000000000..708640704 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices.go @@ -0,0 +1,5 @@ +package devices + +import "fmt" + +var ErrNotSupported = fmt.Errorf("not supported") diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_darwin.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_darwin.go new file mode 100644 index 000000000..5041e6661 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_darwin.go @@ -0,0 +1,15 @@ +package devices + +// from /usr/include/sys/types.h + +func getmajor(dev int32) uint64 { + return (uint64(dev) >> 24) & 0xff +} + +func getminor(dev int32) uint64 { + return uint64(dev) & 0xffffff +} + +func makedev(major int, minor int) int { + return ((major << 24) | minor) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_dummy.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_dummy.go new file mode 100644 index 000000000..9a48330a5 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_dummy.go @@ -0,0 +1,23 @@ +// +build solaris,!cgo + +// +// Implementing the functions below requires cgo support. Non-cgo stubs +// versions are defined below to enable cross-compilation of source code +// that depends on these functions, but the resultant cross-compiled +// binaries cannot actually be used. If the stub function(s) below are +// actually invoked they will cause the calling process to exit. +// + +package devices + +func getmajor(dev uint64) uint64 { + panic("getmajor() support requires cgo.") +} + +func getminor(dev uint64) uint64 { + panic("getminor() support requires cgo.") +} + +func makedev(major int, minor int) int { + panic("makedev() support requires cgo.") +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_freebsd.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_freebsd.go new file mode 100644 index 000000000..a5c7b9318 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_freebsd.go @@ -0,0 +1,15 @@ +package devices + +// from /usr/include/sys/types.h + +func getmajor(dev uint32) uint64 { + return (uint64(dev) >> 24) & 0xff +} + +func getminor(dev uint32) uint64 { + return uint64(dev) & 0xffffff +} + +func makedev(major int, minor int) int { + return ((major << 24) | minor) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_linux.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_linux.go new file mode 100644 index 000000000..454cf668f --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_linux.go @@ -0,0 +1,15 @@ +package devices + +// from /usr/include/linux/kdev_t.h + +func getmajor(dev uint64) uint64 { + return dev >> 8 +} + +func getminor(dev uint64) uint64 { + return dev & 0xff +} + +func makedev(major int, minor int) int { + return ((major << 8) | minor) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_solaris.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_solaris.go new file mode 100644 index 000000000..8819ac82f --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_solaris.go @@ -0,0 +1,18 @@ +// +build cgo + +package devices + +//#include +import "C" + +func getmajor(dev uint64) uint64 { + return uint64(C.major(C.dev_t(dev))) +} + +func getminor(dev uint64) uint64 { + return uint64(C.minor(C.dev_t(dev))) +} + +func makedev(major int, minor int) int { + return int(C.makedev(C.major_t(major), C.minor_t(minor))) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_unix.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_unix.go new file mode 100644 index 000000000..85e9a68c4 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_unix.go @@ -0,0 +1,55 @@ +// +build linux darwin freebsd solaris + +package devices + +import ( + "fmt" + "os" + "syscall" +) + +func DeviceInfo(fi os.FileInfo) (uint64, uint64, error) { + sys, ok := fi.Sys().(*syscall.Stat_t) + if !ok { + return 0, 0, fmt.Errorf("cannot extract device from os.FileInfo") + } + + return getmajor(sys.Rdev), getminor(sys.Rdev), nil +} + +// mknod provides a shortcut for syscall.Mknod +func Mknod(p string, mode os.FileMode, maj, min int) error { + var ( + m = syscallMode(mode.Perm()) + dev int + ) + + if mode&os.ModeDevice != 0 { + dev = makedev(maj, min) + + if mode&os.ModeCharDevice != 0 { + m |= syscall.S_IFCHR + } else { + m |= syscall.S_IFBLK + } + } else if mode&os.ModeNamedPipe != 0 { + m |= syscall.S_IFIFO + } + + return syscall.Mknod(p, m, dev) +} + +// syscallMode returns the syscall-specific mode bits from Go's portable mode bits. +func syscallMode(i os.FileMode) (o uint32) { + o |= uint32(i.Perm()) + if i&os.ModeSetuid != 0 { + o |= syscall.S_ISUID + } + if i&os.ModeSetgid != 0 { + o |= syscall.S_ISGID + } + if i&os.ModeSticky != 0 { + o |= syscall.S_ISVTX + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_windows.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_windows.go new file mode 100644 index 000000000..6099d1d77 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/devices/devices_windows.go @@ -0,0 +1,11 @@ +package devices + +import ( + "os" + + "github.com/pkg/errors" +) + +func DeviceInfo(fi os.FileInfo) (uint64, uint64, error) { + return 0, 0, errors.Wrap(ErrNotSupported, "cannot get device info on windows") +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/driver.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/driver.go new file mode 100644 index 000000000..aa1dd7d29 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/driver.go @@ -0,0 +1,162 @@ +package driver + +import ( + "fmt" + "io" + "os" +) + +var ErrNotSupported = fmt.Errorf("not supported") + +// Driver provides all of the system-level functions in a common interface. +// The context should call these with full paths and should never use the `os` +// package or any other package to access resources on the filesystem. This +// mechanism let's us carefully control access to the context and maintain +// path and resource integrity. It also gives us an interface to reason about +// direct resource access. +// +// Implementations don't need to do much other than meet the interface. For +// example, it is not required to wrap os.FileInfo to return correct paths for +// the call to Name(). +type Driver interface { + // Note that Open() returns a File interface instead of *os.File. This + // is because os.File is a struct, so if Open was to return *os.File, + // the only way to fulfill the interface would be to call os.Open() + Open(path string) (File, error) + OpenFile(path string, flag int, perm os.FileMode) (File, error) + + Stat(path string) (os.FileInfo, error) + Lstat(path string) (os.FileInfo, error) + Readlink(p string) (string, error) + Mkdir(path string, mode os.FileMode) error + Remove(path string) error + + Link(oldname, newname string) error + Lchmod(path string, mode os.FileMode) error + Lchown(path string, uid, gid int64) error + Symlink(oldname, newname string) error + + MkdirAll(path string, perm os.FileMode) error + RemoveAll(path string) error + + // TODO(aaronl): These methods might move outside the main Driver + // interface in the future as more platforms are added. + Mknod(path string, mode os.FileMode, major int, minor int) error + Mkfifo(path string, mode os.FileMode) error +} + +// File is the interface for interacting with files returned by continuity's Open +// This is needed since os.File is a struct, instead of an interface, so it can't +// be used. +type File interface { + io.ReadWriteCloser + io.Seeker + Readdir(n int) ([]os.FileInfo, error) +} + +func NewSystemDriver() (Driver, error) { + // TODO(stevvooe): Consider having this take a "hint" path argument, which + // would be the context root. The hint could be used to resolve required + // filesystem support when assembling the driver to use. + return &driver{}, nil +} + +// XAttrDriver should be implemented on operation systems and filesystems that +// have xattr support for regular files and directories. +type XAttrDriver interface { + // Getxattr returns all of the extended attributes for the file at path. + // Typically, this takes a syscall call to Listxattr and Getxattr. + Getxattr(path string) (map[string][]byte, error) + + // Setxattr sets all of the extended attributes on file at path, following + // any symbolic links, if necessary. All attributes on the target are + // replaced by the values from attr. If the operation fails to set any + // attribute, those already applied will not be rolled back. + Setxattr(path string, attr map[string][]byte) error +} + +// LXAttrDriver should be implemented by drivers on operating systems and +// filesystems that support setting and getting extended attributes on +// symbolic links. If this is not implemented, extended attributes will be +// ignored on symbolic links. +type LXAttrDriver interface { + // LGetxattr returns all of the extended attributes for the file at path + // and does not follow symlinks. Typically, this takes a syscall call to + // Llistxattr and Lgetxattr. + LGetxattr(path string) (map[string][]byte, error) + + // LSetxattr sets all of the extended attributes on file at path, without + // following symbolic links. All attributes on the target are replaced by + // the values from attr. If the operation fails to set any attribute, + // those already applied will not be rolled back. + LSetxattr(path string, attr map[string][]byte) error +} + +type DeviceInfoDriver interface { + DeviceInfo(fi os.FileInfo) (maj uint64, min uint64, err error) +} + +// driver is a simple default implementation that sends calls out to the "os" +// package. Extend the "driver" type in system-specific files to add support, +// such as xattrs, which can add support at compile time. +type driver struct{} + +var _ File = &os.File{} + +// LocalDriver is the exported Driver struct for convenience. +var LocalDriver Driver = &driver{} + +func (d *driver) Open(p string) (File, error) { + return os.Open(p) +} + +func (d *driver) OpenFile(path string, flag int, perm os.FileMode) (File, error) { + return os.OpenFile(path, flag, perm) +} + +func (d *driver) Stat(p string) (os.FileInfo, error) { + return os.Stat(p) +} + +func (d *driver) Lstat(p string) (os.FileInfo, error) { + return os.Lstat(p) +} + +func (d *driver) Readlink(p string) (string, error) { + return os.Readlink(p) +} + +func (d *driver) Mkdir(p string, mode os.FileMode) error { + return os.Mkdir(p, mode) +} + +// Remove is used to unlink files and remove directories. +// This is following the golang os package api which +// combines the operations into a higher level Remove +// function. If explicit unlinking or directory removal +// to mirror system call is required, they should be +// split up at that time. +func (d *driver) Remove(path string) error { + return os.Remove(path) +} + +func (d *driver) Link(oldname, newname string) error { + return os.Link(oldname, newname) +} + +func (d *driver) Lchown(name string, uid, gid int64) error { + // TODO: error out if uid excesses int bit width? + return os.Lchown(name, int(uid), int(gid)) +} + +func (d *driver) Symlink(oldname, newname string) error { + return os.Symlink(oldname, newname) +} + +func (d *driver) MkdirAll(path string, perm os.FileMode) error { + return os.MkdirAll(path, perm) +} + +func (d *driver) RemoveAll(path string) error { + return os.RemoveAll(path) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/driver_unix.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/driver_unix.go new file mode 100644 index 000000000..d9ab1656c --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/driver_unix.go @@ -0,0 +1,122 @@ +// +build linux darwin freebsd solaris + +package driver + +import ( + "errors" + "fmt" + "os" + "path/filepath" + "sort" + + "github.com/containerd/continuity/devices" + "github.com/containerd/continuity/sysx" +) + +func (d *driver) Mknod(path string, mode os.FileMode, major, minor int) error { + return devices.Mknod(path, mode, major, minor) +} + +func (d *driver) Mkfifo(path string, mode os.FileMode) error { + if mode&os.ModeNamedPipe == 0 { + return errors.New("mode passed to Mkfifo does not have the named pipe bit set") + } + // mknod with a mode that has ModeNamedPipe set creates a fifo, not a + // device. + return devices.Mknod(path, mode, 0, 0) +} + +// Lchmod changes the mode of an file not following symlinks. +func (d *driver) Lchmod(path string, mode os.FileMode) (err error) { + if !filepath.IsAbs(path) { + path, err = filepath.Abs(path) + if err != nil { + return + } + } + + return sysx.Fchmodat(0, path, uint32(mode), sysx.AtSymlinkNofollow) +} + +// Getxattr returns all of the extended attributes for the file at path p. +func (d *driver) Getxattr(p string) (map[string][]byte, error) { + xattrs, err := sysx.Listxattr(p) + if err != nil { + return nil, fmt.Errorf("listing %s xattrs: %v", p, err) + } + + sort.Strings(xattrs) + m := make(map[string][]byte, len(xattrs)) + + for _, attr := range xattrs { + value, err := sysx.Getxattr(p, attr) + if err != nil { + return nil, fmt.Errorf("getting %q xattr on %s: %v", attr, p, err) + } + + // NOTE(stevvooe): This append/copy tricky relies on unique + // xattrs. Break this out into an alloc/copy if xattrs are no + // longer unique. + m[attr] = append(m[attr], value...) + } + + return m, nil +} + +// Setxattr sets all of the extended attributes on file at path, following +// any symbolic links, if necessary. All attributes on the target are +// replaced by the values from attr. If the operation fails to set any +// attribute, those already applied will not be rolled back. +func (d *driver) Setxattr(path string, attrMap map[string][]byte) error { + for attr, value := range attrMap { + if err := sysx.Setxattr(path, attr, value, 0); err != nil { + return fmt.Errorf("error setting xattr %q on %s: %v", attr, path, err) + } + } + + return nil +} + +// LGetxattr returns all of the extended attributes for the file at path p +// not following symbolic links. +func (d *driver) LGetxattr(p string) (map[string][]byte, error) { + xattrs, err := sysx.LListxattr(p) + if err != nil { + return nil, fmt.Errorf("listing %s xattrs: %v", p, err) + } + + sort.Strings(xattrs) + m := make(map[string][]byte, len(xattrs)) + + for _, attr := range xattrs { + value, err := sysx.LGetxattr(p, attr) + if err != nil { + return nil, fmt.Errorf("getting %q xattr on %s: %v", attr, p, err) + } + + // NOTE(stevvooe): This append/copy tricky relies on unique + // xattrs. Break this out into an alloc/copy if xattrs are no + // longer unique. + m[attr] = append(m[attr], value...) + } + + return m, nil +} + +// LSetxattr sets all of the extended attributes on file at path, not +// following any symbolic links. All attributes on the target are +// replaced by the values from attr. If the operation fails to set any +// attribute, those already applied will not be rolled back. +func (d *driver) LSetxattr(path string, attrMap map[string][]byte) error { + for attr, value := range attrMap { + if err := sysx.LSetxattr(path, attr, value, 0); err != nil { + return fmt.Errorf("error setting xattr %q on %s: %v", attr, path, err) + } + } + + return nil +} + +func (d *driver) DeviceInfo(fi os.FileInfo) (maj uint64, min uint64, err error) { + return devices.DeviceInfo(fi) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/driver_windows.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/driver_windows.go new file mode 100644 index 000000000..e4cfa64fb --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/driver_windows.go @@ -0,0 +1,21 @@ +package driver + +import ( + "os" + + "github.com/pkg/errors" +) + +func (d *driver) Mknod(path string, mode os.FileMode, major, minor int) error { + return errors.Wrap(ErrNotSupported, "cannot create device node on Windows") +} + +func (d *driver) Mkfifo(path string, mode os.FileMode) error { + return errors.Wrap(ErrNotSupported, "cannot create fifo on Windows") +} + +// Lchmod changes the mode of an file not following symlinks. +func (d *driver) Lchmod(path string, mode os.FileMode) (err error) { + // TODO: Use Window's equivalent + return os.Chmod(path, mode) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/utils.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/utils.go new file mode 100644 index 000000000..9e0edd7bc --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/driver/utils.go @@ -0,0 +1,74 @@ +package driver + +import ( + "io" + "io/ioutil" + "os" + "sort" +) + +// ReadFile works the same as ioutil.ReadFile with the Driver abstraction +func ReadFile(r Driver, filename string) ([]byte, error) { + f, err := r.Open(filename) + if err != nil { + return nil, err + } + defer f.Close() + + data, err := ioutil.ReadAll(f) + if err != nil { + return nil, err + } + + return data, nil +} + +// WriteFile works the same as ioutil.WriteFile with the Driver abstraction +func WriteFile(r Driver, filename string, data []byte, perm os.FileMode) error { + f, err := r.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm) + if err != nil { + return err + } + defer f.Close() + + n, err := f.Write(data) + if err != nil { + return err + } else if n != len(data) { + return io.ErrShortWrite + } + + return nil +} + +// ReadDir works the same as ioutil.ReadDir with the Driver abstraction +func ReadDir(r Driver, dirname string) ([]os.FileInfo, error) { + f, err := r.Open(dirname) + if err != nil { + return nil, err + } + defer f.Close() + + dirs, err := f.Readdir(-1) + if err != nil { + return nil, err + } + + sort.Sort(fileInfos(dirs)) + return dirs, nil +} + +// Simple implementation of the sort.Interface for os.FileInfo +type fileInfos []os.FileInfo + +func (fis fileInfos) Len() int { + return len(fis) +} + +func (fis fileInfos) Less(i, j int) bool { + return fis[i].Name() < fis[j].Name() +} + +func (fis fileInfos) Swap(i, j int) { + fis[i], fis[j] = fis[j], fis[i] +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/pathdriver/path_driver.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/pathdriver/path_driver.go new file mode 100644 index 000000000..b43d55fe9 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/pathdriver/path_driver.go @@ -0,0 +1,85 @@ +package pathdriver + +import ( + "path/filepath" +) + +// PathDriver provides all of the path manipulation functions in a common +// interface. The context should call these and never use the `filepath` +// package or any other package to manipulate paths. +type PathDriver interface { + Join(paths ...string) string + IsAbs(path string) bool + Rel(base, target string) (string, error) + Base(path string) string + Dir(path string) string + Clean(path string) string + Split(path string) (dir, file string) + Separator() byte + Abs(path string) (string, error) + Walk(string, filepath.WalkFunc) error + FromSlash(path string) string + ToSlash(path string) string + Match(pattern, name string) (matched bool, err error) +} + +// pathDriver is a simple default implementation calls the filepath package. +type pathDriver struct{} + +// LocalPathDriver is the exported pathDriver struct for convenience. +var LocalPathDriver PathDriver = &pathDriver{} + +func (*pathDriver) Join(paths ...string) string { + return filepath.Join(paths...) +} + +func (*pathDriver) IsAbs(path string) bool { + return filepath.IsAbs(path) +} + +func (*pathDriver) Rel(base, target string) (string, error) { + return filepath.Rel(base, target) +} + +func (*pathDriver) Base(path string) string { + return filepath.Base(path) +} + +func (*pathDriver) Dir(path string) string { + return filepath.Dir(path) +} + +func (*pathDriver) Clean(path string) string { + return filepath.Clean(path) +} + +func (*pathDriver) Split(path string) (dir, file string) { + return filepath.Split(path) +} + +func (*pathDriver) Separator() byte { + return filepath.Separator +} + +func (*pathDriver) Abs(path string) (string, error) { + return filepath.Abs(path) +} + +// Note that filepath.Walk calls os.Stat, so if the context wants to +// to call Driver.Stat() for Walk, they need to create a new struct that +// overrides this method. +func (*pathDriver) Walk(root string, walkFn filepath.WalkFunc) error { + return filepath.Walk(root, walkFn) +} + +func (*pathDriver) FromSlash(path string) string { + return filepath.FromSlash(path) +} + +func (*pathDriver) ToSlash(path string) string { + return filepath.ToSlash(path) +} + +func (*pathDriver) Match(pattern, name string) (bool, error) { + return filepath.Match(pattern, name) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/asm.s b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/asm.s new file mode 100644 index 000000000..8ed2fdb94 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/asm.s @@ -0,0 +1,10 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !gccgo + +#include "textflag.h" + +TEXT ·use(SB),NOSPLIT,$0 + RET diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_darwin.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_darwin.go new file mode 100644 index 000000000..e3ae2b7bb --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_darwin.go @@ -0,0 +1,18 @@ +package sysx + +const ( + // AtSymlinkNoFollow defined from AT_SYMLINK_NOFOLLOW in + AtSymlinkNofollow = 0x20 +) + +const ( + + // SYS_FCHMODAT defined from golang.org/sys/unix + SYS_FCHMODAT = 467 +) + +// These functions will be generated by generate.sh +// $ GOOS=darwin GOARCH=386 ./generate.sh chmod +// $ GOOS=darwin GOARCH=amd64 ./generate.sh chmod + +//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_darwin_386.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_darwin_386.go new file mode 100644 index 000000000..5a8cf5b57 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_darwin_386.go @@ -0,0 +1,25 @@ +// mksyscall.pl -l32 chmod_darwin.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall.Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_darwin_amd64.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_darwin_amd64.go new file mode 100644 index 000000000..3287d1d57 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_darwin_amd64.go @@ -0,0 +1,25 @@ +// mksyscall.pl chmod_darwin.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall.Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_freebsd.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_freebsd.go new file mode 100644 index 000000000..b64a708be --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_freebsd.go @@ -0,0 +1,17 @@ +package sysx + +const ( + // AtSymlinkNoFollow defined from AT_SYMLINK_NOFOLLOW in + AtSymlinkNofollow = 0x200 +) + +const ( + + // SYS_FCHMODAT defined from golang.org/sys/unix + SYS_FCHMODAT = 490 +) + +// These functions will be generated by generate.sh +// $ GOOS=freebsd GOARCH=amd64 ./generate.sh chmod + +//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_freebsd_amd64.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_freebsd_amd64.go new file mode 100644 index 000000000..5a271abb1 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_freebsd_amd64.go @@ -0,0 +1,25 @@ +// mksyscall.pl chmod_freebsd.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall.Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_linux.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_linux.go new file mode 100644 index 000000000..89df6d38e --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_linux.go @@ -0,0 +1,12 @@ +package sysx + +import "syscall" + +const ( + // AtSymlinkNoFollow defined from AT_SYMLINK_NOFOLLOW in /usr/include/linux/fcntl.h + AtSymlinkNofollow = 0x100 +) + +func Fchmodat(dirfd int, path string, mode uint32, flags int) error { + return syscall.Fchmodat(dirfd, path, mode, flags) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_solaris.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_solaris.go new file mode 100644 index 000000000..3ba6e5edc --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/chmod_solaris.go @@ -0,0 +1,11 @@ +package sysx + +import "golang.org/x/sys/unix" + +const ( + AtSymlinkNofollow = unix.AT_SYMLINK_NOFOLLOW +) + +func Fchmodat(dirfd int, path string, mode uint32, flags int) error { + return unix.Fchmodat(dirfd, path, mode, flags) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux.go new file mode 100644 index 000000000..4d8581284 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux.go @@ -0,0 +1,11 @@ +package sysx + +// These functions will be generated by generate.sh +// $ GOOS=linux GOARCH=386 ./generate.sh copy +// $ GOOS=linux GOARCH=amd64 ./generate.sh copy +// $ GOOS=linux GOARCH=arm ./generate.sh copy +// $ GOOS=linux GOARCH=arm64 ./generate.sh copy +// $ GOOS=linux GOARCH=ppc64le ./generate.sh copy +// $ GOOS=linux GOARCH=s390x ./generate.sh copy + +//sys CopyFileRange(fdin uintptr, offin *int64, fdout uintptr, offout *int64, len int, flags int) (n int, err error) diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_386.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_386.go new file mode 100644 index 000000000..c1368c572 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_386.go @@ -0,0 +1,20 @@ +// mksyscall.pl -l32 copy_linux.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func CopyFileRange(fdin uintptr, offin *int64, fdout uintptr, offout *int64, len int, flags int) (n int, err error) { + r0, _, e1 := syscall.Syscall6(SYS_COPY_FILE_RANGE, uintptr(fdin), uintptr(unsafe.Pointer(offin)), uintptr(fdout), uintptr(unsafe.Pointer(offout)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_amd64.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_amd64.go new file mode 100644 index 000000000..9941b01f0 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_amd64.go @@ -0,0 +1,20 @@ +// mksyscall.pl copy_linux.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func CopyFileRange(fdin uintptr, offin *int64, fdout uintptr, offout *int64, len int, flags int) (n int, err error) { + r0, _, e1 := syscall.Syscall6(SYS_COPY_FILE_RANGE, uintptr(fdin), uintptr(unsafe.Pointer(offin)), uintptr(fdout), uintptr(unsafe.Pointer(offout)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_arm.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_arm.go new file mode 100644 index 000000000..c1368c572 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_arm.go @@ -0,0 +1,20 @@ +// mksyscall.pl -l32 copy_linux.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func CopyFileRange(fdin uintptr, offin *int64, fdout uintptr, offout *int64, len int, flags int) (n int, err error) { + r0, _, e1 := syscall.Syscall6(SYS_COPY_FILE_RANGE, uintptr(fdin), uintptr(unsafe.Pointer(offin)), uintptr(fdout), uintptr(unsafe.Pointer(offout)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_arm64.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_arm64.go new file mode 100644 index 000000000..9941b01f0 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_arm64.go @@ -0,0 +1,20 @@ +// mksyscall.pl copy_linux.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func CopyFileRange(fdin uintptr, offin *int64, fdout uintptr, offout *int64, len int, flags int) (n int, err error) { + r0, _, e1 := syscall.Syscall6(SYS_COPY_FILE_RANGE, uintptr(fdin), uintptr(unsafe.Pointer(offin)), uintptr(fdout), uintptr(unsafe.Pointer(offout)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_ppc64le.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_ppc64le.go new file mode 100644 index 000000000..9941b01f0 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_ppc64le.go @@ -0,0 +1,20 @@ +// mksyscall.pl copy_linux.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func CopyFileRange(fdin uintptr, offin *int64, fdout uintptr, offout *int64, len int, flags int) (n int, err error) { + r0, _, e1 := syscall.Syscall6(SYS_COPY_FILE_RANGE, uintptr(fdin), uintptr(unsafe.Pointer(offin)), uintptr(fdout), uintptr(unsafe.Pointer(offout)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_s390x.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_s390x.go new file mode 100644 index 000000000..9941b01f0 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/copy_linux_s390x.go @@ -0,0 +1,20 @@ +// mksyscall.pl copy_linux.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func CopyFileRange(fdin uintptr, offin *int64, fdout uintptr, offout *int64, len int, flags int) (n int, err error) { + r0, _, e1 := syscall.Syscall6(SYS_COPY_FILE_RANGE, uintptr(fdin), uintptr(unsafe.Pointer(offin)), uintptr(fdout), uintptr(unsafe.Pointer(offout)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/nodata_linux.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/nodata_linux.go new file mode 100644 index 000000000..fc47ddb8d --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/nodata_linux.go @@ -0,0 +1,7 @@ +package sysx + +import ( + "syscall" +) + +const ENODATA = syscall.ENODATA diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/nodata_solaris.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/nodata_solaris.go new file mode 100644 index 000000000..53cc8e068 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/nodata_solaris.go @@ -0,0 +1,8 @@ +package sysx + +import ( + "syscall" +) + +// This should actually be a set that contains ENOENT and EPERM +const ENODATA = syscall.ENOENT diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/nodata_unix.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/nodata_unix.go new file mode 100644 index 000000000..7e6851209 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/nodata_unix.go @@ -0,0 +1,9 @@ +// +build darwin freebsd + +package sysx + +import ( + "syscall" +) + +const ENODATA = syscall.ENOATTR diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sys.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sys.go new file mode 100644 index 000000000..0bb167628 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sys.go @@ -0,0 +1,37 @@ +package sysx + +import ( + "syscall" + "unsafe" +) + +var _zero uintptr + +// use is a no-op, but the compiler cannot see that it is. +// Calling use(p) ensures that p is kept live until that point. +//go:noescape +func use(p unsafe.Pointer) + +// Do the interface allocations only once for common +// Errno values. +var ( + errEAGAIN error = syscall.EAGAIN + errEINVAL error = syscall.EINVAL + errENOENT error = syscall.ENOENT +) + +// errnoErr returns common boxed Errno values, to prevent +// allocations at runtime. +func errnoErr(e syscall.Errno) error { + switch e { + case 0: + return nil + case syscall.EAGAIN: + return errEAGAIN + case syscall.EINVAL: + return errEINVAL + case syscall.ENOENT: + return errENOENT + } + return e +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_386.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_386.go new file mode 100644 index 000000000..0063f8a91 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_386.go @@ -0,0 +1,7 @@ +package sysx + +const ( + // SYS_COPYFILERANGE defined in Kernel 4.5+ + // Number defined in /usr/include/asm/unistd_32.h + SYS_COPY_FILE_RANGE = 377 +) diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_amd64.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_amd64.go new file mode 100644 index 000000000..4170540c5 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_amd64.go @@ -0,0 +1,7 @@ +package sysx + +const ( + // SYS_COPYFILERANGE defined in Kernel 4.5+ + // Number defined in /usr/include/asm/unistd_64.h + SYS_COPY_FILE_RANGE = 326 +) diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_arm.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_arm.go new file mode 100644 index 000000000..a05dcbb5e --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_arm.go @@ -0,0 +1,7 @@ +package sysx + +const ( + // SYS_COPY_FILE_RANGE defined in Kernel 4.5+ + // Number defined in /usr/include/arm-linux-gnueabihf/asm/unistd.h + SYS_COPY_FILE_RANGE = 391 +) diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_arm64.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_arm64.go new file mode 100644 index 000000000..da31bbd90 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_arm64.go @@ -0,0 +1,7 @@ +package sysx + +const ( + // SYS_COPY_FILE_RANGE defined in Kernel 4.5+ + // Number defined in /usr/include/asm-generic/unistd.h + SYS_COPY_FILE_RANGE = 285 +) diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_ppc64le.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_ppc64le.go new file mode 100644 index 000000000..5dea25a3c --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_ppc64le.go @@ -0,0 +1,7 @@ +package sysx + +const ( + // SYS_COPYFILERANGE defined in Kernel 4.5+ + // Number defined in /usr/include/asm/unistd_64.h + SYS_COPY_FILE_RANGE = 379 +) diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_s390x.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_s390x.go new file mode 100644 index 000000000..8a6f2a7ec --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/sysnum_linux_s390x.go @@ -0,0 +1,7 @@ +package sysx + +const ( + // SYS_COPYFILERANGE defined in Kernel 4.5+ + // Number defined in /usr/include/asm/unistd_64.h + SYS_COPY_FILE_RANGE = 375 +) diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr.go new file mode 100644 index 000000000..20937c2d4 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr.go @@ -0,0 +1,67 @@ +package sysx + +import ( + "bytes" + "fmt" + "syscall" +) + +const defaultXattrBufferSize = 5 + +var ErrNotSupported = fmt.Errorf("not supported") + +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. + 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 + } +} + +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) + 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 + } +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_darwin.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_darwin.go new file mode 100644 index 000000000..1164a7d11 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_darwin.go @@ -0,0 +1,71 @@ +package sysx + +// These functions will be generated by generate.sh +// $ GOOS=darwin GOARCH=386 ./generate.sh xattr +// $ GOOS=darwin GOARCH=amd64 ./generate.sh xattr + +//sys getxattr(path string, attr string, dest []byte, pos int, options int) (sz int, err error) +//sys setxattr(path string, attr string, data []byte, flags int) (err error) +//sys removexattr(path string, attr string, options int) (err error) +//sys listxattr(path string, dest []byte, options int) (sz int, err error) +//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) + +const ( + xattrNoFollow = 0x01 +) + +func listxattrFollow(path string, dest []byte) (sz int, err error) { + return listxattr(path, dest, 0) +} + +// Listxattr calls syscall getxattr +func Listxattr(path string) ([]string, error) { + return listxattrAll(path, listxattrFollow) +} + +// Removexattr calls syscall getxattr +func Removexattr(path string, attr string) (err error) { + return removexattr(path, attr, 0) +} + +// Setxattr calls syscall setxattr +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + return setxattr(path, attr, data, flags) +} + +func getxattrFollow(path, attr string, dest []byte) (sz int, err error) { + return getxattr(path, attr, dest, 0, 0) +} + +// Getxattr calls syscall getxattr +func Getxattr(path, attr string) ([]byte, error) { + return getxattrAll(path, attr, getxattrFollow) +} + +func listxattrNoFollow(path string, dest []byte) (sz int, err error) { + return listxattr(path, dest, xattrNoFollow) +} + +// LListxattr calls syscall listxattr with XATTR_NOFOLLOW +func LListxattr(path string) ([]string, error) { + return listxattrAll(path, listxattrNoFollow) +} + +// LRemovexattr calls syscall removexattr with XATTR_NOFOLLOW +func LRemovexattr(path string, attr string) (err error) { + return removexattr(path, attr, xattrNoFollow) +} + +// Setxattr calls syscall setxattr with XATTR_NOFOLLOW +func LSetxattr(path string, attr string, data []byte, flags int) (err error) { + return setxattr(path, attr, data, flags|xattrNoFollow) +} + +func getxattrNoFollow(path, attr string, dest []byte) (sz int, err error) { + return getxattr(path, attr, dest, 0, xattrNoFollow) +} + +// LGetxattr calls syscall getxattr with XATTR_NOFOLLOW +func LGetxattr(path, attr string) ([]byte, error) { + return getxattrAll(path, attr, getxattrNoFollow) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_darwin_386.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_darwin_386.go new file mode 100644 index 000000000..aa896b57f --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_darwin_386.go @@ -0,0 +1,111 @@ +// mksyscall.pl -l32 xattr_darwin.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getxattr(path string, attr string, dest []byte, pos int, options int) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall6(syscall.SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), uintptr(pos), uintptr(options)) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall.Syscall6(syscall.SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func removexattr(path string, attr string, options int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := syscall.Syscall(syscall.SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options)) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func listxattr(path string, dest []byte, options int) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall6(syscall.SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)), uintptr(options), 0, 0) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_darwin_amd64.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_darwin_amd64.go new file mode 100644 index 000000000..6ff27e270 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_darwin_amd64.go @@ -0,0 +1,111 @@ +// mksyscall.pl xattr_darwin.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getxattr(path string, attr string, dest []byte, pos int, options int) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall6(syscall.SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), uintptr(pos), uintptr(options)) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall.Syscall6(syscall.SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func removexattr(path string, attr string, options int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := syscall.Syscall(syscall.SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options)) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func listxattr(path string, dest []byte, options int) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall6(syscall.SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)), uintptr(options), 0, 0) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_freebsd.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_freebsd.go new file mode 100644 index 000000000..e8017d317 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_freebsd.go @@ -0,0 +1,12 @@ +package sysx + +import ( + "errors" +) + +// Initial stub version for FreeBSD. FreeBSD has a different +// syscall API from Darwin and Linux for extended attributes; +// it is also not widely used. It is not exposed at all by the +// Go syscall package, so we need to implement directly eventually. + +var unsupported = errors.New("extended attributes unsupported on FreeBSD") diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux.go new file mode 100644 index 000000000..cd1813634 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux.go @@ -0,0 +1,61 @@ +package sysx + +import "syscall" + +// These functions will be generated by generate.sh +// $ GOOS=linux GOARCH=386 ./generate.sh xattr +// $ GOOS=linux GOARCH=amd64 ./generate.sh xattr +// $ GOOS=linux GOARCH=arm ./generate.sh xattr +// $ GOOS=linux GOARCH=arm64 ./generate.sh xattr +// $ GOOS=linux GOARCH=ppc64 ./generate.sh xattr +// $ GOOS=linux GOARCH=ppc64le ./generate.sh xattr +// $ GOOS=linux GOARCH=s390x ./generate.sh xattr + +// Listxattr calls syscall listxattr and reads all content +// and returns a string array +func Listxattr(path string) ([]string, error) { + return listxattrAll(path, syscall.Listxattr) +} + +// Removexattr calls syscall removexattr +func Removexattr(path string, attr string) (err error) { + return syscall.Removexattr(path, attr) +} + +// Setxattr calls syscall setxattr +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + return syscall.Setxattr(path, attr, data, flags) +} + +// Getxattr calls syscall getxattr +func Getxattr(path, attr string) ([]byte, error) { + return getxattrAll(path, attr, syscall.Getxattr) +} + +//sys llistxattr(path string, dest []byte) (sz int, err error) + +// LListxattr lists xattrs, not following symlinks +func LListxattr(path string) ([]string, error) { + return listxattrAll(path, llistxattr) +} + +//sys lremovexattr(path string, attr string) (err error) + +// LRemovexattr removes an xattr, not following symlinks +func LRemovexattr(path string, attr string) (err error) { + return lremovexattr(path, attr) +} + +//sys lsetxattr(path string, attr string, data []byte, flags int) (err error) + +// LSetxattr sets an xattr, not following symlinks +func LSetxattr(path string, attr string, data []byte, flags int) (err error) { + return lsetxattr(path, attr, data, flags) +} + +//sys lgetxattr(path string, attr string, dest []byte) (sz int, err error) + +// LGetxattr gets an xattr, not following symlinks +func LGetxattr(path, attr string) ([]byte, error) { + return getxattrAll(path, attr, lgetxattr) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_386.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_386.go new file mode 100644 index 000000000..c3e5c8e38 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_386.go @@ -0,0 +1,111 @@ +// mksyscall.pl -l32 xattr_linux.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func llistxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall(syscall.SYS_LLISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lremovexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := syscall.Syscall(syscall.SYS_LREMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lsetxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall.Syscall6(syscall.SYS_LSETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lgetxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_amd64.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_amd64.go new file mode 100644 index 000000000..dec46faaa --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_amd64.go @@ -0,0 +1,111 @@ +// mksyscall.pl xattr_linux.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func llistxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall(syscall.SYS_LLISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lremovexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := syscall.Syscall(syscall.SYS_LREMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lsetxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall.Syscall6(syscall.SYS_LSETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lgetxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_arm.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_arm.go new file mode 100644 index 000000000..c3e5c8e38 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_arm.go @@ -0,0 +1,111 @@ +// mksyscall.pl -l32 xattr_linux.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func llistxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall(syscall.SYS_LLISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lremovexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := syscall.Syscall(syscall.SYS_LREMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lsetxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall.Syscall6(syscall.SYS_LSETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lgetxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_arm64.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_arm64.go new file mode 100644 index 000000000..dec46faaa --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_arm64.go @@ -0,0 +1,111 @@ +// mksyscall.pl xattr_linux.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func llistxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall(syscall.SYS_LLISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lremovexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := syscall.Syscall(syscall.SYS_LREMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lsetxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall.Syscall6(syscall.SYS_LSETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lgetxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_ppc64.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_ppc64.go new file mode 100644 index 000000000..dec46faaa --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_ppc64.go @@ -0,0 +1,111 @@ +// mksyscall.pl xattr_linux.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func llistxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall(syscall.SYS_LLISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lremovexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := syscall.Syscall(syscall.SYS_LREMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lsetxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall.Syscall6(syscall.SYS_LSETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lgetxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_ppc64le.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_ppc64le.go new file mode 100644 index 000000000..dec46faaa --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_ppc64le.go @@ -0,0 +1,111 @@ +// mksyscall.pl xattr_linux.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func llistxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall(syscall.SYS_LLISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lremovexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := syscall.Syscall(syscall.SYS_LREMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lsetxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall.Syscall6(syscall.SYS_LSETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lgetxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_s390x.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_s390x.go new file mode 100644 index 000000000..dec46faaa --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_linux_s390x.go @@ -0,0 +1,111 @@ +// mksyscall.pl xattr_linux.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +package sysx + +import ( + "syscall" + "unsafe" +) + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func llistxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall(syscall.SYS_LLISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lremovexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := syscall.Syscall(syscall.SYS_LREMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lsetxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall.Syscall6(syscall.SYS_LSETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lgetxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_solaris.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_solaris.go new file mode 100644 index 000000000..fc523fcbb --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_solaris.go @@ -0,0 +1,12 @@ +package sysx + +import ( + "errors" +) + +// Initial stub version for Solaris. Solaris has a different +// syscall API from Darwin and Linux for extended attributes; +// it is also not widely used. It is not exposed at all by the +// Go syscall package, so we need to implement directly eventually. + +var unsupported = errors.New("extended attributes unsupported on Solaris") diff --git a/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_unsupported.go b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_unsupported.go new file mode 100644 index 000000000..a8dd9f245 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/containerd/continuity/sysx/xattr_unsupported.go @@ -0,0 +1,44 @@ +// +build freebsd solaris + +package sysx + +// Listxattr calls syscall listxattr and reads all content +// and returns a string array +func Listxattr(path string) ([]string, error) { + return []string{}, nil +} + +// Removexattr calls syscall removexattr +func Removexattr(path string, attr string) (err error) { + return unsupported +} + +// Setxattr calls syscall setxattr +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + return unsupported +} + +// Getxattr calls syscall getxattr +func Getxattr(path, attr string) ([]byte, error) { + return []byte{}, unsupported +} + +// LListxattr lists xattrs, not following symlinks +func LListxattr(path string) ([]string, error) { + return []string{}, nil +} + +// LRemovexattr removes an xattr, not following symlinks +func LRemovexattr(path string, attr string) (err error) { + return unsupported +} + +// LSetxattr sets an xattr, not following symlinks +func LSetxattr(path string, attr string, data []byte, flags int) (err error) { + return unsupported +} + +// LGetxattr gets an xattr, not following symlinks +func LGetxattr(path, attr string) ([]byte, error) { + return []byte{}, nil +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/agent.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/agent.go index daf6936b7..b0d66476e 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/agent.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/agent.go @@ -741,11 +741,12 @@ func (n *network) addDriverWatches() { return } - agent.networkDB.WalkTable(table.name, func(nid, key string, value []byte) bool { - if nid == n.ID() { + agent.networkDB.WalkTable(table.name, func(nid, key string, value []byte, deleted bool) bool { + // skip the entries that are mark for deletion, this is safe because this function is + // called at initialization time so there is no state to delete + if nid == n.ID() && !deleted { d.EventNotify(driverapi.Create, nid, table.name, key, value) } - return false }) } @@ -891,13 +892,13 @@ func (c *controller) handleEpTableEvent(ev events.Event) { if svcID != "" { // This is a remote task part of a service if err := c.addServiceBinding(svcName, svcID, nid, eid, containerName, vip, ingressPorts, serviceAliases, taskAliases, ip, "handleEpTableEvent"); err != nil { - logrus.Errorf("failed adding service binding for %s epRec:%v err:%s", eid, epRec, err) + logrus.Errorf("failed adding service binding for %s epRec:%v err:%v", eid, epRec, err) return } } else { // This is a remote container simply attached to an attachable network if err := c.addContainerNameResolution(nid, eid, containerName, taskAliases, ip, "handleEpTableEvent"); err != nil { - logrus.Errorf("failed adding service binding for %s epRec:%v err:%s", eid, epRec, err) + logrus.Errorf("failed adding container name resolution for %s epRec:%v err:%v", eid, epRec, err) } } } else { @@ -905,13 +906,13 @@ func (c *controller) handleEpTableEvent(ev events.Event) { if svcID != "" { // This is a remote task part of a service if err := c.rmServiceBinding(svcName, svcID, nid, eid, containerName, vip, ingressPorts, serviceAliases, taskAliases, ip, "handleEpTableEvent", true); err != nil { - logrus.Errorf("failed removing service binding for %s epRec:%v err:%s", eid, epRec, err) + logrus.Errorf("failed removing service binding for %s epRec:%v err:%v", eid, epRec, err) return } } else { // This is a remote container simply attached to an attachable network if err := c.delContainerNameResolution(nid, eid, containerName, taskAliases, ip, "handleEpTableEvent"); err != nil { - logrus.Errorf("failed adding service binding for %s epRec:%v err:%s", eid, epRec, err) + logrus.Errorf("failed removing container name resolution for %s epRec:%v err:%v", eid, epRec, err) } } } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/bitseq/sequence.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/bitseq/sequence.go index e3a5bb563..3946473d8 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/bitseq/sequence.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/bitseq/sequence.go @@ -497,7 +497,10 @@ func getFirstAvailable(head *sequence, start uint64) (uint64, uint64, error) { // Derive the this sequence offsets byteOffset := byteStart - inBlockBytePos bitOffset := inBlockBytePos*8 + bitStart - + var firstOffset uint64 + if current == head { + firstOffset = byteOffset + } for current != nil { if current.block != blockMAX { bytePos, bitPos, err := current.getAvailableBit(bitOffset) @@ -505,7 +508,8 @@ func getFirstAvailable(head *sequence, start uint64) (uint64, uint64, error) { } // Moving to next block: Reset bit offset. bitOffset = 0 - byteOffset += current.count * blockBytes + byteOffset += (current.count * blockBytes) - firstOffset + firstOffset = 0 current = current.next } return invalidPos, invalidPos, ErrNoBitAvailable diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/common/caller.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/common/caller.go new file mode 100644 index 000000000..0dec3bc0b --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/common/caller.go @@ -0,0 +1,29 @@ +package common + +import ( + "runtime" + "strings" +) + +func callerInfo(i int) string { + ptr, _, _, ok := runtime.Caller(i) + fName := "unknown" + if ok { + f := runtime.FuncForPC(ptr) + if f != nil { + // f.Name() is like: github.com/docker/libnetwork/common.MethodName + tmp := strings.Split(f.Name(), ".") + if len(tmp) > 0 { + fName = tmp[len(tmp)-1] + } + } + } + + return fName +} + +// CallerName returns the name of the function at the specified level +// level == 0 means current method name +func CallerName(level int) string { + return callerInfo(2 + level) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/config/config.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/config/config.go index 96a157a1f..3e8473d25 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/config/config.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/config/config.go @@ -15,6 +15,11 @@ import ( "github.com/sirupsen/logrus" ) +const ( + warningThNetworkControlPlaneMTU = 1500 + minimumNetworkControlPlaneMTU = 500 +) + // Config encapsulates configurations of various Libnetwork components type Config struct { Daemon DaemonCfg @@ -226,9 +231,12 @@ func OptionExperimental(exp bool) Option { func OptionNetworkControlPlaneMTU(exp int) Option { return func(c *Config) { logrus.Debugf("Network Control Plane MTU: %d", exp) - if exp < 1500 { - // if exp == 0 the value won't be used - logrus.Warnf("Received a MTU of %d, this value is very low, the network control plane can misbehave", exp) + if exp < warningThNetworkControlPlaneMTU { + logrus.Warnf("Received a MTU of %d, this value is very low, the network control plane can misbehave,"+ + " defaulting to minimum value (%d)", exp, minimumNetworkControlPlaneMTU) + if exp < minimumNetworkControlPlaneMTU { + exp = minimumNetworkControlPlaneMTU + } } c.Daemon.NetworkControlPlaneMTU = exp } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/diagnose/diagnose.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/diagnose/diagnose.go new file mode 100644 index 000000000..284939748 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/diagnose/diagnose.go @@ -0,0 +1,133 @@ +package diagnose + +import ( + "fmt" + "net" + "net/http" + "sync" + + "github.com/sirupsen/logrus" +) + +// HTTPHandlerFunc TODO +type HTTPHandlerFunc func(interface{}, http.ResponseWriter, *http.Request) + +type httpHandlerCustom struct { + ctx interface{} + F func(interface{}, http.ResponseWriter, *http.Request) +} + +// ServeHTTP TODO +func (h httpHandlerCustom) ServeHTTP(w http.ResponseWriter, r *http.Request) { + h.F(h.ctx, w, r) +} + +var diagPaths2Func = map[string]HTTPHandlerFunc{ + "/": notImplemented, + "/help": help, + "/ready": ready, +} + +// Server when the debug is enabled exposes a +// This data structure is protected by the Agent mutex so does not require and additional mutex here +type Server struct { + sk net.Listener + port int + mux *http.ServeMux + registeredHanders []string + sync.Mutex +} + +// Init TODO +func (n *Server) Init() { + n.mux = http.NewServeMux() + + // Register local handlers + n.RegisterHandler(n, diagPaths2Func) +} + +// RegisterHandler TODO +func (n *Server) RegisterHandler(ctx interface{}, hdlrs map[string]HTTPHandlerFunc) { + n.Lock() + defer n.Unlock() + for path, fun := range hdlrs { + n.mux.Handle(path, httpHandlerCustom{ctx, fun}) + n.registeredHanders = append(n.registeredHanders, path) + } +} + +// EnableDebug opens a TCP socket to debug the passed network DB +func (n *Server) EnableDebug(ip string, port int) { + n.Lock() + defer n.Unlock() + + n.port = port + logrus.SetLevel(logrus.DebugLevel) + + if n.sk != nil { + logrus.Infof("The server is already up and running") + return + } + + logrus.Infof("Starting the server listening on %d for commands", port) + + // // Create the socket + // var err error + // n.sk, err = net.Listen("tcp", listeningAddr) + // if err != nil { + // log.Fatal(err) + // } + // + // go func() { + // http.Serve(n.sk, n.mux) + // }() + http.ListenAndServe(":8000", n.mux) +} + +// DisableDebug stop the dubug and closes the tcp socket +func (n *Server) DisableDebug() { + n.Lock() + defer n.Unlock() + n.sk.Close() + n.sk = nil +} + +// IsDebugEnable returns true when the debug is enabled +func (n *Server) IsDebugEnable() bool { + n.Lock() + defer n.Unlock() + return n.sk != nil +} + +func notImplemented(ctx interface{}, w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "URL path: %s no method implemented check /help\n", r.URL.Path) +} + +func help(ctx interface{}, w http.ResponseWriter, r *http.Request) { + n, ok := ctx.(*Server) + if ok { + for _, path := range n.registeredHanders { + fmt.Fprintf(w, "%s\n", path) + } + } +} + +func ready(ctx interface{}, w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "OK\n") +} + +// DebugHTTPForm TODO +func DebugHTTPForm(r *http.Request) { + r.ParseForm() + for k, v := range r.Form { + logrus.Debugf("Form[%q] = %q\n", k, v) + } +} + +// HTTPReplyError TODO +func HTTPReplyError(w http.ResponseWriter, message, usage string) { + fmt.Fprintf(w, "%s\n", message) + if usage != "" { + fmt.Fprintf(w, "Usage: %s\n", usage) + } +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/ipvlan/ipvlan_setup.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/ipvlan/ipvlan_setup.go index 0c39ec9d2..28d6cca4e 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/ipvlan/ipvlan_setup.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/ipvlan/ipvlan_setup.go @@ -201,5 +201,5 @@ func delDummyLink(linkName string) error { // getDummyName returns the name of a dummy parent with truncated net ID and driver prefix func getDummyName(netID string) string { - return fmt.Sprintf("%s%s", dummyPrefix, netID) + return dummyPrefix + netID } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/macvlan/macvlan_setup.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/macvlan/macvlan_setup.go index 843a2e73b..98d4bd383 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/macvlan/macvlan_setup.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/macvlan/macvlan_setup.go @@ -205,5 +205,5 @@ func delDummyLink(linkName string) error { // getDummyName returns the name of a dummy parent with truncated net ID and driver prefix func getDummyName(netID string) string { - return fmt.Sprintf("%s%s", dummyPrefix, netID) + return dummyPrefix + netID } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/joinleave.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/joinleave.go index 0917a983a..a07838b76 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/joinleave.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/joinleave.go @@ -120,8 +120,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, } } - d.peerDbAdd(nid, eid, ep.addr.IP, ep.addr.Mask, ep.mac, - net.ParseIP(d.advertiseAddress), true) + d.peerAdd(nid, eid, ep.addr.IP, ep.addr.Mask, ep.mac, net.ParseIP(d.advertiseAddress), false, false, true) if err := d.checkEncryption(nid, nil, n.vxlanID(s), true, true); err != nil { logrus.Warn(err) @@ -201,11 +200,11 @@ func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key stri } if etype == driverapi.Delete { - d.peerDelete(nid, eid, addr.IP, addr.Mask, mac, vtep, true) + d.peerDelete(nid, eid, addr.IP, addr.Mask, mac, vtep) return } - d.peerAdd(nid, eid, addr.IP, addr.Mask, mac, vtep, true, false, false) + d.peerAdd(nid, eid, addr.IP, addr.Mask, mac, vtep, false, false, false) } // Leave method is invoked when a Sandbox detaches from an endpoint. diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/ov_network.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/ov_network.go index 449bf80d3..0e9ca7786 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/ov_network.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/ov_network.go @@ -8,6 +8,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strconv" "strings" "sync" @@ -81,6 +82,10 @@ func setDefaultVlan() { logrus.Error("insufficient number of arguments") os.Exit(1) } + + runtime.LockOSThread() + defer runtime.UnlockOSThread() + nsPath := os.Args[1] ns, err := netns.GetFromPath(nsPath) if err != nil { @@ -489,7 +494,7 @@ func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) erro brIfaceOption := make([]osl.IfaceOption, 2) brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Address(s.gwIP)) brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Bridge(true)) - Ifaces[fmt.Sprintf("%s+%s", brName, "br")] = brIfaceOption + Ifaces[brName+"+br"] = brIfaceOption err := sbox.Restore(Ifaces, nil, nil, nil) if err != nil { @@ -499,7 +504,7 @@ func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) erro Ifaces = make(map[string][]osl.IfaceOption) vxlanIfaceOption := make([]osl.IfaceOption, 1) vxlanIfaceOption = append(vxlanIfaceOption, sbox.InterfaceOptions().Master(brName)) - Ifaces[fmt.Sprintf("%s+%s", vxlanName, "vxlan")] = vxlanIfaceOption + Ifaces[vxlanName+"+vxlan"] = vxlanIfaceOption err = sbox.Restore(Ifaces, nil, nil, nil) if err != nil { return err @@ -683,10 +688,12 @@ func (n *network) initSandbox(restore bool) error { return fmt.Errorf("could not get network sandbox (oper %t): %v", restore, err) } + // this is needed to let the peerAdd configure the sandbox n.setSandbox(sbox) if !restore { - n.driver.peerDbUpdateSandbox(n.id) + // Initialize the sandbox with all the peers previously received from networkdb + n.driver.initSandboxPeerDB(n.id) } var nlSock *nl.NetlinkSocket @@ -765,10 +772,7 @@ func (n *network) watchMiss(nlSock *nl.NetlinkSocket) { logrus.Errorf("could not resolve peer %q: %v", ip, err) continue } - - if err := n.driver.peerAdd(n.id, "dummy", ip, IPmask, mac, vtep, true, l2Miss, l3Miss); err != nil { - logrus.Errorf("could not add neighbor entry for missed peer %q: %v", ip, err) - } + n.driver.peerAdd(n.id, "dummy", ip, IPmask, mac, vtep, l2Miss, l3Miss, false) } else { // If the gc_thresh values are lower kernel might knock off the neighor entries. // When we get a L3 miss check if its a valid peer and reprogram the neighbor diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/ov_serf.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/ov_serf.go index c56839a9d..6e034ada4 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/ov_serf.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/ov_serf.go @@ -120,15 +120,9 @@ func (d *driver) processEvent(u serf.UserEvent) { switch action { case "join": - if err := d.peerAdd(nid, eid, net.ParseIP(ipStr), net.IPMask(net.ParseIP(maskStr).To4()), mac, - net.ParseIP(vtepStr), true, false, false); err != nil { - logrus.Errorf("Peer add failed in the driver: %v\n", err) - } + d.peerAdd(nid, eid, net.ParseIP(ipStr), net.IPMask(net.ParseIP(maskStr).To4()), mac, net.ParseIP(vtepStr), false, false, false) case "leave": - if err := d.peerDelete(nid, eid, net.ParseIP(ipStr), net.IPMask(net.ParseIP(maskStr).To4()), mac, - net.ParseIP(vtepStr), true); err != nil { - logrus.Errorf("Peer delete failed in the driver: %v\n", err) - } + d.peerDelete(nid, eid, net.ParseIP(ipStr), net.IPMask(net.ParseIP(maskStr).To4()), mac, net.ParseIP(vtepStr)) } } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/overlay.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/overlay.go index 1c947619a..2bae0823e 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/overlay.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/overlay.go @@ -3,6 +3,7 @@ package overlay //go:generate protoc -I.:../../Godeps/_workspace/src/github.com/gogo/protobuf --gogo_out=import_path=github.com/docker/libnetwork/drivers/overlay,Mgogoproto/gogo.proto=github.com/gogo/protobuf/gogoproto:. overlay.proto import ( + "context" "fmt" "net" "sync" @@ -50,6 +51,8 @@ type driver struct { joinOnce sync.Once localJoinOnce sync.Once keys []*key + peerOpCh chan *peerOperation + peerOpCancel context.CancelFunc sync.Mutex } @@ -64,10 +67,16 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error { peerDb: peerNetworkMap{ mp: map[string]*peerMap{}, }, - secMap: &encrMap{nodes: map[string][]*spi{}}, - config: config, + secMap: &encrMap{nodes: map[string][]*spi{}}, + config: config, + peerOpCh: make(chan *peerOperation), } + // Launch the go routine for processing peer operations + ctx, cancel := context.WithCancel(context.Background()) + d.peerOpCancel = cancel + go d.peerOpRoutine(ctx, d.peerOpCh) + if data, ok := config[netlabel.GlobalKVClient]; ok { var err error dsc, ok := data.(discoverapi.DatastoreConfigData) @@ -153,7 +162,7 @@ func (d *driver) restoreEndpoints() error { Ifaces := make(map[string][]osl.IfaceOption) vethIfaceOption := make([]osl.IfaceOption, 1) vethIfaceOption = append(vethIfaceOption, n.sbox.InterfaceOptions().Master(s.brName)) - Ifaces[fmt.Sprintf("%s+%s", "veth", "veth")] = vethIfaceOption + Ifaces["veth+veth"] = vethIfaceOption err := n.sbox.Restore(Ifaces, nil, nil, nil) if err != nil { @@ -161,7 +170,7 @@ func (d *driver) restoreEndpoints() error { } n.incEndpointCount() - d.peerDbAdd(ep.nid, ep.id, ep.addr.IP, ep.addr.Mask, ep.mac, net.ParseIP(d.advertiseAddress), true) + d.peerAdd(ep.nid, ep.id, ep.addr.IP, ep.addr.Mask, ep.mac, net.ParseIP(d.advertiseAddress), false, false, true) } return nil } @@ -170,6 +179,11 @@ func (d *driver) restoreEndpoints() error { func Fini(drv driverapi.Driver) { d := drv.(*driver) + // Notify the peer go routine to return + if d.peerOpCancel != nil { + d.peerOpCancel() + } + if d.exitCh != nil { waitCh := make(chan struct{}) @@ -256,7 +270,7 @@ func (d *driver) nodeJoin(advertiseAddress, bindAddress string, self bool) { // If there is no cluster store there is no need to start serf. if d.store != nil { if err := validateSelf(advertiseAddress); err != nil { - logrus.Warnf("%s", err.Error()) + logrus.Warn(err.Error()) } err := d.serfInit() if err != nil { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/peerdb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/peerdb.go index 254e8643f..f953e3c87 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/peerdb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/overlay/peerdb.go @@ -1,11 +1,13 @@ package overlay import ( + "context" "fmt" "net" "sync" "syscall" + "github.com/docker/libnetwork/common" "github.com/sirupsen/logrus" ) @@ -59,8 +61,6 @@ func (pKey *peerKey) Scan(state fmt.ScanState, verb rune) error { return nil } -var peerDbWg sync.WaitGroup - func (d *driver) peerDbWalk(f func(string, *peerKey, *peerEntry) bool) error { d.peerDb.Lock() nids := []string{} @@ -141,8 +141,6 @@ func (d *driver) peerDbSearch(nid string, peerIP net.IP) (net.HardwareAddr, net. func (d *driver) peerDbAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, peerMac net.HardwareAddr, vtep net.IP, isLocal bool) { - peerDbWg.Wait() - d.peerDb.Lock() pMap, ok := d.peerDb.mp[nid] if !ok { @@ -173,7 +171,6 @@ func (d *driver) peerDbAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask func (d *driver) peerDbDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, peerMac net.HardwareAddr, vtep net.IP) peerEntry { - peerDbWg.Wait() d.peerDb.Lock() pMap, ok := d.peerDb.mp[nid] @@ -206,62 +203,117 @@ func (d *driver) peerDbDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPM return pEntry } -func (d *driver) peerDbUpdateSandbox(nid string) { - d.peerDb.Lock() - pMap, ok := d.peerDb.mp[nid] - if !ok { - d.peerDb.Unlock() - return - } - d.peerDb.Unlock() +// The overlay uses a lazy initialization approach, this means that when a network is created +// and the driver registered the overlay does not allocate resources till the moment that a +// sandbox is actually created. +// At the moment of this call, that happens when a sandbox is initialized, is possible that +// networkDB has already delivered some events of peers already available on remote nodes, +// these peers are saved into the peerDB and this function is used to properly configure +// the network sandbox with all those peers that got previously notified. +// Note also that this method sends a single message on the channel and the go routine on the +// other side, will atomically loop on the whole table of peers and will program their state +// in one single atomic operation. This is fundamental to guarantee consistency, and avoid that +// new peerAdd or peerDelete gets reordered during the sandbox init. +func (d *driver) initSandboxPeerDB(nid string) { + d.peerInit(nid) +} - peerDbWg.Add(1) +type peerOperationType int32 - var peerOps []func() - pMap.Lock() - for pKeyStr, pEntry := range pMap.mp { - var pKey peerKey - if _, err := fmt.Sscan(pKeyStr, &pKey); err != nil { - logrus.Errorf("peer key scan failed: %v", err) - } +const ( + peerOperationINIT peerOperationType = iota + peerOperationADD + peerOperationDELETE +) - if pEntry.isLocal { - continue - } +type peerOperation struct { + opType peerOperationType + networkID string + endpointID string + peerIP net.IP + peerIPMask net.IPMask + peerMac net.HardwareAddr + vtepIP net.IP + l2Miss bool + l3Miss bool + localPeer bool + callerName string +} - // Go captures variables by reference. The pEntry could be - // pointing to the same memory location for every iteration. Make - // a copy of pEntry before capturing it in the following closure. - entry := pEntry - op := func() { - if err := d.peerAdd(nid, entry.eid, pKey.peerIP, entry.peerIPMask, - pKey.peerMac, entry.vtep, - false, false, false); err != nil { - logrus.Errorf("peerdbupdate in sandbox failed for ip %s and mac %s: %v", - pKey.peerIP, pKey.peerMac, err) +func (d *driver) peerOpRoutine(ctx context.Context, ch chan *peerOperation) { + var err error + for { + select { + case <-ctx.Done(): + return + case op := <-ch: + switch op.opType { + case peerOperationINIT: + err = d.peerInitOp(op.networkID) + case peerOperationADD: + err = d.peerAddOp(op.networkID, op.endpointID, op.peerIP, op.peerIPMask, op.peerMac, op.vtepIP, op.l2Miss, op.l3Miss, true, op.localPeer) + case peerOperationDELETE: + err = d.peerDeleteOp(op.networkID, op.endpointID, op.peerIP, op.peerIPMask, op.peerMac, op.vtepIP) + } + if err != nil { + logrus.Warnf("Peer operation failed:%s op:%v", err, op) } } - - peerOps = append(peerOps, op) } - pMap.Unlock() +} - for _, op := range peerOps { - op() +func (d *driver) peerInit(nid string) { + callerName := common.CallerName(1) + d.peerOpCh <- &peerOperation{ + opType: peerOperationINIT, + networkID: nid, + callerName: callerName, } +} + +func (d *driver) peerInitOp(nid string) error { + return d.peerDbNetworkWalk(nid, func(pKey *peerKey, pEntry *peerEntry) bool { + // Local entries do not need to be added + if pEntry.isLocal { + return false + } - peerDbWg.Done() + d.peerAddOp(nid, pEntry.eid, pKey.peerIP, pEntry.peerIPMask, pKey.peerMac, pEntry.vtep, false, false, false, pEntry.isLocal) + // return false to loop on all entries + return false + }) } func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, - peerMac net.HardwareAddr, vtep net.IP, updateDb, l2Miss, l3Miss bool) error { + peerMac net.HardwareAddr, vtep net.IP, l2Miss, l3Miss, localPeer bool) { + callerName := common.CallerName(1) + d.peerOpCh <- &peerOperation{ + opType: peerOperationADD, + networkID: nid, + endpointID: eid, + peerIP: peerIP, + peerIPMask: peerIPMask, + peerMac: peerMac, + vtepIP: vtep, + l2Miss: l2Miss, + l3Miss: l3Miss, + localPeer: localPeer, + callerName: callerName, + } +} + +func (d *driver) peerAddOp(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, + peerMac net.HardwareAddr, vtep net.IP, l2Miss, l3Miss, updateDB, updateOnlyDB bool) error { if err := validateID(nid, eid); err != nil { return err } - if updateDb { + if updateDB { d.peerDbAdd(nid, eid, peerIP, peerIPMask, peerMac, vtep, false) + if updateOnlyDB { + return nil + } } n := d.network(nid) @@ -271,6 +323,9 @@ func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, sbox := n.sandbox() if sbox == nil { + // We are hitting this case for all the events that are arriving before that the sandbox + // is being created. The peer got already added into the database and the sanbox init will + // call the peerDbUpdateSandbox that will configure all these peers from the database return nil } @@ -311,16 +366,28 @@ func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, } func (d *driver) peerDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, - peerMac net.HardwareAddr, vtep net.IP, updateDb bool) error { + peerMac net.HardwareAddr, vtep net.IP) { + callerName := common.CallerName(1) + d.peerOpCh <- &peerOperation{ + opType: peerOperationDELETE, + networkID: nid, + endpointID: eid, + peerIP: peerIP, + peerIPMask: peerIPMask, + peerMac: peerMac, + vtepIP: vtep, + callerName: callerName, + } +} + +func (d *driver) peerDeleteOp(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, + peerMac net.HardwareAddr, vtep net.IP) error { if err := validateID(nid, eid); err != nil { return err } - var pEntry peerEntry - if updateDb { - pEntry = d.peerDbDelete(nid, eid, peerIP, peerIPMask, peerMac, vtep) - } + pEntry := d.peerDbDelete(nid, eid, peerIP, peerIPMask, peerMac, vtep) n := d.network(nid) if n == nil { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/solaris/overlay/ov_network.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/solaris/overlay/ov_network.go index b545bc890..4e3f9ae76 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/solaris/overlay/ov_network.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/solaris/overlay/ov_network.go @@ -331,7 +331,7 @@ func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) erro brIfaceOption := make([]osl.IfaceOption, 2) brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Address(s.gwIP)) brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Bridge(true)) - Ifaces[fmt.Sprintf("%s+%s", brName, "br")] = brIfaceOption + Ifaces[brName+"+br"] = brIfaceOption err := sbox.Restore(Ifaces, nil, nil, nil) if err != nil { @@ -341,7 +341,7 @@ func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) erro Ifaces = make(map[string][]osl.IfaceOption) vxlanIfaceOption := make([]osl.IfaceOption, 1) vxlanIfaceOption = append(vxlanIfaceOption, sbox.InterfaceOptions().Master(brName)) - Ifaces[fmt.Sprintf("%s+%s", vxlanName, "vxlan")] = vxlanIfaceOption + Ifaces[vxlanName+"+vxlan"] = vxlanIfaceOption err = sbox.Restore(Ifaces, nil, nil, nil) if err != nil { return err diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/solaris/overlay/overlay.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/solaris/overlay/overlay.go index 45b62b183..92b0a4e3b 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/solaris/overlay/overlay.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/solaris/overlay/overlay.go @@ -141,7 +141,7 @@ func (d *driver) restoreEndpoints() error { Ifaces := make(map[string][]osl.IfaceOption) vethIfaceOption := make([]osl.IfaceOption, 1) vethIfaceOption = append(vethIfaceOption, n.sbox.InterfaceOptions().Master(s.brName)) - Ifaces[fmt.Sprintf("%s+%s", "veth", "veth")] = vethIfaceOption + Ifaces["veth+veth"] = vethIfaceOption err := n.sbox.Restore(Ifaces, nil, nil, nil) if err != nil { @@ -234,7 +234,7 @@ func (d *driver) nodeJoin(advertiseAddress, bindAddress string, self bool) { // If there is no cluster store there is no need to start serf. if d.store != nil { if err := validateSelf(advertiseAddress); err != nil { - logrus.Warnf("%s", err.Error()) + logrus.Warn(err.Error()) } err := d.serfInit() if err != nil { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/joinleave_windows.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/joinleave_windows.go index cded48af6..83bee5ad9 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/joinleave_windows.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/joinleave_windows.go @@ -39,6 +39,11 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, if err := jinfo.AddTableEntry(ovPeerTable, eid, buf); err != nil { logrus.Errorf("overlay: Failed adding table entry to joininfo: %v", err) } + + if ep.disablegateway { + jinfo.DisableGatewayService() + } + return nil } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/ov_endpoint_windows.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/ov_endpoint_windows.go index 47af64cb9..b7bda4a6b 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/ov_endpoint_windows.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/ov_endpoint_windows.go @@ -6,7 +6,11 @@ import ( "net" "github.com/Microsoft/hcsshim" + "github.com/docker/docker/pkg/system" "github.com/docker/libnetwork/driverapi" + "github.com/docker/libnetwork/drivers/windows" + "github.com/docker/libnetwork/netlabel" + "github.com/docker/libnetwork/types" "github.com/sirupsen/logrus" ) @@ -15,12 +19,14 @@ type endpointTable map[string]*endpoint const overlayEndpointPrefix = "overlay/endpoint" type endpoint struct { - id string - nid string - profileId string - remote bool - mac net.HardwareAddr - addr *net.IPNet + id string + nid string + profileID string + remote bool + mac net.HardwareAddr + addr *net.IPNet + disablegateway bool + portMapping []types.PortBinding // Operation port bindings } func validateID(nid, eid string) error { @@ -71,7 +77,7 @@ func (n *network) removeEndpointWithAddress(addr *net.IPNet) { if networkEndpoint != nil { logrus.Debugf("Removing stale endpoint from HNS") - _, err := hcsshim.HNSEndpointRequest("DELETE", networkEndpoint.profileId, "") + _, err := hcsshim.HNSEndpointRequest("DELETE", networkEndpoint.profileID, "") if err != nil { logrus.Debugf("Failed to delete stale overlay endpoint (%s) from hns", networkEndpoint.id[0:7]) @@ -96,7 +102,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, logrus.Debugf("Deleting stale endpoint %s", eid) n.deleteEndpoint(eid) - _, err := hcsshim.HNSEndpointRequest("DELETE", ep.profileId, "") + _, err := hcsshim.HNSEndpointRequest("DELETE", ep.profileID, "") if err != nil { return err } @@ -113,17 +119,19 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, return fmt.Errorf("create endpoint was not passed interface IP address") } - if s := n.getSubnetforIP(ep.addr); s == nil { - return fmt.Errorf("no matching subnet for IP %q in network %q\n", ep.addr, nid) + s := n.getSubnetforIP(ep.addr) + if s == nil { + return fmt.Errorf("no matching subnet for IP %q in network %q", ep.addr, nid) } // Todo: Add port bindings and qos policies here hnsEndpoint := &hcsshim.HNSEndpoint{ Name: eid, - VirtualNetwork: n.hnsId, + VirtualNetwork: n.hnsID, IPAddress: ep.addr.IP, EnableInternalDNS: true, + GatewayAddress: s.gwIP.String(), } if ep.mac != nil { @@ -141,6 +149,31 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, hnsEndpoint.Policies = append(hnsEndpoint.Policies, paPolicy) + if system.GetOSVersion().Build > 16236 { + natPolicy, err := json.Marshal(hcsshim.PaPolicy{ + Type: "OutBoundNAT", + }) + + if err != nil { + return err + } + + hnsEndpoint.Policies = append(hnsEndpoint.Policies, natPolicy) + + epConnectivity, err := windows.ParseEndpointConnectivity(epOptions) + if err != nil { + return err + } + + pbPolicy, err := windows.ConvertPortBindings(epConnectivity.PortBindings) + if err != nil { + return err + } + hnsEndpoint.Policies = append(hnsEndpoint.Policies, pbPolicy...) + + ep.disablegateway = true + } + configurationb, err := json.Marshal(hnsEndpoint) if err != nil { return err @@ -151,7 +184,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, return err } - ep.profileId = hnsresponse.Id + ep.profileID = hnsresponse.Id if ep.mac == nil { ep.mac, err = net.ParseMAC(hnsresponse.MacAddress) @@ -164,6 +197,12 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, } } + ep.portMapping, err = windows.ParsePortBindingPolicies(hnsresponse.Policies) + if err != nil { + hcsshim.HNSEndpointRequest("DELETE", hnsresponse.Id, "") + return err + } + n.addEndpoint(ep) return nil @@ -186,7 +225,7 @@ func (d *driver) DeleteEndpoint(nid, eid string) error { n.deleteEndpoint(eid) - _, err := hcsshim.HNSEndpointRequest("DELETE", ep.profileId, "") + _, err := hcsshim.HNSEndpointRequest("DELETE", ep.profileID, "") if err != nil { return err } @@ -210,7 +249,17 @@ func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, erro } data := make(map[string]interface{}, 1) - data["hnsid"] = ep.profileId + data["hnsid"] = ep.profileID data["AllowUnqualifiedDNSQuery"] = true + + if ep.portMapping != nil { + // Return a copy of the operational data + pmc := make([]types.PortBinding, 0, len(ep.portMapping)) + for _, pm := range ep.portMapping { + pmc = append(pmc, pm.GetCopy()) + } + data[netlabel.PortMap] = pmc + } + return data, nil } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/ov_network_windows.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/ov_network_windows.go index 70c4f02ed..9cc46f8cf 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/ov_network_windows.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/ov_network_windows.go @@ -37,7 +37,7 @@ type subnetJSON struct { type network struct { id string name string - hnsId string + hnsID string providerAddress string interfaceName string endpoints endpointTable @@ -108,7 +108,7 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo d case "com.docker.network.windowsshim.interface": interfaceName = value case "com.docker.network.windowsshim.hnsid": - n.hnsId = value + n.hnsID = value case netlabel.OverlayVxlanIDList: vniStrings := strings.Split(value, ",") for _, vniStr := range vniStrings { @@ -181,7 +181,7 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo d if err != nil { d.deleteNetwork(id) } else { - genData["com.docker.network.windowsshim.hnsid"] = n.hnsId + genData["com.docker.network.windowsshim.hnsid"] = n.hnsID } return err @@ -197,7 +197,7 @@ func (d *driver) DeleteNetwork(nid string) error { return types.ForbiddenErrorf("could not find network with id %s", nid) } - _, err := hcsshim.HNSNetworkRequest("DELETE", n.hnsId, "") + _, err := hcsshim.HNSNetworkRequest("DELETE", n.hnsID, "") if err != nil { return types.ForbiddenErrorf(err.Error()) } @@ -242,7 +242,7 @@ func (d *driver) network(nid string) *network { // } // for _, endpoint := range hnsresponse { -// if endpoint.VirtualNetwork != n.hnsId { +// if endpoint.VirtualNetwork != n.hnsID { // continue // } @@ -260,7 +260,7 @@ func (d *driver) network(nid string) *network { func (n *network) convertToOverlayEndpoint(v *hcsshim.HNSEndpoint) *endpoint { ep := &endpoint{ id: v.Name, - profileId: v.Id, + profileID: v.Id, nid: n.id, remote: v.IsRemoteEndpoint, } @@ -311,6 +311,7 @@ func (d *driver) createHnsNetwork(n *network) error { Type: d.Type(), Subnets: subnets, NetworkAdapterName: n.interfaceName, + AutomaticDNS: true, } configurationb, err := json.Marshal(network) @@ -326,7 +327,7 @@ func (d *driver) createHnsNetwork(n *network) error { return err } - n.hnsId = hnsresponse.Id + n.hnsID = hnsresponse.Id n.providerAddress = hnsresponse.ManagementIP return nil diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/overlay_windows.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/overlay_windows.go index d415bebcb..65ad62ae0 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/overlay_windows.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/overlay_windows.go @@ -104,7 +104,7 @@ func (d *driver) restoreHNSNetworks() error { func (d *driver) convertToOverlayNetwork(v *hcsshim.HNSNetwork) *network { n := &network{ id: v.Name, - hnsId: v.Id, + hnsID: v.Id, driver: d, endpoints: endpointTable{}, subnets: []*subnet{}, diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/peerdb_windows.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/peerdb_windows.go index 0abc23243..159bfd6ed 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/peerdb_windows.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/overlay/peerdb_windows.go @@ -33,7 +33,7 @@ func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, hnsEndpoint := &hcsshim.HNSEndpoint{ Name: eid, - VirtualNetwork: n.hnsId, + VirtualNetwork: n.hnsID, MacAddress: peerMac.String(), IPAddress: peerIP, IsRemoteEndpoint: true, @@ -78,7 +78,7 @@ func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, nid: nid, addr: addr, mac: peerMac, - profileId: hnsresponse.Id, + profileID: hnsresponse.Id, remote: true, } @@ -108,7 +108,7 @@ func (d *driver) peerDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMas } if updateDb { - _, err := hcsshim.HNSEndpointRequest("DELETE", ep.profileId, "") + _, err := hcsshim.HNSEndpointRequest("DELETE", ep.profileID, "") if err != nil { return err } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/windows.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/windows.go index 45f835ee0..0b15b2aa4 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/windows.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/drivers/windows/windows.go @@ -55,7 +55,8 @@ type endpointOption struct { DisableICC bool } -type endpointConnectivity struct { +// EndpointConnectivity stores the port bindings and exposed ports that the user has specified in epOptions. +type EndpointConnectivity struct { PortBindings []types.PortBinding ExposedPorts []types.TransportPort } @@ -67,7 +68,7 @@ type hnsEndpoint struct { Type string macAddress net.HardwareAddr epOption *endpointOption // User specified parameters - epConnectivity *endpointConnectivity // User specified parameters + epConnectivity *EndpointConnectivity // User specified parameters portMapping []types.PortBinding // Operation port bindings addr *net.IPNet gateway net.IP @@ -95,7 +96,7 @@ const ( errNotFound = "HNS failed with error : The object identifier does not represent a valid object. " ) -// IsBuiltinWindowsDriver vaidates if network-type is a builtin local-scoped driver +// IsBuiltinLocalDriver validates if network-type is a builtin local-scoped driver func IsBuiltinLocalDriver(networkType string) bool { if "l2bridge" == networkType || "l2tunnel" == networkType || "nat" == networkType || "ics" == networkType || "transparent" == networkType { return true @@ -396,7 +397,8 @@ func convertQosPolicies(qosPolicies []types.QosPolicy) ([]json.RawMessage, error return qps, nil } -func convertPortBindings(portBindings []types.PortBinding) ([]json.RawMessage, error) { +// ConvertPortBindings converts PortBindings to JSON for HNS request +func ConvertPortBindings(portBindings []types.PortBinding) ([]json.RawMessage, error) { var pbs []json.RawMessage // Enumerate through the port bindings specified by the user and convert @@ -431,7 +433,8 @@ func convertPortBindings(portBindings []types.PortBinding) ([]json.RawMessage, e return pbs, nil } -func parsePortBindingPolicies(policies []json.RawMessage) ([]types.PortBinding, error) { +// ParsePortBindingPolicies parses HNS endpoint response message to PortBindings +func ParsePortBindingPolicies(policies []json.RawMessage) ([]types.PortBinding, error) { var bindings []types.PortBinding hcsPolicy := &hcsshim.NatPolicy{} @@ -505,12 +508,13 @@ func parseEndpointOptions(epOptions map[string]interface{}) (*endpointOption, er return ec, nil } -func parseEndpointConnectivity(epOptions map[string]interface{}) (*endpointConnectivity, error) { +// ParseEndpointConnectivity parses options passed to CreateEndpoint, specifically port bindings, and store in a endpointConnectivity object. +func ParseEndpointConnectivity(epOptions map[string]interface{}) (*EndpointConnectivity, error) { if epOptions == nil { return nil, nil } - ec := &endpointConnectivity{} + ec := &EndpointConnectivity{} if opt, ok := epOptions[netlabel.PortMap]; ok { if bs, ok := opt.([]types.PortBinding); ok { @@ -550,7 +554,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, if err != nil { return err } - epConnectivity, err := parseEndpointConnectivity(epOptions) + epConnectivity, err := ParseEndpointConnectivity(epOptions) if err != nil { return err } @@ -561,7 +565,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, endpointStruct.MacAddress = strings.Replace(macAddress.String(), ":", "-", -1) } - endpointStruct.Policies, err = convertPortBindings(epConnectivity.PortBindings) + endpointStruct.Policies, err = ConvertPortBindings(epConnectivity.PortBindings) if err != nil { return err } @@ -615,7 +619,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, endpoint.profileID = hnsresponse.Id endpoint.epConnectivity = epConnectivity endpoint.epOption = epOption - endpoint.portMapping, err = parsePortBindingPolicies(hnsresponse.Policies) + endpoint.portMapping, err = ParsePortBindingPolicies(hnsresponse.Policies) if err != nil { hcsshim.HNSEndpointRequest("DELETE", hnsresponse.Id, "") diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/endpoint.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/endpoint.go index 724d0e531..a2d1dbc4c 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/endpoint.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/endpoint.go @@ -75,6 +75,7 @@ type endpoint struct { dbIndex uint64 dbExists bool serviceEnabled bool + loadBalancer bool sync.Mutex } @@ -101,6 +102,7 @@ func (ep *endpoint) MarshalJSON() ([]byte, error) { epMap["virtualIP"] = ep.virtualIP.String() epMap["ingressPorts"] = ep.ingressPorts epMap["svcAliases"] = ep.svcAliases + epMap["loadBalancer"] = ep.loadBalancer return json.Marshal(epMap) } @@ -201,6 +203,10 @@ func (ep *endpoint) UnmarshalJSON(b []byte) (err error) { ep.virtualIP = net.ParseIP(vip.(string)) } + if v, ok := epMap["loadBalancer"]; ok { + ep.loadBalancer = v.(bool) + } + sal, _ := json.Marshal(epMap["svcAliases"]) var svcAliases []string json.Unmarshal(sal, &svcAliases) @@ -238,6 +244,7 @@ func (ep *endpoint) CopyTo(o datastore.KVObject) error { dstEp.svcName = ep.svcName dstEp.svcID = ep.svcID dstEp.virtualIP = ep.virtualIP + dstEp.loadBalancer = ep.loadBalancer dstEp.svcAliases = make([]string, len(ep.svcAliases)) copy(dstEp.svcAliases, ep.svcAliases) @@ -985,7 +992,7 @@ func CreateOptionDisableResolution() EndpointOption { } } -//CreateOptionAlias function returns an option setter for setting endpoint alias +// CreateOptionAlias function returns an option setter for setting endpoint alias func CreateOptionAlias(name string, alias string) EndpointOption { return func(ep *endpoint) { if ep.aliases == nil { @@ -1006,13 +1013,20 @@ func CreateOptionService(name, id string, vip net.IP, ingressPorts []*PortConfig } } -//CreateOptionMyAlias function returns an option setter for setting endpoint's self alias +// CreateOptionMyAlias function returns an option setter for setting endpoint's self alias func CreateOptionMyAlias(alias string) EndpointOption { return func(ep *endpoint) { ep.myAliases = append(ep.myAliases, alias) } } +// CreateOptionLoadBalancer function returns an option setter for denoting the endpoint is a load balancer for a network +func CreateOptionLoadBalancer() EndpointOption { + return func(ep *endpoint) { + ep.loadBalancer = true + } +} + // JoinOptionPriority function returns an option setter for priority option to // be passed to the endpoint.Join() method. func JoinOptionPriority(ep Endpoint, prio int) EndpointOption { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/endpoint_info.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/endpoint_info.go index 17e93b976..b5d3fabcb 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/endpoint_info.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/endpoint_info.go @@ -31,6 +31,9 @@ type EndpointInfo interface { // Sandbox returns the attached sandbox if there, nil otherwise. Sandbox() Sandbox + + // LoadBalancer returns whether the endpoint is the load balancer endpoint for the network. + LoadBalancer() bool } // InterfaceInfo provides an interface to retrieve interface addresses bound to the endpoint. @@ -327,6 +330,12 @@ func (ep *endpoint) Sandbox() Sandbox { return cnt } +func (ep *endpoint) LoadBalancer() bool { + ep.Lock() + defer ep.Unlock() + return ep.loadBalancer +} + func (ep *endpoint) StaticRoutes() []*types.StaticRoute { ep.Lock() defer ep.Unlock() @@ -413,7 +422,7 @@ func (epj *endpointJoinInfo) UnmarshalJSON(b []byte) error { return err } if v, ok := epMap["gw"]; ok { - epj.gw6 = net.ParseIP(v.(string)) + epj.gw = net.ParseIP(v.(string)) } if v, ok := epMap["gw6"]; ok { epj.gw6 = net.ParseIP(v.(string)) @@ -442,6 +451,6 @@ func (epj *endpointJoinInfo) CopyTo(dstEpj *endpointJoinInfo) error { dstEpj.driverTableEntries = make([]*tableEntry, len(epj.driverTableEntries)) copy(dstEpj.driverTableEntries, epj.driverTableEntries) dstEpj.gw = types.GetIPCopy(epj.gw) - dstEpj.gw = types.GetIPCopy(epj.gw6) + dstEpj.gw6 = types.GetIPCopy(epj.gw6) return nil } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/ipam/allocator.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/ipam/allocator.go index 71c9f3953..c4ed9a0e3 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/ipam/allocator.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/ipam/allocator.go @@ -579,7 +579,7 @@ func (a *Allocator) DumpDatabase() string { s = fmt.Sprintf("\n\n%s Config", as) aSpace.Lock() for k, config := range aSpace.subnets { - s = fmt.Sprintf("%s%s", s, fmt.Sprintf("\n%v: %v", k, config)) + s += fmt.Sprintf("\n%v: %v", k, config) if config.Range == nil { a.retrieveBitmask(k, config.Pool) } @@ -589,7 +589,7 @@ func (a *Allocator) DumpDatabase() string { s = fmt.Sprintf("%s\n\nBitmasks", s) for k, bm := range a.addresses { - s = fmt.Sprintf("%s%s", s, fmt.Sprintf("\n%s: %s", k, bm)) + s += fmt.Sprintf("\n%s: %s", k, bm) } return s diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/ipvs/ipvs.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/ipvs/ipvs.go index a285e102e..ebcdd808c 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/ipvs/ipvs.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/ipvs/ipvs.go @@ -116,6 +116,13 @@ func (i *Handle) DelService(s *Service) error { return i.doCmd(s, nil, ipvsCmdDelService) } +// Flush deletes all existing services in the passed +// handle. +func (i *Handle) Flush() error { + _, err := i.doCmdWithoutAttr(ipvsCmdFlush) + return err +} + // NewDestination creates a new real server in the passed ipvs // service which should already be existing in the passed handle. func (i *Handle) NewDestination(s *Service, d *Destination) error { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/ipvs/netlink.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/ipvs/netlink.go index b8d33dcdc..2089283d1 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/ipvs/netlink.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/ipvs/netlink.go @@ -402,6 +402,13 @@ func (i *Handle) doGetServicesCmd(svc *Service) ([]*Service, error) { return res, nil } +// doCmdWithoutAttr a simple wrapper of netlink socket execute command +func (i *Handle) doCmdWithoutAttr(cmd uint8) ([][]byte, error) { + req := newIPVSRequest(cmd) + req.Seq = atomic.AddUint32(&i.seq, 1) + return execute(i.sock, req, 0) +} + func assembleDestination(attrs []syscall.NetlinkRouteAttr) (*Destination, error) { var d Destination diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/broadcast.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/broadcast.go index 3fe9f6271..52e96ec63 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/broadcast.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/broadcast.go @@ -114,7 +114,8 @@ type tableEventMessage struct { } func (m *tableEventMessage) Invalidates(other memberlist.Broadcast) bool { - return false + otherm := other.(*tableEventMessage) + return m.tname == otherm.tname && m.id == otherm.id && m.key == otherm.key } func (m *tableEventMessage) Message() []byte { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/cluster.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/cluster.go index 264fd3ca4..d15a5767f 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/cluster.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/cluster.go @@ -290,13 +290,6 @@ func (nDB *NetworkDB) reconnectNode() { return } - // Update all the local table state to a new time to - // force update on the node we are trying to rejoin, just in - // case that node has these in deleting state still. This is - // facilitate fast convergence after recovering from a gossip - // failure. - nDB.updateLocalTableTime() - logrus.Debugf("Initiating bulk sync with node %s after reconnect", node.Name) nDB.bulkSync([]string{node.Name}, true) } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/delegate.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/delegate.go index 73163c11f..ffaf94e8c 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/delegate.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/delegate.go @@ -104,6 +104,9 @@ func (nDB *NetworkDB) handleNodeEvent(nEvent *NodeEvent) bool { } n = nDB.checkAndGetNode(nEvent) + if n == nil { + return false + } nDB.purgeSameNode(n) n.ltime = nEvent.LTime @@ -130,25 +133,12 @@ func (nDB *NetworkDB) handleNodeEvent(nEvent *NodeEvent) bool { } func (nDB *NetworkDB) handleNetworkEvent(nEvent *NetworkEvent) bool { - var flushEntries bool // Update our local clock if the received messages has newer // time. nDB.networkClock.Witness(nEvent.LTime) nDB.Lock() - defer func() { - nDB.Unlock() - // When a node leaves a network on the last task removal cleanup the - // local entries for this network & node combination. When the tasks - // on a network are removed we could have missed the gossip updates. - // Not doing this cleanup can leave stale entries because bulksyncs - // from the node will no longer include this network state. - // - // deleteNodeNetworkEntries takes nDB lock. - if flushEntries { - nDB.deleteNodeNetworkEntries(nEvent.NetworkID, nEvent.NodeName) - } - }() + defer nDB.Unlock() if nEvent.NodeName == nDB.config.NodeName { return false @@ -176,7 +166,12 @@ func (nDB *NetworkDB) handleNetworkEvent(nEvent *NetworkEvent) bool { n.leaving = nEvent.Type == NetworkEventTypeLeave if n.leaving { n.reapTime = reapInterval - flushEntries = true + + // The remote node is leaving the network, but not the gossip cluster. + // Mark all its entries in deleted state, this will guarantee that + // if some node bulk sync with us, the deleted state of + // these entries will be propagated. + nDB.deleteNodeNetworkEntries(nEvent.NetworkID, nEvent.NodeName) } if nEvent.Type == NetworkEventTypeLeave { @@ -211,17 +206,22 @@ func (nDB *NetworkDB) handleTableEvent(tEvent *TableEvent) bool { nDB.RLock() networks := nDB.networks[nDB.config.NodeName] network, ok := networks[tEvent.NetworkID] - nDB.RUnlock() - if !ok || network.leaving { - return true + // Check if the owner of the event is still part of the network + nodes := nDB.networkNodes[tEvent.NetworkID] + var nodePresent bool + for _, node := range nodes { + if node == tEvent.NodeName { + nodePresent = true + break + } } - - e, err := nDB.getEntry(tEvent.TableName, tEvent.NetworkID, tEvent.Key) - if err != nil && tEvent.Type == TableEventTypeDelete { - // If it is a delete event and we don't have the entry here nothing to do. + nDB.RUnlock() + if !ok || network.leaving || !nodePresent { + // I'm out of the network OR the event owner is not anymore part of the network so do not propagate return false } + e, err := nDB.getEntry(tEvent.TableName, tEvent.NetworkID, tEvent.Key) if err == nil { // We have the latest state. Ignore the event // since it is stale. @@ -246,6 +246,11 @@ func (nDB *NetworkDB) handleTableEvent(tEvent *TableEvent) bool { nDB.indexes[byNetwork].Insert(fmt.Sprintf("/%s/%s/%s", tEvent.NetworkID, tEvent.TableName, tEvent.Key), e) nDB.Unlock() + if err != nil && tEvent.Type == TableEventTypeDelete { + // If it is a delete event and we didn't have the entry here don't repropagate + return true + } + var op opType switch tEvent.Type { case TableEventTypeCreate: @@ -286,8 +291,7 @@ func (nDB *NetworkDB) handleTableMessage(buf []byte, isBulkSync bool) { return } - // Do not rebroadcast a bulk sync - if rebroadcast := nDB.handleTableEvent(&tEvent); rebroadcast && !isBulkSync { + if rebroadcast := nDB.handleTableEvent(&tEvent); rebroadcast { var err error buf, err = encodeRawMessage(MessageTypeTableEvent, buf) if err != nil { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/event_delegate.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/event_delegate.go index 5c4bb0062..74aa46529 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/event_delegate.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/event_delegate.go @@ -45,9 +45,12 @@ func (e *eventDelegate) NotifyLeave(mn *memberlist.Node) { var failed bool logrus.Infof("Node %s/%s, left gossip cluster", mn.Name, mn.Addr) e.broadcastNodeEvent(mn.Addr, opDelete) - e.nDB.deleteNodeTableEntries(mn.Name) - e.nDB.deleteNetworkEntriesForNode(mn.Name) + // The node left or failed, delete all the entries created by it. + // If the node was temporary down, deleting the entries will guarantee that the CREATE events will be accepted + // If the node instead left because was going down, then it makes sense to just delete all its state e.nDB.Lock() + e.nDB.deleteNetworkEntriesForNode(mn.Name) + e.nDB.deleteNodeTableEntries(mn.Name) if n, ok := e.nDB.nodes[mn.Name]; ok { delete(e.nDB.nodes, mn.Name) @@ -61,7 +64,6 @@ func (e *eventDelegate) NotifyLeave(mn *memberlist.Node) { if failed { logrus.Infof("Node %s/%s, added to failed nodes list", mn.Name, mn.Addr) } - } func (e *eventDelegate) NotifyUpdate(n *memberlist.Node) { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/networkdb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/networkdb.go index 920318d4f..73dd99909 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/networkdb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/networkdb.go @@ -108,6 +108,11 @@ type PeerInfo struct { IP string } +// PeerClusterInfo represents the peer (gossip cluster) nodes +type PeerClusterInfo struct { + PeerInfo +} + type node struct { memberlist.Node ltime serf.LamportTime @@ -253,6 +258,20 @@ func (nDB *NetworkDB) Close() { } } +// ClusterPeers returns all the gossip cluster peers. +func (nDB *NetworkDB) ClusterPeers() []PeerInfo { + nDB.RLock() + defer nDB.RUnlock() + peers := make([]PeerInfo, 0, len(nDB.nodes)) + for _, node := range nDB.nodes { + peers = append(peers, PeerInfo{ + Name: node.Name, + IP: node.Node.Addr.String(), + }) + } + return peers +} + // Peers returns the gossip peers for a given network. func (nDB *NetworkDB) Peers(nid string) []PeerInfo { nDB.RLock() @@ -399,7 +418,6 @@ func (nDB *NetworkDB) DeleteEntry(tname, nid, key string) error { } func (nDB *NetworkDB) deleteNetworkEntriesForNode(deletedNode string) { - nDB.Lock() for nid, nodes := range nDB.networkNodes { updatedNodes := make([]string, 0, len(nodes)) for _, node := range nodes { @@ -414,11 +432,25 @@ func (nDB *NetworkDB) deleteNetworkEntriesForNode(deletedNode string) { } delete(nDB.networks, deletedNode) - nDB.Unlock() } +// deleteNodeNetworkEntries is called in 2 conditions with 2 different outcomes: +// 1) when a notification is coming of a node leaving the network +// - Walk all the network entries and mark the leaving node's entries for deletion +// These will be garbage collected when the reap timer will expire +// 2) when the local node is leaving the network +// - Walk all the network entries: +// A) if the entry is owned by the local node +// then we will mark it for deletion. This will ensure that if a node did not +// yet received the notification that the local node is leaving, will be aware +// of the entries to be deleted. +// B) if the entry is owned by a remote node, then we can safely delete it. This +// ensures that if we join back this network as we receive the CREATE event for +// entries owned by remote nodes, we will accept them and we notify the application func (nDB *NetworkDB) deleteNodeNetworkEntries(nid, node string) { - nDB.Lock() + // Indicates if the delete is triggered for the local node + isNodeLocal := node == nDB.config.NodeName + nDB.indexes[byNetwork].WalkPrefix(fmt.Sprintf("/%s", nid), func(path string, v interface{}) bool { oldEntry := v.(*entry) @@ -427,7 +459,15 @@ func (nDB *NetworkDB) deleteNodeNetworkEntries(nid, node string) { tname := params[1] key := params[2] - if oldEntry.node != node { + // If the entry is owned by a remote node and this node is not leaving the network + if oldEntry.node != node && !isNodeLocal { + // Don't do anything because the event is triggered for a node that does not own this entry + return false + } + + // If this entry is already marked for deletion and this node is not leaving the network + if oldEntry.deleting && !isNodeLocal { + // Don't do anything this entry will be already garbage collected using the old reapTime return false } @@ -439,17 +479,29 @@ func (nDB *NetworkDB) deleteNodeNetworkEntries(nid, node string) { reapTime: reapInterval, } - nDB.indexes[byTable].Insert(fmt.Sprintf("/%s/%s/%s", tname, nid, key), entry) - nDB.indexes[byNetwork].Insert(fmt.Sprintf("/%s/%s/%s", nid, tname, key), entry) + // we arrived at this point in 2 cases: + // 1) this entry is owned by the node that is leaving the network + // 2) the local node is leaving the network + if oldEntry.node == node { + if isNodeLocal { + // TODO fcrisciani: this can be removed if there is no way to leave the network + // without doing a delete of all the objects + entry.ltime++ + } + nDB.indexes[byTable].Insert(fmt.Sprintf("/%s/%s/%s", tname, nid, key), entry) + nDB.indexes[byNetwork].Insert(fmt.Sprintf("/%s/%s/%s", nid, tname, key), entry) + } else { + // the local node is leaving the network, all the entries of remote nodes can be safely removed + nDB.indexes[byTable].Delete(fmt.Sprintf("/%s/%s/%s", tname, nid, key)) + nDB.indexes[byNetwork].Delete(fmt.Sprintf("/%s/%s/%s", nid, tname, key)) + } nDB.broadcaster.Write(makeEvent(opDelete, tname, nid, key, entry.value)) return false }) - nDB.Unlock() } func (nDB *NetworkDB) deleteNodeTableEntries(node string) { - nDB.Lock() nDB.indexes[byTable].Walk(func(path string, v interface{}) bool { oldEntry := v.(*entry) if oldEntry.node != node { @@ -461,27 +513,18 @@ func (nDB *NetworkDB) deleteNodeTableEntries(node string) { nid := params[1] key := params[2] - entry := &entry{ - ltime: oldEntry.ltime, - node: node, - value: oldEntry.value, - deleting: true, - reapTime: reapInterval, - } + nDB.indexes[byTable].Delete(fmt.Sprintf("/%s/%s/%s", tname, nid, key)) + nDB.indexes[byNetwork].Delete(fmt.Sprintf("/%s/%s/%s", nid, tname, key)) - nDB.indexes[byTable].Insert(fmt.Sprintf("/%s/%s/%s", tname, nid, key), entry) - nDB.indexes[byNetwork].Insert(fmt.Sprintf("/%s/%s/%s", nid, tname, key), entry) - - nDB.broadcaster.Write(makeEvent(opDelete, tname, nid, key, entry.value)) + nDB.broadcaster.Write(makeEvent(opDelete, tname, nid, key, oldEntry.value)) return false }) - nDB.Unlock() } // WalkTable walks a single table in NetworkDB and invokes the passed // function for each entry in the table passing the network, key, // value. The walk stops if the passed function returns a true. -func (nDB *NetworkDB) WalkTable(tname string, fn func(string, string, []byte) bool) error { +func (nDB *NetworkDB) WalkTable(tname string, fn func(string, string, []byte, bool) bool) error { nDB.RLock() values := make(map[string]interface{}) nDB.indexes[byTable].WalkPrefix(fmt.Sprintf("/%s", tname), func(path string, v interface{}) bool { @@ -494,7 +537,7 @@ func (nDB *NetworkDB) WalkTable(tname string, fn func(string, string, []byte) bo params := strings.Split(k[1:], "/") nid := params[1] key := params[2] - if fn(nid, key, v.(*entry).value) { + if fn(nid, key, v.(*entry).value, v.(*entry).deleting) { return nil } } @@ -554,37 +597,12 @@ func (nDB *NetworkDB) LeaveNetwork(nid string) error { nDB.Lock() defer nDB.Unlock() - var ( - paths []string - entries []*entry - ) + // Remove myself from the list of the nodes participating to the network nDB.deleteNetworkNode(nid, nDB.config.NodeName) - nwWalker := func(path string, v interface{}) bool { - entry, ok := v.(*entry) - if !ok { - return false - } - paths = append(paths, path) - entries = append(entries, entry) - return false - } - - nDB.indexes[byNetwork].WalkPrefix(fmt.Sprintf("/%s", nid), nwWalker) - for _, path := range paths { - params := strings.Split(path[1:], "/") - tname := params[1] - key := params[2] - - if _, ok := nDB.indexes[byTable].Delete(fmt.Sprintf("/%s/%s/%s", tname, nid, key)); !ok { - logrus.Errorf("Could not delete entry in table %s with network id %s and key %s as it does not exist", tname, nid, key) - } - - if _, ok := nDB.indexes[byNetwork].Delete(fmt.Sprintf("/%s/%s/%s", nid, tname, key)); !ok { - logrus.Errorf("Could not delete entry in network %s with table name %s and key %s as it does not exist", nid, tname, key) - } - } + // Update all the local entries marking them for deletion and delete all the remote entries + nDB.deleteNodeNetworkEntries(nid, nDB.config.NodeName) nodeNetworks, ok := nDB.networks[nDB.config.NodeName] if !ok { @@ -597,6 +615,7 @@ func (nDB *NetworkDB) LeaveNetwork(nid string) error { } n.ltime = ltime + n.reapTime = reapInterval n.leaving = true return nil } @@ -660,27 +679,3 @@ func (nDB *NetworkDB) updateLocalNetworkTime() { n.ltime = ltime } } - -func (nDB *NetworkDB) updateLocalTableTime() { - nDB.Lock() - defer nDB.Unlock() - - ltime := nDB.tableClock.Increment() - nDB.indexes[byTable].Walk(func(path string, v interface{}) bool { - entry := v.(*entry) - if entry.node != nDB.config.NodeName { - return false - } - - params := strings.Split(path[1:], "/") - tname := params[0] - nid := params[1] - key := params[2] - entry.ltime = ltime - - nDB.indexes[byTable].Insert(fmt.Sprintf("/%s/%s/%s", tname, nid, key), entry) - nDB.indexes[byNetwork].Insert(fmt.Sprintf("/%s/%s/%s", nid, tname, key), entry) - - return false - }) -} diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/networkdbdiagnose.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/networkdbdiagnose.go new file mode 100644 index 000000000..d70cec7bb --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/networkdb/networkdbdiagnose.go @@ -0,0 +1,242 @@ +package networkdb + +import ( + "fmt" + "net/http" + "strings" + + "github.com/docker/libnetwork/diagnose" +) + +const ( + missingParameter = "missing parameter" +) + +// NetDbPaths2Func TODO +var NetDbPaths2Func = map[string]diagnose.HTTPHandlerFunc{ + "/join": dbJoin, + "/networkpeers": dbPeers, + "/clusterpeers": dbClusterPeers, + "/joinnetwork": dbJoinNetwork, + "/leavenetwork": dbLeaveNetwork, + "/createentry": dbCreateEntry, + "/updateentry": dbUpdateEntry, + "/deleteentry": dbDeleteEntry, + "/getentry": dbGetEntry, + "/gettable": dbGetTable, +} + +func dbJoin(ctx interface{}, w http.ResponseWriter, r *http.Request) { + r.ParseForm() + diagnose.DebugHTTPForm(r) + if len(r.Form["members"]) < 1 { + diagnose.HTTPReplyError(w, missingParameter, fmt.Sprintf("%s?members=ip1,ip2,...", r.URL.Path)) + return + } + + nDB, ok := ctx.(*NetworkDB) + if ok { + err := nDB.Join(strings.Split(r.Form["members"][0], ",")) + if err != nil { + fmt.Fprintf(w, "%s error in the DB join %s\n", r.URL.Path, err) + return + } + + fmt.Fprintf(w, "OK\n") + } +} + +func dbPeers(ctx interface{}, w http.ResponseWriter, r *http.Request) { + r.ParseForm() + diagnose.DebugHTTPForm(r) + if len(r.Form["nid"]) < 1 { + diagnose.HTTPReplyError(w, missingParameter, fmt.Sprintf("%s?nid=test", r.URL.Path)) + return + } + + nDB, ok := ctx.(*NetworkDB) + if ok { + peers := nDB.Peers(r.Form["nid"][0]) + fmt.Fprintf(w, "Network:%s Total peers: %d\n", r.Form["nid"], len(peers)) + for i, peerInfo := range peers { + fmt.Fprintf(w, "%d) %s -> %s\n", i, peerInfo.Name, peerInfo.IP) + } + } +} + +func dbClusterPeers(ctx interface{}, w http.ResponseWriter, r *http.Request) { + nDB, ok := ctx.(*NetworkDB) + if ok { + peers := nDB.ClusterPeers() + fmt.Fprintf(w, "Total peers: %d\n", len(peers)) + for i, peerInfo := range peers { + fmt.Fprintf(w, "%d) %s -> %s\n", i, peerInfo.Name, peerInfo.IP) + } + } +} + +func dbCreateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) { + r.ParseForm() + diagnose.DebugHTTPForm(r) + if len(r.Form["tname"]) < 1 || + len(r.Form["nid"]) < 1 || + len(r.Form["key"]) < 1 || + len(r.Form["value"]) < 1 { + diagnose.HTTPReplyError(w, missingParameter, fmt.Sprintf("%s?tname=table_name&nid=network_id&key=k&value=v", r.URL.Path)) + return + } + + tname := r.Form["tname"][0] + nid := r.Form["nid"][0] + key := r.Form["key"][0] + value := r.Form["value"][0] + + nDB, ok := ctx.(*NetworkDB) + if ok { + if err := nDB.CreateEntry(tname, nid, key, []byte(value)); err != nil { + diagnose.HTTPReplyError(w, err.Error(), "") + return + } + fmt.Fprintf(w, "OK\n") + } +} + +func dbUpdateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) { + r.ParseForm() + diagnose.DebugHTTPForm(r) + if len(r.Form["tname"]) < 1 || + len(r.Form["nid"]) < 1 || + len(r.Form["key"]) < 1 || + len(r.Form["value"]) < 1 { + diagnose.HTTPReplyError(w, missingParameter, fmt.Sprintf("%s?tname=table_name&nid=network_id&key=k&value=v", r.URL.Path)) + return + } + + tname := r.Form["tname"][0] + nid := r.Form["nid"][0] + key := r.Form["key"][0] + value := r.Form["value"][0] + + nDB, ok := ctx.(*NetworkDB) + if ok { + if err := nDB.UpdateEntry(tname, nid, key, []byte(value)); err != nil { + diagnose.HTTPReplyError(w, err.Error(), "") + return + } + fmt.Fprintf(w, "OK\n") + } +} + +func dbDeleteEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) { + r.ParseForm() + diagnose.DebugHTTPForm(r) + if len(r.Form["tname"]) < 1 || + len(r.Form["nid"]) < 1 || + len(r.Form["key"]) < 1 { + diagnose.HTTPReplyError(w, missingParameter, fmt.Sprintf("%s?tname=table_name&nid=network_id&key=k", r.URL.Path)) + return + } + + tname := r.Form["tname"][0] + nid := r.Form["nid"][0] + key := r.Form["key"][0] + + nDB, ok := ctx.(*NetworkDB) + if ok { + err := nDB.DeleteEntry(tname, nid, key) + if err != nil { + diagnose.HTTPReplyError(w, err.Error(), "") + return + } + fmt.Fprintf(w, "OK\n") + } +} + +func dbGetEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) { + r.ParseForm() + diagnose.DebugHTTPForm(r) + if len(r.Form["tname"]) < 1 || + len(r.Form["nid"]) < 1 || + len(r.Form["key"]) < 1 { + diagnose.HTTPReplyError(w, missingParameter, fmt.Sprintf("%s?tname=table_name&nid=network_id&key=k", r.URL.Path)) + return + } + + tname := r.Form["tname"][0] + nid := r.Form["nid"][0] + key := r.Form["key"][0] + + nDB, ok := ctx.(*NetworkDB) + if ok { + value, err := nDB.GetEntry(tname, nid, key) + if err != nil { + diagnose.HTTPReplyError(w, err.Error(), "") + return + } + fmt.Fprintf(w, "key:`%s` value:`%s`\n", key, string(value)) + } +} + +func dbJoinNetwork(ctx interface{}, w http.ResponseWriter, r *http.Request) { + r.ParseForm() + diagnose.DebugHTTPForm(r) + if len(r.Form["nid"]) < 1 { + diagnose.HTTPReplyError(w, missingParameter, fmt.Sprintf("%s?nid=network_id", r.URL.Path)) + return + } + + nid := r.Form["nid"][0] + + nDB, ok := ctx.(*NetworkDB) + if ok { + if err := nDB.JoinNetwork(nid); err != nil { + diagnose.HTTPReplyError(w, err.Error(), "") + return + } + fmt.Fprintf(w, "OK\n") + } +} + +func dbLeaveNetwork(ctx interface{}, w http.ResponseWriter, r *http.Request) { + r.ParseForm() + diagnose.DebugHTTPForm(r) + if len(r.Form["nid"]) < 1 { + diagnose.HTTPReplyError(w, missingParameter, fmt.Sprintf("%s?nid=network_id", r.URL.Path)) + return + } + + nid := r.Form["nid"][0] + + nDB, ok := ctx.(*NetworkDB) + if ok { + if err := nDB.LeaveNetwork(nid); err != nil { + diagnose.HTTPReplyError(w, err.Error(), "") + return + } + fmt.Fprintf(w, "OK\n") + } +} + +func dbGetTable(ctx interface{}, w http.ResponseWriter, r *http.Request) { + r.ParseForm() + diagnose.DebugHTTPForm(r) + if len(r.Form["tname"]) < 1 || + len(r.Form["nid"]) < 1 { + diagnose.HTTPReplyError(w, missingParameter, fmt.Sprintf("%s?tname=table_name&nid=network_id", r.URL.Path)) + return + } + + tname := r.Form["tname"][0] + nid := r.Form["nid"][0] + + nDB, ok := ctx.(*NetworkDB) + if ok { + table := nDB.GetTableByNetwork(tname, nid) + fmt.Fprintf(w, "total elements: %d\n", len(table)) + i := 0 + for k, v := range table { + fmt.Fprintf(w, "%d) k:`%s` -> v:`%s`\n", i, k, string(v.([]byte))) + i++ + } + } +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/interface_linux.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/interface_linux.go index 60583bd80..0ecda09f6 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/interface_linux.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/interface_linux.go @@ -26,7 +26,6 @@ type nwIface struct { mac net.HardwareAddr address *net.IPNet addressIPv6 *net.IPNet - ipAliases []*net.IPNet llAddrs []*net.IPNet routes []*net.IPNet bridge bool @@ -97,13 +96,6 @@ func (i *nwIface) LinkLocalAddresses() []*net.IPNet { return i.llAddrs } -func (i *nwIface) IPAliases() []*net.IPNet { - i.Lock() - defer i.Unlock() - - return i.ipAliases -} - func (i *nwIface) Routes() []*net.IPNet { i.Lock() defer i.Unlock() @@ -337,7 +329,6 @@ func configureInterface(nlh *netlink.Handle, iface netlink.Link, i *nwIface) err {setInterfaceIPv6, fmt.Sprintf("error setting interface %q IPv6 to %v", ifaceName, i.AddressIPv6())}, {setInterfaceMaster, fmt.Sprintf("error setting interface %q master to %q", ifaceName, i.DstMaster())}, {setInterfaceLinkLocalIPs, fmt.Sprintf("error setting interface %q link local IPs to %v", ifaceName, i.LinkLocalAddresses())}, - {setInterfaceIPAliases, fmt.Sprintf("error setting interface %q IP Aliases to %v", ifaceName, i.IPAliases())}, } for _, config := range ifaceConfigurators { @@ -399,16 +390,6 @@ func setInterfaceLinkLocalIPs(nlh *netlink.Handle, iface netlink.Link, i *nwIfac return nil } -func setInterfaceIPAliases(nlh *netlink.Handle, iface netlink.Link, i *nwIface) error { - for _, si := range i.IPAliases() { - ipAddr := &netlink.Addr{IPNet: si} - if err := nlh.AddrAdd(iface, ipAddr); err != nil { - return err - } - } - return nil -} - func setInterfaceName(nlh *netlink.Handle, iface netlink.Link, i *nwIface) error { return nlh.LinkSetName(iface, i.DstName()) } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/namespace_linux.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/namespace_linux.go index 33a84f598..6ddf7f16a 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/namespace_linux.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/namespace_linux.go @@ -356,6 +356,22 @@ func (n *networkNamespace) loopbackUp() error { return n.nlHandle.LinkSetUp(iface) } +func (n *networkNamespace) AddLoopbackAliasIP(ip *net.IPNet) error { + iface, err := n.nlHandle.LinkByName("lo") + if err != nil { + return err + } + return n.nlHandle.AddrAdd(iface, &netlink.Addr{IPNet: ip}) +} + +func (n *networkNamespace) RemoveLoopbackAliasIP(ip *net.IPNet) error { + iface, err := n.nlHandle.LinkByName("lo") + if err != nil { + return err + } + return n.nlHandle.AddrDel(iface, &netlink.Addr{IPNet: ip}) +} + func (n *networkNamespace) InvokeFunc(f func()) error { return nsInvoke(n.nsPath(), func(nsFD int) error { return nil }, func(callerFD int) error { f() diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/neigh_linux.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/neigh_linux.go index dc1d300c0..4e479489f 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/neigh_linux.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/neigh_linux.go @@ -91,9 +91,7 @@ func (n *networkNamespace) DeleteNeighbor(dstIP net.IP, dstMac net.HardwareAddr, if nh.linkDst != "" { nlnh.LinkIndex = iface.Attrs().Index } - if err := nlh.NeighDel(nlnh); err != nil { - logrus.Warnf("Deleting bridge mac mac %s failed, %v", dstMac, err) - } + nlh.NeighDel(nlnh) } } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/options_linux.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/options_linux.go index 64309d050..818669647 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/options_linux.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/options_linux.go @@ -66,12 +66,6 @@ func (n *networkNamespace) LinkLocalAddresses(list []*net.IPNet) IfaceOption { } } -func (n *networkNamespace) IPAliases(list []*net.IPNet) IfaceOption { - return func(i *nwIface) { - i.ipAliases = list - } -} - func (n *networkNamespace) Routes(routes []*net.IPNet) IfaceOption { return func(i *nwIface) { i.routes = routes diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/sandbox.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/sandbox.go index 64288f930..6ffc46775 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/sandbox.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/osl/sandbox.go @@ -32,6 +32,12 @@ type Sandbox interface { // Unset the previously set default IPv6 gateway in the sandbox UnsetGatewayIPv6() error + // AddLoopbackAliasIP adds the passed IP address to the sandbox loopback interface + AddLoopbackAliasIP(ip *net.IPNet) error + + // RemoveLoopbackAliasIP removes the passed IP address from the sandbox loopback interface + RemoveLoopbackAliasIP(ip *net.IPNet) error + // Add a static route to the sandbox. AddStaticRoute(*types.StaticRoute) error @@ -91,9 +97,6 @@ type IfaceOptionSetter interface { // LinkLocalAddresses returns an option setter to set the link-local IP addresses. LinkLocalAddresses([]*net.IPNet) IfaceOption - // IPAliases returns an option setter to set IP address Aliases - IPAliases([]*net.IPNet) IfaceOption - // Master returns an option setter to set the master interface if any for this // interface. The master interface name should refer to the srcname of a // previously added interface of type bridge. @@ -150,9 +153,6 @@ type Interface interface { // LinkLocalAddresses returns the link-local IP addresses assigned to the interface. LinkLocalAddresses() []*net.IPNet - // IPAliases returns the IP address aliases assigned to the interface. - IPAliases() []*net.IPNet - // IP routes for the interface. Routes() []*net.IPNet diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/portallocator/portallocator_freebsd.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/portallocator/portallocator_freebsd.go new file mode 100644 index 000000000..97d7fbb49 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/portallocator/portallocator_freebsd.go @@ -0,0 +1,42 @@ +package portallocator + +import ( + "bytes" + "fmt" + "os/exec" +) + +func getDynamicPortRange() (start int, end int, err error) { + portRangeKernelSysctl := []string{"net.inet.ip.portrange.hifirst", "net.ip.portrange.hilast"} + portRangeFallback := fmt.Sprintf("using fallback port range %d-%d", DefaultPortRangeStart, DefaultPortRangeEnd) + portRangeLowCmd := exec.Command("/sbin/sysctl", portRangeKernelSysctl[0]) + var portRangeLowOut bytes.Buffer + portRangeLowCmd.Stdout = &portRangeLowOut + cmdErr := portRangeLowCmd.Run() + if cmdErr != nil { + return 0, 0, fmt.Errorf("port allocator - sysctl net.inet.ip.portrange.hifirst failed - %s: %v", portRangeFallback, err) + } + n, err := fmt.Sscanf(portRangeLowOut.String(), "%d", &start) + if n != 1 || err != nil { + if err == nil { + err = fmt.Errorf("unexpected count of parsed numbers (%d)", n) + } + return 0, 0, fmt.Errorf("port allocator - failed to parse system ephemeral port range start from %s - %s: %v", portRangeLowOut.String(), portRangeFallback, err) + } + + portRangeHighCmd := exec.Command("/sbin/sysctl", portRangeKernelSysctl[1]) + var portRangeHighOut bytes.Buffer + portRangeHighCmd.Stdout = &portRangeHighOut + cmdErr = portRangeHighCmd.Run() + if cmdErr != nil { + return 0, 0, fmt.Errorf("port allocator - sysctl net.inet.ip.portrange.hilast failed - %s: %v", portRangeFallback, err) + } + n, err = fmt.Sscanf(portRangeHighOut.String(), "%d", &end) + if n != 1 || err != nil { + if err == nil { + err = fmt.Errorf("unexpected count of parsed numbers (%d)", n) + } + return 0, 0, fmt.Errorf("port allocator - failed to parse system ephemeral port range end from %s - %s: %v", portRangeHighOut.String(), portRangeFallback, err) + } + return start, end, nil +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/resolver.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/resolver.go index d382e7f67..83382b645 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/resolver.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/resolver.go @@ -231,7 +231,7 @@ func (r *resolver) handleIPQuery(name string, query *dns.Msg, ipType int) (*dns. if addr == nil && ipv6Miss { // Send a reply without any Answer sections - logrus.Debugf("Lookup name %s present without IPv6 address", name) + logrus.Debugf("[resolver] lookup name %s present without IPv6 address", name) resp := createRespMsg(query) return resp, nil } @@ -239,7 +239,7 @@ func (r *resolver) handleIPQuery(name string, query *dns.Msg, ipType int) (*dns. return nil, nil } - logrus.Debugf("Lookup for %s: IP %v", name, addr) + logrus.Debugf("[resolver] lookup for %s: IP %v", name, addr) resp := createRespMsg(query) if len(addr) > 1 { @@ -280,7 +280,7 @@ func (r *resolver) handlePTRQuery(ptr string, query *dns.Msg) (*dns.Msg, error) return nil, nil } - logrus.Debugf("Lookup for IP %s: name %s", parts[0], host) + logrus.Debugf("[resolver] lookup for IP %s: name %s", parts[0], host) fqdn := dns.Fqdn(host) resp := new(dns.Msg) @@ -431,10 +431,12 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) { } } if err != nil { - logrus.Warnf("Connect failed: %s", err) + logrus.Warnf("[resolver] connect failed: %s", err) continue } - logrus.Debugf("Query %s[%d] from %s, forwarding to %s:%s", name, query.Question[0].Qtype, + + queryType := dns.TypeToString[query.Question[0].Qtype] + logrus.Debugf("[resolver] query %s (%s) from %s, forwarding to %s:%s", name, queryType, extConn.LocalAddr().String(), proto, extDNS.IPStr) // Timeout has to be set for every IO operation. @@ -450,7 +452,7 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) { old := r.tStamp r.tStamp = time.Now() if r.tStamp.Sub(old) > logInterval { - logrus.Errorf("More than %v concurrent queries from %s", maxConcurrent, extConn.LocalAddr().String()) + logrus.Errorf("[resolver] more than %v concurrent queries from %s", maxConcurrent, extConn.LocalAddr().String()) } continue } @@ -458,7 +460,7 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) { err = co.WriteMsg(query) if err != nil { r.forwardQueryEnd() - logrus.Debugf("Send to DNS server failed, %s", err) + logrus.Debugf("[resolver] send to DNS server failed, %s", err) continue } @@ -467,22 +469,32 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) { // client can retry over TCP if err != nil && err != dns.ErrTruncated { r.forwardQueryEnd() - logrus.Debugf("Read from DNS server failed, %s", err) + logrus.Debugf("[resolver] read from DNS server failed, %s", err) continue } r.forwardQueryEnd() if resp != nil { + answers := 0 for _, rr := range resp.Answer { h := rr.Header() switch h.Rrtype { case dns.TypeA: + answers++ ip := rr.(*dns.A).A + logrus.Debugf("[resolver] received A record %q for %q from %s:%s", ip, h.Name, proto, extDNS.IPStr) r.backend.HandleQueryResp(h.Name, ip) case dns.TypeAAAA: + answers++ ip := rr.(*dns.AAAA).AAAA + logrus.Debugf("[resolver] received AAAA record %q for %q from %s:%s", ip, h.Name, proto, extDNS.IPStr) r.backend.HandleQueryResp(h.Name, ip) } } + if resp.Answer == nil || answers == 0 { + logrus.Debugf("[resolver] external DNS %s:%s did not return any %s records for %q", proto, extDNS.IPStr, queryType, name) + } + } else { + logrus.Debugf("[resolver] external DNS %s:%s returned empty response for %q", proto, extDNS.IPStr, name) } resp.Compress = true break @@ -493,7 +505,7 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) { } if err = w.WriteMsg(resp); err != nil { - logrus.Errorf("error writing resolver resp, %s", err) + logrus.Errorf("[resolver] error writing resolver resp, %s", err) } } @@ -514,7 +526,7 @@ func (r *resolver) forwardQueryEnd() { defer r.queryLock.Unlock() if r.count == 0 { - logrus.Error("Invalid concurrent query count") + logrus.Error("[resolver] invalid concurrent query count") } else { r.count-- } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/sandbox.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/sandbox.go index 167bc301a..315195ebb 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/sandbox.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/sandbox.go @@ -709,8 +709,15 @@ func releaseOSSboxResources(osSbox osl.Sandbox, ep *endpoint) { ep.Lock() joinInfo := ep.joinInfo + vip := ep.virtualIP ep.Unlock() + if len(vip) != 0 { + if err := osSbox.RemoveLoopbackAliasIP(&net.IPNet{IP: vip, Mask: net.CIDRMask(32, 32)}); err != nil { + logrus.Warnf("Remove virtual IP %v failed: %v", vip, err) + } + } + if joinInfo == nil { return } @@ -767,10 +774,6 @@ func (sb *sandbox) restoreOslSandbox() error { if len(i.llAddrs) != 0 { ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().LinkLocalAddresses(i.llAddrs)) } - if len(ep.virtualIP) != 0 { - vipAlias := &net.IPNet{IP: ep.virtualIP, Mask: net.CIDRMask(32, 32)} - ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().IPAliases([]*net.IPNet{vipAlias})) - } Ifaces[fmt.Sprintf("%s+%s", i.srcName, i.dstPrefix)] = ifaceOptions if joinInfo != nil { routes = append(routes, joinInfo.StaticRoutes...) @@ -818,10 +821,6 @@ func (sb *sandbox) populateNetworkResources(ep *endpoint) error { if len(i.llAddrs) != 0 { ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().LinkLocalAddresses(i.llAddrs)) } - if len(ep.virtualIP) != 0 { - vipAlias := &net.IPNet{IP: ep.virtualIP, Mask: net.CIDRMask(32, 32)} - ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().IPAliases([]*net.IPNet{vipAlias})) - } if i.mac != nil { ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().MacAddress(i.mac)) } @@ -831,6 +830,13 @@ func (sb *sandbox) populateNetworkResources(ep *endpoint) error { } } + if len(ep.virtualIP) != 0 { + err := sb.osSbox.AddLoopbackAliasIP(&net.IPNet{IP: ep.virtualIP, Mask: net.CIDRMask(32, 32)}) + if err != nil { + return fmt.Errorf("failed to add virtual IP %v: %v", ep.virtualIP, err) + } + } + if joinInfo != nil { // Set up non-interface routes. for _, r := range joinInfo.StaticRoutes { @@ -910,6 +916,13 @@ func (sb *sandbox) clearNetworkResources(origEp *endpoint) error { break } } + + if index == -1 { + logrus.Warnf("Endpoint %s has already been deleted", ep.Name()) + sb.Unlock() + return nil + } + heap.Remove(&sb.endpoints, index) for _, e := range sb.endpoints { if len(e.Gateway()) > 0 { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/sandbox_dns_unix.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/sandbox_dns_unix.go index f18f0b3ee..d19633055 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/sandbox_dns_unix.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/sandbox_dns_unix.go @@ -197,14 +197,26 @@ func (sb *sandbox) setupDNS() error { // This is for the host mode networking if sb.config.originResolvConfPath != "" { if err := copyFile(sb.config.originResolvConfPath, sb.config.resolvConfPath); err != nil { - return fmt.Errorf("could not copy source resolv.conf file %s to %s: %v", sb.config.originResolvConfPath, sb.config.resolvConfPath, err) + if !os.IsNotExist(err) { + return fmt.Errorf("could not copy source resolv.conf file %s to %s: %v", sb.config.originResolvConfPath, sb.config.resolvConfPath, err) + } + logrus.Infof("%s does not exist, we create an empty resolv.conf for container", sb.config.originResolvConfPath) + if err := createFile(sb.config.resolvConfPath); err != nil { + return err + } } return nil } currRC, err := resolvconf.Get() if err != nil { - return err + if !os.IsNotExist(err) { + return err + } + // it's ok to continue if /etc/resolv.conf doesn't exist, default resolvers (Google's Public DNS) + // will be used + currRC = &resolvconf.File{} + logrus.Infof("/etc/resolv.conf does not exist") } if len(sb.config.dnsList) > 0 || len(sb.config.dnsSearchList) > 0 || len(sb.config.dnsOptionsList) > 0 { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service.go index 5a0d7e005..63095f31b 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service.go @@ -89,4 +89,5 @@ type loadBalancer struct { // Back pointer to service to which the loadbalancer belongs. service *service + sync.Mutex } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service_common.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service_common.go index 64d283e54..fe54ea30c 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service_common.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service_common.go @@ -287,7 +287,7 @@ func (c *controller) addServiceBinding(svcName, svcID, nID, eID, containerName s // Add loadbalancer service and backend in all sandboxes in // the network only if vip is valid. if len(vip) != 0 { - n.(*network).addLBBackend(ip, vip, lb.fwMark, ingressPorts) + n.(*network).addLBBackend(ip, vip, lb, ingressPorts) } // Add the appropriate name resolutions @@ -355,7 +355,7 @@ func (c *controller) rmServiceBinding(svcName, svcID, nID, eID, containerName st // Remove loadbalancer service(if needed) and backend in all // sandboxes in the network only if the vip is valid. if len(vip) != 0 && entries == 0 { - n.(*network).rmLBBackend(ip, vip, lb.fwMark, ingressPorts, rmService) + n.(*network).rmLBBackend(ip, vip, lb, ingressPorts, rmService) } // Delete the name resolutions diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service_linux.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service_linux.go index 00665941e..d8a95b2f5 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service_linux.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service_linux.go @@ -111,7 +111,7 @@ func (sb *sandbox) populateLoadbalancers(ep *endpoint) { // Add loadbalancer backend to all sandboxes which has a connection to // this network. If needed add the service as well. -func (n *network) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*PortConfig) { +func (n *network) addLBBackend(ip, vip net.IP, lb *loadBalancer, ingressPorts []*PortConfig) { n.WalkEndpoints(func(e Endpoint) bool { ep := e.(*endpoint) if sb, ok := ep.getSandbox(); ok { @@ -124,7 +124,7 @@ func (n *network) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*Po gwIP = ep.Iface().Address().IP } - sb.addLBBackend(ip, vip, fwMark, ingressPorts, ep.Iface().Address(), gwIP, n.ingress) + sb.addLBBackend(ip, vip, lb.fwMark, ingressPorts, ep.Iface().Address(), gwIP, n.ingress) } return false @@ -134,7 +134,7 @@ func (n *network) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*Po // Remove loadbalancer backend from all sandboxes which has a // connection to this network. If needed remove the service entry as // well, as specified by the rmService bool. -func (n *network) rmLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*PortConfig, rmService bool) { +func (n *network) rmLBBackend(ip, vip net.IP, lb *loadBalancer, ingressPorts []*PortConfig, rmService bool) { n.WalkEndpoints(func(e Endpoint) bool { ep := e.(*endpoint) if sb, ok := ep.getSandbox(); ok { @@ -147,7 +147,7 @@ func (n *network) rmLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*Por gwIP = ep.Iface().Address().IP } - sb.rmLBBackend(ip, vip, fwMark, ingressPorts, ep.Iface().Address(), gwIP, rmService, n.ingress) + sb.rmLBBackend(ip, vip, lb.fwMark, ingressPorts, ep.Iface().Address(), gwIP, rmService, n.ingress) } return false diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service_windows.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service_windows.go index 6fe521ef9..9ed3e0604 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service_windows.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/service_windows.go @@ -1,11 +1,146 @@ package libnetwork -import "net" +import ( + "net" -func (n *network) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*PortConfig) { + "github.com/Microsoft/hcsshim" + "github.com/docker/docker/pkg/system" + "github.com/sirupsen/logrus" +) + +type policyLists struct { + ilb *hcsshim.PolicyList + elb *hcsshim.PolicyList +} + +var lbPolicylistMap map[*loadBalancer]*policyLists + +func init() { + lbPolicylistMap = make(map[*loadBalancer]*policyLists) +} + +func (n *network) addLBBackend(ip, vip net.IP, lb *loadBalancer, ingressPorts []*PortConfig) { + + if system.GetOSVersion().Build > 16236 { + lb.Lock() + defer lb.Unlock() + //find the load balancer IP for the network. + var sourceVIP string + for _, e := range n.Endpoints() { + epInfo := e.Info() + if epInfo == nil { + continue + } + if epInfo.LoadBalancer() { + sourceVIP = epInfo.Iface().Address().IP.String() + break + } + } + + if sourceVIP == "" { + logrus.Errorf("Failed to find load balancer IP for network %s", n.Name()) + return + } + + var endpoints []hcsshim.HNSEndpoint + + for eid := range lb.backEnds { + //Call HNS to get back ID (GUID) corresponding to the endpoint. + hnsEndpoint, err := hcsshim.GetHNSEndpointByName(eid) + if err != nil { + logrus.Errorf("Failed to find HNS ID for endpoint %v: %v", eid, err) + return + } + + endpoints = append(endpoints, *hnsEndpoint) + } + + if policies, ok := lbPolicylistMap[lb]; ok { + + if policies.ilb != nil { + policies.ilb.Delete() + policies.ilb = nil + } + + if policies.elb != nil { + policies.elb.Delete() + policies.elb = nil + } + delete(lbPolicylistMap, lb) + } + + ilbPolicy, err := hcsshim.AddLoadBalancer(endpoints, true, sourceVIP, vip.String(), 0, 0, 0) + if err != nil { + logrus.Errorf("Failed to add ILB policy for service %s (%s) with endpoints %v using load balancer IP %s on network %s: %v", + lb.service.name, vip.String(), endpoints, sourceVIP, n.Name(), err) + return + } + + lbPolicylistMap[lb] = &policyLists{ + ilb: ilbPolicy, + } + + publishedPorts := make(map[uint32]uint32) + + for i, port := range ingressPorts { + protocol := uint16(6) + + // Skip already published port + if publishedPorts[port.PublishedPort] == port.TargetPort { + continue + } + + if port.Protocol == ProtocolUDP { + protocol = 17 + } + + // check if already has udp matching to add wild card publishing + for j := i + 1; j < len(ingressPorts); j++ { + if ingressPorts[j].TargetPort == port.TargetPort && + ingressPorts[j].PublishedPort == port.PublishedPort { + protocol = 0 + } + } + + publishedPorts[port.PublishedPort] = port.TargetPort + + lbPolicylistMap[lb].elb, err = hcsshim.AddLoadBalancer(endpoints, false, sourceVIP, "", protocol, uint16(port.TargetPort), uint16(port.PublishedPort)) + if err != nil { + logrus.Errorf("Failed to add ELB policy for service %s (ip:%s target port:%v published port:%v) with endpoints %v using load balancer IP %s on network %s: %v", + lb.service.name, vip.String(), uint16(port.TargetPort), uint16(port.PublishedPort), endpoints, sourceVIP, n.Name(), err) + return + } + } + } } -func (n *network) rmLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*PortConfig, rmService bool) { +func (n *network) rmLBBackend(ip, vip net.IP, lb *loadBalancer, ingressPorts []*PortConfig, rmService bool) { + if system.GetOSVersion().Build > 16236 { + if len(lb.backEnds) > 0 { + //Reprogram HNS (actually VFP) with the existing backends. + n.addLBBackend(ip, vip, lb, ingressPorts) + } else { + lb.Lock() + defer lb.Unlock() + logrus.Debugf("No more backends for service %s (ip:%s). Removing all policies", lb.service.name, lb.vip.String()) + + if policyLists, ok := lbPolicylistMap[lb]; ok { + if policyLists.ilb != nil { + policyLists.ilb.Delete() + policyLists.ilb = nil + } + + if policyLists.elb != nil { + policyLists.elb.Delete() + policyLists.elb = nil + } + delete(lbPolicylistMap, lb) + + } else { + logrus.Errorf("Failed to find policies for service %s (%s)", lb.service.name, lb.vip.String()) + } + } + } } func (sb *sandbox) populateLoadbalancers(ep *endpoint) { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/types/types.go b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/types/types.go index da113e24c..164b18096 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/types/types.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/types/types.go @@ -129,11 +129,11 @@ func (p *PortBinding) GetCopy() PortBinding { func (p *PortBinding) String() string { ret := fmt.Sprintf("%s/", p.Proto) if p.IP != nil { - ret = fmt.Sprintf("%s%s", ret, p.IP.String()) + ret += p.IP.String() } ret = fmt.Sprintf("%s:%d/", ret, p.Port) if p.HostIP != nil { - ret = fmt.Sprintf("%s%s", ret, p.HostIP.String()) + ret += p.HostIP.String() } ret = fmt.Sprintf("%s:%d", ret, p.HostPort) return ret diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/vendor.conf b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/vendor.conf index 203e1cebf..c97f5517d 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/vendor.conf +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/libnetwork/vendor.conf @@ -1,8 +1,7 @@ -github.com/Azure/go-ansiterm 04b7f292a41fcb5da32dda536c0807fc13e8351c +github.com/Azure/go-ansiterm 19f72df4d05d31cbe1c56bfc8045c96babff6c7e github.com/BurntSushi/toml f706d00e3de6abe700c994cdd545a1a4915af060 github.com/Microsoft/go-winio ce2922f643c8fd76b46cadc7f404a06282678b34 -github.com/Microsoft/hcsshim e439b7d2b63f036d3a50c93a9e0b154a0d50e788 -github.com/Sirupsen/logrus 4b6ea7319e214d98c938f12692336f7ca9348d6b +github.com/Microsoft/hcsshim v0.6.3 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 github.com/boltdb/bolt c6ba97b89e0454fec9aa92e1d33a4e2c5fc1f631 @@ -11,9 +10,9 @@ github.com/coreos/etcd 925d1d74cec8c3b169c52fd4b2dc234a35934fce github.com/coreos/go-systemd b4a58d95188dd092ae20072bac14cece0e67c388 github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d -github.com/docker/docker 9c96768eae4b3a65147b47a55c850c103ab8972d -github.com/docker/go-connections 34b5052da6b11e27f5f2e357b38b571ddddd3928 -github.com/docker/go-events 2e7d352816128aa84f4d29b2a21d400133701a0d +github.com/docker/docker 2cac43e3573893cf8fd816e0ad5615426acb87f4 https://github.com/dmcgowan/docker.git +github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d +github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 github.com/docker/go-units 8e2d4523730c73120e10d4652f36ad6010998f4e github.com/docker/libkv 1d8431073ae03cdaedb198a89722f3aab6d418ef @@ -31,9 +30,10 @@ github.com/hashicorp/go-sockaddr acd314c5781ea706c710d9ea70069fd2e110d61d github.com/hashicorp/serf 598c54895cc5a7b1a24a398d635e8c0ea0959870 github.com/mattn/go-shellwords 525bedee691b5a8df547cb5cf9f86b7fb1883e24 github.com/miekg/dns d27455715200c7d3e321a1e5cadb27c9ee0b0f02 -github.com/opencontainers/runc ba1568de399395774ad84c2ace65937814c542ed +github.com/opencontainers/runc 8694d576ea3ce3c9e2c804b7f91b4e1e9a575d1c https://github.com/dmcgowan/runc.git github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374 github.com/seccomp/libseccomp-golang 1b506fc7c24eec5a3693cdcbed40d9c226cfc6a1 +github.com/sirupsen/logrus v1.0.1 github.com/stretchr/testify dab07ac62d4905d3e48d17dc549c684ac3b7c15a github.com/syndtr/gocapability 2c00daeb6c3b45114c80ac44119e7b8801fdd852 github.com/ugorji/go f1f1a805ed361a0e078bb537e4ea78cd37dcf065 diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/README.md b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/README.md index 78eee2267..a7ec3fc54 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/README.md +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/README.md @@ -6,3 +6,19 @@ $ make generate ``` Click [here](https://github.com/google/protobuf) for more information about protobuf. + +The `api.pb.txt` file contains merged descriptors of all defined services and messages. +Definitions present here are considered frozen after the release. + +At release time, the current `api.pb.txt` file will be moved into place to +freeze the API changes for the minor version. For example, when 1.0.0 is +released, `api.pb.txt` should be moved to `1.0.txt`. Notice that we leave off +the patch number, since the API will be completely locked down for a given +patch series. + +We may find that by default, protobuf descriptors are too noisy to lock down +API changes. In that case, we may filter out certain fields in the descriptors, +possibly regenerating for old versions. + +This process is similar to the [process used to ensure backwards compatibility +in Go](https://github.com/golang/go/tree/master/api). diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/ca.pb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/ca.pb.go index 679e4a8f9..caaa06cc8 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/ca.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/ca.pb.go @@ -1,7 +1,223 @@ // Code generated by protoc-gen-gogo. -// source: ca.proto +// source: github.com/docker/swarmkit/api/ca.proto // DO NOT EDIT! +/* + Package api is a generated protocol buffer package. + + It is generated from these files: + github.com/docker/swarmkit/api/ca.proto + github.com/docker/swarmkit/api/control.proto + github.com/docker/swarmkit/api/dispatcher.proto + github.com/docker/swarmkit/api/health.proto + github.com/docker/swarmkit/api/logbroker.proto + github.com/docker/swarmkit/api/objects.proto + github.com/docker/swarmkit/api/raft.proto + github.com/docker/swarmkit/api/resource.proto + github.com/docker/swarmkit/api/snapshot.proto + github.com/docker/swarmkit/api/specs.proto + github.com/docker/swarmkit/api/types.proto + github.com/docker/swarmkit/api/watch.proto + + It has these top-level messages: + NodeCertificateStatusRequest + NodeCertificateStatusResponse + IssueNodeCertificateRequest + IssueNodeCertificateResponse + GetRootCACertificateRequest + GetRootCACertificateResponse + GetUnlockKeyRequest + GetUnlockKeyResponse + GetNodeRequest + GetNodeResponse + ListNodesRequest + ListNodesResponse + UpdateNodeRequest + UpdateNodeResponse + RemoveNodeRequest + RemoveNodeResponse + GetTaskRequest + GetTaskResponse + RemoveTaskRequest + RemoveTaskResponse + ListTasksRequest + ListTasksResponse + CreateServiceRequest + CreateServiceResponse + GetServiceRequest + GetServiceResponse + UpdateServiceRequest + UpdateServiceResponse + RemoveServiceRequest + RemoveServiceResponse + ListServicesRequest + ListServicesResponse + CreateNetworkRequest + CreateNetworkResponse + GetNetworkRequest + GetNetworkResponse + RemoveNetworkRequest + RemoveNetworkResponse + ListNetworksRequest + ListNetworksResponse + GetClusterRequest + GetClusterResponse + ListClustersRequest + ListClustersResponse + KeyRotation + UpdateClusterRequest + UpdateClusterResponse + GetSecretRequest + GetSecretResponse + UpdateSecretRequest + UpdateSecretResponse + ListSecretsRequest + ListSecretsResponse + CreateSecretRequest + CreateSecretResponse + RemoveSecretRequest + RemoveSecretResponse + GetConfigRequest + GetConfigResponse + UpdateConfigRequest + UpdateConfigResponse + ListConfigsRequest + ListConfigsResponse + CreateConfigRequest + CreateConfigResponse + RemoveConfigRequest + RemoveConfigResponse + SessionRequest + SessionMessage + HeartbeatRequest + HeartbeatResponse + UpdateTaskStatusRequest + UpdateTaskStatusResponse + TasksRequest + TasksMessage + AssignmentsRequest + Assignment + AssignmentChange + AssignmentsMessage + HealthCheckRequest + HealthCheckResponse + LogSubscriptionOptions + LogSelector + LogContext + LogAttr + LogMessage + SubscribeLogsRequest + SubscribeLogsMessage + ListenSubscriptionsRequest + SubscriptionMessage + PublishLogsMessage + PublishLogsResponse + Meta + Node + Service + Endpoint + Task + NetworkAttachment + Network + Cluster + Secret + Config + Resource + Extension + RaftMember + JoinRequest + JoinResponse + LeaveRequest + LeaveResponse + ProcessRaftMessageRequest + ProcessRaftMessageResponse + ResolveAddressRequest + ResolveAddressResponse + InternalRaftRequest + StoreAction + AttachNetworkRequest + AttachNetworkResponse + DetachNetworkRequest + DetachNetworkResponse + StoreSnapshot + ClusterSnapshot + Snapshot + NodeSpec + ServiceSpec + ReplicatedService + GlobalService + TaskSpec + ResourceReference + GenericRuntimeSpec + NetworkAttachmentSpec + ContainerSpec + EndpointSpec + NetworkSpec + ClusterSpec + SecretSpec + ConfigSpec + Version + IndexEntry + Annotations + NamedGenericResource + DiscreteGenericResource + GenericResource + Resources + ResourceRequirements + Platform + PluginDescription + EngineDescription + NodeDescription + NodeTLSInfo + RaftMemberStatus + NodeStatus + Image + Mount + RestartPolicy + UpdateConfig + UpdateStatus + ContainerStatus + PortStatus + TaskStatus + NetworkAttachmentConfig + IPAMConfig + PortConfig + Driver + IPAMOptions + Peer + WeightedPeer + IssuanceStatus + AcceptancePolicy + ExternalCA + CAConfig + OrchestrationConfig + TaskDefaults + DispatcherConfig + RaftConfig + EncryptionConfig + SpreadOver + PlacementPreference + Placement + JoinTokens + RootCA + Certificate + EncryptionKey + ManagerStatus + FileTarget + SecretReference + ConfigReference + BlacklistedCertificate + HealthConfig + MaybeEncryptedRecord + RootRotation + Privileges + Object + SelectBySlot + SelectByCustom + SelectBy + WatchRequest + WatchMessage +*/ package api import proto "github.com/gogo/protobuf/proto" @@ -33,6 +249,12 @@ var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package + type NodeCertificateStatusRequest struct { NodeID string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` } @@ -401,7 +623,7 @@ var _CA_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "ca.proto", + Metadata: "github.com/docker/swarmkit/api/ca.proto", } // Client API for NodeCA service @@ -498,7 +720,7 @@ var _NodeCA_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "ca.proto", + Metadata: "github.com/docker/swarmkit/api/ca.proto", } func (m *NodeCertificateStatusRequest) Marshal() (dAtA []byte, err error) { @@ -2070,47 +2292,48 @@ var ( ErrIntOverflowCa = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("ca.proto", fileDescriptorCa) } +func init() { proto.RegisterFile("github.com/docker/swarmkit/api/ca.proto", fileDescriptorCa) } var fileDescriptorCa = []byte{ - // 610 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xee, 0xba, 0x25, 0x6d, 0x27, 0xa1, 0x45, 0xdb, 0x56, 0x32, 0x69, 0xea, 0x54, 0xe6, 0xd0, - 0x72, 0xc0, 0x6d, 0x03, 0x27, 0xb8, 0x90, 0x04, 0xa9, 0x8a, 0x50, 0x11, 0xda, 0x08, 0xae, 0x95, - 0xe3, 0x2c, 0xc1, 0x8a, 0xe3, 0x35, 0xde, 0x75, 0x20, 0x37, 0x24, 0x10, 0x6f, 0x80, 0xe0, 0xc4, - 0x23, 0xf0, 0x1c, 0x11, 0x27, 0x24, 0x2e, 0x9c, 0x22, 0xea, 0x07, 0xe0, 0x19, 0x90, 0xd7, 0x36, - 0xcd, 0x8f, 0x13, 0xca, 0xc9, 0xbb, 0xb3, 0xdf, 0xf7, 0xcd, 0xcc, 0xb7, 0xe3, 0x85, 0x35, 0xcb, - 0x34, 0x3c, 0x9f, 0x09, 0x86, 0x71, 0x9b, 0x59, 0x5d, 0xea, 0x1b, 0xfc, 0xb5, 0xe9, 0xf7, 0xba, - 0xb6, 0x30, 0xfa, 0x27, 0xc5, 0xbc, 0x18, 0x78, 0x94, 0xc7, 0x80, 0x62, 0x9e, 0x7b, 0xd4, 0x4a, - 0x37, 0xdb, 0x1d, 0xd6, 0x61, 0x72, 0x79, 0x14, 0xad, 0x92, 0xe8, 0x96, 0xe7, 0x04, 0x1d, 0xdb, - 0x3d, 0x8a, 0x3f, 0x71, 0x50, 0xaf, 0x43, 0xe9, 0x09, 0x6b, 0xd3, 0x3a, 0xf5, 0x85, 0xfd, 0xc2, - 0xb6, 0x4c, 0x41, 0x9b, 0xc2, 0x14, 0x01, 0x27, 0xf4, 0x55, 0x40, 0xb9, 0xc0, 0xb7, 0x60, 0xd5, - 0x65, 0x6d, 0x7a, 0x6e, 0xb7, 0x55, 0xb4, 0x8f, 0x0e, 0xd7, 0x6b, 0x10, 0x8e, 0xca, 0xb9, 0x88, - 0xd2, 0x78, 0x44, 0x72, 0xd1, 0x51, 0xa3, 0xad, 0x7f, 0x41, 0xb0, 0x37, 0x47, 0x85, 0x7b, 0xcc, - 0xe5, 0x14, 0xdf, 0x87, 0x1c, 0x97, 0x11, 0xa9, 0x92, 0xaf, 0xe8, 0xc6, 0x6c, 0x43, 0x46, 0x83, - 0xf3, 0xc0, 0x74, 0xad, 0x94, 0x9b, 0x30, 0x70, 0x15, 0xf2, 0xd6, 0xa5, 0xb0, 0xaa, 0x48, 0x81, - 0x72, 0x96, 0xc0, 0x58, 0x7e, 0x32, 0xce, 0xd1, 0x7f, 0x20, 0xd8, 0x8d, 0xd4, 0xe9, 0x54, 0x95, - 0x69, 0x97, 0xf7, 0x60, 0xc5, 0x67, 0x0e, 0x95, 0xc5, 0x6d, 0x54, 0x4a, 0x59, 0xda, 0x11, 0x93, - 0x30, 0x87, 0xd6, 0x14, 0x15, 0x11, 0x89, 0xc6, 0x37, 0x61, 0xd9, 0xe2, 0xbe, 0x2c, 0xa8, 0x50, - 0x5b, 0x0d, 0x47, 0xe5, 0xe5, 0x7a, 0x93, 0x90, 0x28, 0x86, 0xb7, 0xe1, 0x9a, 0x60, 0x5d, 0xea, - 0xaa, 0xcb, 0x91, 0x69, 0x24, 0xde, 0xe0, 0x33, 0x28, 0x98, 0x7d, 0xd3, 0x76, 0xcc, 0x96, 0xed, - 0xd8, 0x62, 0xa0, 0xae, 0xc8, 0x74, 0xb7, 0xe7, 0xa5, 0x6b, 0x7a, 0xd4, 0x32, 0xaa, 0x63, 0x04, - 0x32, 0x41, 0xd7, 0x3f, 0x22, 0x28, 0x65, 0x77, 0x95, 0xb8, 0x7e, 0x95, 0xcb, 0xc3, 0x4f, 0x61, - 0x53, 0x82, 0x7a, 0xb4, 0xd7, 0xa2, 0x3e, 0x7f, 0x69, 0x7b, 0xb2, 0xa3, 0x8d, 0xca, 0xc1, 0xc2, - 0xba, 0xce, 0xfe, 0xc2, 0xc9, 0x46, 0xc4, 0xbf, 0xdc, 0xeb, 0x7b, 0xb0, 0x7b, 0x4a, 0x05, 0x61, - 0x4c, 0xd4, 0xab, 0xb3, 0x66, 0xeb, 0x0f, 0xa1, 0x94, 0x7d, 0x9c, 0x54, 0xbd, 0x3f, 0x79, 0xdf, - 0x51, 0xe5, 0x85, 0xc9, 0xeb, 0xdc, 0x81, 0xad, 0x53, 0x2a, 0x9e, 0xb9, 0x0e, 0xb3, 0xba, 0x8f, - 0xe9, 0x20, 0x15, 0xf6, 0x61, 0x7b, 0x32, 0x9c, 0x08, 0xee, 0x01, 0x04, 0x32, 0x78, 0xde, 0xa5, - 0x83, 0x44, 0x6f, 0x3d, 0x48, 0x61, 0xf8, 0x01, 0xac, 0xf6, 0xa9, 0xcf, 0x6d, 0xe6, 0x26, 0xb3, - 0xb5, 0x9b, 0xd5, 0xf8, 0xf3, 0x18, 0x52, 0x5b, 0x19, 0x8e, 0xca, 0x4b, 0x24, 0x65, 0x54, 0xde, - 0x2b, 0xa0, 0xd4, 0xab, 0xf8, 0x1d, 0x92, 0xb9, 0x67, 0x9a, 0xc2, 0x47, 0x59, 0x5a, 0x0b, 0xdc, - 0x29, 0x1e, 0x5f, 0x9d, 0x10, 0xb7, 0xa7, 0xaf, 0x7d, 0xfb, 0xfa, 0xfb, 0xb3, 0xa2, 0xdc, 0x40, - 0xf8, 0x0d, 0x14, 0xc6, 0x0d, 0xc0, 0x07, 0x73, 0xb4, 0xa6, 0x9d, 0x2b, 0x1e, 0xfe, 0x1b, 0x98, - 0x24, 0xdb, 0x91, 0xc9, 0x36, 0xe1, 0xba, 0x44, 0xde, 0xe9, 0x99, 0xae, 0xd9, 0xa1, 0x7e, 0xe5, - 0x93, 0x02, 0x72, 0xae, 0x12, 0x2b, 0xb2, 0xa6, 0x32, 0xdb, 0x8a, 0x05, 0x7f, 0x65, 0xb6, 0x15, - 0x8b, 0x06, 0x7e, 0xcc, 0x8a, 0x0f, 0x08, 0x76, 0x32, 0x9f, 0x24, 0x7c, 0x3c, 0x6f, 0xac, 0xe7, - 0xbd, 0x81, 0xc5, 0x93, 0xff, 0x60, 0x4c, 0x17, 0x52, 0x53, 0x87, 0x17, 0xda, 0xd2, 0xcf, 0x0b, - 0x6d, 0xe9, 0x6d, 0xa8, 0xa1, 0x61, 0xa8, 0xa1, 0xef, 0xa1, 0x86, 0x7e, 0x85, 0x1a, 0x6a, 0xe5, - 0xe4, 0x0b, 0x7c, 0xf7, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x69, 0xad, 0xed, 0x8f, 0xe6, 0x05, - 0x00, 0x00, + // 638 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xc1, 0x6e, 0xd3, 0x4c, + 0x10, 0xee, 0xba, 0xfd, 0xd3, 0xbf, 0xd3, 0xd0, 0xa2, 0xa5, 0x95, 0x4c, 0x9a, 0x3a, 0x95, 0x39, + 0xb4, 0x20, 0x61, 0xb7, 0x01, 0x09, 0x09, 0x2e, 0x24, 0x41, 0xaa, 0x2a, 0x54, 0x84, 0xb6, 0x82, + 0x6b, 0xe5, 0x38, 0xdb, 0x74, 0x15, 0xc7, 0x6b, 0xbc, 0xeb, 0x42, 0x6e, 0x48, 0x20, 0xde, 0x00, + 0xc1, 0x89, 0x47, 0xe0, 0x39, 0x2a, 0x4e, 0x48, 0x5c, 0x38, 0x55, 0xd4, 0x0f, 0xc0, 0x33, 0x20, + 0xaf, 0x6d, 0x9a, 0xb4, 0x4e, 0x5a, 0x4e, 0xf1, 0xce, 0x7c, 0xdf, 0x37, 0x33, 0xdf, 0x4e, 0x16, + 0xd6, 0xbb, 0x4c, 0x1e, 0x46, 0x6d, 0xcb, 0xe5, 0x7d, 0xbb, 0xc3, 0xdd, 0x1e, 0x0d, 0x6d, 0xf1, + 0xda, 0x09, 0xfb, 0x3d, 0x26, 0x6d, 0x27, 0x60, 0xb6, 0xeb, 0x58, 0x41, 0xc8, 0x25, 0xc7, 0x38, + 0xcd, 0x5a, 0x79, 0xd6, 0x3a, 0xda, 0xaa, 0xdc, 0xb9, 0x84, 0x2c, 0x07, 0x01, 0x15, 0x29, 0xff, + 0x52, 0xac, 0x08, 0xa8, 0x9b, 0x63, 0x97, 0xba, 0xbc, 0xcb, 0xd5, 0xa7, 0x9d, 0x7c, 0x65, 0xd1, + 0x07, 0x13, 0x14, 0x14, 0xa2, 0x1d, 0x1d, 0xd8, 0x81, 0x17, 0x75, 0x99, 0x9f, 0xfd, 0xa4, 0x44, + 0xb3, 0x05, 0xd5, 0x67, 0xbc, 0x43, 0x5b, 0x34, 0x94, 0xec, 0x80, 0xb9, 0x8e, 0xa4, 0x7b, 0xd2, + 0x91, 0x91, 0x20, 0xf4, 0x55, 0x44, 0x85, 0xc4, 0xb7, 0x60, 0xd6, 0xe7, 0x1d, 0xba, 0xcf, 0x3a, + 0x3a, 0x5a, 0x43, 0x1b, 0x73, 0x4d, 0x88, 0x4f, 0x6a, 0xa5, 0x84, 0xb2, 0xf3, 0x84, 0x94, 0x92, + 0xd4, 0x4e, 0xc7, 0xfc, 0x82, 0x60, 0x75, 0x8c, 0x8a, 0x08, 0xb8, 0x2f, 0x28, 0x7e, 0x08, 0x25, + 0xa1, 0x22, 0x4a, 0x65, 0xbe, 0x6e, 0x5a, 0x17, 0x2d, 0xb3, 0x76, 0x84, 0x88, 0x1c, 0xdf, 0xcd, + 0xb9, 0x19, 0x03, 0x37, 0x60, 0xde, 0x3d, 0x13, 0xd6, 0x35, 0x25, 0x50, 0x2b, 0x12, 0x18, 0xaa, + 0x4f, 0x86, 0x39, 0xe6, 0x0f, 0x04, 0x2b, 0x89, 0x3a, 0x3d, 0xd7, 0x65, 0x3e, 0xe5, 0x7d, 0x98, + 0x09, 0xb9, 0x47, 0x55, 0x73, 0x0b, 0xf5, 0x6a, 0x91, 0x76, 0xc2, 0x24, 0xdc, 0xa3, 0x4d, 0x4d, + 0x47, 0x44, 0xa1, 0xf1, 0x4d, 0x98, 0x76, 0x45, 0xa8, 0x1a, 0x2a, 0x37, 0x67, 0xe3, 0x93, 0xda, + 0x74, 0x6b, 0x8f, 0x90, 0x24, 0x86, 0x97, 0xe0, 0x3f, 0xc9, 0x7b, 0xd4, 0xd7, 0xa7, 0x13, 0xd3, + 0x48, 0x7a, 0xc0, 0xbb, 0x50, 0x76, 0x8e, 0x1c, 0xe6, 0x39, 0x6d, 0xe6, 0x31, 0x39, 0xd0, 0x67, + 0x54, 0xb9, 0xdb, 0xe3, 0xca, 0xed, 0x05, 0xd4, 0xb5, 0x1a, 0x43, 0x04, 0x32, 0x42, 0x37, 0x3f, + 0x22, 0xa8, 0x16, 0x4f, 0x95, 0xb9, 0x7e, 0x95, 0xcb, 0xc3, 0xcf, 0x61, 0x51, 0x81, 0xfa, 0xb4, + 0xdf, 0xa6, 0xa1, 0x38, 0x64, 0x81, 0x9a, 0x68, 0xa1, 0xbe, 0x3e, 0xb1, 0xaf, 0xdd, 0xbf, 0x70, + 0xb2, 0x90, 0xf0, 0xcf, 0xce, 0xe6, 0x2a, 0xac, 0x6c, 0x53, 0x49, 0x38, 0x97, 0xad, 0xc6, 0x45, + 0xb3, 0xcd, 0xc7, 0x50, 0x2d, 0x4e, 0x67, 0x5d, 0xaf, 0x8d, 0xde, 0x77, 0xd2, 0x79, 0x79, 0xf4, + 0x3a, 0x97, 0xe1, 0xc6, 0x36, 0x95, 0x2f, 0x7c, 0x8f, 0xbb, 0xbd, 0xa7, 0x74, 0x90, 0x0b, 0x87, + 0xb0, 0x34, 0x1a, 0xce, 0x04, 0x57, 0x01, 0x22, 0x15, 0xdc, 0xef, 0xd1, 0x41, 0xa6, 0x37, 0x17, + 0xe5, 0x30, 0xfc, 0x08, 0x66, 0x8f, 0x68, 0x28, 0x18, 0xf7, 0xb3, 0xdd, 0x5a, 0x29, 0x1a, 0xfc, + 0x65, 0x0a, 0x69, 0xce, 0x1c, 0x9f, 0xd4, 0xa6, 0x48, 0xce, 0xa8, 0xbf, 0xd7, 0x40, 0x6b, 0x35, + 0xf0, 0x3b, 0xa4, 0x6a, 0x5f, 0x18, 0x0a, 0xdb, 0x45, 0x5a, 0x13, 0xdc, 0xa9, 0x6c, 0x5e, 0x9d, + 0x90, 0x8e, 0x67, 0xfe, 0xff, 0xed, 0xeb, 0xef, 0xcf, 0x9a, 0x76, 0x1d, 0xe1, 0x37, 0x50, 0x1e, + 0x36, 0x00, 0xaf, 0x8f, 0xd1, 0x3a, 0xef, 0x5c, 0x65, 0xe3, 0x72, 0x60, 0x56, 0x6c, 0x59, 0x15, + 0x5b, 0x84, 0x6b, 0x0a, 0x79, 0xb7, 0xef, 0xf8, 0x4e, 0x97, 0x86, 0xf5, 0x4f, 0x1a, 0xa8, 0xbd, + 0xca, 0xac, 0x28, 0xda, 0xca, 0x62, 0x2b, 0x26, 0xfc, 0x2b, 0x8b, 0xad, 0x98, 0xb4, 0xf0, 0x43, + 0x56, 0x7c, 0x40, 0xb0, 0x5c, 0xf8, 0x24, 0xe1, 0xcd, 0x71, 0x6b, 0x3d, 0xee, 0x0d, 0xac, 0x6c, + 0xfd, 0x03, 0xe3, 0x7c, 0x23, 0x4d, 0xfd, 0xf8, 0xd4, 0x98, 0xfa, 0x79, 0x6a, 0x4c, 0xbd, 0x8d, + 0x0d, 0x74, 0x1c, 0x1b, 0xe8, 0x7b, 0x6c, 0xa0, 0x5f, 0xb1, 0x81, 0xda, 0x25, 0xf5, 0x02, 0xdf, + 0xfb, 0x13, 0x00, 0x00, 0xff, 0xff, 0xe1, 0xda, 0xca, 0xba, 0x67, 0x06, 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/ca.proto b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/ca.proto index 84ec7d3f2..e26c8f35a 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/ca.proto +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/ca.proto @@ -2,10 +2,10 @@ syntax = "proto3"; package docker.swarmkit.v1; -import "types.proto"; -import "specs.proto"; +import "github.com/docker/swarmkit/api/types.proto"; +import "github.com/docker/swarmkit/api/specs.proto"; import "gogoproto/gogo.proto"; -import "plugin/plugin.proto"; +import "github.com/docker/swarmkit/protobuf/plugin/plugin.proto"; // CA defines the RPC methods for requesting certificates from a CA. diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/control.pb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/control.pb.go index 096228e61..13ef4822c 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/control.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/control.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. -// source: control.proto +// source: github.com/docker/swarmkit/api/control.proto // DO NOT EDIT! package api @@ -3468,7 +3468,7 @@ var _Control_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "control.proto", + Metadata: "github.com/docker/swarmkit/api/control.proto", } func (m *GetNodeRequest) Marshal() (dAtA []byte, err error) { @@ -15953,140 +15953,142 @@ var ( ErrIntOverflowControl = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("control.proto", fileDescriptorControl) } +func init() { proto.RegisterFile("github.com/docker/swarmkit/api/control.proto", fileDescriptorControl) } var fileDescriptorControl = []byte{ - // 2106 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0xcd, 0x73, 0x1b, 0x49, - 0x15, 0xb7, 0x3e, 0x6c, 0xc9, 0x4f, 0xb6, 0x6c, 0xb7, 0x1d, 0x50, 0x29, 0xc1, 0x4e, 0x4d, 0x48, - 0xa2, 0x50, 0x41, 0x66, 0x15, 0x16, 0xc2, 0x52, 0x7c, 0xac, 0xed, 0x6c, 0x56, 0xeb, 0x8d, 0x93, - 0x1a, 0xc7, 0x5b, 0xdc, 0x54, 0xb2, 0xd4, 0x36, 0x13, 0xc9, 0x1a, 0x31, 0x33, 0xf2, 0xae, 0x8b, - 0x0b, 0x50, 0xcb, 0x81, 0x3f, 0x80, 0x2a, 0xae, 0x5c, 0x39, 0x70, 0xe0, 0xc4, 0x81, 0x3f, 0x20, - 0xc5, 0x89, 0x23, 0x27, 0xc3, 0xaa, 0x0a, 0x8a, 0x13, 0x7f, 0xc3, 0x56, 0x77, 0xbf, 0x9e, 0x2f, - 0xf5, 0xcc, 0xe8, 0xab, 0xca, 0x7b, 0xb2, 0xa6, 0xe7, 0xf7, 0xfa, 0xbd, 0xee, 0xf7, 0xeb, 0xdf, - 0x74, 0xbf, 0x36, 0xac, 0xb6, 0xcc, 0x9e, 0x63, 0x99, 0xdd, 0x6a, 0xdf, 0x32, 0x1d, 0x93, 0x90, - 0xb6, 0xd9, 0xea, 0x50, 0xab, 0x6a, 0x7f, 0xda, 0xb4, 0x2e, 0x3a, 0x86, 0x53, 0xbd, 0x7c, 0xa7, - 0x5c, 0xb0, 0xfb, 0xb4, 0x65, 0x0b, 0x40, 0x79, 0xd5, 0x3c, 0x7d, 0x43, 0x5b, 0x8e, 0x7c, 0x2c, - 0x38, 0x57, 0x7d, 0x2a, 0x1f, 0xb6, 0xce, 0xcd, 0x73, 0x93, 0xff, 0xdc, 0x65, 0xbf, 0xb0, 0x75, - 0xb3, 0xdf, 0x1d, 0x9c, 0x1b, 0xbd, 0x5d, 0xf1, 0x47, 0x34, 0x6a, 0xef, 0x42, 0xf1, 0x39, 0x75, - 0x8e, 0xcc, 0x36, 0xd5, 0xe9, 0x2f, 0x06, 0xd4, 0x76, 0xc8, 0x3d, 0xc8, 0xf5, 0xcc, 0x36, 0x6d, - 0x18, 0xed, 0x52, 0xea, 0x6e, 0xaa, 0xb2, 0xbc, 0x07, 0xc3, 0xeb, 0x9d, 0x25, 0x86, 0xa8, 0x1f, - 0xe8, 0x4b, 0xec, 0x55, 0xbd, 0xad, 0xfd, 0x04, 0xd6, 0x5c, 0x33, 0xbb, 0x6f, 0xf6, 0x6c, 0x4a, - 0x1e, 0x43, 0x96, 0xbd, 0xe4, 0x46, 0x85, 0x5a, 0xa9, 0x3a, 0x3a, 0x80, 0x2a, 0xc7, 0x73, 0x94, - 0xf6, 0xdf, 0x0c, 0xac, 0x7f, 0x6c, 0xd8, 0xbc, 0x0b, 0x5b, 0xba, 0xfe, 0x00, 0x72, 0x67, 0x46, - 0xd7, 0xa1, 0x96, 0x8d, 0xbd, 0x3c, 0x56, 0xf5, 0x12, 0x36, 0xab, 0x7e, 0x20, 0x6c, 0x74, 0x69, - 0x5c, 0xfe, 0x5d, 0x06, 0x72, 0xd8, 0x48, 0xb6, 0x60, 0xb1, 0xd7, 0xbc, 0xa0, 0xac, 0xc7, 0x4c, - 0x65, 0x59, 0x17, 0x0f, 0x64, 0x17, 0x0a, 0x46, 0xbb, 0xd1, 0xb7, 0xe8, 0x99, 0xf1, 0x19, 0xb5, - 0x4b, 0x69, 0xf6, 0x6e, 0xaf, 0x38, 0xbc, 0xde, 0x81, 0xfa, 0xc1, 0x2b, 0x6c, 0xd5, 0xc1, 0x68, - 0xcb, 0xdf, 0xe4, 0x15, 0x2c, 0x75, 0x9b, 0xa7, 0xb4, 0x6b, 0x97, 0x32, 0x77, 0x33, 0x95, 0x42, - 0xed, 0xe9, 0x24, 0x91, 0x55, 0x3f, 0xe6, 0xa6, 0xcf, 0x7a, 0x8e, 0x75, 0xa5, 0x63, 0x3f, 0xe4, - 0x05, 0x14, 0x2e, 0xe8, 0xc5, 0x29, 0xb5, 0xec, 0x9f, 0x1b, 0x7d, 0xbb, 0x94, 0xbd, 0x9b, 0xa9, - 0x14, 0x6b, 0x0f, 0xa3, 0xa6, 0xed, 0xb8, 0x4f, 0x5b, 0xd5, 0x17, 0x2e, 0x7e, 0x2f, 0xbd, 0xbe, - 0xa0, 0xfb, 0xed, 0xc9, 0xf7, 0x60, 0xd1, 0x32, 0xbb, 0xd4, 0x2e, 0x2d, 0xf2, 0x8e, 0xee, 0x44, - 0xce, 0xbf, 0xd9, 0xa5, 0xdc, 0x5a, 0xc0, 0xc9, 0x3d, 0x58, 0x65, 0x53, 0xe2, 0xcd, 0xc5, 0x12, - 0x9f, 0xa7, 0x15, 0xd6, 0x28, 0x47, 0x5f, 0xfe, 0x01, 0x14, 0x7c, 0x43, 0x20, 0xeb, 0x90, 0xe9, - 0xd0, 0x2b, 0x41, 0x0f, 0x9d, 0xfd, 0x64, 0xb3, 0x7c, 0xd9, 0xec, 0x0e, 0x68, 0x29, 0xcd, 0xdb, - 0xc4, 0xc3, 0x7b, 0xe9, 0xa7, 0x29, 0x6d, 0x1f, 0x36, 0x7c, 0xd3, 0x82, 0x5c, 0xa9, 0xc2, 0x22, - 0x63, 0x81, 0x48, 0x4a, 0x1c, 0x59, 0x04, 0x4c, 0xfb, 0x53, 0x0a, 0x36, 0x4e, 0xfa, 0xed, 0xa6, - 0x43, 0x27, 0x65, 0x2a, 0xf9, 0x31, 0xac, 0x70, 0xd0, 0x25, 0xb5, 0x6c, 0xc3, 0xec, 0xf1, 0x00, - 0x0b, 0xb5, 0xdb, 0x2a, 0x8f, 0x9f, 0x08, 0x88, 0x5e, 0x60, 0x06, 0xf8, 0x40, 0xbe, 0x03, 0x59, - 0xb6, 0xec, 0x4a, 0x19, 0x6e, 0x77, 0x27, 0x2e, 0x3f, 0x3a, 0x47, 0x6a, 0x7b, 0x40, 0xfc, 0xb1, - 0x4e, 0xb5, 0x3c, 0x8e, 0x60, 0x43, 0xa7, 0x17, 0xe6, 0xe5, 0xe4, 0xe3, 0xdd, 0x82, 0xc5, 0x33, - 0xd3, 0x6a, 0x89, 0x4c, 0xe4, 0x75, 0xf1, 0xa0, 0x6d, 0x01, 0xf1, 0xf7, 0x27, 0x62, 0xc2, 0xc5, - 0xff, 0xba, 0x69, 0x77, 0x7c, 0x2e, 0x9c, 0xa6, 0xdd, 0x09, 0xb9, 0x60, 0x08, 0xe6, 0x82, 0xbd, - 0x72, 0x17, 0xbf, 0x30, 0xf3, 0x46, 0xc7, 0x5e, 0xc6, 0x8d, 0x8e, 0xe3, 0x39, 0x4a, 0x7b, 0x2a, - 0x47, 0x37, 0xb1, 0x6b, 0x77, 0x1c, 0x7e, 0xef, 0xda, 0xdf, 0xb2, 0x42, 0x4c, 0x58, 0xe3, 0x14, - 0x62, 0xe2, 0x37, 0x1b, 0x15, 0x93, 0x7f, 0xdd, 0xa0, 0x98, 0xa8, 0x22, 0x53, 0x8a, 0xc9, 0x2e, - 0x14, 0x6c, 0x6a, 0x5d, 0x1a, 0x2d, 0xc6, 0x0e, 0x21, 0x26, 0x18, 0xc2, 0xb1, 0x68, 0xae, 0x1f, - 0xd8, 0x3a, 0x20, 0xa4, 0xde, 0xb6, 0xc9, 0x03, 0xc8, 0x23, 0x97, 0x84, 0x62, 0x2c, 0xef, 0x15, - 0x86, 0xd7, 0x3b, 0x39, 0x41, 0x26, 0x5b, 0xcf, 0x09, 0x36, 0xd9, 0xe4, 0x43, 0x28, 0xb6, 0xa9, - 0x6d, 0x58, 0xb4, 0xdd, 0xb0, 0x9d, 0xa6, 0x83, 0xfa, 0x50, 0xac, 0x7d, 0x23, 0x2a, 0xc5, 0xc7, - 0x0c, 0xc5, 0x05, 0x66, 0x15, 0x0d, 0x79, 0x8b, 0x42, 0x68, 0x72, 0xa3, 0x42, 0x43, 0xee, 0x00, - 0x0c, 0xfa, 0x0d, 0xc7, 0x6c, 0xb0, 0xf5, 0x53, 0xca, 0x73, 0x0a, 0xe7, 0x07, 0xfd, 0xd7, 0xe6, - 0x41, 0xd3, 0xa1, 0xa4, 0x0c, 0x79, 0x6b, 0xd0, 0x73, 0x0c, 0x96, 0x81, 0x65, 0x6e, 0xed, 0x3e, - 0xcf, 0x41, 0xa2, 0x70, 0xb2, 0x3d, 0x89, 0x62, 0x9c, 0x8b, 0x95, 0x28, 0x4e, 0x42, 0x01, 0xd3, - 0x0e, 0x61, 0x6b, 0xdf, 0xa2, 0x4d, 0x87, 0xe2, 0x84, 0x4b, 0x1a, 0x3e, 0x41, 0xfd, 0x10, 0x1c, - 0xdc, 0x51, 0x75, 0x83, 0x16, 0x3e, 0x09, 0x39, 0x82, 0x5b, 0xa1, 0xce, 0x30, 0xaa, 0x77, 0x21, - 0x87, 0x49, 0xc4, 0x0e, 0x6f, 0xc7, 0x74, 0xa8, 0x4b, 0xac, 0xf6, 0x06, 0x36, 0x9e, 0x53, 0x27, - 0x14, 0xd9, 0x63, 0x00, 0x8f, 0x33, 0xb8, 0xe6, 0x56, 0x87, 0xd7, 0x3b, 0xcb, 0x2e, 0x65, 0xf4, - 0x65, 0x97, 0x31, 0xe4, 0x21, 0xac, 0x19, 0x3d, 0x9b, 0x5a, 0x4e, 0xa3, 0x4d, 0xcf, 0x9a, 0x83, - 0xae, 0x63, 0xa3, 0xc2, 0x14, 0x45, 0xf3, 0x01, 0xb6, 0x6a, 0x87, 0x40, 0xfc, 0xbe, 0x66, 0x0b, - 0xfc, 0x2f, 0x69, 0xd8, 0x12, 0x62, 0x3a, 0x53, 0xf0, 0x07, 0xb0, 0x26, 0xd1, 0x13, 0x7c, 0x07, - 0x8a, 0x68, 0x23, 0x3f, 0x05, 0x4f, 0x02, 0x9f, 0x82, 0xf1, 0x52, 0x49, 0x5e, 0x40, 0xde, 0x32, - 0xbb, 0xdd, 0xd3, 0x66, 0xab, 0x53, 0xca, 0xde, 0x4d, 0x55, 0x8a, 0xb5, 0x77, 0x54, 0x86, 0xaa, - 0x41, 0x56, 0x75, 0x34, 0xd4, 0xdd, 0x2e, 0x34, 0x0d, 0xf2, 0xb2, 0x95, 0xe4, 0x21, 0x7b, 0xf4, - 0xf2, 0xe8, 0xd9, 0xfa, 0x02, 0x59, 0x81, 0xfc, 0x2b, 0xfd, 0xd9, 0x27, 0xf5, 0x97, 0x27, 0xc7, - 0xeb, 0x29, 0xc6, 0x9e, 0x50, 0x77, 0xb3, 0x25, 0xe1, 0x00, 0xb6, 0x84, 0xe8, 0xce, 0x92, 0x03, - 0xed, 0xeb, 0x70, 0x2b, 0xd4, 0x0b, 0xaa, 0xf7, 0xe7, 0x19, 0xd8, 0x64, 0xeb, 0x0f, 0xdb, 0x5d, - 0x01, 0xaf, 0x87, 0x05, 0x7c, 0x37, 0x4a, 0x26, 0x43, 0x96, 0xa3, 0x1a, 0xfe, 0xc7, 0xf4, 0xdc, - 0x35, 0xfc, 0x38, 0xa4, 0xe1, 0x3f, 0x9c, 0x30, 0x38, 0xa5, 0x8c, 0x8f, 0x68, 0x64, 0x56, 0xa1, - 0x91, 0x7e, 0x15, 0x5c, 0x9c, 0x9f, 0x0a, 0xbe, 0x84, 0xad, 0x60, 0xb8, 0x48, 0x9a, 0xef, 0x43, - 0x1e, 0x93, 0x28, 0xb5, 0x30, 0x96, 0x35, 0x2e, 0xd8, 0x53, 0xc4, 0x23, 0xea, 0x7c, 0x6a, 0x5a, - 0x9d, 0x09, 0x14, 0x11, 0x2d, 0x54, 0x8a, 0xe8, 0x76, 0xe6, 0x71, 0xba, 0x27, 0x9a, 0xe2, 0x38, - 0x2d, 0xad, 0x24, 0x56, 0x3b, 0xe1, 0x8a, 0x18, 0x8a, 0x8c, 0x40, 0x96, 0xcd, 0x34, 0xce, 0x17, - 0xff, 0xcd, 0x48, 0x8e, 0x36, 0x8c, 0xe4, 0x69, 0x8f, 0xe4, 0x68, 0xcb, 0x48, 0x8e, 0x80, 0x7a, - 0x1b, 0xc5, 0x6f, 0x4e, 0x31, 0xfe, 0x4c, 0xae, 0xbb, 0xb9, 0x87, 0xe9, 0xae, 0xc5, 0x50, 0xa4, - 0xda, 0xff, 0xd2, 0x62, 0x2d, 0x62, 0xfb, 0x14, 0x6b, 0x31, 0x64, 0x39, 0xba, 0x16, 0x7f, 0x7b, - 0x83, 0x6b, 0x31, 0x22, 0xb8, 0xa9, 0xd7, 0xe2, 0x1c, 0xd6, 0x9b, 0x17, 0x92, 0xb7, 0xde, 0x30, - 0x51, 0xb1, 0xeb, 0x4d, 0x66, 0xce, 0x05, 0x6b, 0xef, 0x73, 0x4a, 0xef, 0x77, 0x07, 0xb6, 0x43, - 0x2d, 0x9f, 0x46, 0xb7, 0x44, 0x4b, 0x48, 0xa3, 0x11, 0xc7, 0x78, 0x81, 0x00, 0x97, 0xbe, 0x6e, - 0x17, 0x1e, 0x7d, 0x11, 0x12, 0x47, 0x5f, 0x69, 0x25, 0xb1, 0x2e, 0x97, 0xf0, 0xc5, 0x14, 0x5c, - 0x0a, 0x59, 0x7e, 0xb5, 0xb8, 0x14, 0x11, 0xdc, 0x4d, 0x72, 0xc9, 0x0b, 0xc9, 0xe3, 0x12, 0x66, - 0x23, 0x96, 0x4b, 0x32, 0x75, 0x2e, 0x58, 0xfb, 0x7d, 0x0a, 0x0a, 0x87, 0xf4, 0x4a, 0x37, 0x9d, - 0xa6, 0xc3, 0xb6, 0x3e, 0xdf, 0x82, 0x0d, 0x46, 0x32, 0x6a, 0x35, 0xde, 0x98, 0x46, 0xaf, 0xe1, - 0x98, 0x1d, 0xda, 0xe3, 0xa1, 0xe5, 0xf5, 0x35, 0xf1, 0xe2, 0x23, 0xd3, 0xe8, 0xbd, 0x66, 0xcd, - 0xe4, 0x31, 0x90, 0x8b, 0x66, 0xaf, 0x79, 0x1e, 0x04, 0x8b, 0xcd, 0xe2, 0x3a, 0xbe, 0x51, 0xa2, - 0x07, 0xbd, 0xae, 0xd9, 0xea, 0x34, 0xd8, 0xa8, 0x33, 0x01, 0xf4, 0x09, 0x7f, 0x71, 0x48, 0xaf, - 0xb4, 0xdf, 0xb8, 0xfb, 0xc1, 0x59, 0x78, 0xce, 0xf6, 0x83, 0x12, 0x3d, 0xc9, 0x7e, 0x10, 0x6d, - 0x26, 0xd8, 0x0f, 0xa2, 0x77, 0xdf, 0x7e, 0xf0, 0x7d, 0xb6, 0x1f, 0x14, 0xb3, 0xca, 0xf7, 0x83, - 0x11, 0x86, 0xbe, 0xc9, 0xdf, 0xcb, 0xbe, 0xbd, 0xde, 0x59, 0xd0, 0x5d, 0x33, 0x6f, 0x7f, 0x37, - 0xa7, 0x85, 0xfa, 0x23, 0x58, 0xe7, 0x3b, 0xf6, 0x96, 0x45, 0x1d, 0x39, 0x9f, 0x8f, 0x60, 0xd9, - 0xe6, 0x0d, 0xde, 0x74, 0xae, 0x0c, 0xaf, 0x77, 0xf2, 0x02, 0x55, 0x3f, 0x60, 0xdf, 0x79, 0xfe, - 0xab, 0xad, 0x3d, 0xc7, 0xc3, 0x85, 0x30, 0xc7, 0x50, 0x6a, 0xb0, 0x24, 0x00, 0x18, 0x49, 0x59, - 0xbd, 0x67, 0xe0, 0x36, 0x88, 0xd4, 0xfe, 0x9a, 0x82, 0x4d, 0xb9, 0x71, 0x9d, 0x2e, 0x16, 0xb2, - 0x07, 0x45, 0x84, 0x4e, 0x90, 0xd7, 0x55, 0x61, 0x22, 0xd3, 0x5a, 0x0b, 0xa4, 0x75, 0x3b, 0x3a, - 0x70, 0xdf, 0xf6, 0xe4, 0x23, 0xef, 0x98, 0x32, 0xf3, 0x34, 0xfc, 0x27, 0x0d, 0x44, 0xec, 0xc4, - 0xd8, 0xa3, 0x2b, 0x9b, 0x1f, 0x86, 0x65, 0xb3, 0x1a, 0xbd, 0xe3, 0xf4, 0x1b, 0x8e, 0xaa, 0xe6, - 0xe7, 0xf3, 0x57, 0x4d, 0x3d, 0xa4, 0x9a, 0xef, 0x4d, 0x16, 0xdb, 0x8d, 0x88, 0xe6, 0xa1, 0x3c, - 0x76, 0x60, 0x44, 0x98, 0xb2, 0xef, 0xb2, 0x43, 0x12, 0x6f, 0x42, 0xc9, 0x8c, 0xcb, 0x99, 0x84, - 0x6a, 0x75, 0xd8, 0x94, 0x27, 0x76, 0x3f, 0x75, 0x6b, 0x81, 0xbd, 0xee, 0xd8, 0x5c, 0x0a, 0x76, - 0x35, 0x03, 0x97, 0x7e, 0x0a, 0x9b, 0xf2, 0xd0, 0x35, 0xe5, 0xea, 0xfe, 0x9a, 0x77, 0xf8, 0xf3, - 0x47, 0x83, 0xa2, 0xb1, 0x6f, 0xf6, 0xce, 0x8c, 0x73, 0x5f, 0xb7, 0x2d, 0xde, 0x10, 0xea, 0x56, - 0xa0, 0x58, 0xb7, 0xe2, 0xb5, 0x2b, 0x1a, 0xd2, 0xdc, 0x1b, 0xa1, 0x00, 0xc4, 0x8d, 0x10, 0x6d, - 0x10, 0xe9, 0x13, 0x8d, 0x69, 0x63, 0x61, 0xa2, 0x81, 0xd0, 0x49, 0x44, 0x43, 0x98, 0x4c, 0x20, - 0x1a, 0xc2, 0xb3, 0x4a, 0x34, 0xe6, 0x30, 0x0d, 0x52, 0x34, 0x44, 0xf3, 0x14, 0xa2, 0x11, 0x34, - 0xfc, 0x6a, 0x89, 0x86, 0x3a, 0xb6, 0x9b, 0x14, 0x0d, 0x37, 0x22, 0x4f, 0x34, 0x44, 0x22, 0x62, - 0x45, 0x03, 0x73, 0x26, 0xa1, 0x9e, 0x68, 0x04, 0xa9, 0x3b, 0x86, 0x68, 0xa8, 0xb8, 0x14, 0xec, - 0x6a, 0x06, 0x2e, 0xb9, 0xa2, 0x31, 0xf5, 0xea, 0x76, 0x45, 0x23, 0x18, 0x4d, 0xed, 0xd7, 0xb7, - 0x21, 0xb7, 0x2f, 0xee, 0x39, 0x89, 0x01, 0x39, 0xbc, 0x42, 0x24, 0x9a, 0x2a, 0xa8, 0xe0, 0xb5, - 0x64, 0xf9, 0x5e, 0x2c, 0x06, 0x45, 0xe9, 0xd6, 0xdf, 0xff, 0xfc, 0xff, 0x3f, 0xa4, 0xd7, 0x60, - 0x95, 0x83, 0xbe, 0x8d, 0xdb, 0x47, 0x62, 0xc2, 0xb2, 0x7b, 0x07, 0x45, 0xbe, 0x39, 0xce, 0xcd, - 0x5d, 0xf9, 0x7e, 0x02, 0x2a, 0xde, 0xa1, 0x05, 0xe0, 0x5d, 0x01, 0x91, 0xfb, 0xd1, 0x05, 0x3f, - 0xff, 0x08, 0x1f, 0x24, 0xc1, 0x12, 0x7d, 0x7a, 0x57, 0x3c, 0x6a, 0x9f, 0x23, 0x57, 0x4a, 0x6a, - 0x9f, 0x8a, 0x9b, 0xa2, 0x08, 0x9f, 0x22, 0x87, 0xaf, 0x9b, 0x76, 0x27, 0x32, 0x87, 0xbe, 0x2b, - 0x9e, 0xc8, 0x1c, 0x06, 0x2e, 0x73, 0xe2, 0x73, 0xc8, 0x8b, 0xf4, 0xd1, 0x39, 0xf4, 0x5f, 0x98, - 0x44, 0xe7, 0x30, 0x50, 0xe9, 0x4f, 0x9c, 0x4f, 0x3e, 0xbc, 0x98, 0xf9, 0xf4, 0x8f, 0xf0, 0x41, - 0x12, 0x2c, 0xd1, 0xa7, 0x57, 0x3b, 0x57, 0xfb, 0x1c, 0xa9, 0xe3, 0xab, 0x7d, 0x8e, 0x96, 0xe0, - 0xa3, 0x7c, 0x7e, 0x06, 0x2b, 0xfe, 0xba, 0x1f, 0x79, 0x38, 0x66, 0x21, 0xb3, 0x5c, 0x49, 0x06, - 0xc6, 0x7b, 0xfe, 0x25, 0xac, 0x06, 0x6e, 0x39, 0x88, 0xb2, 0x47, 0xd5, 0xad, 0x4a, 0xf9, 0xd1, - 0x18, 0xc8, 0x44, 0xe7, 0x81, 0x22, 0xb9, 0xda, 0xb9, 0xaa, 0x2c, 0xaf, 0x76, 0xae, 0xac, 0xb8, - 0xc7, 0x38, 0x0f, 0xd4, 0xc2, 0xd5, 0xce, 0x55, 0x45, 0x77, 0xb5, 0x73, 0x75, 0x61, 0x3d, 0x96, - 0x64, 0x58, 0x3f, 0x8a, 0x24, 0x59, 0xb0, 0xe6, 0x18, 0x49, 0xb2, 0x70, 0x01, 0x31, 0x9e, 0x64, - 0xb2, 0xd8, 0x15, 0x4d, 0xb2, 0x50, 0x85, 0x2e, 0x9a, 0x64, 0xe1, 0xba, 0x59, 0x22, 0xc9, 0xe4, - 0x80, 0x63, 0x48, 0x16, 0x1a, 0xf3, 0xa3, 0x31, 0x90, 0x63, 0xe6, 0x39, 0xd6, 0xb9, 0xaa, 0xc8, - 0x1b, 0x97, 0xe7, 0x31, 0x9d, 0x8b, 0x3c, 0xe3, 0x69, 0x3f, 0x32, 0xcf, 0xc1, 0x3a, 0x4a, 0x64, - 0x9e, 0x43, 0xa5, 0x86, 0x84, 0x3c, 0xcb, 0x42, 0x54, 0x74, 0x9e, 0x43, 0xd5, 0xb3, 0xe8, 0x3c, - 0x87, 0x6b, 0x5a, 0x89, 0xeb, 0x59, 0x0e, 0x38, 0x66, 0x3d, 0x87, 0xc6, 0xfc, 0x68, 0x0c, 0x64, - 0xe2, 0xc7, 0xc9, 0x2d, 0x81, 0xa8, 0x3f, 0x4e, 0xe1, 0x02, 0x4b, 0xf9, 0x7e, 0x02, 0x2a, 0x71, - 0x9e, 0xfd, 0xf5, 0x06, 0xf5, 0x3c, 0x2b, 0x6a, 0x29, 0xe5, 0x4a, 0x32, 0x30, 0xde, 0xf3, 0x00, - 0x0a, 0xbe, 0x53, 0x33, 0x79, 0x30, 0xde, 0x41, 0xbf, 0xfc, 0x30, 0x11, 0x97, 0x38, 0x60, 0xff, - 0xa1, 0x58, 0x3d, 0x60, 0xc5, 0x09, 0xbc, 0x5c, 0x49, 0x06, 0x26, 0x7a, 0xf6, 0x1f, 0x80, 0xd5, - 0x9e, 0x15, 0x87, 0xec, 0x72, 0x25, 0x19, 0x38, 0x0e, 0xab, 0xc4, 0x16, 0x3a, 0x92, 0x55, 0x81, - 0x3d, 0x7a, 0x24, 0xab, 0x82, 0xfb, 0xf0, 0x44, 0x56, 0xa1, 0xcf, 0x18, 0x56, 0x05, 0xdd, 0x56, - 0x92, 0x81, 0x63, 0xb1, 0x0a, 0x8f, 0x55, 0xd1, 0xac, 0x0a, 0x9e, 0x04, 0xa3, 0x59, 0x15, 0x3a, - 0x9f, 0x25, 0xb2, 0x2a, 0x6e, 0xc0, 0x8a, 0x23, 0x5a, 0x1c, 0xab, 0xc6, 0x9e, 0x6a, 0xff, 0x09, - 0x29, 0x8e, 0x55, 0x63, 0x78, 0x56, 0x1d, 0xb6, 0x22, 0x3c, 0xef, 0x95, 0xde, 0x7e, 0xb1, 0xbd, - 0xf0, 0xcf, 0x2f, 0xb6, 0x17, 0x7e, 0x35, 0xdc, 0x4e, 0xbd, 0x1d, 0x6e, 0xa7, 0xfe, 0x31, 0xdc, - 0x4e, 0xfd, 0x7b, 0xb8, 0x9d, 0x3a, 0x5d, 0xe2, 0xff, 0x12, 0xfa, 0xe4, 0xcb, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x69, 0xfa, 0x48, 0xde, 0x8b, 0x2a, 0x00, 0x00, + // 2137 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4f, 0x73, 0x1b, 0x49, + 0x15, 0xb7, 0xfe, 0xd8, 0x92, 0x9f, 0x6c, 0xd9, 0xee, 0x38, 0xa0, 0x52, 0x82, 0x9d, 0x9a, 0x90, + 0x44, 0xd9, 0x32, 0x12, 0xab, 0xb0, 0x6c, 0x58, 0x8a, 0x3f, 0x6b, 0x3b, 0x9b, 0xd5, 0x7a, 0xe3, + 0xa4, 0xc6, 0xc9, 0x16, 0x37, 0x95, 0x2c, 0xb5, 0xbd, 0x13, 0xc9, 0x1a, 0x31, 0x33, 0xf2, 0xae, + 0x8b, 0x0b, 0x50, 0xcb, 0x81, 0x0f, 0x40, 0x15, 0x57, 0xae, 0x1c, 0x38, 0x70, 0xe2, 0xc0, 0x07, + 0x48, 0x71, 0xe2, 0xc8, 0xc9, 0xb0, 0xaa, 0x82, 0xe2, 0xc4, 0x67, 0xa0, 0xba, 0xfb, 0xf5, 0xfc, + 0x53, 0xcf, 0x8c, 0x24, 0xab, 0xca, 0x39, 0x59, 0xd3, 0xf3, 0x7b, 0xfd, 0x5e, 0xf7, 0xfb, 0xf5, + 0x6f, 0xba, 0x5f, 0x1b, 0x76, 0x4e, 0x0d, 0xe7, 0xf3, 0xe1, 0x71, 0xb5, 0x6d, 0x9e, 0xd5, 0x3a, + 0x66, 0xbb, 0x4b, 0xad, 0x9a, 0xfd, 0x45, 0xcb, 0x3a, 0xeb, 0x1a, 0x4e, 0xad, 0x35, 0x30, 0x6a, + 0x6d, 0xb3, 0xef, 0x58, 0x66, 0xaf, 0x3a, 0xb0, 0x4c, 0xc7, 0x24, 0x44, 0x40, 0xaa, 0x12, 0x52, + 0x3d, 0x7f, 0xb7, 0xfc, 0x4e, 0x42, 0x0f, 0xf6, 0x80, 0xb6, 0x6d, 0x61, 0x5f, 0x4e, 0xf2, 0x66, + 0x1e, 0xbf, 0xa6, 0x6d, 0x47, 0xa2, 0x93, 0x7a, 0x76, 0x2e, 0x06, 0x54, 0x62, 0x37, 0x4f, 0xcd, + 0x53, 0x93, 0xff, 0xac, 0xb1, 0x5f, 0xd8, 0xfa, 0x7e, 0x4c, 0x0f, 0x1c, 0x71, 0x3c, 0x3c, 0xa9, + 0x0d, 0x7a, 0xc3, 0x53, 0xa3, 0x8f, 0x7f, 0x84, 0xa1, 0xf6, 0x1e, 0x14, 0x9f, 0x52, 0xe7, 0xd0, + 0xec, 0x50, 0x9d, 0xfe, 0x7c, 0x48, 0x6d, 0x87, 0xdc, 0x85, 0x5c, 0xdf, 0xec, 0xd0, 0xa6, 0xd1, + 0x29, 0xa5, 0xee, 0xa4, 0x2a, 0xcb, 0xbb, 0x30, 0xba, 0xdc, 0x5e, 0x62, 0x88, 0xc6, 0xbe, 0xbe, + 0xc4, 0x5e, 0x35, 0x3a, 0xda, 0x4f, 0x60, 0xcd, 0x35, 0xb3, 0x07, 0x66, 0xdf, 0xa6, 0x64, 0x07, + 0xb2, 0xec, 0x25, 0x37, 0x2a, 0xd4, 0x4b, 0xd5, 0xf1, 0x19, 0xac, 0x72, 0x3c, 0x47, 0x69, 0xff, + 0xc9, 0xc0, 0xfa, 0xa7, 0x86, 0xcd, 0xbb, 0xb0, 0xa5, 0xeb, 0x8f, 0x20, 0x77, 0x62, 0xf4, 0x1c, + 0x6a, 0xd9, 0xd8, 0xcb, 0x8e, 0xaa, 0x97, 0xb0, 0x59, 0xf5, 0x23, 0x61, 0xa3, 0x4b, 0xe3, 0xf2, + 0x6f, 0x33, 0x90, 0xc3, 0x46, 0xb2, 0x09, 0x8b, 0xfd, 0xd6, 0x19, 0x65, 0x3d, 0x66, 0x2a, 0xcb, + 0xba, 0x78, 0x20, 0x35, 0x28, 0x18, 0x9d, 0xe6, 0xc0, 0xa2, 0x27, 0xc6, 0x97, 0xd4, 0x2e, 0xa5, + 0xd9, 0xbb, 0xdd, 0xe2, 0xe8, 0x72, 0x1b, 0x1a, 0xfb, 0x2f, 0xb0, 0x55, 0x07, 0xa3, 0x23, 0x7f, + 0x93, 0x17, 0xb0, 0xd4, 0x6b, 0x1d, 0xd3, 0x9e, 0x5d, 0xca, 0xdc, 0xc9, 0x54, 0x0a, 0xf5, 0xc7, + 0xd3, 0x44, 0x56, 0xfd, 0x94, 0x9b, 0x3e, 0xe9, 0x3b, 0xd6, 0x85, 0x8e, 0xfd, 0x90, 0x67, 0x50, + 0x38, 0xa3, 0x67, 0xc7, 0xd4, 0xb2, 0x3f, 0x37, 0x06, 0x76, 0x29, 0x7b, 0x27, 0x53, 0x29, 0xd6, + 0x1f, 0x44, 0x4d, 0xdb, 0xd1, 0x80, 0xb6, 0xab, 0xcf, 0x5c, 0xfc, 0x6e, 0x7a, 0x7d, 0x41, 0xf7, + 0xdb, 0x93, 0xef, 0xc3, 0xa2, 0x65, 0xf6, 0xa8, 0x5d, 0x5a, 0xe4, 0x1d, 0xdd, 0x8e, 0x9c, 0x7f, + 0xb3, 0x47, 0xb9, 0xb5, 0x80, 0x93, 0xbb, 0xb0, 0xca, 0xa6, 0xc4, 0x9b, 0x8b, 0x25, 0x3e, 0x4f, + 0x2b, 0xac, 0x51, 0x8e, 0xbe, 0xfc, 0x03, 0x28, 0xf8, 0x86, 0x40, 0xd6, 0x21, 0xd3, 0xa5, 0x17, + 0x82, 0x1e, 0x3a, 0xfb, 0xc9, 0x66, 0xf9, 0xbc, 0xd5, 0x1b, 0xd2, 0x52, 0x9a, 0xb7, 0x89, 0x87, + 0x0f, 0xd2, 0x8f, 0x53, 0xda, 0x1e, 0x6c, 0xf8, 0xa6, 0x05, 0xb9, 0x52, 0x85, 0x45, 0xc6, 0x02, + 0x91, 0x94, 0x38, 0xb2, 0x08, 0x98, 0xf6, 0xc7, 0x14, 0x6c, 0xbc, 0x1a, 0x74, 0x5a, 0x0e, 0x9d, + 0x96, 0xa9, 0xe4, 0xc7, 0xb0, 0xc2, 0x41, 0xe7, 0xd4, 0xb2, 0x0d, 0xb3, 0xcf, 0x03, 0x2c, 0xd4, + 0x6f, 0xa9, 0x3c, 0x7e, 0x26, 0x20, 0x7a, 0x81, 0x19, 0xe0, 0x03, 0xf9, 0x2e, 0x64, 0xd9, 0xc2, + 0x2e, 0x65, 0xb8, 0xdd, 0xed, 0xb8, 0xfc, 0xe8, 0x1c, 0xa9, 0xed, 0x02, 0xf1, 0xc7, 0x3a, 0xd3, + 0xf2, 0x38, 0x84, 0x0d, 0x9d, 0x9e, 0x99, 0xe7, 0xd3, 0x8f, 0x77, 0x13, 0x16, 0x4f, 0x4c, 0xab, + 0x2d, 0x32, 0x91, 0xd7, 0xc5, 0x83, 0xb6, 0x09, 0xc4, 0xdf, 0x9f, 0x88, 0x09, 0x17, 0xff, 0xcb, + 0x96, 0xdd, 0xf5, 0xb9, 0x70, 0x5a, 0x76, 0x37, 0xe4, 0x82, 0x21, 0x98, 0x0b, 0xf6, 0xca, 0x5d, + 0xfc, 0xc2, 0xcc, 0x1b, 0x1d, 0x7b, 0x19, 0x37, 0x3a, 0x8e, 0xe7, 0x28, 0xed, 0xb1, 0x1c, 0xdd, + 0xd4, 0xae, 0xdd, 0x71, 0xf8, 0xbd, 0x6b, 0x7f, 0xcd, 0x0a, 0x31, 0x61, 0x8d, 0x33, 0x88, 0x89, + 0xdf, 0x6c, 0x5c, 0x4c, 0xfe, 0x79, 0x8d, 0x62, 0xa2, 0x8a, 0x4c, 0x29, 0x26, 0x35, 0x28, 0xd8, + 0xd4, 0x3a, 0x37, 0xda, 0x8c, 0x1d, 0x42, 0x4c, 0x30, 0x84, 0x23, 0xd1, 0xdc, 0xd8, 0xb7, 0x75, + 0x40, 0x48, 0xa3, 0x63, 0x93, 0xfb, 0x90, 0x47, 0x2e, 0x09, 0xc5, 0x58, 0xde, 0x2d, 0x8c, 0x2e, + 0xb7, 0x73, 0x82, 0x4c, 0xb6, 0x9e, 0x13, 0x6c, 0xb2, 0xc9, 0xc7, 0x50, 0xec, 0x50, 0xdb, 0xb0, + 0x68, 0xa7, 0x69, 0x3b, 0x2d, 0x07, 0xf5, 0xa1, 0x58, 0xff, 0x56, 0x54, 0x8a, 0x8f, 0x18, 0x8a, + 0x0b, 0xcc, 0x2a, 0x1a, 0xf2, 0x16, 0x85, 0xd0, 0xe4, 0xc6, 0x85, 0x86, 0xdc, 0x06, 0x18, 0x0e, + 0x9a, 0x8e, 0xd9, 0x64, 0xeb, 0xa7, 0x94, 0xe7, 0x14, 0xce, 0x0f, 0x07, 0x2f, 0xcd, 0xfd, 0x96, + 0x43, 0x49, 0x19, 0xf2, 0xd6, 0xb0, 0xef, 0x18, 0x2c, 0x03, 0xcb, 0xdc, 0xda, 0x7d, 0x9e, 0x83, + 0x44, 0xe1, 0x64, 0x7b, 0x12, 0xc5, 0x38, 0x17, 0x2b, 0x51, 0x9c, 0x84, 0x02, 0xa6, 0x1d, 0xc0, + 0xe6, 0x9e, 0x45, 0x5b, 0x0e, 0xc5, 0x09, 0x97, 0x34, 0x7c, 0x84, 0xfa, 0x21, 0x38, 0xb8, 0xad, + 0xea, 0x06, 0x2d, 0x7c, 0x12, 0x72, 0x08, 0x37, 0x43, 0x9d, 0x61, 0x54, 0xef, 0x41, 0x0e, 0x93, + 0x88, 0x1d, 0xde, 0x8a, 0xe9, 0x50, 0x97, 0x58, 0xed, 0x35, 0x6c, 0x3c, 0xa5, 0x4e, 0x28, 0xb2, + 0x1d, 0x00, 0x8f, 0x33, 0xb8, 0xe6, 0x56, 0x47, 0x97, 0xdb, 0xcb, 0x2e, 0x65, 0xf4, 0x65, 0x97, + 0x31, 0xe4, 0x01, 0xac, 0x19, 0x7d, 0x9b, 0x5a, 0x4e, 0xb3, 0x43, 0x4f, 0x5a, 0xc3, 0x9e, 0x63, + 0xa3, 0xc2, 0x14, 0x45, 0xf3, 0x3e, 0xb6, 0x6a, 0x07, 0x40, 0xfc, 0xbe, 0xae, 0x16, 0xf8, 0x9f, + 0xd3, 0xb0, 0x29, 0xc4, 0xf4, 0x4a, 0xc1, 0xef, 0xc3, 0x9a, 0x44, 0x4f, 0xf1, 0x1d, 0x28, 0xa2, + 0x8d, 0xfc, 0x14, 0x3c, 0x0a, 0x7c, 0x0a, 0x26, 0x4b, 0x25, 0x79, 0x06, 0x79, 0xcb, 0xec, 0xf5, + 0x8e, 0x5b, 0xed, 0x6e, 0x29, 0x7b, 0x27, 0x55, 0x29, 0xd6, 0xdf, 0x55, 0x19, 0xaa, 0x06, 0x59, + 0xd5, 0xd1, 0x50, 0x77, 0xbb, 0xd0, 0x34, 0xc8, 0xcb, 0x56, 0x92, 0x87, 0xec, 0xe1, 0xf3, 0xc3, + 0x27, 0xeb, 0x0b, 0x64, 0x05, 0xf2, 0x2f, 0xf4, 0x27, 0x9f, 0x35, 0x9e, 0xbf, 0x3a, 0x5a, 0x4f, + 0x31, 0xf6, 0x84, 0xba, 0xbb, 0x5a, 0x12, 0xf6, 0x61, 0x53, 0x88, 0xee, 0x55, 0x72, 0xa0, 0x7d, + 0x13, 0x6e, 0x86, 0x7a, 0x41, 0xf5, 0xfe, 0x2a, 0x03, 0x37, 0xd8, 0xfa, 0xc3, 0x76, 0x57, 0xc0, + 0x1b, 0x61, 0x01, 0xaf, 0x45, 0xc9, 0x64, 0xc8, 0x72, 0x5c, 0xc3, 0xff, 0x90, 0x9e, 0xbb, 0x86, + 0x1f, 0x85, 0x34, 0xfc, 0x87, 0x53, 0x06, 0xa7, 0x94, 0xf1, 0x31, 0x8d, 0xcc, 0x2a, 0x34, 0xd2, + 0xaf, 0x82, 0x8b, 0xf3, 0x53, 0xc1, 0xe7, 0xb0, 0x19, 0x0c, 0x17, 0x49, 0xf3, 0x3e, 0xe4, 0x31, + 0x89, 0x52, 0x0b, 0x63, 0x59, 0xe3, 0x82, 0x3d, 0x45, 0x3c, 0xa4, 0xce, 0x17, 0xa6, 0xd5, 0x9d, + 0x42, 0x11, 0xd1, 0x42, 0xa5, 0x88, 0x6e, 0x67, 0x1e, 0xa7, 0xfb, 0xa2, 0x29, 0x8e, 0xd3, 0xd2, + 0x4a, 0x62, 0xb5, 0x57, 0x5c, 0x11, 0x43, 0x91, 0x11, 0xc8, 0xb2, 0x99, 0xc6, 0xf9, 0xe2, 0xbf, + 0x19, 0xc9, 0xd1, 0x86, 0x91, 0x3c, 0xed, 0x91, 0x1c, 0x6d, 0x19, 0xc9, 0x11, 0xd0, 0xe8, 0xa0, + 0xf8, 0xcd, 0x29, 0xc6, 0x9f, 0xc9, 0x75, 0x37, 0xf7, 0x30, 0xdd, 0xb5, 0x18, 0x8a, 0x54, 0xfb, + 0x6f, 0x5a, 0xac, 0x45, 0x6c, 0x9f, 0x61, 0x2d, 0x86, 0x2c, 0xc7, 0xd7, 0xe2, 0x6f, 0xae, 0x71, + 0x2d, 0x46, 0x04, 0x37, 0xf3, 0x5a, 0x9c, 0xc3, 0x7a, 0xf3, 0x42, 0xf2, 0xd6, 0x1b, 0x26, 0x2a, + 0x76, 0xbd, 0xc9, 0xcc, 0xb9, 0x60, 0xed, 0x43, 0x4e, 0xe9, 0xbd, 0xde, 0xd0, 0x76, 0xa8, 0xe5, + 0xd3, 0xe8, 0xb6, 0x68, 0x09, 0x69, 0x34, 0xe2, 0x18, 0x2f, 0x10, 0xe0, 0xd2, 0xd7, 0xed, 0xc2, + 0xa3, 0x2f, 0x42, 0xe2, 0xe8, 0x2b, 0xad, 0x24, 0xd6, 0xe5, 0x12, 0xbe, 0x98, 0x81, 0x4b, 0x21, + 0xcb, 0xb7, 0x8b, 0x4b, 0x11, 0xc1, 0x5d, 0x27, 0x97, 0xbc, 0x90, 0x3c, 0x2e, 0x61, 0x36, 0x62, + 0xb9, 0x24, 0x53, 0xe7, 0x82, 0xb5, 0xdf, 0xa5, 0xa0, 0x70, 0x40, 0x2f, 0x74, 0xd3, 0x69, 0x39, + 0x6c, 0xeb, 0xf3, 0x0e, 0x6c, 0x30, 0x92, 0x51, 0xab, 0xf9, 0xda, 0x34, 0xfa, 0x4d, 0xc7, 0xec, + 0xd2, 0x3e, 0x0f, 0x2d, 0xaf, 0xaf, 0x89, 0x17, 0x9f, 0x98, 0x46, 0xff, 0x25, 0x6b, 0x26, 0x3b, + 0x40, 0xce, 0x5a, 0xfd, 0xd6, 0x69, 0x10, 0x2c, 0x36, 0x8b, 0xeb, 0xf8, 0x46, 0x89, 0x1e, 0xf6, + 0x7b, 0x66, 0xbb, 0xdb, 0x64, 0xa3, 0xce, 0x04, 0xd0, 0xaf, 0xf8, 0x8b, 0x03, 0x7a, 0xa1, 0xfd, + 0xda, 0xdd, 0x0f, 0x5e, 0x85, 0xe7, 0x6c, 0x3f, 0x28, 0xd1, 0xd3, 0xec, 0x07, 0xd1, 0x66, 0x8a, + 0xfd, 0x20, 0x7a, 0xf7, 0xed, 0x07, 0x3f, 0x64, 0xfb, 0x41, 0x31, 0xab, 0x7c, 0x3f, 0x18, 0x61, + 0xe8, 0x9b, 0xfc, 0xdd, 0xec, 0x9b, 0xcb, 0xed, 0x05, 0xdd, 0x35, 0xf3, 0xf6, 0x77, 0x73, 0x5a, + 0xa8, 0x3f, 0x82, 0x75, 0xbe, 0x63, 0x6f, 0x5b, 0xd4, 0x91, 0xf3, 0xf9, 0x10, 0x96, 0x6d, 0xde, + 0xe0, 0x4d, 0xe7, 0xca, 0xe8, 0x72, 0x3b, 0x2f, 0x50, 0x8d, 0x7d, 0xf6, 0x9d, 0xe7, 0xbf, 0x3a, + 0xda, 0x53, 0x3c, 0x5c, 0x08, 0x73, 0x0c, 0xa5, 0x0e, 0x4b, 0x02, 0x80, 0x91, 0x94, 0xd5, 0x7b, + 0x06, 0x6e, 0x83, 0x48, 0xed, 0x2f, 0x29, 0xb8, 0x21, 0x37, 0xae, 0xb3, 0xc5, 0x42, 0x76, 0xa1, + 0x88, 0xd0, 0x29, 0xf2, 0xba, 0x2a, 0x4c, 0x64, 0x5a, 0xeb, 0x81, 0xb4, 0x6e, 0x45, 0x07, 0xee, + 0xdb, 0x9e, 0x7c, 0xe2, 0x1d, 0x53, 0xae, 0x3c, 0x0d, 0xff, 0x4e, 0x03, 0x11, 0x3b, 0x31, 0xf6, + 0xe8, 0xca, 0xe6, 0xc7, 0x61, 0xd9, 0xac, 0x46, 0xef, 0x38, 0xfd, 0x86, 0xe3, 0xaa, 0xf9, 0xd5, + 0xfc, 0x55, 0x53, 0x0f, 0xa9, 0xe6, 0x07, 0xd3, 0xc5, 0x76, 0x2d, 0xa2, 0x79, 0x20, 0x8f, 0x1d, + 0x18, 0x11, 0xa6, 0xec, 0x7b, 0xec, 0x90, 0xc4, 0x9b, 0x50, 0x32, 0xe3, 0x72, 0x26, 0xa1, 0x5a, + 0x03, 0x6e, 0xc8, 0x13, 0xbb, 0x9f, 0xba, 0xf5, 0xc0, 0x5e, 0x77, 0x62, 0x2e, 0x05, 0xbb, 0xba, + 0x02, 0x97, 0x7e, 0x0a, 0x37, 0xe4, 0xa1, 0x6b, 0xc6, 0xd5, 0xfd, 0x0d, 0xef, 0xf0, 0xe7, 0x8f, + 0x06, 0x45, 0x63, 0xcf, 0xec, 0x9f, 0x18, 0xa7, 0xbe, 0x6e, 0xdb, 0xbc, 0x21, 0xd4, 0xad, 0x40, + 0xb1, 0x6e, 0xc5, 0x6b, 0x57, 0x34, 0xa4, 0xb9, 0x37, 0x42, 0x01, 0x88, 0x1b, 0x21, 0xda, 0x20, + 0xd2, 0x27, 0x1a, 0xb3, 0xc6, 0xc2, 0x44, 0x03, 0xa1, 0xd3, 0x88, 0x86, 0x30, 0x99, 0x42, 0x34, + 0x84, 0x67, 0x95, 0x68, 0xcc, 0x61, 0x1a, 0xa4, 0x68, 0x88, 0xe6, 0x19, 0x44, 0x23, 0x68, 0xf8, + 0x76, 0x89, 0x86, 0x3a, 0xb6, 0xeb, 0x14, 0x0d, 0x37, 0x22, 0x4f, 0x34, 0x44, 0x22, 0x62, 0x45, + 0x03, 0x73, 0x26, 0xa1, 0x9e, 0x68, 0x04, 0xa9, 0x3b, 0x81, 0x68, 0xa8, 0xb8, 0x14, 0xec, 0xea, + 0x0a, 0x5c, 0x72, 0x45, 0x63, 0xe6, 0xd5, 0xed, 0x8a, 0x46, 0x30, 0x9a, 0xfa, 0xaf, 0x6e, 0x41, + 0x6e, 0x4f, 0x5c, 0xb4, 0x12, 0x03, 0x72, 0x78, 0x85, 0x48, 0x34, 0x55, 0x50, 0xc1, 0x6b, 0xc9, + 0xf2, 0xdd, 0x58, 0x0c, 0x8a, 0xd2, 0xcd, 0xbf, 0xfd, 0xe9, 0x7f, 0xbf, 0x4f, 0xaf, 0xc1, 0x2a, + 0x07, 0x7d, 0x07, 0xb7, 0x8f, 0xc4, 0x84, 0x65, 0xf7, 0x0e, 0x8a, 0x7c, 0x7b, 0x92, 0x9b, 0xbb, + 0xf2, 0xbd, 0x04, 0x54, 0xbc, 0x43, 0x0b, 0xc0, 0xbb, 0x02, 0x22, 0xf7, 0xa2, 0x0b, 0x7e, 0xfe, + 0x11, 0xde, 0x4f, 0x82, 0x25, 0xfa, 0xf4, 0xae, 0x78, 0xd4, 0x3e, 0xc7, 0xae, 0x94, 0xd4, 0x3e, + 0x15, 0x37, 0x45, 0x11, 0x3e, 0x45, 0x0e, 0x5f, 0xb6, 0xec, 0x6e, 0x64, 0x0e, 0x7d, 0x57, 0x3c, + 0x91, 0x39, 0x0c, 0x5c, 0xe6, 0xc4, 0xe7, 0x90, 0x17, 0xe9, 0xa3, 0x73, 0xe8, 0xbf, 0x30, 0x89, + 0xce, 0x61, 0xa0, 0xd2, 0x9f, 0x38, 0x9f, 0x7c, 0x78, 0x31, 0xf3, 0xe9, 0x1f, 0xe1, 0xfd, 0x24, + 0x58, 0xa2, 0x4f, 0xaf, 0x76, 0xae, 0xf6, 0x39, 0x56, 0xc7, 0x57, 0xfb, 0x1c, 0x2f, 0xc1, 0x47, + 0xf9, 0xfc, 0x12, 0x56, 0xfc, 0x75, 0x3f, 0xf2, 0x60, 0xc2, 0x42, 0x66, 0xb9, 0x92, 0x0c, 0x8c, + 0xf7, 0xfc, 0x0b, 0x58, 0x0d, 0xdc, 0x72, 0x10, 0x65, 0x8f, 0xaa, 0x5b, 0x95, 0xf2, 0xc3, 0x09, + 0x90, 0x89, 0xce, 0x03, 0x45, 0x72, 0xb5, 0x73, 0x55, 0x59, 0x5e, 0xed, 0x5c, 0x59, 0x71, 0x8f, + 0x71, 0x1e, 0xa8, 0x85, 0xab, 0x9d, 0xab, 0x8a, 0xee, 0x6a, 0xe7, 0xea, 0xc2, 0x7a, 0x2c, 0xc9, + 0xb0, 0x7e, 0x14, 0x49, 0xb2, 0x60, 0xcd, 0x31, 0x92, 0x64, 0xe1, 0x02, 0x62, 0x3c, 0xc9, 0x64, + 0xb1, 0x2b, 0x9a, 0x64, 0xa1, 0x0a, 0x5d, 0x34, 0xc9, 0xc2, 0x75, 0xb3, 0x44, 0x92, 0xc9, 0x01, + 0xc7, 0x90, 0x2c, 0x34, 0xe6, 0x87, 0x13, 0x20, 0x27, 0xcc, 0x73, 0xac, 0x73, 0x55, 0x91, 0x37, + 0x2e, 0xcf, 0x13, 0x3a, 0x17, 0x79, 0xc6, 0xd3, 0x7e, 0x64, 0x9e, 0x83, 0x75, 0x94, 0xc8, 0x3c, + 0x87, 0x4a, 0x0d, 0x09, 0x79, 0x96, 0x85, 0xa8, 0xe8, 0x3c, 0x87, 0xaa, 0x67, 0xd1, 0x79, 0x0e, + 0xd7, 0xb4, 0x12, 0xd7, 0xb3, 0x1c, 0x70, 0xcc, 0x7a, 0x0e, 0x8d, 0xf9, 0xe1, 0x04, 0xc8, 0xc4, + 0x8f, 0x93, 0x5b, 0x02, 0x51, 0x7f, 0x9c, 0xc2, 0x05, 0x96, 0xf2, 0xbd, 0x04, 0x54, 0xe2, 0x3c, + 0xfb, 0xeb, 0x0d, 0xea, 0x79, 0x56, 0xd4, 0x52, 0xca, 0x95, 0x64, 0x60, 0xbc, 0xe7, 0x21, 0x14, + 0x7c, 0xa7, 0x66, 0x72, 0x7f, 0xb2, 0x83, 0x7e, 0xf9, 0x41, 0x22, 0x2e, 0x71, 0xc0, 0xfe, 0x43, + 0xb1, 0x7a, 0xc0, 0x8a, 0x13, 0x78, 0xb9, 0x92, 0x0c, 0x4c, 0xf4, 0xec, 0x3f, 0x00, 0xab, 0x3d, + 0x2b, 0x0e, 0xd9, 0xe5, 0x4a, 0x32, 0x70, 0x12, 0x56, 0x89, 0x2d, 0x74, 0x24, 0xab, 0x02, 0x7b, + 0xf4, 0x48, 0x56, 0x05, 0xf7, 0xe1, 0x89, 0xac, 0x42, 0x9f, 0x31, 0xac, 0x0a, 0xba, 0xad, 0x24, + 0x03, 0x27, 0x62, 0x15, 0x1e, 0xab, 0xa2, 0x59, 0x15, 0x3c, 0x09, 0x46, 0xb3, 0x2a, 0x74, 0x3e, + 0x4b, 0x64, 0x55, 0xdc, 0x80, 0x15, 0x47, 0xb4, 0x38, 0x56, 0x4d, 0x3c, 0xd5, 0xfe, 0x13, 0x52, + 0x1c, 0xab, 0x26, 0xf0, 0xac, 0x3a, 0x6c, 0x45, 0x78, 0xde, 0x2d, 0xbd, 0xf9, 0x7a, 0x6b, 0xe1, + 0x1f, 0x5f, 0x6f, 0x2d, 0xfc, 0x72, 0xb4, 0x95, 0x7a, 0x33, 0xda, 0x4a, 0xfd, 0x7d, 0xb4, 0x95, + 0xfa, 0xd7, 0x68, 0x2b, 0x75, 0xbc, 0xc4, 0xff, 0x25, 0xf4, 0xd1, 0xff, 0x03, 0x00, 0x00, 0xff, + 0xff, 0x47, 0x18, 0x50, 0x6c, 0x2b, 0x2b, 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/control.proto b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/control.proto index c8254cab9..0ca59703c 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/control.proto +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/control.proto @@ -2,11 +2,11 @@ syntax = "proto3"; package docker.swarmkit.v1; -import "specs.proto"; -import "objects.proto"; -import "types.proto"; +import "github.com/docker/swarmkit/api/specs.proto"; +import "github.com/docker/swarmkit/api/objects.proto"; +import "github.com/docker/swarmkit/api/types.proto"; import "gogoproto/gogo.proto"; -import "plugin/plugin.proto"; +import "github.com/docker/swarmkit/protobuf/plugin/plugin.proto"; // Control defines the RPC methods for controlling a cluster. service Control { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/dispatcher.pb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/dispatcher.pb.go index 825a6077e..8e9b038ca 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/dispatcher.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/dispatcher.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. -// source: dispatcher.proto +// source: github.com/docker/swarmkit/api/dispatcher.proto // DO NOT EDIT! package api @@ -1100,7 +1100,7 @@ var _Dispatcher_serviceDesc = grpc.ServiceDesc{ ServerStreams: true, }, }, - Metadata: "dispatcher.proto", + Metadata: "github.com/docker/swarmkit/api/dispatcher.proto", } func (m *SessionRequest) Marshal() (dAtA []byte, err error) { @@ -3778,70 +3778,73 @@ var ( ErrIntOverflowDispatcher = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("dispatcher.proto", fileDescriptorDispatcher) } +func init() { + proto.RegisterFile("github.com/docker/swarmkit/api/dispatcher.proto", fileDescriptorDispatcher) +} var fileDescriptorDispatcher = []byte{ - // 983 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0x38, 0xce, 0x26, 0x7e, 0x4e, 0x82, 0x19, 0xaa, 0xb0, 0xac, 0x54, 0xc7, 0x6c, 0x68, - 0x14, 0xa9, 0x61, 0x53, 0xcc, 0x9f, 0x0b, 0x51, 0x20, 0x8e, 0x2d, 0xc5, 0x6a, 0x93, 0x46, 0x13, - 0xb7, 0x3d, 0x5a, 0x6b, 0xef, 0x74, 0xb3, 0x38, 0xde, 0x59, 0x76, 0xc6, 0x2d, 0x3e, 0x20, 0x71, - 0xa0, 0x12, 0xe2, 0x84, 0x38, 0x45, 0x42, 0x7c, 0x05, 0xc4, 0xc7, 0x88, 0x38, 0x71, 0xe4, 0x14, - 0xa8, 0x3f, 0x00, 0x1f, 0x80, 0x13, 0xda, 0xd9, 0x59, 0xdb, 0x75, 0xed, 0xd4, 0xc9, 0xc9, 0x9e, - 0x37, 0xbf, 0xdf, 0x9b, 0xdf, 0xbc, 0xf7, 0xdb, 0x37, 0x90, 0x77, 0x3c, 0x1e, 0xd8, 0xa2, 0x75, - 0x4a, 0x43, 0x2b, 0x08, 0x99, 0x60, 0x18, 0x3b, 0xac, 0xd5, 0xa6, 0xa1, 0xc5, 0x9f, 0xdb, 0x61, - 0xa7, 0xed, 0x09, 0xeb, 0xd9, 0x47, 0x46, 0x4e, 0xf4, 0x02, 0xca, 0x63, 0x80, 0xb1, 0xcc, 0x9a, - 0x5f, 0xd1, 0x96, 0x48, 0x96, 0xb7, 0x5c, 0xe6, 0x32, 0xf9, 0x77, 0x3b, 0xfa, 0xa7, 0xa2, 0xef, - 0x04, 0x67, 0x5d, 0xd7, 0xf3, 0xb7, 0xe3, 0x1f, 0x15, 0x2c, 0xb8, 0x8c, 0xb9, 0x67, 0x74, 0x5b, - 0xae, 0x9a, 0xdd, 0xa7, 0xdb, 0x4e, 0x37, 0xb4, 0x85, 0xc7, 0xd4, 0xbe, 0xf9, 0x02, 0xc1, 0xca, - 0x09, 0xe5, 0xdc, 0x63, 0x3e, 0xa1, 0x5f, 0x77, 0x29, 0x17, 0xb8, 0x0a, 0x39, 0x87, 0xf2, 0x56, - 0xe8, 0x05, 0x11, 0x4e, 0x47, 0x45, 0xb4, 0x99, 0x2b, 0xad, 0x5b, 0xaf, 0x6b, 0xb4, 0x8e, 0x98, - 0x43, 0x2b, 0x43, 0x28, 0x19, 0xe5, 0xe1, 0x2d, 0x00, 0x1e, 0x27, 0x6e, 0x78, 0x8e, 0x9e, 0x2e, - 0xa2, 0xcd, 0x6c, 0x79, 0xb9, 0x7f, 0xb9, 0x96, 0x55, 0xc7, 0xd5, 0x2a, 0x24, 0xab, 0x00, 0x35, - 0xc7, 0xfc, 0x25, 0x3d, 0xd0, 0x71, 0x48, 0x39, 0xb7, 0x5d, 0x3a, 0x96, 0x00, 0x5d, 0x9d, 0x00, - 0x6f, 0x41, 0xc6, 0x67, 0x0e, 0x95, 0x07, 0xe5, 0x4a, 0xfa, 0x34, 0xb9, 0x44, 0xa2, 0xf0, 0x0e, - 0x2c, 0x76, 0x6c, 0xdf, 0x76, 0x69, 0xc8, 0xf5, 0xb9, 0xe2, 0xdc, 0x66, 0xae, 0x54, 0x9c, 0xc4, - 0x78, 0x42, 0x3d, 0xf7, 0x54, 0x50, 0xe7, 0x98, 0xd2, 0x90, 0x0c, 0x18, 0xf8, 0x09, 0xac, 0xfa, - 0x54, 0x3c, 0x67, 0x61, 0xbb, 0xd1, 0x64, 0x4c, 0x70, 0x11, 0xda, 0x41, 0xa3, 0x4d, 0x7b, 0x5c, - 0xcf, 0xc8, 0x5c, 0xef, 0x4f, 0xca, 0x55, 0xf5, 0x5b, 0x61, 0x4f, 0x96, 0xe6, 0x3e, 0xed, 0x91, - 0x5b, 0x2a, 0x41, 0x39, 0xe1, 0xdf, 0xa7, 0x3d, 0x8e, 0x57, 0x41, 0x23, 0x8c, 0x89, 0xfd, 0x3d, - 0x7d, 0xbe, 0x88, 0x36, 0x97, 0x88, 0x5a, 0x99, 0x5f, 0x42, 0xfe, 0x80, 0xda, 0xa1, 0x68, 0x52, - 0x5b, 0x24, 0x6d, 0xba, 0x56, 0x79, 0xcc, 0x63, 0x78, 0x7b, 0x24, 0x03, 0x0f, 0x98, 0xcf, 0x29, - 0xfe, 0x1c, 0xb4, 0x80, 0x86, 0x1e, 0x73, 0x54, 0x93, 0xdf, 0xb3, 0x62, 0xb7, 0x58, 0x89, 0x5b, - 0xac, 0x8a, 0x72, 0x4b, 0x79, 0xf1, 0xe2, 0x72, 0x2d, 0x75, 0xfe, 0xf7, 0x1a, 0x22, 0x8a, 0x62, - 0xfe, 0x94, 0x86, 0x77, 0x1f, 0x05, 0x8e, 0x2d, 0x68, 0xdd, 0xe6, 0xed, 0x13, 0x61, 0x8b, 0x2e, - 0xbf, 0x91, 0x36, 0xfc, 0x18, 0x16, 0xba, 0x32, 0x51, 0xd2, 0x8b, 0x9d, 0x49, 0xf5, 0x9b, 0x72, - 0x96, 0x35, 0x8c, 0xc4, 0x08, 0x92, 0x24, 0x33, 0x18, 0xe4, 0xc7, 0x37, 0xf1, 0x3a, 0x2c, 0x08, - 0x9b, 0xb7, 0x87, 0xb2, 0xa0, 0x7f, 0xb9, 0xa6, 0x45, 0xb0, 0x5a, 0x85, 0x68, 0xd1, 0x56, 0xcd, - 0xc1, 0x9f, 0x81, 0xc6, 0x25, 0x49, 0xb9, 0xa9, 0x30, 0x49, 0xcf, 0x88, 0x12, 0x85, 0x36, 0x0d, - 0xd0, 0x5f, 0x57, 0x19, 0xd7, 0xda, 0xdc, 0x81, 0xa5, 0x28, 0x7a, 0xb3, 0x12, 0x99, 0xbb, 0x8a, - 0x9d, 0x7c, 0x1b, 0x16, 0xcc, 0x47, 0x5a, 0xb9, 0x8e, 0x64, 0xc1, 0xf4, 0x69, 0x02, 0x49, 0x0c, - 0x33, 0xcb, 0x80, 0xf7, 0x38, 0xf7, 0x5c, 0xbf, 0x43, 0x7d, 0x71, 0x43, 0x0d, 0xbf, 0x23, 0x80, - 0x61, 0x12, 0x6c, 0x41, 0x26, 0xca, 0xad, 0xac, 0x33, 0x55, 0xc1, 0x41, 0x8a, 0x48, 0x1c, 0xfe, - 0x04, 0x34, 0x4e, 0x5b, 0x21, 0x15, 0xaa, 0xa8, 0xc6, 0x24, 0xc6, 0x89, 0x44, 0x1c, 0xa4, 0x88, - 0xc2, 0x46, 0xac, 0x16, 0xf3, 0x9f, 0x7a, 0xae, 0x3e, 0x37, 0x9d, 0xb5, 0x2f, 0x11, 0x11, 0x2b, - 0xc6, 0x96, 0x35, 0xc8, 0x78, 0x82, 0x76, 0xcc, 0x17, 0x69, 0xc8, 0x0f, 0x25, 0xef, 0x9f, 0xda, - 0xbe, 0x4b, 0xf1, 0x2e, 0x80, 0x3d, 0x88, 0x29, 0xf9, 0x13, 0x3b, 0x3c, 0x64, 0x92, 0x11, 0x06, - 0x3e, 0x04, 0xcd, 0x6e, 0xc9, 0xd1, 0x18, 0x5d, 0x64, 0xa5, 0xf4, 0xe9, 0xd5, 0xdc, 0xf8, 0xd4, - 0x91, 0xc0, 0x9e, 0x24, 0x13, 0x95, 0xc4, 0x6c, 0x8e, 0x4a, 0x8c, 0xf7, 0xf0, 0x06, 0x68, 0x8f, - 0x8e, 0x2b, 0x7b, 0xf5, 0x6a, 0x3e, 0x65, 0x18, 0x3f, 0xfe, 0x5a, 0x5c, 0x1d, 0x47, 0x28, 0x37, - 0x6f, 0x80, 0x46, 0xaa, 0x87, 0x0f, 0x1f, 0x57, 0xf3, 0x68, 0x32, 0x8e, 0xd0, 0x0e, 0x7b, 0x46, - 0xcd, 0xff, 0xd0, 0x2b, 0xfd, 0x4f, 0x5c, 0xf4, 0x05, 0x64, 0xa2, 0x57, 0x46, 0xd6, 0x60, 0xa5, - 0x74, 0xf7, 0xea, 0x7b, 0x24, 0x2c, 0xab, 0xde, 0x0b, 0x28, 0x91, 0x44, 0x7c, 0x1b, 0xc0, 0x0e, - 0x82, 0x33, 0x8f, 0xf2, 0x86, 0x60, 0xf1, 0x8c, 0x27, 0x59, 0x15, 0xa9, 0xb3, 0x68, 0x3b, 0xa4, - 0xbc, 0x7b, 0x26, 0x78, 0xc3, 0xf3, 0x65, 0x03, 0xb3, 0x24, 0xab, 0x22, 0x35, 0x1f, 0xef, 0xc2, - 0x42, 0x4b, 0x16, 0x27, 0x99, 0x9b, 0x1f, 0xcc, 0x52, 0x49, 0x92, 0x90, 0xcc, 0x3b, 0x90, 0x89, - 0xb4, 0xe0, 0x25, 0x58, 0xdc, 0x7f, 0x78, 0x78, 0xfc, 0xa0, 0x1a, 0xd5, 0x0b, 0xbf, 0x05, 0xb9, - 0xda, 0xd1, 0x3e, 0xa9, 0x1e, 0x56, 0x8f, 0xea, 0x7b, 0x0f, 0xf2, 0xa8, 0x74, 0x3e, 0x0f, 0x50, - 0x19, 0x3c, 0xb9, 0xf8, 0x1b, 0x58, 0x50, 0xf6, 0xc6, 0xe6, 0x64, 0x0b, 0x8e, 0xbe, 0x86, 0xc6, - 0x55, 0x18, 0x55, 0x11, 0x73, 0xfd, 0x8f, 0xdf, 0xfe, 0x3d, 0x4f, 0xdf, 0x86, 0x25, 0x89, 0xf9, - 0x30, 0x9a, 0xeb, 0x34, 0x84, 0xe5, 0x78, 0xa5, 0x5e, 0x8d, 0x7b, 0x08, 0x7f, 0x0b, 0xd9, 0xc1, - 0x0c, 0xc6, 0x13, 0xef, 0x3a, 0x3e, 0xe4, 0x8d, 0x3b, 0x6f, 0x40, 0xa9, 0xe1, 0x32, 0x8b, 0x00, - 0xfc, 0x33, 0x82, 0xfc, 0xf8, 0x78, 0xc2, 0x77, 0xaf, 0x31, 0x6a, 0x8d, 0xad, 0xd9, 0xc0, 0xd7, - 0x11, 0xd5, 0x85, 0x79, 0x39, 0xd8, 0x70, 0x71, 0xda, 0x00, 0x19, 0x9c, 0x3e, 0x1d, 0x91, 0xf4, - 0x61, 0x63, 0x86, 0x13, 0x7f, 0x48, 0xa3, 0x7b, 0x08, 0x7f, 0x8f, 0x20, 0x37, 0x62, 0x6d, 0xbc, - 0xf1, 0x06, 0xef, 0x27, 0x1a, 0x36, 0x66, 0xfb, 0x46, 0x66, 0x74, 0x44, 0x59, 0xbf, 0x78, 0x59, - 0x48, 0xfd, 0xf5, 0xb2, 0x90, 0xfa, 0xae, 0x5f, 0x40, 0x17, 0xfd, 0x02, 0xfa, 0xb3, 0x5f, 0x40, - 0xff, 0xf4, 0x0b, 0xa8, 0xa9, 0xc9, 0x27, 0xf8, 0xe3, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x6c, - 0xba, 0x38, 0xbd, 0x2d, 0x0a, 0x00, 0x00, + // 1007 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x4f, 0x6f, 0xe3, 0x44, + 0x1c, 0xcd, 0xa4, 0xa9, 0xdb, 0xfc, 0xd2, 0x2d, 0x61, 0xb4, 0x2a, 0xc6, 0xd2, 0xa6, 0xc1, 0x65, + 0xab, 0x8a, 0x2d, 0xce, 0x12, 0xfe, 0x1d, 0xa8, 0x0a, 0x4d, 0x13, 0xa9, 0xd1, 0x6e, 0xbb, 0xd5, + 0xb4, 0xbb, 0x7b, 0xac, 0x1c, 0x7b, 0xd6, 0x35, 0x69, 0x3c, 0xc6, 0x33, 0xd9, 0x25, 0x07, 0x24, + 0x0e, 0xac, 0x84, 0x38, 0x21, 0x4e, 0x95, 0x10, 0x5f, 0x01, 0xf1, 0x31, 0x2a, 0x4e, 0x1c, 0x39, + 0x15, 0x36, 0x1f, 0x80, 0x0f, 0xc0, 0x09, 0x79, 0x3c, 0x4e, 0x42, 0x37, 0x69, 0xd3, 0x9e, 0x12, + 0xcf, 0xbc, 0xf7, 0xe6, 0xf9, 0xfd, 0x7e, 0xfe, 0x0d, 0x54, 0x3c, 0x5f, 0x1c, 0x77, 0x5b, 0x96, + 0xc3, 0x3a, 0x15, 0x97, 0x39, 0x6d, 0x1a, 0x55, 0xf8, 0x0b, 0x3b, 0xea, 0xb4, 0x7d, 0x51, 0xb1, + 0x43, 0xbf, 0xe2, 0xfa, 0x3c, 0xb4, 0x85, 0x73, 0x4c, 0x23, 0x2b, 0x8c, 0x98, 0x60, 0x18, 0x27, + 0x28, 0x2b, 0x45, 0x59, 0xcf, 0x3f, 0x30, 0xde, 0xbb, 0x42, 0x44, 0xf4, 0x42, 0xca, 0x13, 0xbe, + 0xb1, 0x7e, 0x05, 0x96, 0xb5, 0xbe, 0xa4, 0x8e, 0x48, 0xd1, 0xb7, 0x3d, 0xe6, 0x31, 0xf9, 0xb7, + 0x12, 0xff, 0x53, 0xab, 0x9f, 0x5e, 0xa2, 0x21, 0x11, 0xad, 0xee, 0xb3, 0x4a, 0x78, 0xd2, 0xf5, + 0xfc, 0x40, 0xfd, 0x28, 0x62, 0xc9, 0x63, 0xcc, 0x3b, 0xa1, 0x43, 0x90, 0xdb, 0x8d, 0x6c, 0xe1, + 0x33, 0xb5, 0x6f, 0xbe, 0x44, 0xb0, 0x78, 0x40, 0x39, 0xf7, 0x59, 0x40, 0xe8, 0x57, 0x5d, 0xca, + 0x05, 0x6e, 0x40, 0xc1, 0xa5, 0xdc, 0x89, 0xfc, 0x30, 0xc6, 0xe9, 0xa8, 0x8c, 0xd6, 0x0a, 0xd5, + 0x15, 0xeb, 0xf5, 0x14, 0xac, 0x3d, 0xe6, 0xd2, 0xfa, 0x10, 0x4a, 0x46, 0x79, 0x78, 0x1d, 0x80, + 0x27, 0xc2, 0x47, 0xbe, 0xab, 0x67, 0xcb, 0x68, 0x2d, 0x5f, 0xbb, 0xd5, 0x3f, 0x5f, 0xce, 0xab, + 0xe3, 0x9a, 0x75, 0x92, 0x57, 0x80, 0xa6, 0x6b, 0xfe, 0x9c, 0x1d, 0xf8, 0xd8, 0xa5, 0x9c, 0xdb, + 0x1e, 0xbd, 0x20, 0x80, 0x2e, 0x17, 0xc0, 0xeb, 0x90, 0x0b, 0x98, 0x4b, 0xe5, 0x41, 0x85, 0xaa, + 0x3e, 0xc9, 0x2e, 0x91, 0x28, 0xbc, 0x01, 0xf3, 0x1d, 0x3b, 0xb0, 0x3d, 0x1a, 0x71, 0x7d, 0xa6, + 0x3c, 0xb3, 0x56, 0xa8, 0x96, 0xc7, 0x31, 0x9e, 0x52, 0xdf, 0x3b, 0x16, 0xd4, 0xdd, 0xa7, 0x34, + 0x22, 0x03, 0x06, 0x7e, 0x0a, 0x4b, 0x01, 0x15, 0x2f, 0x58, 0xd4, 0x3e, 0x6a, 0x31, 0x26, 0xb8, + 0x88, 0xec, 0xf0, 0xa8, 0x4d, 0x7b, 0x5c, 0xcf, 0x49, 0xad, 0x77, 0xc6, 0x69, 0x35, 0x02, 0x27, + 0xea, 0xc9, 0x68, 0x1e, 0xd0, 0x1e, 0xb9, 0xad, 0x04, 0x6a, 0x29, 0xff, 0x01, 0xed, 0x71, 0xbc, + 0x04, 0x1a, 0x61, 0x4c, 0x6c, 0x6f, 0xe9, 0xb3, 0x65, 0xb4, 0xb6, 0x40, 0xd4, 0x93, 0xf9, 0x05, + 0x14, 0x77, 0xa8, 0x1d, 0x89, 0x16, 0xb5, 0x45, 0x5a, 0xa6, 0x6b, 0xc5, 0x63, 0xee, 0xc3, 0x9b, + 0x23, 0x0a, 0x3c, 0x64, 0x01, 0xa7, 0xf8, 0x33, 0xd0, 0x42, 0x1a, 0xf9, 0xcc, 0x55, 0x45, 0x7e, + 0xdb, 0x4a, 0xba, 0xc5, 0x4a, 0xbb, 0xc5, 0xaa, 0xab, 0x6e, 0xa9, 0xcd, 0x9f, 0x9d, 0x2f, 0x67, + 0x4e, 0xff, 0x5a, 0x46, 0x44, 0x51, 0xcc, 0x1f, 0xb3, 0xf0, 0xd6, 0xe3, 0xd0, 0xb5, 0x05, 0x3d, + 0xb4, 0x79, 0xfb, 0x40, 0xd8, 0xa2, 0xcb, 0x6f, 0xe4, 0x0d, 0x3f, 0x81, 0xb9, 0xae, 0x14, 0x4a, + 0x6b, 0xb1, 0x31, 0x2e, 0xbf, 0x09, 0x67, 0x59, 0xc3, 0x95, 0x04, 0x41, 0x52, 0x31, 0x83, 0x41, + 0xf1, 0xe2, 0x26, 0x5e, 0x81, 0x39, 0x61, 0xf3, 0xf6, 0xd0, 0x16, 0xf4, 0xcf, 0x97, 0xb5, 0x18, + 0xd6, 0xac, 0x13, 0x2d, 0xde, 0x6a, 0xba, 0xf8, 0x13, 0xd0, 0xb8, 0x24, 0xa9, 0x6e, 0x2a, 0x8d, + 0xf3, 0x33, 0xe2, 0x44, 0xa1, 0x4d, 0x03, 0xf4, 0xd7, 0x5d, 0x26, 0x59, 0x9b, 0x1b, 0xb0, 0x10, + 0xaf, 0xde, 0x2c, 0x22, 0x73, 0x53, 0xb1, 0xd3, 0x6f, 0xc3, 0x82, 0xd9, 0xd8, 0x2b, 0xd7, 0x91, + 0x0c, 0x4c, 0x9f, 0x64, 0x90, 0x24, 0x30, 0xb3, 0x06, 0x78, 0x8b, 0x73, 0xdf, 0x0b, 0x3a, 0x34, + 0x10, 0x37, 0xf4, 0xf0, 0x1b, 0x02, 0x18, 0x8a, 0x60, 0x0b, 0x72, 0xb1, 0xb6, 0x6a, 0x9d, 0x89, + 0x0e, 0x76, 0x32, 0x44, 0xe2, 0xf0, 0x47, 0xa0, 0x71, 0xea, 0x44, 0x54, 0xa8, 0x50, 0x8d, 0x71, + 0x8c, 0x03, 0x89, 0xd8, 0xc9, 0x10, 0x85, 0x8d, 0x59, 0x0e, 0x0b, 0x9e, 0xf9, 0x9e, 0x3e, 0x33, + 0x99, 0xb5, 0x2d, 0x11, 0x31, 0x2b, 0xc1, 0xd6, 0x34, 0xc8, 0xf9, 0x82, 0x76, 0xcc, 0x97, 0x59, + 0x28, 0x0e, 0x2d, 0x6f, 0x1f, 0xdb, 0x81, 0x47, 0xf1, 0x26, 0x80, 0x3d, 0x58, 0x53, 0xf6, 0xc7, + 0x56, 0x78, 0xc8, 0x24, 0x23, 0x0c, 0xbc, 0x0b, 0x9a, 0xed, 0xc8, 0xd1, 0x18, 0xbf, 0xc8, 0x62, + 0xf5, 0xe3, 0xcb, 0xb9, 0xc9, 0xa9, 0x23, 0x0b, 0x5b, 0x92, 0x4c, 0x94, 0x88, 0xd9, 0x1a, 0xb5, + 0x98, 0xec, 0xe1, 0x55, 0xd0, 0x1e, 0xef, 0xd7, 0xb7, 0x0e, 0x1b, 0xc5, 0x8c, 0x61, 0xfc, 0xf0, + 0x4b, 0x79, 0xe9, 0x22, 0x42, 0x75, 0xf3, 0x2a, 0x68, 0xa4, 0xb1, 0xfb, 0xe8, 0x49, 0xa3, 0x88, + 0xc6, 0xe3, 0x08, 0xed, 0xb0, 0xe7, 0xd4, 0xfc, 0x17, 0xfd, 0xaf, 0xfe, 0x69, 0x17, 0x7d, 0x0e, + 0xb9, 0xf8, 0xa2, 0x92, 0x19, 0x2c, 0x56, 0xef, 0x5d, 0xfe, 0x1e, 0x29, 0xcb, 0x3a, 0xec, 0x85, + 0x94, 0x48, 0x22, 0xbe, 0x03, 0x60, 0x87, 0xe1, 0x89, 0x4f, 0xf9, 0x91, 0x60, 0xc9, 0x8c, 0x27, + 0x79, 0xb5, 0x72, 0xc8, 0xe2, 0xed, 0x88, 0xf2, 0xee, 0x89, 0xe0, 0x47, 0x7e, 0x20, 0x0b, 0x98, + 0x27, 0x79, 0xb5, 0xd2, 0x0c, 0xf0, 0x26, 0xcc, 0x39, 0x32, 0x9c, 0x74, 0x6e, 0xbe, 0x3b, 0x4d, + 0x92, 0x24, 0x25, 0x99, 0x77, 0x21, 0x17, 0x7b, 0xc1, 0x0b, 0x30, 0xbf, 0xfd, 0x68, 0x77, 0xff, + 0x61, 0x23, 0xce, 0x0b, 0xbf, 0x01, 0x85, 0xe6, 0xde, 0x36, 0x69, 0xec, 0x36, 0xf6, 0x0e, 0xb7, + 0x1e, 0x16, 0x51, 0xf5, 0x74, 0x16, 0xa0, 0x3e, 0xb8, 0xd4, 0xf1, 0xd7, 0x30, 0xa7, 0xda, 0x1b, + 0x9b, 0xe3, 0x5b, 0x70, 0xf4, 0x36, 0x34, 0x2e, 0xc3, 0xa8, 0x44, 0xcc, 0x95, 0xdf, 0x7f, 0xfd, + 0xe7, 0x34, 0x7b, 0x07, 0x16, 0x24, 0xe6, 0xfd, 0x78, 0xae, 0xd3, 0x08, 0x6e, 0x25, 0x4f, 0xea, + 0xd6, 0xb8, 0x8f, 0xf0, 0x37, 0x90, 0x1f, 0xcc, 0x60, 0x3c, 0xf6, 0x5d, 0x2f, 0x0e, 0x79, 0xe3, + 0xee, 0x15, 0x28, 0x35, 0x5c, 0xa6, 0x31, 0x80, 0x7f, 0x42, 0x50, 0xbc, 0x38, 0x9e, 0xf0, 0xbd, + 0x6b, 0x8c, 0x5a, 0x63, 0x7d, 0x3a, 0xf0, 0x75, 0x4c, 0x75, 0x61, 0x56, 0x0e, 0x36, 0x5c, 0x9e, + 0x34, 0x40, 0x06, 0xa7, 0x4f, 0x46, 0xa4, 0x75, 0x58, 0x9d, 0xe2, 0xc4, 0xef, 0xb3, 0xe8, 0x3e, + 0xc2, 0xdf, 0x21, 0x28, 0x8c, 0xb4, 0x36, 0x5e, 0xbd, 0xa2, 0xf7, 0x53, 0x0f, 0xab, 0xd3, 0x7d, + 0x23, 0x53, 0x76, 0x44, 0x4d, 0x3f, 0x7b, 0x55, 0xca, 0xfc, 0xf9, 0xaa, 0x94, 0xf9, 0xb6, 0x5f, + 0x42, 0x67, 0xfd, 0x12, 0xfa, 0xa3, 0x5f, 0x42, 0x7f, 0xf7, 0x4b, 0xa8, 0xa5, 0xc9, 0x2b, 0xf8, + 0xc3, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe0, 0xf0, 0x6a, 0xcb, 0xae, 0x0a, 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/dispatcher.proto b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/dispatcher.proto index 505a80baa..232580ec4 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/dispatcher.proto +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/dispatcher.proto @@ -2,10 +2,10 @@ syntax = "proto3"; package docker.swarmkit.v1; -import "types.proto"; -import "objects.proto"; +import "github.com/docker/swarmkit/api/types.proto"; +import "github.com/docker/swarmkit/api/objects.proto"; import "gogoproto/gogo.proto"; -import "plugin/plugin.proto"; +import "github.com/docker/swarmkit/protobuf/plugin/plugin.proto"; import "google/protobuf/duration.proto"; // Dispatcher is the API provided by a manager group for agents to connect to. Agents diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/gen.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/gen.go deleted file mode 100644 index 5a0bd3306..000000000 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/gen.go +++ /dev/null @@ -1,3 +0,0 @@ -package api - -//go:generate protoc -I.:../protobuf:../vendor:../vendor/github.com/gogo/protobuf --gogoswarm_out=plugins=grpc+deepcopy+storeobject+raftproxy+authenticatedwrapper,import_path=github.com/docker/swarmkit/api,Mgogoproto/gogo.proto=github.com/gogo/protobuf/gogoproto,Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor,Mplugin/plugin.proto=github.com/docker/swarmkit/protobuf/plugin,Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types:. types.proto specs.proto objects.proto control.proto dispatcher.proto ca.proto snapshot.proto raft.proto health.proto resource.proto logbroker.proto watch.proto diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/health.pb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/health.pb.go index 500e45b0d..757db6acb 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/health.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/health.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. -// source: health.proto +// source: github.com/docker/swarmkit/api/health.proto // DO NOT EDIT! package api @@ -198,7 +198,7 @@ var _Health_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "health.proto", + Metadata: "github.com/docker/swarmkit/api/health.proto", } func (m *HealthCheckRequest) Marshal() (dAtA []byte, err error) { @@ -696,26 +696,28 @@ var ( ErrIntOverflowHealth = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("health.proto", fileDescriptorHealth) } +func init() { proto.RegisterFile("github.com/docker/swarmkit/api/health.proto", fileDescriptorHealth) } var fileDescriptorHealth = []byte{ - // 287 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xc9, 0x48, 0x4d, 0xcc, - 0x29, 0xc9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x4a, 0xc9, 0x4f, 0xce, 0x4e, 0x2d, - 0xd2, 0x2b, 0x2e, 0x4f, 0x2c, 0xca, 0xcd, 0xce, 0x2c, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, - 0x4f, 0xcf, 0x07, 0x4b, 0xeb, 0x83, 0x58, 0x10, 0x95, 0x52, 0xc2, 0x05, 0x39, 0xa5, 0xe9, 0x99, - 0x79, 0xfa, 0x10, 0x0a, 0x22, 0xa8, 0xa4, 0xc7, 0x25, 0xe4, 0x01, 0x36, 0xce, 0x39, 0x23, 0x35, - 0x39, 0x3b, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, 0x48, 0x82, 0x8b, 0xbd, 0x38, 0xb5, 0xa8, - 0x2c, 0x33, 0x39, 0x55, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x08, 0xc6, 0x55, 0x5a, 0xc0, 0xc8, - 0x25, 0x8c, 0xa2, 0xa1, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0xc8, 0x97, 0x8b, 0xad, 0xb8, 0x24, - 0xb1, 0xa4, 0xb4, 0x18, 0xac, 0x81, 0xcf, 0xc8, 0x54, 0x0f, 0xd3, 0x5d, 0x7a, 0x58, 0x34, 0xea, - 0x05, 0x83, 0x0c, 0xce, 0x4b, 0x0f, 0x06, 0x6b, 0x0e, 0x82, 0x1a, 0xa2, 0x64, 0xc5, 0xc5, 0x8b, - 0x22, 0x21, 0xc4, 0xcd, 0xc5, 0x1e, 0xea, 0xe7, 0xed, 0xe7, 0x1f, 0xee, 0x27, 0xc0, 0x00, 0xe2, - 0x04, 0xbb, 0x06, 0x85, 0x79, 0xfa, 0xb9, 0x0b, 0x30, 0x0a, 0xf1, 0x73, 0x71, 0xfb, 0xf9, 0x87, - 0xc4, 0xc3, 0x04, 0x98, 0x8c, 0x2a, 0xb9, 0xd8, 0x20, 0x16, 0x09, 0xe5, 0x73, 0xb1, 0x82, 0x2d, - 0x13, 0x52, 0x23, 0xe8, 0x1a, 0xb0, 0xbf, 0xa5, 0xd4, 0x89, 0x74, 0xb5, 0x92, 0xe8, 0xa9, 0x75, - 0xef, 0x66, 0x30, 0xf1, 0x73, 0xf1, 0x82, 0x15, 0xea, 0xe6, 0x26, 0xe6, 0x25, 0xa6, 0xa7, 0x16, - 0x39, 0x49, 0x9c, 0x78, 0x28, 0xc7, 0x70, 0xe3, 0xa1, 0x1c, 0x43, 0xc3, 0x23, 0x39, 0xc6, 0x13, - 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x31, 0x89, 0x0d, 0x1c, 0xdc, - 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x59, 0xcd, 0x52, 0xee, 0xbd, 0x01, 0x00, 0x00, + // 315 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4e, 0xcf, 0x2c, 0xc9, + 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xc9, 0x4f, 0xce, 0x4e, 0x2d, 0xd2, 0x2f, 0x2e, + 0x4f, 0x2c, 0xca, 0xcd, 0xce, 0x2c, 0xd1, 0x4f, 0x2c, 0xc8, 0xd4, 0xcf, 0x48, 0x4d, 0xcc, 0x29, + 0xc9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0xa8, 0xd0, 0x83, 0xa9, 0xd0, 0x2b, + 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, 0xeb, 0x83, 0x58, 0x10, 0x95, 0x52, 0xe6, + 0x78, 0x8c, 0x05, 0xab, 0x48, 0x2a, 0x4d, 0xd3, 0x2f, 0xc8, 0x29, 0x4d, 0xcf, 0xcc, 0x83, 0x52, + 0x10, 0x8d, 0x4a, 0x7a, 0x5c, 0x42, 0x1e, 0x60, 0x2b, 0x9d, 0x33, 0x52, 0x93, 0xb3, 0x83, 0x52, + 0x0b, 0x4b, 0x53, 0x8b, 0x4b, 0x84, 0x24, 0xb8, 0xd8, 0x8b, 0x53, 0x8b, 0xca, 0x32, 0x93, 0x53, + 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x60, 0x5c, 0xa5, 0x05, 0x8c, 0x5c, 0xc2, 0x28, 0x1a, + 0x8a, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x85, 0x7c, 0xb9, 0xd8, 0x8a, 0x4b, 0x12, 0x4b, 0x4a, 0x8b, + 0xc1, 0x1a, 0xf8, 0x8c, 0x4c, 0xf5, 0x30, 0xdd, 0xae, 0x87, 0x45, 0xa3, 0x5e, 0x30, 0xc8, 0xe0, + 0xbc, 0xf4, 0x60, 0xb0, 0xe6, 0x20, 0xa8, 0x21, 0x4a, 0x56, 0x5c, 0xbc, 0x28, 0x12, 0x42, 0xdc, + 0x5c, 0xec, 0xa1, 0x7e, 0xde, 0x7e, 0xfe, 0xe1, 0x7e, 0x02, 0x0c, 0x20, 0x4e, 0xb0, 0x6b, 0x50, + 0x98, 0xa7, 0x9f, 0xbb, 0x00, 0xa3, 0x10, 0x3f, 0x17, 0xb7, 0x9f, 0x7f, 0x48, 0x3c, 0x4c, 0x80, + 0xc9, 0xa8, 0x92, 0x8b, 0x0d, 0x62, 0x91, 0x50, 0x3e, 0x17, 0x2b, 0xd8, 0x32, 0x21, 0x35, 0x82, + 0xae, 0x01, 0xfb, 0x5b, 0x4a, 0x9d, 0x48, 0x57, 0x2b, 0x89, 0x9e, 0x5a, 0xf7, 0x6e, 0x06, 0x13, + 0x3f, 0x17, 0x2f, 0x58, 0xa1, 0x6e, 0x6e, 0x62, 0x5e, 0x62, 0x7a, 0x6a, 0x91, 0x93, 0xc4, 0x89, + 0x87, 0x72, 0x0c, 0x37, 0x1e, 0xca, 0x31, 0x34, 0x3c, 0x92, 0x63, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, + 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x93, 0xd8, 0xc0, 0xc1, 0x6d, 0x0c, 0x08, 0x00, + 0x00, 0xff, 0xff, 0x7b, 0xf2, 0xdd, 0x23, 0x00, 0x02, 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/health.proto b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/health.proto index 5edb38bde..8e066c0f8 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/health.proto +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/health.proto @@ -12,7 +12,7 @@ syntax = "proto3"; package docker.swarmkit.v1; import "gogoproto/gogo.proto"; -import "plugin/plugin.proto"; +import "github.com/docker/swarmkit/protobuf/plugin/plugin.proto"; service Health { rpc Check(HealthCheckRequest) returns (HealthCheckResponse) { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/logbroker.pb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/logbroker.pb.go index 6a22eca89..58515aa11 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/logbroker.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/logbroker.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. -// source: logbroker.proto +// source: github.com/docker/swarmkit/api/logbroker.proto // DO NOT EDIT! package api @@ -618,7 +618,7 @@ var _Logs_serviceDesc = grpc.ServiceDesc{ ServerStreams: true, }, }, - Metadata: "logbroker.proto", + Metadata: "github.com/docker/swarmkit/api/logbroker.proto", } // Client API for LogBroker service @@ -790,7 +790,7 @@ var _LogBroker_serviceDesc = grpc.ServiceDesc{ ClientStreams: true, }, }, - Metadata: "logbroker.proto", + Metadata: "github.com/docker/swarmkit/api/logbroker.proto", } func (m *LogSubscriptionOptions) Marshal() (dAtA []byte, err error) { @@ -3350,67 +3350,71 @@ var ( ErrIntOverflowLogbroker = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("logbroker.proto", fileDescriptorLogbroker) } +func init() { + proto.RegisterFile("github.com/docker/swarmkit/api/logbroker.proto", fileDescriptorLogbroker) +} var fileDescriptorLogbroker = []byte{ - // 944 bytes of a gzipped FileDescriptorProto + // 966 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0x41, 0x6f, 0x1b, 0x45, - 0x14, 0xc7, 0x3d, 0xeb, 0xc4, 0x8e, 0x9f, 0x9b, 0xc4, 0x1d, 0xa7, 0x91, 0x65, 0xa8, 0x6d, 0x6d, - 0xa5, 0x62, 0x45, 0xc5, 0x6e, 0x8d, 0x10, 0x48, 0x91, 0x10, 0x35, 0xae, 0x90, 0x85, 0x9b, 0xa0, - 0xb1, 0x23, 0xb8, 0x45, 0x6b, 0xef, 0x74, 0x59, 0x79, 0xbd, 0x63, 0x76, 0xc6, 0x09, 0x48, 0x1c, - 0x38, 0x14, 0x09, 0xe5, 0xc0, 0x0d, 0x09, 0x0e, 0x3d, 0xd1, 0x0b, 0x42, 0xe2, 0xc2, 0x8d, 0x0f, - 0x80, 0x22, 0x4e, 0x1c, 0x39, 0x59, 0x74, 0x3f, 0x00, 0x9f, 0x01, 0xed, 0xcc, 0xd8, 0xde, 0x60, - 0xbb, 0x45, 0xe5, 0x92, 0xcc, 0xec, 0xfc, 0xdf, 0xbe, 0xdf, 0xfb, 0xcf, 0x7b, 0x6b, 0xd8, 0xf5, - 0x98, 0xd3, 0x0f, 0xd8, 0x90, 0x06, 0xb5, 0x71, 0xc0, 0x04, 0xc3, 0xd8, 0x66, 0x83, 0x68, 0xc7, - 0xcf, 0xad, 0x60, 0x34, 0x74, 0x45, 0xed, 0xec, 0x5e, 0x71, 0xcf, 0x61, 0x0e, 0x93, 0xc7, 0xf5, - 0x68, 0xa5, 0x94, 0xc5, 0xb2, 0xc3, 0x98, 0xe3, 0xd1, 0xba, 0xdc, 0xf5, 0x27, 0x8f, 0xea, 0xc2, - 0x1d, 0x51, 0x2e, 0xac, 0xd1, 0x58, 0x0b, 0xf2, 0x63, 0x6f, 0xe2, 0xb8, 0x7e, 0x5d, 0xfd, 0x53, - 0x0f, 0xcd, 0x5f, 0x10, 0xec, 0x77, 0x98, 0xd3, 0x9d, 0xf4, 0xf9, 0x20, 0x70, 0xc7, 0xc2, 0x65, - 0xfe, 0xb1, 0xfc, 0xcb, 0xf1, 0x21, 0xa4, 0xb9, 0x08, 0xa8, 0x35, 0xe2, 0x05, 0x54, 0x49, 0x56, - 0x77, 0x1a, 0x37, 0x6b, 0xcb, 0x30, 0xb5, 0x28, 0x58, 0xaa, 0x9a, 0x46, 0x2e, 0x41, 0x66, 0x11, - 0x78, 0x1f, 0x52, 0x8f, 0x98, 0xe7, 0xb1, 0xf3, 0x82, 0x51, 0x41, 0xd5, 0x2d, 0xa2, 0x77, 0x18, - 0xc3, 0x86, 0xb0, 0x5c, 0xaf, 0x90, 0xac, 0xa0, 0x6a, 0x92, 0xc8, 0x35, 0xbe, 0x0b, 0x9b, 0xdc, - 0xf5, 0x07, 0xb4, 0xb0, 0x51, 0x41, 0xd5, 0x6c, 0xa3, 0x58, 0x53, 0x95, 0xd4, 0x66, 0x95, 0xd4, - 0x7a, 0xb3, 0x4a, 0x88, 0x12, 0x9a, 0xdf, 0x20, 0xc8, 0x46, 0x89, 0xa9, 0x47, 0x07, 0x82, 0x05, - 0xb8, 0x0e, 0x59, 0x4e, 0x83, 0x33, 0x77, 0x40, 0x4f, 0x5d, 0x5b, 0xe1, 0x66, 0x9a, 0x3b, 0xe1, - 0xb4, 0x0c, 0x5d, 0xf5, 0xb8, 0xdd, 0xe2, 0x04, 0xb4, 0xa4, 0x6d, 0x73, 0x7c, 0x1b, 0xb6, 0x7c, - 0x66, 0x2b, 0xb5, 0x21, 0xd5, 0xd9, 0x70, 0x5a, 0x4e, 0x1f, 0x31, 0x5b, 0x4a, 0xd3, 0xd1, 0xa1, - 0xd6, 0x09, 0x8b, 0x0f, 0xa5, 0x2e, 0xb9, 0xd0, 0xf5, 0x2c, 0x3e, 0x94, 0xba, 0xe8, 0xb0, 0x6d, - 0x73, 0xf3, 0x31, 0x02, 0xe8, 0x30, 0xe7, 0x3d, 0xe6, 0x0b, 0xfa, 0x99, 0xc0, 0x77, 0x00, 0x16, - 0x3c, 0x05, 0x54, 0x41, 0xd5, 0x4c, 0x73, 0x3b, 0x9c, 0x96, 0x33, 0x73, 0x1c, 0x92, 0x99, 0xd3, - 0xe0, 0x5b, 0x90, 0xd6, 0x30, 0xd2, 0xac, 0x4c, 0x13, 0xc2, 0x69, 0x39, 0xa5, 0x58, 0x48, 0x4a, - 0xa1, 0x44, 0x22, 0x4d, 0x22, 0xbd, 0xd3, 0x22, 0x05, 0x42, 0x52, 0x8a, 0xc3, 0xbc, 0x07, 0xe9, - 0x0e, 0x73, 0xee, 0x0b, 0x11, 0xe0, 0x1c, 0x24, 0x87, 0xf4, 0x73, 0x95, 0x9b, 0x44, 0x4b, 0xbc, - 0x07, 0x9b, 0x67, 0x96, 0x37, 0xa1, 0x2a, 0x09, 0x51, 0x1b, 0xf3, 0xc2, 0x90, 0xe4, 0x0f, 0x29, - 0xe7, 0x96, 0x43, 0xf1, 0x3b, 0x90, 0x1e, 0xa8, 0x22, 0x64, 0x68, 0xb6, 0x51, 0x5a, 0x73, 0xe9, - 0xba, 0xd4, 0xe6, 0xc6, 0xe5, 0xb4, 0x9c, 0x20, 0xb3, 0x20, 0xfc, 0x36, 0x64, 0xe6, 0x7d, 0x27, - 0x13, 0x3d, 0xff, 0x3e, 0x17, 0x62, 0xfc, 0x26, 0xa4, 0x54, 0xf3, 0xc8, 0xfa, 0x5e, 0xd4, 0x6d, - 0x44, 0x8b, 0xa3, 0x86, 0xb2, 0x2d, 0x61, 0xc9, 0xde, 0xb9, 0x46, 0xe4, 0x1a, 0xbf, 0x05, 0x9b, - 0x96, 0x10, 0x01, 0x2f, 0x6c, 0x56, 0x92, 0xd5, 0x6c, 0xe3, 0x95, 0x35, 0x6f, 0x8a, 0x7c, 0xd2, - 0xfc, 0x4a, 0x6f, 0x7e, 0x8f, 0x60, 0x4f, 0x8f, 0x42, 0x9f, 0x76, 0x98, 0xc3, 0x09, 0xfd, 0x74, - 0x42, 0xb9, 0xc0, 0x87, 0xb0, 0xc5, 0x75, 0xb3, 0x69, 0x5f, 0xca, 0xeb, 0xf0, 0xb4, 0x8c, 0xcc, - 0x03, 0x70, 0x0b, 0xd2, 0x4c, 0xcd, 0x94, 0x76, 0xe4, 0x60, 0x5d, 0xec, 0xf2, 0x14, 0x92, 0x59, - 0xa8, 0xf9, 0xf1, 0xbf, 0xd0, 0x66, 0x37, 0xf6, 0x2e, 0x6c, 0x8d, 0xd4, 0x52, 0x35, 0xfe, 0xfa, - 0x2b, 0xd3, 0x11, 0xba, 0xe4, 0x79, 0x94, 0xf9, 0x2a, 0x14, 0x3b, 0x2e, 0x17, 0xd4, 0x8f, 0xe7, - 0x9f, 0x95, 0x6e, 0xfe, 0x86, 0x20, 0x1f, 0x3f, 0x98, 0xe5, 0xdd, 0x07, 0x63, 0xde, 0xdb, 0xa9, - 0x70, 0x5a, 0x36, 0xda, 0x2d, 0x62, 0xb8, 0xf6, 0x15, 0xab, 0x8c, 0xff, 0x61, 0x55, 0xf2, 0xa5, - 0xad, 0x8a, 0x3a, 0x7d, 0xe0, 0x31, 0xae, 0x3e, 0x28, 0x5b, 0x44, 0x6d, 0xcc, 0x1f, 0x11, 0xe0, - 0x0f, 0x27, 0x7d, 0xcf, 0xe5, 0x9f, 0xc4, 0xfd, 0x3b, 0x84, 0x5d, 0x1e, 0x7b, 0xd9, 0x62, 0x60, - 0x71, 0x38, 0x2d, 0xef, 0xc4, 0xf3, 0xb4, 0x5b, 0x64, 0x27, 0x2e, 0x6d, 0xdb, 0x57, 0xcc, 0x37, - 0x5e, 0xc6, 0xfc, 0x05, 0x6b, 0x32, 0xce, 0x7a, 0x03, 0xf2, 0x31, 0x54, 0x42, 0xf9, 0x98, 0xf9, - 0x9c, 0x1e, 0x3c, 0x45, 0x90, 0x99, 0x8f, 0x00, 0xbe, 0x03, 0xb8, 0x73, 0xfc, 0xfe, 0x69, 0xb7, - 0x47, 0x1e, 0xdc, 0x7f, 0x78, 0x7a, 0x72, 0xf4, 0xc1, 0xd1, 0xf1, 0x47, 0x47, 0xb9, 0x44, 0x71, - 0xef, 0xe2, 0x49, 0x25, 0x37, 0x97, 0x9d, 0xf8, 0x43, 0x9f, 0x9d, 0xfb, 0xf8, 0x00, 0xae, 0xc7, - 0xd4, 0xdd, 0x5e, 0xeb, 0xf8, 0xa4, 0x97, 0x43, 0xc5, 0xfc, 0xc5, 0x93, 0xca, 0xee, 0x5c, 0xdc, - 0x15, 0x36, 0x9b, 0x88, 0x65, 0xed, 0x03, 0x42, 0x72, 0xc6, 0xb2, 0x96, 0x06, 0x41, 0xf1, 0xfa, - 0xd7, 0x3f, 0x94, 0x12, 0xbf, 0x3e, 0x2d, 0x2d, 0xc0, 0x1a, 0x8f, 0x11, 0x6c, 0x44, 0xdc, 0xf8, - 0x0b, 0xd8, 0xbe, 0xd2, 0xb3, 0xb8, 0xba, 0xca, 0x9d, 0x55, 0x13, 0x57, 0x7c, 0xb1, 0x52, 0x3b, - 0x6a, 0xde, 0xf8, 0xfd, 0xe7, 0xbf, 0xbf, 0x33, 0x76, 0x61, 0x5b, 0x2a, 0x5f, 0x1f, 0x59, 0xbe, - 0xe5, 0xd0, 0xe0, 0x2e, 0x6a, 0xfc, 0x64, 0x48, 0xb7, 0x9a, 0xf2, 0xf7, 0x14, 0x7f, 0x8b, 0x20, - 0xbf, 0xa2, 0xcd, 0x71, 0x6d, 0xe5, 0x85, 0xad, 0x9d, 0x87, 0xe2, 0x6b, 0xcf, 0x01, 0x8b, 0x0f, - 0x88, 0x79, 0x4b, 0x72, 0xdd, 0x84, 0x6b, 0x8a, 0xeb, 0x9c, 0x05, 0x43, 0x1a, 0x2c, 0x51, 0xe2, - 0xaf, 0x10, 0x64, 0x63, 0x77, 0x8d, 0x6f, 0xaf, 0x7a, 0xff, 0x72, 0xdf, 0xae, 0xe6, 0x58, 0xd1, - 0x34, 0xff, 0x89, 0xa3, 0x8a, 0x9a, 0x85, 0xcb, 0x67, 0xa5, 0xc4, 0x9f, 0xcf, 0x4a, 0x89, 0x2f, - 0xc3, 0x12, 0xba, 0x0c, 0x4b, 0xe8, 0x8f, 0xb0, 0x84, 0xfe, 0x0a, 0x4b, 0xa8, 0x9f, 0x92, 0x1f, - 0xee, 0x37, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0x08, 0xa1, 0xea, 0xc7, 0x9d, 0x08, 0x00, 0x00, + 0x14, 0xc7, 0x3d, 0xeb, 0xc4, 0x8e, 0x9f, 0x9b, 0xc4, 0x9d, 0xa4, 0x91, 0x65, 0xa8, 0x6d, 0x6d, + 0xa5, 0x62, 0x45, 0x65, 0xdd, 0x1a, 0xa1, 0x22, 0x45, 0x42, 0xd4, 0xb8, 0x42, 0x16, 0x6e, 0x82, + 0xc6, 0x8e, 0xe0, 0x16, 0xad, 0xbd, 0xd3, 0xed, 0xca, 0xeb, 0x1d, 0xb3, 0x33, 0x4e, 0x40, 0xe2, + 0xc0, 0xa1, 0x48, 0x28, 0x07, 0x6e, 0x48, 0x70, 0xe8, 0x89, 0x5e, 0x10, 0x12, 0x17, 0x6e, 0x7c, + 0x00, 0x14, 0x71, 0xe2, 0xc8, 0xc9, 0xa2, 0xfb, 0x01, 0xf8, 0x0c, 0x68, 0x67, 0xd6, 0xeb, 0x0d, + 0xb6, 0x53, 0x54, 0x2e, 0xf6, 0x8c, 0xe7, 0xf7, 0xf6, 0xfd, 0xdf, 0x7f, 0xde, 0x5b, 0x83, 0x61, + 0x3b, 0xe2, 0xc9, 0xa4, 0x6f, 0x0c, 0xd8, 0xa8, 0x6e, 0xb1, 0xc1, 0x90, 0xfa, 0x75, 0x7e, 0x66, + 0xfa, 0xa3, 0xa1, 0x23, 0xea, 0xe6, 0xd8, 0xa9, 0xbb, 0xcc, 0xee, 0xfb, 0x6c, 0x48, 0x7d, 0x63, + 0xec, 0x33, 0xc1, 0x30, 0x56, 0x90, 0x31, 0x83, 0x8c, 0xd3, 0x7b, 0xa5, 0x5d, 0x9b, 0xd9, 0x4c, + 0x1e, 0xd7, 0xc3, 0x95, 0x22, 0x4b, 0x15, 0x9b, 0x31, 0xdb, 0xa5, 0x75, 0xb9, 0xeb, 0x4f, 0x1e, + 0xd7, 0x85, 0x33, 0xa2, 0x5c, 0x98, 0xa3, 0x71, 0x04, 0xdc, 0xbf, 0x22, 0x75, 0x1c, 0x34, 0x76, + 0x27, 0xb6, 0xe3, 0x45, 0x5f, 0x2a, 0x50, 0xff, 0x05, 0xc1, 0x5e, 0x87, 0xd9, 0xdd, 0x49, 0x9f, + 0x0f, 0x7c, 0x67, 0x2c, 0x1c, 0xe6, 0x1d, 0xc9, 0x4f, 0x8e, 0x0f, 0x20, 0xcb, 0x85, 0x4f, 0xcd, + 0x11, 0x2f, 0xa2, 0x6a, 0xba, 0xb6, 0xd5, 0xb8, 0x69, 0x2c, 0x0a, 0x36, 0xc2, 0x60, 0x49, 0x35, + 0xb5, 0x42, 0x8a, 0xcc, 0x22, 0xf0, 0x1e, 0x64, 0x1e, 0x33, 0xd7, 0x65, 0x67, 0x45, 0xad, 0x8a, + 0x6a, 0x1b, 0x24, 0xda, 0x61, 0x0c, 0x6b, 0xc2, 0x74, 0xdc, 0x62, 0xba, 0x8a, 0x6a, 0x69, 0x22, + 0xd7, 0xf8, 0x2e, 0xac, 0x73, 0xc7, 0x1b, 0xd0, 0xe2, 0x5a, 0x15, 0xd5, 0xf2, 0x8d, 0x92, 0xa1, + 0xaa, 0x35, 0x66, 0xc2, 0x8d, 0xde, 0xac, 0x5a, 0xa2, 0x40, 0xfd, 0x1b, 0x04, 0xf9, 0x30, 0x31, + 0x75, 0xe9, 0x40, 0x30, 0x1f, 0xd7, 0x21, 0xcf, 0xa9, 0x7f, 0xea, 0x0c, 0xe8, 0x89, 0x63, 0x29, + 0xb9, 0xb9, 0xe6, 0x56, 0x30, 0xad, 0x40, 0x57, 0xfd, 0xdc, 0x6e, 0x71, 0x02, 0x11, 0xd2, 0xb6, + 0x38, 0xbe, 0x0d, 0x1b, 0x1e, 0xb3, 0x14, 0xad, 0x49, 0x3a, 0x1f, 0x4c, 0x2b, 0xd9, 0x43, 0x66, + 0x49, 0x34, 0x1b, 0x1e, 0x46, 0x9c, 0x30, 0xf9, 0x50, 0x72, 0xe9, 0x39, 0xd7, 0x33, 0xf9, 0x50, + 0x72, 0xe1, 0x61, 0xdb, 0xe2, 0xfa, 0x53, 0x04, 0xd0, 0x61, 0xf6, 0xfb, 0xcc, 0x13, 0xf4, 0x33, + 0x81, 0xef, 0x00, 0xcc, 0xf5, 0x14, 0x51, 0x15, 0xd5, 0x72, 0xcd, 0xcd, 0x60, 0x5a, 0xc9, 0xc5, + 0x72, 0x48, 0x2e, 0x56, 0x83, 0x6f, 0x41, 0x36, 0x12, 0x23, 0xcd, 0xca, 0x35, 0x21, 0x98, 0x56, + 0x32, 0x4a, 0x0b, 0xc9, 0x28, 0x29, 0x21, 0x14, 0x29, 0x91, 0xde, 0x45, 0x90, 0x12, 0x42, 0x32, + 0x4a, 0x87, 0x7e, 0x0f, 0xb2, 0x1d, 0x66, 0x3f, 0x10, 0xc2, 0xc7, 0x05, 0x48, 0x0f, 0xe9, 0xe7, + 0x2a, 0x37, 0x09, 0x97, 0x78, 0x17, 0xd6, 0x4f, 0x4d, 0x77, 0x42, 0x55, 0x12, 0xa2, 0x36, 0xfa, + 0xb9, 0x26, 0x95, 0x3f, 0xa2, 0x9c, 0x9b, 0x36, 0xc5, 0xef, 0x42, 0x76, 0xa0, 0x8a, 0x90, 0xa1, + 0xf9, 0x46, 0x79, 0xc5, 0xa5, 0x47, 0xa5, 0x36, 0xd7, 0x2e, 0xa6, 0x95, 0x14, 0x99, 0x05, 0xe1, + 0x77, 0x20, 0x17, 0xf7, 0xa6, 0x4c, 0x74, 0xf5, 0x7d, 0xce, 0x61, 0xfc, 0x36, 0x64, 0x54, 0xf3, + 0xc8, 0xfa, 0x5e, 0xd6, 0x6d, 0x24, 0x82, 0xc3, 0x86, 0xb2, 0x4c, 0x61, 0xca, 0xde, 0xb9, 0x46, + 0xe4, 0x1a, 0xdf, 0x87, 0x75, 0x53, 0x08, 0x9f, 0x17, 0xd7, 0xab, 0xe9, 0x5a, 0xbe, 0xf1, 0xda, + 0x8a, 0x27, 0x85, 0x3e, 0x45, 0xfa, 0x15, 0xaf, 0x7f, 0x8f, 0x60, 0x37, 0x1a, 0x85, 0x3e, 0xed, + 0x30, 0x9b, 0x13, 0xfa, 0xe9, 0x84, 0x72, 0x81, 0x0f, 0x60, 0x83, 0x47, 0xcd, 0x16, 0xf9, 0x52, + 0x59, 0x25, 0x2f, 0xc2, 0x48, 0x1c, 0x80, 0x5b, 0x90, 0x65, 0x6a, 0xa6, 0x22, 0x47, 0xf6, 0x57, + 0xc5, 0x2e, 0x4e, 0x21, 0x99, 0x85, 0xea, 0x9f, 0xfc, 0x4b, 0xda, 0xec, 0xc6, 0xde, 0x83, 0x8d, + 0x91, 0x5a, 0xaa, 0xc6, 0x5f, 0x7d, 0x65, 0x51, 0x44, 0x54, 0x72, 0x1c, 0xa5, 0xbf, 0x0e, 0xa5, + 0x8e, 0xc3, 0x05, 0xf5, 0x92, 0xf9, 0x67, 0xa5, 0xeb, 0xbf, 0x21, 0xd8, 0x49, 0x1e, 0xcc, 0xf2, + 0xee, 0x81, 0x16, 0xf7, 0x76, 0x26, 0x98, 0x56, 0xb4, 0x76, 0x8b, 0x68, 0x8e, 0x75, 0xc9, 0x2a, + 0xed, 0x7f, 0x58, 0x95, 0x7e, 0x65, 0xab, 0xc2, 0x4e, 0x1f, 0xb8, 0x8c, 0xab, 0x17, 0xca, 0x06, + 0x51, 0x1b, 0xfd, 0x47, 0x04, 0xf8, 0xa3, 0x49, 0xdf, 0x75, 0xf8, 0x93, 0xa4, 0x7f, 0x07, 0xb0, + 0xcd, 0x13, 0x0f, 0x9b, 0x0f, 0x2c, 0x0e, 0xa6, 0x95, 0xad, 0x64, 0x9e, 0x76, 0x8b, 0x6c, 0x25, + 0xd1, 0xb6, 0x75, 0xc9, 0x7c, 0xed, 0x55, 0xcc, 0x9f, 0x6b, 0x4d, 0x27, 0xb5, 0xde, 0x80, 0x9d, + 0x84, 0x54, 0x42, 0xf9, 0x98, 0x79, 0x9c, 0xee, 0x3f, 0x47, 0x90, 0x8b, 0x47, 0x00, 0xdf, 0x01, + 0xdc, 0x39, 0xfa, 0xe0, 0xa4, 0xdb, 0x23, 0x0f, 0x1f, 0x3c, 0x3a, 0x39, 0x3e, 0xfc, 0xf0, 0xf0, + 0xe8, 0xe3, 0xc3, 0x42, 0xaa, 0xb4, 0x7b, 0xfe, 0xac, 0x5a, 0x88, 0xb1, 0x63, 0x6f, 0xe8, 0xb1, + 0x33, 0x0f, 0xef, 0xc3, 0xf5, 0x04, 0xdd, 0xed, 0xb5, 0x8e, 0x8e, 0x7b, 0x05, 0x54, 0xda, 0x39, + 0x7f, 0x56, 0xdd, 0x8e, 0xe1, 0xae, 0xb0, 0xd8, 0x44, 0x2c, 0xb2, 0x0f, 0x09, 0x29, 0x68, 0x8b, + 0x2c, 0xf5, 0xfd, 0xd2, 0xf5, 0xaf, 0x7f, 0x28, 0xa7, 0x7e, 0x7d, 0x5e, 0x9e, 0x0b, 0x6b, 0x3c, + 0x45, 0xb0, 0x16, 0xea, 0xc6, 0x5f, 0xc0, 0xe6, 0xa5, 0x9e, 0xc5, 0xb5, 0x65, 0xee, 0x2c, 0x9b, + 0xb8, 0xd2, 0xcb, 0xc9, 0xc8, 0x51, 0xfd, 0xc6, 0xef, 0x3f, 0xff, 0xfd, 0x9d, 0xb6, 0x0d, 0x9b, + 0x92, 0x7c, 0x73, 0x64, 0x7a, 0xa6, 0x4d, 0xfd, 0xbb, 0xa8, 0xf1, 0x93, 0x26, 0xdd, 0x6a, 0xca, + 0xff, 0x5c, 0xfc, 0x2d, 0x82, 0x9d, 0x25, 0x6d, 0x8e, 0x8d, 0xa5, 0x17, 0xb6, 0x72, 0x1e, 0x4a, + 0x6f, 0x5c, 0x21, 0x2c, 0x39, 0x20, 0xfa, 0x2d, 0xa9, 0xeb, 0x26, 0x5c, 0x53, 0xba, 0xce, 0x98, + 0x3f, 0xa4, 0xfe, 0x82, 0x4a, 0xfc, 0x15, 0x82, 0x7c, 0xe2, 0xae, 0xf1, 0xed, 0x65, 0xcf, 0x5f, + 0xec, 0xdb, 0xe5, 0x3a, 0x96, 0x34, 0xcd, 0x7f, 0xd2, 0x51, 0x43, 0xcd, 0xe2, 0xc5, 0x8b, 0x72, + 0xea, 0xcf, 0x17, 0xe5, 0xd4, 0x97, 0x41, 0x19, 0x5d, 0x04, 0x65, 0xf4, 0x47, 0x50, 0x46, 0x7f, + 0x05, 0x65, 0xd4, 0xcf, 0xc8, 0x17, 0xf7, 0x5b, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x95, 0x7b, + 0x3c, 0x04, 0xe0, 0x08, 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/logbroker.proto b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/logbroker.proto index b86b8e886..1549640d4 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/logbroker.proto +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/logbroker.proto @@ -4,7 +4,7 @@ package docker.swarmkit.v1; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; -import "plugin/plugin.proto"; +import "github.com/docker/swarmkit/protobuf/plugin/plugin.proto"; // LogStream defines the stream from which the log message came. enum LogStream { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/objects.pb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/objects.pb.go index b6a9389a6..cc1a6480f 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/objects.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/objects.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. -// source: objects.proto +// source: github.com/docker/swarmkit/api/objects.proto // DO NOT EDIT! package api @@ -57,6 +57,7 @@ type Node struct { // ManagerStatus provides the current status of the node's manager // component, if the node is a manager. ManagerStatus *ManagerStatus `protobuf:"bytes,6,opt,name=manager_status,json=managerStatus" json:"manager_status,omitempty"` + // DEPRECATED: Use lb_attachments to find the ingress network // The node attachment to the ingress network. Attachment *NetworkAttachment `protobuf:"bytes,7,opt,name=attachment" json:"attachment,omitempty"` // Certificate is the TLS certificate issued for the node, if any. @@ -71,6 +72,10 @@ type Node struct { // shows the privilege level that the CA would currently grant when // issuing or renewing the node's certificate. Role NodeRole `protobuf:"varint,9,opt,name=role,proto3,enum=docker.swarmkit.v1.NodeRole" json:"role,omitempty"` + // Each node uses the network attachment to set up an endpoint on the + // node to be used for load balancing. Each overlay network, including + // ingress network, will have an NetworkAttachment. + LbAttachments []*NetworkAttachment `protobuf:"bytes,10,rep,name=lb_attachments,json=lbAttachments" json:"lb_attachments,omitempty"` } func (m *Node) Reset() { *m = Node{} } @@ -403,6 +408,14 @@ func (m *Node) CopyFrom(src interface{}) { github_com_docker_swarmkit_api_deepcopy.Copy(m.Attachment, o.Attachment) } github_com_docker_swarmkit_api_deepcopy.Copy(&m.Certificate, &o.Certificate) + if o.LbAttachments != nil { + m.LbAttachments = make([]*NetworkAttachment, len(o.LbAttachments)) + for i := range m.LbAttachments { + m.LbAttachments[i] = &NetworkAttachment{} + github_com_docker_swarmkit_api_deepcopy.Copy(m.LbAttachments[i], o.LbAttachments[i]) + } + } + } func (m *Service) Copy() *Service { @@ -849,6 +862,18 @@ func (m *Node) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintObjects(dAtA, i, uint64(m.Role)) } + if len(m.LbAttachments) > 0 { + for _, msg := range m.LbAttachments { + dAtA[i] = 0x52 + i++ + i = encodeVarintObjects(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } return i, nil } @@ -1670,6 +1695,12 @@ func (m *Node) Size() (n int) { if m.Role != 0 { n += 1 + sovObjects(uint64(m.Role)) } + if len(m.LbAttachments) > 0 { + for _, e := range m.LbAttachments { + l = e.Size() + n += 1 + l + sovObjects(uint64(l)) + } + } return n } @@ -4383,6 +4414,7 @@ func (this *Node) String() string { `Attachment:` + strings.Replace(fmt.Sprintf("%v", this.Attachment), "NetworkAttachment", "NetworkAttachment", 1) + `,`, `Certificate:` + strings.Replace(strings.Replace(this.Certificate.String(), "Certificate", "Certificate", 1), `&`, ``, 1) + `,`, `Role:` + fmt.Sprintf("%v", this.Role) + `,`, + `LbAttachments:` + strings.Replace(fmt.Sprintf("%v", this.LbAttachments), "NetworkAttachment", "NetworkAttachment", 1) + `,`, `}`, }, "") return s @@ -5017,6 +5049,37 @@ func (m *Node) Unmarshal(dAtA []byte) error { break } } + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LbAttachments", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowObjects + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthObjects + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LbAttachments = append(m.LbAttachments, &NetworkAttachment{}) + if err := m.LbAttachments[len(m.LbAttachments)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipObjects(dAtA[iNdEx:]) @@ -7686,102 +7749,104 @@ var ( ErrIntOverflowObjects = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("objects.proto", fileDescriptorObjects) } +func init() { proto.RegisterFile("github.com/docker/swarmkit/api/objects.proto", fileDescriptorObjects) } var fileDescriptorObjects = []byte{ - // 1491 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x6f, 0x1b, 0x4f, - 0x15, 0xef, 0xda, 0x1b, 0xff, 0x78, 0x4e, 0x4c, 0x98, 0x86, 0xb0, 0x35, 0xc1, 0x0e, 0xae, 0x40, - 0x15, 0xaa, 0x9c, 0x12, 0x0a, 0x4a, 0x03, 0xa5, 0xb5, 0x93, 0xa8, 0xb5, 0x4a, 0x69, 0x34, 0x2d, - 0x2d, 0xb7, 0x65, 0xb2, 0x3b, 0x75, 0x17, 0xaf, 0x77, 0x56, 0x3b, 0x63, 0x17, 0xdf, 0x38, 0x87, - 0x3f, 0x20, 0x37, 0x0e, 0xfd, 0x17, 0xe0, 0xc2, 0x85, 0x03, 0xa7, 0x1e, 0x39, 0x21, 0x4e, 0x11, - 0xf5, 0x7f, 0x81, 0xc4, 0xe1, 0xab, 0x99, 0x9d, 0xb5, 0x37, 0xf1, 0x3a, 0x49, 0xbf, 0xaa, 0xa2, - 0xef, 0x29, 0x33, 0x3b, 0x9f, 0xcf, 0x9b, 0xf7, 0xde, 0xbc, 0x5f, 0x31, 0xac, 0xb0, 0xa3, 0x3f, - 0x50, 0x47, 0xf0, 0x56, 0x18, 0x31, 0xc1, 0x10, 0x72, 0x99, 0xd3, 0xa7, 0x51, 0x8b, 0xbf, 0x27, - 0xd1, 0xa0, 0xef, 0x89, 0xd6, 0xe8, 0x27, 0xb5, 0x8a, 0x18, 0x87, 0x54, 0x03, 0x6a, 0x15, 0x1e, - 0x52, 0x27, 0xd9, 0x34, 0x7a, 0x8c, 0xf5, 0x7c, 0xba, 0xa5, 0x76, 0x47, 0xc3, 0xb7, 0x5b, 0xc2, - 0x1b, 0x50, 0x2e, 0xc8, 0x20, 0xd4, 0x80, 0xb5, 0x1e, 0xeb, 0x31, 0xb5, 0xdc, 0x92, 0x2b, 0xfd, - 0xf5, 0xd6, 0x79, 0x1a, 0x09, 0xc6, 0xfa, 0xe8, 0x66, 0xe8, 0x0f, 0x7b, 0x5e, 0xb0, 0x15, 0xff, - 0x89, 0x3f, 0x36, 0xff, 0x6e, 0x80, 0xf9, 0x9c, 0x0a, 0x82, 0x7e, 0x01, 0xc5, 0x11, 0x8d, 0xb8, - 0xc7, 0x02, 0xcb, 0xd8, 0x34, 0xee, 0x54, 0xb6, 0xbf, 0xd7, 0x9a, 0xd7, 0xb7, 0xf5, 0x3a, 0x86, - 0x74, 0xcc, 0x8f, 0xa7, 0x8d, 0x1b, 0x38, 0x61, 0xa0, 0x07, 0x00, 0x4e, 0x44, 0x89, 0xa0, 0xae, - 0x4d, 0x84, 0x95, 0x53, 0xfc, 0x5a, 0x2b, 0x56, 0xa5, 0x95, 0xa8, 0xd2, 0x7a, 0x95, 0x58, 0x80, - 0xcb, 0x1a, 0xdd, 0x16, 0x92, 0x3a, 0x0c, 0xdd, 0x84, 0x9a, 0xbf, 0x9c, 0xaa, 0xd1, 0x6d, 0xd1, - 0xfc, 0xab, 0x09, 0xe6, 0x6f, 0x98, 0x4b, 0xd1, 0x3a, 0xe4, 0x3c, 0x57, 0xa9, 0x5d, 0xee, 0x14, - 0x26, 0xa7, 0x8d, 0x5c, 0x77, 0x1f, 0xe7, 0x3c, 0x17, 0x6d, 0x83, 0x39, 0xa0, 0x82, 0x68, 0x85, - 0xac, 0x2c, 0x83, 0xa4, 0xed, 0xda, 0x1a, 0x85, 0x45, 0x3f, 0x07, 0x53, 0x3e, 0x83, 0xd6, 0x64, - 0x23, 0x8b, 0x23, 0xef, 0x7c, 0x19, 0x52, 0x27, 0xe1, 0x49, 0x3c, 0x3a, 0x80, 0x8a, 0x4b, 0xb9, - 0x13, 0x79, 0xa1, 0x90, 0x3e, 0x34, 0x15, 0xfd, 0xf6, 0x22, 0xfa, 0xfe, 0x0c, 0x8a, 0xd3, 0x3c, - 0xf4, 0x4b, 0x28, 0x70, 0x41, 0xc4, 0x90, 0x5b, 0x4b, 0x4a, 0x42, 0x7d, 0xa1, 0x02, 0x0a, 0xa5, - 0x55, 0xd0, 0x1c, 0xf4, 0x14, 0xaa, 0x03, 0x12, 0x90, 0x1e, 0x8d, 0x6c, 0x2d, 0xa5, 0xa0, 0xa4, - 0xfc, 0x20, 0xd3, 0xf4, 0x18, 0x19, 0x0b, 0xc2, 0x2b, 0x83, 0xf4, 0x16, 0x1d, 0x00, 0x10, 0x21, - 0x88, 0xf3, 0x6e, 0x40, 0x03, 0x61, 0x15, 0x95, 0x94, 0x1f, 0x66, 0xea, 0x42, 0xc5, 0x7b, 0x16, - 0xf5, 0xdb, 0x53, 0x30, 0x4e, 0x11, 0xd1, 0x13, 0xa8, 0x38, 0x34, 0x12, 0xde, 0x5b, 0xcf, 0x21, - 0x82, 0x5a, 0x25, 0x25, 0xa7, 0x91, 0x25, 0x67, 0x6f, 0x06, 0xd3, 0x46, 0xa5, 0x99, 0xe8, 0x1e, - 0x98, 0x11, 0xf3, 0xa9, 0x55, 0xde, 0x34, 0xee, 0x54, 0x17, 0x3f, 0x0b, 0x66, 0x3e, 0xc5, 0x0a, - 0xb9, 0xbb, 0x7e, 0x7c, 0xd2, 0x44, 0xb0, 0x5a, 0x32, 0x56, 0x0d, 0x15, 0x1a, 0xc6, 0x3d, 0xe3, - 0x77, 0xc6, 0xef, 0x8d, 0xe6, 0xff, 0xf3, 0x50, 0x7c, 0x49, 0xa3, 0x91, 0xe7, 0x7c, 0xd9, 0xc0, - 0x79, 0x70, 0x26, 0x70, 0x32, 0x6d, 0xd4, 0xd7, 0xce, 0xc5, 0xce, 0x0e, 0x94, 0x68, 0xe0, 0x86, - 0xcc, 0x0b, 0x84, 0x0e, 0x9c, 0x4c, 0x03, 0x0f, 0x34, 0x06, 0x4f, 0xd1, 0xe8, 0x00, 0x56, 0xe2, - 0x7c, 0xb0, 0xcf, 0x44, 0xcd, 0x66, 0x16, 0xfd, 0xb7, 0x0a, 0xa8, 0x9f, 0x7b, 0x79, 0x98, 0xda, - 0xa1, 0x7d, 0x58, 0x09, 0x23, 0x3a, 0xf2, 0xd8, 0x90, 0xdb, 0xca, 0x88, 0xc2, 0x95, 0x8c, 0xc0, - 0xcb, 0x09, 0x4b, 0xee, 0xd0, 0xaf, 0x60, 0x59, 0x92, 0xed, 0xa4, 0x8e, 0xc0, 0xa5, 0x75, 0x04, - 0xab, 0x92, 0xa7, 0x37, 0xe8, 0x05, 0x7c, 0xe7, 0x8c, 0x16, 0x53, 0x41, 0x95, 0xcb, 0x05, 0xdd, - 0x4c, 0x6b, 0xa2, 0x3f, 0xee, 0xa2, 0xe3, 0x93, 0x66, 0x15, 0x96, 0xd3, 0x21, 0xd0, 0xfc, 0x4b, - 0x0e, 0x4a, 0x89, 0x23, 0xd1, 0x7d, 0xfd, 0x66, 0xc6, 0x62, 0xaf, 0x25, 0x58, 0x65, 0x6f, 0xfc, - 0x5c, 0xf7, 0x61, 0x29, 0x64, 0x91, 0xe0, 0x56, 0x6e, 0x33, 0xbf, 0x28, 0x45, 0x0f, 0x59, 0x24, - 0xf6, 0x58, 0xf0, 0xd6, 0xeb, 0xe1, 0x18, 0x8c, 0xde, 0x40, 0x65, 0xe4, 0x45, 0x62, 0x48, 0x7c, - 0xdb, 0x0b, 0xb9, 0x95, 0x57, 0xdc, 0x1f, 0x5d, 0x74, 0x65, 0xeb, 0x75, 0x8c, 0xef, 0x1e, 0x76, - 0xaa, 0x93, 0xd3, 0x06, 0x4c, 0xb7, 0x1c, 0x83, 0x16, 0xd5, 0x0d, 0x79, 0xed, 0x39, 0x94, 0xa7, - 0x27, 0xe8, 0x2e, 0x40, 0x10, 0x67, 0xa4, 0x3d, 0x8d, 0xec, 0x95, 0xc9, 0x69, 0xa3, 0xac, 0xf3, - 0xb4, 0xbb, 0x8f, 0xcb, 0x1a, 0xd0, 0x75, 0x11, 0x02, 0x93, 0xb8, 0x6e, 0xa4, 0xe2, 0xbc, 0x8c, - 0xd5, 0xba, 0xf9, 0xe7, 0x22, 0x98, 0xaf, 0x08, 0xef, 0x5f, 0x77, 0x55, 0x95, 0x77, 0xce, 0x65, - 0xc6, 0x5d, 0x00, 0x1e, 0xc7, 0x9b, 0x34, 0xc7, 0x9c, 0x99, 0xa3, 0xa3, 0x50, 0x9a, 0xa3, 0x01, - 0xb1, 0x39, 0xdc, 0x67, 0x42, 0x25, 0x81, 0x89, 0xd5, 0x1a, 0xdd, 0x86, 0x62, 0xc0, 0x5c, 0x45, - 0x2f, 0x28, 0x3a, 0x4c, 0x4e, 0x1b, 0x05, 0x59, 0x2b, 0xba, 0xfb, 0xb8, 0x20, 0x8f, 0xba, 0xae, - 0x2c, 0x53, 0x24, 0x08, 0x98, 0x20, 0xb2, 0x06, 0x73, 0x5d, 0xee, 0x32, 0xa3, 0xbf, 0x3d, 0x83, - 0x25, 0x65, 0x2a, 0xc5, 0x44, 0xaf, 0xe1, 0x66, 0xa2, 0x6f, 0x5a, 0x60, 0xe9, 0x73, 0x04, 0x22, - 0x2d, 0x21, 0x75, 0x92, 0x6a, 0x0b, 0xe5, 0xc5, 0x6d, 0x41, 0x79, 0x30, 0xab, 0x2d, 0x74, 0x60, - 0xc5, 0xa5, 0xdc, 0x8b, 0xa8, 0xab, 0xca, 0x04, 0x55, 0x99, 0x59, 0xdd, 0xfe, 0xfe, 0x45, 0x42, - 0x28, 0x5e, 0xd6, 0x1c, 0xb5, 0x43, 0x6d, 0x28, 0xe9, 0xb8, 0xe1, 0x56, 0x45, 0xc5, 0xee, 0x15, - 0xdb, 0xc1, 0x94, 0x76, 0xa6, 0xcc, 0x2d, 0x7f, 0x56, 0x99, 0x7b, 0x00, 0xe0, 0xb3, 0x9e, 0xed, - 0x46, 0xde, 0x88, 0x46, 0xd6, 0x8a, 0x1e, 0x12, 0x32, 0xb8, 0xfb, 0x0a, 0x81, 0xcb, 0x3e, 0xeb, - 0xc5, 0xcb, 0xb9, 0xa2, 0x54, 0xfd, 0xcc, 0xa2, 0x44, 0xa0, 0x46, 0x38, 0xf7, 0x7a, 0x01, 0x75, - 0xed, 0x1e, 0x0d, 0x68, 0xe4, 0x39, 0x76, 0x44, 0x39, 0x1b, 0x46, 0x0e, 0xe5, 0xd6, 0xb7, 0x94, - 0x27, 0x32, 0xdb, 0xfc, 0x93, 0x18, 0x8c, 0x35, 0x16, 0x5b, 0x89, 0x98, 0x73, 0x07, 0x7c, 0xb7, - 0x76, 0x7c, 0xd2, 0x5c, 0x87, 0xb5, 0x74, 0x99, 0xda, 0x31, 0x1e, 0x1b, 0x4f, 0x8d, 0x43, 0xa3, - 0xf9, 0xcf, 0x1c, 0x7c, 0x7b, 0xce, 0xa7, 0xe8, 0x67, 0x50, 0xd4, 0x5e, 0xbd, 0x68, 0x58, 0xd3, - 0x3c, 0x9c, 0x60, 0xd1, 0x06, 0x94, 0x65, 0x8a, 0x53, 0xce, 0x69, 0x5c, 0xbc, 0xca, 0x78, 0xf6, - 0x01, 0x59, 0x50, 0x24, 0xbe, 0x47, 0xe4, 0x59, 0x5e, 0x9d, 0x25, 0x5b, 0x34, 0x84, 0xf5, 0xd8, - 0xf5, 0xf6, 0xac, 0xb5, 0xdb, 0x2c, 0x14, 0xdc, 0x32, 0x95, 0xfd, 0x8f, 0xae, 0x14, 0x09, 0xfa, - 0x71, 0x66, 0x1f, 0x5e, 0x84, 0x82, 0x1f, 0x04, 0x22, 0x1a, 0xe3, 0x35, 0x37, 0xe3, 0xa8, 0xf6, - 0x04, 0x6e, 0x2d, 0xa4, 0xa0, 0x55, 0xc8, 0xf7, 0xe9, 0x38, 0x2e, 0x4f, 0x58, 0x2e, 0xd1, 0x1a, - 0x2c, 0x8d, 0x88, 0x3f, 0xa4, 0xba, 0x9a, 0xc5, 0x9b, 0xdd, 0xdc, 0x8e, 0xd1, 0xfc, 0x90, 0x83, - 0xa2, 0x56, 0xe7, 0xba, 0x5b, 0xbe, 0xbe, 0x76, 0xae, 0xb0, 0x3d, 0x84, 0x65, 0xed, 0xd2, 0x38, - 0x23, 0xcd, 0x4b, 0x63, 0xba, 0x12, 0xe3, 0xe3, 0x6c, 0x7c, 0x08, 0xa6, 0x17, 0x92, 0x81, 0x6e, - 0xf7, 0x99, 0x37, 0x77, 0x0f, 0xdb, 0xcf, 0x5f, 0x84, 0x71, 0x61, 0x29, 0x4d, 0x4e, 0x1b, 0xa6, - 0xfc, 0x80, 0x15, 0x2d, 0xb3, 0x31, 0xfe, 0x6d, 0x09, 0x8a, 0x7b, 0xfe, 0x90, 0x0b, 0x1a, 0x5d, - 0xb7, 0x93, 0xf4, 0xb5, 0x73, 0x4e, 0xda, 0x83, 0x62, 0xc4, 0x98, 0xb0, 0x1d, 0x72, 0x91, 0x7f, - 0x30, 0x63, 0x62, 0xaf, 0xdd, 0xa9, 0x4a, 0xa2, 0xac, 0xed, 0xf1, 0x1e, 0x17, 0x24, 0x75, 0x8f, - 0xa0, 0x37, 0xb0, 0x9e, 0x74, 0xc4, 0x23, 0xc6, 0x04, 0x17, 0x11, 0x09, 0xed, 0x3e, 0x1d, 0xcb, - 0x59, 0x29, 0xbf, 0x68, 0x36, 0x3e, 0x08, 0x9c, 0x68, 0xac, 0x9c, 0xf7, 0x8c, 0x8e, 0xf1, 0x9a, - 0x16, 0xd0, 0x49, 0xf8, 0xcf, 0xe8, 0x98, 0xa3, 0x47, 0xb0, 0x41, 0xa7, 0x30, 0x29, 0xd1, 0xf6, - 0xc9, 0x40, 0xf6, 0x7a, 0xdb, 0xf1, 0x99, 0xd3, 0x57, 0xed, 0xc6, 0xc4, 0xb7, 0x68, 0x5a, 0xd4, - 0xaf, 0x63, 0xc4, 0x9e, 0x04, 0x20, 0x0e, 0xd6, 0x91, 0x4f, 0x9c, 0xbe, 0xef, 0x71, 0xf9, 0xef, - 0x4f, 0x6a, 0xdc, 0x95, 0x1d, 0x43, 0xea, 0xb6, 0x73, 0x81, 0xb7, 0x5a, 0x9d, 0x19, 0x37, 0x35, - 0x3c, 0xeb, 0x8c, 0xfa, 0xee, 0x51, 0xf6, 0x29, 0xea, 0x40, 0x65, 0x18, 0xc8, 0xeb, 0x63, 0x1f, - 0x94, 0xaf, 0xea, 0x03, 0x88, 0x59, 0xd2, 0xf2, 0xda, 0x08, 0x36, 0x2e, 0xba, 0x3c, 0x23, 0x37, - 0x1f, 0xa7, 0x73, 0xb3, 0xb2, 0xfd, 0xe3, 0xac, 0xfb, 0xb2, 0x45, 0xa6, 0xf2, 0x38, 0x33, 0x6c, - 0xff, 0x61, 0x40, 0xe1, 0x25, 0x75, 0x22, 0x2a, 0xbe, 0x68, 0xd4, 0xee, 0x9c, 0x89, 0xda, 0x7a, - 0xf6, 0x20, 0x2c, 0x6f, 0x9d, 0x0b, 0xda, 0x1a, 0x94, 0xbc, 0x40, 0xd0, 0x28, 0x20, 0xbe, 0x8a, - 0xda, 0x12, 0x9e, 0xee, 0x33, 0x0d, 0xf8, 0x60, 0x40, 0x21, 0x9e, 0x14, 0xaf, 0xdb, 0x80, 0xf8, - 0xd6, 0xf3, 0x06, 0x64, 0x2a, 0xf9, 0x3f, 0x03, 0x4a, 0x49, 0xc3, 0xfa, 0xa2, 0x6a, 0x9e, 0x9b, - 0xbc, 0xf2, 0x5f, 0x7b, 0xf2, 0x42, 0x60, 0xf6, 0xbd, 0x40, 0xcf, 0x88, 0x58, 0xad, 0x51, 0x0b, - 0x8a, 0x21, 0x19, 0xfb, 0x8c, 0xb8, 0xba, 0x50, 0xae, 0xcd, 0xfd, 0xb0, 0xd0, 0x0e, 0xc6, 0x38, - 0x01, 0xed, 0xae, 0x1d, 0x9f, 0x34, 0x57, 0xa1, 0x9a, 0xb6, 0xfc, 0x9d, 0xd1, 0xfc, 0xb7, 0x01, - 0xe5, 0x83, 0x3f, 0x0a, 0x1a, 0xa8, 0x79, 0xe0, 0x1b, 0x69, 0xfc, 0xe6, 0xfc, 0x8f, 0x0f, 0xe5, - 0x33, 0xbf, 0x2b, 0x64, 0x3d, 0x6a, 0xc7, 0xfa, 0xf8, 0xa9, 0x7e, 0xe3, 0x3f, 0x9f, 0xea, 0x37, - 0xfe, 0x34, 0xa9, 0x1b, 0x1f, 0x27, 0x75, 0xe3, 0x5f, 0x93, 0xba, 0xf1, 0xdf, 0x49, 0xdd, 0x38, - 0x2a, 0x28, 0xff, 0xfc, 0xf4, 0xab, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe4, 0x48, 0xcb, 0x39, 0xc2, - 0x12, 0x00, 0x00, + // 1536 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcd, 0x72, 0x1b, 0x4b, + 0x15, 0xce, 0x48, 0x63, 0xfd, 0x1c, 0xd9, 0xc2, 0xf4, 0x35, 0x66, 0x22, 0x8c, 0x64, 0x74, 0x0b, + 0xea, 0xd6, 0xad, 0x94, 0x1c, 0x4c, 0x00, 0xc7, 0x10, 0x12, 0xc9, 0x76, 0x25, 0xaa, 0x24, 0xc4, + 0xd5, 0x09, 0x09, 0xbb, 0xa1, 0x35, 0xd3, 0x51, 0x06, 0x8d, 0xa6, 0xa7, 0xa6, 0x5b, 0x0a, 0xda, + 0xb1, 0x61, 0x63, 0x1e, 0xc0, 0x3b, 0x16, 0x79, 0x06, 0x36, 0x6c, 0x58, 0xb0, 0xca, 0x92, 0x15, + 0xc5, 0xca, 0x45, 0xf4, 0x16, 0x54, 0xb1, 0xa0, 0xba, 0xa7, 0x47, 0x1a, 0x5b, 0xe3, 0x3f, 0x2a, + 0xe5, 0x62, 0xe5, 0xee, 0xe9, 0xef, 0x3b, 0x7f, 0x7d, 0xce, 0xe9, 0x63, 0xc1, 0x9d, 0xbe, 0x27, + 0xde, 0x8d, 0x7a, 0x2d, 0x87, 0x0d, 0xb7, 0x5c, 0xe6, 0x0c, 0x68, 0xb4, 0xc5, 0xdf, 0x93, 0x68, + 0x38, 0xf0, 0xc4, 0x16, 0x09, 0xbd, 0x2d, 0xd6, 0xfb, 0x2d, 0x75, 0x04, 0x6f, 0x85, 0x11, 0x13, + 0x0c, 0xa1, 0x18, 0xd2, 0x4a, 0x20, 0xad, 0xf1, 0x0f, 0x6b, 0x5f, 0x5f, 0x22, 0x41, 0x4c, 0x42, + 0xaa, 0xf9, 0x97, 0x62, 0x79, 0x48, 0x9d, 0x04, 0xdb, 0xe8, 0x33, 0xd6, 0xf7, 0xe9, 0x96, 0xda, + 0xf5, 0x46, 0x6f, 0xb7, 0x84, 0x37, 0xa4, 0x5c, 0x90, 0x61, 0xa8, 0x01, 0x6b, 0x7d, 0xd6, 0x67, + 0x6a, 0xb9, 0x25, 0x57, 0xfa, 0xeb, 0xed, 0xb3, 0x34, 0x12, 0x4c, 0xf4, 0xd1, 0x4f, 0x2f, 0xd0, + 0x3e, 0x83, 0x87, 0xfe, 0xa8, 0xef, 0x05, 0xfa, 0x4f, 0x4c, 0x6c, 0xfe, 0xc5, 0x00, 0xf3, 0x39, + 0x15, 0x04, 0xfd, 0x0c, 0x8a, 0x63, 0x1a, 0x71, 0x8f, 0x05, 0x96, 0xb1, 0x69, 0x7c, 0x55, 0xd9, + 0xfe, 0x4e, 0x6b, 0x31, 0x22, 0xad, 0xd7, 0x31, 0xa4, 0x63, 0x7e, 0x3c, 0x69, 0xdc, 0xc2, 0x09, + 0x03, 0xdd, 0x07, 0x70, 0x22, 0x4a, 0x04, 0x75, 0x6d, 0x22, 0xac, 0x9c, 0xe2, 0xd7, 0x5a, 0xb1, + 0xb9, 0xad, 0x44, 0x7f, 0xeb, 0x55, 0xe2, 0x25, 0x2e, 0x6b, 0x74, 0x5b, 0x48, 0xea, 0x28, 0x74, + 0x13, 0x6a, 0xfe, 0x72, 0xaa, 0x46, 0xb7, 0x45, 0xf3, 0x0f, 0x4b, 0x60, 0xfe, 0x92, 0xb9, 0x14, + 0xad, 0x43, 0xce, 0x73, 0x95, 0xd9, 0xe5, 0x4e, 0x61, 0x7a, 0xd2, 0xc8, 0x75, 0xf7, 0x71, 0xce, + 0x73, 0xd1, 0x36, 0x98, 0x43, 0x2a, 0x88, 0x36, 0xc8, 0xca, 0x72, 0x48, 0xfa, 0xae, 0xbd, 0x51, + 0x58, 0xf4, 0x13, 0x30, 0xe5, 0x55, 0x69, 0x4b, 0x36, 0xb2, 0x38, 0x52, 0xe7, 0xcb, 0x90, 0x3a, + 0x09, 0x4f, 0xe2, 0xd1, 0x01, 0x54, 0x5c, 0xca, 0x9d, 0xc8, 0x0b, 0x85, 0x8c, 0xa1, 0xa9, 0xe8, + 0x5f, 0x9e, 0x47, 0xdf, 0x9f, 0x43, 0x71, 0x9a, 0x87, 0x7e, 0x0e, 0x05, 0x2e, 0x88, 0x18, 0x71, + 0x6b, 0x49, 0x49, 0xa8, 0x9f, 0x6b, 0x80, 0x42, 0x69, 0x13, 0x34, 0x07, 0x3d, 0x81, 0xea, 0x90, + 0x04, 0xa4, 0x4f, 0x23, 0x5b, 0x4b, 0x29, 0x28, 0x29, 0xdf, 0xcb, 0x74, 0x3d, 0x46, 0xc6, 0x82, + 0xf0, 0xca, 0x30, 0xbd, 0x45, 0x5d, 0x00, 0x22, 0x04, 0x71, 0xde, 0x0d, 0x69, 0x20, 0xac, 0xa2, + 0x92, 0xf2, 0xfd, 0x4c, 0x5b, 0xa8, 0x78, 0xcf, 0xa2, 0x41, 0x7b, 0x06, 0xee, 0xe4, 0x2c, 0x03, + 0xa7, 0xc8, 0xe8, 0x31, 0x54, 0x1c, 0x1a, 0x09, 0xef, 0xad, 0xe7, 0x10, 0x41, 0xad, 0x92, 0x92, + 0xd5, 0xc8, 0x92, 0xb5, 0x37, 0x87, 0x69, 0xc7, 0xd2, 0x4c, 0x74, 0x17, 0xcc, 0x88, 0xf9, 0xd4, + 0x2a, 0x6f, 0x1a, 0x5f, 0x55, 0xcf, 0xbf, 0x1a, 0xcc, 0x7c, 0x8a, 0x15, 0x12, 0x3d, 0x83, 0xaa, + 0xdf, 0xb3, 0xe7, 0xb6, 0x70, 0x0b, 0x36, 0xf3, 0x57, 0xf6, 0x04, 0xaf, 0xf8, 0xbd, 0xf9, 0x8e, + 0xef, 0xae, 0x1f, 0x1d, 0x37, 0x11, 0xac, 0x96, 0x8c, 0x55, 0x43, 0x25, 0x9b, 0x71, 0xd7, 0xf8, + 0xb5, 0xf1, 0x1b, 0xa3, 0xf9, 0x9f, 0x3c, 0x14, 0x5f, 0xd2, 0x68, 0xec, 0x39, 0x9f, 0x37, 0x15, + 0xef, 0x9f, 0x4a, 0xc5, 0xcc, 0x88, 0x69, 0xb5, 0x0b, 0xd9, 0xb8, 0x03, 0x25, 0x1a, 0xb8, 0x21, + 0xf3, 0x02, 0xa1, 0x53, 0x31, 0x33, 0x5c, 0x07, 0x1a, 0x83, 0x67, 0x68, 0x74, 0x00, 0x2b, 0x71, + 0x85, 0xd9, 0xa7, 0xf2, 0x70, 0x33, 0x8b, 0xfe, 0x2b, 0x05, 0xd4, 0x09, 0xb4, 0x3c, 0x4a, 0xed, + 0xd0, 0x3e, 0xac, 0x84, 0x11, 0x1d, 0x7b, 0x6c, 0xc4, 0x6d, 0xe5, 0x44, 0xe1, 0x4a, 0x4e, 0xe0, + 0xe5, 0x84, 0x25, 0x77, 0xe8, 0x17, 0xb0, 0x2c, 0xc9, 0x76, 0xd2, 0x99, 0xe0, 0xd2, 0xce, 0x84, + 0x2b, 0x92, 0xa0, 0x37, 0xe8, 0x05, 0x7c, 0xeb, 0x94, 0x15, 0x33, 0x41, 0x95, 0xcb, 0x05, 0x7d, + 0x91, 0xb6, 0x44, 0x7f, 0xdc, 0x45, 0x47, 0xc7, 0xcd, 0x2a, 0x2c, 0xa7, 0x53, 0xa0, 0xf9, 0xa7, + 0x1c, 0x94, 0x92, 0x40, 0xa2, 0x7b, 0xfa, 0xce, 0x8c, 0xf3, 0xa3, 0x96, 0x60, 0x95, 0xbf, 0xf1, + 0x75, 0xdd, 0x83, 0xa5, 0x90, 0x45, 0x82, 0x5b, 0x39, 0x95, 0x9e, 0x99, 0x45, 0x7f, 0xc8, 0x22, + 0xb1, 0xc7, 0x82, 0xb7, 0x5e, 0x1f, 0xc7, 0x60, 0xf4, 0x06, 0x2a, 0x63, 0x2f, 0x12, 0x23, 0xe2, + 0xdb, 0x5e, 0xc8, 0xad, 0xbc, 0xe2, 0xfe, 0xe0, 0x22, 0x95, 0xad, 0xd7, 0x31, 0xbe, 0x7b, 0xd8, + 0xa9, 0x4e, 0x4f, 0x1a, 0x30, 0xdb, 0x72, 0x0c, 0x5a, 0x54, 0x37, 0xe4, 0xb5, 0xe7, 0x50, 0x9e, + 0x9d, 0xa0, 0x3b, 0x00, 0x41, 0x5c, 0x19, 0xf6, 0x2c, 0xb3, 0x57, 0xa6, 0x27, 0x8d, 0xb2, 0xae, + 0x97, 0xee, 0x3e, 0x2e, 0x6b, 0x40, 0xd7, 0x45, 0x08, 0x4c, 0xe2, 0xba, 0x91, 0xca, 0xf3, 0x32, + 0x56, 0xeb, 0xe6, 0x1f, 0x8b, 0x60, 0xbe, 0x22, 0x7c, 0x70, 0xd3, 0x7d, 0x5a, 0xea, 0x5c, 0xa8, + 0x8c, 0x3b, 0x00, 0x3c, 0xce, 0x37, 0xe9, 0x8e, 0x39, 0x77, 0x47, 0x67, 0xa1, 0x74, 0x47, 0x03, + 0x62, 0x77, 0xb8, 0xcf, 0x84, 0x2a, 0x02, 0x13, 0xab, 0x35, 0xfa, 0x12, 0x8a, 0x01, 0x73, 0x15, + 0xbd, 0xa0, 0xe8, 0x30, 0x3d, 0x69, 0x14, 0x64, 0xe7, 0xe9, 0xee, 0xe3, 0x82, 0x3c, 0xea, 0xba, + 0xb2, 0xe9, 0x91, 0x20, 0x60, 0x82, 0xc8, 0xae, 0xce, 0x75, 0x03, 0xcd, 0xcc, 0xfe, 0xf6, 0x1c, + 0x96, 0x34, 0xbd, 0x14, 0x13, 0xbd, 0x86, 0x2f, 0x12, 0x7b, 0xd3, 0x02, 0x4b, 0xd7, 0x11, 0x88, + 0xb4, 0x84, 0xd4, 0x49, 0xea, 0xa1, 0x29, 0x9f, 0xff, 0xd0, 0xa8, 0x08, 0x66, 0x3d, 0x34, 0x1d, + 0x58, 0x71, 0x29, 0xf7, 0x22, 0xea, 0xaa, 0x36, 0x41, 0x55, 0x65, 0x56, 0xb7, 0xbf, 0x7b, 0x91, + 0x10, 0x8a, 0x97, 0x35, 0x47, 0xed, 0x50, 0x1b, 0x4a, 0x3a, 0x6f, 0xb8, 0x55, 0xb9, 0x4e, 0x5b, + 0x9e, 0xd1, 0x4e, 0xb5, 0xb9, 0xe5, 0x6b, 0xb5, 0xb9, 0xfb, 0x00, 0x3e, 0xeb, 0xdb, 0x6e, 0xe4, + 0x8d, 0x69, 0x64, 0xad, 0xe8, 0xb1, 0x23, 0x83, 0xbb, 0xaf, 0x10, 0xb8, 0xec, 0xb3, 0x7e, 0xbc, + 0x5c, 0x68, 0x4a, 0xd5, 0x6b, 0x36, 0x25, 0x02, 0x35, 0xc2, 0xb9, 0xd7, 0x0f, 0xa8, 0x6b, 0xf7, + 0x69, 0x40, 0x23, 0xcf, 0xb1, 0x23, 0xca, 0xd9, 0x28, 0x72, 0x28, 0xb7, 0xbe, 0xa1, 0x22, 0x91, + 0x39, 0x38, 0x3c, 0x8e, 0xc1, 0x58, 0x63, 0xb1, 0x95, 0x88, 0x39, 0x73, 0xc0, 0x77, 0x6b, 0x47, + 0xc7, 0xcd, 0x75, 0x58, 0x4b, 0xb7, 0xa9, 0x1d, 0xe3, 0x91, 0xf1, 0xc4, 0x38, 0x34, 0x9a, 0x7f, + 0xcb, 0xc1, 0x37, 0x17, 0x62, 0x8a, 0x7e, 0x0c, 0x45, 0x1d, 0xd5, 0x8b, 0xc6, 0x3f, 0xcd, 0xc3, + 0x09, 0x16, 0x6d, 0x40, 0x59, 0x96, 0x38, 0xe5, 0x9c, 0xc6, 0xcd, 0xab, 0x8c, 0xe7, 0x1f, 0x90, + 0x05, 0x45, 0xe2, 0x7b, 0x44, 0x9e, 0xe5, 0xd5, 0x59, 0xb2, 0x45, 0x23, 0x58, 0x8f, 0x43, 0x9f, + 0x7a, 0x9c, 0x6d, 0x16, 0x0a, 0x6e, 0x99, 0xca, 0xff, 0x87, 0x57, 0xca, 0x04, 0x7d, 0x39, 0xf3, + 0x0f, 0x2f, 0x42, 0xc1, 0x0f, 0x02, 0x11, 0x4d, 0xf0, 0x9a, 0x9b, 0x71, 0x54, 0x7b, 0x0c, 0xb7, + 0xcf, 0xa5, 0xa0, 0x55, 0xc8, 0x0f, 0xe8, 0x24, 0x6e, 0x4f, 0x58, 0x2e, 0xd1, 0x1a, 0x2c, 0x8d, + 0x89, 0x3f, 0xa2, 0xba, 0x9b, 0xc5, 0x9b, 0xdd, 0xdc, 0x8e, 0xd1, 0xfc, 0x90, 0x83, 0xa2, 0x36, + 0xe7, 0xa6, 0x9f, 0x7c, 0xad, 0x76, 0xa1, 0xb1, 0x3d, 0x80, 0x65, 0x1d, 0xd2, 0xb8, 0x22, 0xcd, + 0x4b, 0x73, 0xba, 0x12, 0xe3, 0xe3, 0x6a, 0x7c, 0x00, 0xa6, 0x17, 0x92, 0xa1, 0x7e, 0xee, 0x33, + 0x35, 0x77, 0x0f, 0xdb, 0xcf, 0x5f, 0x84, 0x71, 0x63, 0x29, 0x4d, 0x4f, 0x1a, 0xa6, 0xfc, 0x80, + 0x15, 0x2d, 0xf3, 0x61, 0xfc, 0xf3, 0x12, 0x14, 0xf7, 0xfc, 0x11, 0x17, 0x34, 0xba, 0xe9, 0x20, + 0x69, 0xb5, 0x0b, 0x41, 0xda, 0x83, 0x62, 0xc4, 0x98, 0xb0, 0x1d, 0x72, 0x51, 0x7c, 0x30, 0x63, + 0x62, 0xaf, 0xdd, 0xa9, 0x4a, 0xa2, 0xec, 0xed, 0xf1, 0x1e, 0x17, 0x24, 0x75, 0x8f, 0xa0, 0x37, + 0xb0, 0x9e, 0xbc, 0x88, 0x3d, 0xc6, 0x04, 0x17, 0x11, 0x09, 0xed, 0x01, 0x9d, 0xc8, 0x59, 0x29, + 0x7f, 0xde, 0xb4, 0x7d, 0x10, 0x38, 0xd1, 0x44, 0x05, 0xef, 0x29, 0x9d, 0xe0, 0x35, 0x2d, 0xa0, + 0x93, 0xf0, 0x9f, 0xd2, 0x09, 0x47, 0x0f, 0x61, 0x83, 0xce, 0x60, 0x52, 0xa2, 0xed, 0x93, 0xa1, + 0x7c, 0xeb, 0x6d, 0xc7, 0x67, 0xce, 0x40, 0x3d, 0x37, 0x26, 0xbe, 0x4d, 0xd3, 0xa2, 0x9e, 0xc5, + 0x88, 0x3d, 0x09, 0x40, 0x1c, 0xac, 0x9e, 0x4f, 0x9c, 0x81, 0xef, 0x71, 0xf9, 0x0f, 0x55, 0x6a, + 0x78, 0x96, 0x2f, 0x86, 0xb4, 0x6d, 0xe7, 0x82, 0x68, 0xb5, 0x3a, 0x73, 0x6e, 0x6a, 0x14, 0xd7, + 0x15, 0xf5, 0xed, 0x5e, 0xf6, 0x29, 0xea, 0x40, 0x65, 0x14, 0x48, 0xf5, 0x71, 0x0c, 0xca, 0x57, + 0x8d, 0x01, 0xc4, 0x2c, 0xe9, 0x79, 0x6d, 0x0c, 0x1b, 0x17, 0x29, 0xcf, 0xa8, 0xcd, 0x47, 0xe9, + 0xda, 0xac, 0x6c, 0x7f, 0x9d, 0xa5, 0x2f, 0x5b, 0x64, 0xaa, 0x8e, 0x33, 0xd3, 0xf6, 0xaf, 0x06, + 0x14, 0x5e, 0x52, 0x27, 0xa2, 0xe2, 0xb3, 0x66, 0xed, 0xce, 0xa9, 0xac, 0xad, 0x67, 0x0f, 0xc2, + 0x52, 0xeb, 0x42, 0xd2, 0xd6, 0xa0, 0xe4, 0x05, 0x82, 0x46, 0x01, 0xf1, 0x55, 0xd6, 0x96, 0xf0, + 0x6c, 0x9f, 0xe9, 0xc0, 0x07, 0x03, 0x0a, 0xf1, 0xa4, 0x78, 0xd3, 0x0e, 0xc4, 0x5a, 0xcf, 0x3a, + 0x90, 0x69, 0xe4, 0xbf, 0x0d, 0x28, 0x25, 0x0f, 0xd6, 0x67, 0x35, 0xf3, 0xcc, 0xe4, 0x95, 0xff, + 0x9f, 0x27, 0x2f, 0x04, 0xe6, 0xc0, 0x0b, 0xf4, 0x8c, 0x88, 0xd5, 0x1a, 0xb5, 0xa0, 0x18, 0x92, + 0x89, 0xcf, 0x88, 0xab, 0x1b, 0xe5, 0xda, 0xc2, 0x4f, 0x15, 0xed, 0x60, 0x82, 0x13, 0xd0, 0xee, + 0xda, 0xd1, 0x71, 0x73, 0x15, 0xaa, 0x69, 0xcf, 0xdf, 0x19, 0xcd, 0x7f, 0x18, 0x50, 0x3e, 0xf8, + 0x9d, 0xa0, 0x81, 0x9a, 0x07, 0xfe, 0x2f, 0x9d, 0xdf, 0x5c, 0xfc, 0x39, 0xa3, 0x7c, 0xea, 0x97, + 0x8a, 0xac, 0x4b, 0xed, 0x58, 0x1f, 0x3f, 0xd5, 0x6f, 0xfd, 0xf3, 0x53, 0xfd, 0xd6, 0xef, 0xa7, + 0x75, 0xe3, 0xe3, 0xb4, 0x6e, 0xfc, 0x7d, 0x5a, 0x37, 0xfe, 0x35, 0xad, 0x1b, 0xbd, 0x82, 0x8a, + 0xcf, 0x8f, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xbd, 0x5c, 0xf5, 0x06, 0x95, 0x13, 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/objects.proto b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/objects.proto index 311c1f2fb..43bffca38 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/objects.proto +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/objects.proto @@ -2,12 +2,12 @@ syntax = "proto3"; package docker.swarmkit.v1; -import "types.proto"; -import "specs.proto"; +import "github.com/docker/swarmkit/api/types.proto"; +import "github.com/docker/swarmkit/api/specs.proto"; import "google/protobuf/timestamp.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; -import "plugin/plugin.proto"; +import "github.com/docker/swarmkit/protobuf/plugin/plugin.proto"; // This file contains definitions for all first-class objects in the cluster // API. Such types typically have a corresponding specification, with the @@ -59,8 +59,9 @@ message Node { // component, if the node is a manager. ManagerStatus manager_status = 6; + // DEPRECATED: Use lb_attachments to find the ingress network // The node attachment to the ingress network. - NetworkAttachment attachment = 7; + NetworkAttachment attachment = 7 [deprecated=true]; // Certificate is the TLS certificate issued for the node, if any. Certificate certificate = 8 [(gogoproto.nullable) = false]; @@ -75,6 +76,11 @@ message Node { // shows the privilege level that the CA would currently grant when // issuing or renewing the node's certificate. NodeRole role = 9; + + // Each node uses the network attachment to set up an endpoint on the + // node to be used for load balancing. Each overlay network, including + // ingress network, will have an NetworkAttachment. + repeated NetworkAttachment lb_attachments = 10; } message Service { @@ -257,7 +263,7 @@ message NetworkAttachment { // List of aliases by which a task is resolved in a network repeated string aliases = 3; - + // Map of all the driver attachment options for this network map driver_attachment_opts = 4; } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/raft.pb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/raft.pb.go index 6a1e8ef53..4710ee6b0 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/raft.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/raft.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. -// source: raft.proto +// source: github.com/docker/swarmkit/api/raft.proto // DO NOT EDIT! package api @@ -907,7 +907,7 @@ var _Raft_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "raft.proto", + Metadata: "github.com/docker/swarmkit/api/raft.proto", } // Client API for RaftMembership service @@ -1008,7 +1008,7 @@ var _RaftMembership_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "raft.proto", + Metadata: "github.com/docker/swarmkit/api/raft.proto", } func (m *RaftMember) Marshal() (dAtA []byte, err error) { @@ -3571,68 +3571,69 @@ var ( ErrIntOverflowRaft = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("raft.proto", fileDescriptorRaft) } +func init() { proto.RegisterFile("github.com/docker/swarmkit/api/raft.proto", fileDescriptorRaft) } var fileDescriptorRaft = []byte{ - // 953 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x96, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xc7, 0x77, 0xd7, 0x5b, 0x27, 0x79, 0xdc, 0xbc, 0x68, 0x42, 0xc2, 0x76, 0x29, 0x8e, 0xbb, - 0x45, 0xc2, 0x2d, 0x64, 0x2d, 0x0c, 0x12, 0xa8, 0xd0, 0x43, 0xec, 0x58, 0xb2, 0x69, 0xeb, 0x54, - 0x9b, 0x04, 0x7a, 0x0b, 0xeb, 0xdd, 0x89, 0xbb, 0xd8, 0xde, 0x31, 0x33, 0x63, 0x07, 0x2e, 0xa8, - 0x47, 0x94, 0x2b, 0x07, 0x10, 0x52, 0x4f, 0x70, 0xee, 0x07, 0xe0, 0x03, 0xa0, 0x88, 0x13, 0x37, - 0x38, 0x45, 0xd4, 0x1f, 0x00, 0xbe, 0x02, 0x9a, 0xd9, 0x5d, 0x3b, 0x38, 0x6b, 0x37, 0x17, 0x7b, - 0x3c, 0xf3, 0xfb, 0x3f, 0xff, 0x79, 0xe6, 0xe5, 0x19, 0x03, 0x50, 0xf7, 0x98, 0xdb, 0x7d, 0x4a, - 0x38, 0x41, 0xc8, 0x27, 0x5e, 0x07, 0x53, 0x9b, 0x9d, 0xb8, 0xb4, 0xd7, 0x09, 0xb8, 0x3d, 0x7c, - 0xcf, 0x5c, 0x26, 0xad, 0x2f, 0xb1, 0xc7, 0x59, 0x84, 0x98, 0x39, 0xfe, 0x4d, 0x1f, 0x27, 0x3f, - 0xb6, 0xdb, 0x01, 0x7f, 0x3a, 0x68, 0xd9, 0x1e, 0xe9, 0x95, 0x3c, 0x42, 0x31, 0x61, 0x25, 0xcc, - 0x3d, 0xbf, 0x24, 0x42, 0xca, 0x8f, 0x7e, 0xab, 0x34, 0x09, 0x6f, 0xbe, 0xd6, 0x26, 0x6d, 0x22, - 0x9b, 0x25, 0xd1, 0x8a, 0x7b, 0xd7, 0xfb, 0xdd, 0x41, 0x3b, 0x08, 0x4b, 0xd1, 0x57, 0xd4, 0x69, - 0xbd, 0x50, 0x01, 0x1c, 0xf7, 0x98, 0x3f, 0xc2, 0xbd, 0x16, 0xa6, 0xe8, 0x36, 0x2c, 0x88, 0x38, - 0x47, 0x81, 0x6f, 0xa8, 0x05, 0xb5, 0xa8, 0x57, 0x60, 0x74, 0xbe, 0x95, 0x15, 0x40, 0x63, 0xd7, - 0xc9, 0x8a, 0xa1, 0x86, 0x2f, 0xa0, 0x90, 0xf8, 0x58, 0x40, 0x5a, 0x41, 0x2d, 0x2e, 0x45, 0x50, - 0x93, 0xf8, 0x58, 0x40, 0x62, 0xa8, 0xe1, 0x23, 0x04, 0xba, 0xeb, 0xfb, 0xd4, 0xc8, 0x08, 0xc2, - 0x91, 0x6d, 0x54, 0x81, 0x2c, 0xe3, 0x2e, 0x1f, 0x30, 0x43, 0x2f, 0xa8, 0xc5, 0x5c, 0xf9, 0x2d, - 0xfb, 0xf2, 0x3a, 0xd8, 0x93, 0xd9, 0xec, 0x4b, 0xb6, 0xa2, 0x9f, 0x9d, 0x6f, 0x29, 0x4e, 0xac, - 0xb4, 0x6e, 0x41, 0xee, 0x53, 0x12, 0x84, 0x0e, 0xfe, 0x6a, 0x80, 0x19, 0x1f, 0xdb, 0xa8, 0x13, - 0x1b, 0xeb, 0x27, 0x15, 0xae, 0x47, 0x0c, 0xeb, 0x93, 0x90, 0xe1, 0xab, 0x65, 0xf5, 0x11, 0x2c, - 0xf4, 0xa4, 0x2d, 0x33, 0xb4, 0x42, 0xa6, 0x98, 0x2b, 0xe7, 0xe7, 0xcf, 0xce, 0x49, 0x70, 0xf4, - 0x0e, 0xac, 0x52, 0xdc, 0x23, 0x43, 0xec, 0x1f, 0x25, 0x11, 0x32, 0x85, 0x4c, 0x51, 0xaf, 0x68, - 0x6b, 0x8a, 0xb3, 0x12, 0x0f, 0x45, 0x22, 0x66, 0x55, 0xe0, 0xfa, 0x43, 0xec, 0x0e, 0x71, 0x92, - 0x40, 0x19, 0x74, 0xb1, 0x62, 0x72, 0x62, 0xaf, 0xf6, 0x94, 0xac, 0xb5, 0x0a, 0xcb, 0x71, 0x8c, - 0x28, 0x41, 0xeb, 0x21, 0xdc, 0x78, 0x4c, 0x89, 0x87, 0x19, 0x8b, 0x58, 0xc6, 0xdc, 0xf6, 0xd8, - 0xe1, 0x8e, 0x48, 0x4c, 0xf6, 0xc4, 0x26, 0xab, 0x76, 0x74, 0x64, 0xec, 0x04, 0x4c, 0xc6, 0xef, - 0xe9, 0xcf, 0x7e, 0xb0, 0x14, 0xeb, 0x26, 0x98, 0x69, 0xd1, 0x62, 0xaf, 0x4f, 0x60, 0xc3, 0xc1, - 0x8c, 0x74, 0x87, 0x78, 0xc7, 0xf7, 0xa9, 0x80, 0x62, 0x9f, 0xab, 0xac, 0xb2, 0xf5, 0x2e, 0x6c, - 0x4e, 0xab, 0xe3, 0x4d, 0x4a, 0xdb, 0xc9, 0x2e, 0xac, 0x37, 0x42, 0x8e, 0x69, 0xe8, 0x76, 0x45, - 0x9c, 0xc4, 0x69, 0x13, 0xb4, 0xb1, 0x49, 0x76, 0x74, 0xbe, 0xa5, 0x35, 0x76, 0x1d, 0x2d, 0xf0, - 0xd1, 0x7d, 0xc8, 0xba, 0x1e, 0x0f, 0x48, 0x18, 0xef, 0xe0, 0x56, 0xda, 0x6a, 0xee, 0x73, 0x42, - 0xf1, 0x8e, 0xc4, 0x92, 0xa3, 0x15, 0x89, 0xac, 0xdf, 0x74, 0xc8, 0x5d, 0x18, 0x45, 0x1f, 0x8f, - 0xc3, 0x09, 0xab, 0x95, 0xf2, 0xed, 0x57, 0x84, 0x7b, 0x10, 0x84, 0x7e, 0x12, 0x0c, 0xd9, 0xf1, - 0xbe, 0x6a, 0x72, 0xc9, 0x8d, 0x34, 0xa9, 0xb8, 0x31, 0x75, 0x25, 0xda, 0x53, 0xf4, 0x21, 0x2c, - 0x30, 0x4c, 0x87, 0x81, 0x87, 0xe5, 0x95, 0xc9, 0x95, 0xdf, 0x48, 0x75, 0x8b, 0x90, 0xba, 0xe2, - 0x24, 0xb4, 0x30, 0xe2, 0x2e, 0xeb, 0xc4, 0x57, 0x2a, 0xd5, 0xe8, 0xc0, 0x65, 0x1d, 0x61, 0x24, - 0x38, 0x61, 0x14, 0x62, 0x7e, 0x42, 0x68, 0xc7, 0xb8, 0x36, 0xdb, 0xa8, 0x19, 0x21, 0xc2, 0x28, - 0xa6, 0x85, 0xd0, 0xeb, 0x0e, 0x18, 0xc7, 0xd4, 0xc8, 0xce, 0x16, 0x56, 0x23, 0x44, 0x08, 0x63, - 0x1a, 0x7d, 0x00, 0x59, 0x86, 0x3d, 0x8a, 0xb9, 0xb1, 0x20, 0x75, 0x66, 0x7a, 0x66, 0x82, 0xa8, - 0x8b, 0x8b, 0x2e, 0x5b, 0xe8, 0x1e, 0x2c, 0x52, 0xcc, 0xc8, 0x80, 0x7a, 0xd8, 0x58, 0x94, 0xba, - 0x9b, 0xa9, 0x97, 0x23, 0x66, 0xea, 0x8a, 0x33, 0xe6, 0xd1, 0x7d, 0x58, 0xc2, 0x5f, 0x73, 0x1c, - 0x32, 0xb1, 0x79, 0x4b, 0x52, 0xfc, 0x66, 0x9a, 0xb8, 0x96, 0x40, 0x75, 0xc5, 0x99, 0x28, 0xc4, - 0x84, 0x3d, 0x12, 0x1e, 0x07, 0x6d, 0x03, 0x66, 0x4f, 0xb8, 0x2a, 0x09, 0x31, 0xe1, 0x88, 0xad, - 0x2c, 0x42, 0x96, 0xbb, 0xb4, 0x8d, 0xf9, 0xdd, 0x7f, 0x55, 0x58, 0x9d, 0x3a, 0x17, 0xe8, 0x6d, - 0x58, 0x38, 0x6c, 0x3e, 0x68, 0xee, 0x7d, 0xde, 0x5c, 0x53, 0x4c, 0xf3, 0xf4, 0x79, 0x61, 0x73, - 0x8a, 0x38, 0x0c, 0x3b, 0x21, 0x39, 0x09, 0x51, 0x19, 0xd6, 0xf7, 0x0f, 0xf6, 0x9c, 0xda, 0xd1, - 0x4e, 0xf5, 0xa0, 0xb1, 0xd7, 0x3c, 0xaa, 0x3a, 0xb5, 0x9d, 0x83, 0xda, 0x9a, 0x6a, 0xde, 0x38, - 0x7d, 0x5e, 0xd8, 0x98, 0x12, 0x55, 0x29, 0x76, 0x39, 0xbe, 0xa4, 0x39, 0x7c, 0xbc, 0x2b, 0x34, - 0x5a, 0xaa, 0xe6, 0xb0, 0xef, 0xa7, 0x69, 0x9c, 0xda, 0xa3, 0xbd, 0xcf, 0x6a, 0x6b, 0x99, 0x54, - 0x8d, 0x23, 0x8b, 0x98, 0xf9, 0xfa, 0x77, 0x3f, 0xe7, 0x95, 0x5f, 0x7f, 0xc9, 0x4f, 0x67, 0x57, - 0xfe, 0x5e, 0x03, 0x5d, 0xdc, 0x50, 0x74, 0xaa, 0x02, 0xba, 0x5c, 0x3c, 0xd0, 0x76, 0xda, 0x0a, - 0xce, 0x2c, 0x59, 0xa6, 0x7d, 0x55, 0x3c, 0xae, 0x49, 0x1b, 0xbf, 0xbf, 0xf8, 0xe7, 0x47, 0x6d, - 0x15, 0x96, 0x25, 0xbf, 0xdd, 0x73, 0x43, 0xb7, 0x8d, 0x29, 0xfa, 0x16, 0x56, 0xfe, 0x5f, 0x6c, - 0xd0, 0x9d, 0x59, 0x47, 0xe8, 0x52, 0x39, 0x33, 0xef, 0x5e, 0x05, 0x9d, 0xeb, 0x5f, 0xfe, 0x53, - 0x85, 0x95, 0x49, 0xf1, 0x66, 0x4f, 0x83, 0x3e, 0xfa, 0x02, 0x74, 0xf1, 0x34, 0xa1, 0xd4, 0xd2, - 0x74, 0xe1, 0x61, 0x33, 0x0b, 0xb3, 0x81, 0xf9, 0x49, 0x7b, 0x70, 0x4d, 0x3e, 0x0e, 0x28, 0x35, - 0xc2, 0xc5, 0xb7, 0xc7, 0xbc, 0x35, 0x87, 0x98, 0x6b, 0x52, 0x31, 0xce, 0x5e, 0xe6, 0x95, 0xbf, - 0x5e, 0xe6, 0x95, 0x67, 0xa3, 0xbc, 0x7a, 0x36, 0xca, 0xab, 0x7f, 0x8c, 0xf2, 0xea, 0xdf, 0xa3, - 0xbc, 0xfa, 0x24, 0xf3, 0x44, 0x6f, 0x65, 0xe5, 0x7f, 0x8b, 0xf7, 0xff, 0x0b, 0x00, 0x00, 0xff, - 0xff, 0x9a, 0xef, 0x6e, 0xdb, 0xf3, 0x08, 0x00, 0x00, + // 974 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x96, 0x4f, 0x6f, 0x1b, 0x45, + 0x18, 0xc6, 0x77, 0xd7, 0x5b, 0x27, 0x79, 0xd3, 0x26, 0xd1, 0x94, 0x84, 0xed, 0x52, 0x1c, 0x77, + 0x8b, 0x84, 0x13, 0x9a, 0xb5, 0x30, 0x48, 0x45, 0x85, 0x1e, 0x62, 0xc7, 0x92, 0x4d, 0x5b, 0xa7, + 0xda, 0x24, 0xd0, 0x5b, 0x58, 0xef, 0x4e, 0xdc, 0xc5, 0xf6, 0x8e, 0x99, 0x19, 0x3b, 0x70, 0x41, + 0x3d, 0xa2, 0x5c, 0x39, 0x80, 0x90, 0x7a, 0x82, 0x73, 0x3f, 0x00, 0x1f, 0x00, 0x45, 0x9c, 0xb8, + 0xc1, 0x29, 0xa2, 0xfe, 0x00, 0xf0, 0x15, 0xd0, 0xcc, 0xee, 0x3a, 0xc6, 0x59, 0x3b, 0xb9, 0x24, + 0xa3, 0x9d, 0xdf, 0xf3, 0x3e, 0xef, 0x3b, 0x7f, 0xde, 0x31, 0x6c, 0xb4, 0x02, 0xfe, 0xbc, 0xdf, + 0xb4, 0x3d, 0xd2, 0x2d, 0xfa, 0xc4, 0x6b, 0x63, 0x5a, 0x64, 0xc7, 0x2e, 0xed, 0xb6, 0x03, 0x5e, + 0x74, 0x7b, 0x41, 0x91, 0xba, 0x47, 0xdc, 0xee, 0x51, 0xc2, 0x09, 0x42, 0xd1, 0xbc, 0x9d, 0xcc, + 0xdb, 0x83, 0xf7, 0xcd, 0x7b, 0x97, 0xc8, 0x49, 0xf3, 0x4b, 0xec, 0x71, 0x16, 0x45, 0x30, 0x37, + 0x2f, 0xa1, 0xf9, 0x37, 0x3d, 0x9c, 0xb0, 0x5b, 0x63, 0xac, 0x47, 0x28, 0x26, 0xac, 0x88, 0xb9, + 0xe7, 0xcb, 0x84, 0xe4, 0x9f, 0x5e, 0x73, 0x2c, 0x39, 0xf3, 0x8d, 0x16, 0x69, 0x11, 0x39, 0x2c, + 0x8a, 0x51, 0xfc, 0xf5, 0xfe, 0x0c, 0x43, 0x49, 0x34, 0xfb, 0x47, 0xc5, 0x5e, 0xa7, 0xdf, 0x0a, + 0xc2, 0xf8, 0x5f, 0x24, 0xb4, 0x5e, 0xa9, 0x00, 0x8e, 0x7b, 0xc4, 0x9f, 0xe0, 0x6e, 0x13, 0x53, + 0x74, 0x17, 0xe6, 0x84, 0xd7, 0x61, 0xe0, 0x1b, 0x6a, 0x5e, 0x2d, 0xe8, 0x65, 0x18, 0x9e, 0xad, + 0x67, 0x05, 0x50, 0xdf, 0x71, 0xb2, 0x62, 0xaa, 0xee, 0x0b, 0x28, 0x24, 0x3e, 0x16, 0x90, 0x96, + 0x57, 0x0b, 0x0b, 0x11, 0xd4, 0x20, 0x3e, 0x16, 0x90, 0x98, 0xaa, 0xfb, 0x08, 0x81, 0xee, 0xfa, + 0x3e, 0x35, 0x32, 0x82, 0x70, 0xe4, 0x18, 0x95, 0x21, 0xcb, 0xb8, 0xcb, 0xfb, 0xcc, 0xd0, 0xf3, + 0x6a, 0x61, 0xb1, 0xf4, 0x8e, 0x7d, 0x71, 0xa5, 0xed, 0xf3, 0x6c, 0xf6, 0x24, 0x5b, 0xd6, 0x4f, + 0xcf, 0xd6, 0x15, 0x27, 0x56, 0x5a, 0x77, 0x60, 0xf1, 0x53, 0x12, 0x84, 0x0e, 0xfe, 0xaa, 0x8f, + 0x19, 0x1f, 0xd9, 0xa8, 0xe7, 0x36, 0xd6, 0x4f, 0x2a, 0x5c, 0x8f, 0x18, 0xd6, 0x23, 0x21, 0xc3, + 0x57, 0xab, 0xea, 0x23, 0x98, 0xeb, 0x4a, 0x5b, 0x66, 0x68, 0xf9, 0x4c, 0x61, 0xb1, 0x94, 0x9b, + 0x9d, 0x9d, 0x93, 0xe0, 0xe8, 0x3d, 0x58, 0xa6, 0xb8, 0x4b, 0x06, 0xd8, 0x3f, 0x4c, 0x22, 0x64, + 0xf2, 0x99, 0x82, 0x5e, 0xd6, 0x56, 0x14, 0x67, 0x29, 0x9e, 0x8a, 0x44, 0xcc, 0x2a, 0xc3, 0xf5, + 0xc7, 0xd8, 0x1d, 0xe0, 0xa4, 0x80, 0x12, 0xe8, 0x62, 0xc5, 0x64, 0x62, 0x97, 0x7b, 0x4a, 0xd6, + 0x5a, 0x86, 0x1b, 0x71, 0x8c, 0xa8, 0x40, 0xeb, 0x31, 0xdc, 0x7a, 0x4a, 0x89, 0x87, 0x19, 0x8b, + 0x58, 0xc6, 0xdc, 0xd6, 0xc8, 0x61, 0x43, 0x14, 0x26, 0xbf, 0xc4, 0x26, 0xcb, 0x76, 0x74, 0xac, + 0xec, 0x04, 0x4c, 0xe6, 0x1f, 0xe8, 0x2f, 0x7e, 0xb0, 0x14, 0xeb, 0x36, 0x98, 0x69, 0xd1, 0x62, + 0xaf, 0x4f, 0x60, 0xd5, 0xc1, 0x8c, 0x74, 0x06, 0x78, 0xdb, 0xf7, 0xa9, 0x80, 0x62, 0x9f, 0xab, + 0xac, 0xb2, 0x75, 0x0f, 0xd6, 0x26, 0xd5, 0xf1, 0x26, 0xa5, 0xed, 0x64, 0x07, 0x6e, 0xd6, 0x43, + 0x8e, 0x69, 0xe8, 0x76, 0x44, 0x9c, 0xc4, 0x69, 0x0d, 0xb4, 0x91, 0x49, 0x76, 0x78, 0xb6, 0xae, + 0xd5, 0x77, 0x1c, 0x2d, 0xf0, 0xd1, 0x43, 0xc8, 0xba, 0x1e, 0x0f, 0x48, 0x18, 0xef, 0xe0, 0x7a, + 0xda, 0x6a, 0xee, 0x71, 0x42, 0xf1, 0xb6, 0xc4, 0x92, 0xa3, 0x15, 0x89, 0xac, 0xdf, 0x74, 0x58, + 0x1c, 0x9b, 0x45, 0x1f, 0x8f, 0xc2, 0x09, 0xab, 0xa5, 0xd2, 0xdd, 0x4b, 0xc2, 0x3d, 0x0a, 0x42, + 0x3f, 0x09, 0x86, 0xec, 0x78, 0x5f, 0x35, 0xb9, 0xe4, 0x46, 0x9a, 0x54, 0xdc, 0x98, 0x9a, 0x12, + 0xed, 0x29, 0xba, 0x0f, 0x73, 0x0c, 0xd3, 0x41, 0xe0, 0x61, 0x79, 0x65, 0x16, 0x4b, 0x6f, 0xa5, + 0xba, 0x45, 0x48, 0x4d, 0x71, 0x12, 0x5a, 0x18, 0x71, 0x97, 0xb5, 0xe3, 0x2b, 0x95, 0x6a, 0xb4, + 0xef, 0xb2, 0xb6, 0x30, 0x12, 0x9c, 0x30, 0x0a, 0x31, 0x3f, 0x26, 0xb4, 0x6d, 0x5c, 0x9b, 0x6e, + 0xd4, 0x88, 0x10, 0x61, 0x14, 0xd3, 0x42, 0xe8, 0x75, 0xfa, 0x8c, 0x63, 0x6a, 0x64, 0xa7, 0x0b, + 0x2b, 0x11, 0x22, 0x84, 0x31, 0x8d, 0x3e, 0x84, 0x2c, 0xc3, 0x1e, 0xc5, 0xdc, 0x98, 0x93, 0x3a, + 0x33, 0xbd, 0x32, 0x41, 0xd4, 0xc4, 0x45, 0x97, 0x23, 0xf4, 0x00, 0xe6, 0x29, 0x66, 0xa4, 0x4f, + 0x3d, 0x6c, 0xcc, 0x4b, 0xdd, 0xed, 0xd4, 0xcb, 0x11, 0x33, 0x35, 0xc5, 0x19, 0xf1, 0xe8, 0x21, + 0x2c, 0xe0, 0xaf, 0x39, 0x0e, 0x99, 0xd8, 0xbc, 0x05, 0x29, 0x7e, 0x3b, 0x4d, 0x5c, 0x4d, 0xa0, + 0x9a, 0xe2, 0x9c, 0x2b, 0x44, 0xc2, 0x1e, 0x09, 0x8f, 0x82, 0x96, 0x01, 0xd3, 0x13, 0xae, 0x48, + 0x42, 0x24, 0x1c, 0xb1, 0xe5, 0x79, 0xc8, 0x72, 0x97, 0xb6, 0x30, 0xdf, 0xfc, 0x57, 0x85, 0xe5, + 0x89, 0x73, 0x81, 0xde, 0x85, 0xb9, 0x83, 0xc6, 0xa3, 0xc6, 0xee, 0xe7, 0x8d, 0x15, 0xc5, 0x34, + 0x4f, 0x5e, 0xe6, 0xd7, 0x26, 0x88, 0x83, 0xb0, 0x1d, 0x92, 0xe3, 0x10, 0x95, 0xe0, 0xe6, 0xde, + 0xfe, 0xae, 0x53, 0x3d, 0xdc, 0xae, 0xec, 0xd7, 0x77, 0x1b, 0x87, 0x15, 0xa7, 0xba, 0xbd, 0x5f, + 0x5d, 0x51, 0xcd, 0x5b, 0x27, 0x2f, 0xf3, 0xab, 0x13, 0xa2, 0x0a, 0xc5, 0x2e, 0xc7, 0x17, 0x34, + 0x07, 0x4f, 0x77, 0x84, 0x46, 0x4b, 0xd5, 0x1c, 0xf4, 0xfc, 0x34, 0x8d, 0x53, 0x7d, 0xb2, 0xfb, + 0x59, 0x75, 0x25, 0x93, 0xaa, 0x71, 0x64, 0x13, 0x33, 0xdf, 0xfc, 0xee, 0xe7, 0x9c, 0xf2, 0xeb, + 0x2f, 0xb9, 0xc9, 0xea, 0x4a, 0xdf, 0x6b, 0xa0, 0x8b, 0x1b, 0x8a, 0x4e, 0x54, 0x40, 0x17, 0x9b, + 0x07, 0xda, 0x4a, 0x5b, 0xc1, 0xa9, 0x2d, 0xcb, 0xb4, 0xaf, 0x8a, 0xc7, 0x3d, 0x69, 0xf5, 0xf7, + 0x57, 0xff, 0xfc, 0xa8, 0x2d, 0xc3, 0x0d, 0xc9, 0x6f, 0x75, 0xdd, 0xd0, 0x6d, 0x61, 0x8a, 0xbe, + 0x85, 0xa5, 0xff, 0x37, 0x1b, 0xb4, 0x31, 0xed, 0x08, 0x5d, 0x68, 0x67, 0xe6, 0xe6, 0x55, 0xd0, + 0x99, 0xfe, 0xa5, 0x3f, 0x55, 0x58, 0x3a, 0x6f, 0xde, 0xec, 0x79, 0xd0, 0x43, 0x5f, 0x80, 0x2e, + 0x9e, 0x26, 0x94, 0xda, 0x9a, 0xc6, 0x1e, 0x36, 0x33, 0x3f, 0x1d, 0x98, 0x5d, 0xb4, 0x07, 0xd7, + 0xe4, 0xe3, 0x80, 0x52, 0x23, 0x8c, 0xbf, 0x3d, 0xe6, 0x9d, 0x19, 0xc4, 0x4c, 0x93, 0xb2, 0x71, + 0xfa, 0x3a, 0xa7, 0xfc, 0xf5, 0x3a, 0xa7, 0xbc, 0x18, 0xe6, 0xd4, 0xd3, 0x61, 0x4e, 0xfd, 0x63, + 0x98, 0x53, 0xff, 0x1e, 0xe6, 0xd4, 0x67, 0x99, 0x67, 0x7a, 0x33, 0x2b, 0x7f, 0x5b, 0x7c, 0xf0, + 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x64, 0x01, 0xa3, 0x4f, 0x74, 0x09, 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/raft.proto b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/raft.proto index e464f3a6b..b39831584 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/raft.proto +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/raft.proto @@ -2,11 +2,11 @@ syntax = "proto3"; package docker.swarmkit.v1; -import "objects.proto"; -import "types.proto"; +import "github.com/docker/swarmkit/api/objects.proto"; +import "github.com/docker/swarmkit/api/types.proto"; import "github.com/coreos/etcd/raft/raftpb/raft.proto"; import weak "gogoproto/gogo.proto"; -import weak "plugin/plugin.proto"; +import weak "github.com/docker/swarmkit/protobuf/plugin/plugin.proto"; // Raft defines the RPC communication between raft nodes. service Raft { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/resource.pb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/resource.pb.go index 4afd800b9..ead5d27ef 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/resource.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/resource.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. -// source: resource.proto +// source: github.com/docker/swarmkit/api/resource.proto // DO NOT EDIT! package api @@ -262,7 +262,7 @@ var _ResourceAllocator_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "resource.proto", + Metadata: "github.com/docker/swarmkit/api/resource.proto", } func (m *AttachNetworkRequest) Marshal() (dAtA []byte, err error) { @@ -1061,31 +1061,35 @@ var ( ErrIntOverflowResource = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("resource.proto", fileDescriptorResource) } +func init() { + proto.RegisterFile("github.com/docker/swarmkit/api/resource.proto", fileDescriptorResource) +} var fileDescriptorResource = []byte{ - // 368 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2b, 0x4a, 0x2d, 0xce, - 0x2f, 0x2d, 0x4a, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x4a, 0xc9, 0x4f, 0xce, - 0x4e, 0x2d, 0xd2, 0x2b, 0x2e, 0x4f, 0x2c, 0xca, 0xcd, 0xce, 0x2c, 0xd1, 0x2b, 0x33, 0x94, 0xe2, - 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x86, 0x28, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x33, 0xf5, - 0x41, 0x2c, 0xa8, 0xa8, 0x70, 0x41, 0x4e, 0x69, 0x7a, 0x66, 0x9e, 0x3e, 0x84, 0x82, 0x08, 0x2a, - 0xf5, 0x33, 0x72, 0x89, 0x38, 0x96, 0x94, 0x24, 0x26, 0x67, 0xf8, 0xa5, 0x96, 0x94, 0xe7, 0x17, - 0x65, 0x07, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x08, 0x39, 0x73, 0xb1, 0x25, 0xe7, 0xe7, 0xa5, - 0x65, 0xa6, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0x69, 0xeb, 0x61, 0xda, 0xaa, 0x07, 0xd5, - 0x03, 0x31, 0x20, 0x37, 0x35, 0xaf, 0xc4, 0x19, 0xac, 0x25, 0x08, 0xaa, 0x55, 0xc8, 0x88, 0x8b, - 0x27, 0x39, 0x3f, 0xaf, 0x24, 0x31, 0x33, 0x2f, 0xb5, 0x28, 0x3e, 0x33, 0x45, 0x82, 0x49, 0x81, - 0x51, 0x83, 0xd3, 0x89, 0xff, 0xd1, 0x3d, 0x79, 0x6e, 0x67, 0x98, 0xb8, 0xa7, 0x4b, 0x10, 0x37, - 0x5c, 0x91, 0x67, 0x8a, 0x92, 0x1f, 0x97, 0x28, 0x9a, 0x83, 0x8a, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, - 0x85, 0x4c, 0xb9, 0x78, 0x13, 0xe1, 0x16, 0x81, 0x4c, 0x63, 0x04, 0x9b, 0x26, 0xf0, 0xe8, 0x9e, - 0x3c, 0x0f, 0xc2, 0x05, 0x9e, 0x2e, 0x41, 0x3c, 0x08, 0x65, 0x9e, 0x29, 0x4a, 0xbe, 0x5c, 0x22, - 0x2e, 0xa9, 0x58, 0x3c, 0x48, 0xa6, 0x71, 0xe2, 0x5c, 0xa2, 0x68, 0xc6, 0x41, 0x9c, 0x67, 0xb4, - 0x9a, 0x89, 0x4b, 0x30, 0x08, 0x1a, 0x51, 0x8e, 0x39, 0x39, 0xf9, 0xc9, 0x89, 0x25, 0xf9, 0x45, - 0x42, 0x9d, 0x8c, 0x5c, 0xbc, 0x28, 0xde, 0x11, 0xd2, 0xc0, 0x16, 0x90, 0xd8, 0xa2, 0x40, 0x4a, - 0x93, 0x08, 0x95, 0x10, 0xcb, 0x95, 0x94, 0x4f, 0xad, 0x7b, 0x37, 0x83, 0x49, 0x96, 0x8b, 0x07, - 0xac, 0x54, 0x17, 0x24, 0x97, 0x5a, 0xc4, 0xc5, 0x0b, 0xe1, 0xe5, 0x26, 0xe6, 0x25, 0xa6, 0xa7, - 0x42, 0xdc, 0x82, 0xe2, 0x76, 0xec, 0x6e, 0xc1, 0x16, 0x5a, 0xd8, 0xdd, 0x82, 0x35, 0x20, 0x88, - 0x72, 0x8b, 0x93, 0xc4, 0x89, 0x87, 0x72, 0x0c, 0x37, 0x1e, 0xca, 0x31, 0x34, 0x3c, 0x92, 0x63, - 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x93, 0xd8, 0xc0, - 0x09, 0xd3, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x1c, 0x48, 0x12, 0x41, 0xf6, 0x02, 0x00, 0x00, + // 397 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xcf, 0x4e, 0xf2, 0x40, + 0x14, 0xc5, 0x19, 0x16, 0x24, 0xdf, 0x50, 0xf2, 0x69, 0x03, 0x91, 0x90, 0x58, 0x48, 0xdd, 0xa0, + 0x86, 0x36, 0x62, 0x8c, 0x6b, 0xfe, 0x6c, 0xba, 0x90, 0x45, 0x5f, 0xc0, 0x0c, 0xed, 0x50, 0x1a, + 0x68, 0xa7, 0x4e, 0xa7, 0x12, 0x77, 0x6e, 0x5d, 0xb9, 0xf5, 0x1d, 0x4c, 0x7c, 0x0e, 0xe2, 0xca, + 0xa5, 0x2b, 0x22, 0x7d, 0x00, 0x9f, 0xc1, 0xd0, 0x29, 0x10, 0x70, 0xa2, 0xc4, 0x55, 0xa7, 0xd3, + 0x73, 0xce, 0xfd, 0xdd, 0x7b, 0x0b, 0x1b, 0x8e, 0xcb, 0x86, 0x51, 0x5f, 0xb3, 0x88, 0xa7, 0xdb, + 0xc4, 0x1a, 0x61, 0xaa, 0x87, 0x13, 0x44, 0xbd, 0x91, 0xcb, 0x74, 0x14, 0xb8, 0x3a, 0xc5, 0x21, + 0x89, 0xa8, 0x85, 0xb5, 0x80, 0x12, 0x46, 0x64, 0x99, 0x6b, 0xb4, 0xa5, 0x46, 0xbb, 0x3d, 0xab, + 0x9c, 0xfc, 0x12, 0xc1, 0xee, 0x02, 0x1c, 0x72, 0x7f, 0xa5, 0xe8, 0x10, 0x87, 0x24, 0x47, 0x7d, + 0x71, 0x4a, 0x6f, 0x2f, 0x7f, 0x48, 0x48, 0x14, 0xfd, 0x68, 0xa0, 0x07, 0xe3, 0xc8, 0x71, 0xfd, + 0xf4, 0xc1, 0x8d, 0xea, 0x23, 0x80, 0xc5, 0x16, 0x63, 0xc8, 0x1a, 0xf6, 0x30, 0x9b, 0x10, 0x3a, + 0x32, 0xf1, 0x4d, 0x84, 0x43, 0x26, 0x77, 0x60, 0xce, 0x22, 0xfe, 0xc0, 0x75, 0xca, 0xa0, 0x06, + 0xea, 0xf9, 0xe6, 0xa9, 0xf6, 0x1d, 0x5c, 0x4b, 0x3d, 0x3c, 0xc0, 0xc3, 0x3e, 0xeb, 0x24, 0x16, + 0x33, 0xb5, 0xca, 0x4d, 0x28, 0x59, 0xc4, 0x67, 0xc8, 0xf5, 0x31, 0xbd, 0x76, 0xed, 0x72, 0xb6, + 0x06, 0xea, 0xff, 0xda, 0xff, 0xe3, 0x59, 0x35, 0xdf, 0x59, 0xde, 0x1b, 0x5d, 0x33, 0xbf, 0x12, + 0x19, 0xb6, 0xda, 0x83, 0xa5, 0x2d, 0xa0, 0x30, 0x20, 0x7e, 0x88, 0xe5, 0x0b, 0x58, 0x40, 0xab, + 0x42, 0x8b, 0x34, 0x90, 0xa4, 0xed, 0xc5, 0xb3, 0xaa, 0xb4, 0x26, 0x30, 0xba, 0xa6, 0xb4, 0x96, + 0x19, 0xb6, 0x7a, 0x05, 0x8b, 0x5d, 0x2c, 0x68, 0xf0, 0x8f, 0x71, 0x07, 0xb0, 0xb4, 0x15, 0xc7, + 0xf1, 0x9a, 0xcf, 0x59, 0xb8, 0x6f, 0xa6, 0xbb, 0x6e, 0x8d, 0xc7, 0xc4, 0x42, 0x8c, 0x50, 0xf9, + 0x01, 0xc0, 0xc2, 0x46, 0x3b, 0x72, 0x5d, 0x34, 0x48, 0xd1, 0x0a, 0x2a, 0xc7, 0x3b, 0x28, 0x79, + 0x71, 0xf5, 0xe8, 0xf5, 0xe5, 0xf3, 0x29, 0x7b, 0x08, 0xa5, 0x44, 0xda, 0x58, 0x7c, 0xc3, 0x14, + 0x16, 0xf8, 0x9b, 0x87, 0x7c, 0xe4, 0x60, 0xce, 0xb2, 0xc1, 0x2e, 0x66, 0x11, 0x4d, 0x4b, 0xcc, + 0x22, 0x1c, 0xc4, 0x4e, 0x2c, 0xed, 0xf2, 0x74, 0xae, 0x64, 0xde, 0xe7, 0x4a, 0xe6, 0x3e, 0x56, + 0xc0, 0x34, 0x56, 0xc0, 0x5b, 0xac, 0x80, 0x8f, 0x58, 0x01, 0xfd, 0x5c, 0xf2, 0x63, 0x9e, 0x7f, + 0x05, 0x00, 0x00, 0xff, 0xff, 0xc1, 0x7a, 0x29, 0xfc, 0x58, 0x03, 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/resource.proto b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/resource.proto index 92a8302f4..ecaa749ee 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/resource.proto +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/resource.proto @@ -2,9 +2,9 @@ syntax = "proto3"; package docker.swarmkit.v1; -import "types.proto"; +import "github.com/docker/swarmkit/api/types.proto"; import "gogoproto/gogo.proto"; -import "plugin/plugin.proto"; +import "github.com/docker/swarmkit/protobuf/plugin/plugin.proto"; // Allocator is the API provided by a manager group for agents to control the allocation of certain entities. // diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/snapshot.pb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/snapshot.pb.go index 928d1c7de..f8c32b772 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/snapshot.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/snapshot.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. -// source: snapshot.proto +// source: github.com/docker/swarmkit/api/snapshot.proto // DO NOT EDIT! package api @@ -1305,38 +1305,41 @@ var ( ErrIntOverflowSnapshot = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("snapshot.proto", fileDescriptorSnapshot) } +func init() { + proto.RegisterFile("github.com/docker/swarmkit/api/snapshot.proto", fileDescriptorSnapshot) +} var fileDescriptorSnapshot = []byte{ - // 469 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0xbf, 0x6f, 0xd3, 0x40, - 0x14, 0xc7, 0x7d, 0xce, 0x0f, 0xa7, 0xaf, 0x6a, 0x29, 0x27, 0x86, 0x53, 0x28, 0x26, 0x04, 0x86, - 0x4c, 0x06, 0x02, 0x12, 0x08, 0xa9, 0x0c, 0xa9, 0x18, 0x18, 0xe8, 0x70, 0x41, 0x15, 0xab, 0xe3, - 0x5c, 0x52, 0x63, 0xe2, 0x8b, 0xee, 0x5d, 0x53, 0x46, 0xf8, 0xef, 0x32, 0x32, 0x32, 0x21, 0x92, - 0x85, 0x7f, 0x03, 0xdd, 0x9d, 0x6d, 0x22, 0xe1, 0x74, 0xb3, 0x4e, 0x9f, 0xcf, 0x7b, 0xdf, 0x3b, - 0xbf, 0x07, 0xc7, 0x98, 0xc7, 0x4b, 0xbc, 0x92, 0x3a, 0x5a, 0x2a, 0xa9, 0x25, 0xa5, 0x53, 0x99, - 0x64, 0x42, 0x45, 0x78, 0x13, 0xab, 0x45, 0x96, 0xea, 0x68, 0xf5, 0xbc, 0x7b, 0x24, 0x27, 0x9f, - 0x45, 0xa2, 0xd1, 0x21, 0x5d, 0x50, 0xf1, 0xac, 0xc0, 0xbb, 0xf7, 0xe6, 0x72, 0x2e, 0xed, 0xe7, - 0x53, 0xf3, 0xe5, 0x4e, 0xfb, 0xdf, 0x9b, 0x70, 0x34, 0xd6, 0x52, 0x89, 0x71, 0x51, 0x9c, 0x46, - 0xd0, 0xca, 0xe5, 0x54, 0x20, 0x23, 0xbd, 0xc6, 0xe0, 0x70, 0xc8, 0xa2, 0xff, 0xdb, 0x44, 0x17, - 0x72, 0x2a, 0xb8, 0xc3, 0xe8, 0x2b, 0xe8, 0xa0, 0x50, 0xab, 0x34, 0x11, 0xc8, 0x7c, 0xab, 0xdc, - 0xaf, 0x53, 0xc6, 0x8e, 0xe1, 0x15, 0x6c, 0xc4, 0x5c, 0xe8, 0x1b, 0xa9, 0x32, 0x64, 0x8d, 0xfd, - 0xe2, 0x85, 0x63, 0x78, 0x05, 0x9b, 0x84, 0x3a, 0xc6, 0x0c, 0x59, 0x73, 0x7f, 0xc2, 0x8f, 0x31, - 0x66, 0xdc, 0x61, 0xa6, 0x51, 0xf2, 0xe5, 0x1a, 0xb5, 0x50, 0xc8, 0x5a, 0xfb, 0x1b, 0x9d, 0x3b, - 0x86, 0x57, 0x30, 0x7d, 0x09, 0x01, 0x8a, 0x44, 0x09, 0x8d, 0xac, 0x6d, 0xbd, 0x6e, 0xfd, 0xcd, - 0x0c, 0xc2, 0x4b, 0x94, 0xbe, 0x81, 0x03, 0x25, 0x50, 0x5e, 0x2b, 0xf3, 0x22, 0x81, 0xf5, 0x4e, - 0xeb, 0x3c, 0x5e, 0x40, 0xfc, 0x1f, 0x4e, 0xcf, 0x00, 0xc4, 0x57, 0x2d, 0x72, 0x4c, 0x65, 0x8e, - 0xac, 0x63, 0xe5, 0x07, 0x75, 0xf2, 0xbb, 0x92, 0xe2, 0x3b, 0x82, 0x09, 0x9c, 0xc8, 0x7c, 0x96, - 0xce, 0x91, 0x1d, 0xec, 0x0f, 0x7c, 0x6e, 0x11, 0x5e, 0xa2, 0xfd, 0x14, 0xee, 0x14, 0x77, 0xaf, - 0x86, 0xe0, 0x35, 0x04, 0x0b, 0xb1, 0x98, 0x98, 0x17, 0x73, 0x63, 0x10, 0xd6, 0xde, 0x20, 0x9e, - 0xe9, 0x0f, 0x16, 0xe3, 0x25, 0x4e, 0x4f, 0x21, 0x50, 0x62, 0x21, 0x57, 0x62, 0x6a, 0xa7, 0xa1, - 0x39, 0xf2, 0x4f, 0x3c, 0x5e, 0x1e, 0xf5, 0xff, 0x10, 0xe8, 0x54, 0x4d, 0xde, 0x42, 0xb0, 0x12, - 0xca, 0x24, 0x67, 0xa4, 0x47, 0x06, 0xc7, 0xc3, 0x27, 0xb5, 0xcf, 0x5b, 0x4e, 0xfd, 0xa5, 0x63, - 0x79, 0x29, 0xd1, 0xf7, 0x00, 0x45, 0xd7, 0xab, 0x74, 0xc9, 0xfc, 0x1e, 0x19, 0x1c, 0x0e, 0x1f, - 0xdf, 0xf2, 0x67, 0xcb, 0x4a, 0xa3, 0xe6, 0xfa, 0xd7, 0x43, 0x8f, 0xef, 0xc8, 0xf4, 0x0c, 0x5a, - 0x68, 0xb6, 0x80, 0x35, 0x6c, 0x95, 0x47, 0xb5, 0x41, 0x76, 0xd7, 0xa4, 0xa8, 0xe1, 0xac, 0xfe, - 0x5d, 0x08, 0x8a, 0x74, 0xb4, 0x0d, 0xfe, 0xe5, 0xb3, 0x13, 0x6f, 0xc4, 0xd6, 0x9b, 0xd0, 0xfb, - 0xb9, 0x09, 0xbd, 0x6f, 0xdb, 0x90, 0xac, 0xb7, 0x21, 0xf9, 0xb1, 0x0d, 0xc9, 0xef, 0x6d, 0x48, - 0x3e, 0xf9, 0x93, 0xb6, 0xdd, 0xbd, 0x17, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x8d, 0x0f, 0xc4, - 0x6e, 0xd2, 0x03, 0x00, 0x00, + // 493 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xbf, 0x8f, 0xd3, 0x30, + 0x14, 0xc7, 0x93, 0xf4, 0x47, 0x7a, 0x3e, 0x01, 0x87, 0xc5, 0x60, 0x95, 0x23, 0x94, 0xc2, 0x50, + 0x24, 0x48, 0xa0, 0x20, 0x81, 0x90, 0x8e, 0xa1, 0x27, 0x06, 0x06, 0x6e, 0x70, 0xd1, 0x89, 0x35, + 0x4d, 0xdd, 0x36, 0x84, 0xc4, 0x95, 0x9f, 0xdb, 0x63, 0x84, 0xff, 0xae, 0x23, 0x23, 0x13, 0xe2, + 0xba, 0xf0, 0x6f, 0x20, 0xdb, 0x71, 0xa8, 0x44, 0x7a, 0xb7, 0x45, 0xd6, 0xe7, 0xf3, 0xde, 0xd7, + 0xce, 0x7b, 0xe8, 0xe9, 0x3c, 0x95, 0x8b, 0xd5, 0x24, 0x4c, 0x78, 0x1e, 0x4d, 0x79, 0x92, 0x31, + 0x11, 0xc1, 0x45, 0x2c, 0xf2, 0x2c, 0x95, 0x51, 0xbc, 0x4c, 0x23, 0x28, 0xe2, 0x25, 0x2c, 0xb8, + 0x0c, 0x97, 0x82, 0x4b, 0x8e, 0xb1, 0x61, 0x42, 0xcb, 0x84, 0xeb, 0xe7, 0xdd, 0x27, 0xd7, 0x94, + 0xe0, 0x93, 0xcf, 0x2c, 0x91, 0x60, 0x2a, 0x74, 0x1f, 0x5f, 0x43, 0x8b, 0x78, 0x56, 0x36, 0xeb, + 0xde, 0x99, 0xf3, 0x39, 0xd7, 0x9f, 0x91, 0xfa, 0x32, 0xa7, 0xfd, 0xef, 0x4d, 0x74, 0x63, 0x2c, + 0xb9, 0x60, 0xe3, 0x32, 0x1a, 0x0e, 0x51, 0xab, 0xe0, 0x53, 0x06, 0xc4, 0xed, 0x35, 0x06, 0x87, + 0x43, 0x12, 0xfe, 0x1f, 0x32, 0x3c, 0xe3, 0x53, 0x46, 0x0d, 0x86, 0x5f, 0xa1, 0x0e, 0x30, 0xb1, + 0x4e, 0x13, 0x06, 0xc4, 0xd3, 0xca, 0xdd, 0x3a, 0x65, 0x6c, 0x18, 0x5a, 0xc1, 0x4a, 0x2c, 0x98, + 0xbc, 0xe0, 0x22, 0x03, 0xd2, 0xd8, 0x2f, 0x9e, 0x19, 0x86, 0x56, 0xb0, 0x4a, 0x28, 0x63, 0xc8, + 0x80, 0x34, 0xf7, 0x27, 0xfc, 0x18, 0x43, 0x46, 0x0d, 0xa6, 0x1a, 0x25, 0x5f, 0x56, 0x20, 0x99, + 0x00, 0xd2, 0xda, 0xdf, 0xe8, 0xd4, 0x30, 0xb4, 0x82, 0xf1, 0x4b, 0xe4, 0x03, 0x4b, 0x04, 0x93, + 0x40, 0xda, 0xda, 0xeb, 0xd6, 0xdf, 0x4c, 0x21, 0xd4, 0xa2, 0xf8, 0x0d, 0x3a, 0x10, 0x0c, 0xf8, + 0x4a, 0xa8, 0x17, 0xf1, 0xb5, 0x77, 0x5c, 0xe7, 0xd1, 0x12, 0xa2, 0xff, 0x70, 0x7c, 0x82, 0x10, + 0xfb, 0x2a, 0x59, 0x01, 0x29, 0x2f, 0x80, 0x74, 0xb4, 0x7c, 0xaf, 0x4e, 0x7e, 0x67, 0x29, 0xba, + 0x23, 0xa8, 0xc0, 0x09, 0x2f, 0x66, 0xe9, 0x1c, 0xc8, 0xc1, 0xfe, 0xc0, 0xa7, 0x1a, 0xa1, 0x16, + 0xed, 0xa7, 0xe8, 0x56, 0x79, 0xf7, 0x6a, 0x08, 0x5e, 0x23, 0x3f, 0x67, 0xf9, 0x44, 0xbd, 0x98, + 0x19, 0x83, 0xa0, 0xf6, 0x06, 0xf1, 0x4c, 0x7e, 0xd0, 0x18, 0xb5, 0x38, 0x3e, 0x46, 0xbe, 0x60, + 0x39, 0x5f, 0xb3, 0xa9, 0x9e, 0x86, 0xe6, 0xc8, 0x3b, 0x72, 0xa8, 0x3d, 0xea, 0xff, 0x71, 0x51, + 0xa7, 0x6a, 0xf2, 0x16, 0xf9, 0x6b, 0x26, 0x54, 0x72, 0xe2, 0xf6, 0xdc, 0xc1, 0xcd, 0xe1, 0xa3, + 0xda, 0xe7, 0xb5, 0x3b, 0x73, 0x6e, 0x58, 0x6a, 0x25, 0xfc, 0x1e, 0xa1, 0xb2, 0xeb, 0x22, 0x5d, + 0x12, 0xaf, 0xe7, 0x0e, 0x0e, 0x87, 0x0f, 0xaf, 0xf8, 0xb3, 0xb6, 0xd2, 0xa8, 0xb9, 0xf9, 0x75, + 0xdf, 0xa1, 0x3b, 0x32, 0x3e, 0x41, 0x2d, 0x50, 0x5b, 0x40, 0x1a, 0xba, 0xca, 0x83, 0xda, 0x20, + 0xbb, 0x6b, 0x52, 0xd6, 0x30, 0x56, 0xff, 0x36, 0xf2, 0xcb, 0x74, 0xb8, 0x8d, 0xbc, 0xf3, 0x67, + 0x47, 0xce, 0x88, 0x6c, 0x2e, 0x03, 0xe7, 0xe7, 0x65, 0xe0, 0x7c, 0xdb, 0x06, 0xee, 0x66, 0x1b, + 0xb8, 0x3f, 0xb6, 0x81, 0xfb, 0x7b, 0x1b, 0xb8, 0x9f, 0xbc, 0x49, 0x5b, 0xef, 0xde, 0x8b, 0xbf, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xfd, 0xbe, 0x47, 0xec, 0x2f, 0x04, 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/snapshot.proto b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/snapshot.proto index 713649c52..91e9592d4 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/snapshot.proto +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/snapshot.proto @@ -2,8 +2,8 @@ syntax = "proto3"; package docker.swarmkit.v1; -import "objects.proto"; -import "raft.proto"; +import "github.com/docker/swarmkit/api/objects.proto"; +import "github.com/docker/swarmkit/api/raft.proto"; import weak "gogoproto/gogo.proto"; // StoreSnapshot is used to store snapshots of the store. diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/specs.pb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/specs.pb.go index bb9b0db91..3d000fbc3 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/specs.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/specs.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. -// source: specs.proto +// source: github.com/docker/swarmkit/api/specs.proto // DO NOT EDIT! package api @@ -107,7 +107,7 @@ func (x EndpointSpec_ResolutionMode) String() string { return proto.EnumName(EndpointSpec_ResolutionMode_name, int32(x)) } func (EndpointSpec_ResolutionMode) EnumDescriptor() ([]byte, []int) { - return fileDescriptorSpecs, []int{8, 0} + return fileDescriptorSpecs, []int{9, 0} } type NodeSpec struct { @@ -310,6 +310,15 @@ type TaskSpec struct { // using the same reconciliation-based mechanism that performs rolling // updates. ForceUpdate uint64 `protobuf:"varint,9,opt,name=force_update,json=forceUpdate,proto3" json:"force_update,omitempty"` + // ResourceReferences provides a generic way to specify resources that + // are used by this task, and should be sent down to agents along with + // the task. Inside the runtime field there may be more specific + // information about how to use the resource, but ResourceReferences + // establishes the relationship at the store level, and instructs the + // dispatcher to send the related objects. + // + // ResourceReferences is a list of ResourceReferences used by the task. + ResourceReferences []ResourceReference `protobuf:"bytes,11,rep,name=resource_references,json=resourceReferences" json:"resource_references"` } func (m *TaskSpec) Reset() { *m = TaskSpec{} } @@ -457,6 +466,15 @@ func _TaskSpec_OneofSizer(msg proto.Message) (n int) { return n } +type ResourceReference struct { + ResourceID string `protobuf:"bytes,1,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"` + ResourceType ResourceType `protobuf:"varint,2,opt,name=resource_type,json=resourceType,proto3,enum=docker.swarmkit.v1.ResourceType" json:"resource_type,omitempty"` +} + +func (m *ResourceReference) Reset() { *m = ResourceReference{} } +func (*ResourceReference) ProtoMessage() {} +func (*ResourceReference) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{5} } + type GenericRuntimeSpec struct { Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"` Payload *google_protobuf3.Any `protobuf:"bytes,2,opt,name=payload" json:"payload,omitempty"` @@ -464,7 +482,7 @@ type GenericRuntimeSpec struct { func (m *GenericRuntimeSpec) Reset() { *m = GenericRuntimeSpec{} } func (*GenericRuntimeSpec) ProtoMessage() {} -func (*GenericRuntimeSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{5} } +func (*GenericRuntimeSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{6} } // NetworkAttachmentSpec specifies runtime parameters required to attach // a container to a network. @@ -476,7 +494,7 @@ type NetworkAttachmentSpec struct { func (m *NetworkAttachmentSpec) Reset() { *m = NetworkAttachmentSpec{} } func (*NetworkAttachmentSpec) ProtoMessage() {} -func (*NetworkAttachmentSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{6} } +func (*NetworkAttachmentSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{7} } // Container specifies runtime parameters for a container. type ContainerSpec struct { @@ -567,11 +585,96 @@ type ContainerSpec struct { // task will exit and a new task will be rescheduled elsewhere. A container // is considered unhealthy after `Retries` number of consecutive failures. Healthcheck *HealthConfig `protobuf:"bytes,16,opt,name=healthcheck" json:"healthcheck,omitempty"` + // Run a custom init inside the container, if null, use the daemon's configured settings + // + // Types that are valid to be assigned to Init: + // *ContainerSpec_InitValue + Init isContainerSpec_Init `protobuf_oneof:"init"` } func (m *ContainerSpec) Reset() { *m = ContainerSpec{} } func (*ContainerSpec) ProtoMessage() {} -func (*ContainerSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{7} } +func (*ContainerSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{8} } + +type isContainerSpec_Init interface { + isContainerSpec_Init() + MarshalTo([]byte) (int, error) + Size() int +} + +type ContainerSpec_InitValue struct { + InitValue bool `protobuf:"varint,23,opt,name=init_value,json=initValue,proto3,oneof"` +} + +func (*ContainerSpec_InitValue) isContainerSpec_Init() {} + +func (m *ContainerSpec) GetInit() isContainerSpec_Init { + if m != nil { + return m.Init + } + return nil +} + +func (m *ContainerSpec) GetInitValue() bool { + if x, ok := m.GetInit().(*ContainerSpec_InitValue); ok { + return x.InitValue + } + return false +} + +// XXX_OneofFuncs is for the internal use of the proto package. +func (*ContainerSpec) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _ContainerSpec_OneofMarshaler, _ContainerSpec_OneofUnmarshaler, _ContainerSpec_OneofSizer, []interface{}{ + (*ContainerSpec_InitValue)(nil), + } +} + +func _ContainerSpec_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*ContainerSpec) + // init + switch x := m.Init.(type) { + case *ContainerSpec_InitValue: + t := uint64(0) + if x.InitValue { + t = 1 + } + _ = b.EncodeVarint(23<<3 | proto.WireVarint) + _ = b.EncodeVarint(t) + case nil: + default: + return fmt.Errorf("ContainerSpec.Init has unexpected type %T", x) + } + return nil +} + +func _ContainerSpec_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*ContainerSpec) + switch tag { + case 23: // init.init_value + if wire != proto.WireVarint { + return true, proto.ErrInternalBadWireType + } + x, err := b.DecodeVarint() + m.Init = &ContainerSpec_InitValue{x != 0} + return true, err + default: + return false, nil + } +} + +func _ContainerSpec_OneofSizer(msg proto.Message) (n int) { + m := msg.(*ContainerSpec) + // init + switch x := m.Init.(type) { + case *ContainerSpec_InitValue: + n += proto.SizeVarint(23<<3 | proto.WireVarint) + n += 1 + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) + } + return n +} // PullOptions allows one to parameterize an image pull. type ContainerSpec_PullOptions struct { @@ -585,7 +688,7 @@ type ContainerSpec_PullOptions struct { func (m *ContainerSpec_PullOptions) Reset() { *m = ContainerSpec_PullOptions{} } func (*ContainerSpec_PullOptions) ProtoMessage() {} func (*ContainerSpec_PullOptions) Descriptor() ([]byte, []int) { - return fileDescriptorSpecs, []int{7, 1} + return fileDescriptorSpecs, []int{8, 1} } // DNSConfig specifies DNS related configurations in resolver configuration file (resolv.conf) @@ -603,7 +706,7 @@ type ContainerSpec_DNSConfig struct { func (m *ContainerSpec_DNSConfig) Reset() { *m = ContainerSpec_DNSConfig{} } func (*ContainerSpec_DNSConfig) ProtoMessage() {} -func (*ContainerSpec_DNSConfig) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{7, 2} } +func (*ContainerSpec_DNSConfig) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{8, 2} } // EndpointSpec defines the properties that can be configured to // access and loadbalance the service. @@ -616,7 +719,7 @@ type EndpointSpec struct { func (m *EndpointSpec) Reset() { *m = EndpointSpec{} } func (*EndpointSpec) ProtoMessage() {} -func (*EndpointSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{8} } +func (*EndpointSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{9} } // NetworkSpec specifies user defined network parameters. type NetworkSpec struct { @@ -651,7 +754,7 @@ type NetworkSpec struct { func (m *NetworkSpec) Reset() { *m = NetworkSpec{} } func (*NetworkSpec) ProtoMessage() {} -func (*NetworkSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{9} } +func (*NetworkSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{10} } type isNetworkSpec_ConfigFrom interface { isNetworkSpec_ConfigFrom() @@ -753,7 +856,7 @@ type ClusterSpec struct { func (m *ClusterSpec) Reset() { *m = ClusterSpec{} } func (*ClusterSpec) ProtoMessage() {} -func (*ClusterSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{10} } +func (*ClusterSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{11} } // SecretSpec specifies a user-provided secret. type SecretSpec struct { @@ -772,7 +875,7 @@ type SecretSpec struct { func (m *SecretSpec) Reset() { *m = SecretSpec{} } func (*SecretSpec) ProtoMessage() {} -func (*SecretSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{11} } +func (*SecretSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{12} } // ConfigSpec specifies user-provided configuration files. type ConfigSpec struct { @@ -791,7 +894,7 @@ type ConfigSpec struct { func (m *ConfigSpec) Reset() { *m = ConfigSpec{} } func (*ConfigSpec) ProtoMessage() {} -func (*ConfigSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{12} } +func (*ConfigSpec) Descriptor() ([]byte, []int) { return fileDescriptorSpecs, []int{13} } func init() { proto.RegisterType((*NodeSpec)(nil), "docker.swarmkit.v1.NodeSpec") @@ -799,6 +902,7 @@ func init() { proto.RegisterType((*ReplicatedService)(nil), "docker.swarmkit.v1.ReplicatedService") proto.RegisterType((*GlobalService)(nil), "docker.swarmkit.v1.GlobalService") proto.RegisterType((*TaskSpec)(nil), "docker.swarmkit.v1.TaskSpec") + proto.RegisterType((*ResourceReference)(nil), "docker.swarmkit.v1.ResourceReference") proto.RegisterType((*GenericRuntimeSpec)(nil), "docker.swarmkit.v1.GenericRuntimeSpec") proto.RegisterType((*NetworkAttachmentSpec)(nil), "docker.swarmkit.v1.NetworkAttachmentSpec") proto.RegisterType((*ContainerSpec)(nil), "docker.swarmkit.v1.ContainerSpec") @@ -946,6 +1050,13 @@ func (m *TaskSpec) CopyFrom(src interface{}) { } } + if o.ResourceReferences != nil { + m.ResourceReferences = make([]ResourceReference, len(o.ResourceReferences)) + for i := range m.ResourceReferences { + github_com_docker_swarmkit_api_deepcopy.Copy(&m.ResourceReferences[i], &o.ResourceReferences[i]) + } + } + if o.Runtime != nil { switch o.Runtime.(type) { case *TaskSpec_Attachment: @@ -971,6 +1082,21 @@ func (m *TaskSpec) CopyFrom(src interface{}) { } +func (m *ResourceReference) Copy() *ResourceReference { + if m == nil { + return nil + } + o := &ResourceReference{} + o.CopyFrom(m) + return o +} + +func (m *ResourceReference) CopyFrom(src interface{}) { + + o := src.(*ResourceReference) + *m = *o +} + func (m *GenericRuntimeSpec) Copy() *GenericRuntimeSpec { if m == nil { return nil @@ -1093,6 +1219,16 @@ func (m *ContainerSpec) CopyFrom(src interface{}) { m.Healthcheck = &HealthConfig{} github_com_docker_swarmkit_api_deepcopy.Copy(m.Healthcheck, o.Healthcheck) } + if o.Init != nil { + switch o.Init.(type) { + case *ContainerSpec_InitValue: + v := ContainerSpec_InitValue{ + InitValue: o.GetInitValue(), + } + m.Init = &v + } + } + } func (m *ContainerSpec_PullOptions) Copy() *ContainerSpec_PullOptions { @@ -1544,6 +1680,18 @@ func (m *TaskSpec) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintSpecs(dAtA, i, uint64(m.ForceUpdate)) } + if len(m.ResourceReferences) > 0 { + for _, msg := range m.ResourceReferences { + dAtA[i] = 0x5a + i++ + i = encodeVarintSpecs(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } return i, nil } @@ -1589,6 +1737,35 @@ func (m *TaskSpec_Generic) MarshalTo(dAtA []byte) (int, error) { } return i, nil } +func (m *ResourceReference) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResourceReference) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.ResourceID) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintSpecs(dAtA, i, uint64(len(m.ResourceID))) + i += copy(dAtA[i:], m.ResourceID) + } + if m.ResourceType != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintSpecs(dAtA, i, uint64(m.ResourceType)) + } + return i, nil +} + func (m *GenericRuntimeSpec) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1914,9 +2091,30 @@ func (m *ContainerSpec) MarshalTo(dAtA []byte) (int, error) { } i += n23 } + if m.Init != nil { + nn24, err := m.Init.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += nn24 + } return i, nil } +func (m *ContainerSpec_InitValue) MarshalTo(dAtA []byte) (int, error) { + i := 0 + dAtA[i] = 0xb8 + i++ + dAtA[i] = 0x1 + i++ + if m.InitValue { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + return i, nil +} func (m *ContainerSpec_PullOptions) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2059,20 +2257,20 @@ func (m *NetworkSpec) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintSpecs(dAtA, i, uint64(m.Annotations.Size())) - n24, err := m.Annotations.MarshalTo(dAtA[i:]) + n25, err := m.Annotations.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n24 + i += n25 if m.DriverConfig != nil { dAtA[i] = 0x12 i++ i = encodeVarintSpecs(dAtA, i, uint64(m.DriverConfig.Size())) - n25, err := m.DriverConfig.MarshalTo(dAtA[i:]) + n26, err := m.DriverConfig.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n25 + i += n26 } if m.Ipv6Enabled { dAtA[i] = 0x18 @@ -2098,11 +2296,11 @@ func (m *NetworkSpec) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x2a i++ i = encodeVarintSpecs(dAtA, i, uint64(m.IPAM.Size())) - n26, err := m.IPAM.MarshalTo(dAtA[i:]) + n27, err := m.IPAM.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n26 + i += n27 } if m.Attachable { dAtA[i] = 0x30 @@ -2125,11 +2323,11 @@ func (m *NetworkSpec) MarshalTo(dAtA []byte) (int, error) { i++ } if m.ConfigFrom != nil { - nn27, err := m.ConfigFrom.MarshalTo(dAtA[i:]) + nn28, err := m.ConfigFrom.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn27 + i += nn28 } return i, nil } @@ -2160,67 +2358,67 @@ func (m *ClusterSpec) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintSpecs(dAtA, i, uint64(m.Annotations.Size())) - n28, err := m.Annotations.MarshalTo(dAtA[i:]) + n29, err := m.Annotations.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n28 + i += n29 dAtA[i] = 0x12 i++ i = encodeVarintSpecs(dAtA, i, uint64(m.AcceptancePolicy.Size())) - n29, err := m.AcceptancePolicy.MarshalTo(dAtA[i:]) + n30, err := m.AcceptancePolicy.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n29 + i += n30 dAtA[i] = 0x1a i++ i = encodeVarintSpecs(dAtA, i, uint64(m.Orchestration.Size())) - n30, err := m.Orchestration.MarshalTo(dAtA[i:]) + n31, err := m.Orchestration.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n30 + i += n31 dAtA[i] = 0x22 i++ i = encodeVarintSpecs(dAtA, i, uint64(m.Raft.Size())) - n31, err := m.Raft.MarshalTo(dAtA[i:]) + n32, err := m.Raft.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n31 + i += n32 dAtA[i] = 0x2a i++ i = encodeVarintSpecs(dAtA, i, uint64(m.Dispatcher.Size())) - n32, err := m.Dispatcher.MarshalTo(dAtA[i:]) + n33, err := m.Dispatcher.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n32 + i += n33 dAtA[i] = 0x32 i++ i = encodeVarintSpecs(dAtA, i, uint64(m.CAConfig.Size())) - n33, err := m.CAConfig.MarshalTo(dAtA[i:]) + n34, err := m.CAConfig.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n33 + i += n34 dAtA[i] = 0x3a i++ i = encodeVarintSpecs(dAtA, i, uint64(m.TaskDefaults.Size())) - n34, err := m.TaskDefaults.MarshalTo(dAtA[i:]) + n35, err := m.TaskDefaults.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n34 + i += n35 dAtA[i] = 0x42 i++ i = encodeVarintSpecs(dAtA, i, uint64(m.EncryptionConfig.Size())) - n35, err := m.EncryptionConfig.MarshalTo(dAtA[i:]) + n36, err := m.EncryptionConfig.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n35 + i += n36 return i, nil } @@ -2242,11 +2440,11 @@ func (m *SecretSpec) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintSpecs(dAtA, i, uint64(m.Annotations.Size())) - n36, err := m.Annotations.MarshalTo(dAtA[i:]) + n37, err := m.Annotations.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n36 + i += n37 if len(m.Data) > 0 { dAtA[i] = 0x12 i++ @@ -2257,21 +2455,21 @@ func (m *SecretSpec) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintSpecs(dAtA, i, uint64(m.Templating.Size())) - n37, err := m.Templating.MarshalTo(dAtA[i:]) + n38, err := m.Templating.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n37 + i += n38 } if m.Driver != nil { dAtA[i] = 0x22 i++ i = encodeVarintSpecs(dAtA, i, uint64(m.Driver.Size())) - n38, err := m.Driver.MarshalTo(dAtA[i:]) + n39, err := m.Driver.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n38 + i += n39 } return i, nil } @@ -2294,11 +2492,11 @@ func (m *ConfigSpec) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintSpecs(dAtA, i, uint64(m.Annotations.Size())) - n39, err := m.Annotations.MarshalTo(dAtA[i:]) + n40, err := m.Annotations.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n39 + i += n40 if len(m.Data) > 0 { dAtA[i] = 0x12 i++ @@ -2309,11 +2507,11 @@ func (m *ConfigSpec) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintSpecs(dAtA, i, uint64(m.Templating.Size())) - n40, err := m.Templating.MarshalTo(dAtA[i:]) + n41, err := m.Templating.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n40 + i += n41 } return i, nil } @@ -2458,6 +2656,12 @@ func (m *TaskSpec) Size() (n int) { if m.ForceUpdate != 0 { n += 1 + sovSpecs(uint64(m.ForceUpdate)) } + if len(m.ResourceReferences) > 0 { + for _, e := range m.ResourceReferences { + l = e.Size() + n += 1 + l + sovSpecs(uint64(l)) + } + } return n } @@ -2488,6 +2692,19 @@ func (m *TaskSpec_Generic) Size() (n int) { } return n } +func (m *ResourceReference) Size() (n int) { + var l int + _ = l + l = len(m.ResourceID) + if l > 0 { + n += 1 + l + sovSpecs(uint64(l)) + } + if m.ResourceType != 0 { + n += 1 + sovSpecs(uint64(m.ResourceType)) + } + return n +} + func (m *GenericRuntimeSpec) Size() (n int) { var l int _ = l @@ -2620,9 +2837,18 @@ func (m *ContainerSpec) Size() (n int) { l = m.Privileges.Size() n += 2 + l + sovSpecs(uint64(l)) } + if m.Init != nil { + n += m.Init.Size() + } return n } +func (m *ContainerSpec_InitValue) Size() (n int) { + var l int + _ = l + n += 3 + return n +} func (m *ContainerSpec_PullOptions) Size() (n int) { var l int _ = l @@ -2861,6 +3087,7 @@ func (this *TaskSpec) String() string { `LogDriver:` + strings.Replace(fmt.Sprintf("%v", this.LogDriver), "Driver", "Driver", 1) + `,`, `Networks:` + strings.Replace(fmt.Sprintf("%v", this.Networks), "NetworkAttachmentConfig", "NetworkAttachmentConfig", 1) + `,`, `ForceUpdate:` + fmt.Sprintf("%v", this.ForceUpdate) + `,`, + `ResourceReferences:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ResourceReferences), "ResourceReference", "ResourceReference", 1), `&`, ``, 1) + `,`, `}`, }, "") return s @@ -2895,6 +3122,17 @@ func (this *TaskSpec_Generic) String() string { }, "") return s } +func (this *ResourceReference) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ResourceReference{`, + `ResourceID:` + fmt.Sprintf("%v", this.ResourceID) + `,`, + `ResourceType:` + fmt.Sprintf("%v", this.ResourceType) + `,`, + `}`, + }, "") + return s +} func (this *GenericRuntimeSpec) String() string { if this == nil { return "nil" @@ -2953,6 +3191,17 @@ func (this *ContainerSpec) String() string { `StopSignal:` + fmt.Sprintf("%v", this.StopSignal) + `,`, `Configs:` + strings.Replace(fmt.Sprintf("%v", this.Configs), "ConfigReference", "ConfigReference", 1) + `,`, `Privileges:` + strings.Replace(fmt.Sprintf("%v", this.Privileges), "Privileges", "Privileges", 1) + `,`, + `Init:` + fmt.Sprintf("%v", this.Init) + `,`, + `}`, + }, "") + return s +} +func (this *ContainerSpec_InitValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ContainerSpec_InitValue{`, + `InitValue:` + fmt.Sprintf("%v", this.InitValue) + `,`, `}`, }, "") return s @@ -3934,6 +4183,135 @@ func (m *TaskSpec) Unmarshal(dAtA []byte) error { } m.Runtime = &TaskSpec_Generic{v} iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceReferences", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpecs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpecs + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ResourceReferences = append(m.ResourceReferences, ResourceReference{}) + if err := m.ResourceReferences[len(m.ResourceReferences)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpecs(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSpecs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ResourceReference) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpecs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceReference: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceReference: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpecs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpecs + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ResourceID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceType", wireType) + } + m.ResourceType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpecs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResourceType |= (ResourceType(b) & 0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipSpecs(dAtA[iNdEx:]) @@ -4899,6 +5277,27 @@ func (m *ContainerSpec) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 23: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field InitValue", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpecs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + b := bool(v != 0) + m.Init = &ContainerSpec_InitValue{b} default: iNdEx = preIndex skippy, err := skipSpecs(dAtA[iNdEx:]) @@ -6207,126 +6606,133 @@ var ( ErrIntOverflowSpecs = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("specs.proto", fileDescriptorSpecs) } +func init() { proto.RegisterFile("github.com/docker/swarmkit/api/specs.proto", fileDescriptorSpecs) } var fileDescriptorSpecs = []byte{ - // 1880 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0xcf, 0x73, 0x1b, 0x49, - 0x15, 0xb6, 0x6c, 0x59, 0x3f, 0xde, 0xc8, 0x89, 0xdc, 0x24, 0x61, 0xac, 0xb0, 0xb2, 0xa2, 0x0d, - 0xc1, 0xcb, 0x16, 0x72, 0x61, 0xa8, 0x25, 0xbb, 0x61, 0x01, 0xc9, 0x12, 0x8e, 0x31, 0x76, 0x54, - 0x6d, 0x6f, 0x20, 0x27, 0x55, 0x7b, 0xa6, 0x2d, 0x4d, 0x79, 0xd4, 0x3d, 0xf4, 0xf4, 0x68, 0x4b, - 0x37, 0x8e, 0x5b, 0xb9, 0x72, 0x76, 0x71, 0xa0, 0xf8, 0x5f, 0x72, 0xa4, 0x38, 0xc1, 0xc5, 0x45, - 0xfc, 0x2f, 0x70, 0xe3, 0x02, 0xd5, 0x3d, 0x3d, 0xd2, 0x28, 0x19, 0xc7, 0xa9, 0x22, 0x87, 0xbd, - 0x75, 0xbf, 0xfe, 0xbe, 0xd7, 0xdd, 0xaf, 0xbf, 0xee, 0xf7, 0x1a, 0xac, 0x30, 0xa0, 0x4e, 0xd8, - 0x0a, 0x04, 0x97, 0x1c, 0x21, 0x97, 0x3b, 0xe7, 0x54, 0xb4, 0xc2, 0xaf, 0x89, 0x18, 0x9f, 0x7b, - 0xb2, 0x35, 0xf9, 0x71, 0xcd, 0x92, 0xd3, 0x80, 0x1a, 0x40, 0xed, 0xce, 0x90, 0x0f, 0xb9, 0x6e, - 0x6e, 0xab, 0x96, 0xb1, 0xd6, 0x87, 0x9c, 0x0f, 0x7d, 0xba, 0xad, 0x7b, 0xa7, 0xd1, 0xd9, 0xb6, - 0x1b, 0x09, 0x22, 0x3d, 0xce, 0xcc, 0xf8, 0xc6, 0x9b, 0xe3, 0x84, 0x4d, 0xe3, 0xa1, 0xe6, 0x45, - 0x1e, 0x4a, 0x47, 0xdc, 0xa5, 0xc7, 0x01, 0x75, 0xd0, 0x1e, 0x58, 0x84, 0x31, 0x2e, 0x35, 0x37, - 0xb4, 0x73, 0x8d, 0xdc, 0x96, 0xb5, 0xb3, 0xd9, 0x7a, 0x7b, 0x51, 0xad, 0xf6, 0x1c, 0xd6, 0xc9, - 0xbf, 0xba, 0xdc, 0x5c, 0xc2, 0x69, 0x26, 0xfa, 0x25, 0x54, 0x5c, 0x1a, 0x7a, 0x82, 0xba, 0x03, - 0xc1, 0x7d, 0x6a, 0x2f, 0x37, 0x72, 0x5b, 0xb7, 0x76, 0xbe, 0x97, 0xe5, 0x49, 0x4d, 0x8e, 0xb9, - 0x4f, 0xb1, 0x65, 0x18, 0xaa, 0x83, 0xf6, 0x00, 0xc6, 0x74, 0x7c, 0x4a, 0x45, 0x38, 0xf2, 0x02, - 0x7b, 0x45, 0xd3, 0x7f, 0x70, 0x1d, 0x5d, 0xad, 0xbd, 0x75, 0x38, 0x83, 0xe3, 0x14, 0x15, 0x1d, - 0x42, 0x85, 0x4c, 0x88, 0xe7, 0x93, 0x53, 0xcf, 0xf7, 0xe4, 0xd4, 0xce, 0x6b, 0x57, 0x9f, 0xbc, - 0xd3, 0x55, 0x3b, 0x45, 0xc0, 0x0b, 0xf4, 0xa6, 0x0b, 0x30, 0x9f, 0x08, 0x3d, 0x82, 0x62, 0xbf, - 0x77, 0xd4, 0xdd, 0x3f, 0xda, 0xab, 0x2e, 0xd5, 0x36, 0x5e, 0x5e, 0x34, 0xee, 0x2a, 0x1f, 0x73, - 0x40, 0x9f, 0x32, 0xd7, 0x63, 0x43, 0xb4, 0x05, 0xa5, 0xf6, 0xee, 0x6e, 0xaf, 0x7f, 0xd2, 0xeb, - 0x56, 0x73, 0xb5, 0xda, 0xcb, 0x8b, 0xc6, 0xbd, 0x45, 0x60, 0xdb, 0x71, 0x68, 0x20, 0xa9, 0x5b, - 0xcb, 0x7f, 0xf3, 0x97, 0xfa, 0x52, 0xf3, 0x9b, 0x1c, 0x54, 0xd2, 0x8b, 0x40, 0x8f, 0xa0, 0xd0, - 0xde, 0x3d, 0xd9, 0x7f, 0xde, 0xab, 0x2e, 0xcd, 0xe9, 0x69, 0x44, 0xdb, 0x91, 0xde, 0x84, 0xa2, - 0x87, 0xb0, 0xda, 0x6f, 0x7f, 0x75, 0xdc, 0xab, 0xe6, 0xe6, 0xcb, 0x49, 0xc3, 0xfa, 0x24, 0x0a, - 0x35, 0xaa, 0x8b, 0xdb, 0xfb, 0x47, 0xd5, 0xe5, 0x6c, 0x54, 0x57, 0x10, 0x8f, 0x99, 0xa5, 0xfc, - 0x39, 0x0f, 0xd6, 0x31, 0x15, 0x13, 0xcf, 0xf9, 0xc0, 0x12, 0xf9, 0x0c, 0xf2, 0x92, 0x84, 0xe7, - 0x5a, 0x1a, 0x56, 0xb6, 0x34, 0x4e, 0x48, 0x78, 0xae, 0x26, 0x35, 0x74, 0x8d, 0x57, 0xca, 0x10, - 0x34, 0xf0, 0x3d, 0x87, 0x48, 0xea, 0x6a, 0x65, 0x58, 0x3b, 0xdf, 0xcf, 0x62, 0xe3, 0x19, 0xca, - 0xac, 0xff, 0xe9, 0x12, 0x4e, 0x51, 0xd1, 0x13, 0x28, 0x0c, 0x7d, 0x7e, 0x4a, 0x7c, 0xad, 0x09, - 0x6b, 0xe7, 0x41, 0x96, 0x93, 0x3d, 0x8d, 0x98, 0x3b, 0x30, 0x14, 0xf4, 0x18, 0x0a, 0x51, 0xe0, - 0x12, 0x49, 0xed, 0x82, 0x26, 0x37, 0xb2, 0xc8, 0x5f, 0x69, 0xc4, 0x2e, 0x67, 0x67, 0xde, 0x10, - 0x1b, 0x3c, 0x3a, 0x80, 0x12, 0xa3, 0xf2, 0x6b, 0x2e, 0xce, 0x43, 0xbb, 0xd8, 0x58, 0xd9, 0xb2, - 0x76, 0x3e, 0xcd, 0x14, 0x63, 0x8c, 0x69, 0x4b, 0x49, 0x9c, 0xd1, 0x98, 0x32, 0x19, 0xbb, 0xe9, - 0x2c, 0xdb, 0x39, 0x3c, 0x73, 0x80, 0x7e, 0x0e, 0x25, 0xca, 0xdc, 0x80, 0x7b, 0x4c, 0xda, 0xa5, - 0xeb, 0x17, 0xd2, 0x33, 0x18, 0x15, 0x4c, 0x3c, 0x63, 0x28, 0xb6, 0xe0, 0xbe, 0x7f, 0x4a, 0x9c, - 0x73, 0xbb, 0xfc, 0x9e, 0xdb, 0x98, 0x31, 0x3a, 0x05, 0xc8, 0x8f, 0xb9, 0x4b, 0x9b, 0xdb, 0xb0, - 0xfe, 0x56, 0xa8, 0x51, 0x0d, 0x4a, 0x26, 0xd4, 0xb1, 0x46, 0xf2, 0x78, 0xd6, 0x6f, 0xde, 0x86, - 0xb5, 0x85, 0xb0, 0x36, 0xff, 0x9e, 0x87, 0x52, 0x72, 0xd6, 0xa8, 0x0d, 0x65, 0x87, 0x33, 0x49, - 0x3c, 0x46, 0x85, 0x91, 0x57, 0xe6, 0xc9, 0xec, 0x26, 0x20, 0xc5, 0x7a, 0xba, 0x84, 0xe7, 0x2c, - 0xf4, 0x6b, 0x28, 0x0b, 0x1a, 0xf2, 0x48, 0x38, 0x34, 0x34, 0xfa, 0xda, 0xca, 0x56, 0x48, 0x0c, - 0xc2, 0xf4, 0x0f, 0x91, 0x27, 0xa8, 0x8a, 0x72, 0x88, 0xe7, 0x54, 0xf4, 0x04, 0x8a, 0x82, 0x86, - 0x92, 0x08, 0xf9, 0x2e, 0x89, 0xe0, 0x18, 0xd2, 0xe7, 0xbe, 0xe7, 0x4c, 0x71, 0xc2, 0x40, 0x4f, - 0xa0, 0x1c, 0xf8, 0xc4, 0xd1, 0x5e, 0xed, 0x55, 0x4d, 0xff, 0x28, 0x8b, 0xde, 0x4f, 0x40, 0x78, - 0x8e, 0x47, 0x9f, 0x03, 0xf8, 0x7c, 0x38, 0x70, 0x85, 0x37, 0xa1, 0xc2, 0x48, 0xac, 0x96, 0xc5, - 0xee, 0x6a, 0x04, 0x2e, 0xfb, 0x7c, 0x18, 0x37, 0xd1, 0xde, 0xff, 0xa5, 0xaf, 0x94, 0xb6, 0x0e, - 0x00, 0xc8, 0x6c, 0xd4, 0xa8, 0xeb, 0x93, 0xf7, 0x72, 0x65, 0x4e, 0x24, 0x45, 0x47, 0x0f, 0xa0, - 0x72, 0xc6, 0x85, 0x43, 0x07, 0xe6, 0xd6, 0x94, 0xb5, 0x26, 0x2c, 0x6d, 0x8b, 0xf5, 0x85, 0x3a, - 0x50, 0x1c, 0x52, 0x46, 0x85, 0xe7, 0xd8, 0xa0, 0x27, 0x7b, 0x94, 0x79, 0x21, 0x63, 0x08, 0x8e, - 0x98, 0xf4, 0xc6, 0xd4, 0xcc, 0x94, 0x10, 0x3b, 0x65, 0x28, 0x8a, 0x78, 0xa4, 0xf9, 0x7b, 0x40, - 0x6f, 0x63, 0x11, 0x82, 0xfc, 0xb9, 0xc7, 0x5c, 0x2d, 0xac, 0x32, 0xd6, 0x6d, 0xd4, 0x82, 0x62, - 0x40, 0xa6, 0x3e, 0x27, 0xae, 0x11, 0xcb, 0x9d, 0x56, 0x9c, 0x2f, 0x5b, 0x49, 0xbe, 0x6c, 0xb5, - 0xd9, 0x14, 0x27, 0xa0, 0xe6, 0x01, 0xdc, 0xcd, 0xdc, 0x32, 0xda, 0x81, 0xca, 0x4c, 0x84, 0x03, - 0xcf, 0x4c, 0xd2, 0xb9, 0x7d, 0x75, 0xb9, 0x69, 0xcd, 0xd4, 0xba, 0xdf, 0xc5, 0xd6, 0x0c, 0xb4, - 0xef, 0x36, 0xff, 0x54, 0x86, 0xb5, 0x05, 0x29, 0xa3, 0x3b, 0xb0, 0xea, 0x8d, 0xc9, 0x90, 0x9a, - 0x35, 0xc6, 0x1d, 0xd4, 0x83, 0x82, 0x4f, 0x4e, 0xa9, 0xaf, 0x04, 0xad, 0x0e, 0xf5, 0x47, 0x37, - 0xde, 0x89, 0xd6, 0x6f, 0x35, 0xbe, 0xc7, 0xa4, 0x98, 0x62, 0x43, 0x46, 0x36, 0x14, 0x1d, 0x3e, - 0x1e, 0x13, 0xa6, 0x9e, 0xce, 0x95, 0xad, 0x32, 0x4e, 0xba, 0x2a, 0x32, 0x44, 0x0c, 0x43, 0x3b, - 0xaf, 0xcd, 0xba, 0x8d, 0xaa, 0xb0, 0x42, 0xd9, 0xc4, 0x5e, 0xd5, 0x26, 0xd5, 0x54, 0x16, 0xd7, - 0x8b, 0x15, 0x59, 0xc6, 0xaa, 0xa9, 0x78, 0x51, 0x48, 0x85, 0x5d, 0x8c, 0x23, 0xaa, 0xda, 0xe8, - 0x67, 0x50, 0x18, 0xf3, 0x88, 0xc9, 0xd0, 0x2e, 0xe9, 0xc5, 0x6e, 0x64, 0x2d, 0xf6, 0x50, 0x21, - 0xcc, 0xd3, 0x6e, 0xe0, 0xa8, 0x07, 0xeb, 0xa1, 0xe4, 0xc1, 0x60, 0x28, 0x88, 0x43, 0x07, 0x01, - 0x15, 0x1e, 0x77, 0xcd, 0xd3, 0xb4, 0xf1, 0xd6, 0xa1, 0x74, 0x4d, 0x91, 0x83, 0x6f, 0x2b, 0xce, - 0x9e, 0xa2, 0xf4, 0x35, 0x03, 0xf5, 0xa1, 0x12, 0x44, 0xbe, 0x3f, 0xe0, 0x41, 0x9c, 0xa5, 0x62, - 0x3d, 0xbd, 0x47, 0xc8, 0xfa, 0x91, 0xef, 0x3f, 0x8b, 0x49, 0xd8, 0x0a, 0xe6, 0x1d, 0x74, 0x0f, - 0x0a, 0x43, 0xc1, 0xa3, 0x20, 0xb4, 0x2d, 0x1d, 0x0c, 0xd3, 0x43, 0x5f, 0x42, 0x31, 0xa4, 0x8e, - 0xa0, 0x32, 0xb4, 0x2b, 0x7a, 0xab, 0x1f, 0x67, 0x4d, 0x72, 0xac, 0x21, 0x98, 0x9e, 0x51, 0x41, - 0x99, 0x43, 0x71, 0xc2, 0x41, 0x1b, 0xb0, 0x22, 0xe5, 0xd4, 0x5e, 0x6b, 0xe4, 0xb6, 0x4a, 0x9d, - 0xe2, 0xd5, 0xe5, 0xe6, 0xca, 0xc9, 0xc9, 0x0b, 0xac, 0x6c, 0xea, 0x05, 0x1d, 0xf1, 0x50, 0x32, - 0x32, 0xa6, 0xf6, 0x2d, 0x1d, 0xdb, 0x59, 0x1f, 0xbd, 0x00, 0x70, 0x59, 0x38, 0x70, 0xf4, 0x95, - 0xb5, 0x6f, 0xeb, 0xdd, 0x7d, 0x7a, 0xf3, 0xee, 0xba, 0x47, 0xc7, 0x26, 0x8b, 0xac, 0x5d, 0x5d, - 0x6e, 0x96, 0x67, 0x5d, 0x5c, 0x76, 0x59, 0x18, 0x37, 0x51, 0x07, 0xac, 0x11, 0x25, 0xbe, 0x1c, - 0x39, 0x23, 0xea, 0x9c, 0xdb, 0xd5, 0xeb, 0xd3, 0xc2, 0x53, 0x0d, 0x33, 0x1e, 0xd2, 0x24, 0xa5, - 0x60, 0xb5, 0xd4, 0xd0, 0x5e, 0xd7, 0xb1, 0x8a, 0x3b, 0xe8, 0x23, 0x00, 0x1e, 0x50, 0x36, 0x08, - 0xa5, 0xeb, 0x31, 0x1b, 0xa9, 0x2d, 0xe3, 0xb2, 0xb2, 0x1c, 0x2b, 0x03, 0xba, 0xaf, 0x1e, 0x6d, - 0xe2, 0x0e, 0x38, 0xf3, 0xa7, 0xf6, 0x77, 0xf4, 0x68, 0x49, 0x19, 0x9e, 0x31, 0x7f, 0x8a, 0x36, - 0xc1, 0xd2, 0xba, 0x08, 0xbd, 0x21, 0x23, 0xbe, 0x7d, 0x47, 0xc7, 0x03, 0x94, 0xe9, 0x58, 0x5b, - 0xd4, 0x39, 0xc4, 0xd1, 0x08, 0xed, 0xbb, 0xd7, 0x9f, 0x83, 0x59, 0xec, 0xfc, 0x1c, 0x0c, 0x07, - 0xfd, 0x02, 0x20, 0x10, 0xde, 0xc4, 0xf3, 0xe9, 0x90, 0x86, 0xf6, 0x3d, 0xbd, 0xe9, 0x7a, 0xe6, - 0x6b, 0x3d, 0x43, 0xe1, 0x14, 0xa3, 0xf6, 0x39, 0x58, 0xa9, 0xdb, 0xa6, 0x6e, 0xc9, 0x39, 0x9d, - 0x9a, 0x0b, 0xac, 0x9a, 0x2a, 0x24, 0x13, 0xe2, 0x47, 0x71, 0x25, 0x5c, 0xc6, 0x71, 0xe7, 0x8b, - 0xe5, 0xc7, 0xb9, 0xda, 0x0e, 0x58, 0x29, 0xd5, 0xa1, 0x8f, 0x61, 0x4d, 0xd0, 0xa1, 0x17, 0x4a, - 0x31, 0x1d, 0x90, 0x48, 0x8e, 0xec, 0x5f, 0x69, 0x42, 0x25, 0x31, 0xb6, 0x23, 0x39, 0xaa, 0x0d, - 0x60, 0x7e, 0x78, 0xa8, 0x01, 0x96, 0x12, 0x45, 0x48, 0xc5, 0x84, 0x0a, 0x95, 0x6d, 0x55, 0xcc, - 0xd3, 0x26, 0x25, 0xde, 0x90, 0x12, 0xe1, 0x8c, 0xf4, 0xdb, 0x51, 0xc6, 0xa6, 0xa7, 0x1e, 0x83, - 0xe4, 0x86, 0x98, 0xc7, 0xc0, 0x74, 0x9b, 0xff, 0xce, 0x41, 0x25, 0x5d, 0x34, 0xa0, 0xdd, 0x38, - 0xd9, 0xeb, 0x2d, 0xdd, 0xda, 0xd9, 0xbe, 0xa9, 0xc8, 0xd0, 0xa9, 0xd5, 0x8f, 0x94, 0xb3, 0x43, - 0x55, 0xdf, 0x6b, 0x32, 0xfa, 0x29, 0xac, 0x06, 0x5c, 0xc8, 0xe4, 0x09, 0xcb, 0x0e, 0x30, 0x17, - 0x49, 0x2a, 0x8a, 0xc1, 0xcd, 0x11, 0xdc, 0x5a, 0xf4, 0x86, 0x1e, 0xc2, 0xca, 0xf3, 0xfd, 0x7e, - 0x75, 0xa9, 0x76, 0xff, 0xe5, 0x45, 0xe3, 0xbb, 0x8b, 0x83, 0xcf, 0x3d, 0x21, 0x23, 0xe2, 0xef, - 0xf7, 0xd1, 0x0f, 0x61, 0xb5, 0x7b, 0x74, 0x8c, 0x71, 0x35, 0x57, 0xdb, 0x7c, 0x79, 0xd1, 0xb8, - 0xbf, 0x88, 0x53, 0x43, 0x3c, 0x62, 0x2e, 0xe6, 0xa7, 0xb3, 0x5a, 0xf7, 0x3f, 0xcb, 0x60, 0x99, - 0x97, 0xfd, 0x43, 0x7f, 0x87, 0xd6, 0xe2, 0x54, 0x9e, 0x5c, 0xd9, 0xe5, 0x1b, 0x33, 0x7a, 0x25, - 0x26, 0x98, 0x33, 0x7e, 0x00, 0x15, 0x2f, 0x98, 0x7c, 0x36, 0xa0, 0x8c, 0x9c, 0xfa, 0xa6, 0xec, - 0x2d, 0x61, 0x4b, 0xd9, 0x7a, 0xb1, 0x49, 0xbd, 0x17, 0x1e, 0x93, 0x54, 0x30, 0x53, 0xd0, 0x96, - 0xf0, 0xac, 0x8f, 0xbe, 0x84, 0xbc, 0x17, 0x90, 0xb1, 0x29, 0x43, 0x32, 0x77, 0xb0, 0xdf, 0x6f, - 0x1f, 0x1a, 0x0d, 0x76, 0x4a, 0x57, 0x97, 0x9b, 0x79, 0x65, 0xc0, 0x9a, 0x86, 0xea, 0x49, 0x25, - 0xa0, 0x66, 0xd2, 0x6f, 0x7f, 0x09, 0xa7, 0x2c, 0x4a, 0x47, 0x1e, 0x1b, 0x0a, 0x1a, 0x86, 0x3a, - 0x0b, 0x94, 0x70, 0xd2, 0x45, 0x35, 0x28, 0x9a, 0x7a, 0x42, 0x17, 0x10, 0x65, 0x95, 0xab, 0x8d, - 0xa1, 0xb3, 0x06, 0x56, 0x1c, 0x8d, 0xc1, 0x99, 0xe0, 0xe3, 0xe6, 0x7f, 0xf3, 0x60, 0xed, 0xfa, - 0x51, 0x28, 0x4d, 0x1a, 0xfc, 0x60, 0xc1, 0x7f, 0x01, 0xeb, 0x44, 0x7f, 0xaf, 0x08, 0x53, 0x39, - 0x45, 0x97, 0x69, 0xe6, 0x00, 0x1e, 0x66, 0xba, 0x9b, 0x81, 0xe3, 0x92, 0xae, 0x53, 0x50, 0x3e, - 0xed, 0x1c, 0xae, 0x92, 0x37, 0x46, 0xd0, 0x31, 0xac, 0x71, 0xe1, 0x8c, 0x68, 0x28, 0xe3, 0x4c, - 0x64, 0xbe, 0x23, 0x99, 0x1f, 0xd5, 0x67, 0x69, 0xa0, 0x79, 0x86, 0xe3, 0xd5, 0x2e, 0xfa, 0x40, - 0x8f, 0x21, 0x2f, 0xc8, 0x59, 0x52, 0x72, 0x66, 0x5e, 0x12, 0x4c, 0xce, 0xe4, 0x82, 0x0b, 0xcd, - 0x40, 0xbf, 0x01, 0x70, 0xbd, 0x30, 0x20, 0xd2, 0x19, 0x51, 0x61, 0x0e, 0x3b, 0x73, 0x8b, 0xdd, - 0x19, 0x6a, 0xc1, 0x4b, 0x8a, 0x8d, 0x0e, 0xa0, 0xec, 0x90, 0x44, 0xae, 0x85, 0xeb, 0xff, 0x68, - 0xbb, 0x6d, 0xe3, 0xa2, 0xaa, 0x5c, 0x5c, 0x5d, 0x6e, 0x96, 0x12, 0x0b, 0x2e, 0x39, 0xc4, 0xc8, - 0xf7, 0x00, 0xd6, 0xd4, 0xdf, 0x6d, 0xe0, 0xd2, 0x33, 0x12, 0xf9, 0x32, 0x96, 0xc9, 0x35, 0x69, - 0x45, 0x7d, 0x04, 0xba, 0x06, 0x67, 0xd6, 0x55, 0x91, 0x29, 0x1b, 0xfa, 0x1d, 0xac, 0x53, 0xe6, - 0x88, 0xa9, 0x16, 0x6b, 0xb2, 0xc2, 0xd2, 0xf5, 0x9b, 0xed, 0xcd, 0xc0, 0x0b, 0x9b, 0xad, 0xd2, - 0x37, 0xec, 0xcd, 0x7f, 0xe6, 0x00, 0xe2, 0x4c, 0xfd, 0x61, 0x05, 0x88, 0x20, 0xef, 0x12, 0x49, - 0xb4, 0xe6, 0x2a, 0x58, 0xb7, 0xd1, 0x17, 0x00, 0x92, 0x8e, 0x03, 0x9f, 0x48, 0x8f, 0x0d, 0x8d, - 0x6c, 0xde, 0xf5, 0x1c, 0xa4, 0xd0, 0x68, 0x07, 0x0a, 0xe6, 0x63, 0x90, 0xbf, 0x91, 0x67, 0x90, - 0xcd, 0xbf, 0xe6, 0x00, 0xe2, 0x6d, 0x7e, 0xab, 0xf7, 0xd6, 0xb1, 0x5f, 0xbd, 0xae, 0x2f, 0xfd, - 0xe3, 0x75, 0x7d, 0xe9, 0x8f, 0x57, 0xf5, 0xdc, 0xab, 0xab, 0x7a, 0xee, 0x6f, 0x57, 0xf5, 0xdc, - 0xbf, 0xae, 0xea, 0xb9, 0xd3, 0x82, 0xae, 0xfb, 0x7e, 0xf2, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xc1, 0xd8, 0x19, 0x9e, 0x30, 0x13, 0x00, 0x00, + // 2000 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4f, 0x6f, 0x1b, 0xb9, + 0x15, 0xb7, 0x6c, 0x59, 0x7f, 0xde, 0xc8, 0x89, 0xc2, 0x4d, 0xb2, 0x13, 0xa5, 0x6b, 0x29, 0xda, + 0x6c, 0xea, 0xdd, 0x45, 0x65, 0xd4, 0x2d, 0xb6, 0xd9, 0x4d, 0xb7, 0xad, 0x64, 0xa9, 0x8e, 0x9b, + 0xc6, 0x11, 0x68, 0x6f, 0xda, 0x00, 0x05, 0x04, 0x7a, 0x86, 0x96, 0x08, 0x8f, 0x86, 0x53, 0x0e, + 0xc7, 0x0b, 0xdd, 0x7a, 0x5c, 0xa4, 0x9f, 0x21, 0xe8, 0xa1, 0xe8, 0xbd, 0x1f, 0xa0, 0x1f, 0x20, + 0xc7, 0x1e, 0xdb, 0x8b, 0xd1, 0xd5, 0x57, 0xe8, 0xad, 0x97, 0x16, 0xe4, 0x70, 0x46, 0xa3, 0x64, + 0x1c, 0x07, 0x68, 0x0e, 0x7b, 0x23, 0xdf, 0xfc, 0x7e, 0x6f, 0x1e, 0xc9, 0xdf, 0xe3, 0x7b, 0x84, + 0x4f, 0xc6, 0x4c, 0x4e, 0xa2, 0xe3, 0x8e, 0xc3, 0xa7, 0xdb, 0x2e, 0x77, 0x4e, 0xa9, 0xd8, 0x0e, + 0xbf, 0x26, 0x62, 0x7a, 0xca, 0xe4, 0x36, 0x09, 0xd8, 0x76, 0x18, 0x50, 0x27, 0xec, 0x04, 0x82, + 0x4b, 0x8e, 0x50, 0x0c, 0xe8, 0x24, 0x80, 0xce, 0xd9, 0x0f, 0x1b, 0x97, 0xf1, 0xe5, 0x2c, 0xa0, + 0x86, 0xdf, 0xb8, 0x3e, 0xe6, 0x63, 0xae, 0x87, 0xdb, 0x6a, 0x64, 0xac, 0x9b, 0x63, 0xce, 0xc7, + 0x1e, 0xdd, 0xd6, 0xb3, 0xe3, 0xe8, 0x64, 0xdb, 0x8d, 0x04, 0x91, 0x8c, 0xfb, 0xe6, 0xfb, 0xad, + 0x57, 0xbf, 0x13, 0x7f, 0x16, 0x7f, 0x6a, 0xbf, 0x28, 0x42, 0xe5, 0x80, 0xbb, 0xf4, 0x30, 0xa0, + 0x0e, 0xda, 0x03, 0x8b, 0xf8, 0x3e, 0x97, 0x9a, 0x1b, 0xda, 0x85, 0x56, 0x61, 0xcb, 0xda, 0x69, + 0x76, 0x5e, 0x8f, 0xb9, 0xd3, 0x5d, 0xc0, 0x7a, 0xc5, 0x97, 0xe7, 0xcd, 0x15, 0x9c, 0x65, 0xa2, + 0x9f, 0x43, 0xcd, 0xa5, 0x21, 0x13, 0xd4, 0x1d, 0x09, 0xee, 0x51, 0x7b, 0xb5, 0x55, 0xd8, 0xba, + 0xb2, 0xf3, 0xbd, 0x3c, 0x4f, 0xea, 0xe7, 0x98, 0x7b, 0x14, 0x5b, 0x86, 0xa1, 0x26, 0x68, 0x0f, + 0x60, 0x4a, 0xa7, 0xc7, 0x54, 0x84, 0x13, 0x16, 0xd8, 0x6b, 0x9a, 0xfe, 0xfd, 0x8b, 0xe8, 0x2a, + 0xf6, 0xce, 0xe3, 0x14, 0x8e, 0x33, 0x54, 0xf4, 0x18, 0x6a, 0xe4, 0x8c, 0x30, 0x8f, 0x1c, 0x33, + 0x8f, 0xc9, 0x99, 0x5d, 0xd4, 0xae, 0x3e, 0x7e, 0xa3, 0xab, 0x6e, 0x86, 0x80, 0x97, 0xe8, 0x6d, + 0x17, 0x60, 0xf1, 0x23, 0x74, 0x0f, 0xca, 0xc3, 0xc1, 0x41, 0x7f, 0xff, 0x60, 0xaf, 0xbe, 0xd2, + 0xb8, 0xf5, 0xfc, 0x45, 0xeb, 0x86, 0xf2, 0xb1, 0x00, 0x0c, 0xa9, 0xef, 0x32, 0x7f, 0x8c, 0xb6, + 0xa0, 0xd2, 0xdd, 0xdd, 0x1d, 0x0c, 0x8f, 0x06, 0xfd, 0x7a, 0xa1, 0xd1, 0x78, 0xfe, 0xa2, 0x75, + 0x73, 0x19, 0xd8, 0x75, 0x1c, 0x1a, 0x48, 0xea, 0x36, 0x8a, 0xdf, 0xfc, 0x79, 0x73, 0xa5, 0xfd, + 0x4d, 0x01, 0x6a, 0xd9, 0x20, 0xd0, 0x3d, 0x28, 0x75, 0x77, 0x8f, 0xf6, 0x9f, 0x0e, 0xea, 0x2b, + 0x0b, 0x7a, 0x16, 0xd1, 0x75, 0x24, 0x3b, 0xa3, 0xe8, 0x2e, 0xac, 0x0f, 0xbb, 0x5f, 0x1d, 0x0e, + 0xea, 0x85, 0x45, 0x38, 0x59, 0xd8, 0x90, 0x44, 0xa1, 0x46, 0xf5, 0x71, 0x77, 0xff, 0xa0, 0xbe, + 0x9a, 0x8f, 0xea, 0x0b, 0xc2, 0x7c, 0x13, 0xca, 0x9f, 0x8a, 0x60, 0x1d, 0x52, 0x71, 0xc6, 0x9c, + 0x77, 0x2c, 0x91, 0xcf, 0xa0, 0x28, 0x49, 0x78, 0xaa, 0xa5, 0x61, 0xe5, 0x4b, 0xe3, 0x88, 0x84, + 0xa7, 0xea, 0xa7, 0x86, 0xae, 0xf1, 0x4a, 0x19, 0x82, 0x06, 0x1e, 0x73, 0x88, 0xa4, 0xae, 0x56, + 0x86, 0xb5, 0xf3, 0x51, 0x1e, 0x1b, 0xa7, 0x28, 0x13, 0xff, 0xc3, 0x15, 0x9c, 0xa1, 0xa2, 0x07, + 0x50, 0x1a, 0x7b, 0xfc, 0x98, 0x78, 0x5a, 0x13, 0xd6, 0xce, 0x9d, 0x3c, 0x27, 0x7b, 0x1a, 0xb1, + 0x70, 0x60, 0x28, 0xe8, 0x3e, 0x94, 0xa2, 0xc0, 0x25, 0x92, 0xda, 0x25, 0x4d, 0x6e, 0xe5, 0x91, + 0xbf, 0xd2, 0x88, 0x5d, 0xee, 0x9f, 0xb0, 0x31, 0x36, 0x78, 0xf4, 0x08, 0x2a, 0x3e, 0x95, 0x5f, + 0x73, 0x71, 0x1a, 0xda, 0xe5, 0xd6, 0xda, 0x96, 0xb5, 0xf3, 0x69, 0xae, 0x18, 0x63, 0x4c, 0x57, + 0x4a, 0xe2, 0x4c, 0xa6, 0xd4, 0x97, 0xb1, 0x9b, 0xde, 0xaa, 0x5d, 0xc0, 0xa9, 0x03, 0xf4, 0x53, + 0xa8, 0x50, 0xdf, 0x0d, 0x38, 0xf3, 0xa5, 0x5d, 0xb9, 0x38, 0x90, 0x81, 0xc1, 0xa8, 0xcd, 0xc4, + 0x29, 0x43, 0xb1, 0x05, 0xf7, 0xbc, 0x63, 0xe2, 0x9c, 0xda, 0xd5, 0xb7, 0x5c, 0x46, 0xca, 0xe8, + 0x95, 0xa0, 0x38, 0xe5, 0x2e, 0x6d, 0x6f, 0xc3, 0xb5, 0xd7, 0xb6, 0x1a, 0x35, 0xa0, 0x62, 0xb6, + 0x3a, 0xd6, 0x48, 0x11, 0xa7, 0xf3, 0xf6, 0x55, 0xd8, 0x58, 0xda, 0xd6, 0xf6, 0x5f, 0xd7, 0xa1, + 0x92, 0x9c, 0x35, 0xea, 0x42, 0xd5, 0xe1, 0xbe, 0x24, 0xcc, 0xa7, 0xc2, 0xc8, 0x2b, 0xf7, 0x64, + 0x76, 0x13, 0x90, 0x62, 0x3d, 0x5c, 0xc1, 0x0b, 0x16, 0xfa, 0x25, 0x54, 0x05, 0x0d, 0x79, 0x24, + 0x1c, 0x1a, 0x1a, 0x7d, 0x6d, 0xe5, 0x2b, 0x24, 0x06, 0x61, 0xfa, 0xfb, 0x88, 0x09, 0xaa, 0x76, + 0x39, 0xc4, 0x0b, 0x2a, 0x7a, 0x00, 0x65, 0x41, 0x43, 0x49, 0x84, 0x7c, 0x93, 0x44, 0x70, 0x0c, + 0x19, 0x72, 0x8f, 0x39, 0x33, 0x9c, 0x30, 0xd0, 0x03, 0xa8, 0x06, 0x1e, 0x71, 0xb4, 0x57, 0x7b, + 0x5d, 0xd3, 0x3f, 0xc8, 0xa3, 0x0f, 0x13, 0x10, 0x5e, 0xe0, 0xd1, 0xe7, 0x00, 0x1e, 0x1f, 0x8f, + 0x5c, 0xc1, 0xce, 0xa8, 0x30, 0x12, 0x6b, 0xe4, 0xb1, 0xfb, 0x1a, 0x81, 0xab, 0x1e, 0x1f, 0xc7, + 0x43, 0xb4, 0xf7, 0x7f, 0xe9, 0x2b, 0xa3, 0xad, 0x47, 0x00, 0x24, 0xfd, 0x6a, 0xd4, 0xf5, 0xf1, + 0x5b, 0xb9, 0x32, 0x27, 0x92, 0xa1, 0xa3, 0x3b, 0x50, 0x3b, 0xe1, 0xc2, 0xa1, 0x23, 0x93, 0x35, + 0x55, 0xad, 0x09, 0x4b, 0xdb, 0x62, 0x7d, 0xa1, 0x1e, 0x94, 0xc7, 0xd4, 0xa7, 0x82, 0x39, 0x36, + 0xe8, 0x9f, 0xdd, 0xcb, 0x4d, 0xc8, 0x18, 0x82, 0x23, 0x5f, 0xb2, 0x29, 0x35, 0x7f, 0x4a, 0x88, + 0xe8, 0x77, 0xf0, 0x5e, 0x72, 0x7c, 0x23, 0x41, 0x4f, 0xa8, 0xa0, 0xbe, 0xd2, 0x80, 0xa5, 0xf7, + 0xe1, 0xa3, 0x37, 0x6b, 0xc0, 0xa0, 0xcd, 0x65, 0x83, 0xc4, 0xab, 0x1f, 0xc2, 0x5e, 0x15, 0xca, + 0x22, 0xfe, 0x6f, 0xfb, 0x8f, 0x05, 0xa5, 0xfa, 0x57, 0x10, 0x68, 0x1b, 0xac, 0xf4, 0xf7, 0xcc, + 0xd5, 0xea, 0xad, 0xf6, 0xae, 0xcc, 0xcf, 0x9b, 0x90, 0x60, 0xf7, 0xfb, 0xea, 0x0e, 0x32, 0x63, + 0x17, 0x0d, 0x60, 0x23, 0x25, 0xa8, 0x32, 0x6f, 0x0a, 0x65, 0xeb, 0x4d, 0x91, 0x1e, 0xcd, 0x02, + 0x8a, 0x6b, 0x22, 0x33, 0x6b, 0xff, 0x16, 0xd0, 0xeb, 0xfb, 0x82, 0x10, 0x14, 0x4f, 0x99, 0x6f, + 0xc2, 0xc0, 0x7a, 0x8c, 0x3a, 0x50, 0x0e, 0xc8, 0xcc, 0xe3, 0xc4, 0x35, 0x89, 0x71, 0xbd, 0x13, + 0xf7, 0x06, 0x9d, 0xa4, 0x37, 0xe8, 0x74, 0xfd, 0x19, 0x4e, 0x40, 0xed, 0x47, 0x70, 0x23, 0xf7, + 0x78, 0xd1, 0x0e, 0xd4, 0xd2, 0x84, 0x5b, 0xac, 0xf5, 0xea, 0xfc, 0xbc, 0x69, 0xa5, 0x99, 0xb9, + 0xdf, 0xc7, 0x56, 0x0a, 0xda, 0x77, 0xdb, 0x7f, 0xab, 0xc2, 0xc6, 0x52, 0xda, 0xa2, 0xeb, 0xb0, + 0xce, 0xa6, 0x64, 0x4c, 0x4d, 0x8c, 0xf1, 0x04, 0x0d, 0xa0, 0xe4, 0x91, 0x63, 0xea, 0xa9, 0xe4, + 0x55, 0x07, 0xf7, 0x83, 0x4b, 0xf3, 0xbf, 0xf3, 0x6b, 0x8d, 0x1f, 0xf8, 0x52, 0xcc, 0xb0, 0x21, + 0x23, 0x1b, 0xca, 0x0e, 0x9f, 0x4e, 0x89, 0xaf, 0xca, 0xc4, 0xda, 0x56, 0x15, 0x27, 0x53, 0xb5, + 0x33, 0x44, 0x8c, 0x43, 0xbb, 0xa8, 0xcd, 0x7a, 0x8c, 0xea, 0xb0, 0x46, 0xfd, 0x33, 0x7b, 0x5d, + 0x9b, 0xd4, 0x50, 0x59, 0x5c, 0x16, 0x67, 0x5f, 0x15, 0xab, 0xa1, 0xe2, 0x45, 0x21, 0x15, 0x76, + 0x39, 0xde, 0x51, 0x35, 0x46, 0x3f, 0x81, 0xd2, 0x94, 0x47, 0xbe, 0x0c, 0xed, 0x8a, 0x0e, 0xf6, + 0x56, 0x5e, 0xb0, 0x8f, 0x15, 0xc2, 0x28, 0xcb, 0xc0, 0xd1, 0x00, 0xae, 0x85, 0x92, 0x07, 0xa3, + 0xb1, 0x20, 0x0e, 0x1d, 0x05, 0x54, 0x30, 0xee, 0x9a, 0x6b, 0xf8, 0xd6, 0x6b, 0x87, 0xd2, 0x37, + 0x0d, 0x1d, 0xbe, 0xaa, 0x38, 0x7b, 0x8a, 0x32, 0xd4, 0x0c, 0x34, 0x84, 0x5a, 0x10, 0x79, 0xde, + 0x88, 0x07, 0x71, 0x45, 0x8e, 0x73, 0xe7, 0x2d, 0xb6, 0x6c, 0x18, 0x79, 0xde, 0x93, 0x98, 0x84, + 0xad, 0x60, 0x31, 0x41, 0x37, 0xa1, 0x34, 0x16, 0x3c, 0x0a, 0xe2, 0xbc, 0xa9, 0x62, 0x33, 0x43, + 0x5f, 0x42, 0x39, 0xa4, 0x8e, 0xa0, 0x32, 0xb4, 0x6b, 0x7a, 0xa9, 0x1f, 0xe6, 0xfd, 0xe4, 0x50, + 0x43, 0xd2, 0x9c, 0xc0, 0x09, 0x07, 0xdd, 0x82, 0x35, 0x29, 0x67, 0xf6, 0x46, 0xab, 0xb0, 0x55, + 0xe9, 0x95, 0xe7, 0xe7, 0xcd, 0xb5, 0xa3, 0xa3, 0x67, 0x58, 0xd9, 0x54, 0xb5, 0x98, 0xf0, 0x50, + 0xfa, 0x64, 0x4a, 0xed, 0x2b, 0x7a, 0x6f, 0xd3, 0x39, 0x7a, 0x06, 0xe0, 0xfa, 0xe1, 0xc8, 0xd1, + 0xd7, 0x93, 0x7d, 0x55, 0xaf, 0xee, 0xd3, 0xcb, 0x57, 0xd7, 0x3f, 0x38, 0x34, 0x15, 0x73, 0x63, + 0x7e, 0xde, 0xac, 0xa6, 0x53, 0x5c, 0x75, 0xfd, 0x30, 0x1e, 0xa2, 0x1e, 0x58, 0x13, 0x4a, 0x3c, + 0x39, 0x71, 0x26, 0xd4, 0x39, 0xb5, 0xeb, 0x17, 0x97, 0xc0, 0x87, 0x1a, 0x66, 0x3c, 0x64, 0x49, + 0x4a, 0xc1, 0x2a, 0xd4, 0xd0, 0xbe, 0xa6, 0xf7, 0x2a, 0x9e, 0xa0, 0x0f, 0x00, 0x78, 0x40, 0xfd, + 0x51, 0x28, 0x5d, 0xe6, 0xdb, 0x48, 0x2d, 0x19, 0x57, 0x95, 0xe5, 0x50, 0x19, 0xd0, 0x6d, 0x55, + 0xa0, 0x88, 0x3b, 0xe2, 0xbe, 0x37, 0xb3, 0xdf, 0xd3, 0x5f, 0x2b, 0xca, 0xf0, 0xc4, 0xf7, 0x66, + 0xa8, 0x09, 0x96, 0xd6, 0x45, 0xc8, 0xc6, 0x3e, 0xf1, 0xec, 0xeb, 0x7a, 0x3f, 0x40, 0x99, 0x0e, + 0xb5, 0x45, 0x9d, 0x43, 0xbc, 0x1b, 0xa1, 0x7d, 0xe3, 0xe2, 0x73, 0x30, 0xc1, 0x2e, 0xce, 0xc1, + 0x70, 0xd0, 0xcf, 0x00, 0x02, 0xc1, 0xce, 0x98, 0x47, 0xc7, 0x34, 0xb4, 0x6f, 0xea, 0x45, 0x6f, + 0xe6, 0x56, 0xa6, 0x14, 0x85, 0x33, 0x0c, 0xd4, 0x04, 0x60, 0x3e, 0x93, 0xa3, 0x33, 0xe2, 0x45, + 0xd4, 0x7e, 0x5f, 0x45, 0xaf, 0xca, 0xaf, 0xb2, 0x3d, 0x55, 0xa6, 0xc6, 0xe7, 0x60, 0x65, 0xd2, + 0x51, 0xa5, 0xd1, 0x29, 0x9d, 0x99, 0x0c, 0x57, 0x43, 0xb5, 0x67, 0x31, 0x79, 0x35, 0xce, 0x7a, + 0x3d, 0xf9, 0x62, 0xf5, 0x7e, 0xa1, 0xb1, 0x03, 0x56, 0x46, 0x96, 0xe8, 0x43, 0x75, 0x3d, 0x8e, + 0x59, 0x28, 0xc5, 0x6c, 0x44, 0x22, 0x39, 0xb1, 0x7f, 0xa1, 0x09, 0xb5, 0xc4, 0xd8, 0x8d, 0xe4, + 0xa4, 0x31, 0x82, 0xc5, 0xe9, 0xa2, 0x16, 0x58, 0x4a, 0x35, 0x21, 0x15, 0x67, 0x54, 0xa8, 0xd6, + 0x43, 0x1d, 0x4a, 0xd6, 0xa4, 0xd4, 0x1d, 0x52, 0x22, 0x9c, 0x89, 0xbe, 0x5c, 0xaa, 0xd8, 0xcc, + 0xd4, 0x6d, 0x91, 0xa4, 0x90, 0xb9, 0x2d, 0xcc, 0x54, 0x35, 0x3a, 0x6a, 0x71, 0xed, 0x7f, 0x17, + 0xa0, 0x96, 0xed, 0xa4, 0xd0, 0x6e, 0xdc, 0x01, 0xe9, 0xa5, 0x5d, 0xd9, 0xd9, 0xbe, 0xac, 0xf3, + 0xd2, 0x37, 0xb8, 0x17, 0x29, 0xa7, 0x8f, 0xd5, 0xa3, 0x47, 0x93, 0xd1, 0x8f, 0x61, 0x3d, 0xe0, + 0x42, 0x26, 0x77, 0x5d, 0xfe, 0x49, 0x70, 0x91, 0xd4, 0xe7, 0x18, 0xdc, 0x9e, 0xc0, 0x95, 0x65, + 0x6f, 0xe8, 0x2e, 0xac, 0x3d, 0xdd, 0x1f, 0xd6, 0x57, 0x1a, 0xb7, 0x9f, 0xbf, 0x68, 0xbd, 0xbf, + 0xfc, 0xf1, 0x29, 0x13, 0x32, 0x22, 0xde, 0xfe, 0x10, 0x7d, 0x02, 0xeb, 0xfd, 0x83, 0x43, 0x8c, + 0xeb, 0x85, 0x46, 0xf3, 0xf9, 0x8b, 0xd6, 0xed, 0x65, 0x9c, 0xfa, 0xc4, 0x23, 0xdf, 0xc5, 0xfc, + 0x38, 0x7d, 0x00, 0xfc, 0x67, 0x15, 0x2c, 0x53, 0x02, 0xde, 0xf5, 0x1b, 0x71, 0x23, 0xee, 0x6f, + 0x92, 0xdc, 0x5e, 0xbd, 0xb4, 0xcd, 0xa9, 0xc5, 0x04, 0x73, 0xd6, 0x77, 0xa0, 0xc6, 0x82, 0xb3, + 0xcf, 0x46, 0xd4, 0x27, 0xc7, 0x9e, 0x79, 0x0b, 0x54, 0xb0, 0xa5, 0x6c, 0x83, 0xd8, 0xa4, 0x2e, + 0x16, 0xe6, 0x4b, 0x2a, 0x7c, 0xd3, 0xe5, 0x57, 0x70, 0x3a, 0x47, 0x5f, 0x42, 0x91, 0x05, 0x64, + 0x6a, 0x7a, 0xb3, 0xdc, 0x15, 0xec, 0x0f, 0xbb, 0x8f, 0x8d, 0x16, 0x7b, 0x95, 0xf9, 0x79, 0xb3, + 0xa8, 0x0c, 0x58, 0xd3, 0xd0, 0x66, 0xd2, 0x1e, 0xa9, 0x3f, 0xe9, 0x22, 0x51, 0xc1, 0x19, 0x8b, + 0xd2, 0x13, 0xf3, 0xc7, 0x82, 0x86, 0xa1, 0x2e, 0x17, 0x15, 0x9c, 0x4c, 0x51, 0x03, 0xca, 0xa6, + 0xc9, 0xd2, 0x5d, 0x55, 0x55, 0x35, 0x30, 0xc6, 0xd0, 0xdb, 0x00, 0x2b, 0xde, 0x8d, 0xd1, 0x89, + 0xe0, 0xd3, 0xf6, 0x7f, 0x8b, 0x60, 0xed, 0x7a, 0x51, 0x28, 0x4d, 0xbd, 0x7c, 0x67, 0x9b, 0xff, + 0x0c, 0xae, 0x11, 0xfd, 0xe6, 0x24, 0xbe, 0x2a, 0x3e, 0xba, 0x77, 0x35, 0x07, 0x70, 0x37, 0xd7, + 0x5d, 0x0a, 0x8e, 0xfb, 0xdc, 0x5e, 0x49, 0xf9, 0xb4, 0x0b, 0xb8, 0x4e, 0x5e, 0xf9, 0x82, 0x0e, + 0x61, 0x83, 0x0b, 0x67, 0x42, 0x43, 0x19, 0x97, 0x2c, 0xf3, 0x46, 0xcb, 0x7d, 0xbd, 0x3f, 0xc9, + 0x02, 0xcd, 0x7d, 0x1d, 0x47, 0xbb, 0xec, 0x03, 0xdd, 0x87, 0xa2, 0x20, 0x27, 0x49, 0x1f, 0x9e, + 0x9b, 0x24, 0x98, 0x9c, 0xc8, 0x25, 0x17, 0x9a, 0x81, 0x7e, 0x05, 0xe0, 0xb2, 0x30, 0x20, 0xd2, + 0x99, 0x50, 0x61, 0x0e, 0x3b, 0x77, 0x89, 0xfd, 0x14, 0xb5, 0xe4, 0x25, 0xc3, 0x46, 0x8f, 0xa0, + 0xea, 0x90, 0x44, 0xae, 0xa5, 0x8b, 0x1f, 0xae, 0xbb, 0x5d, 0xe3, 0xa2, 0xae, 0x5c, 0xcc, 0xcf, + 0x9b, 0x95, 0xc4, 0x82, 0x2b, 0x0e, 0x31, 0xf2, 0x7d, 0x04, 0x1b, 0xea, 0x41, 0x3b, 0x72, 0xe9, + 0x09, 0x89, 0x3c, 0x19, 0xcb, 0xe4, 0x82, 0xfa, 0xa3, 0x5e, 0x47, 0x7d, 0x83, 0x33, 0x71, 0xd5, + 0x64, 0xc6, 0x86, 0x7e, 0x03, 0xd7, 0xa8, 0xef, 0x88, 0x99, 0x16, 0x6b, 0x12, 0x61, 0xe5, 0xe2, + 0xc5, 0x0e, 0x52, 0xf0, 0xd2, 0x62, 0xeb, 0xf4, 0x15, 0x7b, 0xfb, 0x9f, 0x05, 0x80, 0xb8, 0xa4, + 0xbf, 0x5b, 0x01, 0x22, 0x28, 0xba, 0x44, 0x12, 0xad, 0xb9, 0x1a, 0xd6, 0x63, 0xf4, 0x05, 0x80, + 0xa4, 0xd3, 0xc0, 0x23, 0x92, 0xf9, 0x63, 0x23, 0x9b, 0x37, 0x5d, 0x07, 0x19, 0x34, 0xda, 0x81, + 0x92, 0x79, 0x2d, 0x15, 0x2f, 0xe5, 0x19, 0x64, 0xfb, 0x2f, 0x05, 0x80, 0x78, 0x99, 0xdf, 0xe9, + 0xb5, 0xf5, 0xec, 0x97, 0xdf, 0x6e, 0xae, 0xfc, 0xe3, 0xdb, 0xcd, 0x95, 0x3f, 0xcc, 0x37, 0x0b, + 0x2f, 0xe7, 0x9b, 0x85, 0xbf, 0xcf, 0x37, 0x0b, 0xff, 0x9a, 0x6f, 0x16, 0x8e, 0x4b, 0xba, 0x41, + 0xfc, 0xd1, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x4f, 0xdf, 0x5d, 0x60, 0x83, 0x14, 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/specs.proto b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/specs.proto index c14ebeb6d..c7c365b85 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/specs.proto +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/specs.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package docker.swarmkit.v1; -import "types.proto"; +import "github.com/docker/swarmkit/api/types.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/any.proto"; @@ -128,6 +128,21 @@ message TaskSpec { // using the same reconciliation-based mechanism that performs rolling // updates. uint64 force_update = 9; + + // ResourceReferences provides a generic way to specify resources that + // are used by this task, and should be sent down to agents along with + // the task. Inside the runtime field there may be more specific + // information about how to use the resource, but ResourceReferences + // establishes the relationship at the store level, and instructs the + // dispatcher to send the related objects. + // + // ResourceReferences is a list of ResourceReferences used by the task. + repeated ResourceReference resource_references = 11 [(gogoproto.nullable) = false]; +} + +message ResourceReference { + string resource_id = 1; + ResourceType resource_type = 2; } message GenericRuntimeSpec { @@ -278,6 +293,11 @@ message ContainerSpec { // task will exit and a new task will be rescheduled elsewhere. A container // is considered unhealthy after `Retries` number of consecutive failures. HealthConfig healthcheck = 16; + + // Run a custom init inside the container, if null, use the daemon's configured settings + oneof init { + bool init_value = 23; + } } // EndpointSpec defines the properties that can be configured to diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/types.pb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/types.pb.go index d41e76130..9ce04eb0b 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/types.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/types.pb.go @@ -1,222 +1,7 @@ // Code generated by protoc-gen-gogo. -// source: types.proto +// source: github.com/docker/swarmkit/api/types.proto // DO NOT EDIT! -/* - Package api is a generated protocol buffer package. - - It is generated from these files: - types.proto - specs.proto - objects.proto - control.proto - dispatcher.proto - ca.proto - snapshot.proto - raft.proto - health.proto - resource.proto - logbroker.proto - watch.proto - - It has these top-level messages: - Version - IndexEntry - Annotations - NamedGenericResource - DiscreteGenericResource - GenericResource - Resources - ResourceRequirements - Platform - PluginDescription - EngineDescription - NodeDescription - NodeTLSInfo - RaftMemberStatus - NodeStatus - Image - Mount - RestartPolicy - UpdateConfig - UpdateStatus - ContainerStatus - PortStatus - TaskStatus - NetworkAttachmentConfig - IPAMConfig - PortConfig - Driver - IPAMOptions - Peer - WeightedPeer - IssuanceStatus - AcceptancePolicy - ExternalCA - CAConfig - OrchestrationConfig - TaskDefaults - DispatcherConfig - RaftConfig - EncryptionConfig - SpreadOver - PlacementPreference - Placement - JoinTokens - RootCA - Certificate - EncryptionKey - ManagerStatus - FileTarget - SecretReference - ConfigReference - BlacklistedCertificate - HealthConfig - MaybeEncryptedRecord - RootRotation - Privileges - NodeSpec - ServiceSpec - ReplicatedService - GlobalService - TaskSpec - GenericRuntimeSpec - NetworkAttachmentSpec - ContainerSpec - EndpointSpec - NetworkSpec - ClusterSpec - SecretSpec - ConfigSpec - Meta - Node - Service - Endpoint - Task - NetworkAttachment - Network - Cluster - Secret - Config - Resource - Extension - GetNodeRequest - GetNodeResponse - ListNodesRequest - ListNodesResponse - UpdateNodeRequest - UpdateNodeResponse - RemoveNodeRequest - RemoveNodeResponse - GetTaskRequest - GetTaskResponse - RemoveTaskRequest - RemoveTaskResponse - ListTasksRequest - ListTasksResponse - CreateServiceRequest - CreateServiceResponse - GetServiceRequest - GetServiceResponse - UpdateServiceRequest - UpdateServiceResponse - RemoveServiceRequest - RemoveServiceResponse - ListServicesRequest - ListServicesResponse - CreateNetworkRequest - CreateNetworkResponse - GetNetworkRequest - GetNetworkResponse - RemoveNetworkRequest - RemoveNetworkResponse - ListNetworksRequest - ListNetworksResponse - GetClusterRequest - GetClusterResponse - ListClustersRequest - ListClustersResponse - KeyRotation - UpdateClusterRequest - UpdateClusterResponse - GetSecretRequest - GetSecretResponse - UpdateSecretRequest - UpdateSecretResponse - ListSecretsRequest - ListSecretsResponse - CreateSecretRequest - CreateSecretResponse - RemoveSecretRequest - RemoveSecretResponse - GetConfigRequest - GetConfigResponse - UpdateConfigRequest - UpdateConfigResponse - ListConfigsRequest - ListConfigsResponse - CreateConfigRequest - CreateConfigResponse - RemoveConfigRequest - RemoveConfigResponse - SessionRequest - SessionMessage - HeartbeatRequest - HeartbeatResponse - UpdateTaskStatusRequest - UpdateTaskStatusResponse - TasksRequest - TasksMessage - AssignmentsRequest - Assignment - AssignmentChange - AssignmentsMessage - NodeCertificateStatusRequest - NodeCertificateStatusResponse - IssueNodeCertificateRequest - IssueNodeCertificateResponse - GetRootCACertificateRequest - GetRootCACertificateResponse - GetUnlockKeyRequest - GetUnlockKeyResponse - StoreSnapshot - ClusterSnapshot - Snapshot - RaftMember - JoinRequest - JoinResponse - LeaveRequest - LeaveResponse - ProcessRaftMessageRequest - ProcessRaftMessageResponse - ResolveAddressRequest - ResolveAddressResponse - InternalRaftRequest - StoreAction - HealthCheckRequest - HealthCheckResponse - AttachNetworkRequest - AttachNetworkResponse - DetachNetworkRequest - DetachNetworkResponse - LogSubscriptionOptions - LogSelector - LogContext - LogAttr - LogMessage - SubscribeLogsRequest - SubscribeLogsMessage - ListenSubscriptionsRequest - SubscriptionMessage - PublishLogsMessage - PublishLogsResponse - Object - SelectBySlot - SelectByCustom - SelectBy - WatchRequest - WatchMessage -*/ package api import proto "github.com/gogo/protobuf/proto" @@ -245,11 +30,29 @@ var _ = fmt.Errorf var _ = math.Inf var _ = time.Kitchen -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package +type ResourceType int32 + +const ( + ResourceType_TASK ResourceType = 0 + ResourceType_SECRET ResourceType = 1 + ResourceType_CONFIG ResourceType = 2 +) + +var ResourceType_name = map[int32]string{ + 0: "TASK", + 1: "SECRET", + 2: "CONFIG", +} +var ResourceType_value = map[string]int32{ + "TASK": 0, + "SECRET": 1, + "CONFIG": 2, +} + +func (x ResourceType) String() string { + return proto.EnumName(ResourceType_name, int32(x)) +} +func (ResourceType) EnumDescriptor() ([]byte, []int) { return fileDescriptorTypes, []int{0} } // TaskState enumerates the states that a task progresses through within an // agent. States are designed to be monotonically increasing, such that if two @@ -306,7 +109,7 @@ var TaskState_value = map[string]int32{ func (x TaskState) String() string { return proto.EnumName(TaskState_name, int32(x)) } -func (TaskState) EnumDescriptor() ([]byte, []int) { return fileDescriptorTypes, []int{0} } +func (TaskState) EnumDescriptor() ([]byte, []int) { return fileDescriptorTypes, []int{1} } type NodeRole int32 @@ -327,7 +130,7 @@ var NodeRole_value = map[string]int32{ func (x NodeRole) String() string { return proto.EnumName(NodeRole_name, int32(x)) } -func (NodeRole) EnumDescriptor() ([]byte, []int) { return fileDescriptorTypes, []int{1} } +func (NodeRole) EnumDescriptor() ([]byte, []int) { return fileDescriptorTypes, []int{2} } type RaftMemberStatus_Reachability int32 @@ -416,6 +219,36 @@ func (x Mount_MountType) String() string { } func (Mount_MountType) EnumDescriptor() ([]byte, []int) { return fileDescriptorTypes, []int{16, 0} } +// Consistency indicates the tolerable level of file system consistency +type Mount_MountConsistency int32 + +const ( + MountConsistencyDefault Mount_MountConsistency = 0 + MountConsistencyFull Mount_MountConsistency = 1 + MountConsistencyCached Mount_MountConsistency = 2 + MountConsistencyDelegated Mount_MountConsistency = 3 +) + +var Mount_MountConsistency_name = map[int32]string{ + 0: "DEFAULT", + 1: "CONSISTENT", + 2: "CACHED", + 3: "DELEGATED", +} +var Mount_MountConsistency_value = map[string]int32{ + "DEFAULT": 0, + "CONSISTENT": 1, + "CACHED": 2, + "DELEGATED": 3, +} + +func (x Mount_MountConsistency) String() string { + return proto.EnumName(Mount_MountConsistency_name, int32(x)) +} +func (Mount_MountConsistency) EnumDescriptor() ([]byte, []int) { + return fileDescriptorTypes, []int{16, 1} +} + type Mount_BindOptions_MountPropagation int32 const ( @@ -1068,7 +901,8 @@ type Mount struct { // Target path in container Target string `protobuf:"bytes,3,opt,name=target,proto3" json:"target,omitempty"` // ReadOnly should be set to true if the mount should not be writable. - ReadOnly bool `protobuf:"varint,4,opt,name=readonly,proto3" json:"readonly,omitempty"` + ReadOnly bool `protobuf:"varint,4,opt,name=readonly,proto3" json:"readonly,omitempty"` + Consistency Mount_MountConsistency `protobuf:"varint,8,opt,name=consistency,proto3,enum=docker.swarmkit.v1.Mount_MountConsistency" json:"consistency,omitempty"` // BindOptions configures properties of a bind mount type. // // For mounts of type bind, the source must be an absolute host path. @@ -1267,6 +1101,13 @@ type TaskStatus struct { // HostPorts provides a list of ports allocated at the host // level. PortStatus *PortStatus `protobuf:"bytes,6,opt,name=port_status,json=portStatus" json:"port_status,omitempty"` + // AppliedBy gives the node ID of the manager that applied this task + // status update to the Task object. + AppliedBy string `protobuf:"bytes,7,opt,name=applied_by,json=appliedBy,proto3" json:"applied_by,omitempty"` + // AppliedAt gives a timestamp of when this status update was applied to + // the Task object. + // Note: can't use stdtime because this field is nullable. + AppliedAt *google_protobuf.Timestamp `protobuf:"bytes,8,opt,name=applied_at,json=appliedAt" json:"applied_at,omitempty"` } func (m *TaskStatus) Reset() { *m = TaskStatus{} } @@ -2311,11 +2152,13 @@ func init() { proto.RegisterType((*Privileges)(nil), "docker.swarmkit.v1.Privileges") proto.RegisterType((*Privileges_CredentialSpec)(nil), "docker.swarmkit.v1.Privileges.CredentialSpec") proto.RegisterType((*Privileges_SELinuxContext)(nil), "docker.swarmkit.v1.Privileges.SELinuxContext") + proto.RegisterEnum("docker.swarmkit.v1.ResourceType", ResourceType_name, ResourceType_value) proto.RegisterEnum("docker.swarmkit.v1.TaskState", TaskState_name, TaskState_value) proto.RegisterEnum("docker.swarmkit.v1.NodeRole", NodeRole_name, NodeRole_value) proto.RegisterEnum("docker.swarmkit.v1.RaftMemberStatus_Reachability", RaftMemberStatus_Reachability_name, RaftMemberStatus_Reachability_value) proto.RegisterEnum("docker.swarmkit.v1.NodeStatus_State", NodeStatus_State_name, NodeStatus_State_value) proto.RegisterEnum("docker.swarmkit.v1.Mount_MountType", Mount_MountType_name, Mount_MountType_value) + proto.RegisterEnum("docker.swarmkit.v1.Mount_MountConsistency", Mount_MountConsistency_name, Mount_MountConsistency_value) proto.RegisterEnum("docker.swarmkit.v1.Mount_BindOptions_MountPropagation", Mount_BindOptions_MountPropagation_name, Mount_BindOptions_MountPropagation_value) proto.RegisterEnum("docker.swarmkit.v1.RestartPolicy_RestartCondition", RestartPolicy_RestartCondition_name, RestartPolicy_RestartCondition_value) proto.RegisterEnum("docker.swarmkit.v1.UpdateConfig_FailureAction", UpdateConfig_FailureAction_name, UpdateConfig_FailureAction_value) @@ -2867,6 +2710,10 @@ func (m *TaskStatus) CopyFrom(src interface{}) { m.PortStatus = &PortStatus{} github_com_docker_swarmkit_api_deepcopy.Copy(m.PortStatus, o.PortStatus) } + if o.AppliedAt != nil { + m.AppliedAt = &google_protobuf.Timestamp{} + github_com_docker_swarmkit_api_deepcopy.Copy(m.AppliedAt, o.AppliedAt) + } if o.RuntimeStatus != nil { switch o.RuntimeStatus.(type) { case *TaskStatus_Container: @@ -4345,6 +4192,11 @@ func (m *Mount) MarshalTo(dAtA []byte) (int, error) { } i += n12 } + if m.Consistency != 0 { + dAtA[i] = 0x40 + i++ + i = encodeVarintTypes(dAtA, i, uint64(m.Consistency)) + } return i, nil } @@ -4730,6 +4582,22 @@ func (m *TaskStatus) MarshalTo(dAtA []byte) (int, error) { } i += n22 } + if len(m.AppliedBy) > 0 { + dAtA[i] = 0x3a + i++ + i = encodeVarintTypes(dAtA, i, uint64(len(m.AppliedBy))) + i += copy(dAtA[i:], m.AppliedBy) + } + if m.AppliedAt != nil { + dAtA[i] = 0x42 + i++ + i = encodeVarintTypes(dAtA, i, uint64(m.AppliedAt.Size())) + n23, err := m.AppliedAt.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n23 + } return i, nil } @@ -4739,11 +4607,11 @@ func (m *TaskStatus_Container) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x2a i++ i = encodeVarintTypes(dAtA, i, uint64(m.Container.Size())) - n23, err := m.Container.MarshalTo(dAtA[i:]) + n24, err := m.Container.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n23 + i += n24 } return i, nil } @@ -4980,11 +4848,11 @@ func (m *IPAMOptions) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintTypes(dAtA, i, uint64(m.Driver.Size())) - n24, err := m.Driver.MarshalTo(dAtA[i:]) + n25, err := m.Driver.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n24 + i += n25 } if len(m.Configs) > 0 { for _, msg := range m.Configs { @@ -5050,11 +4918,11 @@ func (m *WeightedPeer) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintTypes(dAtA, i, uint64(m.Peer.Size())) - n25, err := m.Peer.MarshalTo(dAtA[i:]) + n26, err := m.Peer.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n25 + i += n26 } if m.Weight != 0 { dAtA[i] = 0x10 @@ -5157,11 +5025,11 @@ func (m *AcceptancePolicy_RoleAdmissionPolicy) MarshalTo(dAtA []byte) (int, erro dAtA[i] = 0x1a i++ i = encodeVarintTypes(dAtA, i, uint64(m.Secret.Size())) - n26, err := m.Secret.MarshalTo(dAtA[i:]) + n27, err := m.Secret.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n26 + i += n27 } return i, nil } @@ -5267,11 +5135,11 @@ func (m *CAConfig) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintTypes(dAtA, i, uint64(m.NodeCertExpiry.Size())) - n27, err := m.NodeCertExpiry.MarshalTo(dAtA[i:]) + n28, err := m.NodeCertExpiry.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n27 + i += n28 } if len(m.ExternalCAs) > 0 { for _, msg := range m.ExternalCAs { @@ -5347,11 +5215,11 @@ func (m *TaskDefaults) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintTypes(dAtA, i, uint64(m.LogDriver.Size())) - n28, err := m.LogDriver.MarshalTo(dAtA[i:]) + n29, err := m.LogDriver.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n28 + i += n29 } return i, nil } @@ -5375,11 +5243,11 @@ func (m *DispatcherConfig) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintTypes(dAtA, i, uint64(m.HeartbeatPeriod.Size())) - n29, err := m.HeartbeatPeriod.MarshalTo(dAtA[i:]) + n30, err := m.HeartbeatPeriod.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n29 + i += n30 } return i, nil } @@ -5495,11 +5363,11 @@ func (m *PlacementPreference) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Preference != nil { - nn30, err := m.Preference.MarshalTo(dAtA[i:]) + nn31, err := m.Preference.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn30 + i += nn31 } return i, nil } @@ -5510,11 +5378,11 @@ func (m *PlacementPreference_Spread) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintTypes(dAtA, i, uint64(m.Spread.Size())) - n31, err := m.Spread.MarshalTo(dAtA[i:]) + n32, err := m.Spread.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n31 + i += n32 } return i, nil } @@ -5641,20 +5509,20 @@ func (m *RootCA) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x22 i++ i = encodeVarintTypes(dAtA, i, uint64(m.JoinTokens.Size())) - n32, err := m.JoinTokens.MarshalTo(dAtA[i:]) + n33, err := m.JoinTokens.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n32 + i += n33 if m.RootRotation != nil { dAtA[i] = 0x2a i++ i = encodeVarintTypes(dAtA, i, uint64(m.RootRotation.Size())) - n33, err := m.RootRotation.MarshalTo(dAtA[i:]) + n34, err := m.RootRotation.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n33 + i += n34 } if m.LastForcedRotation != 0 { dAtA[i] = 0x30 @@ -5693,11 +5561,11 @@ func (m *Certificate) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintTypes(dAtA, i, uint64(m.Status.Size())) - n34, err := m.Status.MarshalTo(dAtA[i:]) + n35, err := m.Status.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n34 + i += n35 if len(m.Certificate) > 0 { dAtA[i] = 0x22 i++ @@ -5866,11 +5734,11 @@ func (m *SecretReference) MarshalTo(dAtA []byte) (int, error) { i += copy(dAtA[i:], m.SecretName) } if m.Target != nil { - nn35, err := m.Target.MarshalTo(dAtA[i:]) + nn36, err := m.Target.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn35 + i += nn36 } return i, nil } @@ -5881,11 +5749,11 @@ func (m *SecretReference_File) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintTypes(dAtA, i, uint64(m.File.Size())) - n36, err := m.File.MarshalTo(dAtA[i:]) + n37, err := m.File.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n36 + i += n37 } return i, nil } @@ -5917,11 +5785,11 @@ func (m *ConfigReference) MarshalTo(dAtA []byte) (int, error) { i += copy(dAtA[i:], m.ConfigName) } if m.Target != nil { - nn37, err := m.Target.MarshalTo(dAtA[i:]) + nn38, err := m.Target.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn37 + i += nn38 } return i, nil } @@ -5932,11 +5800,11 @@ func (m *ConfigReference_File) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintTypes(dAtA, i, uint64(m.File.Size())) - n38, err := m.File.MarshalTo(dAtA[i:]) + n39, err := m.File.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n38 + i += n39 } return i, nil } @@ -5959,11 +5827,11 @@ func (m *BlacklistedCertificate) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintTypes(dAtA, i, uint64(m.Expiry.Size())) - n39, err := m.Expiry.MarshalTo(dAtA[i:]) + n40, err := m.Expiry.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n39 + i += n40 } return i, nil } @@ -6002,21 +5870,21 @@ func (m *HealthConfig) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintTypes(dAtA, i, uint64(m.Interval.Size())) - n40, err := m.Interval.MarshalTo(dAtA[i:]) + n41, err := m.Interval.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n40 + i += n41 } if m.Timeout != nil { dAtA[i] = 0x1a i++ i = encodeVarintTypes(dAtA, i, uint64(m.Timeout.Size())) - n41, err := m.Timeout.MarshalTo(dAtA[i:]) + n42, err := m.Timeout.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n41 + i += n42 } if m.Retries != 0 { dAtA[i] = 0x20 @@ -6027,11 +5895,11 @@ func (m *HealthConfig) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x2a i++ i = encodeVarintTypes(dAtA, i, uint64(m.StartPeriod.Size())) - n42, err := m.StartPeriod.MarshalTo(dAtA[i:]) + n43, err := m.StartPeriod.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n42 + i += n43 } return i, nil } @@ -6126,21 +5994,21 @@ func (m *Privileges) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintTypes(dAtA, i, uint64(m.CredentialSpec.Size())) - n43, err := m.CredentialSpec.MarshalTo(dAtA[i:]) + n44, err := m.CredentialSpec.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n43 + i += n44 } if m.SELinuxContext != nil { dAtA[i] = 0x12 i++ i = encodeVarintTypes(dAtA, i, uint64(m.SELinuxContext.Size())) - n44, err := m.SELinuxContext.MarshalTo(dAtA[i:]) + n45, err := m.SELinuxContext.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n44 + i += n45 } return i, nil } @@ -6161,11 +6029,11 @@ func (m *Privileges_CredentialSpec) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Source != nil { - nn45, err := m.Source.MarshalTo(dAtA[i:]) + nn46, err := m.Source.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn45 + i += nn46 } return i, nil } @@ -6567,6 +6435,9 @@ func (m *Mount) Size() (n int) { l = m.TmpfsOptions.Size() n += 1 + l + sovTypes(uint64(l)) } + if m.Consistency != 0 { + n += 1 + sovTypes(uint64(m.Consistency)) + } return n } @@ -6730,6 +6601,14 @@ func (m *TaskStatus) Size() (n int) { l = m.PortStatus.Size() n += 1 + l + sovTypes(uint64(l)) } + l = len(m.AppliedBy) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.AppliedAt != nil { + l = m.AppliedAt.Size() + n += 1 + l + sovTypes(uint64(l)) + } return n } @@ -7659,6 +7538,7 @@ func (this *Mount) String() string { `BindOptions:` + strings.Replace(fmt.Sprintf("%v", this.BindOptions), "Mount_BindOptions", "Mount_BindOptions", 1) + `,`, `VolumeOptions:` + strings.Replace(fmt.Sprintf("%v", this.VolumeOptions), "Mount_VolumeOptions", "Mount_VolumeOptions", 1) + `,`, `TmpfsOptions:` + strings.Replace(fmt.Sprintf("%v", this.TmpfsOptions), "Mount_TmpfsOptions", "Mount_TmpfsOptions", 1) + `,`, + `Consistency:` + fmt.Sprintf("%v", this.Consistency) + `,`, `}`, }, "") return s @@ -7780,6 +7660,8 @@ func (this *TaskStatus) String() string { `Err:` + fmt.Sprintf("%v", this.Err) + `,`, `RuntimeStatus:` + fmt.Sprintf("%v", this.RuntimeStatus) + `,`, `PortStatus:` + strings.Replace(fmt.Sprintf("%v", this.PortStatus), "PortStatus", "PortStatus", 1) + `,`, + `AppliedBy:` + fmt.Sprintf("%v", this.AppliedBy) + `,`, + `AppliedAt:` + strings.Replace(fmt.Sprintf("%v", this.AppliedAt), "Timestamp", "google_protobuf.Timestamp", 1) + `,`, `}`, }, "") return s @@ -10623,6 +10505,25 @@ func (m *Mount) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Consistency", wireType) + } + m.Consistency = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Consistency |= (Mount_MountConsistency(b) & 0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) @@ -11924,6 +11825,68 @@ func (m *TaskStatus) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AppliedBy", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AppliedBy = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AppliedAt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AppliedAt == nil { + m.AppliedAt = &google_protobuf.Timestamp{} + } + if err := m.AppliedAt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) @@ -17058,310 +17021,322 @@ var ( ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("types.proto", fileDescriptorTypes) } +func init() { proto.RegisterFile("github.com/docker/swarmkit/api/types.proto", fileDescriptorTypes) } var fileDescriptorTypes = []byte{ - // 4822 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x7a, 0x4d, 0x6c, 0x24, 0x49, - 0x56, 0xbf, 0xeb, 0xd3, 0x55, 0xaf, 0xca, 0x76, 0x3a, 0xda, 0xdb, 0xe3, 0xae, 0xed, 0xb1, 0x6b, - 0x72, 0xa6, 0x77, 0x66, 0x67, 0xe7, 0x5f, 0xd3, 0x1f, 0xbb, 0xab, 0x9e, 0x99, 0xff, 0x7c, 0xd4, - 0x97, 0xdb, 0xb5, 0x6d, 0x57, 0x95, 0xa2, 0xca, 0xdd, 0x3b, 0x48, 0x90, 0x4a, 0x67, 0x86, 0xcb, - 0x39, 0xce, 0xca, 0x28, 0x32, 0xb3, 0xec, 0x2e, 0x16, 0x44, 0x8b, 0x03, 0x20, 0x9f, 0xe0, 0xb6, - 0x12, 0x32, 0x17, 0x38, 0x21, 0x24, 0x0e, 0x20, 0x21, 0xb8, 0x30, 0x48, 0x1c, 0xe6, 0xc6, 0x02, - 0x12, 0x5a, 0x81, 0x64, 0x18, 0x1f, 0xb8, 0x21, 0xb8, 0xac, 0xb8, 0x80, 0x84, 0xe2, 0x23, 0xb3, - 0xb2, 0xaa, 0xd3, 0x76, 0x0f, 0xb3, 0x17, 0x3b, 0xe3, 0xbd, 0xdf, 0x7b, 0xf1, 0xe2, 0x45, 0xc4, - 0x8b, 0xf7, 0x22, 0x0a, 0x0a, 0xfe, 0x64, 0x44, 0xbc, 0xca, 0xc8, 0xa5, 0x3e, 0x45, 0xc8, 0xa4, - 0xc6, 0x11, 0x71, 0x2b, 0xde, 0x89, 0xee, 0x0e, 0x8f, 0x2c, 0xbf, 0x72, 0x7c, 0xaf, 0xb4, 0x39, - 0xa0, 0x74, 0x60, 0x93, 0x77, 0x39, 0x62, 0x7f, 0x7c, 0xf0, 0xae, 0x6f, 0x0d, 0x89, 0xe7, 0xeb, - 0xc3, 0x91, 0x10, 0x2a, 0x6d, 0xcc, 0x03, 0xcc, 0xb1, 0xab, 0xfb, 0x16, 0x75, 0x24, 0x7f, 0x6d, - 0x40, 0x07, 0x94, 0x7f, 0xbe, 0xcb, 0xbe, 0x04, 0x55, 0xdd, 0x84, 0xc5, 0x27, 0xc4, 0xf5, 0x2c, - 0xea, 0xa0, 0x35, 0xc8, 0x58, 0x8e, 0x49, 0x9e, 0xad, 0x27, 0xca, 0x89, 0xb7, 0xd2, 0x58, 0x34, - 0xd4, 0xbb, 0x00, 0x2d, 0xf6, 0xd1, 0x74, 0x7c, 0x77, 0x82, 0x14, 0x48, 0x1d, 0x91, 0x09, 0x47, - 0xe4, 0x31, 0xfb, 0x64, 0x94, 0x63, 0xdd, 0x5e, 0x4f, 0x0a, 0xca, 0xb1, 0x6e, 0xab, 0x5f, 0x26, - 0xa0, 0x50, 0x75, 0x1c, 0xea, 0xf3, 0xde, 0x3d, 0x84, 0x20, 0xed, 0xe8, 0x43, 0x22, 0x85, 0xf8, - 0x37, 0xaa, 0x43, 0xd6, 0xd6, 0xf7, 0x89, 0xed, 0xad, 0x27, 0xcb, 0xa9, 0xb7, 0x0a, 0xf7, 0xbf, - 0x53, 0x79, 0x71, 0xc8, 0x95, 0x88, 0x92, 0xca, 0x0e, 0x47, 0x73, 0x23, 0xb0, 0x14, 0x45, 0x1f, - 0xc1, 0xa2, 0xe5, 0x98, 0x96, 0x41, 0xbc, 0xf5, 0x34, 0xd7, 0xb2, 0x11, 0xa7, 0x65, 0x6a, 0x7d, - 0x2d, 0xfd, 0xc5, 0xf9, 0xe6, 0x02, 0x0e, 0x84, 0x4a, 0xef, 0x41, 0x21, 0xa2, 0x36, 0x66, 0x6c, - 0x6b, 0x90, 0x39, 0xd6, 0xed, 0x31, 0x91, 0xa3, 0x13, 0x8d, 0xf7, 0x93, 0x0f, 0x13, 0xea, 0x27, - 0xb0, 0xd6, 0xd6, 0x87, 0xc4, 0x7c, 0x44, 0x1c, 0xe2, 0x5a, 0x06, 0x26, 0x1e, 0x1d, 0xbb, 0x06, - 0x61, 0x63, 0x3d, 0xb2, 0x1c, 0x33, 0x18, 0x2b, 0xfb, 0x8e, 0xd7, 0xa2, 0xd6, 0xe1, 0x95, 0x86, - 0xe5, 0x19, 0x2e, 0xf1, 0xc9, 0x57, 0x56, 0x92, 0x0a, 0x94, 0x9c, 0x27, 0x60, 0x65, 0x5e, 0xfa, - 0x17, 0xe0, 0x06, 0x73, 0xb1, 0xa9, 0xb9, 0x92, 0xa2, 0x79, 0x23, 0x62, 0x70, 0x65, 0x85, 0xfb, - 0x6f, 0xc5, 0x79, 0x28, 0x6e, 0x24, 0xdb, 0x0b, 0x78, 0x95, 0xab, 0x09, 0x08, 0xbd, 0x11, 0x31, - 0x90, 0x01, 0x37, 0x4d, 0x69, 0xf4, 0x9c, 0xfa, 0x24, 0x57, 0x1f, 0x3b, 0x8d, 0x97, 0x0c, 0x73, - 0x7b, 0x01, 0xaf, 0x05, 0xca, 0xa2, 0x9d, 0xd4, 0x00, 0x72, 0x81, 0x6e, 0xf5, 0xc7, 0x09, 0xc8, - 0x07, 0x4c, 0x0f, 0x7d, 0x1b, 0xf2, 0x8e, 0xee, 0x50, 0xcd, 0x18, 0x8d, 0x3d, 0x3e, 0xa0, 0x54, - 0xad, 0x78, 0x71, 0xbe, 0x99, 0x6b, 0xeb, 0x0e, 0xad, 0x77, 0xf7, 0x3c, 0x9c, 0x63, 0xec, 0xfa, - 0x68, 0xec, 0xa1, 0xd7, 0xa0, 0x38, 0x24, 0x43, 0xea, 0x4e, 0xb4, 0xfd, 0x89, 0x4f, 0x3c, 0xe9, - 0xb6, 0x82, 0xa0, 0xd5, 0x18, 0x09, 0x7d, 0x08, 0x8b, 0x03, 0x61, 0xd2, 0x7a, 0x8a, 0x2f, 0x9f, - 0xd7, 0xe3, 0xac, 0x9f, 0xb3, 0x1a, 0x07, 0x32, 0xea, 0xef, 0x24, 0x60, 0x2d, 0xa4, 0x92, 0x5f, - 0x1e, 0x5b, 0x2e, 0x19, 0x12, 0xc7, 0xf7, 0xd0, 0xf7, 0x20, 0x6b, 0x5b, 0x43, 0xcb, 0xf7, 0xa4, - 0xcf, 0x5f, 0x8d, 0x53, 0x1b, 0x0e, 0x0a, 0x4b, 0x30, 0xaa, 0x42, 0xd1, 0x25, 0x1e, 0x71, 0x8f, - 0xc5, 0x8a, 0x97, 0x1e, 0xbd, 0x46, 0x78, 0x46, 0x44, 0xdd, 0x82, 0x5c, 0xd7, 0xd6, 0xfd, 0x03, - 0xea, 0x0e, 0x91, 0x0a, 0x45, 0xdd, 0x35, 0x0e, 0x2d, 0x9f, 0x18, 0xfe, 0xd8, 0x0d, 0x76, 0xdf, - 0x0c, 0x0d, 0xdd, 0x84, 0x24, 0x15, 0x1d, 0xe5, 0x6b, 0xd9, 0x8b, 0xf3, 0xcd, 0x64, 0xa7, 0x87, - 0x93, 0xd4, 0x53, 0x3f, 0x80, 0xd5, 0xae, 0x3d, 0x1e, 0x58, 0x4e, 0x83, 0x78, 0x86, 0x6b, 0x8d, - 0x98, 0x76, 0xb6, 0x2a, 0x59, 0x8c, 0x0a, 0x56, 0x25, 0xfb, 0x0e, 0xb7, 0x76, 0x72, 0xba, 0xb5, - 0xd5, 0xdf, 0x4a, 0xc2, 0x6a, 0xd3, 0x19, 0x58, 0x0e, 0x89, 0x4a, 0xdf, 0x81, 0x65, 0xc2, 0x89, - 0xda, 0xb1, 0x08, 0x37, 0x52, 0xcf, 0x92, 0xa0, 0x06, 0x31, 0xa8, 0x35, 0x17, 0x17, 0xee, 0xc5, - 0x0d, 0xff, 0x05, 0xed, 0xb1, 0xd1, 0xa1, 0x09, 0x8b, 0x23, 0x3e, 0x08, 0x4f, 0x4e, 0xef, 0x9d, - 0x38, 0x5d, 0x2f, 0x8c, 0x33, 0x08, 0x12, 0x52, 0xf6, 0xeb, 0x04, 0x89, 0x3f, 0x4e, 0xc2, 0x4a, - 0x9b, 0x9a, 0x33, 0x7e, 0x28, 0x41, 0xee, 0x90, 0x7a, 0x7e, 0x24, 0x20, 0x86, 0x6d, 0xf4, 0x10, - 0x72, 0x23, 0x39, 0x7d, 0x72, 0xf6, 0x6f, 0xc7, 0x9b, 0x2c, 0x30, 0x38, 0x44, 0xa3, 0x0f, 0x20, - 0x1f, 0x6c, 0x19, 0x36, 0xda, 0x97, 0x58, 0x38, 0x53, 0x3c, 0xfa, 0x10, 0xb2, 0x62, 0x12, 0xd6, - 0xd3, 0x5c, 0xf2, 0xce, 0x4b, 0xf9, 0x1c, 0x4b, 0x21, 0xf4, 0x08, 0x72, 0xbe, 0xed, 0x69, 0x96, - 0x73, 0x40, 0xd7, 0x33, 0x5c, 0xc1, 0x66, 0x6c, 0x90, 0xa1, 0x26, 0xe9, 0xef, 0xf4, 0x5a, 0xce, - 0x01, 0xad, 0x15, 0x2e, 0xce, 0x37, 0x17, 0x65, 0x03, 0x2f, 0xfa, 0xb6, 0xc7, 0x3e, 0xd4, 0xdf, - 0x4d, 0x40, 0x21, 0x82, 0x42, 0xaf, 0x02, 0xf8, 0xee, 0xd8, 0xf3, 0x35, 0x97, 0x52, 0x9f, 0x3b, - 0xab, 0x88, 0xf3, 0x9c, 0x82, 0x29, 0xf5, 0x51, 0x05, 0x6e, 0x18, 0xc4, 0xf5, 0x35, 0xcb, 0xf3, - 0xc6, 0xc4, 0xd5, 0xbc, 0xf1, 0xfe, 0x67, 0xc4, 0xf0, 0xb9, 0xe3, 0x8a, 0x78, 0x95, 0xb1, 0x5a, - 0x9c, 0xd3, 0x13, 0x0c, 0xf4, 0x00, 0x6e, 0x46, 0xf1, 0xa3, 0xf1, 0xbe, 0x6d, 0x19, 0x1a, 0x9b, - 0xcc, 0x14, 0x17, 0xb9, 0x31, 0x15, 0xe9, 0x72, 0xde, 0x63, 0x32, 0x51, 0x7f, 0x9a, 0x00, 0x05, - 0xeb, 0x07, 0xfe, 0x2e, 0x19, 0xee, 0x13, 0xb7, 0xe7, 0xeb, 0xfe, 0xd8, 0x43, 0x37, 0x21, 0x6b, - 0x13, 0xdd, 0x24, 0x2e, 0x37, 0x2a, 0x87, 0x65, 0x0b, 0xed, 0xb1, 0x1d, 0xac, 0x1b, 0x87, 0xfa, - 0xbe, 0x65, 0x5b, 0xfe, 0x84, 0x9b, 0xb2, 0x1c, 0xbf, 0x84, 0xe7, 0x75, 0x56, 0x70, 0x44, 0x10, - 0xcf, 0xa8, 0x41, 0xeb, 0xb0, 0x38, 0x24, 0x9e, 0xa7, 0x0f, 0x08, 0xb7, 0x34, 0x8f, 0x83, 0xa6, - 0xfa, 0x01, 0x14, 0xa3, 0x72, 0xa8, 0x00, 0x8b, 0x7b, 0xed, 0xc7, 0xed, 0xce, 0xd3, 0xb6, 0xb2, - 0x80, 0x56, 0xa0, 0xb0, 0xd7, 0xc6, 0xcd, 0x6a, 0x7d, 0xbb, 0x5a, 0xdb, 0x69, 0x2a, 0x09, 0xb4, - 0x04, 0xf9, 0x69, 0x33, 0xa9, 0xfe, 0x69, 0x02, 0x80, 0xb9, 0x5b, 0x0e, 0xea, 0x7d, 0xc8, 0x78, - 0xbe, 0xee, 0x8b, 0x55, 0xb9, 0x7c, 0xff, 0x8d, 0xcb, 0xe6, 0x50, 0xda, 0xcb, 0xfe, 0x11, 0x2c, - 0x44, 0xa2, 0x16, 0x26, 0x67, 0x2c, 0x64, 0x01, 0x42, 0x37, 0x4d, 0x57, 0x1a, 0xce, 0xbf, 0xd5, - 0x0f, 0x20, 0xc3, 0xa5, 0x67, 0xcd, 0xcd, 0x41, 0xba, 0xc1, 0xbe, 0x12, 0x28, 0x0f, 0x19, 0xdc, - 0xac, 0x36, 0x3e, 0x55, 0x92, 0x48, 0x81, 0x62, 0xa3, 0xd5, 0xab, 0x77, 0xda, 0xed, 0x66, 0xbd, - 0xdf, 0x6c, 0x28, 0x29, 0xf5, 0x0e, 0x64, 0x5a, 0x43, 0xa6, 0xf9, 0x36, 0x5b, 0xf2, 0x07, 0xc4, - 0x25, 0x8e, 0x11, 0xec, 0xa4, 0x29, 0x41, 0xfd, 0x49, 0x1e, 0x32, 0xbb, 0x74, 0xec, 0xf8, 0xe8, - 0x7e, 0x24, 0x6c, 0x2d, 0xc7, 0x67, 0x08, 0x1c, 0x58, 0xe9, 0x4f, 0x46, 0x44, 0x86, 0xb5, 0x9b, - 0x90, 0x15, 0x9b, 0x43, 0x0e, 0x47, 0xb6, 0x18, 0xdd, 0xd7, 0xdd, 0x01, 0xf1, 0xe5, 0x78, 0x64, - 0x0b, 0xbd, 0xc5, 0x4e, 0x2c, 0xdd, 0xa4, 0x8e, 0x3d, 0xe1, 0x7b, 0x28, 0x27, 0x8e, 0x25, 0x4c, - 0x74, 0xb3, 0xe3, 0xd8, 0x13, 0x1c, 0x72, 0xd1, 0x36, 0x14, 0xf7, 0x2d, 0xc7, 0xd4, 0xe8, 0x48, - 0x04, 0xf9, 0xcc, 0xe5, 0x3b, 0x4e, 0x58, 0x55, 0xb3, 0x1c, 0xb3, 0x23, 0xc0, 0xb8, 0xb0, 0x3f, - 0x6d, 0xa0, 0x36, 0x2c, 0x1f, 0x53, 0x7b, 0x3c, 0x24, 0xa1, 0xae, 0x2c, 0xd7, 0xf5, 0xe6, 0xe5, - 0xba, 0x9e, 0x70, 0x7c, 0xa0, 0x6d, 0xe9, 0x38, 0xda, 0x44, 0x8f, 0x61, 0xc9, 0x1f, 0x8e, 0x0e, - 0xbc, 0x50, 0xdd, 0x22, 0x57, 0xf7, 0xad, 0x2b, 0x1c, 0xc6, 0xe0, 0x81, 0xb6, 0xa2, 0x1f, 0x69, - 0x95, 0x7e, 0x23, 0x05, 0x85, 0x88, 0xe5, 0xa8, 0x07, 0x85, 0x91, 0x4b, 0x47, 0xfa, 0x80, 0x1f, - 0x54, 0x72, 0x2e, 0xee, 0xbd, 0xd4, 0xa8, 0x2b, 0xdd, 0xa9, 0x20, 0x8e, 0x6a, 0x51, 0xcf, 0x92, - 0x50, 0x88, 0x30, 0xd1, 0xdb, 0x90, 0xc3, 0x5d, 0xdc, 0x7a, 0x52, 0xed, 0x37, 0x95, 0x85, 0xd2, - 0xed, 0xd3, 0xb3, 0xf2, 0x3a, 0xd7, 0x16, 0x55, 0xd0, 0x75, 0xad, 0x63, 0xb6, 0xf4, 0xde, 0x82, - 0xc5, 0x00, 0x9a, 0x28, 0x7d, 0xf3, 0xf4, 0xac, 0xfc, 0xca, 0x3c, 0x34, 0x82, 0xc4, 0xbd, 0xed, - 0x2a, 0x6e, 0x36, 0x94, 0x64, 0x3c, 0x12, 0xf7, 0x0e, 0x75, 0x97, 0x98, 0xe8, 0x5b, 0x90, 0x95, - 0xc0, 0x54, 0xa9, 0x74, 0x7a, 0x56, 0xbe, 0x39, 0x0f, 0x9c, 0xe2, 0x70, 0x6f, 0xa7, 0xfa, 0xa4, - 0xa9, 0xa4, 0xe3, 0x71, 0xb8, 0x67, 0xeb, 0xc7, 0x04, 0xbd, 0x01, 0x19, 0x01, 0xcb, 0x94, 0x6e, - 0x9d, 0x9e, 0x95, 0xbf, 0xf1, 0x82, 0x3a, 0x86, 0x2a, 0xad, 0xff, 0xf6, 0x1f, 0x6c, 0x2c, 0xfc, - 0xe5, 0x1f, 0x6e, 0x28, 0xf3, 0xec, 0xd2, 0x7f, 0x27, 0x60, 0x69, 0x66, 0xca, 0x91, 0x0a, 0x59, - 0x87, 0x1a, 0x74, 0x24, 0xce, 0xaf, 0x5c, 0x0d, 0x2e, 0xce, 0x37, 0xb3, 0x6d, 0x5a, 0xa7, 0xa3, - 0x09, 0x96, 0x1c, 0xf4, 0x78, 0xee, 0x04, 0x7e, 0xf0, 0x92, 0xeb, 0x29, 0xf6, 0x0c, 0xfe, 0x18, - 0x96, 0x4c, 0xd7, 0x3a, 0x26, 0xae, 0x66, 0x50, 0xe7, 0xc0, 0x1a, 0xc8, 0xb3, 0xa9, 0x14, 0x9b, - 0x26, 0x72, 0x20, 0x2e, 0x0a, 0x81, 0x3a, 0xc7, 0x7f, 0x8d, 0xd3, 0xb7, 0xf4, 0x04, 0x8a, 0xd1, - 0x15, 0xca, 0x8e, 0x13, 0xcf, 0xfa, 0x15, 0x22, 0xf3, 0x41, 0x9e, 0x3d, 0xe2, 0x3c, 0xa3, 0x88, - 0x6c, 0xf0, 0x4d, 0x48, 0x0f, 0xa9, 0x29, 0xf4, 0x2c, 0xd5, 0x6e, 0xb0, 0x24, 0xe0, 0x9f, 0xce, - 0x37, 0x0b, 0xd4, 0xab, 0x6c, 0x59, 0x36, 0xd9, 0xa5, 0x26, 0xc1, 0x1c, 0xa0, 0x1e, 0x43, 0x9a, - 0x85, 0x0a, 0xf4, 0x4d, 0x48, 0xd7, 0x5a, 0xed, 0x86, 0xb2, 0x50, 0x5a, 0x3d, 0x3d, 0x2b, 0x2f, - 0x71, 0x97, 0x30, 0x06, 0x5b, 0xbb, 0x68, 0x13, 0xb2, 0x4f, 0x3a, 0x3b, 0x7b, 0xbb, 0x6c, 0x79, - 0xdd, 0x38, 0x3d, 0x2b, 0xaf, 0x84, 0x6c, 0xe1, 0x34, 0xf4, 0x2a, 0x64, 0xfa, 0xbb, 0xdd, 0xad, - 0x9e, 0x92, 0x2c, 0xa1, 0xd3, 0xb3, 0xf2, 0x72, 0xc8, 0xe7, 0x36, 0x97, 0x56, 0xe5, 0xac, 0xe6, - 0x43, 0xba, 0xfa, 0xb3, 0x24, 0x2c, 0x61, 0x56, 0xf1, 0xb9, 0x7e, 0x97, 0xda, 0x96, 0x31, 0x41, - 0x5d, 0xc8, 0x1b, 0xd4, 0x31, 0xad, 0xc8, 0x9e, 0xba, 0x7f, 0xc9, 0xa9, 0x3f, 0x95, 0x0a, 0x5a, - 0xf5, 0x40, 0x12, 0x4f, 0x95, 0xa0, 0x77, 0x21, 0x63, 0x12, 0x5b, 0x9f, 0xc8, 0xf4, 0xe3, 0x56, - 0x45, 0xd4, 0x94, 0x95, 0xa0, 0xa6, 0xac, 0x34, 0x64, 0x4d, 0x89, 0x05, 0x8e, 0xa7, 0xd9, 0xfa, - 0x33, 0x4d, 0xf7, 0x7d, 0x32, 0x1c, 0xf9, 0x22, 0xf7, 0x48, 0xe3, 0xc2, 0x50, 0x7f, 0x56, 0x95, - 0x24, 0x74, 0x0f, 0xb2, 0x27, 0x96, 0x63, 0xd2, 0x13, 0x99, 0x5e, 0x5c, 0xa1, 0x54, 0x02, 0xd5, - 0x53, 0x76, 0xea, 0xce, 0x99, 0xc9, 0xfc, 0xdd, 0xee, 0xb4, 0x9b, 0x81, 0xbf, 0x25, 0xbf, 0xe3, - 0xb4, 0xa9, 0xc3, 0xf6, 0x0a, 0x74, 0xda, 0xda, 0x56, 0xb5, 0xb5, 0xb3, 0x87, 0x99, 0xcf, 0xd7, - 0x4e, 0xcf, 0xca, 0x4a, 0x08, 0xd9, 0xd2, 0x2d, 0x9b, 0xe5, 0xbb, 0xb7, 0x20, 0x55, 0x6d, 0x7f, - 0xaa, 0x24, 0x4b, 0xca, 0xe9, 0x59, 0xb9, 0x18, 0xb2, 0xab, 0xce, 0x64, 0xba, 0x8d, 0xe6, 0xfb, - 0x55, 0xff, 0x36, 0x05, 0xc5, 0xbd, 0x91, 0xa9, 0xfb, 0x44, 0xac, 0x49, 0x54, 0x86, 0xc2, 0x48, - 0x77, 0x75, 0xdb, 0x26, 0xb6, 0xe5, 0x0d, 0x65, 0xb5, 0x1c, 0x25, 0xa1, 0xf7, 0x5e, 0xd6, 0x8d, - 0xb5, 0x1c, 0x5b, 0x67, 0x3f, 0xfe, 0x97, 0xcd, 0x44, 0xe0, 0xd0, 0x3d, 0x58, 0x3e, 0x10, 0xd6, - 0x6a, 0xba, 0xc1, 0x27, 0x36, 0xc5, 0x27, 0xb6, 0x12, 0x37, 0xb1, 0x51, 0xb3, 0x2a, 0x72, 0x90, - 0x55, 0x2e, 0x85, 0x97, 0x0e, 0xa2, 0x4d, 0xf4, 0x00, 0x16, 0x87, 0xd4, 0xb1, 0x7c, 0xea, 0x5e, - 0x3f, 0x0b, 0x01, 0x12, 0xbd, 0x0d, 0xab, 0x6c, 0x72, 0x03, 0x7b, 0x38, 0x9b, 0x9f, 0x58, 0x49, - 0xbc, 0x32, 0xd4, 0x9f, 0xc9, 0x0e, 0x31, 0x23, 0xa3, 0x1a, 0x64, 0xa8, 0xcb, 0x52, 0xa2, 0x2c, - 0x37, 0xf7, 0x9d, 0x6b, 0xcd, 0x15, 0x8d, 0x0e, 0x93, 0xc1, 0x42, 0x54, 0xfd, 0x3e, 0x2c, 0xcd, - 0x0c, 0x82, 0x65, 0x02, 0xdd, 0xea, 0x5e, 0xaf, 0xa9, 0x2c, 0xa0, 0x22, 0xe4, 0xea, 0x9d, 0x76, - 0xbf, 0xd5, 0xde, 0x63, 0xa9, 0x4c, 0x11, 0x72, 0xb8, 0xb3, 0xb3, 0x53, 0xab, 0xd6, 0x1f, 0x2b, - 0x49, 0xb5, 0x02, 0x85, 0x88, 0x36, 0xb4, 0x0c, 0xd0, 0xeb, 0x77, 0xba, 0xda, 0x56, 0x0b, 0xf7, - 0xfa, 0x22, 0x11, 0xea, 0xf5, 0xab, 0xb8, 0x2f, 0x09, 0x09, 0xf5, 0x3f, 0x92, 0xc1, 0x8c, 0xca, - 0xdc, 0xa7, 0x36, 0x9b, 0xfb, 0x5c, 0x61, 0xbc, 0xcc, 0x7e, 0xa6, 0x8d, 0x30, 0x07, 0x7a, 0x0f, - 0x80, 0x2f, 0x1c, 0x62, 0x6a, 0xba, 0x2f, 0x27, 0xbe, 0xf4, 0x82, 0x93, 0xfb, 0xc1, 0xa5, 0x0d, - 0xce, 0x4b, 0x74, 0xd5, 0x47, 0x1f, 0x42, 0xd1, 0xa0, 0xc3, 0x91, 0x4d, 0xa4, 0x70, 0xea, 0x5a, - 0xe1, 0x42, 0x88, 0xaf, 0xfa, 0xd1, 0xec, 0x2b, 0x3d, 0x9b, 0x1f, 0xfe, 0x66, 0x22, 0xf0, 0x4c, - 0x4c, 0xc2, 0x55, 0x84, 0xdc, 0x5e, 0xb7, 0x51, 0xed, 0xb7, 0xda, 0x8f, 0x94, 0x04, 0x02, 0xc8, - 0x72, 0x57, 0x37, 0x94, 0x24, 0x4b, 0x14, 0xeb, 0x9d, 0xdd, 0xee, 0x4e, 0x93, 0xa7, 0x5c, 0x68, - 0x0d, 0x94, 0xc0, 0xd9, 0x1a, 0x77, 0x64, 0xb3, 0xa1, 0xa4, 0xd1, 0x0d, 0x58, 0x09, 0xa9, 0x52, - 0x32, 0x83, 0x6e, 0x02, 0x0a, 0x89, 0x53, 0x15, 0x59, 0xf5, 0xd7, 0x60, 0xa5, 0x4e, 0x1d, 0x5f, - 0xb7, 0x9c, 0x30, 0x89, 0xbe, 0xcf, 0x06, 0x2d, 0x49, 0x9a, 0x25, 0x2f, 0x3b, 0x6a, 0x2b, 0x17, - 0xe7, 0x9b, 0x85, 0x10, 0xda, 0x6a, 0xb0, 0x91, 0x06, 0x0d, 0x93, 0xed, 0xdf, 0x91, 0x65, 0x72, - 0xe7, 0x66, 0x6a, 0x8b, 0x17, 0xe7, 0x9b, 0xa9, 0x6e, 0xab, 0x81, 0x19, 0x0d, 0x7d, 0x13, 0xf2, - 0xe4, 0x99, 0xe5, 0x6b, 0x06, 0x8b, 0xe1, 0xcc, 0x81, 0x19, 0x9c, 0x63, 0x84, 0x3a, 0x0b, 0xd9, - 0x35, 0x80, 0x2e, 0x75, 0x7d, 0xd9, 0xf3, 0x77, 0x21, 0x33, 0xa2, 0x2e, 0x2f, 0xcf, 0x2f, 0xbd, - 0x34, 0x62, 0x70, 0xb1, 0x50, 0xb1, 0x00, 0xab, 0x7f, 0x95, 0x04, 0xe8, 0xeb, 0xde, 0x91, 0x54, - 0xf2, 0x10, 0xf2, 0xe1, 0x05, 0x9c, 0xac, 0xf3, 0xaf, 0x9c, 0xed, 0x10, 0x8c, 0x1e, 0x04, 0x8b, - 0x4d, 0x94, 0x07, 0xb1, 0x75, 0x5a, 0xd0, 0x51, 0x5c, 0x86, 0x3d, 0x5b, 0x03, 0xb0, 0x23, 0x91, - 0xb8, 0xae, 0x9c, 0x79, 0xf6, 0x89, 0xea, 0xfc, 0x58, 0x10, 0x4e, 0x93, 0x09, 0x66, 0xec, 0xcd, - 0xc6, 0xdc, 0x8c, 0x6c, 0x2f, 0xe0, 0xa9, 0x1c, 0xfa, 0x18, 0x0a, 0x6c, 0xdc, 0x9a, 0xc7, 0x79, - 0x32, 0xb7, 0xbc, 0xd4, 0x55, 0x42, 0x03, 0x86, 0x51, 0xf8, 0x5d, 0x53, 0x60, 0xd9, 0x1d, 0x3b, - 0x6c, 0xd8, 0x52, 0x87, 0xfa, 0x27, 0x49, 0x78, 0xa5, 0x4d, 0xfc, 0x13, 0xea, 0x1e, 0x55, 0x7d, - 0x5f, 0x37, 0x0e, 0x87, 0xc4, 0x91, 0x4e, 0x8e, 0x64, 0xd6, 0x89, 0x99, 0xcc, 0x7a, 0x1d, 0x16, - 0x75, 0xdb, 0xd2, 0x3d, 0x22, 0xd2, 0x91, 0x3c, 0x0e, 0x9a, 0x2c, 0xff, 0x67, 0xd5, 0x04, 0xf1, - 0x3c, 0x22, 0x0a, 0xfc, 0x3c, 0x9e, 0x12, 0xd0, 0x8f, 0xe0, 0xa6, 0x4c, 0x3c, 0xf4, 0xb0, 0x2b, - 0x96, 0xd9, 0x06, 0x37, 0x85, 0xcd, 0xd8, 0xf2, 0x26, 0xde, 0x38, 0x99, 0x99, 0x4c, 0xc9, 0x9d, - 0x91, 0x2f, 0xf3, 0x9c, 0x35, 0x33, 0x86, 0x55, 0x7a, 0x04, 0xb7, 0x2e, 0x15, 0xf9, 0x4a, 0x17, - 0x08, 0xff, 0x90, 0x04, 0x68, 0x75, 0xab, 0xbb, 0xd2, 0x49, 0x0d, 0xc8, 0x1e, 0xe8, 0x43, 0xcb, - 0x9e, 0x5c, 0x15, 0xa7, 0xa6, 0xf8, 0x4a, 0x55, 0xb8, 0x63, 0x8b, 0xcb, 0x60, 0x29, 0xcb, 0x8b, - 0x9b, 0xf1, 0xbe, 0x43, 0xfc, 0xb0, 0xb8, 0xe1, 0x2d, 0x66, 0x86, 0xab, 0x3b, 0xe1, 0x02, 0x13, - 0x0d, 0x36, 0x01, 0x03, 0xdd, 0x27, 0x27, 0xfa, 0x24, 0x08, 0x2e, 0xb2, 0x89, 0xb6, 0xf9, 0x35, - 0x1d, 0x71, 0x8f, 0x89, 0xb9, 0x9e, 0xe1, 0x4e, 0xbd, 0xce, 0x1e, 0x2c, 0xe1, 0xc2, 0x77, 0xa1, - 0x74, 0xe9, 0x03, 0x9e, 0xd8, 0x4c, 0x59, 0x5f, 0xc9, 0x47, 0x77, 0x61, 0x69, 0x66, 0x9c, 0x2f, - 0x54, 0x95, 0xad, 0xee, 0x93, 0xef, 0x2a, 0x69, 0xf9, 0xf5, 0x7d, 0x25, 0xab, 0xfe, 0x51, 0x4a, - 0x84, 0x03, 0xe9, 0xd5, 0xf8, 0xeb, 0xe9, 0x1c, 0xdf, 0xc4, 0x06, 0xb5, 0xe5, 0x36, 0x7d, 0xf3, - 0xea, 0x28, 0xc1, 0xaa, 0x14, 0x0e, 0xc7, 0xa1, 0x20, 0xda, 0x84, 0x82, 0x58, 0xc5, 0x1a, 0xdb, - 0x16, 0xdc, 0xad, 0x4b, 0x18, 0x04, 0x89, 0x49, 0xa2, 0x3b, 0xb0, 0xcc, 0x6f, 0x21, 0xbc, 0x43, - 0x62, 0x0a, 0x4c, 0x9a, 0x63, 0x96, 0x42, 0x2a, 0x87, 0xed, 0x42, 0x51, 0x12, 0x34, 0x9e, 0xa1, - 0x66, 0xb8, 0x41, 0x6f, 0x5f, 0x67, 0x90, 0x10, 0xe1, 0x89, 0x6b, 0x61, 0x34, 0x6d, 0xa8, 0x0d, - 0xc8, 0x05, 0xc6, 0xa2, 0x75, 0x48, 0xf5, 0xeb, 0x5d, 0x65, 0xa1, 0xb4, 0x72, 0x7a, 0x56, 0x2e, - 0x04, 0xe4, 0x7e, 0xbd, 0xcb, 0x38, 0x7b, 0x8d, 0xae, 0x92, 0x98, 0xe5, 0xec, 0x35, 0xba, 0xa5, - 0x34, 0xcb, 0x94, 0xd4, 0x03, 0x28, 0x44, 0x7a, 0x40, 0xaf, 0xc3, 0x62, 0xab, 0xfd, 0x08, 0x37, - 0x7b, 0x3d, 0x65, 0xa1, 0x74, 0xf3, 0xf4, 0xac, 0x8c, 0x22, 0xdc, 0x96, 0x33, 0x60, 0xf3, 0x83, - 0x5e, 0x85, 0xf4, 0x76, 0x87, 0x9d, 0xc0, 0x22, 0x25, 0x8e, 0x20, 0xb6, 0xa9, 0xe7, 0x97, 0x6e, - 0xc8, 0x14, 0x2c, 0xaa, 0x58, 0xfd, 0xbd, 0x04, 0x64, 0xc5, 0x66, 0x8a, 0x9d, 0xa8, 0x2a, 0x2c, - 0x06, 0xf5, 0xaa, 0x28, 0x57, 0xde, 0xbc, 0xbc, 0xb4, 0xa8, 0xc8, 0x4a, 0x40, 0x2c, 0xbf, 0x40, - 0xae, 0xf4, 0x3e, 0x14, 0xa3, 0x8c, 0xaf, 0xb4, 0xf8, 0x7e, 0x04, 0x05, 0xb6, 0xbe, 0x83, 0x12, - 0xe3, 0x3e, 0x64, 0x45, 0x40, 0x08, 0x4f, 0x84, 0xcb, 0xeb, 0x1c, 0x89, 0x44, 0x0f, 0x61, 0x51, - 0xd4, 0x46, 0xc1, 0x35, 0xe5, 0xc6, 0xd5, 0xbb, 0x08, 0x07, 0x70, 0xf5, 0x63, 0x48, 0x77, 0x09, - 0x71, 0x99, 0xef, 0x1d, 0x6a, 0x92, 0xe9, 0x21, 0x2a, 0xcb, 0x3a, 0x93, 0xb4, 0x1a, 0xac, 0xac, - 0x33, 0x49, 0xcb, 0x0c, 0x2f, 0x62, 0x92, 0x91, 0x8b, 0x98, 0x3e, 0x14, 0x9f, 0x12, 0x6b, 0x70, - 0xe8, 0x13, 0x93, 0x2b, 0x7a, 0x07, 0xd2, 0x23, 0x12, 0x1a, 0xbf, 0x1e, 0xbb, 0xc0, 0x08, 0x71, - 0x31, 0x47, 0xb1, 0x38, 0x72, 0xc2, 0xa5, 0xe5, 0xdd, 0xba, 0x6c, 0xa9, 0x7f, 0x9f, 0x84, 0xe5, - 0x96, 0xe7, 0x8d, 0x75, 0xc7, 0x08, 0xf2, 0xab, 0x8f, 0x66, 0xf3, 0xab, 0xd8, 0x47, 0x88, 0x59, - 0x91, 0xd9, 0xfb, 0x25, 0x79, 0xc6, 0x25, 0xc3, 0x33, 0x4e, 0xfd, 0xf7, 0x44, 0x70, 0x89, 0x74, - 0x27, 0xb2, 0xdd, 0x4b, 0xeb, 0xa7, 0x67, 0xe5, 0xb5, 0xa8, 0x26, 0xb2, 0xe7, 0x1c, 0x39, 0xf4, - 0xc4, 0x41, 0xaf, 0x41, 0x06, 0x37, 0xdb, 0xcd, 0xa7, 0x4a, 0x42, 0x2c, 0xcf, 0x19, 0x10, 0x26, - 0x0e, 0x39, 0x61, 0x9a, 0xba, 0xcd, 0x76, 0x83, 0xe5, 0x43, 0xc9, 0x18, 0x4d, 0x5d, 0xe2, 0x98, - 0x96, 0x33, 0x40, 0xaf, 0x43, 0xb6, 0xd5, 0xeb, 0xed, 0xf1, 0x32, 0xff, 0x95, 0xd3, 0xb3, 0xf2, - 0x8d, 0x19, 0x14, 0xbf, 0x40, 0x34, 0x19, 0x88, 0x15, 0x23, 0x2c, 0x53, 0x8a, 0x01, 0xb1, 0x2c, - 0x57, 0x80, 0x70, 0xa7, 0x5f, 0xed, 0xb3, 0x0a, 0xff, 0x45, 0x10, 0xa6, 0xec, 0xaf, 0xdc, 0x6e, - 0xff, 0x9c, 0x04, 0xa5, 0x6a, 0x18, 0x64, 0xe4, 0x33, 0xbe, 0xac, 0xff, 0xfa, 0x90, 0x1b, 0xb1, - 0x2f, 0x8b, 0x04, 0xb9, 0xcc, 0xc3, 0xd8, 0x67, 0xb4, 0x39, 0xb9, 0x0a, 0xa6, 0x36, 0xa9, 0x9a, - 0x43, 0xcb, 0xf3, 0x2c, 0xea, 0x08, 0x1a, 0x0e, 0x35, 0x95, 0xfe, 0x33, 0x01, 0x37, 0x62, 0x10, - 0xe8, 0x2e, 0xa4, 0x5d, 0x6a, 0x07, 0x73, 0x78, 0xfb, 0xb2, 0xfb, 0x41, 0x26, 0x8a, 0x39, 0x12, - 0x6d, 0x00, 0xe8, 0x63, 0x9f, 0xea, 0xbc, 0x7f, 0x3e, 0x7b, 0x39, 0x1c, 0xa1, 0xa0, 0xa7, 0x90, - 0xf5, 0x88, 0xe1, 0x92, 0x20, 0xe3, 0xfd, 0xf8, 0xff, 0x6a, 0x7d, 0xa5, 0xc7, 0xd5, 0x60, 0xa9, - 0xae, 0x54, 0x81, 0xac, 0xa0, 0xb0, 0x65, 0x6f, 0xea, 0xbe, 0x2e, 0x6f, 0x8f, 0xf9, 0x37, 0x5b, - 0x4d, 0xba, 0x3d, 0x08, 0x56, 0x93, 0x6e, 0x0f, 0xd4, 0xbf, 0x49, 0x02, 0x34, 0x9f, 0xf9, 0xc4, - 0x75, 0x74, 0xbb, 0x5e, 0x45, 0xcd, 0x48, 0xf4, 0x17, 0xa3, 0xfd, 0x76, 0xec, 0x95, 0x78, 0x28, - 0x51, 0xa9, 0x57, 0x63, 0xe2, 0xff, 0x2d, 0x48, 0x8d, 0x5d, 0xf9, 0x32, 0x2a, 0xb2, 0xd5, 0x3d, - 0xbc, 0x83, 0x19, 0x0d, 0x35, 0xa7, 0x61, 0x2b, 0x75, 0xf9, 0xfb, 0x67, 0xa4, 0x83, 0xd8, 0xd0, - 0xc5, 0x76, 0xbe, 0xa1, 0x6b, 0x06, 0x91, 0x27, 0x47, 0x51, 0xec, 0xfc, 0x7a, 0xb5, 0x4e, 0x5c, - 0x1f, 0x67, 0x0d, 0x9d, 0xfd, 0xff, 0x5a, 0xf1, 0xed, 0x1d, 0x80, 0xe9, 0xd0, 0xd0, 0x06, 0x64, - 0xea, 0x5b, 0xbd, 0xde, 0x8e, 0xb2, 0x20, 0x02, 0xf8, 0x94, 0xc5, 0xc9, 0xea, 0x5f, 0x24, 0x21, - 0x57, 0xaf, 0xca, 0x63, 0xb5, 0x0e, 0x0a, 0x8f, 0x4a, 0xfc, 0xce, 0x9d, 0x3c, 0x1b, 0x59, 0xee, - 0x44, 0x06, 0x96, 0x2b, 0x4a, 0xcf, 0x65, 0x26, 0xc2, 0xac, 0x6e, 0x72, 0x01, 0x84, 0xa1, 0x48, - 0xa4, 0x13, 0x34, 0x43, 0x0f, 0x62, 0xfc, 0xc6, 0xd5, 0xce, 0x12, 0x45, 0xc4, 0xb4, 0xed, 0xe1, - 0x42, 0xa0, 0xa4, 0xae, 0x7b, 0xe8, 0x3d, 0x58, 0xf1, 0xac, 0x81, 0x63, 0x39, 0x03, 0x2d, 0x70, - 0x1e, 0x7f, 0x00, 0xa8, 0xad, 0x5e, 0x9c, 0x6f, 0x2e, 0xf5, 0x04, 0x4b, 0xfa, 0x70, 0x49, 0x22, - 0xeb, 0xdc, 0x95, 0xe8, 0xfb, 0xb0, 0x1c, 0x11, 0x65, 0x5e, 0x14, 0x6e, 0x57, 0x2e, 0xce, 0x37, - 0x8b, 0xa1, 0xe4, 0x63, 0x32, 0xc1, 0xc5, 0x50, 0xf0, 0x31, 0xe1, 0xb7, 0x24, 0x07, 0xd4, 0x35, - 0x88, 0xe6, 0xf2, 0x3d, 0xcd, 0x4f, 0xf0, 0x34, 0x2e, 0x70, 0x9a, 0xd8, 0xe6, 0xea, 0x13, 0xb8, - 0xd1, 0x71, 0x8d, 0x43, 0xe2, 0xf9, 0xc2, 0x15, 0xd2, 0x8b, 0x1f, 0xc3, 0x6d, 0x5f, 0xf7, 0x8e, - 0xb4, 0x43, 0xcb, 0xf3, 0xa9, 0x3b, 0xd1, 0x5c, 0xe2, 0x13, 0x87, 0xf1, 0x35, 0xfe, 0x6a, 0x28, - 0xaf, 0xb1, 0x6e, 0x31, 0xcc, 0xb6, 0x80, 0xe0, 0x00, 0xb1, 0xc3, 0x00, 0x6a, 0x0b, 0x8a, 0xac, - 0x98, 0x68, 0x90, 0x03, 0x7d, 0x6c, 0xfb, 0x6c, 0xf4, 0x60, 0xd3, 0x81, 0xf6, 0xd2, 0xc7, 0x54, - 0xde, 0xa6, 0x03, 0xf1, 0xa9, 0xfe, 0x10, 0x94, 0x86, 0xe5, 0x8d, 0x74, 0xdf, 0x38, 0x0c, 0xee, - 0xe7, 0x50, 0x03, 0x94, 0x43, 0xa2, 0xbb, 0xfe, 0x3e, 0xd1, 0x7d, 0x6d, 0x44, 0x5c, 0x8b, 0x9a, - 0xd7, 0xcf, 0xf2, 0x4a, 0x28, 0xd2, 0xe5, 0x12, 0xea, 0x7f, 0x25, 0x00, 0xb0, 0x7e, 0x10, 0x64, - 0x64, 0xdf, 0x81, 0x55, 0xcf, 0xd1, 0x47, 0xde, 0x21, 0xf5, 0x35, 0xcb, 0xf1, 0x89, 0x7b, 0xac, - 0xdb, 0xf2, 0x9a, 0x45, 0x09, 0x18, 0x2d, 0x49, 0x47, 0xef, 0x00, 0x3a, 0x22, 0x64, 0xa4, 0x51, - 0xdb, 0xd4, 0x02, 0xa6, 0x78, 0xd3, 0x4c, 0x63, 0x85, 0x71, 0x3a, 0xb6, 0xd9, 0x0b, 0xe8, 0xa8, - 0x06, 0x1b, 0x6c, 0xf8, 0xc4, 0xf1, 0x5d, 0x8b, 0x78, 0xda, 0x01, 0x75, 0x35, 0xcf, 0xa6, 0x27, - 0xda, 0x01, 0xb5, 0x6d, 0x7a, 0x42, 0xdc, 0xe0, 0x06, 0xab, 0x64, 0xd3, 0x41, 0x53, 0x80, 0xb6, - 0xa8, 0xdb, 0xb3, 0xe9, 0xc9, 0x56, 0x80, 0x60, 0x69, 0xdb, 0x74, 0xcc, 0xbe, 0x65, 0x1c, 0x05, - 0x69, 0x5b, 0x48, 0xed, 0x5b, 0xc6, 0x11, 0x7a, 0x1d, 0x96, 0x88, 0x4d, 0xf8, 0x45, 0x86, 0x40, - 0x65, 0x38, 0xaa, 0x18, 0x10, 0x19, 0x48, 0xfd, 0x04, 0x94, 0xa6, 0x63, 0xb8, 0x93, 0x51, 0x64, - 0xce, 0xdf, 0x01, 0xc4, 0x82, 0xa4, 0x66, 0x53, 0xe3, 0x48, 0x1b, 0xea, 0x8e, 0x3e, 0x60, 0x76, - 0x89, 0xa7, 0x26, 0x85, 0x71, 0x76, 0xa8, 0x71, 0xb4, 0x2b, 0xe9, 0xea, 0x7b, 0x00, 0xbd, 0x91, - 0x4b, 0x74, 0xb3, 0xc3, 0xb2, 0x09, 0xe6, 0x3a, 0xde, 0xd2, 0x4c, 0xf9, 0x54, 0x47, 0x5d, 0xb9, - 0xd5, 0x15, 0xc1, 0x68, 0x84, 0x74, 0xf5, 0x17, 0xe1, 0x46, 0xd7, 0xd6, 0x0d, 0xfe, 0x6c, 0xdd, - 0x0d, 0xdf, 0x4e, 0xd0, 0x43, 0xc8, 0x0a, 0xa8, 0x9c, 0xc9, 0xd8, 0xed, 0x36, 0xed, 0x73, 0x7b, - 0x01, 0x4b, 0x7c, 0xad, 0x08, 0x30, 0xd5, 0xa3, 0xfe, 0x59, 0x02, 0xf2, 0xa1, 0x7e, 0x54, 0x06, - 0x56, 0xca, 0xb3, 0xe5, 0x6d, 0x39, 0xb2, 0xf6, 0xce, 0xe3, 0x28, 0x09, 0xb5, 0xa0, 0x30, 0x0a, - 0xa5, 0xaf, 0xcc, 0xe7, 0x62, 0xac, 0xc6, 0x51, 0x59, 0xf4, 0x3e, 0xe4, 0x83, 0xb7, 0xd1, 0x20, - 0xc2, 0x5e, 0xfd, 0x94, 0x3a, 0x85, 0xab, 0x1f, 0x01, 0xfc, 0x80, 0x5a, 0x4e, 0x9f, 0x1e, 0x11, - 0x87, 0xbf, 0xf5, 0xb1, 0x9a, 0x90, 0x04, 0x5e, 0x94, 0x2d, 0x5e, 0x90, 0x8b, 0x29, 0x08, 0x9f, - 0xbc, 0x44, 0x53, 0xfd, 0xeb, 0x24, 0x64, 0x31, 0xa5, 0x7e, 0xbd, 0x8a, 0xca, 0x90, 0x95, 0x71, - 0x82, 0x9f, 0x3f, 0xb5, 0xfc, 0xc5, 0xf9, 0x66, 0x46, 0x04, 0x88, 0x8c, 0xc1, 0x23, 0x43, 0x24, - 0x82, 0x27, 0x2f, 0x8b, 0xe0, 0xe8, 0x2e, 0x14, 0x25, 0x48, 0x3b, 0xd4, 0xbd, 0x43, 0x51, 0xa0, - 0xd5, 0x96, 0x2f, 0xce, 0x37, 0x41, 0x20, 0xb7, 0x75, 0xef, 0x10, 0x83, 0x40, 0xb3, 0x6f, 0xd4, - 0x84, 0xc2, 0x67, 0xd4, 0x72, 0x34, 0x9f, 0x0f, 0x42, 0x5e, 0xf9, 0xc5, 0xce, 0xe3, 0x74, 0xa8, - 0xf2, 0xe1, 0x1b, 0x3e, 0x9b, 0x0e, 0xbe, 0x09, 0x4b, 0x2e, 0xa5, 0xbe, 0x08, 0x5b, 0x16, 0x75, - 0xe4, 0x6d, 0x42, 0x39, 0xf6, 0x92, 0x99, 0x52, 0x1f, 0x4b, 0x1c, 0x2e, 0xba, 0x91, 0x16, 0xba, - 0x0b, 0x6b, 0xb6, 0xee, 0xf9, 0x1a, 0x8f, 0x77, 0xe6, 0x54, 0x5b, 0x96, 0x6f, 0x35, 0xc4, 0x78, - 0x5b, 0x9c, 0x15, 0x48, 0xa8, 0xff, 0x98, 0x80, 0x02, 0x1b, 0x8c, 0x75, 0x60, 0x19, 0x2c, 0xc9, - 0xfb, 0xea, 0xb9, 0xc7, 0x2d, 0x48, 0x19, 0x9e, 0x2b, 0x9d, 0xca, 0x0f, 0xdf, 0x7a, 0x0f, 0x63, - 0x46, 0x43, 0x9f, 0x40, 0x56, 0xde, 0x6a, 0x88, 0xb4, 0x43, 0xbd, 0x3e, 0x1d, 0x95, 0xbe, 0x91, - 0x72, 0x7c, 0x2d, 0x4f, 0xad, 0x13, 0x87, 0x00, 0x8e, 0x92, 0xd0, 0x4d, 0x48, 0x1a, 0xc2, 0x5d, - 0xf2, 0x97, 0x15, 0xf5, 0x36, 0x4e, 0x1a, 0x8e, 0xfa, 0x77, 0x09, 0x58, 0x9a, 0x6e, 0x78, 0xb6, - 0x02, 0x6e, 0x43, 0xde, 0x1b, 0xef, 0x7b, 0x13, 0xcf, 0x27, 0xc3, 0xe0, 0x1d, 0x33, 0x24, 0xa0, - 0x16, 0xe4, 0x75, 0x7b, 0x40, 0x5d, 0xcb, 0x3f, 0x1c, 0xca, 0x4a, 0x34, 0x3e, 0x55, 0x88, 0xea, - 0xac, 0x54, 0x03, 0x11, 0x3c, 0x95, 0x0e, 0xce, 0x7d, 0xf1, 0xd8, 0xcd, 0xcf, 0xfd, 0xd7, 0xa0, - 0x68, 0xeb, 0x43, 0x7e, 0xcd, 0xe3, 0x5b, 0x43, 0x31, 0x8e, 0x34, 0x2e, 0x48, 0x5a, 0xdf, 0x1a, - 0x12, 0x55, 0x85, 0x7c, 0xa8, 0x0c, 0xad, 0x40, 0xa1, 0xda, 0xec, 0x69, 0xf7, 0xee, 0x3f, 0xd4, - 0x1e, 0xd5, 0x77, 0x95, 0x05, 0x99, 0x9b, 0xfe, 0x79, 0x02, 0x96, 0x64, 0x38, 0x92, 0xf9, 0xfe, - 0xeb, 0xb0, 0xe8, 0xea, 0x07, 0x7e, 0x50, 0x91, 0xa4, 0xc5, 0xaa, 0x66, 0x11, 0x9e, 0x55, 0x24, - 0x8c, 0x15, 0x5f, 0x91, 0x44, 0x5e, 0xd6, 0x53, 0x57, 0xbe, 0xac, 0xa7, 0x7f, 0x2e, 0x2f, 0xeb, - 0xea, 0xaf, 0x03, 0x6c, 0x59, 0x36, 0xe9, 0x8b, 0xbb, 0xa6, 0xb8, 0xfa, 0x92, 0xe5, 0x70, 0xf2, - 0xc6, 0x31, 0xc8, 0xe1, 0x5a, 0x0d, 0xcc, 0x68, 0x8c, 0x35, 0xb0, 0x4c, 0xb9, 0x19, 0x39, 0xeb, - 0x11, 0x63, 0x0d, 0x2c, 0x33, 0x7c, 0x4b, 0x4a, 0x5f, 0xf7, 0x96, 0x74, 0x96, 0x80, 0x15, 0x99, - 0xbb, 0x86, 0xe1, 0xf7, 0xdb, 0x90, 0x17, 0x69, 0xec, 0xb4, 0xa0, 0xe3, 0xaf, 0xc9, 0x02, 0xd7, - 0x6a, 0xe0, 0x9c, 0x60, 0xb7, 0x4c, 0xb4, 0x09, 0x05, 0x09, 0x8d, 0xfc, 0x0a, 0x07, 0x04, 0xa9, - 0xcd, 0xcc, 0xff, 0x2e, 0xa4, 0x0f, 0x2c, 0x9b, 0xc8, 0x85, 0x1e, 0x1b, 0x00, 0xa6, 0x0e, 0xd8, - 0x5e, 0xc0, 0x1c, 0x5d, 0xcb, 0x05, 0x97, 0x71, 0xdc, 0x3e, 0x59, 0x76, 0x46, 0xed, 0x13, 0x15, - 0xe8, 0x9c, 0x7d, 0x02, 0xc7, 0xec, 0x13, 0x6c, 0x61, 0x9f, 0x84, 0x46, 0xed, 0x13, 0xa4, 0x9f, - 0x8b, 0x7d, 0x3b, 0x70, 0xb3, 0x66, 0xeb, 0xc6, 0x91, 0x6d, 0x79, 0x3e, 0x31, 0xa3, 0x11, 0xe3, - 0x3e, 0x64, 0x67, 0x92, 0xce, 0xab, 0x2e, 0x67, 0x25, 0x52, 0xfd, 0xb7, 0x04, 0x14, 0xb7, 0x89, - 0x6e, 0xfb, 0x87, 0xd3, 0xab, 0x21, 0x9f, 0x78, 0xbe, 0x3c, 0xac, 0xf8, 0x37, 0xfa, 0x1e, 0xe4, - 0xc2, 0x9c, 0xe4, 0xda, 0x57, 0xb2, 0x10, 0x8a, 0x1e, 0xc0, 0x22, 0xdb, 0x63, 0x74, 0x1c, 0x14, - 0x3b, 0x57, 0x3d, 0xc0, 0x48, 0x24, 0x3b, 0x64, 0x5c, 0xc2, 0x93, 0x10, 0xbe, 0x94, 0x32, 0x38, - 0x68, 0xa2, 0xff, 0x0f, 0x45, 0xfe, 0x7e, 0x10, 0xe4, 0x5c, 0x99, 0xeb, 0x74, 0x16, 0xc4, 0x13, - 0xa0, 0xc8, 0xb7, 0xfe, 0x27, 0x01, 0x6b, 0xbb, 0xfa, 0x64, 0x9f, 0xc8, 0xb0, 0x41, 0x4c, 0x4c, - 0x0c, 0xea, 0x9a, 0xa8, 0x1b, 0x0d, 0x37, 0x57, 0xbc, 0x28, 0xc6, 0x09, 0xc7, 0x47, 0x9d, 0xa0, - 0x00, 0x4b, 0x46, 0x0a, 0xb0, 0x35, 0xc8, 0x38, 0xd4, 0x31, 0x88, 0x8c, 0x45, 0xa2, 0xa1, 0x5a, - 0xd1, 0x50, 0x53, 0x0a, 0x1f, 0xfb, 0xf8, 0x53, 0x5d, 0x9b, 0xfa, 0x61, 0x6f, 0xe8, 0x13, 0x28, - 0xf5, 0x9a, 0x75, 0xdc, 0xec, 0xd7, 0x3a, 0x3f, 0xd4, 0x7a, 0xd5, 0x9d, 0x5e, 0xf5, 0xfe, 0x5d, - 0xad, 0xdb, 0xd9, 0xf9, 0xf4, 0xde, 0x83, 0xbb, 0xdf, 0x53, 0x12, 0xa5, 0xf2, 0xe9, 0x59, 0xf9, - 0x76, 0xbb, 0x5a, 0xdf, 0x11, 0x3b, 0x66, 0x9f, 0x3e, 0xeb, 0xe9, 0xb6, 0xa7, 0xdf, 0xbf, 0xdb, - 0xa5, 0xf6, 0x84, 0x61, 0xd8, 0xb2, 0x2e, 0x46, 0xcf, 0xab, 0xe8, 0x31, 0x9c, 0xb8, 0xf4, 0x18, - 0x9e, 0x9e, 0xe6, 0xc9, 0x4b, 0x4e, 0xf3, 0x2d, 0x58, 0x33, 0x5c, 0xea, 0x79, 0x1a, 0xcb, 0xfe, - 0x89, 0x39, 0x57, 0x5f, 0x7c, 0xe3, 0xe2, 0x7c, 0x73, 0xb5, 0xce, 0xf8, 0x3d, 0xce, 0x96, 0xea, - 0x57, 0x8d, 0x08, 0x89, 0xf7, 0xa4, 0xfe, 0x7e, 0x8a, 0x25, 0x52, 0xd6, 0xb1, 0x65, 0x93, 0x01, - 0xf1, 0xd0, 0x13, 0x58, 0x31, 0x5c, 0x62, 0xb2, 0xb4, 0x5e, 0xb7, 0xa3, 0xbf, 0xe6, 0xfc, 0x7f, - 0xb1, 0x39, 0x4d, 0x28, 0x58, 0xa9, 0x87, 0x52, 0xbd, 0x11, 0x31, 0xf0, 0xb2, 0x31, 0xd3, 0x46, - 0x9f, 0xc1, 0x8a, 0x47, 0x6c, 0xcb, 0x19, 0x3f, 0xd3, 0x0c, 0xea, 0xf8, 0xe4, 0x59, 0xf0, 0x6e, - 0x75, 0x9d, 0xde, 0x5e, 0x73, 0x87, 0x49, 0xd5, 0x85, 0x50, 0x0d, 0x5d, 0x9c, 0x6f, 0x2e, 0xcf, - 0xd2, 0xf0, 0xb2, 0xd4, 0x2c, 0xdb, 0xa5, 0x36, 0x2c, 0xcf, 0x5a, 0x83, 0xd6, 0xe4, 0xde, 0xe7, - 0x21, 0x24, 0xd8, 0xdb, 0xe8, 0x36, 0xe4, 0x5c, 0x32, 0xb0, 0x3c, 0xdf, 0x15, 0x6e, 0x66, 0x9c, - 0x90, 0xc2, 0x76, 0xbe, 0xf8, 0x29, 0x4e, 0xe9, 0x57, 0x61, 0xae, 0x47, 0xb6, 0x59, 0x4c, 0xcb, - 0xd3, 0xf7, 0xa5, 0xca, 0x1c, 0x0e, 0x9a, 0x6c, 0x0d, 0x8e, 0xbd, 0x30, 0x51, 0xe3, 0xdf, 0x8c, - 0xc6, 0x33, 0x0a, 0xf9, 0xc3, 0x24, 0x9e, 0x33, 0x04, 0xbf, 0x70, 0x4c, 0x47, 0x7e, 0xe1, 0xb8, - 0x06, 0x19, 0x9b, 0x1c, 0x13, 0x5b, 0x9c, 0xe5, 0x58, 0x34, 0xde, 0xfe, 0x59, 0x0a, 0xf2, 0xe1, - 0x1b, 0x0d, 0x3b, 0x09, 0xda, 0xcd, 0xa7, 0xc1, 0x5a, 0x0d, 0xe9, 0x6d, 0x72, 0x82, 0x5e, 0x9b, - 0xde, 0x29, 0x7d, 0x22, 0x1e, 0xa5, 0x43, 0x76, 0x70, 0x9f, 0xf4, 0x06, 0xe4, 0xaa, 0xbd, 0x5e, - 0xeb, 0x51, 0xbb, 0xd9, 0x50, 0x3e, 0x4f, 0x94, 0xbe, 0x71, 0x7a, 0x56, 0x5e, 0x0d, 0x41, 0x55, - 0x4f, 0x2c, 0x25, 0x8e, 0xaa, 0xd7, 0x9b, 0xdd, 0x7e, 0xb3, 0xa1, 0x3c, 0x4f, 0xce, 0xa3, 0xf8, - 0x1d, 0x09, 0xff, 0x69, 0x49, 0xbe, 0x8b, 0x9b, 0xdd, 0x2a, 0x66, 0x1d, 0x7e, 0x9e, 0x14, 0x57, - 0x5d, 0xd3, 0x1e, 0x5d, 0x32, 0xd2, 0x5d, 0xd6, 0xe7, 0x46, 0xf0, 0x13, 0xab, 0xe7, 0x29, 0xf1, - 0xf3, 0x83, 0xe9, 0x83, 0x13, 0xd1, 0xcd, 0x09, 0xeb, 0x8d, 0xbf, 0xf4, 0x71, 0x35, 0xa9, 0xb9, - 0xde, 0x7a, 0x2c, 0x92, 0x30, 0x2d, 0x2a, 0x2c, 0xe2, 0xbd, 0x76, 0x9b, 0x81, 0x9e, 0xa7, 0xe7, - 0x46, 0x87, 0xc7, 0x0e, 0xab, 0x7f, 0xd1, 0x1d, 0xc8, 0x05, 0x0f, 0x81, 0xca, 0xe7, 0xe9, 0x39, - 0x83, 0xea, 0xc1, 0x2b, 0x26, 0xef, 0x70, 0x7b, 0xaf, 0xcf, 0x7f, 0x01, 0xf6, 0x3c, 0x33, 0xdf, - 0xe1, 0xe1, 0xd8, 0x37, 0xe9, 0x89, 0xc3, 0x76, 0xa0, 0xbc, 0x55, 0xfb, 0x3c, 0x23, 0xae, 0x20, - 0x42, 0x8c, 0xbc, 0x52, 0x7b, 0x03, 0x72, 0xb8, 0xf9, 0x03, 0xf1, 0x63, 0xb1, 0xe7, 0xd9, 0x39, - 0x3d, 0x98, 0x7c, 0x46, 0x0c, 0xd9, 0x5b, 0x07, 0x77, 0xb7, 0xab, 0xdc, 0xe5, 0xf3, 0xa8, 0x8e, - 0x3b, 0x3a, 0xd4, 0x1d, 0x62, 0x4e, 0x7f, 0x83, 0x11, 0xb2, 0xde, 0xfe, 0x25, 0xc8, 0x05, 0x79, - 0x26, 0xda, 0x80, 0xec, 0xd3, 0x0e, 0x7e, 0xdc, 0xc4, 0xca, 0x82, 0xf0, 0x61, 0xc0, 0x79, 0x2a, - 0x2a, 0x84, 0x32, 0x2c, 0xee, 0x56, 0xdb, 0xd5, 0x47, 0x4d, 0x1c, 0x5c, 0x78, 0x07, 0x00, 0x99, - 0x2c, 0x95, 0x14, 0xd9, 0x41, 0xa8, 0xb3, 0xb6, 0xfe, 0xc5, 0x97, 0x1b, 0x0b, 0x3f, 0xfd, 0x72, - 0x63, 0xe1, 0xf9, 0xc5, 0x46, 0xe2, 0x8b, 0x8b, 0x8d, 0xc4, 0x4f, 0x2e, 0x36, 0x12, 0xff, 0x7a, - 0xb1, 0x91, 0xd8, 0xcf, 0xf2, 0x90, 0xfe, 0xe0, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x48, 0x1c, - 0x30, 0x25, 0x28, 0x30, 0x00, 0x00, + // 5020 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x5a, 0x4d, 0x6c, 0x24, 0x49, + 0x56, 0x76, 0xfd, 0xba, 0xea, 0x55, 0xd9, 0x4e, 0x47, 0x7b, 0x7b, 0xdc, 0xb5, 0xdd, 0x76, 0x4d, + 0xce, 0xf4, 0xce, 0x6c, 0x6f, 0x53, 0xfd, 0xb7, 0xbb, 0xea, 0x99, 0x61, 0x77, 0xa6, 0xfe, 0x6c, + 0xd7, 0xb6, 0x5d, 0x55, 0x8a, 0x2a, 0x77, 0xef, 0x22, 0x41, 0x2a, 0x9d, 0x19, 0x2e, 0xe7, 0x38, + 0x2b, 0xa3, 0xc8, 0xcc, 0xb2, 0xbb, 0x58, 0x10, 0x2d, 0x0e, 0x80, 0x7c, 0x82, 0xdb, 0x22, 0x64, + 0x2e, 0x70, 0x42, 0x48, 0x1c, 0x40, 0x42, 0x70, 0x1a, 0x24, 0x0e, 0x7b, 0x83, 0x05, 0x09, 0xad, + 0x40, 0x32, 0xac, 0x0f, 0xdc, 0x56, 0x70, 0x59, 0x71, 0x01, 0x09, 0xc5, 0x4f, 0x66, 0xa5, 0xab, + 0xd3, 0x76, 0x0f, 0xb3, 0x17, 0xbb, 0xe2, 0xbd, 0xef, 0xbd, 0x78, 0xf1, 0x22, 0xe2, 0xc5, 0x7b, + 0x11, 0x09, 0xf7, 0x06, 0x96, 0x7f, 0x30, 0xde, 0xab, 0x18, 0x74, 0xf8, 0xc0, 0xa4, 0xc6, 0x21, + 0x71, 0x1f, 0x78, 0xc7, 0xba, 0x3b, 0x3c, 0xb4, 0xfc, 0x07, 0xfa, 0xc8, 0x7a, 0xe0, 0x4f, 0x46, + 0xc4, 0xab, 0x8c, 0x5c, 0xea, 0x53, 0x84, 0x04, 0xa0, 0x12, 0x00, 0x2a, 0x47, 0x8f, 0x4a, 0xeb, + 0x03, 0x4a, 0x07, 0x36, 0x79, 0xc0, 0x11, 0x7b, 0xe3, 0xfd, 0x07, 0xbe, 0x35, 0x24, 0x9e, 0xaf, + 0x0f, 0x47, 0x42, 0xa8, 0xb4, 0x36, 0x0b, 0x30, 0xc7, 0xae, 0xee, 0x5b, 0xd4, 0x91, 0xfc, 0x95, + 0x01, 0x1d, 0x50, 0xfe, 0xf3, 0x01, 0xfb, 0x25, 0xa8, 0xea, 0x3a, 0xcc, 0x3f, 0x27, 0xae, 0x67, + 0x51, 0x07, 0xad, 0x40, 0xc6, 0x72, 0x4c, 0xf2, 0x72, 0x35, 0x51, 0x4e, 0xbc, 0x9f, 0xc6, 0xa2, + 0xa1, 0x3e, 0x04, 0x68, 0xb1, 0x1f, 0x4d, 0xc7, 0x77, 0x27, 0x48, 0x81, 0xd4, 0x21, 0x99, 0x70, + 0x44, 0x1e, 0xb3, 0x9f, 0x8c, 0x72, 0xa4, 0xdb, 0xab, 0x49, 0x41, 0x39, 0xd2, 0x6d, 0xf5, 0x27, + 0x09, 0x28, 0x54, 0x1d, 0x87, 0xfa, 0xbc, 0x77, 0x0f, 0x21, 0x48, 0x3b, 0xfa, 0x90, 0x48, 0x21, + 0xfe, 0x1b, 0xd5, 0x21, 0x6b, 0xeb, 0x7b, 0xc4, 0xf6, 0x56, 0x93, 0xe5, 0xd4, 0xfb, 0x85, 0xc7, + 0x5f, 0xab, 0xbc, 0x3e, 0xe4, 0x4a, 0x44, 0x49, 0x65, 0x9b, 0xa3, 0xb9, 0x11, 0x58, 0x8a, 0xa2, + 0x6f, 0xc3, 0xbc, 0xe5, 0x98, 0x96, 0x41, 0xbc, 0xd5, 0x34, 0xd7, 0xb2, 0x16, 0xa7, 0x65, 0x6a, + 0x7d, 0x2d, 0xfd, 0xc3, 0xb3, 0xf5, 0x39, 0x1c, 0x08, 0x95, 0x3e, 0x80, 0x42, 0x44, 0x6d, 0xcc, + 0xd8, 0x56, 0x20, 0x73, 0xa4, 0xdb, 0x63, 0x22, 0x47, 0x27, 0x1a, 0x1f, 0x26, 0x9f, 0x26, 0xd4, + 0x4f, 0x60, 0xa5, 0xad, 0x0f, 0x89, 0xb9, 0x49, 0x1c, 0xe2, 0x5a, 0x06, 0x26, 0x1e, 0x1d, 0xbb, + 0x06, 0x61, 0x63, 0x3d, 0xb4, 0x1c, 0x33, 0x18, 0x2b, 0xfb, 0x1d, 0xaf, 0x45, 0xad, 0xc3, 0x5b, + 0x0d, 0xcb, 0x33, 0x5c, 0xe2, 0x93, 0xcf, 0xad, 0x24, 0x15, 0x28, 0x39, 0x4b, 0xc0, 0xd2, 0xac, + 0xf4, 0x2f, 0xc1, 0x0d, 0xe6, 0x62, 0x53, 0x73, 0x25, 0x45, 0xf3, 0x46, 0xc4, 0xe0, 0xca, 0x0a, + 0x8f, 0xdf, 0x8f, 0xf3, 0x50, 0xdc, 0x48, 0xb6, 0xe6, 0xf0, 0x32, 0x57, 0x13, 0x10, 0x7a, 0x23, + 0x62, 0x20, 0x03, 0x6e, 0x9a, 0xd2, 0xe8, 0x19, 0xf5, 0x49, 0xae, 0x3e, 0x76, 0x1a, 0x2f, 0x19, + 0xe6, 0xd6, 0x1c, 0x5e, 0x09, 0x94, 0x45, 0x3b, 0xa9, 0x01, 0xe4, 0x02, 0xdd, 0xea, 0x0f, 0x12, + 0x90, 0x0f, 0x98, 0x1e, 0xfa, 0x2a, 0xe4, 0x1d, 0xdd, 0xa1, 0x9a, 0x31, 0x1a, 0x7b, 0x7c, 0x40, + 0xa9, 0x5a, 0xf1, 0xfc, 0x6c, 0x3d, 0xd7, 0xd6, 0x1d, 0x5a, 0xef, 0xee, 0x7a, 0x38, 0xc7, 0xd8, + 0xf5, 0xd1, 0xd8, 0x43, 0x6f, 0x43, 0x71, 0x48, 0x86, 0xd4, 0x9d, 0x68, 0x7b, 0x13, 0x9f, 0x78, + 0xd2, 0x6d, 0x05, 0x41, 0xab, 0x31, 0x12, 0xfa, 0x16, 0xcc, 0x0f, 0x84, 0x49, 0xab, 0x29, 0xbe, + 0x7c, 0xde, 0x89, 0xb3, 0x7e, 0xc6, 0x6a, 0x1c, 0xc8, 0xa8, 0xbf, 0x97, 0x80, 0x95, 0x90, 0x4a, + 0x7e, 0x75, 0x6c, 0xb9, 0x64, 0x48, 0x1c, 0xdf, 0x43, 0xdf, 0x80, 0xac, 0x6d, 0x0d, 0x2d, 0xdf, + 0x93, 0x3e, 0xbf, 0x13, 0xa7, 0x36, 0x1c, 0x14, 0x96, 0x60, 0x54, 0x85, 0xa2, 0x4b, 0x3c, 0xe2, + 0x1e, 0x89, 0x15, 0x2f, 0x3d, 0x7a, 0x8d, 0xf0, 0x05, 0x11, 0x75, 0x03, 0x72, 0x5d, 0x5b, 0xf7, + 0xf7, 0xa9, 0x3b, 0x44, 0x2a, 0x14, 0x75, 0xd7, 0x38, 0xb0, 0x7c, 0x62, 0xf8, 0x63, 0x37, 0xd8, + 0x7d, 0x17, 0x68, 0xe8, 0x26, 0x24, 0xa9, 0xe8, 0x28, 0x5f, 0xcb, 0x9e, 0x9f, 0xad, 0x27, 0x3b, + 0x3d, 0x9c, 0xa4, 0x9e, 0xfa, 0x11, 0x2c, 0x77, 0xed, 0xf1, 0xc0, 0x72, 0x1a, 0xc4, 0x33, 0x5c, + 0x6b, 0xc4, 0xb4, 0xb3, 0x55, 0xc9, 0x62, 0x54, 0xb0, 0x2a, 0xd9, 0xef, 0x70, 0x6b, 0x27, 0xa7, + 0x5b, 0x5b, 0xfd, 0x9d, 0x24, 0x2c, 0x37, 0x9d, 0x81, 0xe5, 0x90, 0xa8, 0xf4, 0x5d, 0x58, 0x24, + 0x9c, 0xa8, 0x1d, 0x89, 0x70, 0x23, 0xf5, 0x2c, 0x08, 0x6a, 0x10, 0x83, 0x5a, 0x33, 0x71, 0xe1, + 0x51, 0xdc, 0xf0, 0x5f, 0xd3, 0x1e, 0x1b, 0x1d, 0x9a, 0x30, 0x3f, 0xe2, 0x83, 0xf0, 0xe4, 0xf4, + 0xde, 0x8d, 0xd3, 0xf5, 0xda, 0x38, 0x83, 0x20, 0x21, 0x65, 0xbf, 0x48, 0x90, 0xf8, 0xb3, 0x24, + 0x2c, 0xb5, 0xa9, 0x79, 0xc1, 0x0f, 0x25, 0xc8, 0x1d, 0x50, 0xcf, 0x8f, 0x04, 0xc4, 0xb0, 0x8d, + 0x9e, 0x42, 0x6e, 0x24, 0xa7, 0x4f, 0xce, 0xfe, 0xed, 0x78, 0x93, 0x05, 0x06, 0x87, 0x68, 0xf4, + 0x11, 0xe4, 0x83, 0x2d, 0xc3, 0x46, 0xfb, 0x06, 0x0b, 0x67, 0x8a, 0x47, 0xdf, 0x82, 0xac, 0x98, + 0x84, 0xd5, 0x34, 0x97, 0xbc, 0xfb, 0x46, 0x3e, 0xc7, 0x52, 0x08, 0x6d, 0x42, 0xce, 0xb7, 0x3d, + 0xcd, 0x72, 0xf6, 0xe9, 0x6a, 0x86, 0x2b, 0x58, 0x8f, 0x0d, 0x32, 0xd4, 0x24, 0xfd, 0xed, 0x5e, + 0xcb, 0xd9, 0xa7, 0xb5, 0xc2, 0xf9, 0xd9, 0xfa, 0xbc, 0x6c, 0xe0, 0x79, 0xdf, 0xf6, 0xd8, 0x0f, + 0xf5, 0xf7, 0x13, 0x50, 0x88, 0xa0, 0xd0, 0x1d, 0x00, 0xdf, 0x1d, 0x7b, 0xbe, 0xe6, 0x52, 0xea, + 0x73, 0x67, 0x15, 0x71, 0x9e, 0x53, 0x30, 0xa5, 0x3e, 0xaa, 0xc0, 0x0d, 0x83, 0xb8, 0xbe, 0x66, + 0x79, 0xde, 0x98, 0xb8, 0x9a, 0x37, 0xde, 0xfb, 0x94, 0x18, 0x3e, 0x77, 0x5c, 0x11, 0x2f, 0x33, + 0x56, 0x8b, 0x73, 0x7a, 0x82, 0x81, 0x9e, 0xc0, 0xcd, 0x28, 0x7e, 0x34, 0xde, 0xb3, 0x2d, 0x43, + 0x63, 0x93, 0x99, 0xe2, 0x22, 0x37, 0xa6, 0x22, 0x5d, 0xce, 0x7b, 0x46, 0x26, 0xea, 0x8f, 0x13, + 0xa0, 0x60, 0x7d, 0xdf, 0xdf, 0x21, 0xc3, 0x3d, 0xe2, 0xf6, 0x7c, 0xdd, 0x1f, 0x7b, 0xe8, 0x26, + 0x64, 0x6d, 0xa2, 0x9b, 0xc4, 0xe5, 0x46, 0xe5, 0xb0, 0x6c, 0xa1, 0x5d, 0xb6, 0x83, 0x75, 0xe3, + 0x40, 0xdf, 0xb3, 0x6c, 0xcb, 0x9f, 0x70, 0x53, 0x16, 0xe3, 0x97, 0xf0, 0xac, 0xce, 0x0a, 0x8e, + 0x08, 0xe2, 0x0b, 0x6a, 0xd0, 0x2a, 0xcc, 0x0f, 0x89, 0xe7, 0xe9, 0x03, 0xc2, 0x2d, 0xcd, 0xe3, + 0xa0, 0xa9, 0x7e, 0x04, 0xc5, 0xa8, 0x1c, 0x2a, 0xc0, 0xfc, 0x6e, 0xfb, 0x59, 0xbb, 0xf3, 0xa2, + 0xad, 0xcc, 0xa1, 0x25, 0x28, 0xec, 0xb6, 0x71, 0xb3, 0x5a, 0xdf, 0xaa, 0xd6, 0xb6, 0x9b, 0x4a, + 0x02, 0x2d, 0x40, 0x7e, 0xda, 0x4c, 0xaa, 0x7f, 0x91, 0x00, 0x60, 0xee, 0x96, 0x83, 0xfa, 0x10, + 0x32, 0x9e, 0xaf, 0xfb, 0x62, 0x55, 0x2e, 0x3e, 0x7e, 0xf7, 0xb2, 0x39, 0x94, 0xf6, 0xb2, 0x7f, + 0x04, 0x0b, 0x91, 0xa8, 0x85, 0xc9, 0x0b, 0x16, 0xb2, 0x00, 0xa1, 0x9b, 0xa6, 0x2b, 0x0d, 0xe7, + 0xbf, 0xd5, 0x8f, 0x20, 0xc3, 0xa5, 0x2f, 0x9a, 0x9b, 0x83, 0x74, 0x83, 0xfd, 0x4a, 0xa0, 0x3c, + 0x64, 0x70, 0xb3, 0xda, 0xf8, 0x9e, 0x92, 0x44, 0x0a, 0x14, 0x1b, 0xad, 0x5e, 0xbd, 0xd3, 0x6e, + 0x37, 0xeb, 0xfd, 0x66, 0x43, 0x49, 0xa9, 0x77, 0x21, 0xd3, 0x1a, 0x32, 0xcd, 0xb7, 0xd9, 0x92, + 0xdf, 0x27, 0x2e, 0x71, 0x8c, 0x60, 0x27, 0x4d, 0x09, 0xea, 0x4f, 0x0b, 0x90, 0xd9, 0xa1, 0x63, + 0xc7, 0x47, 0x8f, 0x23, 0x61, 0x6b, 0x31, 0x3e, 0x43, 0xe0, 0xc0, 0x4a, 0x7f, 0x32, 0x22, 0x32, + 0xac, 0xdd, 0x84, 0xac, 0xd8, 0x1c, 0x72, 0x38, 0xb2, 0xc5, 0xe8, 0xbe, 0xee, 0x0e, 0x88, 0x2f, + 0xc7, 0x23, 0x5b, 0xe8, 0x7d, 0x76, 0x62, 0xe9, 0x26, 0x75, 0xec, 0x09, 0xdf, 0x43, 0x39, 0x71, + 0x2c, 0x61, 0xa2, 0x9b, 0x1d, 0xc7, 0x9e, 0xe0, 0x90, 0x8b, 0xb6, 0xa0, 0xb8, 0x67, 0x39, 0xa6, + 0x46, 0x47, 0x22, 0xc8, 0x67, 0x2e, 0xdf, 0x71, 0xc2, 0xaa, 0x9a, 0xe5, 0x98, 0x1d, 0x01, 0xc6, + 0x85, 0xbd, 0x69, 0x03, 0xb5, 0x61, 0xf1, 0x88, 0xda, 0xe3, 0x21, 0x09, 0x75, 0x65, 0xb9, 0xae, + 0xf7, 0x2e, 0xd7, 0xf5, 0x9c, 0xe3, 0x03, 0x6d, 0x0b, 0x47, 0xd1, 0x26, 0x7a, 0x06, 0x0b, 0xfe, + 0x70, 0xb4, 0xef, 0x85, 0xea, 0xe6, 0xb9, 0xba, 0xaf, 0x5c, 0xe1, 0x30, 0x06, 0x0f, 0xb4, 0x15, + 0xfd, 0x48, 0x0b, 0x6d, 0x42, 0xc1, 0xa0, 0x8e, 0x67, 0x79, 0x3e, 0x71, 0x8c, 0xc9, 0x6a, 0x8e, + 0xfb, 0xfe, 0x8a, 0x51, 0xd6, 0xa7, 0x60, 0x1c, 0x95, 0x2c, 0xfd, 0x56, 0x0a, 0x0a, 0x11, 0x17, + 0xa0, 0x1e, 0x14, 0x46, 0x2e, 0x1d, 0xe9, 0x03, 0x7e, 0xe2, 0xc9, 0x49, 0x7d, 0xf4, 0x46, 0xee, + 0xab, 0x74, 0xa7, 0x82, 0x38, 0xaa, 0x45, 0x3d, 0x4d, 0x42, 0x21, 0xc2, 0x44, 0xf7, 0x20, 0x87, + 0xbb, 0xb8, 0xf5, 0xbc, 0xda, 0x6f, 0x2a, 0x73, 0xa5, 0xdb, 0x27, 0xa7, 0xe5, 0x55, 0xae, 0x2d, + 0xaa, 0xa0, 0xeb, 0x5a, 0x47, 0x6c, 0x0d, 0xbf, 0x0f, 0xf3, 0x01, 0x34, 0x51, 0xfa, 0xf2, 0xc9, + 0x69, 0xf9, 0xad, 0x59, 0x68, 0x04, 0x89, 0x7b, 0x5b, 0x55, 0xdc, 0x6c, 0x28, 0xc9, 0x78, 0x24, + 0xee, 0x1d, 0xe8, 0x2e, 0x31, 0xd1, 0x57, 0x20, 0x2b, 0x81, 0xa9, 0x52, 0xe9, 0xe4, 0xb4, 0x7c, + 0x73, 0x16, 0x38, 0xc5, 0xe1, 0xde, 0x76, 0xf5, 0x79, 0x53, 0x49, 0xc7, 0xe3, 0x70, 0xcf, 0xd6, + 0x8f, 0x08, 0x7a, 0x17, 0x32, 0x02, 0x96, 0x29, 0xdd, 0x3a, 0x39, 0x2d, 0x7f, 0xe9, 0x35, 0x75, + 0x0c, 0x55, 0x5a, 0xfd, 0xdd, 0x3f, 0x5e, 0x9b, 0xfb, 0x9b, 0x3f, 0x59, 0x53, 0x66, 0xd9, 0xa5, + 0xff, 0x49, 0xc0, 0xc2, 0x85, 0xb5, 0x83, 0x54, 0xc8, 0x3a, 0xd4, 0xa0, 0x23, 0x71, 0x10, 0xe6, + 0x6a, 0x70, 0x7e, 0xb6, 0x9e, 0x6d, 0xd3, 0x3a, 0x1d, 0x4d, 0xb0, 0xe4, 0xa0, 0x67, 0x33, 0x47, + 0xf9, 0x93, 0x37, 0x5c, 0x98, 0xb1, 0x87, 0xf9, 0xc7, 0xb0, 0x60, 0xba, 0xd6, 0x11, 0x71, 0x35, + 0x83, 0x3a, 0xfb, 0xd6, 0x40, 0x1e, 0x72, 0xa5, 0xd8, 0x7c, 0x93, 0x03, 0x71, 0x51, 0x08, 0xd4, + 0x39, 0xfe, 0x0b, 0x1c, 0xe3, 0xa5, 0xe7, 0x50, 0x8c, 0x2e, 0x75, 0x76, 0x2e, 0x79, 0xd6, 0xaf, + 0x11, 0x99, 0x58, 0xf2, 0x34, 0x14, 0xe7, 0x19, 0x45, 0xa4, 0x95, 0xef, 0x41, 0x7a, 0x48, 0x4d, + 0xa1, 0x67, 0xa1, 0x76, 0x83, 0x65, 0x13, 0xff, 0x72, 0xb6, 0x5e, 0xa0, 0x5e, 0x65, 0xc3, 0xb2, + 0xc9, 0x0e, 0x35, 0x09, 0xe6, 0x00, 0xf5, 0x08, 0xd2, 0x2c, 0xe6, 0xa0, 0x2f, 0x43, 0xba, 0xd6, + 0x6a, 0x37, 0x94, 0xb9, 0xd2, 0xf2, 0xc9, 0x69, 0x79, 0x81, 0xbb, 0x84, 0x31, 0xd8, 0xda, 0x45, + 0xeb, 0x90, 0x7d, 0xde, 0xd9, 0xde, 0xdd, 0x61, 0xcb, 0xeb, 0xc6, 0xc9, 0x69, 0x79, 0x29, 0x64, + 0x0b, 0xa7, 0xa1, 0x3b, 0x90, 0xe9, 0xef, 0x74, 0x37, 0x7a, 0x4a, 0xb2, 0x84, 0x4e, 0x4e, 0xcb, + 0x8b, 0x21, 0x9f, 0xdb, 0x5c, 0x5a, 0x96, 0xb3, 0x9a, 0x0f, 0xe9, 0xea, 0x8f, 0x12, 0x50, 0x88, + 0x6c, 0x38, 0xb6, 0x30, 0x1b, 0xcd, 0x8d, 0xea, 0xee, 0x76, 0x5f, 0x99, 0x8b, 0x2c, 0xcc, 0x08, + 0xa4, 0x41, 0xf6, 0xf5, 0xb1, 0xcd, 0xe2, 0x1c, 0xd4, 0x3b, 0xed, 0x5e, 0xab, 0xd7, 0x6f, 0xb6, + 0xfb, 0x4a, 0xa2, 0xb4, 0x7a, 0x72, 0x5a, 0x5e, 0x99, 0x05, 0x6f, 0x8c, 0x6d, 0x9b, 0x2d, 0xcd, + 0x7a, 0xb5, 0xbe, 0xc5, 0xd7, 0xfa, 0x74, 0x69, 0x46, 0x50, 0x75, 0xdd, 0x38, 0x20, 0x26, 0xba, + 0x0f, 0xf9, 0x46, 0x73, 0xbb, 0xb9, 0x59, 0xe5, 0xd1, 0xbd, 0x74, 0xe7, 0xe4, 0xb4, 0x7c, 0xeb, + 0xf5, 0xde, 0x6d, 0x32, 0xd0, 0x7d, 0x62, 0xce, 0x2c, 0xd1, 0x08, 0x44, 0xfd, 0x59, 0x12, 0x16, + 0x30, 0x2b, 0x87, 0x5d, 0xbf, 0x4b, 0x6d, 0xcb, 0x98, 0xa0, 0x2e, 0xe4, 0x0d, 0xea, 0x98, 0x56, + 0x24, 0x4e, 0x3c, 0xbe, 0x24, 0x25, 0x9a, 0x4a, 0x05, 0xad, 0x7a, 0x20, 0x89, 0xa7, 0x4a, 0xd0, + 0x03, 0xc8, 0x98, 0xc4, 0xd6, 0x27, 0x32, 0x37, 0xbb, 0x55, 0x11, 0x05, 0x77, 0x25, 0x28, 0xb8, + 0x2b, 0x0d, 0x59, 0x70, 0x63, 0x81, 0xe3, 0x35, 0x88, 0xfe, 0x52, 0xd3, 0x7d, 0x9f, 0x0c, 0x47, + 0xbe, 0x48, 0xcc, 0xd2, 0xb8, 0x30, 0xd4, 0x5f, 0x56, 0x25, 0x09, 0x3d, 0x82, 0xec, 0xb1, 0xe5, + 0x98, 0xf4, 0x58, 0xe6, 0x5e, 0x57, 0x28, 0x95, 0x40, 0xf5, 0x84, 0xa5, 0x24, 0x33, 0x66, 0xb2, + 0x35, 0xd4, 0xee, 0xb4, 0x9b, 0xc1, 0x1a, 0x92, 0xfc, 0x8e, 0xd3, 0xa6, 0x0e, 0xdb, 0xff, 0xd0, + 0x69, 0x6b, 0x1b, 0xd5, 0xd6, 0xf6, 0x2e, 0x66, 0xeb, 0x68, 0xe5, 0xe4, 0xb4, 0xac, 0x84, 0x90, + 0x0d, 0xdd, 0xb2, 0x59, 0x31, 0x70, 0x0b, 0x52, 0xd5, 0xf6, 0xf7, 0x94, 0x64, 0x49, 0x39, 0x39, + 0x2d, 0x17, 0x43, 0x76, 0xd5, 0x99, 0x4c, 0xfd, 0x3e, 0xdb, 0xaf, 0xfa, 0xf7, 0x29, 0x28, 0xee, + 0x8e, 0x4c, 0xdd, 0x27, 0x62, 0x9f, 0xa1, 0x32, 0x14, 0x46, 0xba, 0xab, 0xdb, 0x36, 0xb1, 0x2d, + 0x6f, 0x28, 0xaf, 0x12, 0xa2, 0x24, 0xf4, 0xc1, 0x9b, 0xba, 0xb1, 0x96, 0x63, 0x7b, 0xe7, 0x07, + 0xff, 0xb6, 0x9e, 0x08, 0x1c, 0xba, 0x0b, 0x8b, 0xfb, 0xc2, 0x5a, 0x4d, 0x37, 0xf8, 0xc4, 0xa6, + 0xf8, 0xc4, 0x56, 0xe2, 0x26, 0x36, 0x6a, 0x56, 0x45, 0x0e, 0xb2, 0xca, 0xa5, 0xf0, 0xc2, 0x7e, + 0xb4, 0x89, 0x9e, 0xc0, 0xfc, 0x90, 0x3a, 0x96, 0x4f, 0xdd, 0xeb, 0x67, 0x21, 0x40, 0xa2, 0x7b, + 0xb0, 0xcc, 0x26, 0x37, 0xb0, 0x87, 0xb3, 0xf9, 0x71, 0x9e, 0xc4, 0x4b, 0x43, 0xfd, 0xa5, 0xec, + 0x10, 0x33, 0x32, 0xaa, 0x41, 0x86, 0xba, 0x2c, 0x5f, 0xcc, 0x72, 0x73, 0xef, 0x5f, 0x6b, 0xae, + 0x68, 0x74, 0x98, 0x0c, 0x16, 0xa2, 0xea, 0x37, 0x61, 0xe1, 0xc2, 0x20, 0x58, 0x9a, 0xd4, 0xad, + 0xee, 0xf6, 0x9a, 0xca, 0x1c, 0x2a, 0x42, 0xae, 0xde, 0x69, 0xf7, 0x5b, 0xed, 0x5d, 0x96, 0xe7, + 0x15, 0x21, 0x87, 0x3b, 0xdb, 0xdb, 0xb5, 0x6a, 0xfd, 0x99, 0x92, 0x54, 0x2b, 0x50, 0x88, 0x68, + 0x43, 0x8b, 0x00, 0xbd, 0x7e, 0xa7, 0xab, 0x6d, 0xb4, 0x70, 0xaf, 0x2f, 0xb2, 0xc4, 0x5e, 0xbf, + 0x8a, 0xfb, 0x92, 0x90, 0x50, 0xff, 0x33, 0x19, 0xcc, 0xa8, 0x4c, 0x0c, 0x6b, 0x17, 0x13, 0xc3, + 0x2b, 0x8c, 0x97, 0xa9, 0xe1, 0xb4, 0x11, 0x26, 0x88, 0x1f, 0x00, 0xf0, 0x85, 0x43, 0x4c, 0x4d, + 0xf7, 0xe5, 0xc4, 0x97, 0x5e, 0x73, 0x72, 0x3f, 0xb8, 0xd1, 0xc2, 0x79, 0x89, 0xae, 0xfa, 0xe8, + 0x5b, 0x50, 0x34, 0xe8, 0x70, 0x64, 0x13, 0x29, 0x9c, 0xba, 0x56, 0xb8, 0x10, 0xe2, 0xab, 0x7e, + 0x34, 0x35, 0x4d, 0x5f, 0x4c, 0x9e, 0x7f, 0x3b, 0x11, 0x78, 0x26, 0x26, 0x1b, 0x2d, 0x42, 0x6e, + 0xb7, 0xdb, 0xa8, 0xf6, 0x5b, 0xed, 0x4d, 0x25, 0x81, 0x00, 0xb2, 0xdc, 0xd5, 0x0d, 0x25, 0xc9, + 0xb2, 0xe8, 0x7a, 0x67, 0xa7, 0xbb, 0xdd, 0xe4, 0x11, 0x0b, 0xad, 0x80, 0x12, 0x38, 0x5b, 0xe3, + 0x8e, 0x6c, 0x36, 0x94, 0x34, 0xba, 0x01, 0x4b, 0x21, 0x55, 0x4a, 0x66, 0xd0, 0x4d, 0x40, 0x21, + 0x71, 0xaa, 0x22, 0xab, 0xfe, 0x06, 0x2c, 0xd5, 0xa9, 0xe3, 0xeb, 0x96, 0x13, 0x56, 0x18, 0x8f, + 0xd9, 0xa0, 0x25, 0x49, 0xb3, 0xe4, 0x4d, 0x50, 0x6d, 0xe9, 0xfc, 0x6c, 0xbd, 0x10, 0x42, 0x5b, + 0x0d, 0x9e, 0x2a, 0xc9, 0x86, 0xc9, 0xf6, 0xef, 0xc8, 0x32, 0xb9, 0x73, 0x33, 0xb5, 0xf9, 0xf3, + 0xb3, 0xf5, 0x54, 0xb7, 0xd5, 0xc0, 0x8c, 0x86, 0xbe, 0x0c, 0x79, 0xf2, 0xd2, 0xf2, 0x35, 0x83, + 0x9d, 0x4b, 0xcc, 0x81, 0x19, 0x9c, 0x63, 0x84, 0x3a, 0x3b, 0x86, 0x6a, 0x00, 0x5d, 0xea, 0xfa, + 0xb2, 0xe7, 0xaf, 0x43, 0x66, 0x44, 0x5d, 0x7e, 0x77, 0x71, 0xe9, 0x8d, 0x1a, 0x83, 0x8b, 0x85, + 0x8a, 0x05, 0x58, 0xfd, 0x83, 0x14, 0x40, 0x5f, 0xf7, 0x0e, 0xa5, 0x92, 0xa7, 0x90, 0x0f, 0x6f, + 0x27, 0xe5, 0x25, 0xc8, 0x95, 0xb3, 0x1d, 0x82, 0xd1, 0x93, 0x60, 0xb1, 0x89, 0xda, 0x29, 0xb6, + 0x88, 0x0d, 0x3a, 0x8a, 0x2b, 0x3f, 0x2e, 0x16, 0x48, 0xec, 0x98, 0x27, 0xae, 0x2b, 0x67, 0x9e, + 0xfd, 0x44, 0x75, 0x7e, 0x2c, 0x08, 0xa7, 0xc9, 0xec, 0x3b, 0xf6, 0xda, 0x67, 0x66, 0x46, 0xb6, + 0xe6, 0xf0, 0x54, 0x0e, 0x7d, 0x0c, 0x05, 0x36, 0x6e, 0xcd, 0xe3, 0x3c, 0x99, 0x78, 0x5f, 0xea, + 0x2a, 0xa1, 0x01, 0xc3, 0x68, 0xea, 0xe5, 0x3b, 0x00, 0xfa, 0x68, 0x64, 0x5b, 0xc4, 0xd4, 0xf6, + 0x26, 0x3c, 0xd3, 0xce, 0xe3, 0xbc, 0xa4, 0xd4, 0x26, 0x6c, 0xbb, 0x04, 0x6c, 0xdd, 0xe7, 0xd9, + 0xf3, 0x35, 0x0e, 0x94, 0xe8, 0xaa, 0x5f, 0x53, 0x60, 0xd1, 0x1d, 0x3b, 0xcc, 0xa1, 0xd2, 0x3a, + 0xf5, 0xcf, 0x93, 0xf0, 0x56, 0x9b, 0xf8, 0xc7, 0xd4, 0x3d, 0xac, 0xfa, 0xbe, 0x6e, 0x1c, 0x0c, + 0x89, 0x23, 0xa7, 0x2f, 0x52, 0xd0, 0x24, 0x2e, 0x14, 0x34, 0xab, 0x30, 0xaf, 0xdb, 0x96, 0xee, + 0x11, 0x91, 0xbc, 0xe5, 0x71, 0xd0, 0x64, 0x65, 0x17, 0x2b, 0xe2, 0x88, 0xe7, 0x11, 0x71, 0xaf, + 0xc2, 0x0c, 0x0f, 0x08, 0xe8, 0xfb, 0x70, 0x53, 0xa6, 0x69, 0x7a, 0xd8, 0x15, 0x2b, 0x28, 0x82, + 0x0b, 0xda, 0x66, 0x6c, 0x55, 0x19, 0x6f, 0x9c, 0xcc, 0xe3, 0xa6, 0xe4, 0xce, 0xc8, 0x97, 0x59, + 0xe1, 0x8a, 0x19, 0xc3, 0x2a, 0x6d, 0xc2, 0xad, 0x4b, 0x45, 0x3e, 0xd7, 0xbd, 0xcd, 0x3f, 0x25, + 0x01, 0x5a, 0xdd, 0xea, 0x8e, 0x74, 0x52, 0x03, 0xb2, 0xfb, 0xfa, 0xd0, 0xb2, 0x27, 0x57, 0x45, + 0xc0, 0x29, 0xbe, 0x52, 0x15, 0xee, 0xd8, 0xe0, 0x32, 0x58, 0xca, 0xf2, 0x9a, 0x72, 0xbc, 0xe7, + 0x10, 0x3f, 0xac, 0x29, 0x79, 0x8b, 0x99, 0xe1, 0xea, 0x4e, 0xb8, 0x74, 0x45, 0x83, 0x4d, 0x00, + 0x4b, 0x79, 0x8e, 0xf5, 0x49, 0x10, 0xb6, 0x64, 0x13, 0x6d, 0xf1, 0xdb, 0x51, 0xe2, 0x1e, 0x11, + 0x73, 0x35, 0xc3, 0x9d, 0x7a, 0x9d, 0x3d, 0x58, 0xc2, 0x85, 0xef, 0x42, 0xe9, 0xd2, 0x47, 0x3c, + 0x65, 0x9a, 0xb2, 0x3e, 0x97, 0x8f, 0x1e, 0xc2, 0xc2, 0x85, 0x71, 0xbe, 0x56, 0xcc, 0xb7, 0xba, + 0xcf, 0xbf, 0xae, 0xa4, 0xe5, 0xaf, 0x6f, 0x2a, 0x59, 0xf5, 0x4f, 0x53, 0x22, 0xd0, 0x48, 0xaf, + 0xc6, 0xbf, 0x0a, 0xe4, 0xf8, 0xea, 0x36, 0xa8, 0x2d, 0x03, 0xc0, 0x7b, 0x57, 0xc7, 0x1f, 0x56, + 0xd3, 0x71, 0x38, 0x0e, 0x05, 0xd1, 0x3a, 0x14, 0xc4, 0x2a, 0xd6, 0xd8, 0x86, 0xe3, 0x6e, 0x5d, + 0xc0, 0x20, 0x48, 0x4c, 0x12, 0xdd, 0x85, 0x45, 0x7e, 0xf9, 0xe3, 0x1d, 0x10, 0x53, 0x60, 0xd2, + 0x1c, 0xb3, 0x10, 0x52, 0x39, 0x6c, 0x07, 0x8a, 0x92, 0xa0, 0xf1, 0x7c, 0x3e, 0xc3, 0x0d, 0xba, + 0x77, 0x9d, 0x41, 0x42, 0x84, 0xa7, 0xf9, 0x85, 0xd1, 0xb4, 0xa1, 0x36, 0x20, 0x17, 0x18, 0x8b, + 0x56, 0x21, 0xd5, 0xaf, 0x77, 0x95, 0xb9, 0xd2, 0xd2, 0xc9, 0x69, 0xb9, 0x10, 0x90, 0xfb, 0xf5, + 0x2e, 0xe3, 0xec, 0x36, 0xba, 0x4a, 0xe2, 0x22, 0x67, 0xb7, 0xd1, 0x2d, 0xa5, 0x59, 0x0e, 0xa6, + 0xee, 0x43, 0x21, 0xd2, 0x03, 0x7a, 0x07, 0xe6, 0x5b, 0xed, 0x4d, 0xdc, 0xec, 0xf5, 0x94, 0xb9, + 0xd2, 0xcd, 0x93, 0xd3, 0x32, 0x8a, 0x70, 0x5b, 0xce, 0x80, 0xcd, 0x0f, 0xba, 0x03, 0xe9, 0xad, + 0x0e, 0x3b, 0xdb, 0x45, 0x01, 0x11, 0x41, 0x6c, 0x51, 0xcf, 0x2f, 0xdd, 0x90, 0xc9, 0x5d, 0x54, + 0xb1, 0xfa, 0x87, 0x09, 0xc8, 0x8a, 0xcd, 0x14, 0x3b, 0x51, 0x55, 0x98, 0x0f, 0xae, 0x09, 0x44, + 0x71, 0xf7, 0xde, 0xe5, 0x85, 0x58, 0x45, 0xd6, 0x4d, 0x62, 0xf9, 0x05, 0x72, 0xa5, 0x0f, 0xa1, + 0x18, 0x65, 0x7c, 0xae, 0xc5, 0xf7, 0x7d, 0x28, 0xb0, 0xf5, 0x1d, 0x14, 0x64, 0x8f, 0x21, 0x2b, + 0x02, 0x42, 0x78, 0xd6, 0x5c, 0x5e, 0x15, 0x4a, 0x24, 0x7a, 0x0a, 0xf3, 0xa2, 0x92, 0x0c, 0x6e, + 0x87, 0xd7, 0xae, 0xde, 0x45, 0x38, 0x80, 0xab, 0x1f, 0x43, 0xba, 0x4b, 0x88, 0xcb, 0x7c, 0xef, + 0x50, 0x93, 0x4c, 0x8f, 0x67, 0x59, 0x04, 0x9b, 0xa4, 0xd5, 0x60, 0x45, 0xb0, 0x49, 0x5a, 0x66, + 0x78, 0xff, 0x95, 0x8c, 0xdc, 0x7f, 0xf5, 0xa1, 0xf8, 0x82, 0x58, 0x83, 0x03, 0x9f, 0x98, 0x5c, + 0xd1, 0x7d, 0x48, 0x8f, 0x48, 0x68, 0xfc, 0x6a, 0xec, 0x02, 0x23, 0xc4, 0xc5, 0x1c, 0xc5, 0xe2, + 0xc8, 0x31, 0x97, 0x96, 0x4f, 0x1a, 0xb2, 0xa5, 0xfe, 0x63, 0x12, 0x16, 0x5b, 0x9e, 0x37, 0xd6, + 0x1d, 0x23, 0xc8, 0xdc, 0xbe, 0x7d, 0x31, 0x73, 0x8b, 0x7d, 0xfb, 0xb9, 0x28, 0x72, 0xf1, 0x5a, + 0x4f, 0x9e, 0x9e, 0xc9, 0xf0, 0xf4, 0x54, 0x7f, 0x9a, 0x08, 0xee, 0xee, 0xee, 0x46, 0xb6, 0xbb, + 0xa8, 0x03, 0xa3, 0x9a, 0xc8, 0xae, 0x73, 0xe8, 0xd0, 0x63, 0x07, 0xbd, 0x0d, 0x19, 0xdc, 0x6c, + 0x37, 0x5f, 0x28, 0x09, 0xb1, 0x3c, 0x2f, 0x80, 0x30, 0x71, 0xc8, 0x31, 0xd3, 0xd4, 0x6d, 0xb6, + 0x1b, 0x2c, 0xd3, 0x4a, 0xc6, 0x68, 0xea, 0x12, 0xc7, 0xb4, 0x9c, 0x01, 0x7a, 0x07, 0xb2, 0xad, + 0x5e, 0x6f, 0x97, 0x97, 0x89, 0x6f, 0x9d, 0x9c, 0x96, 0x6f, 0x5c, 0x40, 0xf1, 0x7b, 0x5b, 0x93, + 0x81, 0x58, 0x99, 0xc3, 0x72, 0xb0, 0x18, 0x10, 0xcb, 0x9f, 0x05, 0x08, 0x77, 0xfa, 0xd5, 0x7e, + 0x53, 0xc9, 0xc4, 0x80, 0x30, 0x65, 0x7f, 0xe5, 0x76, 0xfb, 0xd7, 0x24, 0x28, 0x55, 0xc3, 0x20, + 0x23, 0x9f, 0xf1, 0x65, 0x65, 0xd9, 0x87, 0xdc, 0x88, 0xfd, 0xb2, 0x48, 0x90, 0x25, 0x3d, 0x8d, + 0x7d, 0xbd, 0x9c, 0x91, 0xab, 0x60, 0x6a, 0x93, 0xaa, 0x39, 0xb4, 0x3c, 0xcf, 0xa2, 0x8e, 0xa0, + 0xe1, 0x50, 0x53, 0xe9, 0xbf, 0x12, 0x70, 0x23, 0x06, 0x81, 0x1e, 0x42, 0xda, 0xa5, 0x76, 0x30, + 0x87, 0xb7, 0x2f, 0xbb, 0x96, 0x65, 0xa2, 0x98, 0x23, 0xd1, 0x1a, 0x80, 0x3e, 0xf6, 0xa9, 0xce, + 0xfb, 0xe7, 0xb3, 0x97, 0xc3, 0x11, 0x0a, 0x7a, 0x01, 0x59, 0x8f, 0x18, 0x2e, 0x09, 0x72, 0xe9, + 0x8f, 0xff, 0xbf, 0xd6, 0x57, 0x7a, 0x5c, 0x0d, 0x96, 0xea, 0x4a, 0x15, 0xc8, 0x0a, 0x0a, 0x5b, + 0xf6, 0xa6, 0xee, 0xeb, 0xf2, 0xd2, 0x9e, 0xff, 0x66, 0xab, 0x49, 0xb7, 0x07, 0xc1, 0x6a, 0xd2, + 0xed, 0x81, 0xfa, 0x77, 0x49, 0x80, 0xe6, 0x4b, 0x9f, 0xb8, 0x8e, 0x6e, 0xd7, 0xab, 0xa8, 0x19, + 0x89, 0xfe, 0x62, 0xb4, 0x5f, 0x8d, 0x7d, 0x89, 0x08, 0x25, 0x2a, 0xf5, 0x6a, 0x4c, 0xfc, 0xbf, + 0x05, 0xa9, 0xb1, 0x2b, 0x1f, 0xa4, 0x45, 0x1e, 0xbc, 0x8b, 0xb7, 0x31, 0xa3, 0xa1, 0xe6, 0x34, + 0x6c, 0xa5, 0x2e, 0x7f, 0x76, 0x8e, 0x74, 0x10, 0x1b, 0xba, 0xd8, 0xce, 0x37, 0x74, 0xcd, 0x20, + 0xf2, 0xe4, 0x28, 0x8a, 0x9d, 0x5f, 0xaf, 0xd6, 0x89, 0xeb, 0xe3, 0xac, 0xa1, 0xb3, 0xff, 0x5f, + 0x28, 0xbe, 0xdd, 0x07, 0x98, 0x0e, 0x0d, 0xad, 0x41, 0xa6, 0xbe, 0xd1, 0xeb, 0x6d, 0x2b, 0x73, + 0x22, 0x80, 0x4f, 0x59, 0x9c, 0xac, 0xfe, 0x75, 0x12, 0x72, 0xf5, 0xaa, 0x3c, 0x56, 0xeb, 0xa0, + 0xf0, 0xa8, 0xc4, 0x9f, 0x3a, 0xc8, 0xcb, 0x91, 0xe5, 0x4e, 0x64, 0x60, 0xb9, 0xa2, 0xa8, 0x5d, + 0x64, 0x22, 0xcc, 0xea, 0x26, 0x17, 0x40, 0x18, 0x8a, 0x44, 0x3a, 0x41, 0x33, 0xf4, 0x20, 0xc6, + 0xaf, 0x5d, 0xed, 0x2c, 0x51, 0x9e, 0x4c, 0xdb, 0x1e, 0x2e, 0x04, 0x4a, 0xea, 0xba, 0x87, 0x3e, + 0x80, 0x25, 0xcf, 0x1a, 0x38, 0x96, 0x33, 0xd0, 0x02, 0xe7, 0xf1, 0x77, 0x97, 0xda, 0xf2, 0xf9, + 0xd9, 0xfa, 0x42, 0x4f, 0xb0, 0xa4, 0x0f, 0x17, 0x24, 0xb2, 0xce, 0x5d, 0x89, 0xbe, 0x09, 0x8b, + 0x11, 0x51, 0xe6, 0x45, 0xe1, 0x76, 0xe5, 0xfc, 0x6c, 0xbd, 0x18, 0x4a, 0x3e, 0x23, 0x13, 0x5c, + 0x0c, 0x05, 0x9f, 0x11, 0x7e, 0xff, 0xb2, 0x4f, 0x5d, 0x83, 0x68, 0x2e, 0xdf, 0xd3, 0xfc, 0x04, + 0x4f, 0xe3, 0x02, 0xa7, 0x89, 0x6d, 0xae, 0x3e, 0x87, 0x1b, 0x1d, 0xd7, 0x38, 0x20, 0x9e, 0x2f, + 0x5c, 0x21, 0xbd, 0xf8, 0x31, 0xdc, 0xf6, 0x75, 0xef, 0x50, 0x3b, 0xb0, 0x3c, 0x9f, 0xba, 0x13, + 0xcd, 0x25, 0x3e, 0x71, 0x18, 0x5f, 0xe3, 0x8f, 0xb5, 0xf2, 0xd2, 0xef, 0x16, 0xc3, 0x6c, 0x09, + 0x08, 0x0e, 0x10, 0xdb, 0x0c, 0xa0, 0xb6, 0xa0, 0xc8, 0xca, 0x14, 0x79, 0x71, 0xc6, 0x46, 0x0f, + 0x36, 0x1d, 0x68, 0x6f, 0x7c, 0x4c, 0xe5, 0x6d, 0x3a, 0x10, 0x3f, 0xd5, 0xef, 0x82, 0xd2, 0xb0, + 0xbc, 0x91, 0xee, 0x1b, 0x07, 0xc1, 0x6d, 0x26, 0x6a, 0x80, 0x72, 0x40, 0x74, 0xd7, 0xdf, 0x23, + 0xba, 0xaf, 0x8d, 0x88, 0x6b, 0x51, 0xf3, 0xfa, 0x59, 0x5e, 0x0a, 0x45, 0xba, 0x5c, 0x42, 0xfd, + 0xef, 0x04, 0x00, 0xd6, 0xf7, 0x83, 0x8c, 0xec, 0x6b, 0xb0, 0xec, 0x39, 0xfa, 0xc8, 0x3b, 0xa0, + 0xbe, 0x66, 0x39, 0x3e, 0x71, 0x8f, 0x74, 0x5b, 0x5e, 0xe0, 0x28, 0x01, 0xa3, 0x25, 0xe9, 0xe8, + 0x3e, 0xa0, 0x43, 0x42, 0x46, 0x1a, 0xb5, 0x4d, 0x2d, 0x60, 0x8a, 0xa7, 0xe4, 0x34, 0x56, 0x18, + 0xa7, 0x63, 0x9b, 0xbd, 0x80, 0x8e, 0x6a, 0xb0, 0xc6, 0x86, 0x4f, 0x1c, 0xdf, 0xb5, 0x88, 0xa7, + 0xed, 0x53, 0x57, 0xf3, 0x6c, 0x7a, 0xac, 0xed, 0x53, 0xdb, 0xa6, 0xc7, 0xc4, 0x0d, 0xee, 0xc6, + 0x4a, 0x36, 0x1d, 0x34, 0x05, 0x68, 0x83, 0xba, 0x3d, 0x9b, 0x1e, 0x6f, 0x04, 0x08, 0x96, 0xb6, + 0x4d, 0xc7, 0xec, 0x5b, 0xc6, 0x61, 0x90, 0xb6, 0x85, 0xd4, 0xbe, 0x65, 0x1c, 0xa2, 0x77, 0x60, + 0x81, 0xd8, 0x84, 0x5f, 0x91, 0x08, 0x54, 0x86, 0xa3, 0x8a, 0x01, 0x91, 0x81, 0xd4, 0x4f, 0x40, + 0x69, 0x3a, 0x86, 0x3b, 0x19, 0x45, 0xe6, 0xfc, 0x3e, 0x20, 0x16, 0x24, 0x35, 0x9b, 0x1a, 0x87, + 0xda, 0x50, 0x77, 0xf4, 0x01, 0xb3, 0x4b, 0xbc, 0xf0, 0x29, 0x8c, 0xb3, 0x4d, 0x8d, 0xc3, 0x1d, + 0x49, 0x57, 0x3f, 0x00, 0xe8, 0x8d, 0x5c, 0xa2, 0x9b, 0x1d, 0x96, 0x4d, 0x30, 0xd7, 0xf1, 0x96, + 0x66, 0xca, 0x17, 0x52, 0xea, 0xca, 0xad, 0xae, 0x08, 0x46, 0x23, 0xa4, 0xab, 0xbf, 0x0c, 0x37, + 0xba, 0xb6, 0x6e, 0xf0, 0xaf, 0x05, 0xba, 0xe1, 0x93, 0x15, 0x7a, 0x0a, 0x59, 0x01, 0x95, 0x33, + 0x19, 0xbb, 0xdd, 0xa6, 0x7d, 0x6e, 0xcd, 0x61, 0x89, 0xaf, 0x15, 0x01, 0xa6, 0x7a, 0xd4, 0xbf, + 0x4c, 0x40, 0x3e, 0xd4, 0x8f, 0xca, 0xe2, 0x25, 0xc6, 0x77, 0x75, 0xcb, 0x91, 0x55, 0x7d, 0x1e, + 0x47, 0x49, 0xa8, 0x05, 0x85, 0x51, 0x28, 0x7d, 0x65, 0x3e, 0x17, 0x63, 0x35, 0x8e, 0xca, 0xa2, + 0x0f, 0x21, 0x1f, 0x3c, 0x49, 0x07, 0x11, 0xf6, 0xea, 0x17, 0xec, 0x29, 0x5c, 0xfd, 0x36, 0xc0, + 0x77, 0xa8, 0xe5, 0xf4, 0xe9, 0x21, 0x71, 0xf8, 0x13, 0x2b, 0xab, 0x09, 0x49, 0xe0, 0x45, 0xd9, + 0xe2, 0xa5, 0xbe, 0x98, 0x82, 0xf0, 0xa5, 0x51, 0x34, 0xd5, 0xbf, 0x4d, 0x42, 0x16, 0x53, 0xea, + 0xd7, 0xab, 0xa8, 0x0c, 0x59, 0x19, 0x27, 0xf8, 0xf9, 0x53, 0xcb, 0x9f, 0x9f, 0xad, 0x67, 0x44, + 0x80, 0xc8, 0x18, 0x3c, 0x32, 0x44, 0x22, 0x78, 0xf2, 0xb2, 0x08, 0x8e, 0x1e, 0x42, 0x51, 0x82, + 0xb4, 0x03, 0xdd, 0x3b, 0x10, 0x05, 0x5a, 0x6d, 0xf1, 0xfc, 0x6c, 0x1d, 0x04, 0x72, 0x4b, 0xf7, + 0x0e, 0x30, 0x08, 0x34, 0xfb, 0x8d, 0x9a, 0x50, 0xf8, 0x94, 0x5a, 0x8e, 0xe6, 0xf3, 0x41, 0xc8, + 0xcb, 0xc4, 0xd8, 0x79, 0x9c, 0x0e, 0x55, 0x7e, 0x6f, 0x00, 0x9f, 0x4e, 0x07, 0xdf, 0x84, 0x05, + 0x97, 0x52, 0x5f, 0x84, 0x2d, 0x8b, 0x3a, 0xf2, 0x9e, 0xa2, 0x1c, 0x7b, 0x7d, 0x4d, 0xa9, 0x8f, + 0x25, 0x0e, 0x17, 0xdd, 0x48, 0x0b, 0x3d, 0x84, 0x15, 0x5b, 0xf7, 0x7c, 0x8d, 0xc7, 0x3b, 0x73, + 0xaa, 0x2d, 0xcb, 0xb7, 0x1a, 0x62, 0xbc, 0x0d, 0xce, 0x0a, 0x24, 0xd4, 0x7f, 0x4e, 0x40, 0x81, + 0x0d, 0xc6, 0xda, 0xb7, 0x0c, 0x96, 0xe4, 0x7d, 0xfe, 0xdc, 0xe3, 0x16, 0xa4, 0x0c, 0xcf, 0x95, + 0x4e, 0xe5, 0x87, 0x6f, 0xbd, 0x87, 0x31, 0xa3, 0xa1, 0x4f, 0x20, 0x2b, 0xef, 0x4b, 0x44, 0xda, + 0xa1, 0x5e, 0x9f, 0x8e, 0x4a, 0xdf, 0x48, 0x39, 0xbe, 0x96, 0xa7, 0xd6, 0x89, 0x43, 0x00, 0x47, + 0x49, 0xe8, 0x26, 0x24, 0x0d, 0xe1, 0x2e, 0xf9, 0x41, 0x4b, 0xbd, 0x8d, 0x93, 0x86, 0xa3, 0xfe, + 0x28, 0x01, 0x0b, 0xd3, 0x0d, 0xcf, 0x56, 0xc0, 0x6d, 0xc8, 0x7b, 0xe3, 0x3d, 0x6f, 0xe2, 0xf9, + 0x64, 0x18, 0x3c, 0x1f, 0x87, 0x04, 0xd4, 0x82, 0xbc, 0x6e, 0x0f, 0xa8, 0x6b, 0xf9, 0x07, 0x43, + 0x59, 0x89, 0xc6, 0xa7, 0x0a, 0x51, 0x9d, 0x95, 0x6a, 0x20, 0x82, 0xa7, 0xd2, 0xc1, 0xb9, 0x2f, + 0xbe, 0x31, 0xe0, 0xe7, 0xfe, 0xdb, 0x50, 0xb4, 0xf5, 0x21, 0xbf, 0x40, 0xf2, 0xad, 0xa1, 0x18, + 0x47, 0x1a, 0x17, 0x24, 0xad, 0x6f, 0x0d, 0x89, 0xaa, 0x42, 0x3e, 0x54, 0x86, 0x96, 0xa0, 0x50, + 0x6d, 0xf6, 0xb4, 0x47, 0x8f, 0x9f, 0x6a, 0x9b, 0xf5, 0x1d, 0x65, 0x4e, 0xe6, 0xa6, 0x7f, 0x95, + 0x80, 0x05, 0x19, 0x8e, 0x64, 0xbe, 0xff, 0x0e, 0xcc, 0xbb, 0xfa, 0xbe, 0x1f, 0x54, 0x24, 0x69, + 0xb1, 0xaa, 0x59, 0x84, 0x67, 0x15, 0x09, 0x63, 0xc5, 0x57, 0x24, 0x91, 0x0f, 0x1a, 0x52, 0x57, + 0x7e, 0xd0, 0x90, 0xfe, 0xb9, 0x7c, 0xd0, 0xa0, 0xfe, 0x26, 0xc0, 0x86, 0x65, 0x93, 0xbe, 0xb8, + 0x6b, 0x8a, 0xab, 0x2f, 0x59, 0x0e, 0x27, 0xef, 0x32, 0x83, 0x1c, 0xae, 0xd5, 0xc0, 0x8c, 0xc6, + 0x58, 0x03, 0xcb, 0x94, 0x9b, 0x91, 0xb3, 0x36, 0x19, 0x6b, 0x60, 0x99, 0xe1, 0xcb, 0x5b, 0xfa, + 0xba, 0x97, 0xb7, 0xd3, 0x04, 0x2c, 0xc9, 0xdc, 0x35, 0x0c, 0xbf, 0x5f, 0x85, 0xbc, 0x48, 0x63, + 0xa7, 0x05, 0x1d, 0x7f, 0xc4, 0x17, 0xb8, 0x56, 0x03, 0xe7, 0x04, 0xbb, 0x65, 0xa2, 0x75, 0x28, + 0x48, 0x68, 0xe4, 0xe3, 0x27, 0x10, 0xa4, 0x36, 0x33, 0xff, 0xeb, 0x90, 0xde, 0xb7, 0x6c, 0x22, + 0x17, 0x7a, 0x6c, 0x00, 0x98, 0x3a, 0x60, 0x6b, 0x0e, 0x73, 0x74, 0x2d, 0x17, 0x5c, 0xc6, 0x71, + 0xfb, 0x64, 0xd9, 0x19, 0xb5, 0x4f, 0x54, 0xa0, 0x33, 0xf6, 0x09, 0x1c, 0xb3, 0x4f, 0xb0, 0x85, + 0x7d, 0x12, 0x1a, 0xb5, 0x4f, 0x90, 0x7e, 0x2e, 0xf6, 0x6d, 0xc3, 0xcd, 0x9a, 0xad, 0x1b, 0x87, + 0xb6, 0xe5, 0xf9, 0xc4, 0x8c, 0x46, 0x8c, 0xc7, 0x90, 0xbd, 0x90, 0x74, 0x5e, 0x75, 0x6b, 0x29, + 0x91, 0xea, 0x7f, 0x24, 0xa0, 0xb8, 0x45, 0x74, 0xdb, 0x3f, 0x98, 0x5e, 0x0d, 0xf9, 0xc4, 0xf3, + 0xe5, 0x61, 0xc5, 0x7f, 0xa3, 0x6f, 0x40, 0x2e, 0xcc, 0x49, 0xae, 0x7d, 0x7f, 0x0b, 0xa1, 0xe8, + 0x09, 0xcc, 0xb3, 0x3d, 0x46, 0xc7, 0x41, 0xb1, 0x73, 0xd5, 0xd3, 0x8e, 0x44, 0xb2, 0x43, 0xc6, + 0x25, 0x3c, 0x09, 0xe1, 0x4b, 0x29, 0x83, 0x83, 0x26, 0xfa, 0x45, 0x28, 0xf2, 0x97, 0x89, 0x20, + 0xe7, 0xca, 0x5c, 0xa7, 0xb3, 0x20, 0x1e, 0x17, 0x45, 0xbe, 0xf5, 0xbf, 0x09, 0x58, 0xd9, 0xd1, + 0x27, 0x7b, 0x44, 0x86, 0x0d, 0x62, 0x62, 0x62, 0x50, 0xd7, 0x44, 0xdd, 0x68, 0xb8, 0xb9, 0xe2, + 0xad, 0x32, 0x4e, 0x38, 0x3e, 0xea, 0x04, 0x05, 0x58, 0x32, 0x52, 0x80, 0xad, 0x40, 0xc6, 0xa1, + 0x8e, 0x41, 0x64, 0x2c, 0x12, 0x0d, 0xd5, 0x8a, 0x86, 0x9a, 0x52, 0xf8, 0x8c, 0xc8, 0x1f, 0x01, + 0xdb, 0xd4, 0x0f, 0x7b, 0x43, 0x9f, 0x40, 0xa9, 0xd7, 0xac, 0xe3, 0x66, 0xbf, 0xd6, 0xf9, 0xae, + 0xd6, 0xab, 0x6e, 0xf7, 0xaa, 0x8f, 0x1f, 0x6a, 0xdd, 0xce, 0xf6, 0xf7, 0x1e, 0x3d, 0x79, 0xf8, + 0x0d, 0x25, 0x51, 0x2a, 0x9f, 0x9c, 0x96, 0x6f, 0xb7, 0xab, 0xf5, 0x6d, 0xb1, 0x63, 0xf6, 0xe8, + 0xcb, 0x9e, 0x6e, 0x7b, 0xfa, 0xe3, 0x87, 0x5d, 0x6a, 0x4f, 0x18, 0x86, 0x2d, 0xeb, 0x62, 0xf4, + 0xbc, 0x8a, 0x1e, 0xc3, 0x89, 0x4b, 0x8f, 0xe1, 0xe9, 0x69, 0x9e, 0xbc, 0xe4, 0x34, 0xdf, 0x80, + 0x15, 0xc3, 0xa5, 0x9e, 0xa7, 0xb1, 0xec, 0x9f, 0x98, 0x33, 0xf5, 0xc5, 0x97, 0xce, 0xcf, 0xd6, + 0x97, 0xeb, 0x8c, 0xdf, 0xe3, 0x6c, 0xa9, 0x7e, 0xd9, 0x88, 0x90, 0x78, 0x4f, 0xea, 0x1f, 0xa5, + 0x58, 0x22, 0x65, 0x1d, 0x59, 0x36, 0x19, 0x10, 0x0f, 0x3d, 0x87, 0x25, 0xc3, 0x25, 0x26, 0x4b, + 0xeb, 0x75, 0x3b, 0xfa, 0x11, 0xed, 0x2f, 0xc4, 0xe6, 0x34, 0xa1, 0x60, 0xa5, 0x1e, 0x4a, 0xf5, + 0x46, 0xc4, 0xc0, 0x8b, 0xc6, 0x85, 0x36, 0xfa, 0x14, 0x96, 0x3c, 0x62, 0x5b, 0xce, 0xf8, 0xa5, + 0x66, 0x50, 0xc7, 0x27, 0x2f, 0x83, 0x17, 0xb1, 0xeb, 0xf4, 0xf6, 0x9a, 0xdb, 0x4c, 0xaa, 0x2e, + 0x84, 0x6a, 0xe8, 0xfc, 0x6c, 0x7d, 0xf1, 0x22, 0x0d, 0x2f, 0x4a, 0xcd, 0xb2, 0x5d, 0x6a, 0xc3, + 0xe2, 0x45, 0x6b, 0xd0, 0x8a, 0xdc, 0xfb, 0x3c, 0x84, 0x04, 0x7b, 0x1b, 0xdd, 0x86, 0x9c, 0x4b, + 0x06, 0x96, 0xe7, 0xbb, 0xc2, 0xcd, 0x8c, 0x13, 0x52, 0xd8, 0xce, 0x17, 0x5f, 0x40, 0x95, 0x7e, + 0x1d, 0x66, 0x7a, 0x64, 0x9b, 0xc5, 0xb4, 0x3c, 0x7d, 0x4f, 0xaa, 0xcc, 0xe1, 0xa0, 0xc9, 0xd6, + 0xe0, 0xd8, 0x0b, 0x13, 0x35, 0xfe, 0x9b, 0xd1, 0x78, 0x46, 0x21, 0xbf, 0x07, 0xe3, 0x39, 0x43, + 0xf0, 0x61, 0x69, 0x3a, 0xf2, 0x61, 0xe9, 0x0a, 0x64, 0x6c, 0x72, 0x44, 0x6c, 0x71, 0x96, 0x63, + 0xd1, 0xb8, 0xf7, 0x10, 0x8a, 0xc1, 0x17, 0x8c, 0xfc, 0xcb, 0x89, 0x1c, 0xa4, 0xfb, 0xd5, 0xde, + 0x33, 0x65, 0x0e, 0x01, 0x64, 0xc5, 0xe2, 0x14, 0xaf, 0x75, 0xf5, 0x4e, 0x7b, 0xa3, 0xb5, 0xa9, + 0x24, 0xef, 0xfd, 0x2c, 0x05, 0xf9, 0xf0, 0xbd, 0x88, 0x9d, 0x1d, 0xed, 0xe6, 0x8b, 0x60, 0x75, + 0x87, 0xf4, 0x36, 0x39, 0x46, 0x6f, 0x4f, 0x6f, 0xa1, 0x3e, 0x11, 0x0f, 0xe4, 0x21, 0x3b, 0xb8, + 0x81, 0x7a, 0x17, 0x72, 0xd5, 0x5e, 0xaf, 0xb5, 0xd9, 0x6e, 0x36, 0x94, 0xcf, 0x12, 0xa5, 0x2f, + 0x9d, 0x9c, 0x96, 0x97, 0x43, 0x50, 0xd5, 0x13, 0x8b, 0x8f, 0xa3, 0xea, 0xf5, 0x66, 0xb7, 0xdf, + 0x6c, 0x28, 0xaf, 0x92, 0xb3, 0x28, 0x7e, 0xab, 0xc2, 0x3f, 0xdd, 0xc9, 0x77, 0x71, 0xb3, 0x5b, + 0xc5, 0xac, 0xc3, 0xcf, 0x92, 0xe2, 0x72, 0x6c, 0xda, 0xa3, 0x4b, 0x46, 0xba, 0xcb, 0xfa, 0x5c, + 0x0b, 0xbe, 0x85, 0x7b, 0x95, 0x12, 0x9f, 0x77, 0x4c, 0x1f, 0xbf, 0x88, 0x6e, 0x4e, 0x58, 0x6f, + 0xfc, 0xd5, 0x91, 0xab, 0x49, 0xcd, 0xf4, 0xd6, 0x63, 0xb1, 0x87, 0x69, 0x51, 0x61, 0x1e, 0xef, + 0xb6, 0xdb, 0x0c, 0xf4, 0x2a, 0x3d, 0x33, 0x3a, 0x3c, 0x76, 0x58, 0xc5, 0x8c, 0xee, 0x42, 0x2e, + 0x78, 0x94, 0x54, 0x3e, 0x4b, 0xcf, 0x18, 0x54, 0x0f, 0x5e, 0x54, 0x79, 0x87, 0x5b, 0xbb, 0x7d, + 0xfe, 0xa9, 0xde, 0xab, 0xcc, 0x6c, 0x87, 0x07, 0x63, 0xdf, 0xa4, 0xc7, 0x0e, 0xdb, 0xb3, 0xf2, + 0x1e, 0xee, 0xb3, 0x8c, 0xb8, 0xb4, 0x08, 0x31, 0xf2, 0x12, 0xee, 0x5d, 0xc8, 0xe1, 0xe6, 0x77, + 0xc4, 0x57, 0x7d, 0xaf, 0xb2, 0x33, 0x7a, 0x30, 0xf9, 0x94, 0x18, 0xb2, 0xb7, 0x0e, 0xee, 0x6e, + 0x55, 0xb9, 0xcb, 0x67, 0x51, 0x1d, 0x77, 0x74, 0xa0, 0x3b, 0xc4, 0x9c, 0x7e, 0xe3, 0x12, 0xb2, + 0xee, 0xfd, 0x0a, 0xe4, 0x82, 0xcc, 0x14, 0xad, 0x41, 0xf6, 0x45, 0x07, 0x3f, 0x6b, 0x62, 0x65, + 0x4e, 0xf8, 0x30, 0xe0, 0xbc, 0x10, 0x35, 0x45, 0x19, 0xe6, 0x77, 0xaa, 0xed, 0xea, 0x66, 0x13, + 0x07, 0x57, 0xe4, 0x01, 0x40, 0xa6, 0x57, 0x25, 0x45, 0x76, 0x10, 0xea, 0xac, 0xad, 0xfe, 0xf0, + 0x27, 0x6b, 0x73, 0x3f, 0xfe, 0xc9, 0xda, 0xdc, 0xab, 0xf3, 0xb5, 0xc4, 0x0f, 0xcf, 0xd7, 0x12, + 0xff, 0x70, 0xbe, 0x96, 0xf8, 0xf7, 0xf3, 0xb5, 0xc4, 0x5e, 0x96, 0x1f, 0x02, 0x4f, 0xfe, 0x2f, + 0x00, 0x00, 0xff, 0xff, 0x4b, 0xdb, 0xdc, 0xec, 0xf0, 0x31, 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/types.proto b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/types.proto index a9fb07a57..890b3cfc3 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/types.proto +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/types.proto @@ -57,6 +57,12 @@ message GenericResource { } } +enum ResourceType { + TASK = 0; + SECRET = 1; + CONFIG = 2; +} + message Resources { // Amount of CPUs (e.g. 2000000000 = 2 CPU cores) int64 nano_cpus = 1 [(gogoproto.customname) = "NanoCPUs"]; @@ -208,6 +214,18 @@ message Mount { // ReadOnly should be set to true if the mount should not be writable. bool readonly = 4 [(gogoproto.customname) = "ReadOnly"]; + // Consistency indicates the tolerable level of file system consistency + enum Consistency { + option (gogoproto.goproto_enum_prefix) = false; + option (gogoproto.enum_customname) = "MountConsistency"; + + DEFAULT = 0 [(gogoproto.enumvalue_customname) = "MountConsistencyDefault"]; + CONSISTENT = 1 [(gogoproto.enumvalue_customname) = "MountConsistencyFull"]; + CACHED = 2 [(gogoproto.enumvalue_customname) = "MountConsistencyCached"]; + DELEGATED = 3 [(gogoproto.enumvalue_customname) = "MountConsistencyDelegated"]; + } + Consistency consistency = 8; + // BindOptions specifies options that are specific to a bind mount. message BindOptions { enum Propagation { @@ -508,6 +526,15 @@ message TaskStatus { // HostPorts provides a list of ports allocated at the host // level. PortStatus port_status = 6; + + // AppliedBy gives the node ID of the manager that applied this task + // status update to the Task object. + string applied_by = 7; + + // AppliedAt gives a timestamp of when this status update was applied to + // the Task object. + // Note: can't use stdtime because this field is nullable. + google.protobuf.Timestamp applied_at = 8; } // NetworkAttachmentConfig specifies how a service should be attached to a particular network. diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/watch.pb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/watch.pb.go index db7e80f3b..58fa8917e 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/watch.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/watch.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. -// source: watch.proto +// source: github.com/docker/swarmkit/api/watch.proto // DO NOT EDIT! package api @@ -1442,7 +1442,7 @@ var _Watch_serviceDesc = grpc.ServiceDesc{ ServerStreams: true, }, }, - Metadata: "watch.proto", + Metadata: "github.com/docker/swarmkit/api/watch.proto", } func (m *Object) Marshal() (dAtA []byte, err error) { @@ -4519,81 +4519,83 @@ var ( ErrIntOverflowWatch = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("watch.proto", fileDescriptorWatch) } +func init() { proto.RegisterFile("github.com/docker/swarmkit/api/watch.proto", fileDescriptorWatch) } var fileDescriptorWatch = []byte{ - // 1155 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x96, 0xbb, 0x73, 0x1b, 0xd5, - 0x17, 0xc7, 0xb5, 0x8a, 0xbc, 0x92, 0x8e, 0xac, 0xc4, 0x73, 0xed, 0x24, 0xfb, 0xd3, 0x2f, 0x48, - 0x42, 0x0c, 0xe0, 0x21, 0x41, 0x01, 0x13, 0xc2, 0x00, 0x81, 0x19, 0x4b, 0x16, 0x23, 0x91, 0xb1, - 0xec, 0xb9, 0xb6, 0xe3, 0x52, 0xb3, 0xde, 0x3d, 0x56, 0x16, 0xed, 0x43, 0xdc, 0x5d, 0xc9, 0x71, - 0x47, 0x41, 0xc1, 0xa4, 0x67, 0x86, 0x26, 0x15, 0xd4, 0x34, 0x74, 0xf0, 0x0f, 0x64, 0xa8, 0x28, - 0xa1, 0xd1, 0x10, 0x95, 0x14, 0xfc, 0x05, 0x14, 0xcc, 0x7d, 0xac, 0x1f, 0xca, 0xca, 0x21, 0x95, - 0xee, 0xbd, 0xfb, 0xf9, 0x9e, 0x7b, 0xf6, 0xbc, 0x56, 0x50, 0x38, 0x32, 0x23, 0xeb, 0x61, 0x7d, - 0xc8, 0x82, 0x28, 0x20, 0xc4, 0x0e, 0xac, 0x01, 0xb2, 0x7a, 0x78, 0x64, 0x32, 0x6f, 0xe0, 0x44, - 0xf5, 0xf1, 0xbb, 0xa5, 0x42, 0x38, 0x44, 0x2b, 0x94, 0x40, 0xa9, 0x18, 0x1c, 0x7c, 0x81, 0x56, - 0x14, 0x6f, 0x0b, 0xd1, 0xf1, 0x10, 0xe3, 0xcd, 0x4a, 0x3f, 0xe8, 0x07, 0x62, 0x79, 0x9b, 0xaf, - 0xd4, 0xe9, 0xf2, 0xd0, 0x1d, 0xf5, 0x1d, 0xff, 0xb6, 0xfc, 0x91, 0x87, 0xb5, 0xaf, 0x33, 0xa0, - 0x6f, 0x09, 0x4b, 0xa4, 0x0e, 0x19, 0x3f, 0xb0, 0xd1, 0xd0, 0xaa, 0xda, 0x6a, 0x61, 0xcd, 0xa8, - 0x3f, 0xef, 0x41, 0xbd, 0x1b, 0xd8, 0xd8, 0x4e, 0x51, 0xc1, 0x91, 0x0f, 0x20, 0x1b, 0x22, 0x1b, - 0x3b, 0x16, 0x1a, 0x69, 0x21, 0xf9, 0x7f, 0x92, 0x64, 0x47, 0x22, 0xed, 0x14, 0x8d, 0x69, 0x2e, - 0xf4, 0x31, 0x3a, 0x0a, 0xd8, 0xc0, 0xb8, 0x34, 0x5f, 0xd8, 0x95, 0x08, 0x17, 0x2a, 0x9a, 0x7b, - 0x18, 0x99, 0xe1, 0xc0, 0xc8, 0xcc, 0xf7, 0x70, 0xd7, 0x0c, 0xb9, 0x44, 0x70, 0xfc, 0x22, 0xcb, - 0x1d, 0x85, 0x11, 0x32, 0x63, 0x61, 0xfe, 0x45, 0x4d, 0x89, 0xf0, 0x8b, 0x14, 0x4d, 0xee, 0x80, - 0x1e, 0xa2, 0xc5, 0x30, 0x32, 0x74, 0xa1, 0x2b, 0x25, 0xbf, 0x19, 0x27, 0xda, 0x29, 0xaa, 0x58, - 0xf2, 0x11, 0xe4, 0x18, 0x86, 0xc1, 0x88, 0x59, 0x68, 0x64, 0x85, 0xee, 0x46, 0x92, 0x8e, 0x2a, - 0xa6, 0x9d, 0xa2, 0x27, 0x3c, 0xf9, 0x04, 0xf2, 0xf8, 0x28, 0x42, 0x3f, 0x74, 0x02, 0xdf, 0xc8, - 0x09, 0xf1, 0x2b, 0x49, 0xe2, 0x56, 0x0c, 0xb5, 0x53, 0xf4, 0x54, 0xc1, 0x1d, 0xb6, 0x02, 0xff, - 0xd0, 0xe9, 0x1b, 0xf9, 0xf9, 0x0e, 0x37, 0x05, 0xc1, 0x1d, 0x96, 0x6c, 0x23, 0x17, 0xe7, 0xbe, - 0xb6, 0x0d, 0x8b, 0x3b, 0xe8, 0xa2, 0x15, 0x35, 0x8e, 0x77, 0xdc, 0x20, 0x22, 0xb7, 0x00, 0x54, - 0xb6, 0x7a, 0x8e, 0x2d, 0x2a, 0x22, 0xdf, 0x28, 0x4e, 0x27, 0x95, 0xbc, 0x4a, 0x67, 0x67, 0x83, - 0xe6, 0x15, 0xd0, 0xb1, 0x09, 0x81, 0x4c, 0xe8, 0x06, 0x91, 0x28, 0x83, 0x0c, 0x15, 0xeb, 0xda, - 0x36, 0x5c, 0x8e, 0x2d, 0x36, 0x47, 0x61, 0x14, 0x78, 0x9c, 0x1a, 0x38, 0xbe, 0xb2, 0x46, 0xc5, - 0x9a, 0xac, 0xc0, 0x82, 0xe3, 0xdb, 0xf8, 0x48, 0x48, 0xf3, 0x54, 0x6e, 0xf8, 0xe9, 0xd8, 0x74, - 0x47, 0x28, 0xca, 0x23, 0x4f, 0xe5, 0xa6, 0xf6, 0x97, 0x0e, 0xb9, 0xd8, 0x24, 0x31, 0x20, 0x7d, - 0xe2, 0x98, 0x3e, 0x9d, 0x54, 0xd2, 0x9d, 0x8d, 0x76, 0x8a, 0xa6, 0x1d, 0x9b, 0xdc, 0x84, 0xbc, - 0x63, 0xf7, 0x86, 0x0c, 0x0f, 0x1d, 0x65, 0xb6, 0xb1, 0x38, 0x9d, 0x54, 0x72, 0x9d, 0x8d, 0x6d, - 0x71, 0xc6, 0xc3, 0xee, 0xd8, 0x72, 0x4d, 0x56, 0x20, 0xe3, 0x9b, 0x9e, 0xba, 0x48, 0x54, 0xb6, - 0xe9, 0x21, 0x79, 0x15, 0x0a, 0xfc, 0x37, 0x36, 0x92, 0x51, 0x0f, 0x81, 0x1f, 0x2a, 0xe1, 0x3d, - 0xd0, 0x2d, 0xf1, 0x5a, 0xaa, 0xb2, 0x6a, 0xc9, 0x15, 0x72, 0x36, 0x00, 0x22, 0xf0, 0x32, 0x14, - 0x1d, 0x28, 0xca, 0x55, 0x7c, 0x85, 0xfe, 0x12, 0x46, 0x16, 0xa5, 0x54, 0x39, 0x52, 0x3f, 0x97, - 0xa9, 0x6c, 0x42, 0xa6, 0x78, 0xa5, 0x9c, 0xe6, 0xea, 0x75, 0xc8, 0xf2, 0xee, 0xe5, 0x70, 0x4e, - 0xc0, 0x30, 0x9d, 0x54, 0x74, 0xde, 0xd8, 0x82, 0xd4, 0xf9, 0xc3, 0x8e, 0x4d, 0xee, 0xaa, 0x94, - 0xca, 0x72, 0xaa, 0x5e, 0xe4, 0x18, 0x2f, 0x18, 0x1e, 0x3a, 0xce, 0x93, 0x0d, 0x28, 0xda, 0x18, - 0x3a, 0x0c, 0xed, 0x5e, 0x18, 0x99, 0x11, 0x1a, 0x50, 0xd5, 0x56, 0x2f, 0x27, 0xd7, 0x32, 0xef, - 0xd5, 0x1d, 0x0e, 0xf1, 0x97, 0x52, 0x2a, 0xb1, 0x27, 0x6b, 0x90, 0x61, 0x81, 0x8b, 0x46, 0x41, - 0x88, 0x6f, 0xcc, 0x1b, 0x45, 0x34, 0x70, 0xc5, 0x38, 0xe2, 0x2c, 0xe9, 0x00, 0x78, 0xe8, 0x1d, - 0x20, 0x0b, 0x1f, 0x3a, 0x43, 0x63, 0x51, 0x28, 0xdf, 0x9c, 0xa7, 0xdc, 0x19, 0xa2, 0x55, 0xdf, - 0x3c, 0xc1, 0x79, 0x72, 0x4f, 0xc5, 0x64, 0x13, 0xae, 0x32, 0x3c, 0x44, 0x86, 0xbe, 0x85, 0x76, - 0x4f, 0x4d, 0x1f, 0x1e, 0xb1, 0xa2, 0x88, 0xd8, 0xf5, 0xe9, 0xa4, 0xb2, 0x4c, 0x4f, 0x00, 0x35, - 0xa8, 0x44, 0xf8, 0x96, 0xd9, 0x73, 0xc7, 0x36, 0xf9, 0x1c, 0x56, 0xce, 0x98, 0x93, 0xc3, 0x82, - 0x5b, 0xbb, 0x2c, 0xac, 0x5d, 0x9b, 0x4e, 0x2a, 0xe4, 0xd4, 0x9a, 0x9c, 0x2a, 0xc2, 0x18, 0x61, - 0xb3, 0xa7, 0xbc, 0x61, 0x64, 0x13, 0x5d, 0x89, 0x0b, 0x56, 0xb4, 0xd1, 0xf9, 0x1b, 0x64, 0x77, - 0xf3, 0x1b, 0x96, 0x92, 0x6e, 0x90, 0x63, 0x60, 0xf6, 0x06, 0x75, 0x6a, 0x37, 0x32, 0x90, 0x6e, - 0x1c, 0xd7, 0xfe, 0x48, 0xc3, 0xe2, 0x3e, 0xff, 0x1e, 0x51, 0xfc, 0x72, 0x84, 0x61, 0x44, 0x5a, - 0x90, 0x45, 0x3f, 0x62, 0x0e, 0x86, 0x86, 0x56, 0xbd, 0xb4, 0x5a, 0x58, 0xbb, 0x99, 0x14, 0xdb, - 0xb3, 0x12, 0xb9, 0x69, 0xf9, 0x11, 0x3b, 0xa6, 0xb1, 0x96, 0xdc, 0x83, 0x02, 0xc3, 0x70, 0xe4, - 0x61, 0xef, 0x90, 0x05, 0xde, 0x45, 0x1f, 0x8e, 0x07, 0xc8, 0xf8, 0x68, 0xa3, 0x20, 0xf9, 0xcf, - 0x58, 0xe0, 0x91, 0x5b, 0x40, 0x1c, 0xdf, 0x72, 0x47, 0x36, 0xf6, 0x02, 0xd7, 0xee, 0xc9, 0x4f, - 0xa0, 0x68, 0xde, 0x1c, 0x5d, 0x52, 0x4f, 0xb6, 0x5c, 0x5b, 0x0e, 0xb5, 0xd2, 0xb7, 0x1a, 0xc0, - 0xa9, 0x0f, 0x89, 0xf3, 0xe7, 0x63, 0xd0, 0x4d, 0x2b, 0xe2, 0x33, 0x37, 0x2d, 0x0a, 0xe6, 0xb5, - 0xb9, 0x2f, 0xb5, 0x2e, 0xb0, 0xfb, 0x8e, 0x6f, 0x53, 0x25, 0x21, 0x77, 0x21, 0x7b, 0xe8, 0xb8, - 0x11, 0xb2, 0xd0, 0xb8, 0x24, 0x42, 0x72, 0xe3, 0xa2, 0x36, 0xa1, 0x31, 0x5c, 0xfb, 0x25, 0x8e, - 0xed, 0x26, 0x86, 0xa1, 0xd9, 0x47, 0xf2, 0x29, 0xe8, 0x38, 0x46, 0x3f, 0x8a, 0x43, 0xfb, 0xc6, - 0x5c, 0x2f, 0x94, 0xa2, 0xde, 0xe2, 0x38, 0x55, 0x2a, 0xf2, 0x3e, 0x64, 0xc7, 0x32, 0x5a, 0xff, - 0x25, 0xa0, 0x31, 0x5b, 0xfa, 0x49, 0x83, 0x05, 0x61, 0xe8, 0x4c, 0x18, 0xb4, 0x97, 0x0f, 0xc3, - 0x1a, 0xe8, 0x2a, 0x11, 0xe9, 0xf9, 0xdf, 0x1e, 0x99, 0x12, 0xaa, 0x48, 0xf2, 0x21, 0xc0, 0x4c, - 0x02, 0x2f, 0xd6, 0xe5, 0x83, 0x38, 0xab, 0x6f, 0xfd, 0xa3, 0xc1, 0x95, 0x19, 0x57, 0xc8, 0x1d, - 0x58, 0xd9, 0x5f, 0xdf, 0x6d, 0xb6, 0x7b, 0xeb, 0xcd, 0xdd, 0xce, 0x56, 0xb7, 0xb7, 0xd7, 0xbd, - 0xdf, 0xdd, 0xda, 0xef, 0x2e, 0xa5, 0x4a, 0xa5, 0xc7, 0x4f, 0xaa, 0xd7, 0x66, 0xf0, 0x3d, 0x7f, - 0xe0, 0x07, 0x47, 0xdc, 0xf1, 0xe5, 0x73, 0xaa, 0x26, 0x6d, 0xad, 0xef, 0xb6, 0x96, 0xb4, 0xd2, - 0xff, 0x1e, 0x3f, 0xa9, 0x5e, 0x9d, 0x11, 0x35, 0x19, 0xca, 0xc9, 0x74, 0x5e, 0xb3, 0xb7, 0xbd, - 0xc1, 0x35, 0xe9, 0x44, 0xcd, 0xde, 0xd0, 0x4e, 0xd2, 0xd0, 0xd6, 0xe6, 0xd6, 0x83, 0xd6, 0x52, - 0x26, 0x51, 0x43, 0xd1, 0x0b, 0xc6, 0x58, 0xba, 0xfe, 0xcd, 0xf7, 0xe5, 0xd4, 0xcf, 0x3f, 0x94, - 0x67, 0x5f, 0x75, 0xcd, 0x83, 0x05, 0x71, 0x44, 0xec, 0x78, 0x51, 0x7d, 0x51, 0x23, 0x96, 0xaa, - 0x2f, 0xaa, 0xa7, 0xda, 0xd5, 0x5f, 0x7f, 0xfc, 0xfb, 0xbb, 0xf4, 0x15, 0x28, 0x0a, 0xe2, 0x6d, - 0xcf, 0xf4, 0xcd, 0x3e, 0xb2, 0x77, 0xb4, 0x86, 0xf1, 0xf4, 0x59, 0x39, 0xf5, 0xfb, 0xb3, 0x72, - 0xea, 0xab, 0x69, 0x59, 0x7b, 0x3a, 0x2d, 0x6b, 0xbf, 0x4d, 0xcb, 0xda, 0x9f, 0xd3, 0xb2, 0x76, - 0xa0, 0x8b, 0x3f, 0x90, 0xef, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xf8, 0x53, 0xd9, 0x73, 0xb7, - 0x0a, 0x00, 0x00, + // 1186 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x96, 0xbd, 0x73, 0x1b, 0xc5, + 0x1b, 0xc7, 0x75, 0x8a, 0x7c, 0x92, 0x1e, 0xdb, 0x89, 0x67, 0xe3, 0x24, 0xf7, 0xd3, 0x2f, 0xc8, + 0x42, 0x0c, 0x90, 0x49, 0x82, 0x0c, 0x26, 0x24, 0x03, 0x04, 0x66, 0x2c, 0x59, 0x8c, 0x44, 0xc6, + 0x2f, 0xb3, 0xb6, 0x93, 0x52, 0x73, 0xbe, 0x7b, 0xac, 0x1c, 0xba, 0xbb, 0x15, 0x7b, 0x27, 0x39, + 0xee, 0x28, 0x28, 0x98, 0xf4, 0xcc, 0xd0, 0xa4, 0x82, 0x9a, 0x86, 0x0e, 0xfe, 0x81, 0x0c, 0x15, + 0x25, 0x34, 0x1a, 0xa2, 0x92, 0x82, 0xbf, 0x80, 0x82, 0xd9, 0x97, 0xf3, 0x8b, 0x72, 0xb2, 0x49, + 0xa5, 0xbd, 0xbd, 0xcf, 0xf7, 0xd9, 0x67, 0x9f, 0xb7, 0x13, 0xdc, 0xec, 0x7a, 0xf1, 0xe3, 0xc1, + 0x5e, 0xcd, 0x61, 0xc1, 0xb2, 0xcb, 0x9c, 0x1e, 0xf2, 0xe5, 0xe8, 0xc0, 0xe6, 0x41, 0xcf, 0x8b, + 0x97, 0xed, 0xbe, 0xb7, 0x7c, 0x60, 0xc7, 0xce, 0xe3, 0x5a, 0x9f, 0xb3, 0x98, 0x11, 0xa2, 0x80, + 0x5a, 0x02, 0xd4, 0x86, 0xef, 0x95, 0xce, 0xd3, 0x47, 0x7d, 0x74, 0x22, 0xa5, 0x2f, 0xdd, 0x3e, + 0x87, 0x65, 0x7b, 0x5f, 0xa0, 0x13, 0x27, 0xf4, 0x79, 0x96, 0xe3, 0xc3, 0x3e, 0x26, 0xec, 0x62, + 0x97, 0x75, 0x99, 0x5c, 0x2e, 0x8b, 0x95, 0xde, 0xbd, 0x77, 0x86, 0x05, 0x49, 0xec, 0x0d, 0xf6, + 0x97, 0xfb, 0xfe, 0xa0, 0xeb, 0x85, 0xfa, 0x47, 0x09, 0xab, 0x5f, 0xe7, 0xc0, 0xdc, 0x94, 0xce, + 0x90, 0x1a, 0xe4, 0x42, 0xe6, 0xa2, 0x65, 0x54, 0x8c, 0x1b, 0xb3, 0x2b, 0x56, 0xed, 0xe5, 0x10, + 0xd4, 0x36, 0x98, 0x8b, 0xad, 0x0c, 0x95, 0x1c, 0xb9, 0x07, 0xf9, 0x08, 0xf9, 0xd0, 0x73, 0xd0, + 0xca, 0x4a, 0xc9, 0xff, 0xd3, 0x24, 0xdb, 0x0a, 0x69, 0x65, 0x68, 0x42, 0x0b, 0x61, 0x88, 0xf1, + 0x01, 0xe3, 0x3d, 0xeb, 0xc2, 0x74, 0xe1, 0x86, 0x42, 0x84, 0x50, 0xd3, 0xc2, 0xc3, 0xd8, 0x8e, + 0x7a, 0x56, 0x6e, 0xba, 0x87, 0x3b, 0x76, 0x24, 0x24, 0x92, 0x13, 0x07, 0x39, 0xfe, 0x20, 0x8a, + 0x91, 0x5b, 0x33, 0xd3, 0x0f, 0x6a, 0x28, 0x44, 0x1c, 0xa4, 0x69, 0x72, 0x07, 0xcc, 0x08, 0x1d, + 0x8e, 0xb1, 0x65, 0x4a, 0x5d, 0x29, 0xfd, 0x66, 0x82, 0x68, 0x65, 0xa8, 0x66, 0xc9, 0x47, 0x50, + 0xe0, 0x18, 0xb1, 0x01, 0x77, 0xd0, 0xca, 0x4b, 0xdd, 0xf5, 0x34, 0x1d, 0xd5, 0x4c, 0x2b, 0x43, + 0x8f, 0x78, 0xf2, 0x09, 0x14, 0xf1, 0x49, 0x8c, 0x61, 0xe4, 0xb1, 0xd0, 0x2a, 0x48, 0xf1, 0x6b, + 0x69, 0xe2, 0x66, 0x02, 0xb5, 0x32, 0xf4, 0x58, 0x21, 0x1c, 0x76, 0x58, 0xb8, 0xef, 0x75, 0xad, + 0xe2, 0x74, 0x87, 0x1b, 0x92, 0x10, 0x0e, 0x2b, 0xb6, 0x5e, 0x48, 0x72, 0x5f, 0xdd, 0x82, 0xb9, + 0x6d, 0xf4, 0xd1, 0x89, 0xeb, 0x87, 0xdb, 0x3e, 0x8b, 0xc9, 0x6d, 0x00, 0x9d, 0xad, 0x8e, 0xe7, + 0xca, 0x8a, 0x28, 0xd6, 0xe7, 0xc7, 0xa3, 0xa5, 0xa2, 0x4e, 0x67, 0x7b, 0x8d, 0x16, 0x35, 0xd0, + 0x76, 0x09, 0x81, 0x5c, 0xe4, 0xb3, 0x58, 0x96, 0x41, 0x8e, 0xca, 0x75, 0x75, 0x0b, 0x2e, 0x26, + 0x16, 0x1b, 0x83, 0x28, 0x66, 0x81, 0xa0, 0x7a, 0x5e, 0xa8, 0xad, 0x51, 0xb9, 0x26, 0x8b, 0x30, + 0xe3, 0x85, 0x2e, 0x3e, 0x91, 0xd2, 0x22, 0x55, 0x0f, 0x62, 0x77, 0x68, 0xfb, 0x03, 0x94, 0xe5, + 0x51, 0xa4, 0xea, 0xa1, 0xfa, 0x97, 0x09, 0x85, 0xc4, 0x24, 0xb1, 0x20, 0x7b, 0xe4, 0x98, 0x39, + 0x1e, 0x2d, 0x65, 0xdb, 0x6b, 0xad, 0x0c, 0xcd, 0x7a, 0x2e, 0xb9, 0x05, 0x45, 0xcf, 0xed, 0xf4, + 0x39, 0xee, 0x7b, 0xda, 0x6c, 0x7d, 0x6e, 0x3c, 0x5a, 0x2a, 0xb4, 0xd7, 0xb6, 0xe4, 0x9e, 0x08, + 0xbb, 0xe7, 0xaa, 0x35, 0x59, 0x84, 0x5c, 0x68, 0x07, 0xfa, 0x20, 0x59, 0xd9, 0x76, 0x80, 0xe4, + 0x75, 0x98, 0x15, 0xbf, 0x89, 0x91, 0x9c, 0x7e, 0x09, 0x62, 0x53, 0x0b, 0xef, 0x83, 0xe9, 0xc8, + 0x6b, 0xe9, 0xca, 0xaa, 0xa6, 0x57, 0xc8, 0xc9, 0x00, 0xc8, 0xc0, 0xab, 0x50, 0xb4, 0x61, 0x5e, + 0xad, 0x92, 0x23, 0xcc, 0x57, 0x30, 0x32, 0xa7, 0xa4, 0xda, 0x91, 0xda, 0xa9, 0x4c, 0xe5, 0x53, + 0x32, 0x25, 0x2a, 0xe5, 0x38, 0x57, 0x6f, 0x42, 0x5e, 0x74, 0xaf, 0x80, 0x0b, 0x12, 0x86, 0xf1, + 0x68, 0xc9, 0x14, 0x8d, 0x2d, 0x49, 0x53, 0xbc, 0x6c, 0xbb, 0xe4, 0xae, 0x4e, 0xa9, 0x2a, 0xa7, + 0xca, 0x59, 0x8e, 0x89, 0x82, 0x11, 0xa1, 0x13, 0x3c, 0x59, 0x83, 0x79, 0x17, 0x23, 0x8f, 0xa3, + 0xdb, 0x89, 0x62, 0x3b, 0x46, 0x0b, 0x2a, 0xc6, 0x8d, 0x8b, 0xe9, 0xb5, 0x2c, 0x7a, 0x75, 0x5b, + 0x40, 0xe2, 0x52, 0x5a, 0x25, 0x9f, 0xc9, 0x0a, 0xe4, 0x38, 0xf3, 0xd1, 0x9a, 0x95, 0xe2, 0xeb, + 0xd3, 0x46, 0x11, 0x65, 0xbe, 0x1c, 0x47, 0x82, 0x25, 0x6d, 0x80, 0x00, 0x83, 0x3d, 0xe4, 0xd1, + 0x63, 0xaf, 0x6f, 0xcd, 0x49, 0xe5, 0xdb, 0xd3, 0x94, 0xdb, 0x7d, 0x74, 0x6a, 0xeb, 0x47, 0xb8, + 0x48, 0xee, 0xb1, 0x98, 0xac, 0xc3, 0x15, 0x8e, 0xfb, 0xc8, 0x31, 0x74, 0xd0, 0xed, 0xe8, 0xe9, + 0x23, 0x22, 0x36, 0x2f, 0x23, 0x76, 0x6d, 0x3c, 0x5a, 0xba, 0x4c, 0x8f, 0x00, 0x3d, 0xa8, 0x64, + 0xf8, 0x2e, 0xf3, 0x97, 0xb6, 0x5d, 0xf2, 0x39, 0x2c, 0x9e, 0x30, 0xa7, 0x86, 0x85, 0xb0, 0x76, + 0x51, 0x5a, 0xbb, 0x3a, 0x1e, 0x2d, 0x91, 0x63, 0x6b, 0x6a, 0xaa, 0x48, 0x63, 0x84, 0x4f, 0xee, + 0x8a, 0x86, 0x51, 0x4d, 0x74, 0x29, 0x29, 0x58, 0xd9, 0x46, 0xa7, 0x4f, 0x50, 0xdd, 0x2d, 0x4e, + 0x58, 0x48, 0x3b, 0x41, 0x8d, 0x81, 0xc9, 0x13, 0xf4, 0xae, 0x5b, 0xcf, 0x41, 0xb6, 0x7e, 0x58, + 0xfd, 0x23, 0x0b, 0x73, 0x8f, 0xc4, 0x07, 0x91, 0xe2, 0x97, 0x03, 0x8c, 0x62, 0xd2, 0x84, 0x3c, + 0x86, 0x31, 0xf7, 0x30, 0xb2, 0x8c, 0xca, 0x85, 0x1b, 0xb3, 0x2b, 0xb7, 0xd2, 0x62, 0x7b, 0x52, + 0xa2, 0x1e, 0x9a, 0x61, 0xcc, 0x0f, 0x69, 0xa2, 0x25, 0xf7, 0x61, 0x96, 0x63, 0x34, 0x08, 0xb0, + 0xb3, 0xcf, 0x59, 0x70, 0xd6, 0x87, 0xe3, 0x21, 0x72, 0x31, 0xda, 0x28, 0x28, 0xfe, 0x33, 0xce, + 0x02, 0x72, 0x1b, 0x88, 0x17, 0x3a, 0xfe, 0xc0, 0xc5, 0x0e, 0xf3, 0xdd, 0x8e, 0xfa, 0x8a, 0xca, + 0xe6, 0x2d, 0xd0, 0x05, 0xfd, 0x66, 0xd3, 0x77, 0xd5, 0x50, 0x2b, 0x7d, 0x6b, 0x00, 0x1c, 0xfb, + 0x90, 0x3a, 0x7f, 0x3e, 0x06, 0xd3, 0x76, 0x62, 0x31, 0x73, 0xb3, 0xb2, 0x60, 0xde, 0x98, 0x7a, + 0xa9, 0x55, 0x89, 0x3d, 0xf0, 0x42, 0x97, 0x6a, 0x09, 0xb9, 0x0b, 0xf9, 0x7d, 0xcf, 0x8f, 0x91, + 0x47, 0xd6, 0x05, 0x19, 0x92, 0xeb, 0x67, 0xb5, 0x09, 0x4d, 0xe0, 0xea, 0x2f, 0x49, 0x6c, 0xd7, + 0x31, 0x8a, 0xec, 0x2e, 0x92, 0x4f, 0xc1, 0xc4, 0x21, 0x86, 0x71, 0x12, 0xda, 0xb7, 0xa6, 0x7a, + 0xa1, 0x15, 0xb5, 0xa6, 0xc0, 0xa9, 0x56, 0x91, 0x0f, 0x20, 0x3f, 0x54, 0xd1, 0xfa, 0x2f, 0x01, + 0x4d, 0xd8, 0xd2, 0x4f, 0x06, 0xcc, 0x48, 0x43, 0x27, 0xc2, 0x60, 0xbc, 0x7a, 0x18, 0x56, 0xc0, + 0xd4, 0x89, 0xc8, 0x4e, 0xff, 0xf6, 0xa8, 0x94, 0x50, 0x4d, 0x92, 0x0f, 0x01, 0x26, 0x12, 0x78, + 0xb6, 0xae, 0xc8, 0x92, 0xac, 0xde, 0xfc, 0xc7, 0x80, 0x4b, 0x13, 0xae, 0x90, 0x3b, 0xb0, 0xf8, + 0x68, 0x75, 0xa7, 0xd1, 0xea, 0xac, 0x36, 0x76, 0xda, 0x9b, 0x1b, 0x9d, 0xdd, 0x8d, 0x07, 0x1b, + 0x9b, 0x8f, 0x36, 0x16, 0x32, 0xa5, 0xd2, 0xd3, 0x67, 0x95, 0xab, 0x13, 0xf8, 0x6e, 0xd8, 0x0b, + 0xd9, 0x81, 0x70, 0xfc, 0xf2, 0x29, 0x55, 0x83, 0x36, 0x57, 0x77, 0x9a, 0x0b, 0x46, 0xe9, 0x7f, + 0x4f, 0x9f, 0x55, 0xae, 0x4c, 0x88, 0x1a, 0x1c, 0xd5, 0x64, 0x3a, 0xad, 0xd9, 0xdd, 0x5a, 0x13, + 0x9a, 0x6c, 0xaa, 0x66, 0xb7, 0xef, 0xa6, 0x69, 0x68, 0x73, 0x7d, 0xf3, 0x61, 0x73, 0x21, 0x97, + 0xaa, 0xa1, 0x18, 0xb0, 0x21, 0x96, 0xae, 0x7d, 0xf3, 0x7d, 0x39, 0xf3, 0xf3, 0x0f, 0xe5, 0xc9, + 0xab, 0xae, 0x04, 0x30, 0x23, 0xb7, 0x88, 0x9b, 0x2c, 0x2a, 0xe7, 0x35, 0x62, 0xa9, 0x72, 0x5e, + 0x3d, 0x55, 0xaf, 0xfc, 0xfa, 0xe3, 0xdf, 0xdf, 0x65, 0x2f, 0xc1, 0xbc, 0x24, 0xde, 0x09, 0xec, + 0xd0, 0xee, 0x22, 0x7f, 0xd7, 0xa8, 0x5b, 0xcf, 0x5f, 0x94, 0x33, 0xbf, 0xbf, 0x28, 0x67, 0xbe, + 0x1a, 0x97, 0x8d, 0xe7, 0xe3, 0xb2, 0xf1, 0xdb, 0xb8, 0x6c, 0xfc, 0x39, 0x2e, 0x1b, 0x7b, 0xa6, + 0xfc, 0x03, 0xf9, 0xfe, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe6, 0x76, 0x89, 0xef, 0x57, 0x0b, + 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/watch.proto b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/watch.proto index f84fd9ef7..d017730b8 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/watch.proto +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/api/watch.proto @@ -2,11 +2,11 @@ syntax = "proto3"; package docker.swarmkit.v1; -import "specs.proto"; -import "objects.proto"; -import "types.proto"; +import "github.com/docker/swarmkit/api/specs.proto"; +import "github.com/docker/swarmkit/api/objects.proto"; +import "github.com/docker/swarmkit/api/types.proto"; import "gogoproto/gogo.proto"; -import "plugin/plugin.proto"; +import "github.com/docker/swarmkit/protobuf/plugin/plugin.proto"; message Object { oneof Object { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/ca/config.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/ca/config.go index 3731df1c4..0fd4ebe0f 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/ca/config.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/ca/config.go @@ -68,14 +68,11 @@ type SecurityConfig struct { renewalMu sync.Mutex rootCA *RootCA - externalCA *ExternalCA keyReadWriter *KeyReadWriter certificate *tls.Certificate issuerInfo *IssuerInfo - externalCAClientRootPool *x509.CertPool - ServerTLSCreds *MutableTLSCreds ClientTLSCreds *MutableTLSCreds @@ -90,7 +87,7 @@ type CertificateUpdate struct { Err error } -func validateRootCAAndTLSCert(rootCA *RootCA, externalCARootPool *x509.CertPool, tlsKeyPair *tls.Certificate) error { +func validateRootCAAndTLSCert(rootCA *RootCA, tlsKeyPair *tls.Certificate) error { var ( leafCert *x509.Certificate intermediatePool *x509.CertPool @@ -116,10 +113,6 @@ func validateRootCAAndTLSCert(rootCA *RootCA, externalCARootPool *x509.CertPool, if _, err := leafCert.Verify(opts); err != nil { return errors.Wrap(err, "new root CA does not match existing TLS credentials") } - opts.Roots = externalCARootPool - if _, err := leafCert.Verify(opts); err != nil { - return errors.Wrap(err, "new external root pool does not match existing TLS credentials") - } return nil } @@ -139,16 +132,7 @@ func NewSecurityConfig(rootCA *RootCA, krw *KeyReadWriter, tlsKeyPair *tls.Certi return nil, nil, err } - // Make a new TLS config for the external CA client without a - // ServerName value set. - externalCATLSConfig := &tls.Config{ - Certificates: []tls.Certificate{*tlsKeyPair}, - RootCAs: rootCA.Pool, - MinVersion: tls.VersionTLS12, - } - q := watch.NewQueue() - return &SecurityConfig{ rootCA: rootCA, keyReadWriter: krw, @@ -157,10 +141,8 @@ func NewSecurityConfig(rootCA *RootCA, krw *KeyReadWriter, tlsKeyPair *tls.Certi issuerInfo: issuerInfo, queue: q, - externalCA: NewExternalCA(rootCA, externalCATLSConfig), - ClientTLSCreds: clientTLSCreds, - ServerTLSCreds: serverTLSCreds, - externalCAClientRootPool: rootCA.Pool, + ClientTLSCreds: clientTLSCreds, + ServerTLSCreds: serverTLSCreds, }, q.Close, nil } @@ -172,11 +154,6 @@ func (s *SecurityConfig) RootCA() *RootCA { return s.rootCA } -// ExternalCA returns the external CA. -func (s *SecurityConfig) ExternalCA() *ExternalCA { - return s.externalCA -} - // KeyWriter returns the object that can write keys to disk func (s *SecurityConfig) KeyWriter() KeyWriter { return s.keyReadWriter @@ -188,19 +165,16 @@ func (s *SecurityConfig) KeyReader() KeyReader { } // UpdateRootCA replaces the root CA with a new root CA -func (s *SecurityConfig) UpdateRootCA(rootCA *RootCA, externalCARootPool *x509.CertPool) error { +func (s *SecurityConfig) UpdateRootCA(rootCA *RootCA) error { s.mu.Lock() defer s.mu.Unlock() // refuse to update the root CA if the current TLS credentials do not validate against it - if err := validateRootCAAndTLSCert(rootCA, externalCARootPool, s.certificate); err != nil { + if err := validateRootCAAndTLSCert(rootCA, s.certificate); err != nil { return err } s.rootCA = rootCA - s.externalCAClientRootPool = externalCARootPool - s.externalCA.UpdateRootCA(rootCA) - return s.updateTLSCredentials(s.certificate, s.issuerInfo) } @@ -233,14 +207,6 @@ func (s *SecurityConfig) updateTLSCredentials(certificate *tls.Certificate, issu return errors.Wrap(err, "failed to update the client credentials") } - // Update the external CA to use the new client TLS - // config using a copy without a serverName specified. - s.externalCA.UpdateTLSConfig(&tls.Config{ - Certificates: certs, - RootCAs: s.externalCAClientRootPool, - MinVersion: tls.VersionTLS12, - }) - if err := s.ServerTLSCreds.loadNewTLSConfig(serverConfig); err != nil { return errors.Wrap(err, "failed to update the server TLS credentials") } @@ -507,7 +473,7 @@ func updateRootThenUpdateCert(ctx context.Context, s *SecurityConfig, connBroker return nil, nil, err } // validate against the existing security config creds - if err := s.UpdateRootCA(&rootCA, rootCA.Pool); err != nil { + if err := s.UpdateRootCA(&rootCA); err != nil { return nil, nil, err } if err := SaveRootCA(rootCA, rootPaths); err != nil { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/ca/external.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/ca/external.go index 47c8dd8f8..789361eb6 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/ca/external.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/ca/external.go @@ -47,18 +47,28 @@ var ErrNoExternalCAURLs = errors.New("no external CA URLs") type ExternalCA struct { ExternalRequestTimeout time.Duration - mu sync.Mutex - rootCA *RootCA - urls []string - client *http.Client + mu sync.Mutex + intermediates []byte + urls []string + client *http.Client +} + +// NewExternalCATLSConfig takes a TLS certificate and root pool and returns a TLS config that can be updated +// without killing existing connections +func NewExternalCATLSConfig(certs []tls.Certificate, rootPool *x509.CertPool) *tls.Config { + return &tls.Config{ + Certificates: certs, + RootCAs: rootPool, + MinVersion: tls.VersionTLS12, + } } // NewExternalCA creates a new ExternalCA which uses the given tlsConfig to // authenticate to any of the given URLS of CFSSL API endpoints. -func NewExternalCA(rootCA *RootCA, tlsConfig *tls.Config, urls ...string) *ExternalCA { +func NewExternalCA(intermediates []byte, tlsConfig *tls.Config, urls ...string) *ExternalCA { return &ExternalCA{ ExternalRequestTimeout: 5 * time.Second, - rootCA: rootCA, + intermediates: intermediates, urls: urls, client: &http.Client{ Transport: &http.Transport{ @@ -68,19 +78,6 @@ func NewExternalCA(rootCA *RootCA, tlsConfig *tls.Config, urls ...string) *Exter } } -// Copy returns a copy of the external CA that can be updated independently -func (eca *ExternalCA) Copy() *ExternalCA { - eca.mu.Lock() - defer eca.mu.Unlock() - - return &ExternalCA{ - ExternalRequestTimeout: eca.ExternalRequestTimeout, - rootCA: eca.rootCA, - urls: eca.urls, - client: eca.client, - } -} - // UpdateTLSConfig updates the HTTP Client for this ExternalCA by creating // a new client which uses the given tlsConfig. func (eca *ExternalCA) UpdateTLSConfig(tlsConfig *tls.Config) { @@ -102,13 +99,6 @@ func (eca *ExternalCA) UpdateURLs(urls ...string) { eca.urls = urls } -// UpdateRootCA changes the root CA used to append intermediates -func (eca *ExternalCA) UpdateRootCA(rca *RootCA) { - eca.mu.Lock() - eca.rootCA = rca - eca.mu.Unlock() -} - // Sign signs a new certificate by proxying the given certificate signing // request to an external CFSSL API server. func (eca *ExternalCA) Sign(ctx context.Context, req signer.SignRequest) (cert []byte, err error) { @@ -117,7 +107,7 @@ func (eca *ExternalCA) Sign(ctx context.Context, req signer.SignRequest) (cert [ eca.mu.Lock() urls := eca.urls client := eca.client - intermediates := eca.rootCA.Intermediates + intermediates := eca.intermediates eca.mu.Unlock() if len(urls) == 0 { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/ca/server.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/ca/server.go index 33a636769..16dbedc8d 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/ca/server.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/ca/server.go @@ -25,13 +25,6 @@ const ( defaultRootReconciliationInterval = 3 * time.Second ) -// APISecurityConfigUpdater knows how to update a SecurityConfig from an api.Cluster object -type APISecurityConfigUpdater interface { - UpdateRootCA(ctx context.Context, cluster *api.Cluster) error -} - -var _ APISecurityConfigUpdater = &Server{} - // Server is the CA and NodeCA API gRPC server. // TODO(aaronl): At some point we may want to have separate implementations of // CA, NodeCA, and other hypothetical future CA services. At the moment, @@ -43,6 +36,10 @@ type Server struct { cancel func() store *store.MemoryStore securityConfig *SecurityConfig + clusterID string + localRootCA *RootCA + externalCA *ExternalCA + externalCAPool *x509.CertPool joinTokens *api.JoinTokens reconciliationRetryInterval time.Duration @@ -60,10 +57,12 @@ type Server struct { // the security config as a result lastSeenClusterRootCA *api.RootCA lastSeenExternalCAs []*api.ExternalCA - secConfigMu sync.Mutex - // before we update the security config with the new root CA, we need to be able to save the root certs - rootPaths CertPaths + // This mutex protects the components of the CA server used to issue new certificates + // (and any attributes used to update those components): `lastSeenClusterRootCA` and + // `lastSeenExternalCA`, which are used to update `externalCA` and the `rootCA` object + // of the SecurityConfig + signingMu sync.Mutex // lets us monitor and finish root rotations rootReconciler *rootRotationReconciler @@ -78,18 +77,36 @@ func DefaultCAConfig() api.CAConfig { } // NewServer creates a CA API server. -func NewServer(store *store.MemoryStore, securityConfig *SecurityConfig, rootCAPaths CertPaths) *Server { +func NewServer(store *store.MemoryStore, securityConfig *SecurityConfig) *Server { return &Server{ store: store, securityConfig: securityConfig, + localRootCA: securityConfig.RootCA(), + externalCA: NewExternalCA(nil, nil), pending: make(map[string]*api.Node), started: make(chan struct{}), reconciliationRetryInterval: defaultReconciliationRetryInterval, rootReconciliationRetryInterval: defaultRootReconciliationInterval, - rootPaths: rootCAPaths, + clusterID: securityConfig.ClientTLSCreds.Organization(), } } +// ExternalCA returns the current external CA - this is exposed to support unit testing only, and the external CA +// should really be a private field +func (s *Server) ExternalCA() *ExternalCA { + s.signingMu.Lock() + defer s.signingMu.Unlock() + return s.externalCA +} + +// RootCA returns the current local root CA - this is exposed to support unit testing only, and the root CA +// should really be a private field +func (s *Server) RootCA() *RootCA { + s.signingMu.Lock() + defer s.signingMu.Unlock() + return s.localRootCA +} + // SetReconciliationRetryInterval changes the time interval between // reconciliation attempts. This function must be called before Run. func (s *Server) SetReconciliationRetryInterval(reconciliationRetryInterval time.Duration) { @@ -114,7 +131,7 @@ func (s *Server) GetUnlockKey(ctx context.Context, request *api.GetUnlockKeyRequ // a cached value. resp := api.GetUnlockKeyResponse{} s.store.View(func(tx store.ReadTx) { - cluster := store.GetCluster(tx, s.securityConfig.ClientTLSCreds.Organization()) + cluster := store.GetCluster(tx, s.clusterID) resp.Version = cluster.Meta.Version if cluster.Spec.EncryptionConfig.AutoLockManagers { for _, encryptionKey := range cluster.UnlockKeys { @@ -222,7 +239,7 @@ func (s *Server) IssueNodeCertificate(ctx context.Context, request *api.IssueNod return nil, grpc.Errorf(codes.InvalidArgument, codes.InvalidArgument.String()) } - if _, err := s.isRunningLocked(); err != nil { + if err := s.isReadyLocked(); err != nil { return nil, err } @@ -233,8 +250,7 @@ func (s *Server) IssueNodeCertificate(ctx context.Context, request *api.IssueNod ) s.store.View(func(readTx store.ReadTx) { - clusters, err = store.FindClusters(readTx, store.ByName("default")) - + clusters, err = store.FindClusters(readTx, store.ByName(store.DefaultClusterName)) }) // Not having a cluster object yet means we can't check @@ -254,14 +270,14 @@ func (s *Server) IssueNodeCertificate(ctx context.Context, request *api.IssueNod // If the remote node is a worker (either forwarded by a manager, or calling directly), // issue a renew worker certificate entry with the correct ID - nodeID, err := AuthorizeForwardedRoleAndOrg(ctx, []string{WorkerRole}, []string{ManagerRole}, s.securityConfig.ClientTLSCreds.Organization(), blacklistedCerts) + nodeID, err := AuthorizeForwardedRoleAndOrg(ctx, []string{WorkerRole}, []string{ManagerRole}, s.clusterID, blacklistedCerts) if err == nil { return s.issueRenewCertificate(ctx, nodeID, request.CSR) } // If the remote node is a manager (either forwarded by another manager, or calling directly), // issue a renew certificate entry with the correct ID - nodeID, err = AuthorizeForwardedRoleAndOrg(ctx, []string{ManagerRole}, []string{ManagerRole}, s.securityConfig.ClientTLSCreds.Organization(), blacklistedCerts) + nodeID, err = AuthorizeForwardedRoleAndOrg(ctx, []string{ManagerRole}, []string{ManagerRole}, s.clusterID, blacklistedCerts) if err == nil { return s.issueRenewCertificate(ctx, nodeID, request.CSR) } @@ -393,8 +409,11 @@ func (s *Server) GetRootCACertificate(ctx context.Context, request *api.GetRootC "method": "GetRootCACertificate", }) + s.signingMu.Lock() + defer s.signingMu.Unlock() + return &api.GetRootCACertificateResponse{ - Certificate: s.securityConfig.RootCA().Certs, + Certificate: s.localRootCA.Certs, }, nil } @@ -409,47 +428,51 @@ func (s *Server) Run(ctx context.Context) error { s.wg.Add(1) s.ctx, s.cancel = context.WithCancel(log.WithModule(ctx, "ca")) ctx = s.ctx - // we need to set it on the server, because `Server.UpdateRootCA` can be called from outside the Run function - s.rootReconciler = &rootRotationReconciler{ - ctx: log.WithField(ctx, "method", "(*Server).rootRotationReconciler"), - clusterID: s.securityConfig.ClientTLSCreds.Organization(), - store: s.store, - batchUpdateInterval: s.rootReconciliationRetryInterval, - } - rootReconciler := s.rootReconciler s.mu.Unlock() defer s.wg.Done() defer func() { s.mu.Lock() - s.rootReconciler = nil s.mu.Unlock() }() // Retrieve the channels to keep track of changes in the cluster // Retrieve all the currently registered nodes - var nodes []*api.Node - + var ( + nodes []*api.Node + cluster *api.Cluster + err error + ) updates, cancel, err := store.ViewAndWatch( s.store, func(readTx store.ReadTx) error { - clusters, err := store.FindClusters(readTx, store.ByName(store.DefaultClusterName)) - if err != nil { - return err - } - if len(clusters) != 1 { + cluster = store.GetCluster(readTx, s.clusterID) + if cluster == nil { return errors.New("could not find cluster object") } - s.UpdateRootCA(ctx, clusters[0]) // call once to ensure that the join tokens are always set nodes, err = store.FindNodes(readTx, store.All) return err }, api.EventCreateNode{}, api.EventUpdateNode{}, api.EventDeleteNode{}, + api.EventUpdateCluster{ + Cluster: &api.Cluster{ID: s.clusterID}, + Checks: []api.ClusterCheckFunc{api.ClusterCheckID}, + }, ) - // Do this after updateCluster has been called, so isRunning never - // returns true without joinTokens being set correctly. + // call once to ensure that the join tokens and local/external CA signer are always set + rootReconciler := &rootRotationReconciler{ + ctx: log.WithField(ctx, "method", "(*Server).rootRotationReconciler"), + clusterID: s.clusterID, + store: s.store, + batchUpdateInterval: s.rootReconciliationRetryInterval, + } + + s.UpdateRootCA(ctx, cluster, rootReconciler) + + // Do this after updateCluster has been called, so Ready() and isRunning never returns true without + // the join tokens and external CA/security config's root CA being set correctly s.mu.Lock() close(s.started) s.mu.Unlock() @@ -475,6 +498,9 @@ func (s *Server) Run(ctx context.Context) error { ticker := time.NewTicker(s.reconciliationRetryInterval) defer ticker.Stop() + externalTLSCredsChange, externalTLSWatchCancel := s.securityConfig.Watch() + defer externalTLSWatchCancel() + // Watch for new nodes being created, new nodes being updated, and changes // to the cluster for { @@ -499,8 +525,29 @@ func (s *Server) Run(ctx context.Context) error { rootReconciler.UpdateNode(v.Node) case api.EventDeleteNode: rootReconciler.DeleteNode(v.Node) + case api.EventUpdateCluster: + if v.Cluster.ID == s.clusterID { + s.UpdateRootCA(ctx, v.Cluster, rootReconciler) + } } - + case <-externalTLSCredsChange: + // The TLS certificates can rotate independently of the root CA (and hence which roots the + // external CA trusts) and external CA URLs. It's possible that the root CA update is received + // before the external TLS cred change notification. During that period, it is possible that + // the TLS creds will expire or otherwise fail to authorize against external CAs. However, in + // that case signing will just fail with a recoverable connectivity error - the state of the + // certificate issuance is left as pending, and on the next tick, the server will try to sign + // all nodes with pending certs again (by which time the TLS cred change will have been + // received). + + // Note that if the external CA changes, the new external CA *MUST* trust the current server's + // certificate issuer, and this server's certificates should not be extremely close to expiry, + // otherwise this server would not be able to get new TLS certificates and will no longer be + // able to function. + s.signingMu.Lock() + s.externalCA.UpdateTLSConfig(NewExternalCATLSConfig( + s.securityConfig.ClientTLSCreds.Config().Certificates, s.externalCAPool)) + s.signingMu.Unlock() case <-ticker.C: for _, node := range s.pending { if err := s.evaluateAndSignNodeCert(ctx, node); err != nil { @@ -527,6 +574,7 @@ func (s *Server) Stop() error { } s.cancel() s.started = make(chan struct{}) + s.joinTokens = nil s.mu.Unlock() // Wait for Run to complete @@ -553,6 +601,18 @@ func (s *Server) isRunningLocked() (context.Context, error) { return ctx, nil } +func (s *Server) isReadyLocked() error { + s.mu.Lock() + defer s.mu.Unlock() + if !s.isRunning() { + return grpc.Errorf(codes.Aborted, "CA signer is stopped") + } + if s.joinTokens == nil { + return grpc.Errorf(codes.Aborted, "CA signer is still starting") + } + return nil +} + func (s *Server) isRunning() bool { if s.ctx == nil { return false @@ -565,33 +625,59 @@ func (s *Server) isRunning() bool { return true } +// filterExternalCAURLS returns a list of external CA urls filtered by the desired cert. +func filterExternalCAURLS(ctx context.Context, desiredCert, defaultCert []byte, apiExternalCAs []*api.ExternalCA) (urls []string) { + desiredCert = NormalizePEMs(desiredCert) + + // TODO(aaronl): In the future, this will be abstracted with an ExternalCA interface that has different + // implementations for different CA types. At the moment, only CFSSL is supported. + for i, extCA := range apiExternalCAs { + // We want to support old external CA specifications which did not have a CA cert. If there is no cert specified, + // we assume it's the old cert + certForExtCA := extCA.CACert + if len(certForExtCA) == 0 { + certForExtCA = defaultCert + } + certForExtCA = NormalizePEMs(certForExtCA) + if extCA.Protocol != api.ExternalCA_CAProtocolCFSSL { + log.G(ctx).Debugf("skipping external CA %d (url: %s) due to unknown protocol type", i, extCA.URL) + continue + } + if !bytes.Equal(certForExtCA, desiredCert) { + log.G(ctx).Debugf("skipping external CA %d (url: %s) because it has the wrong CA cert", i, extCA.URL) + continue + } + urls = append(urls, extCA.URL) + } + return +} + // UpdateRootCA is called when there are cluster changes, and it ensures that the local RootCA is // always aware of changes in clusterExpiry and the Root CA key material - this can be called by // anything to update the root CA material -func (s *Server) UpdateRootCA(ctx context.Context, cluster *api.Cluster) error { +func (s *Server) UpdateRootCA(ctx context.Context, cluster *api.Cluster, reconciler *rootRotationReconciler) error { s.mu.Lock() s.joinTokens = cluster.RootCA.JoinTokens.Copy() - reconciler := s.rootReconciler s.mu.Unlock() rCA := cluster.RootCA.Copy() if reconciler != nil { reconciler.UpdateRootCA(rCA) } - s.secConfigMu.Lock() - defer s.secConfigMu.Unlock() + s.signingMu.Lock() + defer s.signingMu.Unlock() firstSeenCluster := s.lastSeenClusterRootCA == nil && s.lastSeenExternalCAs == nil rootCAChanged := len(rCA.CACert) != 0 && !equality.RootCAEqualStable(s.lastSeenClusterRootCA, rCA) externalCAChanged := !equality.ExternalCAsEqualStable(s.lastSeenExternalCAs, cluster.Spec.CAConfig.ExternalCAs) - logger := log.G(ctx).WithFields(logrus.Fields{ + ctx = log.WithLogger(ctx, log.G(ctx).WithFields(logrus.Fields{ "cluster.id": cluster.ID, "method": "(*Server).UpdateRootCA", - }) + })) if rootCAChanged { setOrUpdate := "set" if !firstSeenCluster { - logger.Debug("Updating security config due to change in cluster Root CA") + log.G(ctx).Debug("Updating signing root CA and external CA due to change in cluster Root CA") setOrUpdate = "updated" } expiry := DefaultNodeCertExpiration @@ -599,91 +685,55 @@ func (s *Server) UpdateRootCA(ctx context.Context, cluster *api.Cluster) error { // NodeCertExpiry exists, let's try to parse the duration out of it clusterExpiry, err := gogotypes.DurationFromProto(cluster.Spec.CAConfig.NodeCertExpiry) if err != nil { - logger.WithError(err).Warn("failed to parse certificate expiration, using default") + log.G(ctx).WithError(err).Warn("failed to parse certificate expiration, using default") } else { // We were able to successfully parse the expiration out of the cluster. expiry = clusterExpiry } } else { // NodeCertExpiry seems to be nil - logger.Warn("no certificate expiration specified, using default") + log.G(ctx).Warn("no certificate expiration specified, using default") } // Attempt to update our local RootCA with the new parameters - var intermediates []byte - signingCert := rCA.CACert - signingKey := rCA.CAKey - if rCA.RootRotation != nil { - signingCert = rCA.RootRotation.CrossSignedCACert - signingKey = rCA.RootRotation.CAKey - intermediates = rCA.RootRotation.CrossSignedCACert - } - if signingKey == nil { - signingCert = nil - } - updatedRootCA, err := NewRootCA(rCA.CACert, signingCert, signingKey, expiry, intermediates) + updatedRootCA, err := RootCAFromAPI(ctx, rCA, expiry) if err != nil { return errors.Wrap(err, "invalid Root CA object in cluster") } - externalCARootPool := updatedRootCA.Pool + + s.localRootCA = &updatedRootCA + s.externalCAPool = updatedRootCA.Pool + externalCACert := rCA.CACert if rCA.RootRotation != nil { + externalCACert = rCA.RootRotation.CACert // the external CA has to trust the new CA cert - externalCARootPool = x509.NewCertPool() - externalCARootPool.AppendCertsFromPEM(rCA.CACert) - externalCARootPool.AppendCertsFromPEM(rCA.RootRotation.CACert) + s.externalCAPool = x509.NewCertPool() + s.externalCAPool.AppendCertsFromPEM(rCA.CACert) + s.externalCAPool.AppendCertsFromPEM(rCA.RootRotation.CACert) } + s.lastSeenExternalCAs = cluster.Spec.CAConfig.Copy().ExternalCAs + urls := filterExternalCAURLS(ctx, externalCACert, rCA.CACert, s.lastSeenExternalCAs) + // Replace the external CA with the relevant intermediates, URLS, and TLS config + s.externalCA = NewExternalCA(updatedRootCA.Intermediates, + NewExternalCATLSConfig(s.securityConfig.ClientTLSCreds.Config().Certificates, s.externalCAPool), urls...) - // Attempt to update our local RootCA with the new parameters - if err := s.securityConfig.UpdateRootCA(&updatedRootCA, externalCARootPool); err != nil { - return errors.Wrap(err, "updating Root CA failed") - } - if err := SaveRootCA(updatedRootCA, s.rootPaths); err != nil { - return errors.Wrap(err, "unable to save new root CA certificates") - } // only update the server cache if we've successfully updated the root CA - logger.Debugf("Root CA %s successfully", setOrUpdate) + log.G(ctx).Debugf("Root CA %s successfully", setOrUpdate) s.lastSeenClusterRootCA = rCA - } - - // we want to update if the external CA changed, or if the root CA changed because the root CA could affect what - // certificate for external CAs we want to filter by - if rootCAChanged || externalCAChanged { + } else if externalCAChanged { + // we want to update only if the external CA URLS have changed, since if the root CA has changed we already + // run similar logic if !firstSeenCluster { - logger.Debug("Updating security config external CA URLs due to change in cluster Root CA or cluster spec") + log.G(ctx).Debug("Updating security config external CA URLs due to change in cluster spec's list of external CAs") } wantedExternalCACert := rCA.CACert // we want to only add external CA URLs that use this cert if rCA.RootRotation != nil { // we're rotating to a new root, so we only want external CAs with the new root cert wantedExternalCACert = rCA.RootRotation.CACert } - wantedExternalCACert = NormalizePEMs(wantedExternalCACert) - // Update our security config with the list of External CA URLs - // from the new cluster state. - - // TODO(aaronl): In the future, this will be abstracted with an - // ExternalCA interface that has different implementations for - // different CA types. At the moment, only CFSSL is supported. - var cfsslURLs []string - for i, extCA := range cluster.Spec.CAConfig.ExternalCAs { - // We want to support old external CA specifications which did not have a CA cert. If there is no cert specified, - // we assume it's the old cert - certForExtCA := extCA.CACert - if len(certForExtCA) == 0 { - certForExtCA = rCA.CACert - } - certForExtCA = NormalizePEMs(certForExtCA) - if extCA.Protocol != api.ExternalCA_CAProtocolCFSSL { - logger.Debugf("skipping external CA %d (url: %s) due to unknown protocol type", i, extCA.URL) - continue - } - if !bytes.Equal(certForExtCA, wantedExternalCACert) { - logger.Debugf("skipping external CA %d (url: %s) because it has the wrong CA cert", i, extCA.URL) - continue - } - cfsslURLs = append(cfsslURLs, extCA.URL) - } - - s.securityConfig.externalCA.UpdateURLs(cfsslURLs...) + // Update our external CA with the list of External CA URLs from the new cluster state s.lastSeenExternalCAs = cluster.Spec.CAConfig.Copy().ExternalCAs + urls := filterExternalCAURLS(ctx, wantedExternalCACert, rCA.CACert, s.lastSeenExternalCAs) + s.externalCA.UpdateURLs(urls...) } return nil } @@ -714,8 +764,10 @@ func (s *Server) evaluateAndSignNodeCert(ctx context.Context, node *api.Node) er // signNodeCert does the bulk of the work for signing a certificate func (s *Server) signNodeCert(ctx context.Context, node *api.Node) error { - rootCA := s.securityConfig.RootCA() - externalCA := s.securityConfig.externalCA + s.signingMu.Lock() + rootCA := s.localRootCA + externalCA := s.externalCA + s.signingMu.Unlock() node = node.Copy() nodeID := node.ID @@ -736,7 +788,7 @@ func (s *Server) signNodeCert(ctx context.Context, node *api.Node) error { rawCSR = node.Certificate.CSR cn = node.Certificate.CN ou = role - org = s.securityConfig.ClientTLSCreds.Organization() + org = s.clusterID ) // Try using the external CA first. @@ -847,3 +899,19 @@ func isFinalState(status api.IssuanceStatus) bool { return false } + +// RootCAFromAPI creates a RootCA object from an api.RootCA object +func RootCAFromAPI(ctx context.Context, apiRootCA *api.RootCA, expiry time.Duration) (RootCA, error) { + var intermediates []byte + signingCert := apiRootCA.CACert + signingKey := apiRootCA.CAKey + if apiRootCA.RootRotation != nil { + signingCert = apiRootCA.RootRotation.CrossSignedCACert + signingKey = apiRootCA.RootRotation.CAKey + intermediates = apiRootCA.RootRotation.CrossSignedCACert + } + if signingKey == nil { + signingCert = nil + } + return NewRootCA(apiRootCA.CACert, signingCert, signingKey, expiry, intermediates) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/allocator/cnmallocator/networkallocator.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/allocator/cnmallocator/networkallocator.go index 2cfc95130..3b31d0781 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/allocator/cnmallocator/networkallocator.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/allocator/cnmallocator/networkallocator.go @@ -48,8 +48,10 @@ type cnmNetworkAllocator struct { tasks map[string]struct{} // Allocator state to indicate if allocation has been - // successfully completed for this node. - nodes map[string]struct{} + // successfully completed for this node on this network. + // outer map key: node id + // inner map key: network id + nodes map[string]map[string]struct{} } // Local in-memory state related to network that need to be tracked by cnmNetworkAllocator @@ -89,7 +91,7 @@ func New(pg plugingetter.PluginGetter) (networkallocator.NetworkAllocator, error networks: make(map[string]*network), services: make(map[string]struct{}), tasks: make(map[string]struct{}), - nodes: make(map[string]struct{}), + nodes: make(map[string]map[string]struct{}), } // There are no driver configurations and notification @@ -430,81 +432,100 @@ func (na *cnmNetworkAllocator) IsServiceAllocated(s *api.Service, flags ...func( return true } -// IsNodeAllocated returns if the passed node has its network resources allocated or not. -func (na *cnmNetworkAllocator) IsNodeAllocated(node *api.Node) bool { +// AllocateTask allocates all the endpoint resources for all the +// networks that a task is attached to. +func (na *cnmNetworkAllocator) AllocateTask(t *api.Task) error { + for i, nAttach := range t.Networks { + if localNet := na.getNetwork(nAttach.Network.ID); localNet != nil && localNet.isNodeLocal { + continue + } + if err := na.allocateNetworkIPs(nAttach); err != nil { + if err := na.releaseEndpoints(t.Networks[:i]); err != nil { + log.G(context.TODO()).WithError(err).Errorf("failed to release IP addresses while rolling back allocation for task %s network %s", t.ID, nAttach.Network.ID) + } + return errors.Wrapf(err, "failed to allocate network IP for task %s network %s", t.ID, nAttach.Network.ID) + } + } + + na.tasks[t.ID] = struct{}{} + + return nil +} + +// DeallocateTask releases all the endpoint resources for all the +// networks that a task is attached to. +func (na *cnmNetworkAllocator) DeallocateTask(t *api.Task) error { + delete(na.tasks, t.ID) + return na.releaseEndpoints(t.Networks) +} + +// IsLBAttachmentAllocated returns if the passed node and network has resources allocated or not. +func (na *cnmNetworkAllocator) IsLBAttachmentAllocated(node *api.Node, networkAttachment *api.NetworkAttachment) bool { + if node == nil { + return false + } + + if networkAttachment == nil { + return false + } + // If the node is not found in the allocated set, then it is // not allocated. if _, ok := na.nodes[node.ID]; !ok { return false } - // If no attachment, not allocated. - if node.Attachment == nil { + // If the nework is not found in the allocated set, then it is + // not allocated. + if _, ok := na.nodes[node.ID][networkAttachment.Network.ID]; !ok { return false } // If the network is not allocated, the node cannot be allocated. - localNet, ok := na.networks[node.Attachment.Network.ID] + localNet, ok := na.networks[networkAttachment.Network.ID] if !ok { return false } // Addresses empty, not allocated. - if len(node.Attachment.Addresses) == 0 { + if len(networkAttachment.Addresses) == 0 { return false } // The allocated IP address not found in local endpoint state. Not allocated. - if _, ok := localNet.endpoints[node.Attachment.Addresses[0]]; !ok { + if _, ok := localNet.endpoints[networkAttachment.Addresses[0]]; !ok { return false } return true } -// AllocateNode allocates the IP addresses for the network to which -// the node is attached. -func (na *cnmNetworkAllocator) AllocateNode(node *api.Node) error { - if err := na.allocateNetworkIPs(node.Attachment); err != nil { +// AllocateLBAttachment allocates the IP addresses for a LB in a network +// on a given node +func (na *cnmNetworkAllocator) AllocateLBAttachment(node *api.Node, networkAttachment *api.NetworkAttachment) error { + + if err := na.allocateNetworkIPs(networkAttachment); err != nil { return err } - na.nodes[node.ID] = struct{}{} + if na.nodes[node.ID] == nil { + na.nodes[node.ID] = make(map[string]struct{}) + } + na.nodes[node.ID][networkAttachment.Network.ID] = struct{}{} + return nil } -// DeallocateNode deallocates the IP addresses for the network to +// DeallocateLBAttachment deallocates the IP addresses for a LB in a network to // which the node is attached. -func (na *cnmNetworkAllocator) DeallocateNode(node *api.Node) error { - delete(na.nodes, node.ID) - return na.releaseEndpoints([]*api.NetworkAttachment{node.Attachment}) -} +func (na *cnmNetworkAllocator) DeallocateLBAttachment(node *api.Node, networkAttachment *api.NetworkAttachment) error { -// AllocateTask allocates all the endpoint resources for all the -// networks that a task is attached to. -func (na *cnmNetworkAllocator) AllocateTask(t *api.Task) error { - for i, nAttach := range t.Networks { - if localNet := na.getNetwork(nAttach.Network.ID); localNet != nil && localNet.isNodeLocal { - continue - } - if err := na.allocateNetworkIPs(nAttach); err != nil { - if err := na.releaseEndpoints(t.Networks[:i]); err != nil { - log.G(context.TODO()).WithError(err).Errorf("Failed to release IP addresses while rolling back allocation for task %s network %s", t.ID, nAttach.Network.ID) - } - return errors.Wrapf(err, "failed to allocate network IP for task %s network %s", t.ID, nAttach.Network.ID) - } + delete(na.nodes[node.ID], networkAttachment.Network.ID) + if len(na.nodes[node.ID]) == 0 { + delete(na.nodes, node.ID) } - na.tasks[t.ID] = struct{}{} - - return nil -} - -// DeallocateTask releases all the endpoint resources for all the -// networks that a task is attached to. -func (na *cnmNetworkAllocator) DeallocateTask(t *api.Task) error { - delete(na.tasks, t.ID) - return na.releaseEndpoints(t.Networks) + return na.releaseEndpoints([]*api.NetworkAttachment{networkAttachment}) } func (na *cnmNetworkAllocator) releaseEndpoints(networks []*api.NetworkAttachment) error { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/allocator/network.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/allocator/network.go index c760ad53d..794e616c1 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/allocator/network.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/allocator/network.go @@ -154,11 +154,10 @@ func (a *Allocator) doNetworkInit(ctx context.Context) (err error) { // First, allocate objects that already have addresses associated with // them, to reserve these IP addresses in internal state. - if nc.ingressNetwork != nil { - if err := a.allocateNodes(ctx, true); err != nil { - return err - } + if err := a.allocateNodes(ctx, true); err != nil { + return err } + if err := a.allocateServices(ctx, true); err != nil { return err } @@ -166,12 +165,10 @@ func (a *Allocator) doNetworkInit(ctx context.Context) (err error) { return err } - // Now allocate objects that don't have addresses yet. - if nc.ingressNetwork != nil { - if err := a.allocateNodes(ctx, false); err != nil { - return err - } + if err := a.allocateNodes(ctx, false); err != nil { + return err } + if err := a.allocateServices(ctx, false); err != nil { return err } @@ -208,22 +205,22 @@ func (a *Allocator) doNetworkAlloc(ctx context.Context, ev events.Event) { }); err != nil { log.G(ctx).WithError(err).Errorf("Failed to commit allocation for network %s", n.ID) } - if IsIngressNetwork(n) { nc.ingressNetwork = n - err := a.allocateNodes(ctx, false) - if err != nil { - log.G(ctx).WithError(err).Error(err) - } + } + err := a.allocateNodes(ctx, false) + if err != nil { + log.G(ctx).WithError(err).Error(err) } case api.EventDeleteNetwork: n := v.Network.Copy() if IsIngressNetwork(n) && nc.ingressNetwork != nil && nc.ingressNetwork.ID == n.ID { nc.ingressNetwork = nil - if err := a.deallocateNodes(ctx); err != nil { - log.G(ctx).WithError(err).Error(err) - } + } + + if err := a.deallocateNodeAttachments(ctx, n.ID); err != nil { + log.G(ctx).WithError(err).Error(err) } // The assumption here is that all dependent objects @@ -361,33 +358,67 @@ func (a *Allocator) doNodeAlloc(ctx context.Context, ev events.Event) { nc := a.netCtx if isDelete { - if nc.nwkAllocator.IsNodeAllocated(node) { - if err := nc.nwkAllocator.DeallocateNode(node); err != nil { - log.G(ctx).WithError(err).Errorf("Failed freeing network resources for node %s", node.ID) - } else { - nc.somethingWasDeallocated = true + if err := a.deallocateNode(node); err != nil { + log.G(ctx).WithError(err).Errorf("Failed freeing network resources for node %s", node.ID) + } else { + nc.somethingWasDeallocated = true + } + } else { + allocatedNetworks, err := a.getAllocatedNetworks() + if err != nil { + log.G(ctx).WithError(err).Errorf("Error listing allocated networks in network %s", node.ID) + } + + isAllocated := a.allocateNode(ctx, node, false, allocatedNetworks) + + if isAllocated { + if err := a.store.Batch(func(batch *store.Batch) error { + return a.commitAllocatedNode(ctx, batch, node) + }); err != nil { + log.G(ctx).WithError(err).Errorf("Failed to commit allocation of network resources for node %s", node.ID) } } - return } +} - if !nc.nwkAllocator.IsNodeAllocated(node) && nc.ingressNetwork != nil { - if node.Attachment == nil { - node.Attachment = &api.NetworkAttachment{} - } +func isOverlayNetwork(n *api.Network) bool { + if n.DriverState != nil && n.DriverState.Name == "overlay" { + return true + } - node.Attachment.Network = nc.ingressNetwork.Copy() - if err := a.allocateNode(ctx, node); err != nil { - log.G(ctx).WithError(err).Errorf("Failed to allocate network resources for node %s", node.ID) - return - } + if n.Spec.DriverConfig != nil && n.Spec.DriverConfig.Name == "overlay" { + return true + } - if err := a.store.Batch(func(batch *store.Batch) error { - return a.commitAllocatedNode(ctx, batch, node) - }); err != nil { - log.G(ctx).WithError(err).Errorf("Failed to commit allocation of network resources for node %s", node.ID) + return false +} + +func (a *Allocator) getAllocatedNetworks() ([]*api.Network, error) { + var ( + err error + nc = a.netCtx + na = nc.nwkAllocator + allocatedNetworks []*api.Network + ) + + // Find allocated networks + var networks []*api.Network + a.store.View(func(tx store.ReadTx) { + networks, err = store.FindNetworks(tx, store.All) + }) + + if err != nil { + return nil, errors.Wrap(err, "error listing all networks in store while trying to allocate during init") + } + + for _, n := range networks { + + if isOverlayNetwork(n) && na.IsAllocated(n) { + allocatedNetworks = append(allocatedNetworks, n) } } + + return allocatedNetworks, nil } func (a *Allocator) allocateNodes(ctx context.Context, existingAddressesOnly bool) error { @@ -396,7 +427,6 @@ func (a *Allocator) allocateNodes(ctx context.Context, existingAddressesOnly boo allocatedNodes []*api.Node nodes []*api.Node err error - nc = a.netCtx ) a.store.View(func(tx store.ReadTx) { @@ -406,26 +436,16 @@ func (a *Allocator) allocateNodes(ctx context.Context, existingAddressesOnly boo return errors.Wrap(err, "error listing all nodes in store while trying to allocate network resources") } - for _, node := range nodes { - if nc.nwkAllocator.IsNodeAllocated(node) { - continue - } - - if node.Attachment == nil { - node.Attachment = &api.NetworkAttachment{} - } - - if existingAddressesOnly && len(node.Attachment.Addresses) == 0 { - continue - } + allocatedNetworks, err := a.getAllocatedNetworks() + if err != nil { + return errors.Wrap(err, "error listing all nodes in store while trying to allocate network resources") + } - node.Attachment.Network = nc.ingressNetwork.Copy() - if err := a.allocateNode(ctx, node); err != nil { - log.G(ctx).WithError(err).Errorf("Failed to allocate network resources for node %s", node.ID) - continue + for _, node := range nodes { + isAllocated := a.allocateNode(ctx, node, existingAddressesOnly, allocatedNetworks) + if isAllocated { + allocatedNodes = append(allocatedNodes, node) } - - allocatedNodes = append(allocatedNodes, node) } if err := a.store.Batch(func(batch *store.Batch) error { @@ -457,20 +477,89 @@ func (a *Allocator) deallocateNodes(ctx context.Context) error { } for _, node := range nodes { - if nc.nwkAllocator.IsNodeAllocated(node) { - if err := nc.nwkAllocator.DeallocateNode(node); err != nil { - log.G(ctx).WithError(err).Errorf("Failed freeing network resources for node %s", node.ID) - } else { - nc.somethingWasDeallocated = true + if err := a.deallocateNode(node); err != nil { + log.G(ctx).WithError(err).Errorf("Failed freeing network resources for node %s", node.ID) + } else { + nc.somethingWasDeallocated = true + } + if err := a.store.Batch(func(batch *store.Batch) error { + return a.commitAllocatedNode(ctx, batch, node) + }); err != nil { + log.G(ctx).WithError(err).Errorf("Failed to commit deallocation of network resources for node %s", node.ID) + } + } + + return nil +} + +func (a *Allocator) deallocateNodeAttachments(ctx context.Context, nid string) error { + var ( + nodes []*api.Node + nc = a.netCtx + err error + ) + + a.store.View(func(tx store.ReadTx) { + nodes, err = store.FindNodes(tx, store.All) + }) + if err != nil { + return fmt.Errorf("error listing all nodes in store while trying to free network resources") + } + + for _, node := range nodes { + + var networkAttachment *api.NetworkAttachment + var naIndex int + for index, na := range node.LbAttachments { + if na.Network.ID == nid { + networkAttachment = na + naIndex = index + break } - node.Attachment = nil - if err := a.store.Batch(func(batch *store.Batch) error { - return a.commitAllocatedNode(ctx, batch, node) - }); err != nil { + } + + if networkAttachment == nil { + log.G(ctx).Errorf("Failed to find network %s on node %s", nid, node.ID) + continue + } + + if nc.nwkAllocator.IsLBAttachmentAllocated(node, networkAttachment) { + if err := nc.nwkAllocator.DeallocateLBAttachment(node, networkAttachment); err != nil { log.G(ctx).WithError(err).Errorf("Failed to commit deallocation of network resources for node %s", node.ID) + } else { + + // Delete the lbattachment + node.LbAttachments[naIndex] = node.LbAttachments[len(node.LbAttachments)-1] + node.LbAttachments[len(node.LbAttachments)-1] = nil + node.LbAttachments = node.LbAttachments[:len(node.LbAttachments)-1] + + if err := a.store.Batch(func(batch *store.Batch) error { + return a.commitAllocatedNode(ctx, batch, node) + }); err != nil { + log.G(ctx).WithError(err).Errorf("Failed to commit deallocation of network resources for node %s", node.ID) + } + } } + } + return nil +} + +func (a *Allocator) deallocateNode(node *api.Node) error { + var ( + nc = a.netCtx + ) + + for _, na := range node.LbAttachments { + if nc.nwkAllocator.IsLBAttachmentAllocated(node, na) { + if err := nc.nwkAllocator.DeallocateLBAttachment(node, na); err != nil { + return err + } + } + } + + node.LbAttachments = nil return nil } @@ -758,8 +847,48 @@ func (a *Allocator) doTaskAlloc(ctx context.Context, ev events.Event) { nc.pendingTasks[t.ID] = t } -func (a *Allocator) allocateNode(ctx context.Context, node *api.Node) error { - return a.netCtx.nwkAllocator.AllocateNode(node) +func (a *Allocator) allocateNode(ctx context.Context, node *api.Node, existingAddressesOnly bool, networks []*api.Network) bool { + var allocated bool + + nc := a.netCtx + + for _, network := range networks { + + var lbAttachment *api.NetworkAttachment + for _, na := range node.LbAttachments { + if na.Network != nil && na.Network.ID == network.ID { + lbAttachment = na + break + } + } + + if lbAttachment != nil { + if nc.nwkAllocator.IsLBAttachmentAllocated(node, lbAttachment) { + continue + } + } + + if lbAttachment == nil { + lbAttachment = &api.NetworkAttachment{} + node.LbAttachments = append(node.LbAttachments, lbAttachment) + } + + if existingAddressesOnly && len(lbAttachment.Addresses) == 0 { + continue + } + + lbAttachment.Network = network.Copy() + if err := a.netCtx.nwkAllocator.AllocateLBAttachment(node, lbAttachment); err != nil { + log.G(ctx).WithError(err).Errorf("Failed to allocate network resources for node %s", node.ID) + // TODO: Should we add a unallocatedNode and retry allocating resources like we do for network, tasks, services? + // right now, we will only retry allocating network resources for the node when the node is updated. + continue + } + + allocated = true + } + return allocated + } func (a *Allocator) commitAllocatedNode(ctx context.Context, batch *store.Batch, node *api.Node) error { @@ -768,13 +897,13 @@ func (a *Allocator) commitAllocatedNode(ctx context.Context, batch *store.Batch, if err == store.ErrSequenceConflict { storeNode := store.GetNode(tx, node.ID) - storeNode.Attachment = node.Attachment.Copy() + storeNode.LbAttachments = node.LbAttachments err = store.UpdateNode(tx, storeNode) } return errors.Wrapf(err, "failed updating state in store transaction for node %s", node.ID) }); err != nil { - if err := a.netCtx.nwkAllocator.DeallocateNode(node); err != nil { + if err := a.deallocateNode(node); err != nil { log.G(ctx).WithError(err).Errorf("failed rolling back allocation of node %s", node.ID) } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/allocator/networkallocator/networkallocator.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/allocator/networkallocator/networkallocator.go index 04dd16812..5fc5801d4 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/allocator/networkallocator/networkallocator.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/allocator/networkallocator/networkallocator.go @@ -65,22 +65,6 @@ type NetworkAllocator interface { // allocations for its published ports in host (non ingress) mode HostPublishPortsNeedUpdate(s *api.Service) bool - // - // Node Allocation - // - - // IsNodeAllocated returns if the passed node has its network - // resources allocated or not. - IsNodeAllocated(node *api.Node) bool - - // AllocateNode allocates the IP addresses for the network to which - // the node is attached. - AllocateNode(node *api.Node) error - - // DeallocateNode deallocates the IP addresses for the network to - // which the node is attached. - DeallocateNode(node *api.Node) error - // // Task Allocation // @@ -96,6 +80,15 @@ type NetworkAllocator interface { // DeallocateTask releases all the endpoint resources for all the // networks that a task is attached to. DeallocateTask(t *api.Task) error + + // AllocateLBAttachment Allocates a load balancer endpoint for the node + AllocateLBAttachment(node *api.Node, networkAttachment *api.NetworkAttachment) error + + // DeallocateLBAttachment Deallocates a load balancer endpoint for the node + DeallocateLBAttachment(node *api.Node, networkAttachment *api.NetworkAttachment) error + + //IsLBAttachmentAllocated If lb endpoint is allocated on the node + IsLBAttachmentAllocated(node *api.Node, networkAttachment *api.NetworkAttachment) bool } // IsIngressNetwork check if the network is an ingress network diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/ca_rotation.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/ca_rotation.go index 41e9a4d97..5e8fa43ce 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/ca_rotation.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/ca_rotation.go @@ -63,7 +63,6 @@ func newRootRotationObject(ctx context.Context, securityConfig *ca.SecurityConfi return nil, grpc.Errorf(codes.InvalidArgument, "rotating from one external CA to a different external CA is not supported") default: // We need the same credentials but to connect to the original URLs (in case we are in the middle of a root rotation already) - externalCA := securityConfig.ExternalCA().Copy() var urls []string for _, c := range extCAs { if c.Protocol == api.ExternalCA_CAProtocolCFSSL { @@ -74,7 +73,11 @@ func newRootRotationObject(ctx context.Context, securityConfig *ca.SecurityConfi return nil, grpc.Errorf(codes.InvalidArgument, "must provide an external CA for the current external root CA to generate a cross-signed certificate") } - externalCA.UpdateURLs(urls...) + rootPool := x509.NewCertPool() + rootPool.AppendCertsFromPEM(apiRootCA.CACert) + + externalCAConfig := ca.NewExternalCATLSConfig(securityConfig.ClientTLSCreds.Config().Certificates, rootPool) + externalCA := ca.NewExternalCA(nil, externalCAConfig, urls...) crossSignedCert, err = externalCA.CrossSignRootCA(ctx, newCARootCA) } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/cluster.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/cluster.go index 7e9dea2ce..329313a95 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/cluster.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/cluster.go @@ -104,17 +104,14 @@ func (s *Server) UpdateCluster(ctx context.Context, request *api.UpdateClusterRe if cluster == nil { return grpc.Errorf(codes.NotFound, "cluster %s not found", request.ClusterID) } - // This ensures that we always have the latest security config, so our ca.SecurityConfig.RootCA and - // ca.SecurityConfig.externalCA objects are up-to-date with the current api.Cluster.RootCA and - // api.Cluster.Spec.ExternalCA objects, respectively. Note that if, during this update, the cluster gets - // updated again with different CA info and the security config gets changed under us, that's still fine because - // this cluster update would fail anyway due to its version being too low on write. - if err := s.scu.UpdateRootCA(ctx, cluster); err != nil { + // This ensures that we have the current rootCA with which to generate tokens (expiration doesn't matter + // for generating the tokens) + rootCA, err := ca.RootCAFromAPI(ctx, &cluster.RootCA, ca.DefaultNodeCertExpiration) + if err != nil { log.G(ctx).WithField( - "method", "(*controlapi.Server).UpdateCluster").WithError(err).Error("could not update security config") - return grpc.Errorf(codes.Internal, "could not update security config") + "method", "(*controlapi.Server).UpdateCluster").WithError(err).Error("invalid cluster root CA") + return grpc.Errorf(codes.Internal, "error loading cluster rootCA for update") } - rootCA := s.securityConfig.RootCA() cluster.Meta.Version = *request.ClusterVersion cluster.Spec = *request.Spec.Copy() @@ -122,10 +119,10 @@ func (s *Server) UpdateCluster(ctx context.Context, request *api.UpdateClusterRe expireBlacklistedCerts(cluster) if request.Rotation.WorkerJoinToken { - cluster.RootCA.JoinTokens.Worker = ca.GenerateJoinToken(rootCA) + cluster.RootCA.JoinTokens.Worker = ca.GenerateJoinToken(&rootCA) } if request.Rotation.ManagerJoinToken { - cluster.RootCA.JoinTokens.Manager = ca.GenerateJoinToken(rootCA) + cluster.RootCA.JoinTokens.Manager = ca.GenerateJoinToken(&rootCA) } updatedRootCA, err := validateCAConfig(ctx, s.securityConfig, cluster) diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/secret.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/secret.go index 2f8d2559c..bac4c102e 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/secret.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/secret.go @@ -158,6 +158,12 @@ func (s *Server) CreateSecret(ctx context.Context, request *api.CreateSecretRequ return nil, err } + if request.Spec.Driver != nil { // Check that the requested driver is valid + if _, err := s.dr.NewSecretDriver(request.Spec.Driver); err != nil { + return nil, err + } + } + secret := secretFromSecretSpec(request.Spec) // the store will handle name conflicts err := s.store.Update(func(tx store.Tx) error { return store.CreateSecret(tx, secret) diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/server.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/server.go index c2490ba00..c16e22917 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/server.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/controlapi/server.go @@ -5,6 +5,7 @@ import ( "github.com/docker/docker/pkg/plugingetter" "github.com/docker/swarmkit/ca" + "github.com/docker/swarmkit/manager/drivers" "github.com/docker/swarmkit/manager/state/raft" "github.com/docker/swarmkit/manager/state/store" ) @@ -18,18 +19,17 @@ type Server struct { store *store.MemoryStore raft *raft.Node securityConfig *ca.SecurityConfig - scu ca.APISecurityConfigUpdater pg plugingetter.PluginGetter + dr *drivers.DriverProvider } // NewServer creates a Cluster API server. -func NewServer(store *store.MemoryStore, raft *raft.Node, securityConfig *ca.SecurityConfig, - scu ca.APISecurityConfigUpdater, pg plugingetter.PluginGetter) *Server { +func NewServer(store *store.MemoryStore, raft *raft.Node, securityConfig *ca.SecurityConfig, pg plugingetter.PluginGetter, dr *drivers.DriverProvider) *Server { return &Server{ store: store, + dr: dr, raft: raft, securityConfig: securityConfig, - scu: scu, pg: pg, } } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/dispatcher/assignments.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/dispatcher/assignments.go index 4373e99d5..5a5634805 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/dispatcher/assignments.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/dispatcher/assignments.go @@ -11,20 +11,9 @@ import ( "github.com/sirupsen/logrus" ) -// Used as a key in tasksUsingDependency and changes. Only using the -// ID could cause (rare) collisions between different types of -// objects, so we also include the type of object in the key. -type objectType int - -const ( - typeTask objectType = iota - typeSecret - typeConfig -) - type typeAndID struct { id string - objType objectType + objType api.ResourceType } type assignmentSet struct { @@ -45,39 +34,78 @@ func newAssignmentSet(log *logrus.Entry, dp *drivers.DriverProvider) *assignment } } +func assignSecret(a *assignmentSet, readTx store.ReadTx, mapKey typeAndID, t *api.Task) { + a.tasksUsingDependency[mapKey] = make(map[string]struct{}) + secret, err := a.secret(readTx, t, mapKey.id) + if err != nil { + a.log.WithFields(logrus.Fields{ + "resource.type": "secret", + "secret.id": mapKey.id, + "error": err, + }).Debug("failed to fetch secret") + return + } + a.changes[mapKey] = &api.AssignmentChange{ + Assignment: &api.Assignment{ + Item: &api.Assignment_Secret{ + Secret: secret, + }, + }, + Action: api.AssignmentChange_AssignmentActionUpdate, + } +} + +func assignConfig(a *assignmentSet, readTx store.ReadTx, mapKey typeAndID) { + a.tasksUsingDependency[mapKey] = make(map[string]struct{}) + config := store.GetConfig(readTx, mapKey.id) + if config == nil { + a.log.WithFields(logrus.Fields{ + "resource.type": "config", + "config.id": mapKey.id, + }).Debug("config not found") + return + } + a.changes[mapKey] = &api.AssignmentChange{ + Assignment: &api.Assignment{ + Item: &api.Assignment_Config{ + Config: config, + }, + }, + Action: api.AssignmentChange_AssignmentActionUpdate, + } +} + func (a *assignmentSet) addTaskDependencies(readTx store.ReadTx, t *api.Task) { + for _, resourceRef := range t.Spec.ResourceReferences { + mapKey := typeAndID{objType: resourceRef.ResourceType, id: resourceRef.ResourceID} + if len(a.tasksUsingDependency[mapKey]) == 0 { + switch resourceRef.ResourceType { + case api.ResourceType_SECRET: + assignSecret(a, readTx, mapKey, t) + case api.ResourceType_CONFIG: + assignConfig(a, readTx, mapKey) + default: + a.log.WithField( + "resource.type", resourceRef.ResourceType, + ).Debug("invalid resource type for a task dependency, skipping") + continue + } + } + a.tasksUsingDependency[mapKey][t.ID] = struct{}{} + } + var secrets []*api.SecretReference container := t.Spec.GetContainer() if container != nil { secrets = container.Secrets } + for _, secretRef := range secrets { secretID := secretRef.SecretID - mapKey := typeAndID{objType: typeSecret, id: secretID} + mapKey := typeAndID{objType: api.ResourceType_SECRET, id: secretID} if len(a.tasksUsingDependency[mapKey]) == 0 { - a.tasksUsingDependency[mapKey] = make(map[string]struct{}) - - secret, err := a.secret(readTx, secretID) - if err != nil { - a.log.WithFields(logrus.Fields{ - "secret.id": secretID, - "secret.name": secretRef.SecretName, - "error": err, - }).Error("failed to fetch secret") - continue - } - - // If the secret was found, add this secret to - // our set that we send down. - a.changes[mapKey] = &api.AssignmentChange{ - Assignment: &api.Assignment{ - Item: &api.Assignment_Secret{ - Secret: secret, - }, - }, - Action: api.AssignmentChange_AssignmentActionUpdate, - } + assignSecret(a, readTx, mapKey, t) } a.tasksUsingDependency[mapKey][t.ID] = struct{}{} } @@ -88,30 +116,10 @@ func (a *assignmentSet) addTaskDependencies(readTx store.ReadTx, t *api.Task) { } for _, configRef := range configs { configID := configRef.ConfigID - mapKey := typeAndID{objType: typeConfig, id: configID} + mapKey := typeAndID{objType: api.ResourceType_CONFIG, id: configID} if len(a.tasksUsingDependency[mapKey]) == 0 { - a.tasksUsingDependency[mapKey] = make(map[string]struct{}) - - config := store.GetConfig(readTx, configID) - if config == nil { - a.log.WithFields(logrus.Fields{ - "config.id": configID, - "config.name": configRef.ConfigName, - }).Debug("config not found") - continue - } - - // If the config was found, add this config to - // our set that we send down. - a.changes[mapKey] = &api.AssignmentChange{ - Assignment: &api.Assignment{ - Item: &api.Assignment_Config{ - Config: config, - }, - }, - Action: api.AssignmentChange_AssignmentActionUpdate, - } + assignConfig(a, readTx, mapKey) } a.tasksUsingDependency[mapKey][t.ID] = struct{}{} } @@ -133,6 +141,35 @@ func (a *assignmentSet) releaseDependency(mapKey typeAndID, assignment *api.Assi func (a *assignmentSet) releaseTaskDependencies(t *api.Task) bool { var modified bool + + for _, resourceRef := range t.Spec.ResourceReferences { + var assignment *api.Assignment + switch resourceRef.ResourceType { + case api.ResourceType_SECRET: + assignment = &api.Assignment{ + Item: &api.Assignment_Secret{ + Secret: &api.Secret{ID: resourceRef.ResourceID}, + }, + } + case api.ResourceType_CONFIG: + assignment = &api.Assignment{ + Item: &api.Assignment_Config{ + Config: &api.Config{ID: resourceRef.ResourceID}, + }, + } + default: + a.log.WithField( + "resource.type", resourceRef.ResourceType, + ).Debug("invalid resource type for a task dependency, skipping") + continue + } + + mapKey := typeAndID{objType: resourceRef.ResourceType, id: resourceRef.ResourceID} + if a.releaseDependency(mapKey, assignment, t.ID) { + modified = true + } + } + container := t.Spec.GetContainer() var secrets []*api.SecretReference @@ -142,7 +179,7 @@ func (a *assignmentSet) releaseTaskDependencies(t *api.Task) bool { for _, secretRef := range secrets { secretID := secretRef.SecretID - mapKey := typeAndID{objType: typeSecret, id: secretID} + mapKey := typeAndID{objType: api.ResourceType_SECRET, id: secretID} assignment := &api.Assignment{ Item: &api.Assignment_Secret{ Secret: &api.Secret{ID: secretID}, @@ -160,7 +197,7 @@ func (a *assignmentSet) releaseTaskDependencies(t *api.Task) bool { for _, configRef := range configs { configID := configRef.ConfigID - mapKey := typeAndID{objType: typeConfig, id: configID} + mapKey := typeAndID{objType: api.ResourceType_CONFIG, id: configID} assignment := &api.Assignment{ Item: &api.Assignment_Config{ Config: &api.Config{ID: configID}, @@ -205,7 +242,7 @@ func (a *assignmentSet) addOrUpdateTask(readTx store.ReadTx, t *api.Task) bool { a.addTaskDependencies(readTx, t) } a.tasksMap[t.ID] = t - a.changes[typeAndID{objType: typeTask, id: t.ID}] = &api.AssignmentChange{ + a.changes[typeAndID{objType: api.ResourceType_TASK, id: t.ID}] = &api.AssignmentChange{ Assignment: &api.Assignment{ Item: &api.Assignment_Task{ Task: t, @@ -221,7 +258,7 @@ func (a *assignmentSet) removeTask(t *api.Task) bool { return false } - a.changes[typeAndID{objType: typeTask, id: t.ID}] = &api.AssignmentChange{ + a.changes[typeAndID{objType: api.ResourceType_TASK, id: t.ID}] = &api.AssignmentChange{ Assignment: &api.Assignment{ Item: &api.Assignment_Task{ Task: &api.Task{ID: t.ID}, @@ -254,7 +291,7 @@ func (a *assignmentSet) message() api.AssignmentsMessage { // secret populates the secret value from raft store. For external secrets, the value is populated // from the secret driver. -func (a *assignmentSet) secret(readTx store.ReadTx, secretID string) (*api.Secret, error) { +func (a *assignmentSet) secret(readTx store.ReadTx, task *api.Task, secretID string) (*api.Secret, error) { secret := store.GetSecret(readTx, secretID) if secret == nil { return nil, fmt.Errorf("secret not found") @@ -266,7 +303,7 @@ func (a *assignmentSet) secret(readTx store.ReadTx, secretID string) (*api.Secre if err != nil { return nil, err } - value, err := d.Get(&secret.Spec) + value, err := d.Get(&secret.Spec, task) if err != nil { return nil, err } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/dispatcher/dispatcher.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/dispatcher/dispatcher.go index cb630047b..8ad1df397 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/dispatcher/dispatcher.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/dispatcher/dispatcher.go @@ -18,6 +18,7 @@ import ( "github.com/docker/swarmkit/log" "github.com/docker/swarmkit/manager/drivers" "github.com/docker/swarmkit/manager/state/store" + "github.com/docker/swarmkit/protobuf/ptypes" "github.com/docker/swarmkit/remotes" "github.com/docker/swarmkit/watch" gogotypes "github.com/gogo/protobuf/types" @@ -127,6 +128,7 @@ type Dispatcher struct { cancel context.CancelFunc clusterUpdateQueue *watch.Queue dp *drivers.DriverProvider + securityConfig *ca.SecurityConfig taskUpdates map[string]*api.TaskStatus // indexed by task ID taskUpdatesLock sync.Mutex @@ -144,7 +146,7 @@ type Dispatcher struct { } // New returns Dispatcher with cluster interface(usually raft.Node). -func New(cluster Cluster, c *Config, dp *drivers.DriverProvider) *Dispatcher { +func New(cluster Cluster, c *Config, dp *drivers.DriverProvider, securityConfig *ca.SecurityConfig) *Dispatcher { d := &Dispatcher{ dp: dp, nodes: newNodeStore(c.HeartbeatPeriod, c.HeartbeatEpsilon, c.GracePeriodMultiplier, c.RateLimitPeriod), @@ -153,6 +155,7 @@ func New(cluster Cluster, c *Config, dp *drivers.DriverProvider) *Dispatcher { cluster: cluster, processUpdatesTrigger: make(chan struct{}, 1), config: c, + securityConfig: securityConfig, } d.processUpdatesCond = sync.NewCond(&d.processUpdatesLock) @@ -630,6 +633,8 @@ func (d *Dispatcher) processUpdates(ctx context.Context) { } task.Status = *status + task.Status.AppliedBy = d.securityConfig.ClientTLSCreds.NodeID() + task.Status.AppliedAt = ptypes.MustTimestampProto(time.Now()) if err := store.UpdateTask(tx, task); err != nil { logger.WithError(err).Error("failed to update task status") return nil diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/drivers/secrets.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/drivers/secrets.go index 9c8ccc7d0..2e7bc392b 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/drivers/secrets.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/drivers/secrets.go @@ -26,12 +26,45 @@ func NewSecretDriver(plugin plugingetter.CompatPlugin) *SecretDriver { } // Get gets a secret from the secret provider -func (d *SecretDriver) Get(spec *api.SecretSpec) ([]byte, error) { +func (d *SecretDriver) Get(spec *api.SecretSpec, task *api.Task) ([]byte, error) { if spec == nil { - return nil, fmt.Errorf("spec is nil") + return nil, fmt.Errorf("secret spec is nil") } + if task == nil { + return nil, fmt.Errorf("task is nil") + } + var secretResp SecretsProviderResponse - secretReq := &SecretsProviderRequest{Name: spec.Annotations.Name} + secretReq := &SecretsProviderRequest{ + SecretName: spec.Annotations.Name, + ServiceName: task.ServiceAnnotations.Name, + ServiceLabels: task.ServiceAnnotations.Labels, + } + container := task.Spec.GetContainer() + if container != nil { + secretReq.ServiceHostname = container.Hostname + } + + if task.Endpoint != nil && task.Endpoint.Spec != nil { + secretReq.ServiceEndpointSpec = &EndpointSpec{ + Mode: int32(task.Endpoint.Spec.Mode), + } + for _, p := range task.Endpoint.Spec.Ports { + if p == nil { + continue + } + secretReq.ServiceEndpointSpec.Ports = + append(secretReq.ServiceEndpointSpec.Ports, + PortConfig{ + Name: p.Name, + Protocol: int32(p.Protocol), + PublishedPort: p.PublishedPort, + TargetPort: p.TargetPort, + PublishMode: int32(p.PublishMode), + }) + } + } + err := d.plugin.Client().Call(SecretsProviderAPI, secretReq, &secretResp) if err != nil { return nil, err @@ -40,16 +73,38 @@ func (d *SecretDriver) Get(spec *api.SecretSpec) ([]byte, error) { return nil, fmt.Errorf(secretResp.Err) } // Assign the secret value - return []byte(secretResp.Value), nil + return secretResp.Value, nil } // SecretsProviderRequest is the secrets provider request. type SecretsProviderRequest struct { - Name string `json:"name"` // Name is the name of the secret plugin + SecretName string `json:",omitempty"` // SecretName is the name of the secret to request from the plugin + ServiceHostname string `json:",omitempty"` // ServiceHostname is the hostname of the service, can be used for x509 certificate + ServiceName string `json:",omitempty"` // ServiceName is the name of the service that requested the secret + ServiceLabels map[string]string `json:",omitempty"` // ServiceLabels capture environment names and other metadata + ServiceEndpointSpec *EndpointSpec `json:",omitempty"` // ServiceEndpointSpec holds the specification for endpoints } // SecretsProviderResponse is the secrets provider response. type SecretsProviderResponse struct { - Value string `json:"value"` // Value is the value of the secret - Err string `json:"err"` // Err is the error response of the plugin + Value []byte `json:",omitempty"` // Value is the value of the secret + Err string `json:",omitempty"` // Err is the error response of the plugin +} + +// EndpointSpec represents the spec of an endpoint. +type EndpointSpec struct { + Mode int32 `json:",omitempty"` + Ports []PortConfig `json:",omitempty"` +} + +// PortConfig represents the config of a port. +type PortConfig struct { + Name string `json:",omitempty"` + Protocol int32 `json:",omitempty"` + // TargetPort is the port inside the container + TargetPort uint32 `json:",omitempty"` + // PublishedPort is the port on the swarm hosts + PublishedPort uint32 `json:",omitempty"` + // PublishMode is the mode in which port is published + PublishMode int32 `json:",omitempty"` } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/logbroker/broker.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/logbroker/broker.go index 7f064bb91..860b55c30 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/logbroker/broker.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/logbroker/broker.go @@ -57,12 +57,12 @@ func New(store *store.MemoryStore) *LogBroker { } } -// Run the log broker -func (lb *LogBroker) Run(ctx context.Context) error { +// Start starts the log broker +func (lb *LogBroker) Start(ctx context.Context) error { lb.mu.Lock() + defer lb.mu.Unlock() if lb.cancelAll != nil { - lb.mu.Unlock() return errAlreadyRunning } @@ -71,12 +71,7 @@ func (lb *LogBroker) Run(ctx context.Context) error { lb.subscriptionQueue = watch.NewQueue() lb.registeredSubscriptions = make(map[string]*subscription) lb.subscriptionsByNode = make(map[string]map[*subscription]struct{}) - lb.mu.Unlock() - - select { - case <-lb.pctx.Done(): - return lb.pctx.Err() - } + return nil } // Stop stops the log broker @@ -234,8 +229,15 @@ func (lb *LogBroker) SubscribeLogs(request *api.SubscribeLogsRequest, stream api return err } + lb.mu.Lock() + pctx := lb.pctx + lb.mu.Unlock() + if pctx == nil { + return errNotRunning + } + subscription := lb.newSubscription(request.Selector, request.Options) - subscription.Run(lb.pctx) + subscription.Run(pctx) defer subscription.Stop() log := log.G(ctx).WithFields( @@ -257,8 +259,8 @@ func (lb *LogBroker) SubscribeLogs(request *api.SubscribeLogsRequest, stream api select { case <-ctx.Done(): return ctx.Err() - case <-lb.pctx.Done(): - return lb.pctx.Err() + case <-pctx.Done(): + return pctx.Err() case event := <-publishCh: publish := event.(*logMessage) if publish.completed { @@ -308,6 +310,13 @@ func (lb *LogBroker) ListenSubscriptions(request *api.ListenSubscriptionsRequest return err } + lb.mu.Lock() + pctx := lb.pctx + lb.mu.Unlock() + if pctx == nil { + return errNotRunning + } + lb.nodeConnected(remote.NodeID) defer lb.nodeDisconnected(remote.NodeID) @@ -329,7 +338,7 @@ func (lb *LogBroker) ListenSubscriptions(request *api.ListenSubscriptionsRequest select { case <-stream.Context().Done(): return stream.Context().Err() - case <-lb.pctx.Done(): + case <-pctx.Done(): return nil default: } @@ -362,7 +371,7 @@ func (lb *LogBroker) ListenSubscriptions(request *api.ListenSubscriptionsRequest } case <-stream.Context().Done(): return stream.Context().Err() - case <-lb.pctx.Done(): + case <-pctx.Done(): return nil } } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/manager.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/manager.go index 0b64a9a69..d3e88fd64 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/manager.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/manager.go @@ -16,6 +16,7 @@ import ( "github.com/cloudflare/cfssl/helpers" "github.com/docker/docker/pkg/plugingetter" "github.com/docker/go-events" + gmetrics "github.com/docker/go-metrics" "github.com/docker/swarmkit/api" "github.com/docker/swarmkit/ca" "github.com/docker/swarmkit/connectionbroker" @@ -87,7 +88,11 @@ type Config struct { // cluster to join. JoinRaft string - // Top-level state directory + // ForceJoin causes us to invoke raft's Join RPC even if already part + // of a cluster. + ForceJoin bool + + // StateDir is the top-level state directory StateDir string // ForceNewCluster defines if we have to force a new cluster @@ -130,6 +135,7 @@ type Manager struct { caserver *ca.Server dispatcher *dispatcher.Dispatcher logbroker *logbroker.LogBroker + watchServer *watchapi.Server replicatedOrchestrator *replicated.Orchestrator globalOrchestrator *global.Orchestrator taskReaper *taskreaper.TaskReaper @@ -159,6 +165,16 @@ type Manager struct { errServe chan error } +var ( + leaderMetric gmetrics.Gauge +) + +func init() { + ns := gmetrics.NewNamespace("swarm", "manager", nil) + leaderMetric = ns.NewGauge("leader", "Indicates if this manager node is a leader", "") + gmetrics.Register(ns) +} + type closeOnceListener struct { once sync.Once net.Listener @@ -202,6 +218,7 @@ func New(config *Config) (*Manager, error) { newNodeOpts := raft.NodeOptions{ ID: config.SecurityConfig.ClientTLSCreds.NodeID(), JoinAddr: config.JoinRaft, + ForceJoin: config.ForceJoin, Config: raftCfg, StateDir: raftStateDir, ForceNewCluster: config.ForceNewCluster, @@ -218,9 +235,10 @@ func New(config *Config) (*Manager, error) { m := &Manager{ config: *config, - caserver: ca.NewServer(raftNode.MemoryStore(), config.SecurityConfig, config.RootCAPaths), - dispatcher: dispatcher.New(raftNode, dispatcher.DefaultConfig(), drivers.New(config.PluginGetter)), + caserver: ca.NewServer(raftNode.MemoryStore(), config.SecurityConfig), + dispatcher: dispatcher.New(raftNode, dispatcher.DefaultConfig(), drivers.New(config.PluginGetter), config.SecurityConfig), logbroker: logbroker.New(raftNode.MemoryStore()), + watchServer: watchapi.NewServer(raftNode.MemoryStore()), server: grpc.NewServer(opts...), localserver: grpc.NewServer(opts...), raftNode: raftNode, @@ -397,14 +415,13 @@ func (m *Manager) Run(parent context.Context) error { return err } - baseControlAPI := controlapi.NewServer(m.raftNode.MemoryStore(), m.raftNode, m.config.SecurityConfig, m.caserver, m.config.PluginGetter) - baseWatchAPI := watchapi.NewServer(m.raftNode.MemoryStore()) + baseControlAPI := controlapi.NewServer(m.raftNode.MemoryStore(), m.raftNode, m.config.SecurityConfig, m.config.PluginGetter, drivers.New(m.config.PluginGetter)) baseResourceAPI := resourceapi.New(m.raftNode.MemoryStore()) healthServer := health.NewHealthServer() localHealthServer := health.NewHealthServer() authenticatedControlAPI := api.NewAuthenticatedWrapperControlServer(baseControlAPI, authorize) - authenticatedWatchAPI := api.NewAuthenticatedWrapperWatchServer(baseWatchAPI, authorize) + authenticatedWatchAPI := api.NewAuthenticatedWrapperWatchServer(m.watchServer, authorize) authenticatedResourceAPI := api.NewAuthenticatedWrapperResourceAllocatorServer(baseResourceAPI, authorize) authenticatedLogsServerAPI := api.NewAuthenticatedWrapperLogsServer(m.logbroker, authorize) authenticatedLogBrokerAPI := api.NewAuthenticatedWrapperLogBrokerServer(m.logbroker, authorize) @@ -477,7 +494,7 @@ func (m *Manager) Run(parent context.Context) error { grpc_prometheus.Register(m.server) api.RegisterControlServer(m.localserver, localProxyControlAPI) - api.RegisterWatchServer(m.localserver, baseWatchAPI) + api.RegisterWatchServer(m.localserver, m.watchServer) api.RegisterLogsServer(m.localserver, localProxyLogsAPI) api.RegisterHealthServer(m.localserver, localHealthServer) api.RegisterDispatcherServer(m.localserver, localProxyDispatcherAPI) @@ -490,6 +507,10 @@ func (m *Manager) Run(parent context.Context) error { healthServer.SetServingStatus("Raft", api.HealthCheckResponse_NOT_SERVING) localHealthServer.SetServingStatus("ControlAPI", api.HealthCheckResponse_NOT_SERVING) + if err := m.watchServer.Start(ctx); err != nil { + log.G(ctx).WithError(err).Error("watch server failed to start") + } + go m.serveListener(ctx, m.remoteListener) go m.serveListener(ctx, m.controlListener) @@ -565,8 +586,8 @@ func (m *Manager) Run(parent context.Context) error { const stopTimeout = 8 * time.Second // Stop stops the manager. It immediately closes all open connections and -// active RPCs as well as stopping the scheduler. If clearData is set, the -// raft logs, snapshots, and keys will be erased. +// active RPCs as well as stopping the manager's subsystems. If clearData is +// set, the raft logs, snapshots, and keys will be erased. func (m *Manager) Stop(ctx context.Context, clearData bool) { log.G(ctx).Info("Stopping manager") // It's not safe to start shutting down while the manager is still @@ -600,6 +621,7 @@ func (m *Manager) Stop(ctx context.Context, clearData bool) { m.dispatcher.Stop() m.logbroker.Stop() + m.watchServer.Stop() m.caserver.Stop() if m.allocator != nil { @@ -709,16 +731,14 @@ func (m *Manager) updateKEK(ctx context.Context, cluster *api.Cluster) error { func (m *Manager) watchForClusterChanges(ctx context.Context) error { clusterID := m.config.SecurityConfig.ClientTLSCreds.Organization() + var cluster *api.Cluster clusterWatch, clusterWatchCancel, err := store.ViewAndWatch(m.raftNode.MemoryStore(), func(tx store.ReadTx) error { - cluster := store.GetCluster(tx, clusterID) + cluster = store.GetCluster(tx, clusterID) if cluster == nil { return fmt.Errorf("unable to get current cluster") } - if err := m.caserver.UpdateRootCA(ctx, cluster); err != nil { - log.G(ctx).WithError(err).Error("could not update security config") - } - return m.updateKEK(ctx, cluster) + return nil }, api.EventUpdateCluster{ Cluster: &api.Cluster{ID: clusterID}, @@ -728,14 +748,15 @@ func (m *Manager) watchForClusterChanges(ctx context.Context) error { if err != nil { return err } + if err := m.updateKEK(ctx, cluster); err != nil { + return err + } + go func() { for { select { case event := <-clusterWatch: clusterEvent := event.(api.EventUpdateCluster) - if err := m.caserver.UpdateRootCA(ctx, clusterEvent.Cluster); err != nil { - log.G(ctx).WithError(err).Error("could not update security config") - } m.updateKEK(ctx, clusterEvent.Cluster) case <-ctx.Done(): clusterWatchCancel() @@ -863,8 +884,10 @@ func (m *Manager) handleLeadershipEvents(ctx context.Context, leadershipCh chan if newState == raft.IsLeader { m.becomeLeader(ctx) + leaderMetric.Set(1) } else if newState == raft.IsFollower { m.becomeFollower() + leaderMetric.Set(0) } m.mu.Unlock() case <-ctx.Done(): @@ -1001,11 +1024,9 @@ func (m *Manager) becomeLeader(ctx context.Context) { } }(m.dispatcher) - go func(lb *logbroker.LogBroker) { - if err := lb.Run(ctx); err != nil { - log.G(ctx).WithError(err).Error("LogBroker exited with an error") - } - }(m.logbroker) + if err := m.logbroker.Start(ctx); err != nil { + log.G(ctx).WithError(err).Error("LogBroker failed to start") + } go func(server *ca.Server) { if err := server.Run(ctx); err != nil { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/global/global.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/global/global.go index b89a105fe..a1d2873e8 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/global/global.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/global/global.go @@ -156,25 +156,12 @@ func (g *Orchestrator) Run(ctx context.Context) error { g.reconcileOneNode(ctx, v.Node) case api.EventUpdateNode: g.updateNode(v.Node) - switch v.Node.Status.State { - // NodeStatus_DISCONNECTED is a transient state, no need to make any change - case api.NodeStatus_DOWN: - g.foreachTaskFromNode(ctx, v.Node, g.shutdownTask) - case api.NodeStatus_READY: - // node could come back to READY from DOWN or DISCONNECT - g.reconcileOneNode(ctx, v.Node) - } + g.reconcileOneNode(ctx, v.Node) case api.EventDeleteNode: g.foreachTaskFromNode(ctx, v.Node, g.deleteTask) delete(g.nodes, v.Node.ID) case api.EventUpdateTask: g.handleTaskChange(ctx, v.Task) - case api.EventDeleteTask: - // CLI allows deleting task - if _, exists := g.globalServices[v.Task.ServiceID]; !exists { - continue - } - g.reconcileServicesOneNode(ctx, []string{v.Task.ServiceID}, v.Task.NodeID) } case <-g.stopChan: return nil @@ -216,7 +203,7 @@ func (g *Orchestrator) handleTaskChange(ctx context.Context, t *api.Task) { if _, exists := g.globalServices[t.ServiceID]; !exists { return } - // if a task's DesiredState has past running, which + // if a task's DesiredState has passed running, it // means the task has been processed if t.DesiredState > api.TaskStateRunning { return @@ -264,33 +251,41 @@ func (g *Orchestrator) foreachTaskFromNode(ctx context.Context, node *api.Node, } func (g *Orchestrator) reconcileServices(ctx context.Context, serviceIDs []string) { - nodeCompleted := make(map[string]map[string]struct{}) nodeTasks := make(map[string]map[string][]*api.Task) g.store.View(func(tx store.ReadTx) { for _, serviceID := range serviceIDs { + service := g.globalServices[serviceID].Service + if service == nil { + continue + } + tasks, err := store.FindTasks(tx, store.ByServiceID(serviceID)) if err != nil { log.G(ctx).WithError(err).Errorf("global orchestrator: reconcileServices failed finding tasks for service %s", serviceID) continue } - // a node may have completed this service - nodeCompleted[serviceID] = make(map[string]struct{}) // nodeID -> task list nodeTasks[serviceID] = make(map[string][]*api.Task) for _, t := range tasks { - if t.DesiredState <= api.TaskStateRunning { - // Collect all running instances of this service - nodeTasks[serviceID][t.NodeID] = append(nodeTasks[serviceID][t.NodeID], t) + nodeTasks[serviceID][t.NodeID] = append(nodeTasks[serviceID][t.NodeID], t) + } + + // Keep all runnable instances of this service, + // and instances that were not be restarted due + // to restart policy but may be updated if the + // service spec changed. + for nodeID, slot := range nodeTasks[serviceID] { + updatable := g.restarts.UpdatableTasksInSlot(ctx, slot, g.globalServices[serviceID].Service) + if len(updatable) != 0 { + nodeTasks[serviceID][nodeID] = updatable } else { - // for finished tasks, check restartPolicy - if isTaskCompleted(t, orchestrator.RestartCondition(t)) { - nodeCompleted[serviceID][t.NodeID] = struct{}{} - } + delete(nodeTasks[serviceID], nodeID) } } + } }) @@ -311,9 +306,7 @@ func (g *Orchestrator) reconcileServices(ctx context.Context, serviceIDs []strin ntasks := nodeTasks[serviceID][nodeID] delete(nodeTasks[serviceID], nodeID) - // if restart policy considers this node has finished its task - // it should remove all running tasks - if _, exists := nodeCompleted[serviceID][nodeID]; exists || !meetsConstraints { + if !meetsConstraints { g.shutdownTasks(ctx, batch, ntasks) continue } @@ -357,7 +350,7 @@ func (g *Orchestrator) reconcileServices(ctx context.Context, serviceIDs []strin // updateNode updates g.nodes based on the current node value func (g *Orchestrator) updateNode(node *api.Node) { - if node.Spec.Availability == api.NodeAvailabilityDrain { + if node.Spec.Availability == api.NodeAvailabilityDrain || node.Status.State == api.NodeStatus_DOWN { delete(g.nodes, node.ID) } else { g.nodes[node.ID] = node @@ -381,27 +374,27 @@ func (g *Orchestrator) updateService(service *api.Service) { // reconcileOneNode checks all global services on one node func (g *Orchestrator) reconcileOneNode(ctx context.Context, node *api.Node) { if node.Spec.Availability == api.NodeAvailabilityDrain { - log.G(ctx).Debugf("global orchestrator: node %s in drain state, removing tasks from it", node.ID) + log.G(ctx).Debugf("global orchestrator: node %s in drain state, shutting down its tasks", node.ID) g.foreachTaskFromNode(ctx, node, g.shutdownTask) return } - var serviceIDs []string - for id := range g.globalServices { - serviceIDs = append(serviceIDs, id) + if node.Status.State == api.NodeStatus_DOWN { + log.G(ctx).Debugf("global orchestrator: node %s is down, shutting down its tasks", node.ID) + g.foreachTaskFromNode(ctx, node, g.shutdownTask) + return } - g.reconcileServicesOneNode(ctx, serviceIDs, node.ID) -} -// reconcileServicesOneNode checks the specified services on one node -func (g *Orchestrator) reconcileServicesOneNode(ctx context.Context, serviceIDs []string, nodeID string) { - node, exists := g.nodes[nodeID] + if node.Spec.Availability == api.NodeAvailabilityPause { + // the node is paused, so we won't add or update tasks + return + } + + node, exists := g.nodes[node.ID] if !exists { return } - // whether each service has completed on the node - completed := make(map[string]bool) // tasks by service tasks := make(map[string][]*api.Task) @@ -411,53 +404,44 @@ func (g *Orchestrator) reconcileServicesOneNode(ctx context.Context, serviceIDs ) g.store.View(func(tx store.ReadTx) { - tasksOnNode, err = store.FindTasks(tx, store.ByNodeID(nodeID)) + tasksOnNode, err = store.FindTasks(tx, store.ByNodeID(node.ID)) }) if err != nil { - log.G(ctx).WithError(err).Errorf("global orchestrator: reconcile failed finding tasks on node %s", nodeID) + log.G(ctx).WithError(err).Errorf("global orchestrator: reconcile failed finding tasks on node %s", node.ID) return } - for _, serviceID := range serviceIDs { + for serviceID, service := range g.globalServices { for _, t := range tasksOnNode { if t.ServiceID != serviceID { continue } - if t.DesiredState <= api.TaskStateRunning { - tasks[serviceID] = append(tasks[serviceID], t) + tasks[serviceID] = append(tasks[serviceID], t) + } + + // Keep all runnable instances of this service, + // and instances that were not be restarted due + // to restart policy but may be updated if the + // service spec changed. + for serviceID, slot := range tasks { + updatable := g.restarts.UpdatableTasksInSlot(ctx, slot, service.Service) + + if len(updatable) != 0 { + tasks[serviceID] = updatable } else { - if isTaskCompleted(t, orchestrator.RestartCondition(t)) { - completed[serviceID] = true - } + delete(tasks, serviceID) } } } err = g.store.Batch(func(batch *store.Batch) error { - for _, serviceID := range serviceIDs { - service, exists := g.globalServices[serviceID] - if !exists { - continue - } - + for serviceID, service := range g.globalServices { if !constraint.NodeMatches(service.constraints, node) { continue } - // if restart policy considers this node has finished its task - // it should remove all running tasks - if completed[serviceID] { - g.shutdownTasks(ctx, batch, tasks[serviceID]) - continue - } - - if node.Spec.Availability == api.NodeAvailabilityPause { - // the node is paused, so we won't add or update tasks - continue - } - if len(tasks) == 0 { - g.addTask(ctx, batch, service.Service, nodeID) + g.addTask(ctx, batch, service.Service, node.ID) } else { // If task is out of date, update it. This can happen // on node reconciliation if, for example, we pause a @@ -487,7 +471,7 @@ func (g *Orchestrator) reconcileServicesOneNode(ctx context.Context, serviceIDs } if len(cleanTasks) == 0 { - g.addTask(ctx, batch, service.Service, nodeID) + g.addTask(ctx, batch, service.Service, node.ID) } else { dirtyTasks = append(dirtyTasks, cleanTasks[1:]...) } @@ -523,7 +507,9 @@ func (g *Orchestrator) tickTasks(ctx context.Context) { if !nodeExists || !serviceExists { return nil } - if !constraint.NodeMatches(serviceEntry.constraints, node) { + + if node.Spec.Availability == api.NodeAvailabilityPause || + !constraint.NodeMatches(serviceEntry.constraints, node) { t.DesiredState = api.TaskStateShutdown return store.UpdateTask(tx, t) } @@ -592,6 +578,14 @@ func (g *Orchestrator) IsRelatedService(service *api.Service) bool { return orchestrator.IsGlobalService(service) } +// SlotTuple returns a slot tuple for the global service task. +func (g *Orchestrator) SlotTuple(t *api.Task) orchestrator.SlotTuple { + return orchestrator.SlotTuple{ + ServiceID: t.ServiceID, + NodeID: t.NodeID, + } +} + func isTaskCompleted(t *api.Task, restartPolicy api.RestartPolicy_RestartCondition) bool { if t == nil || t.DesiredState <= api.TaskStateRunning { return false diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/replicated/services.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/replicated/services.go index 101976d96..f4d0511f8 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/replicated/services.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/replicated/services.go @@ -87,7 +87,7 @@ func (r *Orchestrator) resolveService(ctx context.Context, task *api.Task) *api. } func (r *Orchestrator) reconcile(ctx context.Context, service *api.Service) { - runningSlots, deadSlots, err := orchestrator.GetRunnableAndDeadSlots(r.store, service.ID) + runningSlots, deadSlots, err := r.updatableAndDeadSlots(ctx, service) if err != nil { log.G(ctx).WithError(err).Errorf("reconcile failed finding tasks") return diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/replicated/slot.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/replicated/slot.go index 1f1fd3eca..bdc25d9d7 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/replicated/slot.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/replicated/slot.go @@ -3,6 +3,8 @@ package replicated import ( "github.com/docker/swarmkit/api" "github.com/docker/swarmkit/manager/orchestrator" + "github.com/docker/swarmkit/manager/state/store" + "golang.org/x/net/context" ) type slotsByRunningState []orchestrator.Slot @@ -53,3 +55,46 @@ func (is slotsByIndex) Less(i, j int) bool { } return is[i].index < is[j].index } + +// updatableAndDeadSlots returns two maps of slots. The first contains slots +// that have at least one task with a desired state above NEW and lesser or +// equal to RUNNING, or a task that shouldn't be restarted. The second contains +// all other slots with at least one task. +func (r *Orchestrator) updatableAndDeadSlots(ctx context.Context, service *api.Service) (map[uint64]orchestrator.Slot, map[uint64]orchestrator.Slot, error) { + var ( + tasks []*api.Task + err error + ) + r.store.View(func(tx store.ReadTx) { + tasks, err = store.FindTasks(tx, store.ByServiceID(service.ID)) + }) + if err != nil { + return nil, nil, err + } + + updatableSlots := make(map[uint64]orchestrator.Slot) + for _, t := range tasks { + updatableSlots[t.Slot] = append(updatableSlots[t.Slot], t) + } + + deadSlots := make(map[uint64]orchestrator.Slot) + for slotID, slot := range updatableSlots { + updatable := r.restarts.UpdatableTasksInSlot(ctx, slot, service) + if len(updatable) != 0 { + updatableSlots[slotID] = updatable + } else { + delete(updatableSlots, slotID) + deadSlots[slotID] = slot + } + } + + return updatableSlots, deadSlots, nil +} + +// SlotTuple returns a slot tuple for the replicated service task. +func (r *Orchestrator) SlotTuple(t *api.Task) orchestrator.SlotTuple { + return orchestrator.SlotTuple{ + ServiceID: t.ServiceID, + Slot: t.Slot, + } +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/restart/restart.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/restart/restart.go index 6167552d4..6af44b734 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/restart/restart.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/restart/restart.go @@ -30,6 +30,13 @@ type instanceRestartInfo struct { // Restart.MaxAttempts and Restart.Window are both // nonzero. restartedInstances *list.List + // Why is specVersion in this structure and not in the map key? While + // putting it in the key would be a very simple solution, it wouldn't + // be easy to clean up map entries corresponding to old specVersions. + // Making the key version-agnostic and clearing the value whenever the + // version changes avoids the issue of stale map entries for old + // versions. + specVersion api.Version } type delayedStart struct { @@ -42,20 +49,13 @@ type delayedStart struct { waiter bool } -type instanceTuple struct { - instance uint64 // unset for global tasks - serviceID string - nodeID string // unset for replicated tasks -} - // Supervisor initiates and manages restarts. It's responsible for // delaying restarts when applicable. type Supervisor struct { mu sync.Mutex store *store.MemoryStore delays map[string]*delayedStart - history map[instanceTuple]*instanceRestartInfo - historyByService map[string]map[instanceTuple]struct{} + historyByService map[string]map[orchestrator.SlotTuple]*instanceRestartInfo TaskTimeout time.Duration } @@ -64,8 +64,7 @@ func NewSupervisor(store *store.MemoryStore) *Supervisor { return &Supervisor{ store: store, delays: make(map[string]*delayedStart), - history: make(map[instanceTuple]*instanceRestartInfo), - historyByService: make(map[string]map[instanceTuple]struct{}), + historyByService: make(map[string]map[orchestrator.SlotTuple]*instanceRestartInfo), TaskTimeout: defaultOldTaskTimeout, } } @@ -180,15 +179,21 @@ func (r *Supervisor) Restart(ctx context.Context, tx store.Tx, cluster *api.Clus return err } - r.recordRestartHistory(restartTask) + tuple := orchestrator.SlotTuple{ + Slot: restartTask.Slot, + ServiceID: restartTask.ServiceID, + NodeID: restartTask.NodeID, + } + r.RecordRestartHistory(tuple, restartTask) r.DelayStart(ctx, tx, &t, restartTask.ID, restartDelay, waitStop) return nil } +// shouldRestart returns true if a task should be restarted according to the +// restart policy. func (r *Supervisor) shouldRestart(ctx context.Context, t *api.Task, service *api.Service) bool { // TODO(aluzzardi): This function should not depend on `service`. - condition := orchestrator.RestartCondition(t) if condition != api.RestartOnAny && @@ -200,22 +205,22 @@ func (r *Supervisor) shouldRestart(ctx context.Context, t *api.Task, service *ap return true } - instanceTuple := instanceTuple{ - instance: t.Slot, - serviceID: t.ServiceID, + instanceTuple := orchestrator.SlotTuple{ + Slot: t.Slot, + ServiceID: t.ServiceID, } - // Instance is not meaningful for "global" tasks, so they need to be + // Slot is not meaningful for "global" tasks, so they need to be // indexed by NodeID. if orchestrator.IsGlobalService(service) { - instanceTuple.nodeID = t.NodeID + instanceTuple.NodeID = t.NodeID } r.mu.Lock() defer r.mu.Unlock() - restartInfo := r.history[instanceTuple] - if restartInfo == nil { + restartInfo := r.historyByService[t.ServiceID][instanceTuple] + if restartInfo == nil || (t.SpecVersion != nil && *t.SpecVersion != restartInfo.specVersion) { return true } @@ -232,8 +237,32 @@ func (r *Supervisor) shouldRestart(ctx context.Context, t *api.Task, service *ap log.G(ctx).WithError(err).Error("invalid restart lookback window") return restartInfo.totalRestarts < t.Spec.Restart.MaxAttempts } - lookback := time.Now().Add(-window) + var timestamp time.Time + // Prefer the manager's timestamp over the agent's, since manager + // clocks are more trustworthy. + if t.Status.AppliedAt != nil { + timestamp, err = gogotypes.TimestampFromProto(t.Status.AppliedAt) + if err != nil { + log.G(ctx).WithError(err).Error("invalid task status AppliedAt timestamp") + return restartInfo.totalRestarts < t.Spec.Restart.MaxAttempts + } + } else { + // It's safe to call TimestampFromProto with a nil timestamp + timestamp, err = gogotypes.TimestampFromProto(t.Status.Timestamp) + if t.Status.Timestamp == nil || err != nil { + log.G(ctx).WithError(err).Error("invalid task completion timestamp") + return restartInfo.totalRestarts < t.Spec.Restart.MaxAttempts + } + } + lookback := timestamp.Add(-window) + + numRestarts := uint64(restartInfo.restartedInstances.Len()) + + // Disregard any restarts that happened before the lookback window, + // and remove them from the linked list since they will no longer + // be relevant to figuring out if tasks should be restarted going + // forward. var next *list.Element for e := restartInfo.restartedInstances.Front(); e != nil; e = next { next = e.Next() @@ -242,51 +271,115 @@ func (r *Supervisor) shouldRestart(ctx context.Context, t *api.Task, service *ap break } restartInfo.restartedInstances.Remove(e) + numRestarts-- } - numRestarts := uint64(restartInfo.restartedInstances.Len()) + // Ignore restarts that didn't happen before the task we're looking at. + for e2 := restartInfo.restartedInstances.Back(); e2 != nil; e2 = e2.Prev() { + if e2.Value.(restartedInstance).timestamp.Before(timestamp) { + break + } + numRestarts-- + } - if numRestarts == 0 { + if restartInfo.restartedInstances.Len() == 0 { restartInfo.restartedInstances = nil } return numRestarts < t.Spec.Restart.MaxAttempts } -func (r *Supervisor) recordRestartHistory(restartTask *api.Task) { - if restartTask.Spec.Restart == nil || restartTask.Spec.Restart.MaxAttempts == 0 { +// UpdatableTasksInSlot returns the set of tasks that should be passed to the +// updater from this slot, or an empty slice if none should be. An updatable +// slot has either at least one task that with desired state <= RUNNING, or its +// most recent task has stopped running and should not be restarted. The latter +// case is for making sure that tasks that shouldn't normally be restarted will +// still be handled by rolling updates when they become outdated. There is a +// special case for rollbacks to make sure that a rollback always takes the +// service to a converged state, instead of ignoring tasks with the original +// spec that stopped running and shouldn't be restarted according to the +// restart policy. +func (r *Supervisor) UpdatableTasksInSlot(ctx context.Context, slot orchestrator.Slot, service *api.Service) orchestrator.Slot { + if len(slot) < 1 { + return nil + } + + var updatable orchestrator.Slot + for _, t := range slot { + if t.DesiredState <= api.TaskStateRunning { + updatable = append(updatable, t) + } + } + if len(updatable) > 0 { + return updatable + } + + if service.UpdateStatus != nil && service.UpdateStatus.State == api.UpdateStatus_ROLLBACK_STARTED { + return nil + } + + // Find most recent task + byTimestamp := orchestrator.TasksByTimestamp(slot) + newestIndex := 0 + for i := 1; i != len(slot); i++ { + if byTimestamp.Less(newestIndex, i) { + newestIndex = i + } + } + + if !r.shouldRestart(ctx, slot[newestIndex], service) { + return orchestrator.Slot{slot[newestIndex]} + } + return nil +} + +// RecordRestartHistory updates the historyByService map to reflect the restart +// of restartedTask. +func (r *Supervisor) RecordRestartHistory(tuple orchestrator.SlotTuple, replacementTask *api.Task) { + if replacementTask.Spec.Restart == nil || replacementTask.Spec.Restart.MaxAttempts == 0 { // No limit on the number of restarts, so no need to record // history. return } - tuple := instanceTuple{ - instance: restartTask.Slot, - serviceID: restartTask.ServiceID, - nodeID: restartTask.NodeID, - } r.mu.Lock() defer r.mu.Unlock() - if r.history[tuple] == nil { - r.history[tuple] = &instanceRestartInfo{} + serviceID := replacementTask.ServiceID + if r.historyByService[serviceID] == nil { + r.historyByService[serviceID] = make(map[orchestrator.SlotTuple]*instanceRestartInfo) + } + if r.historyByService[serviceID][tuple] == nil { + r.historyByService[serviceID][tuple] = &instanceRestartInfo{} } - restartInfo := r.history[tuple] - restartInfo.totalRestarts++ + restartInfo := r.historyByService[serviceID][tuple] - if r.historyByService[restartTask.ServiceID] == nil { - r.historyByService[restartTask.ServiceID] = make(map[instanceTuple]struct{}) + if replacementTask.SpecVersion != nil && *replacementTask.SpecVersion != restartInfo.specVersion { + // This task has a different SpecVersion from the one we're + // tracking. Most likely, the service was updated. Past failures + // shouldn't count against the new service definition, so clear + // the history for this instance. + *restartInfo = instanceRestartInfo{ + specVersion: *replacementTask.SpecVersion, + } } - r.historyByService[restartTask.ServiceID][tuple] = struct{}{} - if restartTask.Spec.Restart.Window != nil && (restartTask.Spec.Restart.Window.Seconds != 0 || restartTask.Spec.Restart.Window.Nanos != 0) { + restartInfo.totalRestarts++ + + if replacementTask.Spec.Restart.Window != nil && (replacementTask.Spec.Restart.Window.Seconds != 0 || replacementTask.Spec.Restart.Window.Nanos != 0) { if restartInfo.restartedInstances == nil { restartInfo.restartedInstances = list.New() } + // it's okay to call TimestampFromProto with a nil argument + timestamp, err := gogotypes.TimestampFromProto(replacementTask.Meta.CreatedAt) + if replacementTask.Meta.CreatedAt == nil || err != nil { + timestamp = time.Now() + } + restartedInstance := restartedInstance{ - timestamp: time.Now(), + timestamp: timestamp, } restartInfo.restartedInstances.PushBack(restartedInstance) @@ -323,7 +416,9 @@ func (r *Supervisor) DelayStart(ctx context.Context, _ store.Tx, oldTask *api.Ta var watch chan events.Event cancelWatch := func() {} - if waitStop && oldTask != nil { + waitForTask := waitStop && oldTask != nil && oldTask.Status.State <= api.TaskStateRunning + + if waitForTask { // Wait for either the old task to complete, or the old task's // node to become unavailable. watch, cancelWatch = state.Watch( @@ -364,7 +459,7 @@ func (r *Supervisor) DelayStart(ctx context.Context, _ store.Tx, oldTask *api.Ta } } - if waitStop && oldTask != nil { + if waitForTask { select { case <-watch: case <-oldTaskTimer.C: @@ -432,16 +527,6 @@ func (r *Supervisor) CancelAll() { // ClearServiceHistory forgets restart history related to a given service ID. func (r *Supervisor) ClearServiceHistory(serviceID string) { r.mu.Lock() - defer r.mu.Unlock() - - tuples := r.historyByService[serviceID] - if tuples == nil { - return - } - delete(r.historyByService, serviceID) - - for t := range tuples { - delete(r.history, t) - } + r.mu.Unlock() } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/slot.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/slot.go index ce347136b..7839a7509 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/slot.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/slot.go @@ -2,7 +2,6 @@ package orchestrator import ( "github.com/docker/swarmkit/api" - "github.com/docker/swarmkit/manager/state/store" ) // Slot is a list of the running tasks occupying a certain slot. Generally this @@ -12,35 +11,11 @@ import ( // is also considered a slot for global services. type Slot []*api.Task -// GetRunnableAndDeadSlots returns two maps of slots. The first contains slots -// that have at least one task with a desired state above NEW and lesser or -// equal to RUNNING. The second is for slots that only contain tasks with a -// desired state above RUNNING. -func GetRunnableAndDeadSlots(s *store.MemoryStore, serviceID string) (map[uint64]Slot, map[uint64]Slot, error) { - var ( - tasks []*api.Task - err error - ) - s.View(func(tx store.ReadTx) { - tasks, err = store.FindTasks(tx, store.ByServiceID(serviceID)) - }) - if err != nil { - return nil, nil, err - } - - runningSlots := make(map[uint64]Slot) - for _, t := range tasks { - if t.DesiredState <= api.TaskStateRunning { - runningSlots[t.Slot] = append(runningSlots[t.Slot], t) - } - } - - deadSlots := make(map[uint64]Slot) - for _, t := range tasks { - if _, exists := runningSlots[t.Slot]; !exists { - deadSlots[t.Slot] = append(deadSlots[t.Slot], t) - } - } - - return runningSlots, deadSlots, nil +// SlotTuple identifies a unique slot, in the broad sense described above. It's +// a combination of either a service ID and a slot number (replicated services), +// or a service ID and a node ID (global services). +type SlotTuple struct { + Slot uint64 // unset for global service tasks + ServiceID string + NodeID string // unset for replicated service tasks } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/task.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/task.go index 32a22d5f5..ebfeee2b5 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/task.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/task.go @@ -67,7 +67,29 @@ func IsTaskDirty(s *api.Service, t *api.Task) bool { return false } - return !reflect.DeepEqual(s.Spec.Task, t.Spec) || + // Make a deep copy of the service and task spec for the comparison. + serviceTaskSpec := *s.Spec.Task.Copy() + + // For non-failed tasks with a container spec runtime that have already + // pulled the required image (i.e., current state is between READY and + // RUNNING inclusively), ignore the value of the `PullOptions` field by + // setting the copied service to have the same PullOptions value as the + // task. A difference in only the `PullOptions` field should not cause + // a running (or ready to run) task to be considered 'dirty' when we + // handle updates. + // See https://github.com/docker/swarmkit/issues/971 + currentState := t.Status.State + // Ignore PullOpts if the task is desired to be in a "runnable" state + // and its last known current state is between READY and RUNNING in + // which case we know that the task either successfully pulled its + // container image or didn't need to. + ignorePullOpts := t.DesiredState <= api.TaskStateRunning && currentState >= api.TaskStateReady && currentState <= api.TaskStateRunning + if ignorePullOpts && serviceTaskSpec.GetContainer() != nil && t.Spec.GetContainer() != nil { + // Modify the service's container spec. + serviceTaskSpec.GetContainer().PullOptions = t.Spec.GetContainer().PullOptions + } + + return !reflect.DeepEqual(serviceTaskSpec, t.Spec) || (t.Endpoint != nil && !reflect.DeepEqual(s.Spec.Endpoint, t.Endpoint.Spec)) } @@ -77,3 +99,44 @@ func InvalidNode(n *api.Node) bool { n.Status.State == api.NodeStatus_DOWN || n.Spec.Availability == api.NodeAvailabilityDrain } + +// TasksByTimestamp sorts tasks by applied timestamp if available, otherwise +// status timestamp. +type TasksByTimestamp []*api.Task + +// Len implements the Len method for sorting. +func (t TasksByTimestamp) Len() int { + return len(t) +} + +// Swap implements the Swap method for sorting. +func (t TasksByTimestamp) Swap(i, j int) { + t[i], t[j] = t[j], t[i] +} + +// Less implements the Less method for sorting. +func (t TasksByTimestamp) Less(i, j int) bool { + iTimestamp := t[i].Status.Timestamp + if t[i].Status.AppliedAt != nil { + iTimestamp = t[i].Status.AppliedAt + } + + jTimestamp := t[j].Status.Timestamp + if t[j].Status.AppliedAt != nil { + iTimestamp = t[j].Status.AppliedAt + } + + if iTimestamp == nil { + return true + } + if jTimestamp == nil { + return false + } + if iTimestamp.Seconds < jTimestamp.Seconds { + return true + } + if iTimestamp.Seconds > jTimestamp.Seconds { + return false + } + return iTimestamp.Nanos < jTimestamp.Nanos +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/taskinit/init.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/taskinit/init.go index 33558a43c..b893428d5 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/taskinit/init.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/taskinit/init.go @@ -1,11 +1,13 @@ package taskinit import ( + "sort" "time" "github.com/docker/swarmkit/api" "github.com/docker/swarmkit/api/defaults" "github.com/docker/swarmkit/log" + "github.com/docker/swarmkit/manager/orchestrator" "github.com/docker/swarmkit/manager/orchestrator/restart" "github.com/docker/swarmkit/manager/state/store" gogotypes "github.com/gogo/protobuf/types" @@ -16,11 +18,13 @@ import ( type InitHandler interface { IsRelatedService(service *api.Service) bool FixTask(ctx context.Context, batch *store.Batch, t *api.Task) + SlotTuple(t *api.Task) orchestrator.SlotTuple } // CheckTasks fixes tasks in the store before orchestrator runs. The previous leader might // not have finished processing their updates and left them in an inconsistent state. func CheckTasks(ctx context.Context, s *store.MemoryStore, readTx store.ReadTx, initHandler InitHandler, startSupervisor *restart.Supervisor) error { + instances := make(map[orchestrator.SlotTuple][]*api.Task) err := s.Batch(func(batch *store.Batch) error { tasks, err := store.FindTasks(readTx, store.All) if err != nil { @@ -47,6 +51,9 @@ func CheckTasks(ctx context.Context, s *store.MemoryStore, readTx store.ReadTx, continue } + tuple := initHandler.SlotTuple(t) + instances[tuple] = append(instances[tuple], t) + // handle task updates from agent which should have been triggered by task update events initHandler.FixTask(ctx, batch, t) @@ -65,7 +72,12 @@ func CheckTasks(ctx context.Context, s *store.MemoryStore, readTx store.ReadTx, } } if restartDelay != 0 { - timestamp, err := gogotypes.TimestampFromProto(t.Status.Timestamp) + var timestamp time.Time + if t.Status.AppliedAt != nil { + timestamp, err = gogotypes.TimestampFromProto(t.Status.AppliedAt) + } else { + timestamp, err = gogotypes.TimestampFromProto(t.Status.Timestamp) + } if err == nil { restartTime := timestamp.Add(restartDelay) calculatedRestartDelay := restartTime.Sub(time.Now()) @@ -99,5 +111,64 @@ func CheckTasks(ctx context.Context, s *store.MemoryStore, readTx store.ReadTx, } return nil }) - return err + if err != nil { + return err + } + + for tuple, instance := range instances { + // Find the most current spec version. That's the only one + // we care about for the purpose of reconstructing restart + // history. + maxVersion := uint64(0) + for _, t := range instance { + if t.SpecVersion != nil && t.SpecVersion.Index > maxVersion { + maxVersion = t.SpecVersion.Index + } + } + + // Create a new slice with just the current spec version tasks. + var upToDate []*api.Task + for _, t := range instance { + if t.SpecVersion != nil && t.SpecVersion.Index == maxVersion { + upToDate = append(upToDate, t) + } + } + + // Sort by creation timestamp + sort.Sort(tasksByCreationTimestamp(upToDate)) + + // All up-to-date tasks in this instance except the first one + // should be considered restarted. + if len(upToDate) < 2 { + continue + } + for _, t := range upToDate[1:] { + startSupervisor.RecordRestartHistory(tuple, t) + } + } + return nil +} + +type tasksByCreationTimestamp []*api.Task + +func (t tasksByCreationTimestamp) Len() int { + return len(t) +} +func (t tasksByCreationTimestamp) Swap(i, j int) { + t[i], t[j] = t[j], t[i] +} +func (t tasksByCreationTimestamp) Less(i, j int) bool { + if t[i].Meta.CreatedAt == nil { + return true + } + if t[j].Meta.CreatedAt == nil { + return false + } + if t[i].Meta.CreatedAt.Seconds < t[j].Meta.CreatedAt.Seconds { + return true + } + if t[i].Meta.CreatedAt.Seconds > t[j].Meta.CreatedAt.Seconds { + return false + } + return t[i].Meta.CreatedAt.Nanos < t[j].Meta.CreatedAt.Nanos } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/taskreaper/task_reaper.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/taskreaper/task_reaper.go index edb771c69..577319c8e 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/taskreaper/task_reaper.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/taskreaper/task_reaper.go @@ -6,6 +6,7 @@ import ( "github.com/docker/swarmkit/api" "github.com/docker/swarmkit/log" + "github.com/docker/swarmkit/manager/orchestrator" "github.com/docker/swarmkit/manager/state" "github.com/docker/swarmkit/manager/state/store" "golang.org/x/net/context" @@ -18,19 +19,13 @@ const ( reaperBatchingInterval = 250 * time.Millisecond ) -type instanceTuple struct { - instance uint64 // unset for global tasks - serviceID string - nodeID string // unset for replicated tasks -} - // A TaskReaper deletes old tasks when more than TaskHistoryRetentionLimit tasks // exist for the same service/instance or service/nodeid combination. type TaskReaper struct { store *store.MemoryStore // taskHistory is the number of tasks to keep taskHistory int64 - dirty map[instanceTuple]struct{} + dirty map[orchestrator.SlotTuple]struct{} orphaned []string stopChan chan struct{} doneChan chan struct{} @@ -40,7 +35,7 @@ type TaskReaper struct { func New(store *store.MemoryStore) *TaskReaper { return &TaskReaper{ store: store, - dirty: make(map[instanceTuple]struct{}), + dirty: make(map[orchestrator.SlotTuple]struct{}), stopChan: make(chan struct{}), doneChan: make(chan struct{}), } @@ -93,10 +88,10 @@ func (tr *TaskReaper) Run(ctx context.Context) { switch v := event.(type) { case api.EventCreateTask: t := v.Task - tr.dirty[instanceTuple{ - instance: t.Slot, - serviceID: t.ServiceID, - nodeID: t.NodeID, + tr.dirty[orchestrator.SlotTuple{ + Slot: t.Slot, + ServiceID: t.ServiceID, + NodeID: t.NodeID, }] = struct{}{} case api.EventUpdateTask: t := v.Task @@ -138,13 +133,29 @@ func (tr *TaskReaper) tick() { } tr.store.View(func(tx store.ReadTx) { for dirty := range tr.dirty { - service := store.GetService(tx, dirty.serviceID) + service := store.GetService(tx, dirty.ServiceID) if service == nil { continue } taskHistory := tr.taskHistory + // If MaxAttempts is set, keep at least one more than + // that number of tasks. This is necessary reconstruct + // restart history when the orchestrator starts up. + // TODO(aaronl): Consider hiding tasks beyond the normal + // retention limit in the UI. + // TODO(aaronl): There are some ways to cut down the + // number of retained tasks at the cost of more + // complexity: + // - Don't force retention of tasks with an older spec + // version. + // - Don't force retention of tasks outside of the + // time window configured for restart lookback. + if service.Spec.Task.Restart != nil && service.Spec.Task.Restart.MaxAttempts > 0 { + taskHistory = int64(service.Spec.Task.Restart.MaxAttempts) + 1 + } + if taskHistory < 0 { continue } @@ -154,19 +165,19 @@ func (tr *TaskReaper) tick() { switch service.Spec.GetMode().(type) { case *api.ServiceSpec_Replicated: var err error - historicTasks, err = store.FindTasks(tx, store.BySlot(dirty.serviceID, dirty.instance)) + historicTasks, err = store.FindTasks(tx, store.BySlot(dirty.ServiceID, dirty.Slot)) if err != nil { continue } case *api.ServiceSpec_Global: - tasksByNode, err := store.FindTasks(tx, store.ByNodeID(dirty.nodeID)) + tasksByNode, err := store.FindTasks(tx, store.ByNodeID(dirty.NodeID)) if err != nil { continue } for _, t := range tasksByNode { - if t.ServiceID == dirty.serviceID { + if t.ServiceID == dirty.ServiceID { historicTasks = append(historicTasks, t) } } @@ -178,7 +189,9 @@ func (tr *TaskReaper) tick() { // TODO(aaronl): This could filter for non-running tasks and use quickselect // instead of sorting the whole slice. - sort.Sort(tasksByTimestamp(historicTasks)) + // TODO(aaronl): This sort should really use lamport time instead of wall + // clock time. We should store a Version in the Status field. + sort.Sort(orchestrator.TasksByTimestamp(historicTasks)) runningTasks := 0 for _, t := range historicTasks { @@ -219,27 +232,3 @@ func (tr *TaskReaper) Stop() { close(tr.stopChan) <-tr.doneChan } - -type tasksByTimestamp []*api.Task - -func (t tasksByTimestamp) Len() int { - return len(t) -} -func (t tasksByTimestamp) Swap(i, j int) { - t[i], t[j] = t[j], t[i] -} -func (t tasksByTimestamp) Less(i, j int) bool { - if t[i].Status.Timestamp == nil { - return true - } - if t[j].Status.Timestamp == nil { - return false - } - if t[i].Status.Timestamp.Seconds < t[j].Status.Timestamp.Seconds { - return true - } - if t[i].Status.Timestamp.Seconds > t[j].Status.Timestamp.Seconds { - return false - } - return t[i].Status.Timestamp.Nanos < t[j].Status.Timestamp.Nanos -} diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/update/updater.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/update/updater.go index 2b1f55d3f..0bda96e9a 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/update/updater.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/orchestrator/update/updater.go @@ -430,7 +430,7 @@ func (u *Updater) updateTask(ctx context.Context, slot orchestrator.Slot, update u.updatedTasks[updated.ID] = time.Now() u.updatedTasksMu.Unlock() - if startThenStop { + if startThenStop && updated.Status.State == api.TaskStateRunning { err := u.store.Batch(func(batch *store.Batch) error { _, err := u.removeOldTasks(ctx, batch, slot) if err != nil { @@ -496,6 +496,9 @@ func (u *Updater) removeOldTasks(ctx context.Context, batch *store.Batch, remove removedTask *api.Task ) for _, original := range removeTasks { + if original.DesiredState > api.TaskStateRunning { + continue + } err := batch.Update(func(tx store.Tx) error { t := store.GetTask(tx, original.ID) if t == nil { @@ -583,9 +586,8 @@ func (u *Updater) pauseUpdate(ctx context.Context, serviceID, message string) { func (u *Updater) rollbackUpdate(ctx context.Context, serviceID, message string) { log.G(ctx).Debugf("starting rollback of service %s", serviceID) - var service *api.Service err := u.store.Update(func(tx store.Tx) error { - service = store.GetService(tx, serviceID) + service := store.GetService(tx, serviceID) if service == nil { return nil } @@ -601,7 +603,9 @@ func (u *Updater) rollbackUpdate(ctx context.Context, serviceID, message string) return errors.New("cannot roll back service because no previous spec is available") } service.Spec = *service.PreviousSpec + service.SpecVersion = service.PreviousSpecVersion.Copy() service.PreviousSpec = nil + service.PreviousSpecVersion = nil return store.UpdateService(tx, service) }) diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/state/raft/raft.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/state/raft/raft.go index b37953829..cfbec992f 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/state/raft/raft.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/state/raft/raft.go @@ -166,6 +166,8 @@ type NodeOptions struct { // JoinAddr is the cluster to join. May be an empty string to create // a standalone cluster. JoinAddr string + // ForceJoin tells us to join even if already part of a cluster. + ForceJoin bool // Config is the raft config. Config *raft.Config // StateDir is the directory to store durable state. @@ -393,8 +395,10 @@ func (n *Node) JoinAndStart(ctx context.Context) (err error) { // restore from snapshot if loadAndStartErr == nil { - if n.opts.JoinAddr != "" { - log.G(ctx).Warning("ignoring request to join cluster, because raft state already exists") + if n.opts.JoinAddr != "" && n.opts.ForceJoin { + if err := n.joinCluster(ctx); err != nil { + return errors.Wrap(err, "failed to rejoin cluster") + } } n.campaignWhenAble = true n.initTransport() @@ -402,7 +406,6 @@ func (n *Node) JoinAndStart(ctx context.Context) (err error) { return nil } - // first member of cluster if n.opts.JoinAddr == "" { // First member in the cluster, self-assign ID n.Config.ID = uint64(rand.Int63()) + 1 @@ -417,6 +420,22 @@ func (n *Node) JoinAndStart(ctx context.Context) (err error) { } // join to existing cluster + + if err := n.joinCluster(ctx); err != nil { + return err + } + + if _, err := n.newRaftLogs(n.opts.ID); err != nil { + return err + } + + n.initTransport() + n.raftNode = raft.StartNode(n.Config, nil) + + return nil +} + +func (n *Node) joinCluster(ctx context.Context) error { if n.opts.Addr == "" { return errors.New("attempted to join raft cluster without knowing own address") } @@ -438,15 +457,7 @@ func (n *Node) JoinAndStart(ctx context.Context) (err error) { } n.Config.ID = resp.RaftID - - if _, err := n.newRaftLogs(n.opts.ID); err != nil { - return err - } n.bootstrapMembers = resp.Members - - n.initTransport() - n.raftNode = raft.StartNode(n.Config, nil) - return nil } @@ -909,24 +920,6 @@ func (n *Node) Join(ctx context.Context, req *api.JoinRequest) (*api.JoinRespons return nil, grpc.Errorf(codes.FailedPrecondition, "%s", ErrLostLeadership.Error()) } - // A single manager must not be able to join the raft cluster twice. If - // it did, that would cause the quorum to be computed incorrectly. This - // could happen if the WAL was deleted from an active manager. - for _, m := range n.cluster.Members() { - if m.NodeID == nodeInfo.NodeID { - return nil, grpc.Errorf(codes.AlreadyExists, "%s", "a raft member with this node ID already exists") - } - } - - // Find a unique ID for the joining member. - var raftID uint64 - for { - raftID = uint64(rand.Int63()) + 1 - if n.cluster.GetMember(raftID) == nil && !n.cluster.IsIDRemoved(raftID) { - break - } - } - remoteAddr := req.Addr // If the joining node sent an address like 0.0.0.0:4242, automatically @@ -953,12 +946,54 @@ func (n *Node) Join(ctx context.Context, req *api.JoinRequest) (*api.JoinRespons return nil, err } + // If the peer is already a member of the cluster, we will only update + // its information, not add it as a new member. Adding it again would + // cause the quorum to be computed incorrectly. + for _, m := range n.cluster.Members() { + if m.NodeID == nodeInfo.NodeID { + if remoteAddr == m.Addr { + return n.joinResponse(m.RaftID), nil + } + updatedRaftMember := &api.RaftMember{ + RaftID: m.RaftID, + NodeID: m.NodeID, + Addr: remoteAddr, + } + if err := n.cluster.UpdateMember(m.RaftID, updatedRaftMember); err != nil { + return nil, err + } + + if err := n.updateNodeBlocking(ctx, m.RaftID, remoteAddr); err != nil { + log.WithError(err).Error("failed to update node address") + return nil, err + } + + log.Info("updated node address") + return n.joinResponse(m.RaftID), nil + } + } + + // Find a unique ID for the joining member. + var raftID uint64 + for { + raftID = uint64(rand.Int63()) + 1 + if n.cluster.GetMember(raftID) == nil && !n.cluster.IsIDRemoved(raftID) { + break + } + } + err = n.addMember(ctx, remoteAddr, raftID, nodeInfo.NodeID) if err != nil { log.WithError(err).Errorf("failed to add member %x", raftID) return nil, err } + log.Debug("node joined") + + return n.joinResponse(raftID), nil +} + +func (n *Node) joinResponse(raftID uint64) *api.JoinResponse { var nodes []*api.RaftMember for _, node := range n.cluster.Members() { nodes = append(nodes, &api.RaftMember{ @@ -967,9 +1002,8 @@ func (n *Node) Join(ctx context.Context, req *api.JoinRequest) (*api.JoinRespons Addr: node.Addr, }) } - log.Debugf("node joined") - return &api.JoinResponse{Members: nodes, RaftID: raftID}, nil + return &api.JoinResponse{Members: nodes, RaftID: raftID} } // checkHealth tries to contact an aspiring member through its advertised address diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/watchapi/server.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/watchapi/server.go index 07cdedbb3..6d49dca71 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/watchapi/server.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/watchapi/server.go @@ -1,12 +1,24 @@ package watchapi import ( + "errors" + "sync" + "github.com/docker/swarmkit/manager/state/store" + "golang.org/x/net/context" +) + +var ( + errAlreadyRunning = errors.New("broker is already running") + errNotRunning = errors.New("broker is not running") ) // Server is the store API gRPC server. type Server struct { - store *store.MemoryStore + store *store.MemoryStore + mu sync.Mutex + pctx context.Context + cancelAll func() } // NewServer creates a store API server. @@ -15,3 +27,30 @@ func NewServer(store *store.MemoryStore) *Server { store: store, } } + +// Start starts the watch server. +func (s *Server) Start(ctx context.Context) error { + s.mu.Lock() + defer s.mu.Unlock() + + if s.cancelAll != nil { + return errAlreadyRunning + } + + s.pctx, s.cancelAll = context.WithCancel(ctx) + return nil +} + +// Stop stops the watch server. +func (s *Server) Stop() error { + s.mu.Lock() + defer s.mu.Unlock() + + if s.cancelAll == nil { + return errNotRunning + } + s.cancelAll() + s.cancelAll = nil + + return nil +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/watchapi/watch.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/watchapi/watch.go index 555b89974..53bed49f1 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/watchapi/watch.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/manager/watchapi/watch.go @@ -17,6 +17,13 @@ import ( func (s *Server) Watch(request *api.WatchRequest, stream api.Watch_WatchServer) error { ctx := stream.Context() + s.mu.Lock() + pctx := s.pctx + s.mu.Unlock() + if pctx == nil { + return errNotRunning + } + watchArgs, err := api.ConvertWatchArgs(request.Entries) if err != nil { return grpc.Errorf(codes.InvalidArgument, "%s", err.Error()) @@ -39,6 +46,8 @@ func (s *Server) Watch(request *api.WatchRequest, stream api.Watch_WatchServer) select { case <-ctx.Done(): return ctx.Err() + case <-pctx.Done(): + return pctx.Err() case event := <-watch: if commitEvent, ok := event.(state.EventCommit); ok && len(events) > 0 { if err := stream.Send(&api.WatchMessage{Events: events, Version: commitEvent.Version}); err != nil { diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/node/node.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/node/node.go index a6a747216..adad42b72 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/node/node.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/node/node.go @@ -308,8 +308,6 @@ func (n *Node) run(ctx context.Context) (err error) { case <-agentDone: return case nodeChanges := <-n.notifyNodeChange: - currentRole := n.currentRole() - if nodeChanges.Node != nil { // This is a bit complex to be backward compatible with older CAs that // don't support the Node.Role field. They only use what's presently @@ -335,10 +333,7 @@ func (n *Node) run(ctx context.Context) (err error) { } if nodeChanges.RootCert != nil { - // We only want to update the root CA if this is a worker node. Manager nodes directly watch the raft - // store and update the root CA, with the necessary signer, from the raft store (since the managers - // need the CA key as well to potentially issue new TLS certificates). - if currentRole == api.NodeRoleManager || bytes.Equal(nodeChanges.RootCert, securityConfig.RootCA().Certs) { + if bytes.Equal(nodeChanges.RootCert, securityConfig.RootCA().Certs) { continue } newRootCA, err := ca.NewRootCA(nodeChanges.RootCert, nil, nil, ca.DefaultNodeCertExpiration, nil) @@ -346,7 +341,7 @@ func (n *Node) run(ctx context.Context) (err error) { log.G(ctx).WithError(err).Error("invalid new root certificate from the dispatcher") continue } - if err := securityConfig.UpdateRootCA(&newRootCA, newRootCA.Pool); err != nil { + if err := securityConfig.UpdateRootCA(&newRootCA); err != nil { log.G(ctx).WithError(err).Error("could not use new root CA from dispatcher") continue } @@ -828,14 +823,22 @@ func (n *Node) runManager(ctx context.Context, securityConfig *ca.SecurityConfig } } - remoteAddr, _ := n.remotes.Select(n.NodeID()) + joinAddr := n.config.JoinAddr + if joinAddr == "" { + remoteAddr, err := n.remotes.Select(n.NodeID()) + if err == nil { + joinAddr = remoteAddr.Addr + } + } + m, err := manager.New(&manager.Config{ ForceNewCluster: n.config.ForceNewCluster, RemoteAPI: remoteAPI, ControlAPI: n.config.ListenControlAPI, SecurityConfig: securityConfig, ExternalCAs: n.config.ExternalCAs, - JoinRaft: remoteAddr.Addr, + JoinRaft: joinAddr, + ForceJoin: n.config.JoinAddr != "", StateDir: n.config.StateDir, HeartbeatTick: n.config.HeartbeatTick, ElectionTick: n.config.ElectionTick, diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/protobuf/plugin/gen.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/protobuf/plugin/gen.go deleted file mode 100644 index b68b83798..000000000 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/protobuf/plugin/gen.go +++ /dev/null @@ -1,3 +0,0 @@ -package plugin - -//go:generate protoc -I.:/usr/local --gogoswarm_out=import_path=github.com/docker/swarmkit/protobuf/plugin,Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:. plugin.proto diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/protobuf/plugin/plugin.pb.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/protobuf/plugin/plugin.pb.go index 9cafe7343..549cebaea 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/protobuf/plugin/plugin.pb.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/protobuf/plugin/plugin.pb.go @@ -1,12 +1,12 @@ // Code generated by protoc-gen-gogo. -// source: plugin.proto +// source: github.com/docker/swarmkit/protobuf/plugin/plugin.proto // DO NOT EDIT! /* Package plugin is a generated protocol buffer package. It is generated from these files: - plugin.proto + github.com/docker/swarmkit/protobuf/plugin/plugin.proto It has these top-level messages: WatchSelectors @@ -20,6 +20,8 @@ import fmt "fmt" import math "math" import google_protobuf "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" +import github_com_docker_swarmkit_api_deepcopy "github.com/docker/swarmkit/api/deepcopy" + import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto" import strings "strings" @@ -92,7 +94,7 @@ var E_Deepcopy = &proto.ExtensionDesc{ Field: 70000, Name: "docker.protobuf.plugin.deepcopy", Tag: "varint,70000,opt,name=deepcopy,def=1", - Filename: "plugin.proto", + Filename: "github.com/docker/swarmkit/protobuf/plugin/plugin.proto", } var E_StoreObject = &proto.ExtensionDesc{ @@ -101,7 +103,7 @@ var E_StoreObject = &proto.ExtensionDesc{ Field: 70001, Name: "docker.protobuf.plugin.store_object", Tag: "bytes,70001,opt,name=store_object,json=storeObject", - Filename: "plugin.proto", + Filename: "github.com/docker/swarmkit/protobuf/plugin/plugin.proto", } var E_TlsAuthorization = &proto.ExtensionDesc{ @@ -110,7 +112,7 @@ var E_TlsAuthorization = &proto.ExtensionDesc{ Field: 73626345, Name: "docker.protobuf.plugin.tls_authorization", Tag: "bytes,73626345,opt,name=tls_authorization,json=tlsAuthorization", - Filename: "plugin.proto", + Filename: "github.com/docker/swarmkit/protobuf/plugin/plugin.proto", } func init() { @@ -121,6 +123,61 @@ func init() { proto.RegisterExtension(E_StoreObject) proto.RegisterExtension(E_TlsAuthorization) } + +func (m *WatchSelectors) Copy() *WatchSelectors { + if m == nil { + return nil + } + o := &WatchSelectors{} + o.CopyFrom(m) + return o +} + +func (m *WatchSelectors) CopyFrom(src interface{}) { + + o := src.(*WatchSelectors) + *m = *o +} + +func (m *StoreObject) Copy() *StoreObject { + if m == nil { + return nil + } + o := &StoreObject{} + o.CopyFrom(m) + return o +} + +func (m *StoreObject) CopyFrom(src interface{}) { + + o := src.(*StoreObject) + *m = *o + if o.WatchSelectors != nil { + m.WatchSelectors = &WatchSelectors{} + github_com_docker_swarmkit_api_deepcopy.Copy(m.WatchSelectors, o.WatchSelectors) + } +} + +func (m *TLSAuthorization) Copy() *TLSAuthorization { + if m == nil { + return nil + } + o := &TLSAuthorization{} + o.CopyFrom(m) + return o +} + +func (m *TLSAuthorization) CopyFrom(src interface{}) { + + o := src.(*TLSAuthorization) + *m = *o + if o.Roles != nil { + m.Roles = make([]string, len(o.Roles)) + copy(m.Roles, o.Roles) + } + +} + func (m *WatchSelectors) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -378,6 +435,7 @@ func encodeVarintPlugin(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return offset + 1 } + func (m *WatchSelectors) Size() (n int) { var l int _ = l @@ -1143,43 +1201,46 @@ var ( ErrIntOverflowPlugin = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("plugin.proto", fileDescriptorPlugin) } +func init() { + proto.RegisterFile("github.com/docker/swarmkit/protobuf/plugin/plugin.proto", fileDescriptorPlugin) +} var fileDescriptorPlugin = []byte{ - // 551 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0xad, 0xd3, 0x36, 0x4d, 0xc6, 0x69, 0x29, 0x2b, 0x54, 0xad, 0x7a, 0xb0, 0xab, 0x46, 0x42, - 0x41, 0x42, 0xa9, 0xd4, 0x63, 0x6e, 0x94, 0x5c, 0x22, 0x01, 0x45, 0x0e, 0x12, 0x37, 0x2c, 0xd7, - 0x3b, 0x4d, 0x96, 0x3a, 0x5e, 0x6b, 0x77, 0x4d, 0x0b, 0x27, 0x7e, 0x80, 0x0f, 0xe0, 0xca, 0xd7, - 0xf4, 0xc8, 0x91, 0x53, 0x44, 0x2d, 0x71, 0xe0, 0x06, 0x7f, 0x80, 0x76, 0xd7, 0x69, 0x09, 0x6a, - 0xc5, 0xc9, 0x33, 0x6f, 0xe6, 0xcd, 0xcc, 0xdb, 0x67, 0xe8, 0x14, 0x59, 0x39, 0xe1, 0x79, 0xbf, - 0x90, 0x42, 0x0b, 0xb2, 0xc3, 0x44, 0x7a, 0x86, 0xd2, 0x65, 0x27, 0xe5, 0x69, 0xdf, 0x55, 0x77, - 0xf7, 0x26, 0x42, 0x4c, 0x32, 0x3c, 0x58, 0xe0, 0x07, 0x0c, 0x55, 0x2a, 0x79, 0xa1, 0x45, 0xdd, - 0xbb, 0xff, 0x79, 0x15, 0xb6, 0x5e, 0x27, 0x3a, 0x9d, 0x8e, 0x31, 0xc3, 0x54, 0x0b, 0xa9, 0xc8, - 0x0e, 0x34, 0x38, 0xa3, 0xde, 0x9e, 0xd7, 0x6b, 0x1d, 0x35, 0xab, 0x79, 0xd8, 0x18, 0x0d, 0xa3, - 0x06, 0x67, 0xe4, 0x11, 0xb4, 0x39, 0x8b, 0x0b, 0x89, 0xa7, 0xfc, 0x82, 0x36, 0x6c, 0xb9, 0x53, - 0xcd, 0xc3, 0xd6, 0x68, 0xf8, 0xd2, 0x62, 0x51, 0x8b, 0x33, 0x17, 0x11, 0x02, 0x6b, 0x79, 0x32, - 0x43, 0xba, 0x6a, 0xba, 0x22, 0x1b, 0x93, 0x10, 0x7c, 0xf3, 0x5d, 0x0c, 0x58, 0xb3, 0x25, 0x30, - 0x50, 0x4d, 0xda, 0x81, 0x66, 0x5a, 0x2a, 0x2d, 0x66, 0x74, 0xdd, 0xd6, 0xea, 0x8c, 0x74, 0x61, - 0xd3, 0x45, 0x0b, 0x6a, 0xd3, 0x96, 0x3b, 0x0e, 0xac, 0xc9, 0x8f, 0x01, 0x14, 0xca, 0x77, 0x3c, - 0xc5, 0x98, 0x33, 0xba, 0x61, 0xaf, 0xdb, 0xac, 0xe6, 0x61, 0x7b, 0xec, 0xd0, 0xd1, 0x30, 0x6a, - 0xd7, 0x0d, 0x23, 0x46, 0xba, 0xb0, 0x91, 0x0b, 0x66, 0x5b, 0x5b, 0xb6, 0x15, 0xaa, 0x79, 0xd8, - 0x7c, 0x21, 0x98, 0xe9, 0x6b, 0x9a, 0xd2, 0x88, 0x19, 0x11, 0x2a, 0x13, 0x9a, 0xb6, 0x9d, 0x08, - 0x13, 0x9b, 0x5b, 0x18, 0x2a, 0x2e, 0x91, 0xc5, 0x4a, 0x27, 0x1a, 0x29, 0xb8, 0x5b, 0x6a, 0x70, - 0x6c, 0x30, 0x43, 0x94, 0x22, 0x43, 0xea, 0x3b, 0xa2, 0x89, 0x49, 0x00, 0x30, 0xc3, 0xd9, 0x09, - 0x4a, 0x35, 0xe5, 0x05, 0xed, 0x38, 0xf1, 0x37, 0x88, 0xe1, 0x9c, 0xf1, 0x9c, 0xd1, 0x4d, 0xc7, - 0x31, 0xf1, 0xfe, 0x1b, 0xf0, 0xc7, 0x5a, 0x48, 0x3c, 0x3e, 0x79, 0x8b, 0xa9, 0x26, 0xc7, 0x70, - 0xef, 0xdc, 0x38, 0x15, 0xab, 0x85, 0x55, 0xd4, 0xdb, 0x6b, 0xf4, 0xfc, 0xc3, 0x87, 0xfd, 0xdb, - 0xed, 0xef, 0x2f, 0x1b, 0x1b, 0x6d, 0x9d, 0x2f, 0xe5, 0xfb, 0x43, 0xd8, 0x7e, 0xf5, 0x6c, 0xfc, - 0xa4, 0xd4, 0x53, 0x21, 0xf9, 0x87, 0x44, 0x73, 0x91, 0x93, 0x07, 0xb0, 0x6e, 0xee, 0x35, 0xa3, - 0x57, 0x7b, 0xed, 0xc8, 0x25, 0x64, 0x17, 0x5a, 0x3c, 0x57, 0x98, 0x96, 0x12, 0x9d, 0xf3, 0xd1, - 0x75, 0x3e, 0x78, 0x0a, 0x2d, 0x86, 0x58, 0xa4, 0xa2, 0x78, 0x4f, 0xc2, 0xbe, 0xfb, 0xe1, 0x6e, - 0x2e, 0x79, 0x8e, 0x4a, 0x25, 0x13, 0x3c, 0x2e, 0xcc, 0x74, 0x45, 0x7f, 0x7d, 0xb1, 0xbe, 0x0f, - 0xd6, 0xb4, 0x2c, 0x31, 0xba, 0x26, 0x0e, 0x38, 0x74, 0x94, 0x91, 0x1a, 0x0b, 0xa7, 0xf5, 0xbf, - 0x83, 0x7e, 0xdb, 0x41, 0xfe, 0x61, 0xf7, 0x2e, 0xed, 0x7f, 0xbd, 0x5c, 0xe4, 0xab, 0x9b, 0x64, - 0x70, 0x01, 0xf7, 0x75, 0xa6, 0xe2, 0x64, 0x49, 0x76, 0x70, 0xcb, 0x3e, 0x3d, 0x15, 0x6c, 0xb1, - 0xee, 0xe7, 0x8f, 0x4f, 0x5d, 0xbb, 0xaf, 0x77, 0xd7, 0xbe, 0x7f, 0x5f, 0x32, 0xda, 0xd6, 0x99, - 0x5a, 0x42, 0x8e, 0xe8, 0xe5, 0x55, 0xb0, 0xf2, 0xed, 0x2a, 0x58, 0xf9, 0x58, 0x05, 0xde, 0x65, - 0x15, 0x78, 0x5f, 0xab, 0xc0, 0xfb, 0x5e, 0x05, 0xde, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x94, - 0xd6, 0x21, 0x73, 0xce, 0x03, 0x00, 0x00, + // 575 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xc1, 0x6e, 0xd3, 0x4c, + 0x10, 0xae, 0xd3, 0x36, 0x4d, 0x26, 0x69, 0xff, 0xfe, 0x2b, 0x54, 0xad, 0x7a, 0x70, 0xaa, 0x46, + 0x42, 0x41, 0x42, 0x8e, 0xd4, 0x0b, 0x52, 0x6e, 0x94, 0x5c, 0x22, 0x01, 0x45, 0x0e, 0x12, 0x37, + 0x22, 0xc7, 0x3b, 0x4d, 0x96, 0x3a, 0x5e, 0x6b, 0x77, 0x4d, 0x0a, 0x27, 0x5e, 0x80, 0x07, 0xe0, + 0xca, 0xd3, 0xf4, 0xc8, 0x91, 0x53, 0x44, 0x2d, 0x71, 0xe0, 0x06, 0x6f, 0x80, 0x76, 0xd7, 0x69, + 0x08, 0x6a, 0xc5, 0xc9, 0x33, 0xdf, 0x7c, 0xdf, 0xcc, 0x7c, 0x3b, 0x86, 0x47, 0x13, 0xae, 0xa7, + 0xf9, 0x38, 0x88, 0xc5, 0xac, 0xcb, 0x44, 0x7c, 0x81, 0xb2, 0xab, 0xe6, 0x91, 0x9c, 0x5d, 0x70, + 0xdd, 0xcd, 0xa4, 0xd0, 0x62, 0x9c, 0x9f, 0x77, 0xb3, 0x24, 0x9f, 0xf0, 0xb4, 0xfc, 0x04, 0x16, + 0x26, 0x07, 0x8e, 0x1d, 0x2c, 0x49, 0x81, 0xab, 0x1e, 0x1e, 0x4d, 0x84, 0x98, 0x24, 0xb8, 0x12, + 0x33, 0x54, 0xb1, 0xe4, 0x99, 0x16, 0x25, 0xf7, 0xf8, 0xd3, 0x26, 0xec, 0xbd, 0x8a, 0x74, 0x3c, + 0x1d, 0x62, 0x82, 0xb1, 0x16, 0x52, 0x91, 0x03, 0xa8, 0x70, 0x46, 0xbd, 0x23, 0xaf, 0x53, 0x3b, + 0xad, 0x16, 0x8b, 0x56, 0x65, 0xd0, 0x0f, 0x2b, 0x9c, 0x91, 0x07, 0x50, 0xe7, 0x6c, 0x94, 0x49, + 0x3c, 0xe7, 0x97, 0xb4, 0x62, 0xcb, 0xcd, 0x62, 0xd1, 0xaa, 0x0d, 0xfa, 0x2f, 0x2c, 0x16, 0xd6, + 0x38, 0x73, 0x11, 0x21, 0xb0, 0x95, 0x46, 0x33, 0xa4, 0x9b, 0x86, 0x15, 0xda, 0x98, 0xb4, 0xa0, + 0x61, 0xbe, 0xcb, 0x06, 0x5b, 0xb6, 0x04, 0x06, 0x2a, 0x45, 0x07, 0x50, 0x8d, 0x73, 0xa5, 0xc5, + 0x8c, 0x6e, 0xdb, 0x5a, 0x99, 0x91, 0x36, 0xec, 0xba, 0x68, 0x29, 0xad, 0xda, 0x72, 0xd3, 0x81, + 0xa5, 0xf8, 0x21, 0x80, 0x42, 0xf9, 0x96, 0xc7, 0x38, 0xe2, 0x8c, 0xee, 0xd8, 0xed, 0x76, 0x8b, + 0x45, 0xab, 0x3e, 0x74, 0xe8, 0xa0, 0x1f, 0xd6, 0x4b, 0xc2, 0x80, 0x91, 0x36, 0xec, 0xa4, 0x82, + 0x59, 0x6a, 0xcd, 0x52, 0xa1, 0x58, 0xb4, 0xaa, 0xcf, 0x05, 0x33, 0xbc, 0xaa, 0x29, 0x0d, 0x98, + 0x31, 0xa1, 0x12, 0xa1, 0x69, 0xdd, 0x99, 0x30, 0xb1, 0xd9, 0x85, 0xa1, 0xe2, 0x12, 0xd9, 0x48, + 0xe9, 0x48, 0x23, 0x05, 0xb7, 0x4b, 0x09, 0x0e, 0x0d, 0x66, 0x84, 0x52, 0x24, 0x48, 0x1b, 0x4e, + 0x68, 0x62, 0xe2, 0x03, 0xcc, 0x70, 0x36, 0x46, 0xa9, 0xa6, 0x3c, 0xa3, 0x4d, 0x67, 0x7e, 0x85, + 0x18, 0xcd, 0x05, 0x4f, 0x19, 0xdd, 0x75, 0x1a, 0x13, 0x1f, 0xbf, 0x86, 0xc6, 0x50, 0x0b, 0x89, + 0x67, 0xe3, 0x37, 0x18, 0x6b, 0x72, 0x06, 0xff, 0xcd, 0xcd, 0xa5, 0x46, 0x6a, 0x79, 0x2a, 0xea, + 0x1d, 0x55, 0x3a, 0x8d, 0x93, 0xfb, 0xc1, 0xed, 0xe7, 0x0f, 0xd6, 0x0f, 0x1b, 0xee, 0xcd, 0xd7, + 0xf2, 0xe3, 0x3e, 0xec, 0xbf, 0x7c, 0x3a, 0x7c, 0x9c, 0xeb, 0xa9, 0x90, 0xfc, 0x7d, 0xa4, 0xb9, + 0x48, 0xc9, 0x3d, 0xd8, 0x36, 0xfb, 0x9a, 0xd6, 0x9b, 0x9d, 0x7a, 0xe8, 0x12, 0x72, 0x08, 0x35, + 0x9e, 0x2a, 0x8c, 0x73, 0x89, 0xee, 0xf2, 0xe1, 0x4d, 0xde, 0x7b, 0x02, 0x35, 0x86, 0x98, 0xc5, + 0x22, 0x7b, 0x47, 0x5a, 0x81, 0xfb, 0xe1, 0x56, 0x9b, 0x3c, 0x43, 0xa5, 0xa2, 0x09, 0x9e, 0x65, + 0xa6, 0xbb, 0xa2, 0x3f, 0x3f, 0xdb, 0xbb, 0xf7, 0xb6, 0xb4, 0xcc, 0x31, 0xbc, 0x11, 0xf6, 0x38, + 0x34, 0x95, 0xb1, 0x3a, 0x12, 0xce, 0xeb, 0x3f, 0x1b, 0xfd, 0xb2, 0x8d, 0x1a, 0x27, 0xed, 0xbb, + 0xbc, 0xff, 0xf1, 0x72, 0x61, 0x43, 0xad, 0x92, 0xde, 0x25, 0xfc, 0xaf, 0x13, 0x35, 0x8a, 0xd6, + 0x6c, 0xfb, 0xb7, 0xcc, 0xd3, 0x53, 0xc1, 0x96, 0xe3, 0x7e, 0x7c, 0xff, 0xd8, 0xb6, 0xf3, 0x3a, + 0x77, 0xcd, 0xfb, 0xfb, 0x25, 0xc3, 0x7d, 0x9d, 0xa8, 0x35, 0xe4, 0x94, 0x5e, 0x5d, 0xfb, 0x1b, + 0x5f, 0xaf, 0xfd, 0x8d, 0x0f, 0x85, 0xef, 0x5d, 0x15, 0xbe, 0xf7, 0xa5, 0xf0, 0xbd, 0x6f, 0x85, + 0xef, 0xfd, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xb3, 0x99, 0x7d, 0xfb, 0xf9, 0x03, 0x00, 0x00, } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/template/context.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/template/context.go index e3badef53..8485fc462 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/template/context.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/template/context.go @@ -107,9 +107,10 @@ type PayloadContext struct { t *api.Task restrictedSecrets exec.SecretGetter restrictedConfigs exec.ConfigGetter + sensitive bool } -func (ctx PayloadContext) secretGetter(target string) (string, error) { +func (ctx *PayloadContext) secretGetter(target string) (string, error) { if ctx.restrictedSecrets == nil { return "", errors.New("secrets unavailable") } @@ -126,6 +127,7 @@ func (ctx PayloadContext) secretGetter(target string) (string, error) { if err != nil { return "", err } + ctx.sensitive = true return string(secret.Spec.Data), nil } } @@ -133,7 +135,7 @@ func (ctx PayloadContext) secretGetter(target string) (string, error) { return "", errors.Errorf("secret target %s not found", target) } -func (ctx PayloadContext) configGetter(target string) (string, error) { +func (ctx *PayloadContext) configGetter(target string) (string, error) { if ctx.restrictedConfigs == nil { return "", errors.New("configs unavailable") } @@ -157,7 +159,7 @@ func (ctx PayloadContext) configGetter(target string) (string, error) { return "", errors.Errorf("config target %s not found", target) } -func (ctx PayloadContext) envGetter(variable string) (string, error) { +func (ctx *PayloadContext) envGetter(variable string) (string, error) { container := ctx.t.Spec.GetContainer() if container == nil { return "", errors.New("task is not a container") diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/template/expand.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/template/expand.go index 45ca97114..0957c25f2 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/template/expand.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/template/expand.go @@ -119,7 +119,7 @@ func expandEnv(ctx Context, values []string) ([]string, error) { return result, nil } -func expandPayload(ctx PayloadContext, payload []byte) ([]byte, error) { +func expandPayload(ctx *PayloadContext, payload []byte) ([]byte, error) { result, err := ctx.Expand(string(payload)) if err != nil { return payload, err @@ -138,7 +138,7 @@ func ExpandSecretSpec(s *api.Secret, node *api.NodeDescription, t *api.Task, dep secretSpec := s.Spec.Copy() var err error - secretSpec.Data, err = expandPayload(ctx, secretSpec.Data) + secretSpec.Data, err = expandPayload(&ctx, secretSpec.Data) return secretSpec, err } return &s.Spec, errors.New("unrecognized template type") @@ -146,17 +146,17 @@ func ExpandSecretSpec(s *api.Secret, node *api.NodeDescription, t *api.Task, dep // ExpandConfigSpec expands the template inside the config payload, if any. // Templating is evaluated on the agent-side. -func ExpandConfigSpec(c *api.Config, node *api.NodeDescription, t *api.Task, dependencies exec.DependencyGetter) (*api.ConfigSpec, error) { +func ExpandConfigSpec(c *api.Config, node *api.NodeDescription, t *api.Task, dependencies exec.DependencyGetter) (*api.ConfigSpec, bool, error) { if c.Spec.Templating == nil { - return &c.Spec, nil + return &c.Spec, false, nil } if c.Spec.Templating.Name == "golang" { ctx := NewPayloadContextFromTask(node, t, dependencies) configSpec := c.Spec.Copy() var err error - configSpec.Data, err = expandPayload(ctx, configSpec.Data) - return configSpec, err + configSpec.Data, err = expandPayload(&ctx, configSpec.Data) + return configSpec, ctx.sensitive, err } - return &c.Spec, errors.New("unrecognized template type") + return &c.Spec, false, errors.New("unrecognized template type") } diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/template/getter.go b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/template/getter.go index 05e5de72e..58c187592 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/template/getter.go +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/template/getter.go @@ -42,6 +42,18 @@ func (t templatedSecretGetter) Get(secretID string) (*api.Secret, error) { return &secretCopy, nil } +// TemplatedConfigGetter is a ConfigGetter with an additional method to expose +// whether a config contains sensitive data. +type TemplatedConfigGetter interface { + exec.ConfigGetter + + // GetAndFlagSecretData returns the interpolated config, and also + // returns true if the config has been interpolated with data from a + // secret. In this case, the config should be handled specially and + // should not be written to disk. + GetAndFlagSecretData(configID string) (*api.Config, bool, error) +} + type templatedConfigGetter struct { dependencies exec.DependencyGetter t *api.Task @@ -49,38 +61,43 @@ type templatedConfigGetter struct { } // NewTemplatedConfigGetter returns a ConfigGetter that evaluates templates. -func NewTemplatedConfigGetter(dependencies exec.DependencyGetter, t *api.Task, node *api.NodeDescription) exec.ConfigGetter { +func NewTemplatedConfigGetter(dependencies exec.DependencyGetter, t *api.Task, node *api.NodeDescription) TemplatedConfigGetter { return templatedConfigGetter{dependencies: dependencies, t: t, node: node} } func (t templatedConfigGetter) Get(configID string) (*api.Config, error) { + config, _, err := t.GetAndFlagSecretData(configID) + return config, err +} + +func (t templatedConfigGetter) GetAndFlagSecretData(configID string) (*api.Config, bool, error) { if t.dependencies == nil { - return nil, errors.New("no config provider available") + return nil, false, errors.New("no config provider available") } configs := t.dependencies.Configs() if configs == nil { - return nil, errors.New("no config provider available") + return nil, false, errors.New("no config provider available") } config, err := configs.Get(configID) if err != nil { - return config, err + return config, false, err } - newSpec, err := ExpandConfigSpec(config, t.node, t.t, t.dependencies) + newSpec, sensitive, err := ExpandConfigSpec(config, t.node, t.t, t.dependencies) if err != nil { - return config, errors.Wrapf(err, "failed to expand templated config %s", configID) + return config, false, errors.Wrapf(err, "failed to expand templated config %s", configID) } configCopy := *config configCopy.Spec = *newSpec - return &configCopy, nil + return &configCopy, sensitive, nil } type templatedDependencyGetter struct { secrets exec.SecretGetter - configs exec.ConfigGetter + configs TemplatedConfigGetter } // NewTemplatedDependencyGetter returns a DependencyGetter that evaluates templates. diff --git a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/vendor.conf b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/vendor.conf index 73692eeee..abb1a6c24 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/vendor.conf +++ b/vendor/github.com/docker/docker/vendor/github.com/docker/swarmkit/vendor.conf @@ -19,26 +19,27 @@ github.com/prometheus/common ebdfc6da46522d58825777cf1f90490a5b1ef1d8 github.com/prometheus/procfs abf152e5f3e97f2fafac028d2cc06c1feb87ffa5 github.com/docker/distribution b38e5838b7b2f2ad48e06ec4b500011976080621 -github.com/docker/docker 77c9728847358a3ed3581d828fb0753017e1afd3 -github.com/docker/go-connections 34b5052da6b11e27f5f2e357b38b571ddddd3928 -github.com/docker/go-events 37d35add5005832485c0225ec870121b78fcff1c +github.com/docker/docker 8af4db6f002ac907b6ef8610b237879dfcaa5b7a +github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d +github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 github.com/docker/go-units 954fed01cc617c55d838fa2230073f2cb17386c8 github.com/docker/libkv 9fd56606e928ff1f309808f5d5a0b7a2ef73f9a8 -github.com/docker/libnetwork 37e20af882e13dd01ade3658b7aabdae3412118b +github.com/docker/libnetwork 19ac3ea7f52bb46e0eb10669756cdae0c441a5b1 github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a -github.com/opencontainers/runc b6b70e53451794e8333e9b602cc096b47a20bd0f -github.com/opencontainers/go-digest a6d0ee40d4207ea02364bd3b9e8e77b9159ba1eb -github.com/opencontainers/image-spec 372ad780f63454fbbbbcc7cf80e5b90245c13e13 +github.com/opencontainers/runc d40db12e72a40109dfcf28539f5ee0930d2f0277 +github.com/opencontainers/go-digest 21dfd564fd89c944783d00d069f33e3e7123c448 +github.com/opencontainers/image-spec v1.0.0 # containerd executor -github.com/containerd/containerd 76697ac8cbf357a19beb58e4805a81fe48cf7974 +github.com/containerd/containerd 29a4dd7f46e0780d0bff2a237dc600a5b90a4dd5 github.com/containerd/fifo 69b99525e472735860a5269b75af1970142b3062 -github.com/opencontainers/runtime-spec v1.0.0-rc5 +github.com/opencontainers/runtime-spec v1.0.0 golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c +github.com/containerd/continuity cf279e6ac893682272b4479d4c67fd3abf878b4e github.com/davecgh/go-spew 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d github.com/Microsoft/go-winio v0.4.2 -github.com/Sirupsen/logrus v0.11.0 +github.com/sirupsen/logrus v1.0.1 github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9 github.com/boltdb/bolt e72f08ddb5a52992c0a44c7dda9316c7333938b2 github.com/cloudflare/cfssl 7fb22c8cba7ecaf98e4082d22d65800cf45e042a @@ -58,6 +59,6 @@ github.com/spf13/pflag 7f60f83a2c81bc3c3c0d5297f61ddfa68da9d3b7 github.com/stretchr/testify v1.1.4 golang.org/x/crypto 3fbbcd23f1cb824e69491a5930cfeff09b12f4d2 golang.org/x/net 7dcfb8076726a3fdd9353b6b8a1f1b6be6811bd6 -golang.org/x/sys 5eaf0df67e70d6997a9fe0ed24383fa1b01638d3 +golang.org/x/sys 739734461d1c916b6c72a63d7efda2b27edb369f golang.org/x/text f72d8390a633d5dfb0cc84043294db9f6c935756 golang.org/x/time a4bde12657593d5e90d0533a3e4fd95e635124cb diff --git a/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/LICENSE b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/README.md b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/README.md new file mode 100644 index 000000000..037fba6c7 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/README.md @@ -0,0 +1,33 @@ +# Go Test Yourself + +A collection of packages compatible with `go test` to support common testing +patterns. + +[![GoDoc](https://godoc.org/github.com/gotestyourself/gotestyourself?status.svg)](https://godoc.org/github.com/gotestyourself/gotestyourself) +[![CircleCI](https://circleci.com/gh/gotestyourself/gotestyourself/tree/master.svg?style=shield)](https://circleci.com/gh/gotestyourself/gotestyourself/tree/master) +[![Go Reportcard](https://goreportcard.com/badge/github.com/gotestyourself/gotestyourself)](https://goreportcard.com/report/github.com/gotestyourself/gotestyourself) + + +## Packages + +* [fs](http://godoc.org/github.com/gotestyourself/gotestyourself/fs) - + create test files and directories +* [golden](http://godoc.org/github.com/gotestyourself/gotestyourself/golden) - + compare large multi-line strings +* [testsum](http://godoc.org/github.com/gotestyourself/gotestyourself/testsum) - + a program to summarize `go test` output and test failures +* [icmd](http://godoc.org/github.com/gotestyourself/gotestyourself/icmd) - + execute binaries and test the output +* [poll](http://godoc.org/github.com/gotestyourself/gotestyourself/poll) - + test asynchronous code by polling until a desired state is reached +* [skip](http://godoc.org/github.com/gotestyourself/gotestyourself/skip) - + skip tests based on conditions + +## Related + +* [testify/assert](https://godoc.org/github.com/stretchr/testify/assert) and + [testify/require](https://godoc.org/github.com/stretchr/testify/require) - + assertion libraries with common assertions +* [golang/mock](https://github.com/golang/mock) - generate mocks for interfaces +* [testify/suite](https://godoc.org/github.com/stretchr/testify/suite) - + group test into suites to share common setup/teardown logic diff --git a/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/fs/file.go b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/fs/file.go new file mode 100644 index 000000000..dcda10a02 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/fs/file.go @@ -0,0 +1,81 @@ +/*Package fs provides tools for creating and working with temporary files and +directories. +*/ +package fs + +import ( + "io/ioutil" + "os" + "path/filepath" + + "github.com/stretchr/testify/require" +) + +// Path objects return their filesystem path. Both File and Dir implement Path. +type Path interface { + Path() string +} + +// File is a temporary file on the filesystem +type File struct { + path string +} + +// NewFile creates a new file in a temporary directory using prefix as part of +// the filename. The PathOps are applied to the before returning the File. +func NewFile(t require.TestingT, prefix string, ops ...PathOp) *File { + tempfile, err := ioutil.TempFile("", prefix+"-") + require.NoError(t, err) + file := &File{path: tempfile.Name()} + require.NoError(t, tempfile.Close()) + + for _, op := range ops { + require.NoError(t, op(file)) + } + return file +} + +// Path returns the full path to the file +func (f *File) Path() string { + return f.path +} + +// Remove the file +func (f *File) Remove() { + // nolint: errcheck + os.Remove(f.path) +} + +// Dir is a temporary directory +type Dir struct { + path string +} + +// NewDir returns a new temporary directory using prefix as part of the directory +// name. The PathOps are applied before returning the Dir. +func NewDir(t require.TestingT, prefix string, ops ...PathOp) *Dir { + path, err := ioutil.TempDir("", prefix+"-") + require.NoError(t, err) + dir := &Dir{path: path} + + for _, op := range ops { + require.NoError(t, op(dir)) + } + return dir +} + +// Path returns the full path to the directory +func (d *Dir) Path() string { + return d.path +} + +// Remove the directory +func (d *Dir) Remove() { + // nolint: errcheck + os.RemoveAll(d.path) +} + +// Join returns a new path with this directory as the base of the path +func (d *Dir) Join(parts ...string) string { + return filepath.Join(append([]string{d.Path()}, parts...)...) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/fs/ops.go b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/fs/ops.go new file mode 100644 index 000000000..4fbc40f42 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/fs/ops.go @@ -0,0 +1,94 @@ +package fs + +import ( + "io/ioutil" + "os" + "path/filepath" +) + +// PathOp is a function which accepts a Path to perform some operation +type PathOp func(path Path) error + +// WithContent writes content to a file at Path +func WithContent(content string) PathOp { + return func(path Path) error { + return ioutil.WriteFile(path.Path(), []byte(content), 0644) + } +} + +// WithBytes write bytes to a file at Path +func WithBytes(raw []byte) PathOp { + return func(path Path) error { + return ioutil.WriteFile(path.Path(), raw, 0644) + } +} + +// AsUser changes ownership of the file system object at Path +func AsUser(uid, gid int) PathOp { + return func(path Path) error { + return os.Chown(path.Path(), uid, gid) + } +} + +// WithFile creates a file in the directory at path with content +func WithFile(filename, content string) PathOp { + return func(path Path) error { + return createFile(path.Path(), filename, content) + } +} + +func createFile(dir, filename, content string) error { + fullpath := filepath.Join(dir, filepath.FromSlash(filename)) + return ioutil.WriteFile(fullpath, []byte(content), 0644) +} + +// WithFiles creates all the files in the directory at path with their content +func WithFiles(files map[string]string) PathOp { + return func(path Path) error { + for filename, content := range files { + if err := createFile(path.Path(), filename, content); err != nil { + return err + } + } + return nil + } +} + +// FromDir copies the directory tree from the source path into the new Dir +func FromDir(source string) PathOp { + return func(path Path) error { + return copyDirectory(source, path.Path()) + } +} + +func copyDirectory(source, dest string) error { + entries, err := ioutil.ReadDir(source) + if err != nil { + return err + } + for _, entry := range entries { + sourcePath := filepath.Join(source, entry.Name()) + destPath := filepath.Join(dest, entry.Name()) + if entry.IsDir() { + if err := os.Mkdir(destPath, 0755); err != nil { + return err + } + if err := copyDirectory(sourcePath, destPath); err != nil { + return err + } + continue + } + if err := copyFile(sourcePath, destPath); err != nil { + return err + } + } + return nil +} + +func copyFile(source, dest string) error { + content, err := ioutil.ReadFile(source) + if err != nil { + return err + } + return ioutil.WriteFile(dest, content, 0644) +} diff --git a/vendor/github.com/docker/docker/pkg/testutil/cmd/command.go b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/icmd/command.go similarity index 78% rename from vendor/github.com/docker/docker/pkg/testutil/cmd/command.go rename to vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/icmd/command.go index 6f36d6790..8729457b4 100644 --- a/vendor/github.com/docker/docker/pkg/testutil/cmd/command.go +++ b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/icmd/command.go @@ -1,4 +1,6 @@ -package cmd +/*Package icmd executes binaries and provides convenient assertions for testing the results. + */ +package icmd import ( "bytes" @@ -10,19 +12,14 @@ import ( "strings" "sync" "time" - - "github.com/docker/docker/pkg/system" - "github.com/go-check/check" ) type testingT interface { Fatalf(string, ...interface{}) } -const ( - // None is a token to inform Result.Assert that the output should be empty - None string = "" -) +// None is a token to inform Result.Assert that the output should be empty +const None string = "[NOTHING]" type lockedBuffer struct { m sync.RWMutex @@ -61,7 +58,7 @@ func (r *Result) Assert(t testingT, exp Expected) *Result { } _, file, line, ok := runtime.Caller(1) if ok { - t.Fatalf("at %s:%d - %s", filepath.Base(file), line, err.Error()) + t.Fatalf("at %s:%d - %s\n", filepath.Base(file), line, err.Error()) } else { t.Fatalf("(no file/line info) - %s", err.Error()) } @@ -70,6 +67,7 @@ func (r *Result) Assert(t testingT, exp Expected) *Result { // Compare returns a formatted error with the command, stdout, stderr, exit // code, and any failed expectations +// nolint: gocyclo func (r *Result) Compare(exp Expected) error { errors := []string{} add := func(format string, args ...interface{}) { @@ -108,7 +106,7 @@ func (r *Result) Compare(exp Expected) error { if len(errors) == 0 { return nil } - return fmt.Errorf("%s\nFailures:\n%s\n", r, strings.Join(errors, "\n")) + return fmt.Errorf("%s\nFailures:\n%s", r, strings.Join(errors, "\n")) } func matchOutput(expected string, actual string) bool { @@ -151,7 +149,8 @@ type Expected struct { Err string } -// Success is the default expected result +// Success is the default expected result. A Success result is one with a 0 +// ExitCode. var Success = Expected{} // Stdout returns the stdout of the process as a string @@ -169,46 +168,14 @@ func (r *Result) Combined() string { return r.outBuffer.String() + r.errBuffer.String() } -// SetExitError sets Error and ExitCode based on Error -func (r *Result) SetExitError(err error) { +func (r *Result) setExitError(err error) { if err == nil { return } r.Error = err - r.ExitCode = system.ProcessExitCode(err) -} - -type matches struct{} - -// Info returns the CheckerInfo -func (m *matches) Info() *check.CheckerInfo { - return &check.CheckerInfo{ - Name: "CommandMatches", - Params: []string{"result", "expected"}, - } -} - -// Check compares a result against the expected -func (m *matches) Check(params []interface{}, names []string) (bool, string) { - result, ok := params[0].(*Result) - if !ok { - return false, fmt.Sprintf("result must be a *Result, not %T", params[0]) - } - expected, ok := params[1].(Expected) - if !ok { - return false, fmt.Sprintf("expected must be an Expected, not %T", params[1]) - } - - err := result.Compare(expected) - if err == nil { - return true, "" - } - return false, err.Error() + r.ExitCode = processExitCode(err) } -// Matches is a gocheck.Checker for comparing a Result against an Expected -var Matches = &matches{} - // Cmd contains the arguments and options for a process to run as part of a test // suite. type Cmd struct { @@ -226,7 +193,7 @@ func Command(command string, args ...string) Cmd { } // RunCmd runs a command and returns a Result -func RunCmd(cmd Cmd, cmdOperators ...func(*Cmd)) *Result { +func RunCmd(cmd Cmd, cmdOperators ...CmdOp) *Result { for _, op := range cmdOperators { op(&cmd) } @@ -237,7 +204,7 @@ func RunCmd(cmd Cmd, cmdOperators ...func(*Cmd)) *Result { return WaitOnCmd(cmd.Timeout, result) } -// RunCommand parses a command line and runs it, returning a result +// RunCommand runs a command with default options, and returns a result func RunCommand(command string, args ...string) *Result { return RunCmd(Command(command, args...)) } @@ -248,7 +215,7 @@ func StartCmd(cmd Cmd) *Result { if result.Error != nil { return result } - result.SetExitError(result.Cmd.Start()) + result.setExitError(result.Cmd.Start()) return result } @@ -283,7 +250,7 @@ func buildCmd(cmd Cmd) *Result { // only wait until the timeout. func WaitOnCmd(timeout time.Duration, result *Result) *Result { if timeout == time.Duration(0) { - result.SetExitError(result.Cmd.Wait()) + result.setExitError(result.Cmd.Wait()) return result } @@ -301,7 +268,7 @@ func WaitOnCmd(timeout time.Duration, result *Result) *Result { } result.Timeout = true case err := <-done: - result.SetExitError(err) + result.setExitError(err) } return result } diff --git a/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/icmd/exitcode.go b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/icmd/exitcode.go new file mode 100644 index 000000000..9356dbcde --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/icmd/exitcode.go @@ -0,0 +1,32 @@ +package icmd + +import ( + "os/exec" + "syscall" + + "github.com/pkg/errors" +) + +// getExitCode returns the ExitStatus of a process from the error returned by +// exec.Run(). If the exit status could not be parsed an error is returned. +func getExitCode(err error) (int, error) { + if exiterr, ok := err.(*exec.ExitError); ok { + if procExit, ok := exiterr.Sys().(syscall.WaitStatus); ok { + return procExit.ExitStatus(), nil + } + } + return 0, errors.Wrap(err, "failed to get exit code") +} + +func processExitCode(err error) (exitCode int) { + if err == nil { + return 0 + } + exitCode, exiterr := getExitCode(err) + if exiterr != nil { + // TODO: Fix this so we check the error's text. + // we've failed to retrieve exit code, so we set it to 127 + return 127 + } + return exitCode +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/icmd/ops.go b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/icmd/ops.go new file mode 100644 index 000000000..02b1d8402 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/icmd/ops.go @@ -0,0 +1,4 @@ +package icmd + +// CmdOp is an operation which modified a Cmd structure used to execute commands +type CmdOp func(*Cmd) diff --git a/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/poll/poll.go b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/poll/poll.go new file mode 100644 index 000000000..3838d38e1 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/poll/poll.go @@ -0,0 +1,133 @@ +/*Package poll provides tools for testing asynchronous code. + */ +package poll + +import ( + "fmt" + "time" +) + +// TestingT is the subset of testing.T used by WaitOn +type TestingT interface { + LogT + Fatalf(format string, args ...interface{}) +} + +// LogT is a logging interface that is passed to the WaitOn check function +type LogT interface { + Log(args ...interface{}) + Logf(format string, args ...interface{}) +} + +// Settings are used to configure the behaviour of WaitOn +type Settings struct { + // Timeout is the maximum time to wait for the condition. Defaults to 10s + Timeout time.Duration + // Delay is the time to sleep between checking the condition. Detaults to + // 1ms + Delay time.Duration +} + +func defaultConfig() *Settings { + return &Settings{Timeout: 10 * time.Second, Delay: time.Millisecond} +} + +// SettingOp is a function which accepts and modifies Settings +type SettingOp func(config *Settings) + +// WithDelay sets the delay to wait between polls +func WithDelay(delay time.Duration) SettingOp { + return func(config *Settings) { + config.Delay = delay + } +} + +// WithTimeout sets the timeout +func WithTimeout(timeout time.Duration) SettingOp { + return func(config *Settings) { + config.Timeout = timeout + } +} + +// Result of a check performed by WaitOn +type Result interface { + // Error indicates that the check failed and polling should stop, and the + // the has failed + Error() error + // Done indicates that polling should stop, and the test should proceed + Done() bool + // Message provides the most recent state when polling has not completed + Message() string +} + +type result struct { + done bool + message string + err error +} + +func (r result) Done() bool { + return r.done +} + +func (r result) Message() string { + return r.message +} + +func (r result) Error() error { + return r.err +} + +// Continue returns a Result that indicates to WaitOn that it should continue +// polling. The message text will be used as the failure message if the timeout +// is reached. +func Continue(message string, args ...interface{}) Result { + return result{message: fmt.Sprintf(message, args...)} +} + +// Success returns a Result where Done() returns true, which indicates to WaitOn +// that it should stop polling and exit without an error. +func Success() Result { + return result{done: true} +} + +// Error returns a Result that indicates to WaitOn that it should fail the test +// and stop polling. +func Error(err error) Result { + return result{err: err} +} + +// WaitOn a condition or until a timeout. Poll by calling check and exit when +// check returns a done Result. To fail a test and exit polling with an error +// return a error result. +func WaitOn(t TestingT, check func(t LogT) Result, pollOps ...SettingOp) { + config := defaultConfig() + for _, pollOp := range pollOps { + pollOp(config) + } + + var lastMessage string + after := time.After(config.Timeout) + chResult := make(chan Result) + for { + go func() { + chResult <- check(t) + }() + select { + case <-after: + if lastMessage == "" { + lastMessage = "first check never completed" + } + t.Fatalf("timeout hit after %s: %s", config.Timeout, lastMessage) + case result := <-chResult: + switch { + case result.Error() != nil: + t.Fatalf("polling check failed: %s", result.Error()) + case result.Done(): + return + } + time.Sleep(config.Delay) + lastMessage = result.Message() + } + } +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/skip/skip.go b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/skip/skip.go new file mode 100644 index 000000000..d92110b0e --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/skip/skip.go @@ -0,0 +1,133 @@ +/*Package skip provides functions for skipping based on a condition. + */ +package skip + +import ( + "bytes" + "fmt" + "go/ast" + "go/format" + "go/parser" + "go/token" + "io/ioutil" + "path" + "reflect" + "runtime" + "strings" + + "github.com/pkg/errors" +) + +type skipT interface { + Skip(args ...interface{}) + Log(args ...interface{}) +} + +// If skips the test if the check function returns true. The skip message will +// contain the name of the check function. Extra message text can be passed as a +// format string with args +func If(t skipT, check func() bool, msgAndArgs ...interface{}) { + if check() { + t.Skip(formatWithCustomMessage( + getFunctionName(check), + formatMessage(msgAndArgs...))) + } +} + +func getFunctionName(function func() bool) string { + funcPath := runtime.FuncForPC(reflect.ValueOf(function).Pointer()).Name() + return strings.SplitN(path.Base(funcPath), ".", 2)[1] +} + +// IfCondition skips the test if the condition is true. The skip message will +// contain the source of the expression passed as the condition. Extra message +// text can be passed as a format string with args. +func IfCondition(t skipT, condition bool, msgAndArgs ...interface{}) { + if !condition { + return + } + source, err := getConditionSource() + if err != nil { + t.Log(err.Error()) + t.Skip(formatMessage(msgAndArgs...)) + } + t.Skip(formatWithCustomMessage(source, formatMessage(msgAndArgs...))) +} + +func getConditionSource() (string, error) { + const callstackIndex = 3 + lines, err := getSourceLine(callstackIndex) + if err != nil { + return "", err + } + + for i := range lines { + source := strings.Join(lines[len(lines)-i-1:], "\n") + node, err := parser.ParseExpr(source) + if err == nil { + return getConditionArgFromAST(node) + } + } + return "", errors.Wrapf(err, "failed to parse source") +} + +// maxContextLines is the maximum number of lines to scan for a complete +// skip.If() statement +const maxContextLines = 10 + +// getSourceLines returns the source line which called skip.If() along with a +// few preceding lines. To properly parse the AST a complete statement is +// required, and that statement may be split across multiple lines, so include +// up to maxContextLines. +func getSourceLine(stackIndex int) ([]string, error) { + _, filename, line, ok := runtime.Caller(stackIndex) + if !ok { + return nil, errors.New("failed to get caller info") + } + + raw, err := ioutil.ReadFile(filename) + if err != nil { + return nil, errors.Wrapf(err, "failed to read source file: %s", filename) + } + + lines := strings.Split(string(raw), "\n") + if len(lines) < line { + return nil, errors.Errorf("file %s does not have line %d", filename, line) + } + firstLine := line - maxContextLines + if firstLine < 0 { + firstLine = 0 + } + return lines[firstLine:line], nil +} + +func getConditionArgFromAST(node ast.Expr) (string, error) { + switch expr := node.(type) { + case *ast.CallExpr: + buf := new(bytes.Buffer) + err := format.Node(buf, token.NewFileSet(), expr.Args[1]) + return buf.String(), err + } + return "", errors.New("unexpected ast") +} + +func formatMessage(msgAndArgs ...interface{}) string { + switch len(msgAndArgs) { + case 0: + return "" + case 1: + return msgAndArgs[0].(string) + default: + return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...) + } +} + +func formatWithCustomMessage(source, custom string) string { + switch { + case custom == "": + return source + case source == "": + return custom + } + return fmt.Sprintf("%s: %s", source, custom) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/LICENSE b/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/LICENSE deleted file mode 100644 index 8739a025e..000000000 --- a/vendor/github.com/docker/docker/vendor/github.com/jhowardmsft/opengcs/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 Microsoft - -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. \ No newline at end of file diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/README.md b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/README.md index a951f0db3..eabfb982b 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/README.md +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/README.md @@ -145,11 +145,33 @@ Your process field in the `config.json` should look like this below with `"termi "TERM=xterm" ], "cwd": "/", - "capabilities": [ - "CAP_AUDIT_WRITE", - "CAP_KILL", - "CAP_NET_BIND_SERVICE" - ], + "capabilities": { + "bounding": [ + "CAP_AUDIT_WRITE", + "CAP_KILL", + "CAP_NET_BIND_SERVICE" + ], + "effective": [ + "CAP_AUDIT_WRITE", + "CAP_KILL", + "CAP_NET_BIND_SERVICE" + ], + "inheritable": [ + "CAP_AUDIT_WRITE", + "CAP_KILL", + "CAP_NET_BIND_SERVICE" + ], + "permitted": [ + "CAP_AUDIT_WRITE", + "CAP_KILL", + "CAP_NET_BIND_SERVICE" + ], + "ambient": [ + "CAP_AUDIT_WRITE", + "CAP_KILL", + "CAP_NET_BIND_SERVICE" + ] + }, "rlimits": [ { "type": "RLIMIT_NOFILE", @@ -161,7 +183,7 @@ Your process field in the `config.json` should look like this below with `"termi }, ``` -Now we can go though the lifecycle operations in your shell. +Now we can go through the lifecycle operations in your shell. ```bash diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/README.md b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/README.md index d2a7d7889..42f3efe56 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/README.md +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/README.md @@ -56,25 +56,91 @@ Once you have an instance of the factory created we can create a configuration struct describing how the container is to be created. A sample would look similar to this: ```go -defaultMountFlags := syscall.MS_NOEXEC | syscall.MS_NOSUID | syscall.MS_NODEV +defaultMountFlags := unix.MS_NOEXEC | unix.MS_NOSUID | unix.MS_NODEV config := &configs.Config{ Rootfs: "/your/path/to/rootfs", - Capabilities: []string{ - "CAP_CHOWN", - "CAP_DAC_OVERRIDE", - "CAP_FSETID", - "CAP_FOWNER", - "CAP_MKNOD", - "CAP_NET_RAW", - "CAP_SETGID", - "CAP_SETUID", - "CAP_SETFCAP", - "CAP_SETPCAP", - "CAP_NET_BIND_SERVICE", - "CAP_SYS_CHROOT", - "CAP_KILL", - "CAP_AUDIT_WRITE", - }, + Capabilities: &configs.Capabilities{ + Bounding: []string{ + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_FSETID", + "CAP_FOWNER", + "CAP_MKNOD", + "CAP_NET_RAW", + "CAP_SETGID", + "CAP_SETUID", + "CAP_SETFCAP", + "CAP_SETPCAP", + "CAP_NET_BIND_SERVICE", + "CAP_SYS_CHROOT", + "CAP_KILL", + "CAP_AUDIT_WRITE", + }, + Effective: []string{ + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_FSETID", + "CAP_FOWNER", + "CAP_MKNOD", + "CAP_NET_RAW", + "CAP_SETGID", + "CAP_SETUID", + "CAP_SETFCAP", + "CAP_SETPCAP", + "CAP_NET_BIND_SERVICE", + "CAP_SYS_CHROOT", + "CAP_KILL", + "CAP_AUDIT_WRITE", + }, + Inheritable: []string{ + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_FSETID", + "CAP_FOWNER", + "CAP_MKNOD", + "CAP_NET_RAW", + "CAP_SETGID", + "CAP_SETUID", + "CAP_SETFCAP", + "CAP_SETPCAP", + "CAP_NET_BIND_SERVICE", + "CAP_SYS_CHROOT", + "CAP_KILL", + "CAP_AUDIT_WRITE", + }, + Permitted: []string{ + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_FSETID", + "CAP_FOWNER", + "CAP_MKNOD", + "CAP_NET_RAW", + "CAP_SETGID", + "CAP_SETUID", + "CAP_SETFCAP", + "CAP_SETPCAP", + "CAP_NET_BIND_SERVICE", + "CAP_SYS_CHROOT", + "CAP_KILL", + "CAP_AUDIT_WRITE", + }, + Ambient: []string{ + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_FSETID", + "CAP_FOWNER", + "CAP_MKNOD", + "CAP_NET_RAW", + "CAP_SETGID", + "CAP_SETUID", + "CAP_SETFCAP", + "CAP_SETPCAP", + "CAP_NET_BIND_SERVICE", + "CAP_SYS_CHROOT", + "CAP_KILL", + "CAP_AUDIT_WRITE", + }, + }, Namespaces: configs.Namespaces([]configs.Namespace{ {Type: configs.NEWNS}, {Type: configs.NEWUTS}, @@ -112,14 +178,14 @@ config := &configs.Config{ Source: "tmpfs", Destination: "/dev", Device: "tmpfs", - Flags: syscall.MS_NOSUID | syscall.MS_STRICTATIME, + Flags: unix.MS_NOSUID | unix.MS_STRICTATIME, Data: "mode=755", }, { Source: "devpts", Destination: "/dev/pts", Device: "devpts", - Flags: syscall.MS_NOSUID | syscall.MS_NOEXEC, + Flags: unix.MS_NOSUID | unix.MS_NOEXEC, Data: "newinstance,ptmxmode=0666,mode=0620,gid=5", }, { @@ -139,7 +205,7 @@ config := &configs.Config{ Source: "sysfs", Destination: "/sys", Device: "sysfs", - Flags: defaultMountFlags | syscall.MS_RDONLY, + Flags: defaultMountFlags | unix.MS_RDONLY, }, }, UidMappings: []configs.IDMap{ @@ -165,7 +231,7 @@ config := &configs.Config{ }, Rlimits: []configs.Rlimit{ { - Type: syscall.RLIMIT_NOFILE, + Type: unix.RLIMIT_NOFILE, Hard: uint64(1025), Soft: uint64(1025), }, diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/cgroups/stats.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/cgroups/stats.go index b483f1bf9..8eeedc55b 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/cgroups/stats.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/cgroups/stats.go @@ -51,6 +51,8 @@ type MemoryStats struct { KernelUsage MemoryData `json:"kernel_usage,omitempty"` // usage of kernel TCP memory KernelTCPUsage MemoryData `json:"kernel_tcp_usage,omitempty"` + // if true, memory usage is accounted for throughout a hierarchy of cgroups. + UseHierarchy bool `json:"use_hierarchy"` Stats map[string]uint64 `json:"stats,omitempty"` } diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/cgroups/utils.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/cgroups/utils.go index 5db373449..7c995efee 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/cgroups/utils.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/cgroups/utils.go @@ -66,6 +66,21 @@ func isSubsystemAvailable(subsystem string) bool { return avail } +func GetClosestMountpointAncestor(dir, mountinfo string) string { + deepestMountPoint := "" + for _, mountInfoEntry := range strings.Split(mountinfo, "\n") { + mountInfoParts := strings.Fields(mountInfoEntry) + if len(mountInfoParts) < 5 { + continue + } + mountPoint := mountInfoParts[4] + if strings.HasPrefix(mountPoint, deepestMountPoint) && strings.HasPrefix(dir, mountPoint) { + deepestMountPoint = mountPoint + } + } + return deepestMountPoint +} + func FindCgroupMountpointDir() (string, error) { f, err := os.Open("/proc/self/mountinfo") if err != nil { diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/cgroup_unix.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/cgroup_linux.go similarity index 94% rename from vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/cgroup_unix.go rename to vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/cgroup_linux.go index 75722890a..e15a662f5 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/cgroup_unix.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/cgroup_linux.go @@ -1,5 +1,3 @@ -// +build linux freebsd - package configs type FreezerState string @@ -45,19 +43,19 @@ type Resources struct { Devices []*Device `json:"devices"` // Memory limit (in bytes) - Memory uint64 `json:"memory"` + Memory int64 `json:"memory"` // Memory reservation or soft_limit (in bytes) - MemoryReservation uint64 `json:"memory_reservation"` + MemoryReservation int64 `json:"memory_reservation"` // Total memory usage (memory + swap); set `-1` to enable unlimited swap - MemorySwap uint64 `json:"memory_swap"` + MemorySwap int64 `json:"memory_swap"` // Kernel memory limit (in bytes) - KernelMemory uint64 `json:"kernel_memory"` + KernelMemory int64 `json:"kernel_memory"` // Kernel memory limit for TCP use (in bytes) - KernelMemoryTCP uint64 `json:"kernel_memory_tcp"` + KernelMemoryTCP int64 `json:"kernel_memory_tcp"` // CPU shares (relative weight vs. other containers) CpuShares uint64 `json:"cpu_shares"` diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/config.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/config.go index d681ad78c..269fffff3 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/config.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/config.go @@ -8,6 +8,7 @@ import ( "time" "github.com/opencontainers/runtime-spec/specs-go" + "github.com/sirupsen/logrus" ) diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/config_unix.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/config_linux.go similarity index 98% rename from vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/config_unix.go rename to vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/config_linux.go index 84463995d..07da10804 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/config_unix.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/config_linux.go @@ -1,5 +1,3 @@ -// +build freebsd linux - package configs import "fmt" diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_unix.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_linux.go similarity index 97% rename from vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_unix.go rename to vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_linux.go index 1f0b3ee28..5fc171a57 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_unix.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_linux.go @@ -1,5 +1,3 @@ -// +build linux freebsd - package configs import ( @@ -81,9 +79,6 @@ type Namespace struct { } func (n *Namespace) GetPath(pid int) string { - if n.Path != "" { - return n.Path - } return fmt.Sprintf("/proc/%d/ns/%s", pid, NsName(n.Type)) } diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_syscall.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_syscall.go index fb4b85222..4ce6813d2 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_syscall.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_syscall.go @@ -2,19 +2,19 @@ package configs -import "syscall" +import "golang.org/x/sys/unix" func (n *Namespace) Syscall() int { return namespaceInfo[n.Type] } var namespaceInfo = map[NamespaceType]int{ - NEWNET: syscall.CLONE_NEWNET, - NEWNS: syscall.CLONE_NEWNS, - NEWUSER: syscall.CLONE_NEWUSER, - NEWIPC: syscall.CLONE_NEWIPC, - NEWUTS: syscall.CLONE_NEWUTS, - NEWPID: syscall.CLONE_NEWPID, + NEWNET: unix.CLONE_NEWNET, + NEWNS: unix.CLONE_NEWNS, + NEWUSER: unix.CLONE_NEWUSER, + NEWIPC: unix.CLONE_NEWIPC, + NEWUTS: unix.CLONE_NEWUTS, + NEWPID: unix.CLONE_NEWPID, } // CloneFlags parses the container's Namespaces options to set the correct diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_unsupported.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_unsupported.go index 9a74033ce..19bf713de 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_unsupported.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/configs/namespaces_unsupported.go @@ -1,4 +1,4 @@ -// +build !linux,!freebsd +// +build !linux package configs diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/devices/devices_unix.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/devices/devices_linux.go similarity index 71% rename from vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/devices/devices_unix.go rename to vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/devices/devices_linux.go index f44e62ce8..326ad3b15 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/devices/devices_unix.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/devices/devices_linux.go @@ -1,16 +1,14 @@ -// +build linux freebsd - package devices import ( "errors" - "fmt" "io/ioutil" "os" "path/filepath" - "syscall" "github.com/opencontainers/runc/libcontainer/configs" + + "golang.org/x/sys/unix" ) var ( @@ -19,45 +17,45 @@ var ( // Testing dependencies var ( - osLstat = os.Lstat + unixLstat = unix.Lstat ioutilReadDir = ioutil.ReadDir ) // Given the path to a device and its cgroup_permissions(which cannot be easily queried) look up the information about a linux device and return that information as a Device struct. func DeviceFromPath(path, permissions string) (*configs.Device, error) { - fileInfo, err := osLstat(path) + var stat unix.Stat_t + err := unixLstat(path, &stat) if err != nil { return nil, err } + var ( - devType rune - mode = fileInfo.Mode() - fileModePermissionBits = os.FileMode.Perm(mode) + devNumber = int(stat.Rdev) + major = Major(devNumber) ) - switch { - case mode&os.ModeDevice == 0: + if major == 0 { return nil, ErrNotADevice - case mode&os.ModeCharDevice != 0: - fileModePermissionBits |= syscall.S_IFCHR - devType = 'c' - default: - fileModePermissionBits |= syscall.S_IFBLK - devType = 'b' } - stat_t, ok := fileInfo.Sys().(*syscall.Stat_t) - if !ok { - return nil, fmt.Errorf("cannot determine the device number for device %s", path) + + var ( + devType rune + mode = stat.Mode + ) + switch { + case mode&unix.S_IFBLK == unix.S_IFBLK: + devType = 'b' + case mode&unix.S_IFCHR == unix.S_IFCHR: + devType = 'c' } - devNumber := int(stat_t.Rdev) return &configs.Device{ Type: devType, Path: path, - Major: Major(devNumber), + Major: major, Minor: Minor(devNumber), Permissions: permissions, - FileMode: fileModePermissionBits, - Uid: stat_t.Uid, - Gid: stat_t.Gid, + FileMode: os.FileMode(mode), + Uid: stat.Uid, + Gid: stat.Gid, }, nil } diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/devices/devices_unsupported.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/devices/devices_unsupported.go index 1e84033da..6649b9f2d 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/devices/devices_unsupported.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/devices/devices_unsupported.go @@ -1,3 +1,3 @@ -// +build windows +// +build !linux package devices diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/nsenter/nsexec.c b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/nsenter/nsexec.c index 0ad688343..6814a5abb 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/nsenter/nsexec.c +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/nsenter/nsexec.c @@ -143,8 +143,7 @@ static int write_file(char *data, size_t data_len, char *pathfmt, ...) fd = open(path, O_RDWR); if (fd < 0) { - ret = -1; - goto out; + return -1; } len = write(fd, data, data_len); @@ -543,7 +542,7 @@ void nsexec(void) */ case JUMP_PARENT: { int len; - pid_t child; + pid_t child, first_child = -1; char buf[JSON_MAX]; bool ready = false; @@ -607,18 +606,18 @@ void nsexec(void) } break; case SYNC_RECVPID_PLS: { - pid_t old = child; + first_child = child; /* Get the init_func pid. */ if (read(syncfd, &child, sizeof(child)) != sizeof(child)) { - kill(old, SIGKILL); + kill(first_child, SIGKILL); bail("failed to sync with child: read(childpid)"); } /* Send ACK. */ s = SYNC_RECVPID_ACK; if (write(syncfd, &s, sizeof(s)) != sizeof(s)) { - kill(old, SIGKILL); + kill(first_child, SIGKILL); kill(child, SIGKILL); bail("failed to sync with child: write(SYNC_RECVPID_ACK)"); } @@ -666,8 +665,13 @@ void nsexec(void) } } - /* Send the init_func pid back to our parent. */ - len = snprintf(buf, JSON_MAX, "{\"pid\": %d}\n", child); + /* + * Send the init_func pid and the pid of the first child back to our parent. + * + * We need to send both back because we can't reap the first child we created (CLONE_PARENT). + * It becomes the responsibility of our parent to reap the first child. + */ + len = snprintf(buf, JSON_MAX, "{\"pid\": %d, \"pid_first\": %d}\n", child, first_child); if (len < 0) { kill(child, SIGKILL); bail("unable to generate JSON for child pid"); diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/linux.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/linux.go index 1afc52b4b..4837085a7 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/linux.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/linux.go @@ -7,8 +7,10 @@ import ( "fmt" "os" "os/exec" - "syscall" + "syscall" // only for exec "unsafe" + + "golang.org/x/sys/unix" ) // If arg2 is nonzero, set the "child subreaper" attribute of the @@ -53,8 +55,8 @@ func Execv(cmd string, args []string, env []string) error { return syscall.Exec(name, args, env) } -func Prlimit(pid, resource int, limit syscall.Rlimit) error { - _, _, err := syscall.RawSyscall6(syscall.SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(&limit)), uintptr(unsafe.Pointer(&limit)), 0, 0) +func Prlimit(pid, resource int, limit unix.Rlimit) error { + _, _, err := unix.RawSyscall6(unix.SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(&limit)), uintptr(unsafe.Pointer(&limit)), 0, 0) if err != 0 { return err } @@ -62,7 +64,7 @@ func Prlimit(pid, resource int, limit syscall.Rlimit) error { } func SetParentDeathSignal(sig uintptr) error { - if _, _, err := syscall.RawSyscall(syscall.SYS_PRCTL, syscall.PR_SET_PDEATHSIG, sig, 0); err != 0 { + if err := unix.Prctl(unix.PR_SET_PDEATHSIG, sig, 0, 0, 0); err != nil { return err } return nil @@ -70,15 +72,14 @@ func SetParentDeathSignal(sig uintptr) error { func GetParentDeathSignal() (ParentDeathSignal, error) { var sig int - _, _, err := syscall.RawSyscall(syscall.SYS_PRCTL, syscall.PR_GET_PDEATHSIG, uintptr(unsafe.Pointer(&sig)), 0) - if err != 0 { + if err := unix.Prctl(unix.PR_GET_PDEATHSIG, uintptr(unsafe.Pointer(&sig)), 0, 0, 0); err != nil { return -1, err } return ParentDeathSignal(sig), nil } func SetKeepCaps() error { - if _, _, err := syscall.RawSyscall(syscall.SYS_PRCTL, syscall.PR_SET_KEEPCAPS, 1, 0); err != 0 { + if err := unix.Prctl(unix.PR_SET_KEEPCAPS, 1, 0, 0, 0); err != nil { return err } @@ -86,7 +87,7 @@ func SetKeepCaps() error { } func ClearKeepCaps() error { - if _, _, err := syscall.RawSyscall(syscall.SYS_PRCTL, syscall.PR_SET_KEEPCAPS, 0, 0); err != 0 { + if err := unix.Prctl(unix.PR_SET_KEEPCAPS, 0, 0, 0, 0); err != nil { return err } @@ -94,7 +95,7 @@ func ClearKeepCaps() error { } func Setctty() error { - if _, _, err := syscall.RawSyscall(syscall.SYS_IOCTL, 0, uintptr(syscall.TIOCSCTTY), 0); err != 0 { + if err := unix.IoctlSetInt(0, unix.TIOCSCTTY, 0); err != nil { return err } return nil @@ -131,13 +132,5 @@ func RunningInUserNS() bool { // SetSubreaper sets the value i as the subreaper setting for the calling process func SetSubreaper(i int) error { - return Prctl(PR_SET_CHILD_SUBREAPER, uintptr(i), 0, 0, 0) -} - -func Prctl(option int, arg2, arg3, arg4, arg5 uintptr) (err error) { - _, _, e1 := syscall.Syscall6(syscall.SYS_PRCTL, uintptr(option), arg2, arg3, arg4, arg5, 0) - if e1 != 0 { - err = e1 - } - return + return unix.Prctl(PR_SET_CHILD_SUBREAPER, uintptr(i), 0, 0, 0) } diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/proc.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/proc.go index a0e963719..79232a437 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/proc.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/proc.go @@ -1,43 +1,113 @@ package system import ( + "fmt" "io/ioutil" "path/filepath" "strconv" "strings" ) -// look in /proc to find the process start time so that we can verify -// that this pid has started after ourself +// State is the status of a process. +type State rune + +const ( // Only values for Linux 3.14 and later are listed here + Dead State = 'X' + DiskSleep State = 'D' + Running State = 'R' + Sleeping State = 'S' + Stopped State = 'T' + TracingStop State = 't' + Zombie State = 'Z' +) + +// String forms of the state from proc(5)'s documentation for +// /proc/[pid]/status' "State" field. +func (s State) String() string { + switch s { + case Dead: + return "dead" + case DiskSleep: + return "disk sleep" + case Running: + return "running" + case Sleeping: + return "sleeping" + case Stopped: + return "stopped" + case TracingStop: + return "tracing stop" + case Zombie: + return "zombie" + default: + return fmt.Sprintf("unknown (%c)", s) + } +} + +// Stat_t represents the information from /proc/[pid]/stat, as +// described in proc(5) with names based on the /proc/[pid]/status +// fields. +type Stat_t struct { + // PID is the process ID. + PID uint + + // Name is the command run by the process. + Name string + + // State is the state of the process. + State State + + // StartTime is the number of clock ticks after system boot (since + // Linux 2.6). + StartTime uint64 +} + +// Stat returns a Stat_t instance for the specified process. +func Stat(pid int) (stat Stat_t, err error) { + bytes, err := ioutil.ReadFile(filepath.Join("/proc", strconv.Itoa(pid), "stat")) + if err != nil { + return stat, err + } + return parseStat(string(bytes)) +} + +// GetProcessStartTime is deprecated. Use Stat(pid) and +// Stat_t.StartTime instead. func GetProcessStartTime(pid int) (string, error) { - data, err := ioutil.ReadFile(filepath.Join("/proc", strconv.Itoa(pid), "stat")) + stat, err := Stat(pid) if err != nil { return "", err } - return parseStartTime(string(data)) + return fmt.Sprintf("%d", stat.StartTime), nil } -func parseStartTime(stat string) (string, error) { - // the starttime is located at pos 22 - // from the man page - // - // starttime %llu (was %lu before Linux 2.6) - // (22) The time the process started after system boot. In kernels before Linux 2.6, this - // value was expressed in jiffies. Since Linux 2.6, the value is expressed in clock ticks - // (divide by sysconf(_SC_CLK_TCK)). - // - // NOTE: - // pos 2 could contain space and is inside `(` and `)`: - // (2) comm %s - // The filename of the executable, in parentheses. - // This is visible whether or not the executable is - // swapped out. - // - // the following is an example: +func parseStat(data string) (stat Stat_t, err error) { + // From proc(5), field 2 could contain space and is inside `(` and `)`. + // The following is an example: // 89653 (gunicorn: maste) S 89630 89653 89653 0 -1 4194560 29689 28896 0 3 146 32 76 19 20 0 1 0 2971844 52965376 3920 18446744073709551615 1 1 0 0 0 0 0 16781312 137447943 0 0 0 17 1 0 0 0 0 0 0 0 0 0 0 0 0 0 + i := strings.LastIndex(data, ")") + if i <= 2 || i >= len(data)-1 { + return stat, fmt.Errorf("invalid stat data: %q", data) + } + + parts := strings.SplitN(data[:i], "(", 2) + if len(parts) != 2 { + return stat, fmt.Errorf("invalid stat data: %q", data) + } + + stat.Name = parts[1] + _, err = fmt.Sscanf(parts[0], "%d", &stat.PID) + if err != nil { + return stat, err + } - // get parts after last `)`: - s := strings.Split(stat, ")") - parts := strings.Split(strings.TrimSpace(s[len(s)-1]), " ") - return parts[22-3], nil // starts at 3 (after the filename pos `2`) + // parts indexes should be offset by 3 from the field number given + // proc(5), because parts is zero-indexed and we've removed fields + // one (PID) and two (Name) in the paren-split. + parts = strings.Split(data[i+2:], " ") + var state int + fmt.Sscanf(parts[3-3], "%c", &state) + stat.State = State(state) + fmt.Sscanf(parts[22-3], "%d", &stat.StartTime) + return stat, nil } diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/setns_linux.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/setns_linux.go deleted file mode 100644 index 615ff4c82..000000000 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/setns_linux.go +++ /dev/null @@ -1,40 +0,0 @@ -package system - -import ( - "fmt" - "runtime" - "syscall" -) - -// Via http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=7b21fddd087678a70ad64afc0f632e0f1071b092 -// -// We need different setns values for the different platforms and arch -// We are declaring the macro here because the SETNS syscall does not exist in th stdlib -var setNsMap = map[string]uintptr{ - "linux/386": 346, - "linux/arm64": 268, - "linux/amd64": 308, - "linux/arm": 375, - "linux/ppc": 350, - "linux/ppc64": 350, - "linux/ppc64le": 350, - "linux/s390x": 339, -} - -var sysSetns = setNsMap[fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)] - -func SysSetns() uint32 { - return uint32(sysSetns) -} - -func Setns(fd uintptr, flags uintptr) error { - ns, exists := setNsMap[fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)] - if !exists { - return fmt.Errorf("unsupported platform %s/%s", runtime.GOOS, runtime.GOARCH) - } - _, _, err := syscall.RawSyscall(ns, fd, flags, 0) - if err != 0 { - return err - } - return nil -} diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_386.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_386.go index bb44d895c..3f7235ed1 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_386.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_386.go @@ -3,12 +3,12 @@ package system import ( - "syscall" + "golang.org/x/sys/unix" ) // Setuid sets the uid of the calling thread to the specified uid. func Setuid(uid int) (err error) { - _, _, e1 := syscall.RawSyscall(syscall.SYS_SETUID32, uintptr(uid), 0, 0) + _, _, e1 := unix.RawSyscall(unix.SYS_SETUID32, uintptr(uid), 0, 0) if e1 != 0 { err = e1 } @@ -17,7 +17,7 @@ func Setuid(uid int) (err error) { // Setgid sets the gid of the calling thread to the specified gid. func Setgid(gid int) (err error) { - _, _, e1 := syscall.RawSyscall(syscall.SYS_SETGID32, uintptr(gid), 0, 0) + _, _, e1 := unix.RawSyscall(unix.SYS_SETGID32, uintptr(gid), 0, 0) if e1 != 0 { err = e1 } diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go index 0816bf828..d7891a2ff 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go @@ -3,12 +3,12 @@ package system import ( - "syscall" + "golang.org/x/sys/unix" ) // Setuid sets the uid of the calling thread to the specified uid. func Setuid(uid int) (err error) { - _, _, e1 := syscall.RawSyscall(syscall.SYS_SETUID, uintptr(uid), 0, 0) + _, _, e1 := unix.RawSyscall(unix.SYS_SETUID, uintptr(uid), 0, 0) if e1 != 0 { err = e1 } @@ -17,7 +17,7 @@ func Setuid(uid int) (err error) { // Setgid sets the gid of the calling thread to the specified gid. func Setgid(gid int) (err error) { - _, _, e1 := syscall.RawSyscall(syscall.SYS_SETGID, uintptr(gid), 0, 0) + _, _, e1 := unix.RawSyscall(unix.SYS_SETGID, uintptr(gid), 0, 0) if e1 != 0 { err = e1 } diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_arm.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_arm.go index 3f780f312..31ff3deb1 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_arm.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_arm.go @@ -3,12 +3,12 @@ package system import ( - "syscall" + "golang.org/x/sys/unix" ) // Setuid sets the uid of the calling thread to the specified uid. func Setuid(uid int) (err error) { - _, _, e1 := syscall.RawSyscall(syscall.SYS_SETUID32, uintptr(uid), 0, 0) + _, _, e1 := unix.RawSyscall(unix.SYS_SETUID32, uintptr(uid), 0, 0) if e1 != 0 { err = e1 } @@ -17,7 +17,7 @@ func Setuid(uid int) (err error) { // Setgid sets the gid of the calling thread to the specified gid. func Setgid(gid int) (err error) { - _, _, e1 := syscall.RawSyscall(syscall.SYS_SETGID32, uintptr(gid), 0, 0) + _, _, e1 := unix.RawSyscall(unix.SYS_SETGID32, uintptr(gid), 0, 0) if e1 != 0 { err = e1 } diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/xattrs_linux.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/xattrs_linux.go index 30f74dfb1..a6823fc99 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/xattrs_linux.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/xattrs_linux.go @@ -1,99 +1,35 @@ package system -import ( - "syscall" - "unsafe" -) - -var _zero uintptr - -// Returns the size of xattrs and nil error -// Requires path, takes allocated []byte or nil as last argument -func Llistxattr(path string, dest []byte) (size int, err error) { - pathBytes, err := syscall.BytePtrFromString(path) - if err != nil { - return -1, err - } - var newpathBytes unsafe.Pointer - if len(dest) > 0 { - newpathBytes = unsafe.Pointer(&dest[0]) - } else { - newpathBytes = unsafe.Pointer(&_zero) - } - - _size, _, errno := syscall.Syscall6(syscall.SYS_LLISTXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(newpathBytes), uintptr(len(dest)), 0, 0, 0) - size = int(_size) - if errno != 0 { - return -1, errno - } - - return size, nil -} +import "golang.org/x/sys/unix" // Returns a []byte slice if the xattr is set and nil otherwise // Requires path and its attribute as arguments func Lgetxattr(path string, attr string) ([]byte, error) { var sz int - pathBytes, err := syscall.BytePtrFromString(path) - if err != nil { - return nil, err - } - attrBytes, err := syscall.BytePtrFromString(attr) - if err != nil { - return nil, err - } - // Start with a 128 length byte array - sz = 128 - dest := make([]byte, sz) - destBytes := unsafe.Pointer(&dest[0]) - _sz, _, errno := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0) + dest := make([]byte, 128) + sz, errno := unix.Lgetxattr(path, attr, dest) switch { - case errno == syscall.ENODATA: + case errno == unix.ENODATA: return nil, errno - case errno == syscall.ENOTSUP: + case errno == unix.ENOTSUP: return nil, errno - case errno == syscall.ERANGE: + case errno == unix.ERANGE: // 128 byte array might just not be good enough, - // A dummy buffer is used ``uintptr(0)`` to get real size + // A dummy buffer is used to get the real size // of the xattrs on disk - _sz, _, errno = syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(unsafe.Pointer(nil)), uintptr(0), 0, 0) - sz = int(_sz) - if sz < 0 { + sz, errno = unix.Lgetxattr(path, attr, []byte{}) + if errno != nil { return nil, errno } dest = make([]byte, sz) - destBytes := unsafe.Pointer(&dest[0]) - _sz, _, errno = syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0) - if errno != 0 { + sz, errno = unix.Lgetxattr(path, attr, dest) + if errno != nil { return nil, errno } - case errno != 0: + case errno != nil: return nil, errno } - sz = int(_sz) return dest[:sz], nil } - -func Lsetxattr(path string, attr string, data []byte, flags int) error { - pathBytes, err := syscall.BytePtrFromString(path) - if err != nil { - return err - } - attrBytes, err := syscall.BytePtrFromString(attr) - if err != nil { - return err - } - var dataBytes unsafe.Pointer - if len(data) > 0 { - dataBytes = unsafe.Pointer(&data[0]) - } else { - dataBytes = unsafe.Pointer(&_zero) - } - _, _, errno := syscall.Syscall6(syscall.SYS_LSETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(dataBytes), uintptr(len(data)), uintptr(flags), 0) - if errno != 0 { - return errno - } - return nil -} diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user/lookup.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user/lookup.go index ab1439f36..95e9eebc0 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user/lookup.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user/lookup.go @@ -2,7 +2,6 @@ package user import ( "errors" - "syscall" ) var ( @@ -36,13 +35,6 @@ func lookupUser(filter func(u User) bool) (User, error) { return users[0], nil } -// CurrentUser looks up the current user by their user id in /etc/passwd. If the -// user cannot be found (or there is no /etc/passwd file on the filesystem), -// then CurrentUser returns an error. -func CurrentUser() (User, error) { - return LookupUid(syscall.Getuid()) -} - // LookupUser looks up a user by their username in /etc/passwd. If the user // cannot be found (or there is no /etc/passwd file on the filesystem), then // LookupUser returns an error. @@ -84,13 +76,6 @@ func lookupGroup(filter func(g Group) bool) (Group, error) { return groups[0], nil } -// CurrentGroup looks up the current user's group by their primary group id's -// entry in /etc/passwd. If the group cannot be found (or there is no -// /etc/group file on the filesystem), then CurrentGroup returns an error. -func CurrentGroup() (Group, error) { - return LookupGid(syscall.Getgid()) -} - // LookupGroup looks up a group by its name in /etc/group. If the group cannot // be found (or there is no /etc/group file on the filesystem), then LookupGroup // returns an error. diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user/lookup_unix.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user/lookup_unix.go index 758b734c2..c2bb9ec90 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user/lookup_unix.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user/lookup_unix.go @@ -5,6 +5,8 @@ package user import ( "io" "os" + + "golang.org/x/sys/unix" ) // Unix-specific path to the passwd and group formatted files. @@ -28,3 +30,17 @@ func GetGroupPath() (string, error) { func GetGroup() (io.ReadCloser, error) { return os.Open(unixGroupPath) } + +// CurrentUser looks up the current user by their user id in /etc/passwd. If the +// user cannot be found (or there is no /etc/passwd file on the filesystem), +// then CurrentUser returns an error. +func CurrentUser() (User, error) { + return LookupUid(unix.Getuid()) +} + +// CurrentGroup looks up the current user's group by their primary group id's +// entry in /etc/passwd. If the group cannot be found (or there is no +// /etc/group file on the filesystem), then CurrentGroup returns an error. +func CurrentGroup() (Group, error) { + return LookupGid(unix.Getgid()) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user/lookup_unsupported.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user/lookup_unsupported.go index 721794887..4a8d00acb 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user/lookup_unsupported.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user/lookup_unsupported.go @@ -2,7 +2,10 @@ package user -import "io" +import ( + "io" + "syscall" +) func GetPasswdPath() (string, error) { return "", ErrUnsupported @@ -19,3 +22,17 @@ func GetGroupPath() (string, error) { func GetGroup() (io.ReadCloser, error) { return nil, ErrUnsupported } + +// CurrentUser looks up the current user by their user id in /etc/passwd. If the +// user cannot be found (or there is no /etc/passwd file on the filesystem), +// then CurrentUser returns an error. +func CurrentUser() (User, error) { + return LookupUid(syscall.Getuid()) +} + +// CurrentGroup looks up the current user's group by their primary group id's +// entry in /etc/passwd. If the group cannot be found (or there is no +// /etc/group file on the filesystem), then CurrentGroup returns an error. +func CurrentGroup() (Group, error) { + return LookupGid(syscall.Getgid()) +} diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/vendor.conf b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/vendor.conf index 6ab9bf87a..9506b5c67 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/vendor.conf +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runc/vendor.conf @@ -1,21 +1,21 @@ # OCI runtime-spec. When updating this, make sure you use a version tag rather # than a commit ID so it's much more obvious what version of the spec we are # using. -github.com/opencontainers/runtime-spec v1.0.0-rc5 +github.com/opencontainers/runtime-spec v1.0.0 # Core libcontainer functionality. github.com/mrunalp/fileutils ed869b029674c0e9ce4c0dfa781405c2d9946d08 github.com/opencontainers/selinux v1.0.0-rc1 github.com/seccomp/libseccomp-golang 32f571b70023028bd57d9288c20efbcb237f3ce0 -github.com/Sirupsen/logrus 26709e2714106fb8ad40b773b711ebce25b78914 -github.com/syndtr/gocapability e7cb7fa329f456b3855136a2642b197bad7366ba +github.com/sirupsen/logrus a3f95b5c423586578a4e099b11a46c2479628cac +github.com/syndtr/gocapability db04d3cc01c8b54962a58ec7e491717d06cfcc16 github.com/vishvananda/netlink 1e2e08e8a2dcdacaae3f14ac44c5cfa31361f270 # systemd integration. github.com/coreos/go-systemd v14 github.com/coreos/pkg v3 github.com/godbus/dbus v3 -github.com/golang/protobuf f7137ae6b19afbfd61a94b746fda3b3fe0491874 +github.com/golang/protobuf 18c9bb3261723cd5401db4d0c9fbc5c3b6c70fe8 # Command-line interface. github.com/docker/docker 0f5c9d301b9b1cca66b3ea0f9dec3b5317d3686d github.com/docker/go-units v0.2.0 github.com/urfave/cli d53eb991652b1d438abdd34ce4bfa3ef1539108e -golang.org/x/sys 9a7256cb28ed514b4e1e5f68959914c4c28a92e0 https://github.com/golang/sys +golang.org/x/sys 0e0164865330d5cf1c00247be08330bf96e2f87c https://github.com/golang/sys diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/README.md b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/README.md index 1364f6fcb..2f7eb6086 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/README.md +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/README.md @@ -10,7 +10,6 @@ Additional documentation about how this group operates: - [Code of Conduct][code-of-conduct] - [Style and Conventions](style.md) -- [Roadmap](ROADMAP.md) - [Implementations](implementations.md) - [Releases](RELEASES.md) - [project](project.md) @@ -33,12 +32,7 @@ Example use cases include sophisticated network configuration, volume garbage co ### Runtime Developers -Runtime developers can build runtime implementations that run OCI-compliant bundles and container configuration, containing low-level OS and host specific details, on a particular platform. - -## Releases - -There is a loose [Road Map](./ROADMAP.md). -During the `0.x` series of OCI releases we make no backwards compatibility guarantees and intend to break the schema during this series. +Runtime developers can build runtime implementations that run OCI-compliant bundles and container configuration, containing low-level OS and host-specific details, on a particular platform. ## Contributing @@ -63,7 +57,7 @@ When in doubt, start on the [mailing-list](#mailing-list). The contributors and maintainers of all OCI projects have a weekly meeting on Wednesdays at: * 8:00 AM (USA Pacific), during [odd weeks][iso-week]. -* 5:00 PM (USA Pacific), during [even weeks][iso-week]. +* 2:00 PM (USA Pacific), during [even weeks][iso-week]. There is an [iCalendar][rfc5545] format for the meetings [here](meeting.ics). @@ -145,7 +139,7 @@ Read more on [How to Write a Git Commit Message][how-to-git-commit] or the Discu 5. Use the imperative mood in the subject line 6. Wrap the body at 72 characters 7. Use the body to explain what and why vs. how - * If there was important/useful/essential conversation or information, copy or include a reference + * If there was important/useful/essential conversation or information, copy or include a reference 8. When possible, one keyword to scope the change in the subject (i.e. "README: ...", "runtime: ...") diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/specs-go/config.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/specs-go/config.go index da9040594..f3f37d42d 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/specs-go/config.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/specs-go/config.go @@ -6,26 +6,24 @@ import "os" type Spec struct { // Version of the Open Container Runtime Specification with which the bundle complies. Version string `json:"ociVersion"` - // Platform specifies the configuration's target platform. - Platform Platform `json:"platform"` // Process configures the container process. - Process Process `json:"process"` + Process *Process `json:"process,omitempty"` // Root configures the container's root filesystem. - Root Root `json:"root"` + Root *Root `json:"root,omitempty"` // Hostname configures the container's hostname. Hostname string `json:"hostname,omitempty"` // Mounts configures additional mounts (on top of Root). Mounts []Mount `json:"mounts,omitempty"` // Hooks configures callbacks for container lifecycle events. - Hooks *Hooks `json:"hooks,omitempty"` + Hooks *Hooks `json:"hooks,omitempty" platform:"linux,solaris"` // Annotations contains arbitrary metadata for the container. Annotations map[string]string `json:"annotations,omitempty"` - // Linux is platform specific configuration for Linux based containers. + // Linux is platform-specific configuration for Linux based containers. Linux *Linux `json:"linux,omitempty" platform:"linux"` - // Solaris is platform specific configuration for Solaris containers. + // Solaris is platform-specific configuration for Solaris based containers. Solaris *Solaris `json:"solaris,omitempty" platform:"solaris"` - // Windows is platform specific configuration for Windows based containers, including Hyper-V containers. + // Windows is platform-specific configuration for Windows based containers. Windows *Windows `json:"windows,omitempty" platform:"windows"` } @@ -34,7 +32,7 @@ type Process struct { // Terminal creates an interactive terminal for the container. Terminal bool `json:"terminal,omitempty"` // ConsoleSize specifies the size of the console. - ConsoleSize Box `json:"consoleSize,omitempty"` + ConsoleSize *Box `json:"consoleSize,omitempty"` // User specifies user information for the process. User User `json:"user"` // Args specifies the binary and arguments for the application to execute. @@ -47,11 +45,13 @@ type Process struct { // Capabilities are Linux capabilities that are kept for the process. Capabilities *LinuxCapabilities `json:"capabilities,omitempty" platform:"linux"` // Rlimits specifies rlimit options to apply to the process. - Rlimits []LinuxRlimit `json:"rlimits,omitempty" platform:"linux"` + Rlimits []POSIXRlimit `json:"rlimits,omitempty" platform:"linux,solaris"` // NoNewPrivileges controls whether additional privileges could be gained by processes in the container. NoNewPrivileges bool `json:"noNewPrivileges,omitempty" platform:"linux"` // ApparmorProfile specifies the apparmor profile for the container. ApparmorProfile string `json:"apparmorProfile,omitempty" platform:"linux"` + // Specify an oom_score_adj for the container. + OOMScoreAdj *int `json:"oomScoreAdj,omitempty" platform:"linux"` // SelinuxLabel specifies the selinux context that the container process is run as. SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"` } @@ -99,23 +99,13 @@ type Root struct { Readonly bool `json:"readonly,omitempty"` } -// Platform specifies OS and arch information for the host system that the container -// is created for. -type Platform struct { - // OS is the operating system. - OS string `json:"os"` - // Arch is the architecture - Arch string `json:"arch"` -} - // Mount specifies a mount for a container. type Mount struct { - // Destination is the path where the mount will be placed relative to the container's root. The path and child directories MUST exist, a runtime MUST NOT create directories automatically to a mount point. + // Destination is the absolute path where the mount will be placed in the container. Destination string `json:"destination"` // Type specifies the mount kind. - Type string `json:"type,omitempty"` - // Source specifies the source path of the mount. In the case of bind mounts on - // Linux based systems this would be the file on the host. + Type string `json:"type,omitempty" platform:"linux,solaris"` + // Source specifies the source path of the mount. Source string `json:"source,omitempty"` // Options are fstab style mount options. Options []string `json:"options,omitempty"` @@ -132,7 +122,6 @@ type Hook struct { // Hooks for container setup and teardown type Hooks struct { // Prestart is a list of hooks to be run before the container process is executed. - // On Linux, they are run after the container namespaces are created. Prestart []Hook `json:"prestart,omitempty"` // Poststart is a list of hooks to be run after the container process is started. Poststart []Hook `json:"poststart,omitempty"` @@ -140,11 +129,11 @@ type Hooks struct { Poststop []Hook `json:"poststop,omitempty"` } -// Linux contains platform specific configuration for Linux based containers. +// Linux contains platform-specific configuration for Linux based containers. type Linux struct { - // UIDMapping specifies user mappings for supporting user namespaces on Linux. + // UIDMapping specifies user mappings for supporting user namespaces. UIDMappings []LinuxIDMapping `json:"uidMappings,omitempty"` - // GIDMapping specifies group mappings for supporting user namespaces on Linux. + // GIDMapping specifies group mappings for supporting user namespaces. GIDMappings []LinuxIDMapping `json:"gidMappings,omitempty"` // Sysctl are a set of key value pairs that are set for the container on start Sysctl map[string]string `json:"sysctl,omitempty"` @@ -176,7 +165,7 @@ type Linux struct { // LinuxNamespace is the configuration for a Linux namespace type LinuxNamespace struct { - // Type is the type of Linux namespace + // Type is the type of namespace Type LinuxNamespaceType `json:"type"` // Path is a path to an existing namespace persisted on disk that can be joined // and is of the same type @@ -213,8 +202,8 @@ type LinuxIDMapping struct { Size uint32 `json:"size"` } -// LinuxRlimit type and restrictions -type LinuxRlimit struct { +// POSIXRlimit type and restrictions +type POSIXRlimit struct { // Type of the rlimit to set Type string `json:"type"` // Hard is the hard limit for the specified type @@ -247,7 +236,7 @@ type linuxBlockIODevice struct { Minor int64 `json:"minor"` } -// LinuxWeightDevice struct holds a `major:minor weight` pair for blkioWeightDevice +// LinuxWeightDevice struct holds a `major:minor weight` pair for weightDevice type LinuxWeightDevice struct { linuxBlockIODevice // Weight is the bandwidth rate for the device. @@ -266,35 +255,37 @@ type LinuxThrottleDevice struct { // LinuxBlockIO for Linux cgroup 'blkio' resource management type LinuxBlockIO struct { // Specifies per cgroup weight - Weight *uint16 `json:"blkioWeight,omitempty"` + Weight *uint16 `json:"weight,omitempty"` // Specifies tasks' weight in the given cgroup while competing with the cgroup's child cgroups, CFQ scheduler only - LeafWeight *uint16 `json:"blkioLeafWeight,omitempty"` + LeafWeight *uint16 `json:"leafWeight,omitempty"` // Weight per cgroup per device, can override BlkioWeight - WeightDevice []LinuxWeightDevice `json:"blkioWeightDevice,omitempty"` + WeightDevice []LinuxWeightDevice `json:"weightDevice,omitempty"` // IO read rate limit per cgroup per device, bytes per second - ThrottleReadBpsDevice []LinuxThrottleDevice `json:"blkioThrottleReadBpsDevice,omitempty"` + ThrottleReadBpsDevice []LinuxThrottleDevice `json:"throttleReadBpsDevice,omitempty"` // IO write rate limit per cgroup per device, bytes per second - ThrottleWriteBpsDevice []LinuxThrottleDevice `json:"blkioThrottleWriteBpsDevice,omitempty"` + ThrottleWriteBpsDevice []LinuxThrottleDevice `json:"throttleWriteBpsDevice,omitempty"` // IO read rate limit per cgroup per device, IO per second - ThrottleReadIOPSDevice []LinuxThrottleDevice `json:"blkioThrottleReadIOPSDevice,omitempty"` + ThrottleReadIOPSDevice []LinuxThrottleDevice `json:"throttleReadIOPSDevice,omitempty"` // IO write rate limit per cgroup per device, IO per second - ThrottleWriteIOPSDevice []LinuxThrottleDevice `json:"blkioThrottleWriteIOPSDevice,omitempty"` + ThrottleWriteIOPSDevice []LinuxThrottleDevice `json:"throttleWriteIOPSDevice,omitempty"` } // LinuxMemory for Linux cgroup 'memory' resource management type LinuxMemory struct { // Memory limit (in bytes). - Limit *uint64 `json:"limit,omitempty"` + Limit *int64 `json:"limit,omitempty"` // Memory reservation or soft_limit (in bytes). - Reservation *uint64 `json:"reservation,omitempty"` + Reservation *int64 `json:"reservation,omitempty"` // Total memory limit (memory + swap). - Swap *uint64 `json:"swap,omitempty"` + Swap *int64 `json:"swap,omitempty"` // Kernel memory limit (in bytes). - Kernel *uint64 `json:"kernel,omitempty"` + Kernel *int64 `json:"kernel,omitempty"` // Kernel memory limit for tcp (in bytes) - KernelTCP *uint64 `json:"kernelTCP,omitempty"` - // How aggressive the kernel will swap memory pages. Range from 0 to 100. + KernelTCP *int64 `json:"kernelTCP,omitempty"` + // How aggressive the kernel will swap memory pages. Swappiness *uint64 `json:"swappiness,omitempty"` + // DisableOOMKiller disables the OOM killer for out of memory conditions + DisableOOMKiller *bool `json:"disableOOMKiller,omitempty"` } // LinuxCPU for Linux cgroup 'cpu' resource management @@ -333,10 +324,6 @@ type LinuxNetwork struct { type LinuxResources struct { // Devices configures the device whitelist. Devices []LinuxDeviceCgroup `json:"devices,omitempty"` - // DisableOOMKiller disables the OOM killer for out of memory conditions - DisableOOMKiller *bool `json:"disableOOMKiller,omitempty"` - // Specify an oom_score_adj for the container. - OOMScoreAdj *int `json:"oomScoreAdj,omitempty"` // Memory restriction configuration Memory *LinuxMemory `json:"memory,omitempty"` // CPU resource restriction configuration @@ -383,7 +370,7 @@ type LinuxDeviceCgroup struct { Access string `json:"access,omitempty"` } -// Solaris contains platform specific configuration for Solaris application containers. +// Solaris contains platform-specific configuration for Solaris application containers. type Solaris struct { // SMF FMRI which should go "online" before we start the container process. Milestone string `json:"milestone,omitempty"` @@ -430,8 +417,20 @@ type SolarisAnet struct { // Windows defines the runtime configuration for Windows based containers, including Hyper-V containers. type Windows struct { + // LayerFolders contains a list of absolute paths to directories containing image layers. + LayerFolders []string `json:"layerFolders"` // Resources contains information for handling resource constraints for the container. Resources *WindowsResources `json:"resources,omitempty"` + // CredentialSpec contains a JSON object describing a group Managed Service Account (gMSA) specification. + CredentialSpec interface{} `json:"credentialSpec,omitempty"` + // Servicing indicates if the container is being started in a mode to apply a Windows Update servicing operation. + Servicing bool `json:"servicing,omitempty"` + // IgnoreFlushesDuringBoot indicates if the container is being started in a mode where disk writes are not flushed during its boot process. + IgnoreFlushesDuringBoot bool `json:"ignoreFlushesDuringBoot,omitempty"` + // HyperV contains information for running a container with Hyper-V isolation. + HyperV *WindowsHyperV `json:"hyperv,omitempty"` + // Network restriction configuration. + Network *WindowsNetwork `json:"network,omitempty"` } // WindowsResources has container runtime resource constraints for containers running on Windows. @@ -442,23 +441,19 @@ type WindowsResources struct { CPU *WindowsCPUResources `json:"cpu,omitempty"` // Storage restriction configuration. Storage *WindowsStorageResources `json:"storage,omitempty"` - // Network restriction configuration. - Network *WindowsNetworkResources `json:"network,omitempty"` } // WindowsMemoryResources contains memory resource management settings. type WindowsMemoryResources struct { // Memory limit in bytes. Limit *uint64 `json:"limit,omitempty"` - // Memory reservation in bytes. - Reservation *uint64 `json:"reservation,omitempty"` } // WindowsCPUResources contains CPU resource management settings. type WindowsCPUResources struct { // Number of CPUs available to the container. Count *uint64 `json:"count,omitempty"` - // CPU shares (relative weight to other containers with cpu shares). Range is from 1 to 10000. + // CPU shares (relative weight to other containers with cpu shares). Shares *uint16 `json:"shares,omitempty"` // Specifies the portion of processor cycles that this container can use as a percentage times 100. Maximum *uint16 `json:"maximum,omitempty"` @@ -474,10 +469,22 @@ type WindowsStorageResources struct { SandboxSize *uint64 `json:"sandboxSize,omitempty"` } -// WindowsNetworkResources contains network resource management settings. -type WindowsNetworkResources struct { - // EgressBandwidth is the maximum egress bandwidth in bytes per second. - EgressBandwidth *uint64 `json:"egressBandwidth,omitempty"` +// WindowsNetwork contains network settings for Windows containers. +type WindowsNetwork struct { + // List of HNS endpoints that the container should connect to. + EndpointList []string `json:"endpointList,omitempty"` + // Specifies if unqualified DNS name resolution is allowed. + AllowUnqualifiedDNSQuery bool `json:"allowUnqualifiedDNSQuery,omitempty"` + // Comma separated list of DNS suffixes to use for name resolution. + DNSSearchList []string `json:"DNSSearchList,omitempty"` + // Name (ID) of the container that we will share with the network stack. + NetworkSharedContainerName string `json:"networkSharedContainerName,omitempty"` +} + +// WindowsHyperV contains information for configuring a container to run with Hyper-V isolation. +type WindowsHyperV struct { + // UtilityVMPath is an optional path to the image used for the Utility VM. + UtilityVMPath string `json:"utilityVMPath,omitempty"` } // LinuxSeccomp represents syscall restrictions @@ -543,7 +550,7 @@ const ( type LinuxSeccompArg struct { Index uint `json:"index"` Value uint64 `json:"value"` - ValueTwo uint64 `json:"valueTwo"` + ValueTwo uint64 `json:"valueTwo,omitempty"` Op LinuxSeccompOperator `json:"op"` } diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/specs-go/state.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/specs-go/state.go index b5dd3bee8..89dce34be 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/specs-go/state.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/specs-go/state.go @@ -9,7 +9,7 @@ type State struct { // Status is the runtime status of the container. Status string `json:"status"` // Pid is the process ID for the container process. - Pid int `json:"pid"` + Pid int `json:"pid,omitempty"` // Bundle is the path to the container's bundle directory. Bundle string `json:"bundle"` // Annotations are key values associated with the container. diff --git a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/specs-go/version.go b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/specs-go/version.go index dfcf0090e..926ce6650 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/specs-go/version.go +++ b/vendor/github.com/docker/docker/vendor/github.com/opencontainers/runtime-spec/specs-go/version.go @@ -11,7 +11,7 @@ const ( VersionPatch = 0 // VersionDev indicates development branch. Releases will be empty string. - VersionDev = "-rc5-dev" + VersionDev = "" ) // Version is the specification version that the package types support. diff --git a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/README.md b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/README.md index 82aeb4eef..4f5ce576d 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/README.md +++ b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/README.md @@ -1,7 +1,7 @@ # Logrus :walrus: [![Build Status](https://travis-ci.org/sirupsen/logrus.svg?branch=master)](https://travis-ci.org/sirupsen/logrus) [![GoDoc](https://godoc.org/github.com/sirupsen/logrus?status.svg)](https://godoc.org/github.com/sirupsen/logrus) Logrus is a structured logger for Go (golang), completely API compatible with -the standard library logger. [Godoc][godoc]. +the standard library logger. **Seeing weird case-sensitive problems?** It's in the past been possible to import Logrus as both upper- and lower-case. Due to the Go package environment, @@ -372,6 +372,7 @@ The built-in logging formatters are: Third party logging formatters: +* [`FluentdFormatter`](https://github.com/joonix/log). Formats entries that can by parsed by Kubernetes and Google Container Engine. * [`logstash`](https://github.com/bshuster-repo/logrus-logstash-hook). Logs fields as [Logstash](http://logstash.net) Events. * [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout. * [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the P͉̫o̳̼̊w̖͈̰͎e̬͔̭͂r͚̼̹̲ ̫͓͉̳͈ō̠͕͖̚f̝͍̠ ͕̲̞͖͑Z̖̫̤̫ͪa͉̬͈̗l͖͎g̳̥o̰̥̅!̣͔̲̻͊̄ ̙̘̦̹̦. diff --git a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/entry.go b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/entry.go index 320e5d5b8..5bf582ef2 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/entry.go +++ b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/entry.go @@ -35,6 +35,7 @@ type Entry struct { Time time.Time // Level the log entry was logged at: Debug, Info, Warn, Error, Fatal or Panic + // This field will be set on entry firing and the value will be equal to the one in Logger struct field. Level Level // Message passed to Debug, Info, Warn, Error, Fatal or Panic diff --git a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/exported.go b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/exported.go index 1aeaa90ba..013183eda 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/exported.go +++ b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/exported.go @@ -31,7 +31,7 @@ func SetFormatter(formatter Formatter) { func SetLevel(level Level) { std.mu.Lock() defer std.mu.Unlock() - std.setLevel(level) + std.SetLevel(level) } // GetLevel returns the standard logger level. diff --git a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/formatter.go b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/formatter.go index b5fbe934d..b183ff5b1 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/formatter.go +++ b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/formatter.go @@ -2,7 +2,7 @@ package logrus import "time" -const DefaultTimestampFormat = time.RFC3339 +const defaultTimestampFormat = time.RFC3339 // The Formatter interface is used to implement a custom Formatter. It takes an // `Entry`. It exposes all the fields, including the default ones: diff --git a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/json_formatter.go b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/json_formatter.go index e787ea175..fb01c1b10 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/json_formatter.go +++ b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/json_formatter.go @@ -6,8 +6,11 @@ import ( ) type fieldKey string + +// FieldMap allows customization of the key names for default fields. type FieldMap map[fieldKey]string +// Default key names for the default fields const ( FieldKeyMsg = "msg" FieldKeyLevel = "level" @@ -22,6 +25,7 @@ func (f FieldMap) resolve(key fieldKey) string { return string(key) } +// JSONFormatter formats logs into parsable json type JSONFormatter struct { // TimestampFormat sets the format used for marshaling timestamps. TimestampFormat string @@ -29,7 +33,7 @@ type JSONFormatter struct { // DisableTimestamp allows disabling automatic timestamps in output DisableTimestamp bool - // FieldMap allows users to customize the names of keys for various fields. + // FieldMap allows users to customize the names of keys for default fields. // As an example: // formatter := &JSONFormatter{ // FieldMap: FieldMap{ @@ -41,6 +45,7 @@ type JSONFormatter struct { FieldMap FieldMap } +// Format renders a single log entry func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { data := make(Fields, len(entry.Data)+3) for k, v := range entry.Data { @@ -57,7 +62,7 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { timestampFormat := f.TimestampFormat if timestampFormat == "" { - timestampFormat = DefaultTimestampFormat + timestampFormat = defaultTimestampFormat } if !f.DisableTimestamp { diff --git a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/logger.go b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/logger.go index 370fff5d1..2acab0509 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/logger.go +++ b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/logger.go @@ -25,7 +25,7 @@ type Logger struct { Formatter Formatter // The logging level the logger should log at. This is typically (and defaults // to) `logrus.Info`, which allows Info(), Warn(), Error() and Fatal() to be - // logged. `logrus.Debug` is useful in + // logged. Level Level // Used to sync writing to the log. Locking is enabled by Default mu MutexWrap @@ -312,6 +312,6 @@ func (logger *Logger) level() Level { return Level(atomic.LoadUint32((*uint32)(&logger.Level))) } -func (logger *Logger) setLevel(level Level) { +func (logger *Logger) SetLevel(level Level) { atomic.StoreUint32((*uint32)(&logger.Level), uint32(level)) } diff --git a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_appengine.go b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_appengine.go deleted file mode 100644 index e011a8694..000000000 --- a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_appengine.go +++ /dev/null @@ -1,10 +0,0 @@ -// +build appengine - -package logrus - -import "io" - -// IsTerminal returns true if stderr's file descriptor is a terminal. -func IsTerminal(f io.Writer) bool { - return true -} diff --git a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_bsd.go b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_bsd.go index 5f6be4d3c..d7b3893f3 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_bsd.go +++ b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_bsd.go @@ -3,8 +3,8 @@ package logrus -import "syscall" +import "golang.org/x/sys/unix" -const ioctlReadTermios = syscall.TIOCGETA +const ioctlReadTermios = unix.TIOCGETA -type Termios syscall.Termios +type Termios unix.Termios diff --git a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_linux.go b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_linux.go index 308160ca8..88d7298e2 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_linux.go +++ b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_linux.go @@ -7,8 +7,8 @@ package logrus -import "syscall" +import "golang.org/x/sys/unix" -const ioctlReadTermios = syscall.TCGETS +const ioctlReadTermios = unix.TCGETS -type Termios syscall.Termios +type Termios unix.Termios diff --git a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_notwindows.go b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_notwindows.go deleted file mode 100644 index 190297abf..000000000 --- a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_notwindows.go +++ /dev/null @@ -1,28 +0,0 @@ -// Based on ssh/terminal: -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build linux darwin freebsd openbsd netbsd dragonfly -// +build !appengine - -package logrus - -import ( - "io" - "os" - "syscall" - "unsafe" -) - -// IsTerminal returns true if stderr's file descriptor is a terminal. -func IsTerminal(f io.Writer) bool { - var termios Termios - switch v := f.(type) { - case *os.File: - _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(v.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) - return err == 0 - default: - return false - } -} diff --git a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_solaris.go b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_solaris.go deleted file mode 100644 index 3c86b1abe..000000000 --- a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_solaris.go +++ /dev/null @@ -1,21 +0,0 @@ -// +build solaris,!appengine - -package logrus - -import ( - "io" - "os" - - "golang.org/x/sys/unix" -) - -// IsTerminal returns true if the given file descriptor is a terminal. -func IsTerminal(f io.Writer) bool { - switch v := f.(type) { - case *os.File: - _, err := unix.IoctlGetTermios(int(v.Fd()), unix.TCGETA) - return err == nil - default: - return false - } -} diff --git a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_windows.go b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_windows.go deleted file mode 100644 index 7a336307e..000000000 --- a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/terminal_windows.go +++ /dev/null @@ -1,82 +0,0 @@ -// Based on ssh/terminal: -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows,!appengine - -package logrus - -import ( - "bytes" - "errors" - "io" - "os" - "os/exec" - "strconv" - "strings" - "syscall" - "unsafe" -) - -var kernel32 = syscall.NewLazyDLL("kernel32.dll") - -var ( - procGetConsoleMode = kernel32.NewProc("GetConsoleMode") - procSetConsoleMode = kernel32.NewProc("SetConsoleMode") -) - -const ( - enableProcessedOutput = 0x0001 - enableWrapAtEolOutput = 0x0002 - enableVirtualTerminalProcessing = 0x0004 -) - -func getVersion() (float64, error) { - stdout, stderr := &bytes.Buffer{}, &bytes.Buffer{} - cmd := exec.Command("cmd", "ver") - cmd.Stdout = stdout - cmd.Stderr = stderr - err := cmd.Run() - if err != nil { - return -1, err - } - - // The output should be like "Microsoft Windows [Version XX.X.XXXXXX]" - version := strings.Replace(stdout.String(), "\n", "", -1) - version = strings.Replace(version, "\r\n", "", -1) - - x1 := strings.Index(version, "[Version") - - if x1 == -1 || strings.Index(version, "]") == -1 { - return -1, errors.New("Can't determine Windows version") - } - - return strconv.ParseFloat(version[x1+9:x1+13], 64) -} - -func init() { - ver, err := getVersion() - if err != nil { - return - } - - // Activate Virtual Processing for Windows CMD - // Info: https://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx - if ver >= 10 { - handle := syscall.Handle(os.Stderr.Fd()) - procSetConsoleMode.Call(uintptr(handle), enableProcessedOutput|enableWrapAtEolOutput|enableVirtualTerminalProcessing) - } -} - -// IsTerminal returns true if stderr's file descriptor is a terminal. -func IsTerminal(f io.Writer) bool { - switch v := f.(type) { - case *os.File: - var st uint32 - r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(v.Fd()), uintptr(unsafe.Pointer(&st)), 0) - return r != 0 && e == 0 - default: - return false - } -} diff --git a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/text_formatter.go b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/text_formatter.go index 26dcc1553..be412aa94 100644 --- a/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/text_formatter.go +++ b/vendor/github.com/docker/docker/vendor/github.com/sirupsen/logrus/text_formatter.go @@ -3,10 +3,14 @@ package logrus import ( "bytes" "fmt" + "io" + "os" "sort" "strings" "sync" "time" + + "golang.org/x/crypto/ssh/terminal" ) const ( @@ -14,7 +18,7 @@ const ( red = 31 green = 32 yellow = 33 - blue = 34 + blue = 36 gray = 37 ) @@ -26,6 +30,7 @@ func init() { baseTimestamp = time.Now() } +// TextFormatter formats logs into text type TextFormatter struct { // Set to true to bypass checking for a TTY before outputting colors. ForceColors bool @@ -52,10 +57,6 @@ type TextFormatter struct { // QuoteEmptyFields will wrap empty fields in quotes if true QuoteEmptyFields bool - // QuoteCharacter can be set to the override the default quoting character " - // with something else. For example: ', or `. - QuoteCharacter string - // Whether the logger's out is to a terminal isTerminal bool @@ -63,14 +64,21 @@ type TextFormatter struct { } func (f *TextFormatter) init(entry *Entry) { - if len(f.QuoteCharacter) == 0 { - f.QuoteCharacter = "\"" - } if entry.Logger != nil { - f.isTerminal = IsTerminal(entry.Logger.Out) + f.isTerminal = f.checkIfTerminal(entry.Logger.Out) + } +} + +func (f *TextFormatter) checkIfTerminal(w io.Writer) bool { + switch v := w.(type) { + case *os.File: + return terminal.IsTerminal(int(v.Fd())) + default: + return false } } +// Format renders a single log entry func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { var b *bytes.Buffer keys := make([]string, 0, len(entry.Data)) @@ -95,7 +103,7 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { timestampFormat := f.TimestampFormat if timestampFormat == "" { - timestampFormat = DefaultTimestampFormat + timestampFormat = defaultTimestampFormat } if isColored { f.printColored(b, entry, keys, timestampFormat) @@ -153,7 +161,7 @@ func (f *TextFormatter) needsQuoting(text string) bool { if !((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || - ch == '-' || ch == '.') { + ch == '-' || ch == '.' || ch == '_' || ch == '/' || ch == '@' || ch == '^' || ch == '+') { return true } } @@ -161,36 +169,23 @@ func (f *TextFormatter) needsQuoting(text string) bool { } func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) { - + if b.Len() > 0 { + b.WriteByte(' ') + } b.WriteString(key) b.WriteByte('=') f.appendValue(b, value) - b.WriteByte(' ') } func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) { - switch value := value.(type) { - case string: - if !f.needsQuoting(value) { - b.WriteString(value) - } else { - b.WriteString(f.quoteString(value)) - } - case error: - errmsg := value.Error() - if !f.needsQuoting(errmsg) { - b.WriteString(errmsg) - } else { - b.WriteString(f.quoteString(errmsg)) - } - default: - fmt.Fprint(b, value) + stringVal, ok := value.(string) + if !ok { + stringVal = fmt.Sprint(value) } -} - -func (f *TextFormatter) quoteString(v string) string { - escapedQuote := fmt.Sprintf("\\%s", f.QuoteCharacter) - escapedValue := strings.Replace(v, f.QuoteCharacter, escapedQuote, -1) - return fmt.Sprintf("%s%v%s", f.QuoteCharacter, escapedValue, f.QuoteCharacter) + if !f.needsQuoting(stringVal) { + b.WriteString(stringVal) + } else { + b.WriteString(fmt.Sprintf("%q", stringVal)) + } } diff --git a/vendor/golang.org/x/crypto/README.md b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/README.md similarity index 100% rename from vendor/golang.org/x/crypto/README.md rename to vendor/github.com/docker/docker/vendor/golang.org/x/crypto/README.md diff --git a/vendor/golang.org/x/crypto/curve25519/const_amd64.h b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/const_amd64.h similarity index 100% rename from vendor/golang.org/x/crypto/curve25519/const_amd64.h rename to vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/const_amd64.h diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/const_amd64.s b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/const_amd64.s new file mode 100644 index 000000000..ee7b4bd5f --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/const_amd64.s @@ -0,0 +1,20 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This code was translated into a form compatible with 6a from the public +// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html + +// +build amd64,!gccgo,!appengine + +// These constants cannot be encoded in non-MOVQ immediates. +// We access them directly from memory instead. + +DATA ·_121666_213(SB)/8, $996687872 +GLOBL ·_121666_213(SB), 8, $8 + +DATA ·_2P0(SB)/8, $0xFFFFFFFFFFFDA +GLOBL ·_2P0(SB), 8, $8 + +DATA ·_2P1234(SB)/8, $0xFFFFFFFFFFFFE +GLOBL ·_2P1234(SB), 8, $8 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/cswap_amd64.s b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/cswap_amd64.s new file mode 100644 index 000000000..cd793a5b5 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/cswap_amd64.s @@ -0,0 +1,65 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build amd64,!gccgo,!appengine + +// func cswap(inout *[4][5]uint64, v uint64) +TEXT ·cswap(SB),7,$0 + MOVQ inout+0(FP),DI + MOVQ v+8(FP),SI + + SUBQ $1, SI + NOTQ SI + MOVQ SI, X15 + PSHUFD $0x44, X15, X15 + + MOVOU 0(DI), X0 + MOVOU 16(DI), X2 + MOVOU 32(DI), X4 + MOVOU 48(DI), X6 + MOVOU 64(DI), X8 + MOVOU 80(DI), X1 + MOVOU 96(DI), X3 + MOVOU 112(DI), X5 + MOVOU 128(DI), X7 + MOVOU 144(DI), X9 + + MOVO X1, X10 + MOVO X3, X11 + MOVO X5, X12 + MOVO X7, X13 + MOVO X9, X14 + + PXOR X0, X10 + PXOR X2, X11 + PXOR X4, X12 + PXOR X6, X13 + PXOR X8, X14 + PAND X15, X10 + PAND X15, X11 + PAND X15, X12 + PAND X15, X13 + PAND X15, X14 + PXOR X10, X0 + PXOR X10, X1 + PXOR X11, X2 + PXOR X11, X3 + PXOR X12, X4 + PXOR X12, X5 + PXOR X13, X6 + PXOR X13, X7 + PXOR X14, X8 + PXOR X14, X9 + + MOVOU X0, 0(DI) + MOVOU X2, 16(DI) + MOVOU X4, 32(DI) + MOVOU X6, 48(DI) + MOVOU X8, 64(DI) + MOVOU X1, 80(DI) + MOVOU X3, 96(DI) + MOVOU X5, 112(DI) + MOVOU X7, 128(DI) + MOVOU X9, 144(DI) + RET diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/curve25519.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/curve25519.go new file mode 100644 index 000000000..2d14c2a78 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/curve25519.go @@ -0,0 +1,834 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// We have a implementation in amd64 assembly so this code is only run on +// non-amd64 platforms. The amd64 assembly does not support gccgo. +// +build !amd64 gccgo appengine + +package curve25519 + +import ( + "encoding/binary" +) + +// This code is a port of the public domain, "ref10" implementation of +// curve25519 from SUPERCOP 20130419 by D. J. Bernstein. + +// fieldElement represents an element of the field GF(2^255 - 19). An element +// t, entries t[0]...t[9], represents the integer t[0]+2^26 t[1]+2^51 t[2]+2^77 +// t[3]+2^102 t[4]+...+2^230 t[9]. Bounds on each t[i] vary depending on +// context. +type fieldElement [10]int32 + +func feZero(fe *fieldElement) { + for i := range fe { + fe[i] = 0 + } +} + +func feOne(fe *fieldElement) { + feZero(fe) + fe[0] = 1 +} + +func feAdd(dst, a, b *fieldElement) { + for i := range dst { + dst[i] = a[i] + b[i] + } +} + +func feSub(dst, a, b *fieldElement) { + for i := range dst { + dst[i] = a[i] - b[i] + } +} + +func feCopy(dst, src *fieldElement) { + for i := range dst { + dst[i] = src[i] + } +} + +// feCSwap replaces (f,g) with (g,f) if b == 1; replaces (f,g) with (f,g) if b == 0. +// +// Preconditions: b in {0,1}. +func feCSwap(f, g *fieldElement, b int32) { + b = -b + for i := range f { + t := b & (f[i] ^ g[i]) + f[i] ^= t + g[i] ^= t + } +} + +// load3 reads a 24-bit, little-endian value from in. +func load3(in []byte) int64 { + var r int64 + r = int64(in[0]) + r |= int64(in[1]) << 8 + r |= int64(in[2]) << 16 + return r +} + +// load4 reads a 32-bit, little-endian value from in. +func load4(in []byte) int64 { + return int64(binary.LittleEndian.Uint32(in)) +} + +func feFromBytes(dst *fieldElement, src *[32]byte) { + h0 := load4(src[:]) + h1 := load3(src[4:]) << 6 + h2 := load3(src[7:]) << 5 + h3 := load3(src[10:]) << 3 + h4 := load3(src[13:]) << 2 + h5 := load4(src[16:]) + h6 := load3(src[20:]) << 7 + h7 := load3(src[23:]) << 5 + h8 := load3(src[26:]) << 4 + h9 := load3(src[29:]) << 2 + + var carry [10]int64 + carry[9] = (h9 + 1<<24) >> 25 + h0 += carry[9] * 19 + h9 -= carry[9] << 25 + carry[1] = (h1 + 1<<24) >> 25 + h2 += carry[1] + h1 -= carry[1] << 25 + carry[3] = (h3 + 1<<24) >> 25 + h4 += carry[3] + h3 -= carry[3] << 25 + carry[5] = (h5 + 1<<24) >> 25 + h6 += carry[5] + h5 -= carry[5] << 25 + carry[7] = (h7 + 1<<24) >> 25 + h8 += carry[7] + h7 -= carry[7] << 25 + + carry[0] = (h0 + 1<<25) >> 26 + h1 += carry[0] + h0 -= carry[0] << 26 + carry[2] = (h2 + 1<<25) >> 26 + h3 += carry[2] + h2 -= carry[2] << 26 + carry[4] = (h4 + 1<<25) >> 26 + h5 += carry[4] + h4 -= carry[4] << 26 + carry[6] = (h6 + 1<<25) >> 26 + h7 += carry[6] + h6 -= carry[6] << 26 + carry[8] = (h8 + 1<<25) >> 26 + h9 += carry[8] + h8 -= carry[8] << 26 + + dst[0] = int32(h0) + dst[1] = int32(h1) + dst[2] = int32(h2) + dst[3] = int32(h3) + dst[4] = int32(h4) + dst[5] = int32(h5) + dst[6] = int32(h6) + dst[7] = int32(h7) + dst[8] = int32(h8) + dst[9] = int32(h9) +} + +// feToBytes marshals h to s. +// Preconditions: +// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. +// +// Write p=2^255-19; q=floor(h/p). +// Basic claim: q = floor(2^(-255)(h + 19 2^(-25)h9 + 2^(-1))). +// +// Proof: +// Have |h|<=p so |q|<=1 so |19^2 2^(-255) q|<1/4. +// Also have |h-2^230 h9|<2^230 so |19 2^(-255)(h-2^230 h9)|<1/4. +// +// Write y=2^(-1)-19^2 2^(-255)q-19 2^(-255)(h-2^230 h9). +// Then 0> 25 + q = (h[0] + q) >> 26 + q = (h[1] + q) >> 25 + q = (h[2] + q) >> 26 + q = (h[3] + q) >> 25 + q = (h[4] + q) >> 26 + q = (h[5] + q) >> 25 + q = (h[6] + q) >> 26 + q = (h[7] + q) >> 25 + q = (h[8] + q) >> 26 + q = (h[9] + q) >> 25 + + // Goal: Output h-(2^255-19)q, which is between 0 and 2^255-20. + h[0] += 19 * q + // Goal: Output h-2^255 q, which is between 0 and 2^255-20. + + carry[0] = h[0] >> 26 + h[1] += carry[0] + h[0] -= carry[0] << 26 + carry[1] = h[1] >> 25 + h[2] += carry[1] + h[1] -= carry[1] << 25 + carry[2] = h[2] >> 26 + h[3] += carry[2] + h[2] -= carry[2] << 26 + carry[3] = h[3] >> 25 + h[4] += carry[3] + h[3] -= carry[3] << 25 + carry[4] = h[4] >> 26 + h[5] += carry[4] + h[4] -= carry[4] << 26 + carry[5] = h[5] >> 25 + h[6] += carry[5] + h[5] -= carry[5] << 25 + carry[6] = h[6] >> 26 + h[7] += carry[6] + h[6] -= carry[6] << 26 + carry[7] = h[7] >> 25 + h[8] += carry[7] + h[7] -= carry[7] << 25 + carry[8] = h[8] >> 26 + h[9] += carry[8] + h[8] -= carry[8] << 26 + carry[9] = h[9] >> 25 + h[9] -= carry[9] << 25 + // h10 = carry9 + + // Goal: Output h[0]+...+2^255 h10-2^255 q, which is between 0 and 2^255-20. + // Have h[0]+...+2^230 h[9] between 0 and 2^255-1; + // evidently 2^255 h10-2^255 q = 0. + // Goal: Output h[0]+...+2^230 h[9]. + + s[0] = byte(h[0] >> 0) + s[1] = byte(h[0] >> 8) + s[2] = byte(h[0] >> 16) + s[3] = byte((h[0] >> 24) | (h[1] << 2)) + s[4] = byte(h[1] >> 6) + s[5] = byte(h[1] >> 14) + s[6] = byte((h[1] >> 22) | (h[2] << 3)) + s[7] = byte(h[2] >> 5) + s[8] = byte(h[2] >> 13) + s[9] = byte((h[2] >> 21) | (h[3] << 5)) + s[10] = byte(h[3] >> 3) + s[11] = byte(h[3] >> 11) + s[12] = byte((h[3] >> 19) | (h[4] << 6)) + s[13] = byte(h[4] >> 2) + s[14] = byte(h[4] >> 10) + s[15] = byte(h[4] >> 18) + s[16] = byte(h[5] >> 0) + s[17] = byte(h[5] >> 8) + s[18] = byte(h[5] >> 16) + s[19] = byte((h[5] >> 24) | (h[6] << 1)) + s[20] = byte(h[6] >> 7) + s[21] = byte(h[6] >> 15) + s[22] = byte((h[6] >> 23) | (h[7] << 3)) + s[23] = byte(h[7] >> 5) + s[24] = byte(h[7] >> 13) + s[25] = byte((h[7] >> 21) | (h[8] << 4)) + s[26] = byte(h[8] >> 4) + s[27] = byte(h[8] >> 12) + s[28] = byte((h[8] >> 20) | (h[9] << 6)) + s[29] = byte(h[9] >> 2) + s[30] = byte(h[9] >> 10) + s[31] = byte(h[9] >> 18) +} + +// feMul calculates h = f * g +// Can overlap h with f or g. +// +// Preconditions: +// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. +// |g| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. +// +// Postconditions: +// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. +// +// Notes on implementation strategy: +// +// Using schoolbook multiplication. +// Karatsuba would save a little in some cost models. +// +// Most multiplications by 2 and 19 are 32-bit precomputations; +// cheaper than 64-bit postcomputations. +// +// There is one remaining multiplication by 19 in the carry chain; +// one *19 precomputation can be merged into this, +// but the resulting data flow is considerably less clean. +// +// There are 12 carries below. +// 10 of them are 2-way parallelizable and vectorizable. +// Can get away with 11 carries, but then data flow is much deeper. +// +// With tighter constraints on inputs can squeeze carries into int32. +func feMul(h, f, g *fieldElement) { + f0 := f[0] + f1 := f[1] + f2 := f[2] + f3 := f[3] + f4 := f[4] + f5 := f[5] + f6 := f[6] + f7 := f[7] + f8 := f[8] + f9 := f[9] + g0 := g[0] + g1 := g[1] + g2 := g[2] + g3 := g[3] + g4 := g[4] + g5 := g[5] + g6 := g[6] + g7 := g[7] + g8 := g[8] + g9 := g[9] + g1_19 := 19 * g1 // 1.4*2^29 + g2_19 := 19 * g2 // 1.4*2^30; still ok + g3_19 := 19 * g3 + g4_19 := 19 * g4 + g5_19 := 19 * g5 + g6_19 := 19 * g6 + g7_19 := 19 * g7 + g8_19 := 19 * g8 + g9_19 := 19 * g9 + f1_2 := 2 * f1 + f3_2 := 2 * f3 + f5_2 := 2 * f5 + f7_2 := 2 * f7 + f9_2 := 2 * f9 + f0g0 := int64(f0) * int64(g0) + f0g1 := int64(f0) * int64(g1) + f0g2 := int64(f0) * int64(g2) + f0g3 := int64(f0) * int64(g3) + f0g4 := int64(f0) * int64(g4) + f0g5 := int64(f0) * int64(g5) + f0g6 := int64(f0) * int64(g6) + f0g7 := int64(f0) * int64(g7) + f0g8 := int64(f0) * int64(g8) + f0g9 := int64(f0) * int64(g9) + f1g0 := int64(f1) * int64(g0) + f1g1_2 := int64(f1_2) * int64(g1) + f1g2 := int64(f1) * int64(g2) + f1g3_2 := int64(f1_2) * int64(g3) + f1g4 := int64(f1) * int64(g4) + f1g5_2 := int64(f1_2) * int64(g5) + f1g6 := int64(f1) * int64(g6) + f1g7_2 := int64(f1_2) * int64(g7) + f1g8 := int64(f1) * int64(g8) + f1g9_38 := int64(f1_2) * int64(g9_19) + f2g0 := int64(f2) * int64(g0) + f2g1 := int64(f2) * int64(g1) + f2g2 := int64(f2) * int64(g2) + f2g3 := int64(f2) * int64(g3) + f2g4 := int64(f2) * int64(g4) + f2g5 := int64(f2) * int64(g5) + f2g6 := int64(f2) * int64(g6) + f2g7 := int64(f2) * int64(g7) + f2g8_19 := int64(f2) * int64(g8_19) + f2g9_19 := int64(f2) * int64(g9_19) + f3g0 := int64(f3) * int64(g0) + f3g1_2 := int64(f3_2) * int64(g1) + f3g2 := int64(f3) * int64(g2) + f3g3_2 := int64(f3_2) * int64(g3) + f3g4 := int64(f3) * int64(g4) + f3g5_2 := int64(f3_2) * int64(g5) + f3g6 := int64(f3) * int64(g6) + f3g7_38 := int64(f3_2) * int64(g7_19) + f3g8_19 := int64(f3) * int64(g8_19) + f3g9_38 := int64(f3_2) * int64(g9_19) + f4g0 := int64(f4) * int64(g0) + f4g1 := int64(f4) * int64(g1) + f4g2 := int64(f4) * int64(g2) + f4g3 := int64(f4) * int64(g3) + f4g4 := int64(f4) * int64(g4) + f4g5 := int64(f4) * int64(g5) + f4g6_19 := int64(f4) * int64(g6_19) + f4g7_19 := int64(f4) * int64(g7_19) + f4g8_19 := int64(f4) * int64(g8_19) + f4g9_19 := int64(f4) * int64(g9_19) + f5g0 := int64(f5) * int64(g0) + f5g1_2 := int64(f5_2) * int64(g1) + f5g2 := int64(f5) * int64(g2) + f5g3_2 := int64(f5_2) * int64(g3) + f5g4 := int64(f5) * int64(g4) + f5g5_38 := int64(f5_2) * int64(g5_19) + f5g6_19 := int64(f5) * int64(g6_19) + f5g7_38 := int64(f5_2) * int64(g7_19) + f5g8_19 := int64(f5) * int64(g8_19) + f5g9_38 := int64(f5_2) * int64(g9_19) + f6g0 := int64(f6) * int64(g0) + f6g1 := int64(f6) * int64(g1) + f6g2 := int64(f6) * int64(g2) + f6g3 := int64(f6) * int64(g3) + f6g4_19 := int64(f6) * int64(g4_19) + f6g5_19 := int64(f6) * int64(g5_19) + f6g6_19 := int64(f6) * int64(g6_19) + f6g7_19 := int64(f6) * int64(g7_19) + f6g8_19 := int64(f6) * int64(g8_19) + f6g9_19 := int64(f6) * int64(g9_19) + f7g0 := int64(f7) * int64(g0) + f7g1_2 := int64(f7_2) * int64(g1) + f7g2 := int64(f7) * int64(g2) + f7g3_38 := int64(f7_2) * int64(g3_19) + f7g4_19 := int64(f7) * int64(g4_19) + f7g5_38 := int64(f7_2) * int64(g5_19) + f7g6_19 := int64(f7) * int64(g6_19) + f7g7_38 := int64(f7_2) * int64(g7_19) + f7g8_19 := int64(f7) * int64(g8_19) + f7g9_38 := int64(f7_2) * int64(g9_19) + f8g0 := int64(f8) * int64(g0) + f8g1 := int64(f8) * int64(g1) + f8g2_19 := int64(f8) * int64(g2_19) + f8g3_19 := int64(f8) * int64(g3_19) + f8g4_19 := int64(f8) * int64(g4_19) + f8g5_19 := int64(f8) * int64(g5_19) + f8g6_19 := int64(f8) * int64(g6_19) + f8g7_19 := int64(f8) * int64(g7_19) + f8g8_19 := int64(f8) * int64(g8_19) + f8g9_19 := int64(f8) * int64(g9_19) + f9g0 := int64(f9) * int64(g0) + f9g1_38 := int64(f9_2) * int64(g1_19) + f9g2_19 := int64(f9) * int64(g2_19) + f9g3_38 := int64(f9_2) * int64(g3_19) + f9g4_19 := int64(f9) * int64(g4_19) + f9g5_38 := int64(f9_2) * int64(g5_19) + f9g6_19 := int64(f9) * int64(g6_19) + f9g7_38 := int64(f9_2) * int64(g7_19) + f9g8_19 := int64(f9) * int64(g8_19) + f9g9_38 := int64(f9_2) * int64(g9_19) + h0 := f0g0 + f1g9_38 + f2g8_19 + f3g7_38 + f4g6_19 + f5g5_38 + f6g4_19 + f7g3_38 + f8g2_19 + f9g1_38 + h1 := f0g1 + f1g0 + f2g9_19 + f3g8_19 + f4g7_19 + f5g6_19 + f6g5_19 + f7g4_19 + f8g3_19 + f9g2_19 + h2 := f0g2 + f1g1_2 + f2g0 + f3g9_38 + f4g8_19 + f5g7_38 + f6g6_19 + f7g5_38 + f8g4_19 + f9g3_38 + h3 := f0g3 + f1g2 + f2g1 + f3g0 + f4g9_19 + f5g8_19 + f6g7_19 + f7g6_19 + f8g5_19 + f9g4_19 + h4 := f0g4 + f1g3_2 + f2g2 + f3g1_2 + f4g0 + f5g9_38 + f6g8_19 + f7g7_38 + f8g6_19 + f9g5_38 + h5 := f0g5 + f1g4 + f2g3 + f3g2 + f4g1 + f5g0 + f6g9_19 + f7g8_19 + f8g7_19 + f9g6_19 + h6 := f0g6 + f1g5_2 + f2g4 + f3g3_2 + f4g2 + f5g1_2 + f6g0 + f7g9_38 + f8g8_19 + f9g7_38 + h7 := f0g7 + f1g6 + f2g5 + f3g4 + f4g3 + f5g2 + f6g1 + f7g0 + f8g9_19 + f9g8_19 + h8 := f0g8 + f1g7_2 + f2g6 + f3g5_2 + f4g4 + f5g3_2 + f6g2 + f7g1_2 + f8g0 + f9g9_38 + h9 := f0g9 + f1g8 + f2g7 + f3g6 + f4g5 + f5g4 + f6g3 + f7g2 + f8g1 + f9g0 + var carry [10]int64 + + // |h0| <= (1.1*1.1*2^52*(1+19+19+19+19)+1.1*1.1*2^50*(38+38+38+38+38)) + // i.e. |h0| <= 1.2*2^59; narrower ranges for h2, h4, h6, h8 + // |h1| <= (1.1*1.1*2^51*(1+1+19+19+19+19+19+19+19+19)) + // i.e. |h1| <= 1.5*2^58; narrower ranges for h3, h5, h7, h9 + + carry[0] = (h0 + (1 << 25)) >> 26 + h1 += carry[0] + h0 -= carry[0] << 26 + carry[4] = (h4 + (1 << 25)) >> 26 + h5 += carry[4] + h4 -= carry[4] << 26 + // |h0| <= 2^25 + // |h4| <= 2^25 + // |h1| <= 1.51*2^58 + // |h5| <= 1.51*2^58 + + carry[1] = (h1 + (1 << 24)) >> 25 + h2 += carry[1] + h1 -= carry[1] << 25 + carry[5] = (h5 + (1 << 24)) >> 25 + h6 += carry[5] + h5 -= carry[5] << 25 + // |h1| <= 2^24; from now on fits into int32 + // |h5| <= 2^24; from now on fits into int32 + // |h2| <= 1.21*2^59 + // |h6| <= 1.21*2^59 + + carry[2] = (h2 + (1 << 25)) >> 26 + h3 += carry[2] + h2 -= carry[2] << 26 + carry[6] = (h6 + (1 << 25)) >> 26 + h7 += carry[6] + h6 -= carry[6] << 26 + // |h2| <= 2^25; from now on fits into int32 unchanged + // |h6| <= 2^25; from now on fits into int32 unchanged + // |h3| <= 1.51*2^58 + // |h7| <= 1.51*2^58 + + carry[3] = (h3 + (1 << 24)) >> 25 + h4 += carry[3] + h3 -= carry[3] << 25 + carry[7] = (h7 + (1 << 24)) >> 25 + h8 += carry[7] + h7 -= carry[7] << 25 + // |h3| <= 2^24; from now on fits into int32 unchanged + // |h7| <= 2^24; from now on fits into int32 unchanged + // |h4| <= 1.52*2^33 + // |h8| <= 1.52*2^33 + + carry[4] = (h4 + (1 << 25)) >> 26 + h5 += carry[4] + h4 -= carry[4] << 26 + carry[8] = (h8 + (1 << 25)) >> 26 + h9 += carry[8] + h8 -= carry[8] << 26 + // |h4| <= 2^25; from now on fits into int32 unchanged + // |h8| <= 2^25; from now on fits into int32 unchanged + // |h5| <= 1.01*2^24 + // |h9| <= 1.51*2^58 + + carry[9] = (h9 + (1 << 24)) >> 25 + h0 += carry[9] * 19 + h9 -= carry[9] << 25 + // |h9| <= 2^24; from now on fits into int32 unchanged + // |h0| <= 1.8*2^37 + + carry[0] = (h0 + (1 << 25)) >> 26 + h1 += carry[0] + h0 -= carry[0] << 26 + // |h0| <= 2^25; from now on fits into int32 unchanged + // |h1| <= 1.01*2^24 + + h[0] = int32(h0) + h[1] = int32(h1) + h[2] = int32(h2) + h[3] = int32(h3) + h[4] = int32(h4) + h[5] = int32(h5) + h[6] = int32(h6) + h[7] = int32(h7) + h[8] = int32(h8) + h[9] = int32(h9) +} + +// feSquare calculates h = f*f. Can overlap h with f. +// +// Preconditions: +// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. +// +// Postconditions: +// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. +func feSquare(h, f *fieldElement) { + f0 := f[0] + f1 := f[1] + f2 := f[2] + f3 := f[3] + f4 := f[4] + f5 := f[5] + f6 := f[6] + f7 := f[7] + f8 := f[8] + f9 := f[9] + f0_2 := 2 * f0 + f1_2 := 2 * f1 + f2_2 := 2 * f2 + f3_2 := 2 * f3 + f4_2 := 2 * f4 + f5_2 := 2 * f5 + f6_2 := 2 * f6 + f7_2 := 2 * f7 + f5_38 := 38 * f5 // 1.31*2^30 + f6_19 := 19 * f6 // 1.31*2^30 + f7_38 := 38 * f7 // 1.31*2^30 + f8_19 := 19 * f8 // 1.31*2^30 + f9_38 := 38 * f9 // 1.31*2^30 + f0f0 := int64(f0) * int64(f0) + f0f1_2 := int64(f0_2) * int64(f1) + f0f2_2 := int64(f0_2) * int64(f2) + f0f3_2 := int64(f0_2) * int64(f3) + f0f4_2 := int64(f0_2) * int64(f4) + f0f5_2 := int64(f0_2) * int64(f5) + f0f6_2 := int64(f0_2) * int64(f6) + f0f7_2 := int64(f0_2) * int64(f7) + f0f8_2 := int64(f0_2) * int64(f8) + f0f9_2 := int64(f0_2) * int64(f9) + f1f1_2 := int64(f1_2) * int64(f1) + f1f2_2 := int64(f1_2) * int64(f2) + f1f3_4 := int64(f1_2) * int64(f3_2) + f1f4_2 := int64(f1_2) * int64(f4) + f1f5_4 := int64(f1_2) * int64(f5_2) + f1f6_2 := int64(f1_2) * int64(f6) + f1f7_4 := int64(f1_2) * int64(f7_2) + f1f8_2 := int64(f1_2) * int64(f8) + f1f9_76 := int64(f1_2) * int64(f9_38) + f2f2 := int64(f2) * int64(f2) + f2f3_2 := int64(f2_2) * int64(f3) + f2f4_2 := int64(f2_2) * int64(f4) + f2f5_2 := int64(f2_2) * int64(f5) + f2f6_2 := int64(f2_2) * int64(f6) + f2f7_2 := int64(f2_2) * int64(f7) + f2f8_38 := int64(f2_2) * int64(f8_19) + f2f9_38 := int64(f2) * int64(f9_38) + f3f3_2 := int64(f3_2) * int64(f3) + f3f4_2 := int64(f3_2) * int64(f4) + f3f5_4 := int64(f3_2) * int64(f5_2) + f3f6_2 := int64(f3_2) * int64(f6) + f3f7_76 := int64(f3_2) * int64(f7_38) + f3f8_38 := int64(f3_2) * int64(f8_19) + f3f9_76 := int64(f3_2) * int64(f9_38) + f4f4 := int64(f4) * int64(f4) + f4f5_2 := int64(f4_2) * int64(f5) + f4f6_38 := int64(f4_2) * int64(f6_19) + f4f7_38 := int64(f4) * int64(f7_38) + f4f8_38 := int64(f4_2) * int64(f8_19) + f4f9_38 := int64(f4) * int64(f9_38) + f5f5_38 := int64(f5) * int64(f5_38) + f5f6_38 := int64(f5_2) * int64(f6_19) + f5f7_76 := int64(f5_2) * int64(f7_38) + f5f8_38 := int64(f5_2) * int64(f8_19) + f5f9_76 := int64(f5_2) * int64(f9_38) + f6f6_19 := int64(f6) * int64(f6_19) + f6f7_38 := int64(f6) * int64(f7_38) + f6f8_38 := int64(f6_2) * int64(f8_19) + f6f9_38 := int64(f6) * int64(f9_38) + f7f7_38 := int64(f7) * int64(f7_38) + f7f8_38 := int64(f7_2) * int64(f8_19) + f7f9_76 := int64(f7_2) * int64(f9_38) + f8f8_19 := int64(f8) * int64(f8_19) + f8f9_38 := int64(f8) * int64(f9_38) + f9f9_38 := int64(f9) * int64(f9_38) + h0 := f0f0 + f1f9_76 + f2f8_38 + f3f7_76 + f4f6_38 + f5f5_38 + h1 := f0f1_2 + f2f9_38 + f3f8_38 + f4f7_38 + f5f6_38 + h2 := f0f2_2 + f1f1_2 + f3f9_76 + f4f8_38 + f5f7_76 + f6f6_19 + h3 := f0f3_2 + f1f2_2 + f4f9_38 + f5f8_38 + f6f7_38 + h4 := f0f4_2 + f1f3_4 + f2f2 + f5f9_76 + f6f8_38 + f7f7_38 + h5 := f0f5_2 + f1f4_2 + f2f3_2 + f6f9_38 + f7f8_38 + h6 := f0f6_2 + f1f5_4 + f2f4_2 + f3f3_2 + f7f9_76 + f8f8_19 + h7 := f0f7_2 + f1f6_2 + f2f5_2 + f3f4_2 + f8f9_38 + h8 := f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38 + h9 := f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2 + var carry [10]int64 + + carry[0] = (h0 + (1 << 25)) >> 26 + h1 += carry[0] + h0 -= carry[0] << 26 + carry[4] = (h4 + (1 << 25)) >> 26 + h5 += carry[4] + h4 -= carry[4] << 26 + + carry[1] = (h1 + (1 << 24)) >> 25 + h2 += carry[1] + h1 -= carry[1] << 25 + carry[5] = (h5 + (1 << 24)) >> 25 + h6 += carry[5] + h5 -= carry[5] << 25 + + carry[2] = (h2 + (1 << 25)) >> 26 + h3 += carry[2] + h2 -= carry[2] << 26 + carry[6] = (h6 + (1 << 25)) >> 26 + h7 += carry[6] + h6 -= carry[6] << 26 + + carry[3] = (h3 + (1 << 24)) >> 25 + h4 += carry[3] + h3 -= carry[3] << 25 + carry[7] = (h7 + (1 << 24)) >> 25 + h8 += carry[7] + h7 -= carry[7] << 25 + + carry[4] = (h4 + (1 << 25)) >> 26 + h5 += carry[4] + h4 -= carry[4] << 26 + carry[8] = (h8 + (1 << 25)) >> 26 + h9 += carry[8] + h8 -= carry[8] << 26 + + carry[9] = (h9 + (1 << 24)) >> 25 + h0 += carry[9] * 19 + h9 -= carry[9] << 25 + + carry[0] = (h0 + (1 << 25)) >> 26 + h1 += carry[0] + h0 -= carry[0] << 26 + + h[0] = int32(h0) + h[1] = int32(h1) + h[2] = int32(h2) + h[3] = int32(h3) + h[4] = int32(h4) + h[5] = int32(h5) + h[6] = int32(h6) + h[7] = int32(h7) + h[8] = int32(h8) + h[9] = int32(h9) +} + +// feMul121666 calculates h = f * 121666. Can overlap h with f. +// +// Preconditions: +// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. +// +// Postconditions: +// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. +func feMul121666(h, f *fieldElement) { + h0 := int64(f[0]) * 121666 + h1 := int64(f[1]) * 121666 + h2 := int64(f[2]) * 121666 + h3 := int64(f[3]) * 121666 + h4 := int64(f[4]) * 121666 + h5 := int64(f[5]) * 121666 + h6 := int64(f[6]) * 121666 + h7 := int64(f[7]) * 121666 + h8 := int64(f[8]) * 121666 + h9 := int64(f[9]) * 121666 + var carry [10]int64 + + carry[9] = (h9 + (1 << 24)) >> 25 + h0 += carry[9] * 19 + h9 -= carry[9] << 25 + carry[1] = (h1 + (1 << 24)) >> 25 + h2 += carry[1] + h1 -= carry[1] << 25 + carry[3] = (h3 + (1 << 24)) >> 25 + h4 += carry[3] + h3 -= carry[3] << 25 + carry[5] = (h5 + (1 << 24)) >> 25 + h6 += carry[5] + h5 -= carry[5] << 25 + carry[7] = (h7 + (1 << 24)) >> 25 + h8 += carry[7] + h7 -= carry[7] << 25 + + carry[0] = (h0 + (1 << 25)) >> 26 + h1 += carry[0] + h0 -= carry[0] << 26 + carry[2] = (h2 + (1 << 25)) >> 26 + h3 += carry[2] + h2 -= carry[2] << 26 + carry[4] = (h4 + (1 << 25)) >> 26 + h5 += carry[4] + h4 -= carry[4] << 26 + carry[6] = (h6 + (1 << 25)) >> 26 + h7 += carry[6] + h6 -= carry[6] << 26 + carry[8] = (h8 + (1 << 25)) >> 26 + h9 += carry[8] + h8 -= carry[8] << 26 + + h[0] = int32(h0) + h[1] = int32(h1) + h[2] = int32(h2) + h[3] = int32(h3) + h[4] = int32(h4) + h[5] = int32(h5) + h[6] = int32(h6) + h[7] = int32(h7) + h[8] = int32(h8) + h[9] = int32(h9) +} + +// feInvert sets out = z^-1. +func feInvert(out, z *fieldElement) { + var t0, t1, t2, t3 fieldElement + var i int + + feSquare(&t0, z) + for i = 1; i < 1; i++ { + feSquare(&t0, &t0) + } + feSquare(&t1, &t0) + for i = 1; i < 2; i++ { + feSquare(&t1, &t1) + } + feMul(&t1, z, &t1) + feMul(&t0, &t0, &t1) + feSquare(&t2, &t0) + for i = 1; i < 1; i++ { + feSquare(&t2, &t2) + } + feMul(&t1, &t1, &t2) + feSquare(&t2, &t1) + for i = 1; i < 5; i++ { + feSquare(&t2, &t2) + } + feMul(&t1, &t2, &t1) + feSquare(&t2, &t1) + for i = 1; i < 10; i++ { + feSquare(&t2, &t2) + } + feMul(&t2, &t2, &t1) + feSquare(&t3, &t2) + for i = 1; i < 20; i++ { + feSquare(&t3, &t3) + } + feMul(&t2, &t3, &t2) + feSquare(&t2, &t2) + for i = 1; i < 10; i++ { + feSquare(&t2, &t2) + } + feMul(&t1, &t2, &t1) + feSquare(&t2, &t1) + for i = 1; i < 50; i++ { + feSquare(&t2, &t2) + } + feMul(&t2, &t2, &t1) + feSquare(&t3, &t2) + for i = 1; i < 100; i++ { + feSquare(&t3, &t3) + } + feMul(&t2, &t3, &t2) + feSquare(&t2, &t2) + for i = 1; i < 50; i++ { + feSquare(&t2, &t2) + } + feMul(&t1, &t2, &t1) + feSquare(&t1, &t1) + for i = 1; i < 5; i++ { + feSquare(&t1, &t1) + } + feMul(out, &t1, &t0) +} + +func scalarMult(out, in, base *[32]byte) { + var e [32]byte + + copy(e[:], in[:]) + e[0] &= 248 + e[31] &= 127 + e[31] |= 64 + + var x1, x2, z2, x3, z3, tmp0, tmp1 fieldElement + feFromBytes(&x1, base) + feOne(&x2) + feCopy(&x3, &x1) + feOne(&z3) + + swap := int32(0) + for pos := 254; pos >= 0; pos-- { + b := e[pos/8] >> uint(pos&7) + b &= 1 + swap ^= int32(b) + feCSwap(&x2, &x3, swap) + feCSwap(&z2, &z3, swap) + swap = int32(b) + + feSub(&tmp0, &x3, &z3) + feSub(&tmp1, &x2, &z2) + feAdd(&x2, &x2, &z2) + feAdd(&z2, &x3, &z3) + feMul(&z3, &tmp0, &x2) + feMul(&z2, &z2, &tmp1) + feSquare(&tmp0, &tmp1) + feSquare(&tmp1, &x2) + feAdd(&x3, &z3, &z2) + feSub(&z2, &z3, &z2) + feMul(&x2, &tmp1, &tmp0) + feSub(&tmp1, &tmp1, &tmp0) + feSquare(&z2, &z2) + feMul121666(&z3, &tmp1) + feSquare(&x3, &x3) + feAdd(&tmp0, &tmp0, &z3) + feMul(&z3, &x1, &z2) + feMul(&z2, &tmp1, &tmp0) + } + + feCSwap(&x2, &x3, swap) + feCSwap(&z2, &z3, swap) + + feInvert(&z2, &z2) + feMul(&x2, &x2, &z2) + feToBytes(out, &x2) +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/doc.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/doc.go new file mode 100644 index 000000000..da9b10d9c --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/doc.go @@ -0,0 +1,23 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package curve25519 provides an implementation of scalar multiplication on +// the elliptic curve known as curve25519. See https://cr.yp.to/ecdh.html +package curve25519 // import "golang.org/x/crypto/curve25519" + +// basePoint is the x coordinate of the generator of the curve. +var basePoint = [32]byte{9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + +// ScalarMult sets dst to the product in*base where dst and base are the x +// coordinates of group points and all values are in little-endian form. +func ScalarMult(dst, in, base *[32]byte) { + scalarMult(dst, in, base) +} + +// ScalarBaseMult sets dst to the product in*base where dst and base are the x +// coordinates of group points, base is the standard generator and all values +// are in little-endian form. +func ScalarBaseMult(dst, in *[32]byte) { + ScalarMult(dst, in, &basePoint) +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/freeze_amd64.s b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/freeze_amd64.s new file mode 100644 index 000000000..390816106 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/freeze_amd64.s @@ -0,0 +1,73 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This code was translated into a form compatible with 6a from the public +// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html + +// +build amd64,!gccgo,!appengine + +#include "const_amd64.h" + +// func freeze(inout *[5]uint64) +TEXT ·freeze(SB),7,$0-8 + MOVQ inout+0(FP), DI + + MOVQ 0(DI),SI + MOVQ 8(DI),DX + MOVQ 16(DI),CX + MOVQ 24(DI),R8 + MOVQ 32(DI),R9 + MOVQ $REDMASK51,AX + MOVQ AX,R10 + SUBQ $18,R10 + MOVQ $3,R11 +REDUCELOOP: + MOVQ SI,R12 + SHRQ $51,R12 + ANDQ AX,SI + ADDQ R12,DX + MOVQ DX,R12 + SHRQ $51,R12 + ANDQ AX,DX + ADDQ R12,CX + MOVQ CX,R12 + SHRQ $51,R12 + ANDQ AX,CX + ADDQ R12,R8 + MOVQ R8,R12 + SHRQ $51,R12 + ANDQ AX,R8 + ADDQ R12,R9 + MOVQ R9,R12 + SHRQ $51,R12 + ANDQ AX,R9 + IMUL3Q $19,R12,R12 + ADDQ R12,SI + SUBQ $1,R11 + JA REDUCELOOP + MOVQ $1,R12 + CMPQ R10,SI + CMOVQLT R11,R12 + CMPQ AX,DX + CMOVQNE R11,R12 + CMPQ AX,CX + CMOVQNE R11,R12 + CMPQ AX,R8 + CMOVQNE R11,R12 + CMPQ AX,R9 + CMOVQNE R11,R12 + NEGQ R12 + ANDQ R12,AX + ANDQ R12,R10 + SUBQ R10,SI + SUBQ AX,DX + SUBQ AX,CX + SUBQ AX,R8 + SUBQ AX,R9 + MOVQ SI,0(DI) + MOVQ DX,8(DI) + MOVQ CX,16(DI) + MOVQ R8,24(DI) + MOVQ R9,32(DI) + RET diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s new file mode 100644 index 000000000..9e9040b25 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s @@ -0,0 +1,1377 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This code was translated into a form compatible with 6a from the public +// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html + +// +build amd64,!gccgo,!appengine + +#include "const_amd64.h" + +// func ladderstep(inout *[5][5]uint64) +TEXT ·ladderstep(SB),0,$296-8 + MOVQ inout+0(FP),DI + + MOVQ 40(DI),SI + MOVQ 48(DI),DX + MOVQ 56(DI),CX + MOVQ 64(DI),R8 + MOVQ 72(DI),R9 + MOVQ SI,AX + MOVQ DX,R10 + MOVQ CX,R11 + MOVQ R8,R12 + MOVQ R9,R13 + ADDQ ·_2P0(SB),AX + ADDQ ·_2P1234(SB),R10 + ADDQ ·_2P1234(SB),R11 + ADDQ ·_2P1234(SB),R12 + ADDQ ·_2P1234(SB),R13 + ADDQ 80(DI),SI + ADDQ 88(DI),DX + ADDQ 96(DI),CX + ADDQ 104(DI),R8 + ADDQ 112(DI),R9 + SUBQ 80(DI),AX + SUBQ 88(DI),R10 + SUBQ 96(DI),R11 + SUBQ 104(DI),R12 + SUBQ 112(DI),R13 + MOVQ SI,0(SP) + MOVQ DX,8(SP) + MOVQ CX,16(SP) + MOVQ R8,24(SP) + MOVQ R9,32(SP) + MOVQ AX,40(SP) + MOVQ R10,48(SP) + MOVQ R11,56(SP) + MOVQ R12,64(SP) + MOVQ R13,72(SP) + MOVQ 40(SP),AX + MULQ 40(SP) + MOVQ AX,SI + MOVQ DX,CX + MOVQ 40(SP),AX + SHLQ $1,AX + MULQ 48(SP) + MOVQ AX,R8 + MOVQ DX,R9 + MOVQ 40(SP),AX + SHLQ $1,AX + MULQ 56(SP) + MOVQ AX,R10 + MOVQ DX,R11 + MOVQ 40(SP),AX + SHLQ $1,AX + MULQ 64(SP) + MOVQ AX,R12 + MOVQ DX,R13 + MOVQ 40(SP),AX + SHLQ $1,AX + MULQ 72(SP) + MOVQ AX,R14 + MOVQ DX,R15 + MOVQ 48(SP),AX + MULQ 48(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 48(SP),AX + SHLQ $1,AX + MULQ 56(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 48(SP),AX + SHLQ $1,AX + MULQ 64(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 48(SP),DX + IMUL3Q $38,DX,AX + MULQ 72(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 56(SP),AX + MULQ 56(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 56(SP),DX + IMUL3Q $38,DX,AX + MULQ 64(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 56(SP),DX + IMUL3Q $38,DX,AX + MULQ 72(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 64(SP),DX + IMUL3Q $19,DX,AX + MULQ 64(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 64(SP),DX + IMUL3Q $38,DX,AX + MULQ 72(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 72(SP),DX + IMUL3Q $19,DX,AX + MULQ 72(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ $REDMASK51,DX + SHLQ $13,CX:SI + ANDQ DX,SI + SHLQ $13,R9:R8 + ANDQ DX,R8 + ADDQ CX,R8 + SHLQ $13,R11:R10 + ANDQ DX,R10 + ADDQ R9,R10 + SHLQ $13,R13:R12 + ANDQ DX,R12 + ADDQ R11,R12 + SHLQ $13,R15:R14 + ANDQ DX,R14 + ADDQ R13,R14 + IMUL3Q $19,R15,CX + ADDQ CX,SI + MOVQ SI,CX + SHRQ $51,CX + ADDQ R8,CX + ANDQ DX,SI + MOVQ CX,R8 + SHRQ $51,CX + ADDQ R10,CX + ANDQ DX,R8 + MOVQ CX,R9 + SHRQ $51,CX + ADDQ R12,CX + ANDQ DX,R9 + MOVQ CX,AX + SHRQ $51,CX + ADDQ R14,CX + ANDQ DX,AX + MOVQ CX,R10 + SHRQ $51,CX + IMUL3Q $19,CX,CX + ADDQ CX,SI + ANDQ DX,R10 + MOVQ SI,80(SP) + MOVQ R8,88(SP) + MOVQ R9,96(SP) + MOVQ AX,104(SP) + MOVQ R10,112(SP) + MOVQ 0(SP),AX + MULQ 0(SP) + MOVQ AX,SI + MOVQ DX,CX + MOVQ 0(SP),AX + SHLQ $1,AX + MULQ 8(SP) + MOVQ AX,R8 + MOVQ DX,R9 + MOVQ 0(SP),AX + SHLQ $1,AX + MULQ 16(SP) + MOVQ AX,R10 + MOVQ DX,R11 + MOVQ 0(SP),AX + SHLQ $1,AX + MULQ 24(SP) + MOVQ AX,R12 + MOVQ DX,R13 + MOVQ 0(SP),AX + SHLQ $1,AX + MULQ 32(SP) + MOVQ AX,R14 + MOVQ DX,R15 + MOVQ 8(SP),AX + MULQ 8(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 8(SP),AX + SHLQ $1,AX + MULQ 16(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 8(SP),AX + SHLQ $1,AX + MULQ 24(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 8(SP),DX + IMUL3Q $38,DX,AX + MULQ 32(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 16(SP),AX + MULQ 16(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 16(SP),DX + IMUL3Q $38,DX,AX + MULQ 24(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 16(SP),DX + IMUL3Q $38,DX,AX + MULQ 32(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 24(SP),DX + IMUL3Q $19,DX,AX + MULQ 24(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 24(SP),DX + IMUL3Q $38,DX,AX + MULQ 32(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 32(SP),DX + IMUL3Q $19,DX,AX + MULQ 32(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ $REDMASK51,DX + SHLQ $13,CX:SI + ANDQ DX,SI + SHLQ $13,R9:R8 + ANDQ DX,R8 + ADDQ CX,R8 + SHLQ $13,R11:R10 + ANDQ DX,R10 + ADDQ R9,R10 + SHLQ $13,R13:R12 + ANDQ DX,R12 + ADDQ R11,R12 + SHLQ $13,R15:R14 + ANDQ DX,R14 + ADDQ R13,R14 + IMUL3Q $19,R15,CX + ADDQ CX,SI + MOVQ SI,CX + SHRQ $51,CX + ADDQ R8,CX + ANDQ DX,SI + MOVQ CX,R8 + SHRQ $51,CX + ADDQ R10,CX + ANDQ DX,R8 + MOVQ CX,R9 + SHRQ $51,CX + ADDQ R12,CX + ANDQ DX,R9 + MOVQ CX,AX + SHRQ $51,CX + ADDQ R14,CX + ANDQ DX,AX + MOVQ CX,R10 + SHRQ $51,CX + IMUL3Q $19,CX,CX + ADDQ CX,SI + ANDQ DX,R10 + MOVQ SI,120(SP) + MOVQ R8,128(SP) + MOVQ R9,136(SP) + MOVQ AX,144(SP) + MOVQ R10,152(SP) + MOVQ SI,SI + MOVQ R8,DX + MOVQ R9,CX + MOVQ AX,R8 + MOVQ R10,R9 + ADDQ ·_2P0(SB),SI + ADDQ ·_2P1234(SB),DX + ADDQ ·_2P1234(SB),CX + ADDQ ·_2P1234(SB),R8 + ADDQ ·_2P1234(SB),R9 + SUBQ 80(SP),SI + SUBQ 88(SP),DX + SUBQ 96(SP),CX + SUBQ 104(SP),R8 + SUBQ 112(SP),R9 + MOVQ SI,160(SP) + MOVQ DX,168(SP) + MOVQ CX,176(SP) + MOVQ R8,184(SP) + MOVQ R9,192(SP) + MOVQ 120(DI),SI + MOVQ 128(DI),DX + MOVQ 136(DI),CX + MOVQ 144(DI),R8 + MOVQ 152(DI),R9 + MOVQ SI,AX + MOVQ DX,R10 + MOVQ CX,R11 + MOVQ R8,R12 + MOVQ R9,R13 + ADDQ ·_2P0(SB),AX + ADDQ ·_2P1234(SB),R10 + ADDQ ·_2P1234(SB),R11 + ADDQ ·_2P1234(SB),R12 + ADDQ ·_2P1234(SB),R13 + ADDQ 160(DI),SI + ADDQ 168(DI),DX + ADDQ 176(DI),CX + ADDQ 184(DI),R8 + ADDQ 192(DI),R9 + SUBQ 160(DI),AX + SUBQ 168(DI),R10 + SUBQ 176(DI),R11 + SUBQ 184(DI),R12 + SUBQ 192(DI),R13 + MOVQ SI,200(SP) + MOVQ DX,208(SP) + MOVQ CX,216(SP) + MOVQ R8,224(SP) + MOVQ R9,232(SP) + MOVQ AX,240(SP) + MOVQ R10,248(SP) + MOVQ R11,256(SP) + MOVQ R12,264(SP) + MOVQ R13,272(SP) + MOVQ 224(SP),SI + IMUL3Q $19,SI,AX + MOVQ AX,280(SP) + MULQ 56(SP) + MOVQ AX,SI + MOVQ DX,CX + MOVQ 232(SP),DX + IMUL3Q $19,DX,AX + MOVQ AX,288(SP) + MULQ 48(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 200(SP),AX + MULQ 40(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 200(SP),AX + MULQ 48(SP) + MOVQ AX,R8 + MOVQ DX,R9 + MOVQ 200(SP),AX + MULQ 56(SP) + MOVQ AX,R10 + MOVQ DX,R11 + MOVQ 200(SP),AX + MULQ 64(SP) + MOVQ AX,R12 + MOVQ DX,R13 + MOVQ 200(SP),AX + MULQ 72(SP) + MOVQ AX,R14 + MOVQ DX,R15 + MOVQ 208(SP),AX + MULQ 40(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 208(SP),AX + MULQ 48(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 208(SP),AX + MULQ 56(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 208(SP),AX + MULQ 64(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 208(SP),DX + IMUL3Q $19,DX,AX + MULQ 72(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 216(SP),AX + MULQ 40(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 216(SP),AX + MULQ 48(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 216(SP),AX + MULQ 56(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 216(SP),DX + IMUL3Q $19,DX,AX + MULQ 64(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 216(SP),DX + IMUL3Q $19,DX,AX + MULQ 72(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 224(SP),AX + MULQ 40(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 224(SP),AX + MULQ 48(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 280(SP),AX + MULQ 64(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 280(SP),AX + MULQ 72(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 232(SP),AX + MULQ 40(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 288(SP),AX + MULQ 56(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 288(SP),AX + MULQ 64(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 288(SP),AX + MULQ 72(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ $REDMASK51,DX + SHLQ $13,CX:SI + ANDQ DX,SI + SHLQ $13,R9:R8 + ANDQ DX,R8 + ADDQ CX,R8 + SHLQ $13,R11:R10 + ANDQ DX,R10 + ADDQ R9,R10 + SHLQ $13,R13:R12 + ANDQ DX,R12 + ADDQ R11,R12 + SHLQ $13,R15:R14 + ANDQ DX,R14 + ADDQ R13,R14 + IMUL3Q $19,R15,CX + ADDQ CX,SI + MOVQ SI,CX + SHRQ $51,CX + ADDQ R8,CX + MOVQ CX,R8 + SHRQ $51,CX + ANDQ DX,SI + ADDQ R10,CX + MOVQ CX,R9 + SHRQ $51,CX + ANDQ DX,R8 + ADDQ R12,CX + MOVQ CX,AX + SHRQ $51,CX + ANDQ DX,R9 + ADDQ R14,CX + MOVQ CX,R10 + SHRQ $51,CX + ANDQ DX,AX + IMUL3Q $19,CX,CX + ADDQ CX,SI + ANDQ DX,R10 + MOVQ SI,40(SP) + MOVQ R8,48(SP) + MOVQ R9,56(SP) + MOVQ AX,64(SP) + MOVQ R10,72(SP) + MOVQ 264(SP),SI + IMUL3Q $19,SI,AX + MOVQ AX,200(SP) + MULQ 16(SP) + MOVQ AX,SI + MOVQ DX,CX + MOVQ 272(SP),DX + IMUL3Q $19,DX,AX + MOVQ AX,208(SP) + MULQ 8(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 240(SP),AX + MULQ 0(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 240(SP),AX + MULQ 8(SP) + MOVQ AX,R8 + MOVQ DX,R9 + MOVQ 240(SP),AX + MULQ 16(SP) + MOVQ AX,R10 + MOVQ DX,R11 + MOVQ 240(SP),AX + MULQ 24(SP) + MOVQ AX,R12 + MOVQ DX,R13 + MOVQ 240(SP),AX + MULQ 32(SP) + MOVQ AX,R14 + MOVQ DX,R15 + MOVQ 248(SP),AX + MULQ 0(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 248(SP),AX + MULQ 8(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 248(SP),AX + MULQ 16(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 248(SP),AX + MULQ 24(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 248(SP),DX + IMUL3Q $19,DX,AX + MULQ 32(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 256(SP),AX + MULQ 0(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 256(SP),AX + MULQ 8(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 256(SP),AX + MULQ 16(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 256(SP),DX + IMUL3Q $19,DX,AX + MULQ 24(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 256(SP),DX + IMUL3Q $19,DX,AX + MULQ 32(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 264(SP),AX + MULQ 0(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 264(SP),AX + MULQ 8(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 200(SP),AX + MULQ 24(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 200(SP),AX + MULQ 32(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 272(SP),AX + MULQ 0(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 208(SP),AX + MULQ 16(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 208(SP),AX + MULQ 24(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 208(SP),AX + MULQ 32(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ $REDMASK51,DX + SHLQ $13,CX:SI + ANDQ DX,SI + SHLQ $13,R9:R8 + ANDQ DX,R8 + ADDQ CX,R8 + SHLQ $13,R11:R10 + ANDQ DX,R10 + ADDQ R9,R10 + SHLQ $13,R13:R12 + ANDQ DX,R12 + ADDQ R11,R12 + SHLQ $13,R15:R14 + ANDQ DX,R14 + ADDQ R13,R14 + IMUL3Q $19,R15,CX + ADDQ CX,SI + MOVQ SI,CX + SHRQ $51,CX + ADDQ R8,CX + MOVQ CX,R8 + SHRQ $51,CX + ANDQ DX,SI + ADDQ R10,CX + MOVQ CX,R9 + SHRQ $51,CX + ANDQ DX,R8 + ADDQ R12,CX + MOVQ CX,AX + SHRQ $51,CX + ANDQ DX,R9 + ADDQ R14,CX + MOVQ CX,R10 + SHRQ $51,CX + ANDQ DX,AX + IMUL3Q $19,CX,CX + ADDQ CX,SI + ANDQ DX,R10 + MOVQ SI,DX + MOVQ R8,CX + MOVQ R9,R11 + MOVQ AX,R12 + MOVQ R10,R13 + ADDQ ·_2P0(SB),DX + ADDQ ·_2P1234(SB),CX + ADDQ ·_2P1234(SB),R11 + ADDQ ·_2P1234(SB),R12 + ADDQ ·_2P1234(SB),R13 + ADDQ 40(SP),SI + ADDQ 48(SP),R8 + ADDQ 56(SP),R9 + ADDQ 64(SP),AX + ADDQ 72(SP),R10 + SUBQ 40(SP),DX + SUBQ 48(SP),CX + SUBQ 56(SP),R11 + SUBQ 64(SP),R12 + SUBQ 72(SP),R13 + MOVQ SI,120(DI) + MOVQ R8,128(DI) + MOVQ R9,136(DI) + MOVQ AX,144(DI) + MOVQ R10,152(DI) + MOVQ DX,160(DI) + MOVQ CX,168(DI) + MOVQ R11,176(DI) + MOVQ R12,184(DI) + MOVQ R13,192(DI) + MOVQ 120(DI),AX + MULQ 120(DI) + MOVQ AX,SI + MOVQ DX,CX + MOVQ 120(DI),AX + SHLQ $1,AX + MULQ 128(DI) + MOVQ AX,R8 + MOVQ DX,R9 + MOVQ 120(DI),AX + SHLQ $1,AX + MULQ 136(DI) + MOVQ AX,R10 + MOVQ DX,R11 + MOVQ 120(DI),AX + SHLQ $1,AX + MULQ 144(DI) + MOVQ AX,R12 + MOVQ DX,R13 + MOVQ 120(DI),AX + SHLQ $1,AX + MULQ 152(DI) + MOVQ AX,R14 + MOVQ DX,R15 + MOVQ 128(DI),AX + MULQ 128(DI) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 128(DI),AX + SHLQ $1,AX + MULQ 136(DI) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 128(DI),AX + SHLQ $1,AX + MULQ 144(DI) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 128(DI),DX + IMUL3Q $38,DX,AX + MULQ 152(DI) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 136(DI),AX + MULQ 136(DI) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 136(DI),DX + IMUL3Q $38,DX,AX + MULQ 144(DI) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 136(DI),DX + IMUL3Q $38,DX,AX + MULQ 152(DI) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 144(DI),DX + IMUL3Q $19,DX,AX + MULQ 144(DI) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 144(DI),DX + IMUL3Q $38,DX,AX + MULQ 152(DI) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 152(DI),DX + IMUL3Q $19,DX,AX + MULQ 152(DI) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ $REDMASK51,DX + SHLQ $13,CX:SI + ANDQ DX,SI + SHLQ $13,R9:R8 + ANDQ DX,R8 + ADDQ CX,R8 + SHLQ $13,R11:R10 + ANDQ DX,R10 + ADDQ R9,R10 + SHLQ $13,R13:R12 + ANDQ DX,R12 + ADDQ R11,R12 + SHLQ $13,R15:R14 + ANDQ DX,R14 + ADDQ R13,R14 + IMUL3Q $19,R15,CX + ADDQ CX,SI + MOVQ SI,CX + SHRQ $51,CX + ADDQ R8,CX + ANDQ DX,SI + MOVQ CX,R8 + SHRQ $51,CX + ADDQ R10,CX + ANDQ DX,R8 + MOVQ CX,R9 + SHRQ $51,CX + ADDQ R12,CX + ANDQ DX,R9 + MOVQ CX,AX + SHRQ $51,CX + ADDQ R14,CX + ANDQ DX,AX + MOVQ CX,R10 + SHRQ $51,CX + IMUL3Q $19,CX,CX + ADDQ CX,SI + ANDQ DX,R10 + MOVQ SI,120(DI) + MOVQ R8,128(DI) + MOVQ R9,136(DI) + MOVQ AX,144(DI) + MOVQ R10,152(DI) + MOVQ 160(DI),AX + MULQ 160(DI) + MOVQ AX,SI + MOVQ DX,CX + MOVQ 160(DI),AX + SHLQ $1,AX + MULQ 168(DI) + MOVQ AX,R8 + MOVQ DX,R9 + MOVQ 160(DI),AX + SHLQ $1,AX + MULQ 176(DI) + MOVQ AX,R10 + MOVQ DX,R11 + MOVQ 160(DI),AX + SHLQ $1,AX + MULQ 184(DI) + MOVQ AX,R12 + MOVQ DX,R13 + MOVQ 160(DI),AX + SHLQ $1,AX + MULQ 192(DI) + MOVQ AX,R14 + MOVQ DX,R15 + MOVQ 168(DI),AX + MULQ 168(DI) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 168(DI),AX + SHLQ $1,AX + MULQ 176(DI) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 168(DI),AX + SHLQ $1,AX + MULQ 184(DI) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 168(DI),DX + IMUL3Q $38,DX,AX + MULQ 192(DI) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 176(DI),AX + MULQ 176(DI) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 176(DI),DX + IMUL3Q $38,DX,AX + MULQ 184(DI) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 176(DI),DX + IMUL3Q $38,DX,AX + MULQ 192(DI) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 184(DI),DX + IMUL3Q $19,DX,AX + MULQ 184(DI) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 184(DI),DX + IMUL3Q $38,DX,AX + MULQ 192(DI) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 192(DI),DX + IMUL3Q $19,DX,AX + MULQ 192(DI) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ $REDMASK51,DX + SHLQ $13,CX:SI + ANDQ DX,SI + SHLQ $13,R9:R8 + ANDQ DX,R8 + ADDQ CX,R8 + SHLQ $13,R11:R10 + ANDQ DX,R10 + ADDQ R9,R10 + SHLQ $13,R13:R12 + ANDQ DX,R12 + ADDQ R11,R12 + SHLQ $13,R15:R14 + ANDQ DX,R14 + ADDQ R13,R14 + IMUL3Q $19,R15,CX + ADDQ CX,SI + MOVQ SI,CX + SHRQ $51,CX + ADDQ R8,CX + ANDQ DX,SI + MOVQ CX,R8 + SHRQ $51,CX + ADDQ R10,CX + ANDQ DX,R8 + MOVQ CX,R9 + SHRQ $51,CX + ADDQ R12,CX + ANDQ DX,R9 + MOVQ CX,AX + SHRQ $51,CX + ADDQ R14,CX + ANDQ DX,AX + MOVQ CX,R10 + SHRQ $51,CX + IMUL3Q $19,CX,CX + ADDQ CX,SI + ANDQ DX,R10 + MOVQ SI,160(DI) + MOVQ R8,168(DI) + MOVQ R9,176(DI) + MOVQ AX,184(DI) + MOVQ R10,192(DI) + MOVQ 184(DI),SI + IMUL3Q $19,SI,AX + MOVQ AX,0(SP) + MULQ 16(DI) + MOVQ AX,SI + MOVQ DX,CX + MOVQ 192(DI),DX + IMUL3Q $19,DX,AX + MOVQ AX,8(SP) + MULQ 8(DI) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 160(DI),AX + MULQ 0(DI) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 160(DI),AX + MULQ 8(DI) + MOVQ AX,R8 + MOVQ DX,R9 + MOVQ 160(DI),AX + MULQ 16(DI) + MOVQ AX,R10 + MOVQ DX,R11 + MOVQ 160(DI),AX + MULQ 24(DI) + MOVQ AX,R12 + MOVQ DX,R13 + MOVQ 160(DI),AX + MULQ 32(DI) + MOVQ AX,R14 + MOVQ DX,R15 + MOVQ 168(DI),AX + MULQ 0(DI) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 168(DI),AX + MULQ 8(DI) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 168(DI),AX + MULQ 16(DI) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 168(DI),AX + MULQ 24(DI) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 168(DI),DX + IMUL3Q $19,DX,AX + MULQ 32(DI) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 176(DI),AX + MULQ 0(DI) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 176(DI),AX + MULQ 8(DI) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 176(DI),AX + MULQ 16(DI) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 176(DI),DX + IMUL3Q $19,DX,AX + MULQ 24(DI) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 176(DI),DX + IMUL3Q $19,DX,AX + MULQ 32(DI) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 184(DI),AX + MULQ 0(DI) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 184(DI),AX + MULQ 8(DI) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 0(SP),AX + MULQ 24(DI) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 0(SP),AX + MULQ 32(DI) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 192(DI),AX + MULQ 0(DI) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 8(SP),AX + MULQ 16(DI) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 8(SP),AX + MULQ 24(DI) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 8(SP),AX + MULQ 32(DI) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ $REDMASK51,DX + SHLQ $13,CX:SI + ANDQ DX,SI + SHLQ $13,R9:R8 + ANDQ DX,R8 + ADDQ CX,R8 + SHLQ $13,R11:R10 + ANDQ DX,R10 + ADDQ R9,R10 + SHLQ $13,R13:R12 + ANDQ DX,R12 + ADDQ R11,R12 + SHLQ $13,R15:R14 + ANDQ DX,R14 + ADDQ R13,R14 + IMUL3Q $19,R15,CX + ADDQ CX,SI + MOVQ SI,CX + SHRQ $51,CX + ADDQ R8,CX + MOVQ CX,R8 + SHRQ $51,CX + ANDQ DX,SI + ADDQ R10,CX + MOVQ CX,R9 + SHRQ $51,CX + ANDQ DX,R8 + ADDQ R12,CX + MOVQ CX,AX + SHRQ $51,CX + ANDQ DX,R9 + ADDQ R14,CX + MOVQ CX,R10 + SHRQ $51,CX + ANDQ DX,AX + IMUL3Q $19,CX,CX + ADDQ CX,SI + ANDQ DX,R10 + MOVQ SI,160(DI) + MOVQ R8,168(DI) + MOVQ R9,176(DI) + MOVQ AX,184(DI) + MOVQ R10,192(DI) + MOVQ 144(SP),SI + IMUL3Q $19,SI,AX + MOVQ AX,0(SP) + MULQ 96(SP) + MOVQ AX,SI + MOVQ DX,CX + MOVQ 152(SP),DX + IMUL3Q $19,DX,AX + MOVQ AX,8(SP) + MULQ 88(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 120(SP),AX + MULQ 80(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 120(SP),AX + MULQ 88(SP) + MOVQ AX,R8 + MOVQ DX,R9 + MOVQ 120(SP),AX + MULQ 96(SP) + MOVQ AX,R10 + MOVQ DX,R11 + MOVQ 120(SP),AX + MULQ 104(SP) + MOVQ AX,R12 + MOVQ DX,R13 + MOVQ 120(SP),AX + MULQ 112(SP) + MOVQ AX,R14 + MOVQ DX,R15 + MOVQ 128(SP),AX + MULQ 80(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 128(SP),AX + MULQ 88(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 128(SP),AX + MULQ 96(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 128(SP),AX + MULQ 104(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 128(SP),DX + IMUL3Q $19,DX,AX + MULQ 112(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 136(SP),AX + MULQ 80(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 136(SP),AX + MULQ 88(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 136(SP),AX + MULQ 96(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 136(SP),DX + IMUL3Q $19,DX,AX + MULQ 104(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 136(SP),DX + IMUL3Q $19,DX,AX + MULQ 112(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 144(SP),AX + MULQ 80(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 144(SP),AX + MULQ 88(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 0(SP),AX + MULQ 104(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 0(SP),AX + MULQ 112(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 152(SP),AX + MULQ 80(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 8(SP),AX + MULQ 96(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 8(SP),AX + MULQ 104(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 8(SP),AX + MULQ 112(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ $REDMASK51,DX + SHLQ $13,CX:SI + ANDQ DX,SI + SHLQ $13,R9:R8 + ANDQ DX,R8 + ADDQ CX,R8 + SHLQ $13,R11:R10 + ANDQ DX,R10 + ADDQ R9,R10 + SHLQ $13,R13:R12 + ANDQ DX,R12 + ADDQ R11,R12 + SHLQ $13,R15:R14 + ANDQ DX,R14 + ADDQ R13,R14 + IMUL3Q $19,R15,CX + ADDQ CX,SI + MOVQ SI,CX + SHRQ $51,CX + ADDQ R8,CX + MOVQ CX,R8 + SHRQ $51,CX + ANDQ DX,SI + ADDQ R10,CX + MOVQ CX,R9 + SHRQ $51,CX + ANDQ DX,R8 + ADDQ R12,CX + MOVQ CX,AX + SHRQ $51,CX + ANDQ DX,R9 + ADDQ R14,CX + MOVQ CX,R10 + SHRQ $51,CX + ANDQ DX,AX + IMUL3Q $19,CX,CX + ADDQ CX,SI + ANDQ DX,R10 + MOVQ SI,40(DI) + MOVQ R8,48(DI) + MOVQ R9,56(DI) + MOVQ AX,64(DI) + MOVQ R10,72(DI) + MOVQ 160(SP),AX + MULQ ·_121666_213(SB) + SHRQ $13,AX + MOVQ AX,SI + MOVQ DX,CX + MOVQ 168(SP),AX + MULQ ·_121666_213(SB) + SHRQ $13,AX + ADDQ AX,CX + MOVQ DX,R8 + MOVQ 176(SP),AX + MULQ ·_121666_213(SB) + SHRQ $13,AX + ADDQ AX,R8 + MOVQ DX,R9 + MOVQ 184(SP),AX + MULQ ·_121666_213(SB) + SHRQ $13,AX + ADDQ AX,R9 + MOVQ DX,R10 + MOVQ 192(SP),AX + MULQ ·_121666_213(SB) + SHRQ $13,AX + ADDQ AX,R10 + IMUL3Q $19,DX,DX + ADDQ DX,SI + ADDQ 80(SP),SI + ADDQ 88(SP),CX + ADDQ 96(SP),R8 + ADDQ 104(SP),R9 + ADDQ 112(SP),R10 + MOVQ SI,80(DI) + MOVQ CX,88(DI) + MOVQ R8,96(DI) + MOVQ R9,104(DI) + MOVQ R10,112(DI) + MOVQ 104(DI),SI + IMUL3Q $19,SI,AX + MOVQ AX,0(SP) + MULQ 176(SP) + MOVQ AX,SI + MOVQ DX,CX + MOVQ 112(DI),DX + IMUL3Q $19,DX,AX + MOVQ AX,8(SP) + MULQ 168(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 80(DI),AX + MULQ 160(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 80(DI),AX + MULQ 168(SP) + MOVQ AX,R8 + MOVQ DX,R9 + MOVQ 80(DI),AX + MULQ 176(SP) + MOVQ AX,R10 + MOVQ DX,R11 + MOVQ 80(DI),AX + MULQ 184(SP) + MOVQ AX,R12 + MOVQ DX,R13 + MOVQ 80(DI),AX + MULQ 192(SP) + MOVQ AX,R14 + MOVQ DX,R15 + MOVQ 88(DI),AX + MULQ 160(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 88(DI),AX + MULQ 168(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 88(DI),AX + MULQ 176(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 88(DI),AX + MULQ 184(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 88(DI),DX + IMUL3Q $19,DX,AX + MULQ 192(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 96(DI),AX + MULQ 160(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 96(DI),AX + MULQ 168(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 96(DI),AX + MULQ 176(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 96(DI),DX + IMUL3Q $19,DX,AX + MULQ 184(SP) + ADDQ AX,SI + ADCQ DX,CX + MOVQ 96(DI),DX + IMUL3Q $19,DX,AX + MULQ 192(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 104(DI),AX + MULQ 160(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 104(DI),AX + MULQ 168(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 0(SP),AX + MULQ 184(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 0(SP),AX + MULQ 192(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 112(DI),AX + MULQ 160(SP) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 8(SP),AX + MULQ 176(SP) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 8(SP),AX + MULQ 184(SP) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 8(SP),AX + MULQ 192(SP) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ $REDMASK51,DX + SHLQ $13,CX:SI + ANDQ DX,SI + SHLQ $13,R9:R8 + ANDQ DX,R8 + ADDQ CX,R8 + SHLQ $13,R11:R10 + ANDQ DX,R10 + ADDQ R9,R10 + SHLQ $13,R13:R12 + ANDQ DX,R12 + ADDQ R11,R12 + SHLQ $13,R15:R14 + ANDQ DX,R14 + ADDQ R13,R14 + IMUL3Q $19,R15,CX + ADDQ CX,SI + MOVQ SI,CX + SHRQ $51,CX + ADDQ R8,CX + MOVQ CX,R8 + SHRQ $51,CX + ANDQ DX,SI + ADDQ R10,CX + MOVQ CX,R9 + SHRQ $51,CX + ANDQ DX,R8 + ADDQ R12,CX + MOVQ CX,AX + SHRQ $51,CX + ANDQ DX,R9 + ADDQ R14,CX + MOVQ CX,R10 + SHRQ $51,CX + ANDQ DX,AX + IMUL3Q $19,CX,CX + ADDQ CX,SI + ANDQ DX,R10 + MOVQ SI,80(DI) + MOVQ R8,88(DI) + MOVQ R9,96(DI) + MOVQ AX,104(DI) + MOVQ R10,112(DI) + RET diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/mont25519_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/mont25519_amd64.go new file mode 100644 index 000000000..5822bd533 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/mont25519_amd64.go @@ -0,0 +1,240 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build amd64,!gccgo,!appengine + +package curve25519 + +// These functions are implemented in the .s files. The names of the functions +// in the rest of the file are also taken from the SUPERCOP sources to help +// people following along. + +//go:noescape + +func cswap(inout *[5]uint64, v uint64) + +//go:noescape + +func ladderstep(inout *[5][5]uint64) + +//go:noescape + +func freeze(inout *[5]uint64) + +//go:noescape + +func mul(dest, a, b *[5]uint64) + +//go:noescape + +func square(out, in *[5]uint64) + +// mladder uses a Montgomery ladder to calculate (xr/zr) *= s. +func mladder(xr, zr *[5]uint64, s *[32]byte) { + var work [5][5]uint64 + + work[0] = *xr + setint(&work[1], 1) + setint(&work[2], 0) + work[3] = *xr + setint(&work[4], 1) + + j := uint(6) + var prevbit byte + + for i := 31; i >= 0; i-- { + for j < 8 { + bit := ((*s)[i] >> j) & 1 + swap := bit ^ prevbit + prevbit = bit + cswap(&work[1], uint64(swap)) + ladderstep(&work) + j-- + } + j = 7 + } + + *xr = work[1] + *zr = work[2] +} + +func scalarMult(out, in, base *[32]byte) { + var e [32]byte + copy(e[:], (*in)[:]) + e[0] &= 248 + e[31] &= 127 + e[31] |= 64 + + var t, z [5]uint64 + unpack(&t, base) + mladder(&t, &z, &e) + invert(&z, &z) + mul(&t, &t, &z) + pack(out, &t) +} + +func setint(r *[5]uint64, v uint64) { + r[0] = v + r[1] = 0 + r[2] = 0 + r[3] = 0 + r[4] = 0 +} + +// unpack sets r = x where r consists of 5, 51-bit limbs in little-endian +// order. +func unpack(r *[5]uint64, x *[32]byte) { + r[0] = uint64(x[0]) | + uint64(x[1])<<8 | + uint64(x[2])<<16 | + uint64(x[3])<<24 | + uint64(x[4])<<32 | + uint64(x[5])<<40 | + uint64(x[6]&7)<<48 + + r[1] = uint64(x[6])>>3 | + uint64(x[7])<<5 | + uint64(x[8])<<13 | + uint64(x[9])<<21 | + uint64(x[10])<<29 | + uint64(x[11])<<37 | + uint64(x[12]&63)<<45 + + r[2] = uint64(x[12])>>6 | + uint64(x[13])<<2 | + uint64(x[14])<<10 | + uint64(x[15])<<18 | + uint64(x[16])<<26 | + uint64(x[17])<<34 | + uint64(x[18])<<42 | + uint64(x[19]&1)<<50 + + r[3] = uint64(x[19])>>1 | + uint64(x[20])<<7 | + uint64(x[21])<<15 | + uint64(x[22])<<23 | + uint64(x[23])<<31 | + uint64(x[24])<<39 | + uint64(x[25]&15)<<47 + + r[4] = uint64(x[25])>>4 | + uint64(x[26])<<4 | + uint64(x[27])<<12 | + uint64(x[28])<<20 | + uint64(x[29])<<28 | + uint64(x[30])<<36 | + uint64(x[31]&127)<<44 +} + +// pack sets out = x where out is the usual, little-endian form of the 5, +// 51-bit limbs in x. +func pack(out *[32]byte, x *[5]uint64) { + t := *x + freeze(&t) + + out[0] = byte(t[0]) + out[1] = byte(t[0] >> 8) + out[2] = byte(t[0] >> 16) + out[3] = byte(t[0] >> 24) + out[4] = byte(t[0] >> 32) + out[5] = byte(t[0] >> 40) + out[6] = byte(t[0] >> 48) + + out[6] ^= byte(t[1]<<3) & 0xf8 + out[7] = byte(t[1] >> 5) + out[8] = byte(t[1] >> 13) + out[9] = byte(t[1] >> 21) + out[10] = byte(t[1] >> 29) + out[11] = byte(t[1] >> 37) + out[12] = byte(t[1] >> 45) + + out[12] ^= byte(t[2]<<6) & 0xc0 + out[13] = byte(t[2] >> 2) + out[14] = byte(t[2] >> 10) + out[15] = byte(t[2] >> 18) + out[16] = byte(t[2] >> 26) + out[17] = byte(t[2] >> 34) + out[18] = byte(t[2] >> 42) + out[19] = byte(t[2] >> 50) + + out[19] ^= byte(t[3]<<1) & 0xfe + out[20] = byte(t[3] >> 7) + out[21] = byte(t[3] >> 15) + out[22] = byte(t[3] >> 23) + out[23] = byte(t[3] >> 31) + out[24] = byte(t[3] >> 39) + out[25] = byte(t[3] >> 47) + + out[25] ^= byte(t[4]<<4) & 0xf0 + out[26] = byte(t[4] >> 4) + out[27] = byte(t[4] >> 12) + out[28] = byte(t[4] >> 20) + out[29] = byte(t[4] >> 28) + out[30] = byte(t[4] >> 36) + out[31] = byte(t[4] >> 44) +} + +// invert calculates r = x^-1 mod p using Fermat's little theorem. +func invert(r *[5]uint64, x *[5]uint64) { + var z2, z9, z11, z2_5_0, z2_10_0, z2_20_0, z2_50_0, z2_100_0, t [5]uint64 + + square(&z2, x) /* 2 */ + square(&t, &z2) /* 4 */ + square(&t, &t) /* 8 */ + mul(&z9, &t, x) /* 9 */ + mul(&z11, &z9, &z2) /* 11 */ + square(&t, &z11) /* 22 */ + mul(&z2_5_0, &t, &z9) /* 2^5 - 2^0 = 31 */ + + square(&t, &z2_5_0) /* 2^6 - 2^1 */ + for i := 1; i < 5; i++ { /* 2^20 - 2^10 */ + square(&t, &t) + } + mul(&z2_10_0, &t, &z2_5_0) /* 2^10 - 2^0 */ + + square(&t, &z2_10_0) /* 2^11 - 2^1 */ + for i := 1; i < 10; i++ { /* 2^20 - 2^10 */ + square(&t, &t) + } + mul(&z2_20_0, &t, &z2_10_0) /* 2^20 - 2^0 */ + + square(&t, &z2_20_0) /* 2^21 - 2^1 */ + for i := 1; i < 20; i++ { /* 2^40 - 2^20 */ + square(&t, &t) + } + mul(&t, &t, &z2_20_0) /* 2^40 - 2^0 */ + + square(&t, &t) /* 2^41 - 2^1 */ + for i := 1; i < 10; i++ { /* 2^50 - 2^10 */ + square(&t, &t) + } + mul(&z2_50_0, &t, &z2_10_0) /* 2^50 - 2^0 */ + + square(&t, &z2_50_0) /* 2^51 - 2^1 */ + for i := 1; i < 50; i++ { /* 2^100 - 2^50 */ + square(&t, &t) + } + mul(&z2_100_0, &t, &z2_50_0) /* 2^100 - 2^0 */ + + square(&t, &z2_100_0) /* 2^101 - 2^1 */ + for i := 1; i < 100; i++ { /* 2^200 - 2^100 */ + square(&t, &t) + } + mul(&t, &t, &z2_100_0) /* 2^200 - 2^0 */ + + square(&t, &t) /* 2^201 - 2^1 */ + for i := 1; i < 50; i++ { /* 2^250 - 2^50 */ + square(&t, &t) + } + mul(&t, &t, &z2_50_0) /* 2^250 - 2^0 */ + + square(&t, &t) /* 2^251 - 2^1 */ + square(&t, &t) /* 2^252 - 2^2 */ + square(&t, &t) /* 2^253 - 2^3 */ + + square(&t, &t) /* 2^254 - 2^4 */ + + square(&t, &t) /* 2^255 - 2^5 */ + mul(r, &t, &z11) /* 2^255 - 21 */ +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/mul_amd64.s b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/mul_amd64.s new file mode 100644 index 000000000..5ce80a2e5 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/mul_amd64.s @@ -0,0 +1,169 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This code was translated into a form compatible with 6a from the public +// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html + +// +build amd64,!gccgo,!appengine + +#include "const_amd64.h" + +// func mul(dest, a, b *[5]uint64) +TEXT ·mul(SB),0,$16-24 + MOVQ dest+0(FP), DI + MOVQ a+8(FP), SI + MOVQ b+16(FP), DX + + MOVQ DX,CX + MOVQ 24(SI),DX + IMUL3Q $19,DX,AX + MOVQ AX,0(SP) + MULQ 16(CX) + MOVQ AX,R8 + MOVQ DX,R9 + MOVQ 32(SI),DX + IMUL3Q $19,DX,AX + MOVQ AX,8(SP) + MULQ 8(CX) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 0(SI),AX + MULQ 0(CX) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 0(SI),AX + MULQ 8(CX) + MOVQ AX,R10 + MOVQ DX,R11 + MOVQ 0(SI),AX + MULQ 16(CX) + MOVQ AX,R12 + MOVQ DX,R13 + MOVQ 0(SI),AX + MULQ 24(CX) + MOVQ AX,R14 + MOVQ DX,R15 + MOVQ 0(SI),AX + MULQ 32(CX) + MOVQ AX,BX + MOVQ DX,BP + MOVQ 8(SI),AX + MULQ 0(CX) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 8(SI),AX + MULQ 8(CX) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 8(SI),AX + MULQ 16(CX) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 8(SI),AX + MULQ 24(CX) + ADDQ AX,BX + ADCQ DX,BP + MOVQ 8(SI),DX + IMUL3Q $19,DX,AX + MULQ 32(CX) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 16(SI),AX + MULQ 0(CX) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 16(SI),AX + MULQ 8(CX) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 16(SI),AX + MULQ 16(CX) + ADDQ AX,BX + ADCQ DX,BP + MOVQ 16(SI),DX + IMUL3Q $19,DX,AX + MULQ 24(CX) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 16(SI),DX + IMUL3Q $19,DX,AX + MULQ 32(CX) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 24(SI),AX + MULQ 0(CX) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 24(SI),AX + MULQ 8(CX) + ADDQ AX,BX + ADCQ DX,BP + MOVQ 0(SP),AX + MULQ 24(CX) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 0(SP),AX + MULQ 32(CX) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 32(SI),AX + MULQ 0(CX) + ADDQ AX,BX + ADCQ DX,BP + MOVQ 8(SP),AX + MULQ 16(CX) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 8(SP),AX + MULQ 24(CX) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 8(SP),AX + MULQ 32(CX) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ $REDMASK51,SI + SHLQ $13,R9:R8 + ANDQ SI,R8 + SHLQ $13,R11:R10 + ANDQ SI,R10 + ADDQ R9,R10 + SHLQ $13,R13:R12 + ANDQ SI,R12 + ADDQ R11,R12 + SHLQ $13,R15:R14 + ANDQ SI,R14 + ADDQ R13,R14 + SHLQ $13,BP:BX + ANDQ SI,BX + ADDQ R15,BX + IMUL3Q $19,BP,DX + ADDQ DX,R8 + MOVQ R8,DX + SHRQ $51,DX + ADDQ R10,DX + MOVQ DX,CX + SHRQ $51,DX + ANDQ SI,R8 + ADDQ R12,DX + MOVQ DX,R9 + SHRQ $51,DX + ANDQ SI,CX + ADDQ R14,DX + MOVQ DX,AX + SHRQ $51,DX + ANDQ SI,R9 + ADDQ BX,DX + MOVQ DX,R10 + SHRQ $51,DX + ANDQ SI,AX + IMUL3Q $19,DX,DX + ADDQ DX,R8 + ANDQ SI,R10 + MOVQ R8,0(DI) + MOVQ CX,8(DI) + MOVQ R9,16(DI) + MOVQ AX,24(DI) + MOVQ R10,32(DI) + RET diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/square_amd64.s b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/square_amd64.s new file mode 100644 index 000000000..12f73734f --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/curve25519/square_amd64.s @@ -0,0 +1,132 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This code was translated into a form compatible with 6a from the public +// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html + +// +build amd64,!gccgo,!appengine + +#include "const_amd64.h" + +// func square(out, in *[5]uint64) +TEXT ·square(SB),7,$0-16 + MOVQ out+0(FP), DI + MOVQ in+8(FP), SI + + MOVQ 0(SI),AX + MULQ 0(SI) + MOVQ AX,CX + MOVQ DX,R8 + MOVQ 0(SI),AX + SHLQ $1,AX + MULQ 8(SI) + MOVQ AX,R9 + MOVQ DX,R10 + MOVQ 0(SI),AX + SHLQ $1,AX + MULQ 16(SI) + MOVQ AX,R11 + MOVQ DX,R12 + MOVQ 0(SI),AX + SHLQ $1,AX + MULQ 24(SI) + MOVQ AX,R13 + MOVQ DX,R14 + MOVQ 0(SI),AX + SHLQ $1,AX + MULQ 32(SI) + MOVQ AX,R15 + MOVQ DX,BX + MOVQ 8(SI),AX + MULQ 8(SI) + ADDQ AX,R11 + ADCQ DX,R12 + MOVQ 8(SI),AX + SHLQ $1,AX + MULQ 16(SI) + ADDQ AX,R13 + ADCQ DX,R14 + MOVQ 8(SI),AX + SHLQ $1,AX + MULQ 24(SI) + ADDQ AX,R15 + ADCQ DX,BX + MOVQ 8(SI),DX + IMUL3Q $38,DX,AX + MULQ 32(SI) + ADDQ AX,CX + ADCQ DX,R8 + MOVQ 16(SI),AX + MULQ 16(SI) + ADDQ AX,R15 + ADCQ DX,BX + MOVQ 16(SI),DX + IMUL3Q $38,DX,AX + MULQ 24(SI) + ADDQ AX,CX + ADCQ DX,R8 + MOVQ 16(SI),DX + IMUL3Q $38,DX,AX + MULQ 32(SI) + ADDQ AX,R9 + ADCQ DX,R10 + MOVQ 24(SI),DX + IMUL3Q $19,DX,AX + MULQ 24(SI) + ADDQ AX,R9 + ADCQ DX,R10 + MOVQ 24(SI),DX + IMUL3Q $38,DX,AX + MULQ 32(SI) + ADDQ AX,R11 + ADCQ DX,R12 + MOVQ 32(SI),DX + IMUL3Q $19,DX,AX + MULQ 32(SI) + ADDQ AX,R13 + ADCQ DX,R14 + MOVQ $REDMASK51,SI + SHLQ $13,R8:CX + ANDQ SI,CX + SHLQ $13,R10:R9 + ANDQ SI,R9 + ADDQ R8,R9 + SHLQ $13,R12:R11 + ANDQ SI,R11 + ADDQ R10,R11 + SHLQ $13,R14:R13 + ANDQ SI,R13 + ADDQ R12,R13 + SHLQ $13,BX:R15 + ANDQ SI,R15 + ADDQ R14,R15 + IMUL3Q $19,BX,DX + ADDQ DX,CX + MOVQ CX,DX + SHRQ $51,DX + ADDQ R9,DX + ANDQ SI,CX + MOVQ DX,R8 + SHRQ $51,DX + ADDQ R11,DX + ANDQ SI,R8 + MOVQ DX,R9 + SHRQ $51,DX + ADDQ R13,DX + ANDQ SI,R9 + MOVQ DX,AX + SHRQ $51,DX + ADDQ R15,DX + ANDQ SI,AX + MOVQ DX,R10 + SHRQ $51,DX + IMUL3Q $19,DX,DX + ADDQ DX,CX + ANDQ SI,R10 + MOVQ CX,0(DI) + MOVQ R8,8(DI) + MOVQ R9,16(DI) + MOVQ AX,24(DI) + MOVQ R10,32(DI) + RET diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/nacl/secretbox/secretbox.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/nacl/secretbox/secretbox.go index dbf31bbf4..1e1dff506 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/nacl/secretbox/secretbox.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/nacl/secretbox/secretbox.go @@ -13,7 +13,7 @@ example, by using nonce 1 for the first message, nonce 2 for the second message, etc. Nonces are long enough that randomly generated nonces have negligible risk of collision. -This package is interoperable with NaCl: http://nacl.cr.yp.to/secretbox.html. +This package is interoperable with NaCl: https://nacl.cr.yp.to/secretbox.html. */ package secretbox // import "golang.org/x/crypto/nacl/secretbox" diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/pkcs12/bmp-string.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/pkcs12/bmp-string.go index 284d2a68f..233b8b62c 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/pkcs12/bmp-string.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/pkcs12/bmp-string.go @@ -13,7 +13,7 @@ import ( func bmpString(s string) ([]byte, error) { // References: // https://tools.ietf.org/html/rfc7292#appendix-B.1 - // http://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane + // https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane // - non-BMP characters are encoded in UTF 16 by using a surrogate pair of 16-bit codes // EncodeRune returns 0xfffd if the rune does not need special encoding // - the above RFC provides the info that BMPStrings are NULL terminated. diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/pkcs12/pkcs12.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/pkcs12/pkcs12.go index ad6341e60..eff9ad3a9 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/pkcs12/pkcs12.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/pkcs12/pkcs12.go @@ -109,6 +109,10 @@ func ToPEM(pfxData []byte, password string) ([]*pem.Block, error) { bags, encodedPassword, err := getSafeContents(pfxData, encodedPassword) + if err != nil { + return nil, err + } + blocks := make([]*pem.Block, 0, len(bags)) for _, bag := range bags { block, err := convertBag(&bag, encodedPassword) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/poly1305.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/poly1305.go index 4a5f826f7..f562fa571 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/poly1305.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/poly1305.go @@ -3,7 +3,8 @@ // license that can be found in the LICENSE file. /* -Package poly1305 implements Poly1305 one-time message authentication code as specified in http://cr.yp.to/mac/poly1305-20050329.pdf. +Package poly1305 implements Poly1305 one-time message authentication code as +specified in https://cr.yp.to/mac/poly1305-20050329.pdf. Poly1305 is a fast, one-time authentication function. It is infeasible for an attacker to generate an authenticator for a message without the key. However, a diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_amd64.go index 6775c703f..4dd72fe79 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_amd64.go @@ -6,10 +6,8 @@ package poly1305 -// This function is implemented in poly1305_amd64.s - +// This function is implemented in sum_amd64.s //go:noescape - func poly1305(out *[16]byte, m *byte, mlen uint64, key *[32]byte) // Sum generates an authenticator for m using a one-time key and puts the diff --git a/vendor/golang.org/x/crypto/poly1305/sum_amd64.s b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_amd64.s similarity index 100% rename from vendor/golang.org/x/crypto/poly1305/sum_amd64.s rename to vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_amd64.s diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_arm.go index 50b979c24..5dc321c2f 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_arm.go @@ -2,14 +2,12 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build arm,!gccgo,!appengine +// +build arm,!gccgo,!appengine,!nacl package poly1305 -// This function is implemented in poly1305_arm.s - +// This function is implemented in sum_arm.s //go:noescape - func poly1305_auth_armv6(out *[16]byte, m *byte, mlen uint32, key *[32]byte) // Sum generates an authenticator for m using a one-time key and puts the diff --git a/vendor/golang.org/x/crypto/poly1305/sum_arm.s b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_arm.s similarity index 100% rename from vendor/golang.org/x/crypto/poly1305/sum_arm.s rename to vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_arm.s diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_ref.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_ref.go index 0b24fc78b..b2805a5ca 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_ref.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/poly1305/sum_ref.go @@ -2,1530 +2,140 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !amd64,!arm gccgo appengine +// +build !amd64,!arm gccgo appengine nacl package poly1305 -// Based on original, public domain implementation from NaCl by D. J. -// Bernstein. +import "encoding/binary" -import "math" - -const ( - alpham80 = 0.00000000558793544769287109375 - alpham48 = 24.0 - alpham16 = 103079215104.0 - alpha0 = 6755399441055744.0 - alpha18 = 1770887431076116955136.0 - alpha32 = 29014219670751100192948224.0 - alpha50 = 7605903601369376408980219232256.0 - alpha64 = 124615124604835863084731911901282304.0 - alpha82 = 32667107224410092492483962313449748299776.0 - alpha96 = 535217884764734955396857238543560676143529984.0 - alpha112 = 35076039295941670036888435985190792471742381031424.0 - alpha130 = 9194973245195333150150082162901855101712434733101613056.0 - scale = 0.0000000000000000000000000000000000000036734198463196484624023016788195177431833298649127735047148490821200539357960224151611328125 - offset0 = 6755408030990331.0 - offset1 = 29014256564239239022116864.0 - offset2 = 124615283061160854719918951570079744.0 - offset3 = 535219245894202480694386063513315216128475136.0 -) - -// Sum generates an authenticator for m using a one-time key and puts the +// Sum generates an authenticator for msg using a one-time key and puts the // 16-byte result into out. Authenticating two different messages with the same // key allows an attacker to forge messages at will. -func Sum(out *[16]byte, m []byte, key *[32]byte) { - r := key - s := key[16:] +func Sum(out *[TagSize]byte, msg []byte, key *[32]byte) { var ( - y7 float64 - y6 float64 - y1 float64 - y0 float64 - y5 float64 - y4 float64 - x7 float64 - x6 float64 - x1 float64 - x0 float64 - y3 float64 - y2 float64 - x5 float64 - r3lowx0 float64 - x4 float64 - r0lowx6 float64 - x3 float64 - r3highx0 float64 - x2 float64 - r0highx6 float64 - r0lowx0 float64 - sr1lowx6 float64 - r0highx0 float64 - sr1highx6 float64 - sr3low float64 - r1lowx0 float64 - sr2lowx6 float64 - r1highx0 float64 - sr2highx6 float64 - r2lowx0 float64 - sr3lowx6 float64 - r2highx0 float64 - sr3highx6 float64 - r1highx4 float64 - r1lowx4 float64 - r0highx4 float64 - r0lowx4 float64 - sr3highx4 float64 - sr3lowx4 float64 - sr2highx4 float64 - sr2lowx4 float64 - r0lowx2 float64 - r0highx2 float64 - r1lowx2 float64 - r1highx2 float64 - r2lowx2 float64 - r2highx2 float64 - sr3lowx2 float64 - sr3highx2 float64 - z0 float64 - z1 float64 - z2 float64 - z3 float64 - m0 int64 - m1 int64 - m2 int64 - m3 int64 - m00 uint32 - m01 uint32 - m02 uint32 - m03 uint32 - m10 uint32 - m11 uint32 - m12 uint32 - m13 uint32 - m20 uint32 - m21 uint32 - m22 uint32 - m23 uint32 - m30 uint32 - m31 uint32 - m32 uint32 - m33 uint64 - lbelow2 int32 - lbelow3 int32 - lbelow4 int32 - lbelow5 int32 - lbelow6 int32 - lbelow7 int32 - lbelow8 int32 - lbelow9 int32 - lbelow10 int32 - lbelow11 int32 - lbelow12 int32 - lbelow13 int32 - lbelow14 int32 - lbelow15 int32 - s00 uint32 - s01 uint32 - s02 uint32 - s03 uint32 - s10 uint32 - s11 uint32 - s12 uint32 - s13 uint32 - s20 uint32 - s21 uint32 - s22 uint32 - s23 uint32 - s30 uint32 - s31 uint32 - s32 uint32 - s33 uint32 - bits32 uint64 - f uint64 - f0 uint64 - f1 uint64 - f2 uint64 - f3 uint64 - f4 uint64 - g uint64 - g0 uint64 - g1 uint64 - g2 uint64 - g3 uint64 - g4 uint64 + h0, h1, h2, h3, h4 uint32 // the hash accumulators + r0, r1, r2, r3, r4 uint64 // the r part of the key ) - var p int32 - - l := int32(len(m)) - - r00 := uint32(r[0]) - - r01 := uint32(r[1]) - - r02 := uint32(r[2]) - r0 := int64(2151) - - r03 := uint32(r[3]) - r03 &= 15 - r0 <<= 51 - - r10 := uint32(r[4]) - r10 &= 252 - r01 <<= 8 - r0 += int64(r00) - - r11 := uint32(r[5]) - r02 <<= 16 - r0 += int64(r01) - - r12 := uint32(r[6]) - r03 <<= 24 - r0 += int64(r02) - - r13 := uint32(r[7]) - r13 &= 15 - r1 := int64(2215) - r0 += int64(r03) - - d0 := r0 - r1 <<= 51 - r2 := int64(2279) - - r20 := uint32(r[8]) - r20 &= 252 - r11 <<= 8 - r1 += int64(r10) - - r21 := uint32(r[9]) - r12 <<= 16 - r1 += int64(r11) - - r22 := uint32(r[10]) - r13 <<= 24 - r1 += int64(r12) - - r23 := uint32(r[11]) - r23 &= 15 - r2 <<= 51 - r1 += int64(r13) - - d1 := r1 - r21 <<= 8 - r2 += int64(r20) - - r30 := uint32(r[12]) - r30 &= 252 - r22 <<= 16 - r2 += int64(r21) - - r31 := uint32(r[13]) - r23 <<= 24 - r2 += int64(r22) - - r32 := uint32(r[14]) - r2 += int64(r23) - r3 := int64(2343) - - d2 := r2 - r3 <<= 51 - - r33 := uint32(r[15]) - r33 &= 15 - r31 <<= 8 - r3 += int64(r30) - - r32 <<= 16 - r3 += int64(r31) - - r33 <<= 24 - r3 += int64(r32) - - r3 += int64(r33) - h0 := alpha32 - alpha32 - - d3 := r3 - h1 := alpha32 - alpha32 - - h2 := alpha32 - alpha32 - - h3 := alpha32 - alpha32 - - h4 := alpha32 - alpha32 - - r0low := math.Float64frombits(uint64(d0)) - h5 := alpha32 - alpha32 - - r1low := math.Float64frombits(uint64(d1)) - h6 := alpha32 - alpha32 - - r2low := math.Float64frombits(uint64(d2)) - h7 := alpha32 - alpha32 - - r0low -= alpha0 - - r1low -= alpha32 - - r2low -= alpha64 - - r0high := r0low + alpha18 - - r3low := math.Float64frombits(uint64(d3)) - - r1high := r1low + alpha50 - sr1low := scale * r1low - - r2high := r2low + alpha82 - sr2low := scale * r2low - - r0high -= alpha18 - r0high_stack := r0high - - r3low -= alpha96 - - r1high -= alpha50 - r1high_stack := r1high - - sr1high := sr1low + alpham80 - - r0low -= r0high - - r2high -= alpha82 - sr3low = scale * r3low - - sr2high := sr2low + alpham48 - - r1low -= r1high - r1low_stack := r1low - - sr1high -= alpham80 - sr1high_stack := sr1high - - r2low -= r2high - r2low_stack := r2low - - sr2high -= alpham48 - sr2high_stack := sr2high - - r3high := r3low + alpha112 - r0low_stack := r0low - - sr1low -= sr1high - sr1low_stack := sr1low - - sr3high := sr3low + alpham16 - r2high_stack := r2high - - sr2low -= sr2high - sr2low_stack := sr2low - - r3high -= alpha112 - r3high_stack := r3high - - sr3high -= alpham16 - sr3high_stack := sr3high - - r3low -= r3high - r3low_stack := r3low - - sr3low -= sr3high - sr3low_stack := sr3low - - if l < 16 { - goto addatmost15bytes - } - - m00 = uint32(m[p+0]) - m0 = 2151 - - m0 <<= 51 - m1 = 2215 - m01 = uint32(m[p+1]) - - m1 <<= 51 - m2 = 2279 - m02 = uint32(m[p+2]) - - m2 <<= 51 - m3 = 2343 - m03 = uint32(m[p+3]) - - m10 = uint32(m[p+4]) - m01 <<= 8 - m0 += int64(m00) - - m11 = uint32(m[p+5]) - m02 <<= 16 - m0 += int64(m01) - - m12 = uint32(m[p+6]) - m03 <<= 24 - m0 += int64(m02) - - m13 = uint32(m[p+7]) - m3 <<= 51 - m0 += int64(m03) - - m20 = uint32(m[p+8]) - m11 <<= 8 - m1 += int64(m10) - - m21 = uint32(m[p+9]) - m12 <<= 16 - m1 += int64(m11) - - m22 = uint32(m[p+10]) - m13 <<= 24 - m1 += int64(m12) - - m23 = uint32(m[p+11]) - m1 += int64(m13) - - m30 = uint32(m[p+12]) - m21 <<= 8 - m2 += int64(m20) - - m31 = uint32(m[p+13]) - m22 <<= 16 - m2 += int64(m21) - - m32 = uint32(m[p+14]) - m23 <<= 24 - m2 += int64(m22) - - m33 = uint64(m[p+15]) - m2 += int64(m23) - - d0 = m0 - m31 <<= 8 - m3 += int64(m30) - - d1 = m1 - m32 <<= 16 - m3 += int64(m31) - - d2 = m2 - m33 += 256 - - m33 <<= 24 - m3 += int64(m32) - - m3 += int64(m33) - d3 = m3 - - p += 16 - l -= 16 - - z0 = math.Float64frombits(uint64(d0)) - - z1 = math.Float64frombits(uint64(d1)) - - z2 = math.Float64frombits(uint64(d2)) - - z3 = math.Float64frombits(uint64(d3)) - - z0 -= alpha0 - - z1 -= alpha32 - - z2 -= alpha64 - - z3 -= alpha96 - - h0 += z0 - - h1 += z1 - - h3 += z2 - - h5 += z3 - - if l < 16 { - goto multiplyaddatmost15bytes + r0 = uint64(binary.LittleEndian.Uint32(key[0:]) & 0x3ffffff) + r1 = uint64((binary.LittleEndian.Uint32(key[3:]) >> 2) & 0x3ffff03) + r2 = uint64((binary.LittleEndian.Uint32(key[6:]) >> 4) & 0x3ffc0ff) + r3 = uint64((binary.LittleEndian.Uint32(key[9:]) >> 6) & 0x3f03fff) + r4 = uint64((binary.LittleEndian.Uint32(key[12:]) >> 8) & 0x00fffff) + + R1, R2, R3, R4 := r1*5, r2*5, r3*5, r4*5 + + for len(msg) >= TagSize { + // h += msg + h0 += binary.LittleEndian.Uint32(msg[0:]) & 0x3ffffff + h1 += (binary.LittleEndian.Uint32(msg[3:]) >> 2) & 0x3ffffff + h2 += (binary.LittleEndian.Uint32(msg[6:]) >> 4) & 0x3ffffff + h3 += (binary.LittleEndian.Uint32(msg[9:]) >> 6) & 0x3ffffff + h4 += (binary.LittleEndian.Uint32(msg[12:]) >> 8) | (1 << 24) + + // h *= r + d0 := (uint64(h0) * r0) + (uint64(h1) * R4) + (uint64(h2) * R3) + (uint64(h3) * R2) + (uint64(h4) * R1) + d1 := (d0 >> 26) + (uint64(h0) * r1) + (uint64(h1) * r0) + (uint64(h2) * R4) + (uint64(h3) * R3) + (uint64(h4) * R2) + d2 := (d1 >> 26) + (uint64(h0) * r2) + (uint64(h1) * r1) + (uint64(h2) * r0) + (uint64(h3) * R4) + (uint64(h4) * R3) + d3 := (d2 >> 26) + (uint64(h0) * r3) + (uint64(h1) * r2) + (uint64(h2) * r1) + (uint64(h3) * r0) + (uint64(h4) * R4) + d4 := (d3 >> 26) + (uint64(h0) * r4) + (uint64(h1) * r3) + (uint64(h2) * r2) + (uint64(h3) * r1) + (uint64(h4) * r0) + + // h %= p + h0 = uint32(d0) & 0x3ffffff + h1 = uint32(d1) & 0x3ffffff + h2 = uint32(d2) & 0x3ffffff + h3 = uint32(d3) & 0x3ffffff + h4 = uint32(d4) & 0x3ffffff + + h0 += uint32(d4>>26) * 5 + h1 += h0 >> 26 + h0 = h0 & 0x3ffffff + + msg = msg[TagSize:] } -multiplyaddatleast16bytes: - - m2 = 2279 - m20 = uint32(m[p+8]) - y7 = h7 + alpha130 - - m2 <<= 51 - m3 = 2343 - m21 = uint32(m[p+9]) - y6 = h6 + alpha130 - - m3 <<= 51 - m0 = 2151 - m22 = uint32(m[p+10]) - y1 = h1 + alpha32 - - m0 <<= 51 - m1 = 2215 - m23 = uint32(m[p+11]) - y0 = h0 + alpha32 - - m1 <<= 51 - m30 = uint32(m[p+12]) - y7 -= alpha130 - - m21 <<= 8 - m2 += int64(m20) - m31 = uint32(m[p+13]) - y6 -= alpha130 - - m22 <<= 16 - m2 += int64(m21) - m32 = uint32(m[p+14]) - y1 -= alpha32 - - m23 <<= 24 - m2 += int64(m22) - m33 = uint64(m[p+15]) - y0 -= alpha32 - - m2 += int64(m23) - m00 = uint32(m[p+0]) - y5 = h5 + alpha96 - - m31 <<= 8 - m3 += int64(m30) - m01 = uint32(m[p+1]) - y4 = h4 + alpha96 - - m32 <<= 16 - m02 = uint32(m[p+2]) - x7 = h7 - y7 - y7 *= scale - - m33 += 256 - m03 = uint32(m[p+3]) - x6 = h6 - y6 - y6 *= scale - - m33 <<= 24 - m3 += int64(m31) - m10 = uint32(m[p+4]) - x1 = h1 - y1 - - m01 <<= 8 - m3 += int64(m32) - m11 = uint32(m[p+5]) - x0 = h0 - y0 - - m3 += int64(m33) - m0 += int64(m00) - m12 = uint32(m[p+6]) - y5 -= alpha96 - - m02 <<= 16 - m0 += int64(m01) - m13 = uint32(m[p+7]) - y4 -= alpha96 - - m03 <<= 24 - m0 += int64(m02) - d2 = m2 - x1 += y7 - - m0 += int64(m03) - d3 = m3 - x0 += y6 - - m11 <<= 8 - m1 += int64(m10) - d0 = m0 - x7 += y5 - - m12 <<= 16 - m1 += int64(m11) - x6 += y4 - - m13 <<= 24 - m1 += int64(m12) - y3 = h3 + alpha64 - - m1 += int64(m13) - d1 = m1 - y2 = h2 + alpha64 - - x0 += x1 - - x6 += x7 - - y3 -= alpha64 - r3low = r3low_stack - - y2 -= alpha64 - r0low = r0low_stack - - x5 = h5 - y5 - r3lowx0 = r3low * x0 - r3high = r3high_stack - - x4 = h4 - y4 - r0lowx6 = r0low * x6 - r0high = r0high_stack - - x3 = h3 - y3 - r3highx0 = r3high * x0 - sr1low = sr1low_stack - - x2 = h2 - y2 - r0highx6 = r0high * x6 - sr1high = sr1high_stack - - x5 += y3 - r0lowx0 = r0low * x0 - r1low = r1low_stack - - h6 = r3lowx0 + r0lowx6 - sr1lowx6 = sr1low * x6 - r1high = r1high_stack - - x4 += y2 - r0highx0 = r0high * x0 - sr2low = sr2low_stack - - h7 = r3highx0 + r0highx6 - sr1highx6 = sr1high * x6 - sr2high = sr2high_stack - - x3 += y1 - r1lowx0 = r1low * x0 - r2low = r2low_stack - - h0 = r0lowx0 + sr1lowx6 - sr2lowx6 = sr2low * x6 - r2high = r2high_stack - - x2 += y0 - r1highx0 = r1high * x0 - sr3low = sr3low_stack - - h1 = r0highx0 + sr1highx6 - sr2highx6 = sr2high * x6 - sr3high = sr3high_stack - - x4 += x5 - r2lowx0 = r2low * x0 - z2 = math.Float64frombits(uint64(d2)) - - h2 = r1lowx0 + sr2lowx6 - sr3lowx6 = sr3low * x6 - - x2 += x3 - r2highx0 = r2high * x0 - z3 = math.Float64frombits(uint64(d3)) - - h3 = r1highx0 + sr2highx6 - sr3highx6 = sr3high * x6 - - r1highx4 = r1high * x4 - z2 -= alpha64 - - h4 = r2lowx0 + sr3lowx6 - r1lowx4 = r1low * x4 - - r0highx4 = r0high * x4 - z3 -= alpha96 - - h5 = r2highx0 + sr3highx6 - r0lowx4 = r0low * x4 - - h7 += r1highx4 - sr3highx4 = sr3high * x4 - - h6 += r1lowx4 - sr3lowx4 = sr3low * x4 - - h5 += r0highx4 - sr2highx4 = sr2high * x4 - - h4 += r0lowx4 - sr2lowx4 = sr2low * x4 - - h3 += sr3highx4 - r0lowx2 = r0low * x2 - - h2 += sr3lowx4 - r0highx2 = r0high * x2 - - h1 += sr2highx4 - r1lowx2 = r1low * x2 - - h0 += sr2lowx4 - r1highx2 = r1high * x2 - - h2 += r0lowx2 - r2lowx2 = r2low * x2 - - h3 += r0highx2 - r2highx2 = r2high * x2 - - h4 += r1lowx2 - sr3lowx2 = sr3low * x2 - - h5 += r1highx2 - sr3highx2 = sr3high * x2 - - p += 16 - l -= 16 - h6 += r2lowx2 - - h7 += r2highx2 - - z1 = math.Float64frombits(uint64(d1)) - h0 += sr3lowx2 - - z0 = math.Float64frombits(uint64(d0)) - h1 += sr3highx2 - - z1 -= alpha32 - - z0 -= alpha0 - - h5 += z3 - - h3 += z2 - - h1 += z1 - - h0 += z0 - - if l >= 16 { - goto multiplyaddatleast16bytes - } - -multiplyaddatmost15bytes: - - y7 = h7 + alpha130 - - y6 = h6 + alpha130 - - y1 = h1 + alpha32 - - y0 = h0 + alpha32 - - y7 -= alpha130 - - y6 -= alpha130 - - y1 -= alpha32 - - y0 -= alpha32 - - y5 = h5 + alpha96 - - y4 = h4 + alpha96 - - x7 = h7 - y7 - y7 *= scale - - x6 = h6 - y6 - y6 *= scale - - x1 = h1 - y1 - - x0 = h0 - y0 - - y5 -= alpha96 - - y4 -= alpha96 - - x1 += y7 - - x0 += y6 - - x7 += y5 - - x6 += y4 - - y3 = h3 + alpha64 - - y2 = h2 + alpha64 - - x0 += x1 - - x6 += x7 - - y3 -= alpha64 - r3low = r3low_stack - - y2 -= alpha64 - r0low = r0low_stack - - x5 = h5 - y5 - r3lowx0 = r3low * x0 - r3high = r3high_stack - - x4 = h4 - y4 - r0lowx6 = r0low * x6 - r0high = r0high_stack - - x3 = h3 - y3 - r3highx0 = r3high * x0 - sr1low = sr1low_stack - - x2 = h2 - y2 - r0highx6 = r0high * x6 - sr1high = sr1high_stack - - x5 += y3 - r0lowx0 = r0low * x0 - r1low = r1low_stack - - h6 = r3lowx0 + r0lowx6 - sr1lowx6 = sr1low * x6 - r1high = r1high_stack - - x4 += y2 - r0highx0 = r0high * x0 - sr2low = sr2low_stack - - h7 = r3highx0 + r0highx6 - sr1highx6 = sr1high * x6 - sr2high = sr2high_stack - - x3 += y1 - r1lowx0 = r1low * x0 - r2low = r2low_stack - - h0 = r0lowx0 + sr1lowx6 - sr2lowx6 = sr2low * x6 - r2high = r2high_stack - - x2 += y0 - r1highx0 = r1high * x0 - sr3low = sr3low_stack - - h1 = r0highx0 + sr1highx6 - sr2highx6 = sr2high * x6 - sr3high = sr3high_stack - - x4 += x5 - r2lowx0 = r2low * x0 - - h2 = r1lowx0 + sr2lowx6 - sr3lowx6 = sr3low * x6 - - x2 += x3 - r2highx0 = r2high * x0 - - h3 = r1highx0 + sr2highx6 - sr3highx6 = sr3high * x6 - - r1highx4 = r1high * x4 - - h4 = r2lowx0 + sr3lowx6 - r1lowx4 = r1low * x4 - - r0highx4 = r0high * x4 - - h5 = r2highx0 + sr3highx6 - r0lowx4 = r0low * x4 - - h7 += r1highx4 - sr3highx4 = sr3high * x4 - - h6 += r1lowx4 - sr3lowx4 = sr3low * x4 - - h5 += r0highx4 - sr2highx4 = sr2high * x4 - - h4 += r0lowx4 - sr2lowx4 = sr2low * x4 - - h3 += sr3highx4 - r0lowx2 = r0low * x2 - - h2 += sr3lowx4 - r0highx2 = r0high * x2 - - h1 += sr2highx4 - r1lowx2 = r1low * x2 - - h0 += sr2lowx4 - r1highx2 = r1high * x2 - - h2 += r0lowx2 - r2lowx2 = r2low * x2 - - h3 += r0highx2 - r2highx2 = r2high * x2 - - h4 += r1lowx2 - sr3lowx2 = sr3low * x2 - - h5 += r1highx2 - sr3highx2 = sr3high * x2 - - h6 += r2lowx2 - - h7 += r2highx2 - - h0 += sr3lowx2 - - h1 += sr3highx2 - -addatmost15bytes: - - if l == 0 { - goto nomorebytes + if len(msg) > 0 { + var block [TagSize]byte + off := copy(block[:], msg) + block[off] = 0x01 + + // h += msg + h0 += binary.LittleEndian.Uint32(block[0:]) & 0x3ffffff + h1 += (binary.LittleEndian.Uint32(block[3:]) >> 2) & 0x3ffffff + h2 += (binary.LittleEndian.Uint32(block[6:]) >> 4) & 0x3ffffff + h3 += (binary.LittleEndian.Uint32(block[9:]) >> 6) & 0x3ffffff + h4 += (binary.LittleEndian.Uint32(block[12:]) >> 8) + + // h *= r + d0 := (uint64(h0) * r0) + (uint64(h1) * R4) + (uint64(h2) * R3) + (uint64(h3) * R2) + (uint64(h4) * R1) + d1 := (d0 >> 26) + (uint64(h0) * r1) + (uint64(h1) * r0) + (uint64(h2) * R4) + (uint64(h3) * R3) + (uint64(h4) * R2) + d2 := (d1 >> 26) + (uint64(h0) * r2) + (uint64(h1) * r1) + (uint64(h2) * r0) + (uint64(h3) * R4) + (uint64(h4) * R3) + d3 := (d2 >> 26) + (uint64(h0) * r3) + (uint64(h1) * r2) + (uint64(h2) * r1) + (uint64(h3) * r0) + (uint64(h4) * R4) + d4 := (d3 >> 26) + (uint64(h0) * r4) + (uint64(h1) * r3) + (uint64(h2) * r2) + (uint64(h3) * r1) + (uint64(h4) * r0) + + // h %= p + h0 = uint32(d0) & 0x3ffffff + h1 = uint32(d1) & 0x3ffffff + h2 = uint32(d2) & 0x3ffffff + h3 = uint32(d3) & 0x3ffffff + h4 = uint32(d4) & 0x3ffffff + + h0 += uint32(d4>>26) * 5 + h1 += h0 >> 26 + h0 = h0 & 0x3ffffff } - lbelow2 = l - 2 - - lbelow3 = l - 3 - - lbelow2 >>= 31 - lbelow4 = l - 4 - - m00 = uint32(m[p+0]) - lbelow3 >>= 31 - p += lbelow2 - - m01 = uint32(m[p+1]) - lbelow4 >>= 31 - p += lbelow3 - - m02 = uint32(m[p+2]) - p += lbelow4 - m0 = 2151 - - m03 = uint32(m[p+3]) - m0 <<= 51 - m1 = 2215 - - m0 += int64(m00) - m01 &^= uint32(lbelow2) - - m02 &^= uint32(lbelow3) - m01 -= uint32(lbelow2) - - m01 <<= 8 - m03 &^= uint32(lbelow4) - - m0 += int64(m01) - lbelow2 -= lbelow3 - - m02 += uint32(lbelow2) - lbelow3 -= lbelow4 - - m02 <<= 16 - m03 += uint32(lbelow3) - - m03 <<= 24 - m0 += int64(m02) - - m0 += int64(m03) - lbelow5 = l - 5 - - lbelow6 = l - 6 - lbelow7 = l - 7 - - lbelow5 >>= 31 - lbelow8 = l - 8 - - lbelow6 >>= 31 - p += lbelow5 - - m10 = uint32(m[p+4]) - lbelow7 >>= 31 - p += lbelow6 - - m11 = uint32(m[p+5]) - lbelow8 >>= 31 - p += lbelow7 - - m12 = uint32(m[p+6]) - m1 <<= 51 - p += lbelow8 - - m13 = uint32(m[p+7]) - m10 &^= uint32(lbelow5) - lbelow4 -= lbelow5 - - m10 += uint32(lbelow4) - lbelow5 -= lbelow6 - - m11 &^= uint32(lbelow6) - m11 += uint32(lbelow5) - - m11 <<= 8 - m1 += int64(m10) - - m1 += int64(m11) - m12 &^= uint32(lbelow7) - - lbelow6 -= lbelow7 - m13 &^= uint32(lbelow8) - - m12 += uint32(lbelow6) - lbelow7 -= lbelow8 - - m12 <<= 16 - m13 += uint32(lbelow7) - - m13 <<= 24 - m1 += int64(m12) - - m1 += int64(m13) - m2 = 2279 - - lbelow9 = l - 9 - m3 = 2343 - - lbelow10 = l - 10 - lbelow11 = l - 11 - - lbelow9 >>= 31 - lbelow12 = l - 12 - - lbelow10 >>= 31 - p += lbelow9 - - m20 = uint32(m[p+8]) - lbelow11 >>= 31 - p += lbelow10 - - m21 = uint32(m[p+9]) - lbelow12 >>= 31 - p += lbelow11 - - m22 = uint32(m[p+10]) - m2 <<= 51 - p += lbelow12 - - m23 = uint32(m[p+11]) - m20 &^= uint32(lbelow9) - lbelow8 -= lbelow9 - - m20 += uint32(lbelow8) - lbelow9 -= lbelow10 - - m21 &^= uint32(lbelow10) - m21 += uint32(lbelow9) - - m21 <<= 8 - m2 += int64(m20) - - m2 += int64(m21) - m22 &^= uint32(lbelow11) - - lbelow10 -= lbelow11 - m23 &^= uint32(lbelow12) - - m22 += uint32(lbelow10) - lbelow11 -= lbelow12 - - m22 <<= 16 - m23 += uint32(lbelow11) - - m23 <<= 24 - m2 += int64(m22) - - m3 <<= 51 - lbelow13 = l - 13 - - lbelow13 >>= 31 - lbelow14 = l - 14 - - lbelow14 >>= 31 - p += lbelow13 - lbelow15 = l - 15 - - m30 = uint32(m[p+12]) - lbelow15 >>= 31 - p += lbelow14 - - m31 = uint32(m[p+13]) - p += lbelow15 - m2 += int64(m23) - - m32 = uint32(m[p+14]) - m30 &^= uint32(lbelow13) - lbelow12 -= lbelow13 - - m30 += uint32(lbelow12) - lbelow13 -= lbelow14 - - m3 += int64(m30) - m31 &^= uint32(lbelow14) - - m31 += uint32(lbelow13) - m32 &^= uint32(lbelow15) - - m31 <<= 8 - lbelow14 -= lbelow15 - - m3 += int64(m31) - m32 += uint32(lbelow14) - d0 = m0 - - m32 <<= 16 - m33 = uint64(lbelow15 + 1) - d1 = m1 - - m33 <<= 24 - m3 += int64(m32) - d2 = m2 - - m3 += int64(m33) - d3 = m3 - - z3 = math.Float64frombits(uint64(d3)) - - z2 = math.Float64frombits(uint64(d2)) - - z1 = math.Float64frombits(uint64(d1)) - - z0 = math.Float64frombits(uint64(d0)) - - z3 -= alpha96 - - z2 -= alpha64 - - z1 -= alpha32 - - z0 -= alpha0 - - h5 += z3 - - h3 += z2 - - h1 += z1 - - h0 += z0 - - y7 = h7 + alpha130 - - y6 = h6 + alpha130 - - y1 = h1 + alpha32 - - y0 = h0 + alpha32 - - y7 -= alpha130 - - y6 -= alpha130 - - y1 -= alpha32 - - y0 -= alpha32 - - y5 = h5 + alpha96 - - y4 = h4 + alpha96 - - x7 = h7 - y7 - y7 *= scale - - x6 = h6 - y6 - y6 *= scale - - x1 = h1 - y1 - - x0 = h0 - y0 - - y5 -= alpha96 - - y4 -= alpha96 - - x1 += y7 - - x0 += y6 - - x7 += y5 - - x6 += y4 - - y3 = h3 + alpha64 - - y2 = h2 + alpha64 - - x0 += x1 - - x6 += x7 - - y3 -= alpha64 - r3low = r3low_stack - - y2 -= alpha64 - r0low = r0low_stack - - x5 = h5 - y5 - r3lowx0 = r3low * x0 - r3high = r3high_stack - - x4 = h4 - y4 - r0lowx6 = r0low * x6 - r0high = r0high_stack - - x3 = h3 - y3 - r3highx0 = r3high * x0 - sr1low = sr1low_stack - - x2 = h2 - y2 - r0highx6 = r0high * x6 - sr1high = sr1high_stack - - x5 += y3 - r0lowx0 = r0low * x0 - r1low = r1low_stack - - h6 = r3lowx0 + r0lowx6 - sr1lowx6 = sr1low * x6 - r1high = r1high_stack - - x4 += y2 - r0highx0 = r0high * x0 - sr2low = sr2low_stack - - h7 = r3highx0 + r0highx6 - sr1highx6 = sr1high * x6 - sr2high = sr2high_stack - - x3 += y1 - r1lowx0 = r1low * x0 - r2low = r2low_stack - - h0 = r0lowx0 + sr1lowx6 - sr2lowx6 = sr2low * x6 - r2high = r2high_stack - - x2 += y0 - r1highx0 = r1high * x0 - sr3low = sr3low_stack - - h1 = r0highx0 + sr1highx6 - sr2highx6 = sr2high * x6 - sr3high = sr3high_stack - - x4 += x5 - r2lowx0 = r2low * x0 - - h2 = r1lowx0 + sr2lowx6 - sr3lowx6 = sr3low * x6 - - x2 += x3 - r2highx0 = r2high * x0 - - h3 = r1highx0 + sr2highx6 - sr3highx6 = sr3high * x6 - - r1highx4 = r1high * x4 - - h4 = r2lowx0 + sr3lowx6 - r1lowx4 = r1low * x4 - - r0highx4 = r0high * x4 - - h5 = r2highx0 + sr3highx6 - r0lowx4 = r0low * x4 - - h7 += r1highx4 - sr3highx4 = sr3high * x4 - - h6 += r1lowx4 - sr3lowx4 = sr3low * x4 - - h5 += r0highx4 - sr2highx4 = sr2high * x4 - - h4 += r0lowx4 - sr2lowx4 = sr2low * x4 - - h3 += sr3highx4 - r0lowx2 = r0low * x2 - - h2 += sr3lowx4 - r0highx2 = r0high * x2 - - h1 += sr2highx4 - r1lowx2 = r1low * x2 - - h0 += sr2lowx4 - r1highx2 = r1high * x2 - - h2 += r0lowx2 - r2lowx2 = r2low * x2 - - h3 += r0highx2 - r2highx2 = r2high * x2 - - h4 += r1lowx2 - sr3lowx2 = sr3low * x2 - - h5 += r1highx2 - sr3highx2 = sr3high * x2 - - h6 += r2lowx2 - - h7 += r2highx2 - - h0 += sr3lowx2 - - h1 += sr3highx2 - -nomorebytes: - - y7 = h7 + alpha130 - - y0 = h0 + alpha32 - - y1 = h1 + alpha32 - - y2 = h2 + alpha64 - - y7 -= alpha130 - - y3 = h3 + alpha64 - - y4 = h4 + alpha96 - - y5 = h5 + alpha96 - - x7 = h7 - y7 - y7 *= scale - - y0 -= alpha32 - - y1 -= alpha32 - - y2 -= alpha64 - - h6 += x7 - - y3 -= alpha64 - - y4 -= alpha96 - - y5 -= alpha96 - - y6 = h6 + alpha130 - - x0 = h0 - y0 - - x1 = h1 - y1 - - x2 = h2 - y2 - - y6 -= alpha130 - - x0 += y7 - - x3 = h3 - y3 - - x4 = h4 - y4 - - x5 = h5 - y5 - - x6 = h6 - y6 - - y6 *= scale - - x2 += y0 - - x3 += y1 - - x4 += y2 - - x0 += y6 - - x5 += y3 - - x6 += y4 - - x2 += x3 - - x0 += x1 - - x4 += x5 - - x6 += y5 - - x2 += offset1 - d1 = int64(math.Float64bits(x2)) - - x0 += offset0 - d0 = int64(math.Float64bits(x0)) - - x4 += offset2 - d2 = int64(math.Float64bits(x4)) - - x6 += offset3 - d3 = int64(math.Float64bits(x6)) - - f0 = uint64(d0) - - f1 = uint64(d1) - bits32 = math.MaxUint64 - - f2 = uint64(d2) - bits32 >>= 32 - - f3 = uint64(d3) - f = f0 >> 32 - - f0 &= bits32 - f &= 255 - - f1 += f - g0 = f0 + 5 - - g = g0 >> 32 - g0 &= bits32 - - f = f1 >> 32 - f1 &= bits32 - - f &= 255 - g1 = f1 + g - - g = g1 >> 32 - f2 += f - - f = f2 >> 32 - g1 &= bits32 - - f2 &= bits32 - f &= 255 - - f3 += f - g2 = f2 + g - - g = g2 >> 32 - g2 &= bits32 - - f4 = f3 >> 32 - f3 &= bits32 - - f4 &= 255 - g3 = f3 + g - - g = g3 >> 32 - g3 &= bits32 - - g4 = f4 + g - - g4 = g4 - 4 - s00 = uint32(s[0]) - - f = uint64(int64(g4) >> 63) - s01 = uint32(s[1]) - - f0 &= f - g0 &^= f - s02 = uint32(s[2]) - - f1 &= f - f0 |= g0 - s03 = uint32(s[3]) - - g1 &^= f - f2 &= f - s10 = uint32(s[4]) - - f3 &= f - g2 &^= f - s11 = uint32(s[5]) - - g3 &^= f - f1 |= g1 - s12 = uint32(s[6]) - - f2 |= g2 - f3 |= g3 - s13 = uint32(s[7]) - - s01 <<= 8 - f0 += uint64(s00) - s20 = uint32(s[8]) - - s02 <<= 16 - f0 += uint64(s01) - s21 = uint32(s[9]) - - s03 <<= 24 - f0 += uint64(s02) - s22 = uint32(s[10]) - - s11 <<= 8 - f1 += uint64(s10) - s23 = uint32(s[11]) - - s12 <<= 16 - f1 += uint64(s11) - s30 = uint32(s[12]) - - s13 <<= 24 - f1 += uint64(s12) - s31 = uint32(s[13]) - - f0 += uint64(s03) - f1 += uint64(s13) - s32 = uint32(s[14]) - - s21 <<= 8 - f2 += uint64(s20) - s33 = uint32(s[15]) - - s22 <<= 16 - f2 += uint64(s21) - - s23 <<= 24 - f2 += uint64(s22) - - s31 <<= 8 - f3 += uint64(s30) - - s32 <<= 16 - f3 += uint64(s31) - - s33 <<= 24 - f3 += uint64(s32) - - f2 += uint64(s23) - f3 += uint64(s33) - - out[0] = byte(f0) - f0 >>= 8 - out[1] = byte(f0) - f0 >>= 8 - out[2] = byte(f0) - f0 >>= 8 - out[3] = byte(f0) - f0 >>= 8 - f1 += f0 - - out[4] = byte(f1) - f1 >>= 8 - out[5] = byte(f1) - f1 >>= 8 - out[6] = byte(f1) - f1 >>= 8 - out[7] = byte(f1) - f1 >>= 8 - f2 += f1 - - out[8] = byte(f2) - f2 >>= 8 - out[9] = byte(f2) - f2 >>= 8 - out[10] = byte(f2) - f2 >>= 8 - out[11] = byte(f2) - f2 >>= 8 - f3 += f2 - - out[12] = byte(f3) - f3 >>= 8 - out[13] = byte(f3) - f3 >>= 8 - out[14] = byte(f3) - f3 >>= 8 - out[15] = byte(f3) + // h %= p reduction + h2 += h1 >> 26 + h1 &= 0x3ffffff + h3 += h2 >> 26 + h2 &= 0x3ffffff + h4 += h3 >> 26 + h3 &= 0x3ffffff + h0 += 5 * (h4 >> 26) + h4 &= 0x3ffffff + h1 += h0 >> 26 + h0 &= 0x3ffffff + + // h - p + t0 := h0 + 5 + t1 := h1 + (t0 >> 26) + t2 := h2 + (t1 >> 26) + t3 := h3 + (t2 >> 26) + t4 := h4 + (t3 >> 26) - (1 << 26) + t0 &= 0x3ffffff + t1 &= 0x3ffffff + t2 &= 0x3ffffff + t3 &= 0x3ffffff + + // select h if h < p else h - p + t_mask := (t4 >> 31) - 1 + h_mask := ^t_mask + h0 = (h0 & h_mask) | (t0 & t_mask) + h1 = (h1 & h_mask) | (t1 & t_mask) + h2 = (h2 & h_mask) | (t2 & t_mask) + h3 = (h3 & h_mask) | (t3 & t_mask) + h4 = (h4 & h_mask) | (t4 & t_mask) + + // h %= 2^128 + h0 |= h1 << 26 + h1 = ((h1 >> 6) | (h2 << 20)) + h2 = ((h2 >> 12) | (h3 << 14)) + h3 = ((h3 >> 18) | (h4 << 8)) + + // s: the s part of the key + // tag = (h + s) % (2^128) + t := uint64(h0) + uint64(binary.LittleEndian.Uint32(key[16:])) + h0 = uint32(t) + t = uint64(h1) + uint64(binary.LittleEndian.Uint32(key[20:])) + (t >> 32) + h1 = uint32(t) + t = uint64(h2) + uint64(binary.LittleEndian.Uint32(key[24:])) + (t >> 32) + h2 = uint32(t) + t = uint64(h3) + uint64(binary.LittleEndian.Uint32(key[28:])) + (t >> 32) + h3 = uint32(t) + + binary.LittleEndian.PutUint32(out[0:], h0) + binary.LittleEndian.PutUint32(out[4:], h1) + binary.LittleEndian.PutUint32(out[8:], h2) + binary.LittleEndian.PutUint32(out[12:], h3) } diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/salsa20/salsa/salsa2020_amd64.s b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/salsa20/salsa/salsa2020_amd64.s index 6e1df9639..22afbdcad 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/salsa20/salsa/salsa2020_amd64.s +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/salsa20/salsa/salsa2020_amd64.s @@ -5,29 +5,23 @@ // +build amd64,!appengine,!gccgo // This code was translated into a form compatible with 6a from the public -// domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html +// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html // func salsa2020XORKeyStream(out, in *byte, n uint64, nonce, key *byte) -TEXT ·salsa2020XORKeyStream(SB),0,$512-40 +// This needs up to 64 bytes at 360(SP); hence the non-obvious frame size. +TEXT ·salsa2020XORKeyStream(SB),0,$456-40 // frame = 424 + 32 byte alignment MOVQ out+0(FP),DI MOVQ in+8(FP),SI MOVQ n+16(FP),DX MOVQ nonce+24(FP),CX MOVQ key+32(FP),R8 - MOVQ SP,R11 - MOVQ $31,R9 - NOTQ R9 - ANDQ R9,SP - ADDQ $32,SP + MOVQ SP,R12 + MOVQ SP,R9 + ADDQ $31, R9 + ANDQ $~31, R9 + MOVQ R9, SP - MOVQ R11,352(SP) - MOVQ R12,360(SP) - MOVQ R13,368(SP) - MOVQ R14,376(SP) - MOVQ R15,384(SP) - MOVQ BX,392(SP) - MOVQ BP,400(SP) MOVQ DX,R9 MOVQ CX,DX MOVQ R8,R10 @@ -133,7 +127,7 @@ TEXT ·salsa2020XORKeyStream(SB),0,$512-40 SHRQ $32,CX MOVL DX,16(SP) MOVL CX, 36 (SP) - MOVQ R9,408(SP) + MOVQ R9,352(SP) MOVQ $20,DX MOVOA 64(SP),X0 MOVOA 80(SP),X1 @@ -650,7 +644,7 @@ TEXT ·salsa2020XORKeyStream(SB),0,$512-40 MOVL CX,244(DI) MOVL R8,248(DI) MOVL R9,252(DI) - MOVQ 408(SP),R9 + MOVQ 352(SP),R9 SUBQ $256,R9 ADDQ $256,SI ADDQ $256,DI @@ -662,13 +656,13 @@ TEXT ·salsa2020XORKeyStream(SB),0,$512-40 CMPQ R9,$64 JAE NOCOPY MOVQ DI,DX - LEAQ 416(SP),DI + LEAQ 360(SP),DI MOVQ R9,CX REP; MOVSB - LEAQ 416(SP),DI - LEAQ 416(SP),SI + LEAQ 360(SP),DI + LEAQ 360(SP),SI NOCOPY: - MOVQ R9,408(SP) + MOVQ R9,352(SP) MOVOA 48(SP),X0 MOVOA 0(SP),X1 MOVOA 16(SP),X2 @@ -867,7 +861,7 @@ TEXT ·salsa2020XORKeyStream(SB),0,$512-40 MOVL R8,44(DI) MOVL R9,28(DI) MOVL AX,12(DI) - MOVQ 408(SP),R9 + MOVQ 352(SP),R9 MOVL 16(SP),CX MOVL 36 (SP),R8 ADDQ $1,CX @@ -886,14 +880,7 @@ TEXT ·salsa2020XORKeyStream(SB),0,$512-40 REP; MOVSB BYTESATLEAST64: DONE: - MOVQ 352(SP),R11 - MOVQ 360(SP),R12 - MOVQ 368(SP),R13 - MOVQ 376(SP),R14 - MOVQ 384(SP),R15 - MOVQ 392(SP),BX - MOVQ 400(SP),BP - MOVQ R11,SP + MOVQ R12,SP RET BYTESATLEAST65: SUBQ $64,R9 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/terminal.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/terminal.go new file mode 100644 index 000000000..18379a935 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/terminal.go @@ -0,0 +1,951 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package terminal + +import ( + "bytes" + "io" + "sync" + "unicode/utf8" +) + +// EscapeCodes contains escape sequences that can be written to the terminal in +// order to achieve different styles of text. +type EscapeCodes struct { + // Foreground colors + Black, Red, Green, Yellow, Blue, Magenta, Cyan, White []byte + + // Reset all attributes + Reset []byte +} + +var vt100EscapeCodes = EscapeCodes{ + Black: []byte{keyEscape, '[', '3', '0', 'm'}, + Red: []byte{keyEscape, '[', '3', '1', 'm'}, + Green: []byte{keyEscape, '[', '3', '2', 'm'}, + Yellow: []byte{keyEscape, '[', '3', '3', 'm'}, + Blue: []byte{keyEscape, '[', '3', '4', 'm'}, + Magenta: []byte{keyEscape, '[', '3', '5', 'm'}, + Cyan: []byte{keyEscape, '[', '3', '6', 'm'}, + White: []byte{keyEscape, '[', '3', '7', 'm'}, + + Reset: []byte{keyEscape, '[', '0', 'm'}, +} + +// Terminal contains the state for running a VT100 terminal that is capable of +// reading lines of input. +type Terminal struct { + // AutoCompleteCallback, if non-null, is called for each keypress with + // the full input line and the current position of the cursor (in + // bytes, as an index into |line|). If it returns ok=false, the key + // press is processed normally. Otherwise it returns a replacement line + // and the new cursor position. + AutoCompleteCallback func(line string, pos int, key rune) (newLine string, newPos int, ok bool) + + // Escape contains a pointer to the escape codes for this terminal. + // It's always a valid pointer, although the escape codes themselves + // may be empty if the terminal doesn't support them. + Escape *EscapeCodes + + // lock protects the terminal and the state in this object from + // concurrent processing of a key press and a Write() call. + lock sync.Mutex + + c io.ReadWriter + prompt []rune + + // line is the current line being entered. + line []rune + // pos is the logical position of the cursor in line + pos int + // echo is true if local echo is enabled + echo bool + // pasteActive is true iff there is a bracketed paste operation in + // progress. + pasteActive bool + + // cursorX contains the current X value of the cursor where the left + // edge is 0. cursorY contains the row number where the first row of + // the current line is 0. + cursorX, cursorY int + // maxLine is the greatest value of cursorY so far. + maxLine int + + termWidth, termHeight int + + // outBuf contains the terminal data to be sent. + outBuf []byte + // remainder contains the remainder of any partial key sequences after + // a read. It aliases into inBuf. + remainder []byte + inBuf [256]byte + + // history contains previously entered commands so that they can be + // accessed with the up and down keys. + history stRingBuffer + // historyIndex stores the currently accessed history entry, where zero + // means the immediately previous entry. + historyIndex int + // When navigating up and down the history it's possible to return to + // the incomplete, initial line. That value is stored in + // historyPending. + historyPending string +} + +// NewTerminal runs a VT100 terminal on the given ReadWriter. If the ReadWriter is +// a local terminal, that terminal must first have been put into raw mode. +// prompt is a string that is written at the start of each input line (i.e. +// "> "). +func NewTerminal(c io.ReadWriter, prompt string) *Terminal { + return &Terminal{ + Escape: &vt100EscapeCodes, + c: c, + prompt: []rune(prompt), + termWidth: 80, + termHeight: 24, + echo: true, + historyIndex: -1, + } +} + +const ( + keyCtrlD = 4 + keyCtrlU = 21 + keyEnter = '\r' + keyEscape = 27 + keyBackspace = 127 + keyUnknown = 0xd800 /* UTF-16 surrogate area */ + iota + keyUp + keyDown + keyLeft + keyRight + keyAltLeft + keyAltRight + keyHome + keyEnd + keyDeleteWord + keyDeleteLine + keyClearScreen + keyPasteStart + keyPasteEnd +) + +var ( + crlf = []byte{'\r', '\n'} + pasteStart = []byte{keyEscape, '[', '2', '0', '0', '~'} + pasteEnd = []byte{keyEscape, '[', '2', '0', '1', '~'} +) + +// bytesToKey tries to parse a key sequence from b. If successful, it returns +// the key and the remainder of the input. Otherwise it returns utf8.RuneError. +func bytesToKey(b []byte, pasteActive bool) (rune, []byte) { + if len(b) == 0 { + return utf8.RuneError, nil + } + + if !pasteActive { + switch b[0] { + case 1: // ^A + return keyHome, b[1:] + case 5: // ^E + return keyEnd, b[1:] + case 8: // ^H + return keyBackspace, b[1:] + case 11: // ^K + return keyDeleteLine, b[1:] + case 12: // ^L + return keyClearScreen, b[1:] + case 23: // ^W + return keyDeleteWord, b[1:] + } + } + + if b[0] != keyEscape { + if !utf8.FullRune(b) { + return utf8.RuneError, b + } + r, l := utf8.DecodeRune(b) + return r, b[l:] + } + + if !pasteActive && len(b) >= 3 && b[0] == keyEscape && b[1] == '[' { + switch b[2] { + case 'A': + return keyUp, b[3:] + case 'B': + return keyDown, b[3:] + case 'C': + return keyRight, b[3:] + case 'D': + return keyLeft, b[3:] + case 'H': + return keyHome, b[3:] + case 'F': + return keyEnd, b[3:] + } + } + + if !pasteActive && len(b) >= 6 && b[0] == keyEscape && b[1] == '[' && b[2] == '1' && b[3] == ';' && b[4] == '3' { + switch b[5] { + case 'C': + return keyAltRight, b[6:] + case 'D': + return keyAltLeft, b[6:] + } + } + + if !pasteActive && len(b) >= 6 && bytes.Equal(b[:6], pasteStart) { + return keyPasteStart, b[6:] + } + + if pasteActive && len(b) >= 6 && bytes.Equal(b[:6], pasteEnd) { + return keyPasteEnd, b[6:] + } + + // If we get here then we have a key that we don't recognise, or a + // partial sequence. It's not clear how one should find the end of a + // sequence without knowing them all, but it seems that [a-zA-Z~] only + // appears at the end of a sequence. + for i, c := range b[0:] { + if c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '~' { + return keyUnknown, b[i+1:] + } + } + + return utf8.RuneError, b +} + +// queue appends data to the end of t.outBuf +func (t *Terminal) queue(data []rune) { + t.outBuf = append(t.outBuf, []byte(string(data))...) +} + +var eraseUnderCursor = []rune{' ', keyEscape, '[', 'D'} +var space = []rune{' '} + +func isPrintable(key rune) bool { + isInSurrogateArea := key >= 0xd800 && key <= 0xdbff + return key >= 32 && !isInSurrogateArea +} + +// moveCursorToPos appends data to t.outBuf which will move the cursor to the +// given, logical position in the text. +func (t *Terminal) moveCursorToPos(pos int) { + if !t.echo { + return + } + + x := visualLength(t.prompt) + pos + y := x / t.termWidth + x = x % t.termWidth + + up := 0 + if y < t.cursorY { + up = t.cursorY - y + } + + down := 0 + if y > t.cursorY { + down = y - t.cursorY + } + + left := 0 + if x < t.cursorX { + left = t.cursorX - x + } + + right := 0 + if x > t.cursorX { + right = x - t.cursorX + } + + t.cursorX = x + t.cursorY = y + t.move(up, down, left, right) +} + +func (t *Terminal) move(up, down, left, right int) { + movement := make([]rune, 3*(up+down+left+right)) + m := movement + for i := 0; i < up; i++ { + m[0] = keyEscape + m[1] = '[' + m[2] = 'A' + m = m[3:] + } + for i := 0; i < down; i++ { + m[0] = keyEscape + m[1] = '[' + m[2] = 'B' + m = m[3:] + } + for i := 0; i < left; i++ { + m[0] = keyEscape + m[1] = '[' + m[2] = 'D' + m = m[3:] + } + for i := 0; i < right; i++ { + m[0] = keyEscape + m[1] = '[' + m[2] = 'C' + m = m[3:] + } + + t.queue(movement) +} + +func (t *Terminal) clearLineToRight() { + op := []rune{keyEscape, '[', 'K'} + t.queue(op) +} + +const maxLineLength = 4096 + +func (t *Terminal) setLine(newLine []rune, newPos int) { + if t.echo { + t.moveCursorToPos(0) + t.writeLine(newLine) + for i := len(newLine); i < len(t.line); i++ { + t.writeLine(space) + } + t.moveCursorToPos(newPos) + } + t.line = newLine + t.pos = newPos +} + +func (t *Terminal) advanceCursor(places int) { + t.cursorX += places + t.cursorY += t.cursorX / t.termWidth + if t.cursorY > t.maxLine { + t.maxLine = t.cursorY + } + t.cursorX = t.cursorX % t.termWidth + + if places > 0 && t.cursorX == 0 { + // Normally terminals will advance the current position + // when writing a character. But that doesn't happen + // for the last character in a line. However, when + // writing a character (except a new line) that causes + // a line wrap, the position will be advanced two + // places. + // + // So, if we are stopping at the end of a line, we + // need to write a newline so that our cursor can be + // advanced to the next line. + t.outBuf = append(t.outBuf, '\r', '\n') + } +} + +func (t *Terminal) eraseNPreviousChars(n int) { + if n == 0 { + return + } + + if t.pos < n { + n = t.pos + } + t.pos -= n + t.moveCursorToPos(t.pos) + + copy(t.line[t.pos:], t.line[n+t.pos:]) + t.line = t.line[:len(t.line)-n] + if t.echo { + t.writeLine(t.line[t.pos:]) + for i := 0; i < n; i++ { + t.queue(space) + } + t.advanceCursor(n) + t.moveCursorToPos(t.pos) + } +} + +// countToLeftWord returns then number of characters from the cursor to the +// start of the previous word. +func (t *Terminal) countToLeftWord() int { + if t.pos == 0 { + return 0 + } + + pos := t.pos - 1 + for pos > 0 { + if t.line[pos] != ' ' { + break + } + pos-- + } + for pos > 0 { + if t.line[pos] == ' ' { + pos++ + break + } + pos-- + } + + return t.pos - pos +} + +// countToRightWord returns then number of characters from the cursor to the +// start of the next word. +func (t *Terminal) countToRightWord() int { + pos := t.pos + for pos < len(t.line) { + if t.line[pos] == ' ' { + break + } + pos++ + } + for pos < len(t.line) { + if t.line[pos] != ' ' { + break + } + pos++ + } + return pos - t.pos +} + +// visualLength returns the number of visible glyphs in s. +func visualLength(runes []rune) int { + inEscapeSeq := false + length := 0 + + for _, r := range runes { + switch { + case inEscapeSeq: + if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') { + inEscapeSeq = false + } + case r == '\x1b': + inEscapeSeq = true + default: + length++ + } + } + + return length +} + +// handleKey processes the given key and, optionally, returns a line of text +// that the user has entered. +func (t *Terminal) handleKey(key rune) (line string, ok bool) { + if t.pasteActive && key != keyEnter { + t.addKeyToLine(key) + return + } + + switch key { + case keyBackspace: + if t.pos == 0 { + return + } + t.eraseNPreviousChars(1) + case keyAltLeft: + // move left by a word. + t.pos -= t.countToLeftWord() + t.moveCursorToPos(t.pos) + case keyAltRight: + // move right by a word. + t.pos += t.countToRightWord() + t.moveCursorToPos(t.pos) + case keyLeft: + if t.pos == 0 { + return + } + t.pos-- + t.moveCursorToPos(t.pos) + case keyRight: + if t.pos == len(t.line) { + return + } + t.pos++ + t.moveCursorToPos(t.pos) + case keyHome: + if t.pos == 0 { + return + } + t.pos = 0 + t.moveCursorToPos(t.pos) + case keyEnd: + if t.pos == len(t.line) { + return + } + t.pos = len(t.line) + t.moveCursorToPos(t.pos) + case keyUp: + entry, ok := t.history.NthPreviousEntry(t.historyIndex + 1) + if !ok { + return "", false + } + if t.historyIndex == -1 { + t.historyPending = string(t.line) + } + t.historyIndex++ + runes := []rune(entry) + t.setLine(runes, len(runes)) + case keyDown: + switch t.historyIndex { + case -1: + return + case 0: + runes := []rune(t.historyPending) + t.setLine(runes, len(runes)) + t.historyIndex-- + default: + entry, ok := t.history.NthPreviousEntry(t.historyIndex - 1) + if ok { + t.historyIndex-- + runes := []rune(entry) + t.setLine(runes, len(runes)) + } + } + case keyEnter: + t.moveCursorToPos(len(t.line)) + t.queue([]rune("\r\n")) + line = string(t.line) + ok = true + t.line = t.line[:0] + t.pos = 0 + t.cursorX = 0 + t.cursorY = 0 + t.maxLine = 0 + case keyDeleteWord: + // Delete zero or more spaces and then one or more characters. + t.eraseNPreviousChars(t.countToLeftWord()) + case keyDeleteLine: + // Delete everything from the current cursor position to the + // end of line. + for i := t.pos; i < len(t.line); i++ { + t.queue(space) + t.advanceCursor(1) + } + t.line = t.line[:t.pos] + t.moveCursorToPos(t.pos) + case keyCtrlD: + // Erase the character under the current position. + // The EOF case when the line is empty is handled in + // readLine(). + if t.pos < len(t.line) { + t.pos++ + t.eraseNPreviousChars(1) + } + case keyCtrlU: + t.eraseNPreviousChars(t.pos) + case keyClearScreen: + // Erases the screen and moves the cursor to the home position. + t.queue([]rune("\x1b[2J\x1b[H")) + t.queue(t.prompt) + t.cursorX, t.cursorY = 0, 0 + t.advanceCursor(visualLength(t.prompt)) + t.setLine(t.line, t.pos) + default: + if t.AutoCompleteCallback != nil { + prefix := string(t.line[:t.pos]) + suffix := string(t.line[t.pos:]) + + t.lock.Unlock() + newLine, newPos, completeOk := t.AutoCompleteCallback(prefix+suffix, len(prefix), key) + t.lock.Lock() + + if completeOk { + t.setLine([]rune(newLine), utf8.RuneCount([]byte(newLine)[:newPos])) + return + } + } + if !isPrintable(key) { + return + } + if len(t.line) == maxLineLength { + return + } + t.addKeyToLine(key) + } + return +} + +// addKeyToLine inserts the given key at the current position in the current +// line. +func (t *Terminal) addKeyToLine(key rune) { + if len(t.line) == cap(t.line) { + newLine := make([]rune, len(t.line), 2*(1+len(t.line))) + copy(newLine, t.line) + t.line = newLine + } + t.line = t.line[:len(t.line)+1] + copy(t.line[t.pos+1:], t.line[t.pos:]) + t.line[t.pos] = key + if t.echo { + t.writeLine(t.line[t.pos:]) + } + t.pos++ + t.moveCursorToPos(t.pos) +} + +func (t *Terminal) writeLine(line []rune) { + for len(line) != 0 { + remainingOnLine := t.termWidth - t.cursorX + todo := len(line) + if todo > remainingOnLine { + todo = remainingOnLine + } + t.queue(line[:todo]) + t.advanceCursor(visualLength(line[:todo])) + line = line[todo:] + } +} + +// writeWithCRLF writes buf to w but replaces all occurrences of \n with \r\n. +func writeWithCRLF(w io.Writer, buf []byte) (n int, err error) { + for len(buf) > 0 { + i := bytes.IndexByte(buf, '\n') + todo := len(buf) + if i >= 0 { + todo = i + } + + var nn int + nn, err = w.Write(buf[:todo]) + n += nn + if err != nil { + return n, err + } + buf = buf[todo:] + + if i >= 0 { + if _, err = w.Write(crlf); err != nil { + return n, err + } + n += 1 + buf = buf[1:] + } + } + + return n, nil +} + +func (t *Terminal) Write(buf []byte) (n int, err error) { + t.lock.Lock() + defer t.lock.Unlock() + + if t.cursorX == 0 && t.cursorY == 0 { + // This is the easy case: there's nothing on the screen that we + // have to move out of the way. + return writeWithCRLF(t.c, buf) + } + + // We have a prompt and possibly user input on the screen. We + // have to clear it first. + t.move(0 /* up */, 0 /* down */, t.cursorX /* left */, 0 /* right */) + t.cursorX = 0 + t.clearLineToRight() + + for t.cursorY > 0 { + t.move(1 /* up */, 0, 0, 0) + t.cursorY-- + t.clearLineToRight() + } + + if _, err = t.c.Write(t.outBuf); err != nil { + return + } + t.outBuf = t.outBuf[:0] + + if n, err = writeWithCRLF(t.c, buf); err != nil { + return + } + + t.writeLine(t.prompt) + if t.echo { + t.writeLine(t.line) + } + + t.moveCursorToPos(t.pos) + + if _, err = t.c.Write(t.outBuf); err != nil { + return + } + t.outBuf = t.outBuf[:0] + return +} + +// ReadPassword temporarily changes the prompt and reads a password, without +// echo, from the terminal. +func (t *Terminal) ReadPassword(prompt string) (line string, err error) { + t.lock.Lock() + defer t.lock.Unlock() + + oldPrompt := t.prompt + t.prompt = []rune(prompt) + t.echo = false + + line, err = t.readLine() + + t.prompt = oldPrompt + t.echo = true + + return +} + +// ReadLine returns a line of input from the terminal. +func (t *Terminal) ReadLine() (line string, err error) { + t.lock.Lock() + defer t.lock.Unlock() + + return t.readLine() +} + +func (t *Terminal) readLine() (line string, err error) { + // t.lock must be held at this point + + if t.cursorX == 0 && t.cursorY == 0 { + t.writeLine(t.prompt) + t.c.Write(t.outBuf) + t.outBuf = t.outBuf[:0] + } + + lineIsPasted := t.pasteActive + + for { + rest := t.remainder + lineOk := false + for !lineOk { + var key rune + key, rest = bytesToKey(rest, t.pasteActive) + if key == utf8.RuneError { + break + } + if !t.pasteActive { + if key == keyCtrlD { + if len(t.line) == 0 { + return "", io.EOF + } + } + if key == keyPasteStart { + t.pasteActive = true + if len(t.line) == 0 { + lineIsPasted = true + } + continue + } + } else if key == keyPasteEnd { + t.pasteActive = false + continue + } + if !t.pasteActive { + lineIsPasted = false + } + line, lineOk = t.handleKey(key) + } + if len(rest) > 0 { + n := copy(t.inBuf[:], rest) + t.remainder = t.inBuf[:n] + } else { + t.remainder = nil + } + t.c.Write(t.outBuf) + t.outBuf = t.outBuf[:0] + if lineOk { + if t.echo { + t.historyIndex = -1 + t.history.Add(line) + } + if lineIsPasted { + err = ErrPasteIndicator + } + return + } + + // t.remainder is a slice at the beginning of t.inBuf + // containing a partial key sequence + readBuf := t.inBuf[len(t.remainder):] + var n int + + t.lock.Unlock() + n, err = t.c.Read(readBuf) + t.lock.Lock() + + if err != nil { + return + } + + t.remainder = t.inBuf[:n+len(t.remainder)] + } +} + +// SetPrompt sets the prompt to be used when reading subsequent lines. +func (t *Terminal) SetPrompt(prompt string) { + t.lock.Lock() + defer t.lock.Unlock() + + t.prompt = []rune(prompt) +} + +func (t *Terminal) clearAndRepaintLinePlusNPrevious(numPrevLines int) { + // Move cursor to column zero at the start of the line. + t.move(t.cursorY, 0, t.cursorX, 0) + t.cursorX, t.cursorY = 0, 0 + t.clearLineToRight() + for t.cursorY < numPrevLines { + // Move down a line + t.move(0, 1, 0, 0) + t.cursorY++ + t.clearLineToRight() + } + // Move back to beginning. + t.move(t.cursorY, 0, 0, 0) + t.cursorX, t.cursorY = 0, 0 + + t.queue(t.prompt) + t.advanceCursor(visualLength(t.prompt)) + t.writeLine(t.line) + t.moveCursorToPos(t.pos) +} + +func (t *Terminal) SetSize(width, height int) error { + t.lock.Lock() + defer t.lock.Unlock() + + if width == 0 { + width = 1 + } + + oldWidth := t.termWidth + t.termWidth, t.termHeight = width, height + + switch { + case width == oldWidth: + // If the width didn't change then nothing else needs to be + // done. + return nil + case len(t.line) == 0 && t.cursorX == 0 && t.cursorY == 0: + // If there is nothing on current line and no prompt printed, + // just do nothing + return nil + case width < oldWidth: + // Some terminals (e.g. xterm) will truncate lines that were + // too long when shinking. Others, (e.g. gnome-terminal) will + // attempt to wrap them. For the former, repainting t.maxLine + // works great, but that behaviour goes badly wrong in the case + // of the latter because they have doubled every full line. + + // We assume that we are working on a terminal that wraps lines + // and adjust the cursor position based on every previous line + // wrapping and turning into two. This causes the prompt on + // xterms to move upwards, which isn't great, but it avoids a + // huge mess with gnome-terminal. + if t.cursorX >= t.termWidth { + t.cursorX = t.termWidth - 1 + } + t.cursorY *= 2 + t.clearAndRepaintLinePlusNPrevious(t.maxLine * 2) + case width > oldWidth: + // If the terminal expands then our position calculations will + // be wrong in the future because we think the cursor is + // |t.pos| chars into the string, but there will be a gap at + // the end of any wrapped line. + // + // But the position will actually be correct until we move, so + // we can move back to the beginning and repaint everything. + t.clearAndRepaintLinePlusNPrevious(t.maxLine) + } + + _, err := t.c.Write(t.outBuf) + t.outBuf = t.outBuf[:0] + return err +} + +type pasteIndicatorError struct{} + +func (pasteIndicatorError) Error() string { + return "terminal: ErrPasteIndicator not correctly handled" +} + +// ErrPasteIndicator may be returned from ReadLine as the error, in addition +// to valid line data. It indicates that bracketed paste mode is enabled and +// that the returned line consists only of pasted data. Programs may wish to +// interpret pasted data more literally than typed data. +var ErrPasteIndicator = pasteIndicatorError{} + +// SetBracketedPasteMode requests that the terminal bracket paste operations +// with markers. Not all terminals support this but, if it is supported, then +// enabling this mode will stop any autocomplete callback from running due to +// pastes. Additionally, any lines that are completely pasted will be returned +// from ReadLine with the error set to ErrPasteIndicator. +func (t *Terminal) SetBracketedPasteMode(on bool) { + if on { + io.WriteString(t.c, "\x1b[?2004h") + } else { + io.WriteString(t.c, "\x1b[?2004l") + } +} + +// stRingBuffer is a ring buffer of strings. +type stRingBuffer struct { + // entries contains max elements. + entries []string + max int + // head contains the index of the element most recently added to the ring. + head int + // size contains the number of elements in the ring. + size int +} + +func (s *stRingBuffer) Add(a string) { + if s.entries == nil { + const defaultNumEntries = 100 + s.entries = make([]string, defaultNumEntries) + s.max = defaultNumEntries + } + + s.head = (s.head + 1) % s.max + s.entries[s.head] = a + if s.size < s.max { + s.size++ + } +} + +// NthPreviousEntry returns the value passed to the nth previous call to Add. +// If n is zero then the immediately prior value is returned, if one, then the +// next most recent, and so on. If such an element doesn't exist then ok is +// false. +func (s *stRingBuffer) NthPreviousEntry(n int) (value string, ok bool) { + if n >= s.size { + return "", false + } + index := s.head - n + if index < 0 { + index += s.max + } + return s.entries[index], true +} + +// readPasswordLine reads from reader until it finds \n or io.EOF. +// The slice returned does not include the \n. +// readPasswordLine also ignores any \r it finds. +func readPasswordLine(reader io.Reader) ([]byte, error) { + var buf [1]byte + var ret []byte + + for { + n, err := reader.Read(buf[:]) + if n > 0 { + switch buf[0] { + case '\n': + return ret, nil + case '\r': + // remove \r from passwords on Windows + default: + ret = append(ret, buf[0]) + } + continue + } + if err != nil { + if err == io.EOF && len(ret) > 0 { + return ret, nil + } + return ret, err + } + } +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util.go new file mode 100644 index 000000000..d01919614 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util.go @@ -0,0 +1,119 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin dragonfly freebsd linux,!appengine netbsd openbsd + +// Package terminal provides support functions for dealing with terminals, as +// commonly found on UNIX systems. +// +// Putting a terminal into raw mode is the most common requirement: +// +// oldState, err := terminal.MakeRaw(0) +// if err != nil { +// panic(err) +// } +// defer terminal.Restore(0, oldState) +package terminal // import "golang.org/x/crypto/ssh/terminal" + +import ( + "syscall" + "unsafe" +) + +// State contains the state of a terminal. +type State struct { + termios syscall.Termios +} + +// IsTerminal returns true if the given file descriptor is a terminal. +func IsTerminal(fd int) bool { + var termios syscall.Termios + _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) + return err == 0 +} + +// MakeRaw put the terminal connected to the given file descriptor into raw +// mode and returns the previous state of the terminal so that it can be +// restored. +func MakeRaw(fd int) (*State, error) { + var oldState State + if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 { + return nil, err + } + + newState := oldState.termios + // This attempts to replicate the behaviour documented for cfmakeraw in + // the termios(3) manpage. + newState.Iflag &^= syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON + newState.Oflag &^= syscall.OPOST + newState.Lflag &^= syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN + newState.Cflag &^= syscall.CSIZE | syscall.PARENB + newState.Cflag |= syscall.CS8 + if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 { + return nil, err + } + + return &oldState, nil +} + +// GetState returns the current state of a terminal which may be useful to +// restore the terminal after a signal. +func GetState(fd int) (*State, error) { + var oldState State + if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 { + return nil, err + } + + return &oldState, nil +} + +// Restore restores the terminal connected to the given file descriptor to a +// previous state. +func Restore(fd int, state *State) error { + if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&state.termios)), 0, 0, 0); err != 0 { + return err + } + return nil +} + +// GetSize returns the dimensions of the given terminal. +func GetSize(fd int) (width, height int, err error) { + var dimensions [4]uint16 + + if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&dimensions)), 0, 0, 0); err != 0 { + return -1, -1, err + } + return int(dimensions[1]), int(dimensions[0]), nil +} + +// passwordReader is an io.Reader that reads from a specific file descriptor. +type passwordReader int + +func (r passwordReader) Read(buf []byte) (int, error) { + return syscall.Read(int(r), buf) +} + +// ReadPassword reads a line of input from a terminal without local echo. This +// is commonly used for inputting passwords and other sensitive data. The slice +// returned does not include the \n. +func ReadPassword(fd int) ([]byte, error) { + var oldState syscall.Termios + if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0); err != 0 { + return nil, err + } + + newState := oldState + newState.Lflag &^= syscall.ECHO + newState.Lflag |= syscall.ICANON | syscall.ISIG + newState.Iflag |= syscall.ICRNL + if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 { + return nil, err + } + + defer func() { + syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0) + }() + + return readPasswordLine(passwordReader(fd)) +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go new file mode 100644 index 000000000..cb23a5904 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go @@ -0,0 +1,12 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin dragonfly freebsd netbsd openbsd + +package terminal + +import "golang.org/x/sys/unix" + +const ioctlReadTermios = unix.TIOCGETA +const ioctlWriteTermios = unix.TIOCSETA diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_linux.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_linux.go new file mode 100644 index 000000000..5fadfe8a1 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_linux.go @@ -0,0 +1,10 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package terminal + +import "golang.org/x/sys/unix" + +const ioctlReadTermios = unix.TCGETS +const ioctlWriteTermios = unix.TCSETS diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_plan9.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_plan9.go new file mode 100644 index 000000000..799f049f0 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_plan9.go @@ -0,0 +1,58 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package terminal provides support functions for dealing with terminals, as +// commonly found on UNIX systems. +// +// Putting a terminal into raw mode is the most common requirement: +// +// oldState, err := terminal.MakeRaw(0) +// if err != nil { +// panic(err) +// } +// defer terminal.Restore(0, oldState) +package terminal + +import ( + "fmt" + "runtime" +) + +type State struct{} + +// IsTerminal returns true if the given file descriptor is a terminal. +func IsTerminal(fd int) bool { + return false +} + +// MakeRaw put the terminal connected to the given file descriptor into raw +// mode and returns the previous state of the terminal so that it can be +// restored. +func MakeRaw(fd int) (*State, error) { + return nil, fmt.Errorf("terminal: MakeRaw not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) +} + +// GetState returns the current state of a terminal which may be useful to +// restore the terminal after a signal. +func GetState(fd int) (*State, error) { + return nil, fmt.Errorf("terminal: GetState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) +} + +// Restore restores the terminal connected to the given file descriptor to a +// previous state. +func Restore(fd int, state *State) error { + return fmt.Errorf("terminal: Restore not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) +} + +// GetSize returns the dimensions of the given terminal. +func GetSize(fd int) (width, height int, err error) { + return 0, 0, fmt.Errorf("terminal: GetSize not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) +} + +// ReadPassword reads a line of input from a terminal without local echo. This +// is commonly used for inputting passwords and other sensitive data. The slice +// returned does not include the \n. +func ReadPassword(fd int) ([]byte, error) { + return nil, fmt.Errorf("terminal: ReadPassword not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) +} diff --git a/vendor/golang.org/x/crypto/ssh/terminal/util_solaris.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_solaris.go similarity index 100% rename from vendor/golang.org/x/crypto/ssh/terminal/util_solaris.go rename to vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_solaris.go diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go new file mode 100644 index 000000000..e0a1f36ce --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go @@ -0,0 +1,155 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +// Package terminal provides support functions for dealing with terminals, as +// commonly found on UNIX systems. +// +// Putting a terminal into raw mode is the most common requirement: +// +// oldState, err := terminal.MakeRaw(0) +// if err != nil { +// panic(err) +// } +// defer terminal.Restore(0, oldState) +package terminal + +import ( + "syscall" + "unsafe" +) + +const ( + enableLineInput = 2 + enableEchoInput = 4 + enableProcessedInput = 1 + enableWindowInput = 8 + enableMouseInput = 16 + enableInsertMode = 32 + enableQuickEditMode = 64 + enableExtendedFlags = 128 + enableAutoPosition = 256 + enableProcessedOutput = 1 + enableWrapAtEolOutput = 2 +) + +var kernel32 = syscall.NewLazyDLL("kernel32.dll") + +var ( + procGetConsoleMode = kernel32.NewProc("GetConsoleMode") + procSetConsoleMode = kernel32.NewProc("SetConsoleMode") + procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") +) + +type ( + short int16 + word uint16 + + coord struct { + x short + y short + } + smallRect struct { + left short + top short + right short + bottom short + } + consoleScreenBufferInfo struct { + size coord + cursorPosition coord + attributes word + window smallRect + maximumWindowSize coord + } +) + +type State struct { + mode uint32 +} + +// IsTerminal returns true if the given file descriptor is a terminal. +func IsTerminal(fd int) bool { + var st uint32 + r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) + return r != 0 && e == 0 +} + +// MakeRaw put the terminal connected to the given file descriptor into raw +// mode and returns the previous state of the terminal so that it can be +// restored. +func MakeRaw(fd int) (*State, error) { + var st uint32 + _, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) + if e != 0 { + return nil, error(e) + } + raw := st &^ (enableEchoInput | enableProcessedInput | enableLineInput | enableProcessedOutput) + _, _, e = syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(raw), 0) + if e != 0 { + return nil, error(e) + } + return &State{st}, nil +} + +// GetState returns the current state of a terminal which may be useful to +// restore the terminal after a signal. +func GetState(fd int) (*State, error) { + var st uint32 + _, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) + if e != 0 { + return nil, error(e) + } + return &State{st}, nil +} + +// Restore restores the terminal connected to the given file descriptor to a +// previous state. +func Restore(fd int, state *State) error { + _, _, err := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(state.mode), 0) + return err +} + +// GetSize returns the dimensions of the given terminal. +func GetSize(fd int) (width, height int, err error) { + var info consoleScreenBufferInfo + _, _, e := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&info)), 0) + if e != 0 { + return 0, 0, error(e) + } + return int(info.size.x), int(info.size.y), nil +} + +// passwordReader is an io.Reader that reads from a specific Windows HANDLE. +type passwordReader int + +func (r passwordReader) Read(buf []byte) (int, error) { + return syscall.Read(syscall.Handle(r), buf) +} + +// ReadPassword reads a line of input from a terminal without local echo. This +// is commonly used for inputting passwords and other sensitive data. The slice +// returned does not include the \n. +func ReadPassword(fd int) ([]byte, error) { + var st uint32 + _, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) + if e != 0 { + return nil, error(e) + } + old := st + + st &^= (enableEchoInput) + st |= (enableProcessedInput | enableLineInput | enableProcessedOutput) + _, _, e = syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(st), 0) + if e != 0 { + return nil, error(e) + } + + defer func() { + syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(old), 0) + }() + + return readPasswordLine(passwordReader(fd)) +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/asm_openbsd_arm.s b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/asm_openbsd_arm.s new file mode 100644 index 000000000..469bfa100 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/asm_openbsd_arm.s @@ -0,0 +1,29 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !gccgo + +#include "textflag.h" + +// +// System call support for ARM, OpenBSD +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-28 + B syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-40 + B syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-52 + B syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-28 + B syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 + B syscall·RawSyscall6(SB) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/cap_freebsd.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/cap_freebsd.go new file mode 100644 index 000000000..83b6bceab --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/cap_freebsd.go @@ -0,0 +1,195 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build freebsd + +package unix + +import ( + errorspkg "errors" + "fmt" +) + +// Go implementation of C mostly found in /usr/src/sys/kern/subr_capability.c + +const ( + // This is the version of CapRights this package understands. See C implementation for parallels. + capRightsGoVersion = CAP_RIGHTS_VERSION_00 + capArSizeMin = CAP_RIGHTS_VERSION_00 + 2 + capArSizeMax = capRightsGoVersion + 2 +) + +var ( + bit2idx = []int{ + -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, + 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + } +) + +func capidxbit(right uint64) int { + return int((right >> 57) & 0x1f) +} + +func rightToIndex(right uint64) (int, error) { + idx := capidxbit(right) + if idx < 0 || idx >= len(bit2idx) { + return -2, fmt.Errorf("index for right 0x%x out of range", right) + } + return bit2idx[idx], nil +} + +func caprver(right uint64) int { + return int(right >> 62) +} + +func capver(rights *CapRights) int { + return caprver(rights.Rights[0]) +} + +func caparsize(rights *CapRights) int { + return capver(rights) + 2 +} + +// CapRightsSet sets the permissions in setrights in rights. +func CapRightsSet(rights *CapRights, setrights []uint64) error { + // This is essentially a copy of cap_rights_vset() + if capver(rights) != CAP_RIGHTS_VERSION_00 { + return fmt.Errorf("bad rights version %d", capver(rights)) + } + + n := caparsize(rights) + if n < capArSizeMin || n > capArSizeMax { + return errorspkg.New("bad rights size") + } + + for _, right := range setrights { + if caprver(right) != CAP_RIGHTS_VERSION_00 { + return errorspkg.New("bad right version") + } + i, err := rightToIndex(right) + if err != nil { + return err + } + if i >= n { + return errorspkg.New("index overflow") + } + if capidxbit(rights.Rights[i]) != capidxbit(right) { + return errorspkg.New("index mismatch") + } + rights.Rights[i] |= right + if capidxbit(rights.Rights[i]) != capidxbit(right) { + return errorspkg.New("index mismatch (after assign)") + } + } + + return nil +} + +// CapRightsClear clears the permissions in clearrights from rights. +func CapRightsClear(rights *CapRights, clearrights []uint64) error { + // This is essentially a copy of cap_rights_vclear() + if capver(rights) != CAP_RIGHTS_VERSION_00 { + return fmt.Errorf("bad rights version %d", capver(rights)) + } + + n := caparsize(rights) + if n < capArSizeMin || n > capArSizeMax { + return errorspkg.New("bad rights size") + } + + for _, right := range clearrights { + if caprver(right) != CAP_RIGHTS_VERSION_00 { + return errorspkg.New("bad right version") + } + i, err := rightToIndex(right) + if err != nil { + return err + } + if i >= n { + return errorspkg.New("index overflow") + } + if capidxbit(rights.Rights[i]) != capidxbit(right) { + return errorspkg.New("index mismatch") + } + rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF) + if capidxbit(rights.Rights[i]) != capidxbit(right) { + return errorspkg.New("index mismatch (after assign)") + } + } + + return nil +} + +// CapRightsIsSet checks whether all the permissions in setrights are present in rights. +func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) { + // This is essentially a copy of cap_rights_is_vset() + if capver(rights) != CAP_RIGHTS_VERSION_00 { + return false, fmt.Errorf("bad rights version %d", capver(rights)) + } + + n := caparsize(rights) + if n < capArSizeMin || n > capArSizeMax { + return false, errorspkg.New("bad rights size") + } + + for _, right := range setrights { + if caprver(right) != CAP_RIGHTS_VERSION_00 { + return false, errorspkg.New("bad right version") + } + i, err := rightToIndex(right) + if err != nil { + return false, err + } + if i >= n { + return false, errorspkg.New("index overflow") + } + if capidxbit(rights.Rights[i]) != capidxbit(right) { + return false, errorspkg.New("index mismatch") + } + if (rights.Rights[i] & right) != right { + return false, nil + } + } + + return true, nil +} + +func capright(idx uint64, bit uint64) uint64 { + return ((1 << (57 + idx)) | bit) +} + +// CapRightsInit returns a pointer to an initialised CapRights structure filled with rights. +// See man cap_rights_init(3) and rights(4). +func CapRightsInit(rights []uint64) (*CapRights, error) { + var r CapRights + r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0) + r.Rights[1] = capright(1, 0) + + err := CapRightsSet(&r, rights) + if err != nil { + return nil, err + } + return &r, nil +} + +// CapRightsLimit reduces the operations permitted on fd to at most those contained in rights. +// The capability rights on fd can never be increased by CapRightsLimit. +// See man cap_rights_limit(2) and rights(4). +func CapRightsLimit(fd uintptr, rights *CapRights) error { + return capRightsLimit(int(fd), rights) +} + +// CapRightsGet returns a CapRights structure containing the operations permitted on fd. +// See man cap_rights_get(3) and rights(4). +func CapRightsGet(fd uintptr) (*CapRights, error) { + r, err := CapRightsInit(nil) + if err != nil { + return nil, err + } + err = capRightsGet(capRightsGoVersion, int(fd), r) + if err != nil { + return nil, err + } + return r, nil +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/dev_linux.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/dev_linux.go new file mode 100644 index 000000000..c902c39e8 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/dev_linux.go @@ -0,0 +1,42 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Functions to access/create device major and minor numbers matching the +// encoding used by the Linux kernel and glibc. +// +// The information below is extracted and adapted from bits/sysmacros.h in the +// glibc sources: +// +// dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's +// default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major +// number and m is a hex digit of the minor number. This is backward compatible +// with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also +// backward compatible with the Linux kernel, which for some architectures uses +// 32-bit dev_t, encoded as mmmM MMmm. + +package unix + +// Major returns the major component of a Linux device number. +func Major(dev uint64) uint32 { + major := uint32((dev & 0x00000000000fff00) >> 8) + major |= uint32((dev & 0xfffff00000000000) >> 32) + return major +} + +// Minor returns the minor component of a Linux device number. +func Minor(dev uint64) uint32 { + minor := uint32((dev & 0x00000000000000ff) >> 0) + minor |= uint32((dev & 0x00000ffffff00000) >> 12) + return minor +} + +// Mkdev returns a Linux device number generated from the given major and minor +// components. +func Mkdev(major, minor uint32) uint64 { + dev := uint64((major & 0x00000fff) << 8) + dev |= uint64((major & 0xfffff000) << 32) + dev |= uint64((minor & 0x000000ff) << 0) + dev |= uint64((minor & 0xffffff00) << 12) + return dev +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/errors_freebsd_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/errors_freebsd_386.go new file mode 100644 index 000000000..c56bc8b05 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/errors_freebsd_386.go @@ -0,0 +1,227 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep +// them here for backwards compatibility. + +package unix + +const ( + IFF_SMART = 0x20 + IFT_1822 = 0x2 + IFT_A12MPPSWITCH = 0x82 + IFT_AAL2 = 0xbb + IFT_AAL5 = 0x31 + IFT_ADSL = 0x5e + IFT_AFLANE8023 = 0x3b + IFT_AFLANE8025 = 0x3c + IFT_ARAP = 0x58 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ASYNC = 0x54 + IFT_ATM = 0x25 + IFT_ATMDXI = 0x69 + IFT_ATMFUNI = 0x6a + IFT_ATMIMA = 0x6b + IFT_ATMLOGICAL = 0x50 + IFT_ATMRADIO = 0xbd + IFT_ATMSUBINTERFACE = 0x86 + IFT_ATMVCIENDPT = 0xc2 + IFT_ATMVIRTUAL = 0x95 + IFT_BGPPOLICYACCOUNTING = 0xa2 + IFT_BSC = 0x53 + IFT_CCTEMUL = 0x3d + IFT_CEPT = 0x13 + IFT_CES = 0x85 + IFT_CHANNEL = 0x46 + IFT_CNR = 0x55 + IFT_COFFEE = 0x84 + IFT_COMPOSITELINK = 0x9b + IFT_DCN = 0x8d + IFT_DIGITALPOWERLINE = 0x8a + IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba + IFT_DLSW = 0x4a + IFT_DOCSCABLEDOWNSTREAM = 0x80 + IFT_DOCSCABLEMACLAYER = 0x7f + IFT_DOCSCABLEUPSTREAM = 0x81 + IFT_DS0 = 0x51 + IFT_DS0BUNDLE = 0x52 + IFT_DS1FDL = 0xaa + IFT_DS3 = 0x1e + IFT_DTM = 0x8c + IFT_DVBASILN = 0xac + IFT_DVBASIOUT = 0xad + IFT_DVBRCCDOWNSTREAM = 0x93 + IFT_DVBRCCMACLAYER = 0x92 + IFT_DVBRCCUPSTREAM = 0x94 + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_EPLRS = 0x57 + IFT_ESCON = 0x49 + IFT_ETHER = 0x6 + IFT_FAITH = 0xf2 + IFT_FAST = 0x7d + IFT_FASTETHER = 0x3e + IFT_FASTETHERFX = 0x45 + IFT_FDDI = 0xf + IFT_FIBRECHANNEL = 0x38 + IFT_FRAMERELAYINTERCONNECT = 0x3a + IFT_FRAMERELAYMPI = 0x5c + IFT_FRDLCIENDPT = 0xc1 + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_FRF16MFRBUNDLE = 0xa3 + IFT_FRFORWARD = 0x9e + IFT_G703AT2MB = 0x43 + IFT_G703AT64K = 0x42 + IFT_GIF = 0xf0 + IFT_GIGABITETHERNET = 0x75 + IFT_GR303IDT = 0xb2 + IFT_GR303RDT = 0xb1 + IFT_H323GATEKEEPER = 0xa4 + IFT_H323PROXY = 0xa5 + IFT_HDH1822 = 0x3 + IFT_HDLC = 0x76 + IFT_HDSL2 = 0xa8 + IFT_HIPERLAN2 = 0xb7 + IFT_HIPPI = 0x2f + IFT_HIPPIINTERFACE = 0x39 + IFT_HOSTPAD = 0x5a + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IBM370PARCHAN = 0x48 + IFT_IDSL = 0x9a + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INTERLEAVE = 0x7c + IFT_IP = 0x7e + IFT_IPFORWARD = 0x8e + IFT_IPOVERATM = 0x72 + IFT_IPOVERCDLC = 0x6d + IFT_IPOVERCLAW = 0x6e + IFT_IPSWITCH = 0x4e + IFT_IPXIP = 0xf9 + IFT_ISDN = 0x3f + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISDNS = 0x4b + IFT_ISDNU = 0x4c + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88025CRFPINT = 0x62 + IFT_ISO88025DTR = 0x56 + IFT_ISO88025FIBER = 0x73 + IFT_ISO88026 = 0xa + IFT_ISUP = 0xb3 + IFT_L3IPXVLAN = 0x89 + IFT_LAPB = 0x10 + IFT_LAPD = 0x4d + IFT_LAPF = 0x77 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MEDIAMAILOVERIP = 0x8b + IFT_MFSIGLINK = 0xa7 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_MPC = 0x71 + IFT_MPLS = 0xa6 + IFT_MPLSTUNNEL = 0x96 + IFT_MSDSL = 0x8f + IFT_MVL = 0xbf + IFT_MYRINET = 0x63 + IFT_NFAS = 0xaf + IFT_NSIP = 0x1b + IFT_OPTICALCHANNEL = 0xc3 + IFT_OPTICALTRANSPORT = 0xc4 + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PFLOG = 0xf6 + IFT_PFSYNC = 0xf7 + IFT_PLC = 0xae + IFT_POS = 0xab + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPWIRELESSP2P = 0x9d + IFT_PTPSERIAL = 0x16 + IFT_PVC = 0xf1 + IFT_QLLC = 0x44 + IFT_RADIOMAC = 0xbc + IFT_RADSL = 0x5f + IFT_REACHDSL = 0xc0 + IFT_RFC1483 = 0x9f + IFT_RS232 = 0x21 + IFT_RSRB = 0x4f + IFT_SDLC = 0x11 + IFT_SDSL = 0x60 + IFT_SHDSL = 0xa9 + IFT_SIP = 0x1f + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETOVERHEADCHANNEL = 0xb9 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_SRP = 0x97 + IFT_SS7SIGLINK = 0x9c + IFT_STACKTOSTACK = 0x6f + IFT_STARLAN = 0xb + IFT_STF = 0xd7 + IFT_T1 = 0x12 + IFT_TDLC = 0x74 + IFT_TERMPAD = 0x5b + IFT_TR008 = 0xb0 + IFT_TRANSPHDLC = 0x7b + IFT_TUNNEL = 0x83 + IFT_ULTRA = 0x1d + IFT_USB = 0xa0 + IFT_V11 = 0x40 + IFT_V35 = 0x2d + IFT_V36 = 0x41 + IFT_V37 = 0x78 + IFT_VDSL = 0x61 + IFT_VIRTUALIPADDRESS = 0x70 + IFT_VOICEEM = 0x64 + IFT_VOICEENCAP = 0x67 + IFT_VOICEFXO = 0x65 + IFT_VOICEFXS = 0x66 + IFT_VOICEOVERATM = 0x98 + IFT_VOICEOVERFRAMERELAY = 0x99 + IFT_VOICEOVERIP = 0x68 + IFT_X213 = 0x5d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25HUNTGROUP = 0x7a + IFT_X25MLP = 0x79 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + IPPROTO_MAXID = 0x34 + IPV6_FAITH = 0x1d + IP_FAITH = 0x16 + MAP_NORESERVE = 0x40 + MAP_RENAME = 0x20 + NET_RT_MAXID = 0x6 + RTF_PRCLONING = 0x10000 + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + SIOCADDRT = 0x8030720a + SIOCALIFADDR = 0x8118691b + SIOCDELRT = 0x8030720b + SIOCDLIFADDR = 0x8118691d + SIOCGLIFADDR = 0xc118691c + SIOCGLIFPHYADDR = 0xc118694b + SIOCSLIFPHYADDR = 0x8118694a +) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go new file mode 100644 index 000000000..3e9771175 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go @@ -0,0 +1,227 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep +// them here for backwards compatibility. + +package unix + +const ( + IFF_SMART = 0x20 + IFT_1822 = 0x2 + IFT_A12MPPSWITCH = 0x82 + IFT_AAL2 = 0xbb + IFT_AAL5 = 0x31 + IFT_ADSL = 0x5e + IFT_AFLANE8023 = 0x3b + IFT_AFLANE8025 = 0x3c + IFT_ARAP = 0x58 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ASYNC = 0x54 + IFT_ATM = 0x25 + IFT_ATMDXI = 0x69 + IFT_ATMFUNI = 0x6a + IFT_ATMIMA = 0x6b + IFT_ATMLOGICAL = 0x50 + IFT_ATMRADIO = 0xbd + IFT_ATMSUBINTERFACE = 0x86 + IFT_ATMVCIENDPT = 0xc2 + IFT_ATMVIRTUAL = 0x95 + IFT_BGPPOLICYACCOUNTING = 0xa2 + IFT_BSC = 0x53 + IFT_CCTEMUL = 0x3d + IFT_CEPT = 0x13 + IFT_CES = 0x85 + IFT_CHANNEL = 0x46 + IFT_CNR = 0x55 + IFT_COFFEE = 0x84 + IFT_COMPOSITELINK = 0x9b + IFT_DCN = 0x8d + IFT_DIGITALPOWERLINE = 0x8a + IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba + IFT_DLSW = 0x4a + IFT_DOCSCABLEDOWNSTREAM = 0x80 + IFT_DOCSCABLEMACLAYER = 0x7f + IFT_DOCSCABLEUPSTREAM = 0x81 + IFT_DS0 = 0x51 + IFT_DS0BUNDLE = 0x52 + IFT_DS1FDL = 0xaa + IFT_DS3 = 0x1e + IFT_DTM = 0x8c + IFT_DVBASILN = 0xac + IFT_DVBASIOUT = 0xad + IFT_DVBRCCDOWNSTREAM = 0x93 + IFT_DVBRCCMACLAYER = 0x92 + IFT_DVBRCCUPSTREAM = 0x94 + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_EPLRS = 0x57 + IFT_ESCON = 0x49 + IFT_ETHER = 0x6 + IFT_FAITH = 0xf2 + IFT_FAST = 0x7d + IFT_FASTETHER = 0x3e + IFT_FASTETHERFX = 0x45 + IFT_FDDI = 0xf + IFT_FIBRECHANNEL = 0x38 + IFT_FRAMERELAYINTERCONNECT = 0x3a + IFT_FRAMERELAYMPI = 0x5c + IFT_FRDLCIENDPT = 0xc1 + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_FRF16MFRBUNDLE = 0xa3 + IFT_FRFORWARD = 0x9e + IFT_G703AT2MB = 0x43 + IFT_G703AT64K = 0x42 + IFT_GIF = 0xf0 + IFT_GIGABITETHERNET = 0x75 + IFT_GR303IDT = 0xb2 + IFT_GR303RDT = 0xb1 + IFT_H323GATEKEEPER = 0xa4 + IFT_H323PROXY = 0xa5 + IFT_HDH1822 = 0x3 + IFT_HDLC = 0x76 + IFT_HDSL2 = 0xa8 + IFT_HIPERLAN2 = 0xb7 + IFT_HIPPI = 0x2f + IFT_HIPPIINTERFACE = 0x39 + IFT_HOSTPAD = 0x5a + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IBM370PARCHAN = 0x48 + IFT_IDSL = 0x9a + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INTERLEAVE = 0x7c + IFT_IP = 0x7e + IFT_IPFORWARD = 0x8e + IFT_IPOVERATM = 0x72 + IFT_IPOVERCDLC = 0x6d + IFT_IPOVERCLAW = 0x6e + IFT_IPSWITCH = 0x4e + IFT_IPXIP = 0xf9 + IFT_ISDN = 0x3f + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISDNS = 0x4b + IFT_ISDNU = 0x4c + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88025CRFPINT = 0x62 + IFT_ISO88025DTR = 0x56 + IFT_ISO88025FIBER = 0x73 + IFT_ISO88026 = 0xa + IFT_ISUP = 0xb3 + IFT_L3IPXVLAN = 0x89 + IFT_LAPB = 0x10 + IFT_LAPD = 0x4d + IFT_LAPF = 0x77 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MEDIAMAILOVERIP = 0x8b + IFT_MFSIGLINK = 0xa7 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_MPC = 0x71 + IFT_MPLS = 0xa6 + IFT_MPLSTUNNEL = 0x96 + IFT_MSDSL = 0x8f + IFT_MVL = 0xbf + IFT_MYRINET = 0x63 + IFT_NFAS = 0xaf + IFT_NSIP = 0x1b + IFT_OPTICALCHANNEL = 0xc3 + IFT_OPTICALTRANSPORT = 0xc4 + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PFLOG = 0xf6 + IFT_PFSYNC = 0xf7 + IFT_PLC = 0xae + IFT_POS = 0xab + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPWIRELESSP2P = 0x9d + IFT_PTPSERIAL = 0x16 + IFT_PVC = 0xf1 + IFT_QLLC = 0x44 + IFT_RADIOMAC = 0xbc + IFT_RADSL = 0x5f + IFT_REACHDSL = 0xc0 + IFT_RFC1483 = 0x9f + IFT_RS232 = 0x21 + IFT_RSRB = 0x4f + IFT_SDLC = 0x11 + IFT_SDSL = 0x60 + IFT_SHDSL = 0xa9 + IFT_SIP = 0x1f + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETOVERHEADCHANNEL = 0xb9 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_SRP = 0x97 + IFT_SS7SIGLINK = 0x9c + IFT_STACKTOSTACK = 0x6f + IFT_STARLAN = 0xb + IFT_STF = 0xd7 + IFT_T1 = 0x12 + IFT_TDLC = 0x74 + IFT_TERMPAD = 0x5b + IFT_TR008 = 0xb0 + IFT_TRANSPHDLC = 0x7b + IFT_TUNNEL = 0x83 + IFT_ULTRA = 0x1d + IFT_USB = 0xa0 + IFT_V11 = 0x40 + IFT_V35 = 0x2d + IFT_V36 = 0x41 + IFT_V37 = 0x78 + IFT_VDSL = 0x61 + IFT_VIRTUALIPADDRESS = 0x70 + IFT_VOICEEM = 0x64 + IFT_VOICEENCAP = 0x67 + IFT_VOICEFXO = 0x65 + IFT_VOICEFXS = 0x66 + IFT_VOICEOVERATM = 0x98 + IFT_VOICEOVERFRAMERELAY = 0x99 + IFT_VOICEOVERIP = 0x68 + IFT_X213 = 0x5d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25HUNTGROUP = 0x7a + IFT_X25MLP = 0x79 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + IPPROTO_MAXID = 0x34 + IPV6_FAITH = 0x1d + IP_FAITH = 0x16 + MAP_NORESERVE = 0x40 + MAP_RENAME = 0x20 + NET_RT_MAXID = 0x6 + RTF_PRCLONING = 0x10000 + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + SIOCADDRT = 0x8040720a + SIOCALIFADDR = 0x8118691b + SIOCDELRT = 0x8040720b + SIOCDLIFADDR = 0x8118691d + SIOCGLIFADDR = 0xc118691c + SIOCGLIFPHYADDR = 0xc118694b + SIOCSLIFPHYADDR = 0x8118694a +) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/errors_freebsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/errors_freebsd_arm.go new file mode 100644 index 000000000..856dca325 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/errors_freebsd_arm.go @@ -0,0 +1,226 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +const ( + IFT_1822 = 0x2 + IFT_A12MPPSWITCH = 0x82 + IFT_AAL2 = 0xbb + IFT_AAL5 = 0x31 + IFT_ADSL = 0x5e + IFT_AFLANE8023 = 0x3b + IFT_AFLANE8025 = 0x3c + IFT_ARAP = 0x58 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ASYNC = 0x54 + IFT_ATM = 0x25 + IFT_ATMDXI = 0x69 + IFT_ATMFUNI = 0x6a + IFT_ATMIMA = 0x6b + IFT_ATMLOGICAL = 0x50 + IFT_ATMRADIO = 0xbd + IFT_ATMSUBINTERFACE = 0x86 + IFT_ATMVCIENDPT = 0xc2 + IFT_ATMVIRTUAL = 0x95 + IFT_BGPPOLICYACCOUNTING = 0xa2 + IFT_BSC = 0x53 + IFT_CCTEMUL = 0x3d + IFT_CEPT = 0x13 + IFT_CES = 0x85 + IFT_CHANNEL = 0x46 + IFT_CNR = 0x55 + IFT_COFFEE = 0x84 + IFT_COMPOSITELINK = 0x9b + IFT_DCN = 0x8d + IFT_DIGITALPOWERLINE = 0x8a + IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba + IFT_DLSW = 0x4a + IFT_DOCSCABLEDOWNSTREAM = 0x80 + IFT_DOCSCABLEMACLAYER = 0x7f + IFT_DOCSCABLEUPSTREAM = 0x81 + IFT_DS0 = 0x51 + IFT_DS0BUNDLE = 0x52 + IFT_DS1FDL = 0xaa + IFT_DS3 = 0x1e + IFT_DTM = 0x8c + IFT_DVBASILN = 0xac + IFT_DVBASIOUT = 0xad + IFT_DVBRCCDOWNSTREAM = 0x93 + IFT_DVBRCCMACLAYER = 0x92 + IFT_DVBRCCUPSTREAM = 0x94 + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_EPLRS = 0x57 + IFT_ESCON = 0x49 + IFT_ETHER = 0x6 + IFT_FAST = 0x7d + IFT_FASTETHER = 0x3e + IFT_FASTETHERFX = 0x45 + IFT_FDDI = 0xf + IFT_FIBRECHANNEL = 0x38 + IFT_FRAMERELAYINTERCONNECT = 0x3a + IFT_FRAMERELAYMPI = 0x5c + IFT_FRDLCIENDPT = 0xc1 + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_FRF16MFRBUNDLE = 0xa3 + IFT_FRFORWARD = 0x9e + IFT_G703AT2MB = 0x43 + IFT_G703AT64K = 0x42 + IFT_GIF = 0xf0 + IFT_GIGABITETHERNET = 0x75 + IFT_GR303IDT = 0xb2 + IFT_GR303RDT = 0xb1 + IFT_H323GATEKEEPER = 0xa4 + IFT_H323PROXY = 0xa5 + IFT_HDH1822 = 0x3 + IFT_HDLC = 0x76 + IFT_HDSL2 = 0xa8 + IFT_HIPERLAN2 = 0xb7 + IFT_HIPPI = 0x2f + IFT_HIPPIINTERFACE = 0x39 + IFT_HOSTPAD = 0x5a + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IBM370PARCHAN = 0x48 + IFT_IDSL = 0x9a + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INTERLEAVE = 0x7c + IFT_IP = 0x7e + IFT_IPFORWARD = 0x8e + IFT_IPOVERATM = 0x72 + IFT_IPOVERCDLC = 0x6d + IFT_IPOVERCLAW = 0x6e + IFT_IPSWITCH = 0x4e + IFT_ISDN = 0x3f + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISDNS = 0x4b + IFT_ISDNU = 0x4c + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88025CRFPINT = 0x62 + IFT_ISO88025DTR = 0x56 + IFT_ISO88025FIBER = 0x73 + IFT_ISO88026 = 0xa + IFT_ISUP = 0xb3 + IFT_L3IPXVLAN = 0x89 + IFT_LAPB = 0x10 + IFT_LAPD = 0x4d + IFT_LAPF = 0x77 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MEDIAMAILOVERIP = 0x8b + IFT_MFSIGLINK = 0xa7 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_MPC = 0x71 + IFT_MPLS = 0xa6 + IFT_MPLSTUNNEL = 0x96 + IFT_MSDSL = 0x8f + IFT_MVL = 0xbf + IFT_MYRINET = 0x63 + IFT_NFAS = 0xaf + IFT_NSIP = 0x1b + IFT_OPTICALCHANNEL = 0xc3 + IFT_OPTICALTRANSPORT = 0xc4 + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PFLOG = 0xf6 + IFT_PFSYNC = 0xf7 + IFT_PLC = 0xae + IFT_POS = 0xab + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPWIRELESSP2P = 0x9d + IFT_PTPSERIAL = 0x16 + IFT_PVC = 0xf1 + IFT_QLLC = 0x44 + IFT_RADIOMAC = 0xbc + IFT_RADSL = 0x5f + IFT_REACHDSL = 0xc0 + IFT_RFC1483 = 0x9f + IFT_RS232 = 0x21 + IFT_RSRB = 0x4f + IFT_SDLC = 0x11 + IFT_SDSL = 0x60 + IFT_SHDSL = 0xa9 + IFT_SIP = 0x1f + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETOVERHEADCHANNEL = 0xb9 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_SRP = 0x97 + IFT_SS7SIGLINK = 0x9c + IFT_STACKTOSTACK = 0x6f + IFT_STARLAN = 0xb + IFT_STF = 0xd7 + IFT_T1 = 0x12 + IFT_TDLC = 0x74 + IFT_TERMPAD = 0x5b + IFT_TR008 = 0xb0 + IFT_TRANSPHDLC = 0x7b + IFT_TUNNEL = 0x83 + IFT_ULTRA = 0x1d + IFT_USB = 0xa0 + IFT_V11 = 0x40 + IFT_V35 = 0x2d + IFT_V36 = 0x41 + IFT_V37 = 0x78 + IFT_VDSL = 0x61 + IFT_VIRTUALIPADDRESS = 0x70 + IFT_VOICEEM = 0x64 + IFT_VOICEENCAP = 0x67 + IFT_VOICEFXO = 0x65 + IFT_VOICEFXS = 0x66 + IFT_VOICEOVERATM = 0x98 + IFT_VOICEOVERFRAMERELAY = 0x99 + IFT_VOICEOVERIP = 0x68 + IFT_X213 = 0x5d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25HUNTGROUP = 0x7a + IFT_X25MLP = 0x79 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + + // missing constants on FreeBSD-11.1-RELEASE, copied from old values in ztypes_freebsd_arm.go + IFF_SMART = 0x20 + IFT_FAITH = 0xf2 + IFT_IPXIP = 0xf9 + IPPROTO_MAXID = 0x34 + IPV6_FAITH = 0x1d + IP_FAITH = 0x16 + MAP_NORESERVE = 0x40 + MAP_RENAME = 0x20 + NET_RT_MAXID = 0x6 + RTF_PRCLONING = 0x10000 + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + SIOCADDRT = 0x8030720a + SIOCALIFADDR = 0x8118691b + SIOCDELRT = 0x8030720b + SIOCDLIFADDR = 0x8118691d + SIOCGLIFADDR = 0xc118691c + SIOCGLIFPHYADDR = 0xc118694b + SIOCSLIFPHYADDR = 0x8118694a +) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/file_unix.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/file_unix.go new file mode 100644 index 000000000..47f6a83f2 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/file_unix.go @@ -0,0 +1,27 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +import ( + "os" + "syscall" +) + +// FIXME: unexported function from os +// syscallMode returns the syscall-specific mode bits from Go's portable mode bits. +func syscallMode(i os.FileMode) (o uint32) { + o |= uint32(i.Perm()) + if i&os.ModeSetuid != 0 { + o |= syscall.S_ISUID + } + if i&os.ModeSetgid != 0 { + o |= syscall.S_ISGID + } + if i&os.ModeSticky != 0 { + o |= syscall.S_ISVTX + } + // No mapping for Go's ModeTemporary (plan9 only). + return +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/flock.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/flock.go index ce67a5952..2994ce75f 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/flock.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/flock.go @@ -1,5 +1,3 @@ -// +build linux darwin freebsd openbsd netbsd dragonfly - // Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_bsd.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_bsd.go index ccb29c75c..c2846b32d 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_bsd.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_bsd.go @@ -561,13 +561,19 @@ func Utimes(path string, tv []Timeval) error { func UtimesNano(path string, ts []Timespec) error { if ts == nil { + err := utimensat(AT_FDCWD, path, nil, 0) + if err != ENOSYS { + return err + } return utimes(path, nil) } - // TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it - // isn't supported by darwin so this uses utimes instead if len(ts) != 2 { return EINVAL } + err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) + if err != ENOSYS { + return err + } // Not as efficient as it could be because Timespec and // Timeval have different types in the different OSes tv := [2]Timeval{ @@ -577,6 +583,16 @@ func UtimesNano(path string, ts []Timespec) error { return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) } +func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error { + if ts == nil { + return utimensat(dirfd, path, nil, flags) + } + if len(ts) != 2 { + return EINVAL + } + return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags) +} + //sys futimes(fd int, timeval *[2]Timeval) (err error) func Futimes(fd int, tv []Timeval) error { @@ -594,9 +610,6 @@ func Futimes(fd int, tv []Timeval) error { // TODO: wrap // Acct(name nil-string) (err error) // Gethostuuid(uuid *byte, timeout *Timespec) (err error) -// Madvise(addr *byte, len int, behav int) (err error) -// Mprotect(addr *byte, len int, prot int) (err error) -// Msync(addr *byte, len int, flags int) (err error) // Ptrace(req int, pid int, addr uintptr, data int) (ret uintptr, err error) var mapper = &mmapper{ @@ -612,3 +625,11 @@ func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, e func Munmap(b []byte) (err error) { return mapper.Munmap(b) } + +//sys Madvise(b []byte, behav int) (err error) +//sys Mlock(b []byte) (err error) +//sys Mlockall(flags int) (err error) +//sys Mprotect(b []byte, prot int) (err error) +//sys Msync(b []byte, flags int) (err error) +//sys Munlock(b []byte) (err error) +//sys Munlockall() (err error) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_darwin.go index 7d91ac02a..ad74a11fb 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -187,6 +187,11 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { return } +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) error { + // Darwin doesn't support SYS_UTIMENSAT + return ENOSYS +} + /* * Wrapped */ @@ -195,6 +200,45 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) } +//sys ioctl(fd int, req uint, arg uintptr) (err error) + +// ioctl itself should not be exposed directly, but additional get/set +// functions for specific types are permissible. + +// IoctlSetInt performs an ioctl operation which sets an integer value +// on fd, using the specified request number. +func IoctlSetInt(fd int, req uint, value int) error { + return ioctl(fd, req, uintptr(value)) +} + +func IoctlSetWinsize(fd int, req uint, value *Winsize) error { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + +func IoctlSetTermios(fd int, req uint, value *Termios) error { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + +// IoctlGetInt performs an ioctl operation which gets an integer value +// from fd, using the specified request number. +func IoctlGetInt(fd int, req uint) (int, error) { + var value int + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return value, err +} + +func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { + var value Winsize + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + +func IoctlGetTermios(fd int, req uint) (*Termios, error) { + var value Termios + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + /* * Exposed directly */ @@ -210,10 +254,13 @@ func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(sig //sys Dup2(from int, to int) (err error) //sys Exchangedata(path1 string, path2 string, options int) (err error) //sys Exit(code int) +//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error) //sys Fchdir(fd int) (err error) //sys Fchflags(fd int, flags int) (err error) //sys Fchmod(fd int, mode uint32) (err error) +//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) //sys Fchown(fd int, uid int, gid int) (err error) +//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) //sys Flock(fd int, how int) (err error) //sys Fpathconf(fd int, name int) (val int, err error) //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 @@ -238,23 +285,23 @@ func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(sig //sys Kqueue() (fd int, err error) //sys Lchown(path string, uid int, gid int) (err error) //sys Link(path string, link string) (err error) +//sys Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) //sys Listen(s int, backlog int) (err error) //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 //sys Mkdir(path string, mode uint32) (err error) +//sys Mkdirat(dirfd int, path string, mode uint32) (err error) //sys Mkfifo(path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) -//sys Mlock(b []byte) (err error) -//sys Mlockall(flags int) (err error) -//sys Mprotect(b []byte, prot int) (err error) -//sys Munlock(b []byte) (err error) -//sys Munlockall() (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) +//sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) //sys Pread(fd int, p []byte, offset int64) (n int, err error) //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) +//sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error) //sys Rename(from string, to string) (err error) +//sys Renameat(fromfd int, from string, tofd int, to string) (err error) //sys Revoke(path string) (err error) //sys Rmdir(path string) (err error) //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK @@ -275,11 +322,13 @@ func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(sig //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 //sys Symlink(path string, link string) (err error) +//sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error) //sys Sync() (err error) //sys Truncate(path string, length int64) (err error) //sys Umask(newmask int) (oldmask int) //sys Undelete(path string) (err error) //sys Unlink(path string) (err error) +//sys Unlinkat(dirfd int, path string, flags int) (err error) //sys Unmount(path string, flags int) (err error) //sys write(fd int, p []byte) (n int, err error) //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) @@ -319,9 +368,6 @@ func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(sig // Add_profil // Kdebug_trace // Sigreturn -// Mmap -// Mlock -// Munlock // Atsocket // Kqueue_from_portset_np // Kqueue_portset @@ -414,8 +460,6 @@ func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(sig // Lio_listio // __pthread_cond_wait // Iopolicysys -// Mlockall -// Munlockall // __pthread_kill // __pthread_sigmask // __sigwait @@ -469,7 +513,6 @@ func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(sig // Sendmsg_nocancel // Recvfrom_nocancel // Accept_nocancel -// Msync_nocancel // Fcntl_nocancel // Select_nocancel // Fsync_nocancel diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go index fc1e5a4a8..c6c99c13a 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go @@ -11,8 +11,6 @@ import ( "unsafe" ) -//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) - func Getpagesize() int { return 4096 } func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_dragonfly.go index 7e0210fc9..3a483373d 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_dragonfly.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_dragonfly.go @@ -174,11 +174,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { //sys Mkdir(path string, mode uint32) (err error) //sys Mkfifo(path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) -//sys Mlock(b []byte) (err error) -//sys Mlockall(flags int) (err error) -//sys Mprotect(b []byte, prot int) (err error) -//sys Munlock(b []byte) (err error) -//sys Munlockall() (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) @@ -218,6 +213,7 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE //sys accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) +//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) /* * Unimplemented @@ -252,9 +248,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { // Add_profil // Kdebug_trace // Sigreturn -// Mmap -// Mlock -// Munlock // Atsocket // Kqueue_from_portset_np // Kqueue_portset @@ -347,8 +340,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { // Lio_listio // __pthread_cond_wait // Iopolicysys -// Mlockall -// Munlockall // __pthread_kill // __pthread_sigmask // __sigwait @@ -401,7 +392,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { // Sendmsg_nocancel // Recvfrom_nocancel // Accept_nocancel -// Msync_nocancel // Fcntl_nocancel // Select_nocancel // Fsync_nocancel diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_freebsd.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_freebsd.go index 077d1f39a..d26e52eae 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_freebsd.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_freebsd.go @@ -352,11 +352,53 @@ func Llistxattr(link string, dest []byte) (sz int, err error) { return s, e } +//sys ioctl(fd int, req uint, arg uintptr) (err error) + +// ioctl itself should not be exposed directly, but additional get/set +// functions for specific types are permissible. + +// IoctlSetInt performs an ioctl operation which sets an integer value +// on fd, using the specified request number. +func IoctlSetInt(fd int, req uint, value int) error { + return ioctl(fd, req, uintptr(value)) +} + +func IoctlSetWinsize(fd int, req uint, value *Winsize) error { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + +func IoctlSetTermios(fd int, req uint, value *Termios) error { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + +// IoctlGetInt performs an ioctl operation which gets an integer value +// from fd, using the specified request number. +func IoctlGetInt(fd int, req uint) (int, error) { + var value int + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return value, err +} + +func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { + var value Winsize + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + +func IoctlGetTermios(fd int, req uint) (*Termios, error) { + var value Termios + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + /* * Exposed directly */ //sys Access(path string, mode uint32) (err error) //sys Adjtime(delta *Timeval, olddelta *Timeval) (err error) +//sys CapEnter() (err error) +//sys capRightsGet(version int, fd int, rightsp *CapRights) (err error) = SYS___CAP_RIGHTS_GET +//sys capRightsLimit(fd int, rightsp *CapRights) (err error) //sys Chdir(path string) (err error) //sys Chflags(path string, flags int) (err error) //sys Chmod(path string, mode uint32) (err error) @@ -379,10 +421,13 @@ func Llistxattr(link string, dest []byte) (sz int, err error) { //sys ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error) //sys ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_POSIX_FADVISE +//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error) //sys Fchdir(fd int) (err error) //sys Fchflags(fd int, flags int) (err error) //sys Fchmod(fd int, mode uint32) (err error) +//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) //sys Fchown(fd int, uid int, gid int) (err error) +//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) //sys Flock(fd int, how int) (err error) //sys Fpathconf(fd int, name int) (val int, err error) //sys Fstat(fd int, stat *Stat_t) (err error) @@ -409,24 +454,24 @@ func Llistxattr(link string, dest []byte) (sz int, err error) { //sys Kqueue() (fd int, err error) //sys Lchown(path string, uid int, gid int) (err error) //sys Link(path string, link string) (err error) +//sys Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) //sys Listen(s int, backlog int) (err error) //sys Lstat(path string, stat *Stat_t) (err error) //sys Mkdir(path string, mode uint32) (err error) +//sys Mkdirat(dirfd int, path string, mode uint32) (err error) //sys Mkfifo(path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) -//sys Mlock(b []byte) (err error) -//sys Mlockall(flags int) (err error) -//sys Mprotect(b []byte, prot int) (err error) -//sys Munlock(b []byte) (err error) -//sys Munlockall() (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) +//sys Openat(fdat int, path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) //sys Pread(fd int, p []byte, offset int64) (n int, err error) //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) +//sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error) //sys Rename(from string, to string) (err error) +//sys Renameat(fromfd int, from string, tofd int, to string) (err error) //sys Revoke(path string) (err error) //sys Rmdir(path string) (err error) //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK @@ -448,11 +493,13 @@ func Llistxattr(link string, dest []byte) (sz int, err error) { //sys Stat(path string, stat *Stat_t) (err error) //sys Statfs(path string, stat *Statfs_t) (err error) //sys Symlink(path string, link string) (err error) +//sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error) //sys Sync() (err error) //sys Truncate(path string, length int64) (err error) //sys Umask(newmask int) (oldmask int) //sys Undelete(path string) (err error) //sys Unlink(path string) (err error) +//sys Unlinkat(dirfd int, path string, flags int) (err error) //sys Unmount(path string, flags int) (err error) //sys write(fd int, p []byte) (n int, err error) //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) @@ -460,6 +507,7 @@ func Llistxattr(link string, dest []byte) (sz int, err error) { //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE //sys accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) +//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) /* * Unimplemented @@ -493,9 +541,6 @@ func Llistxattr(link string, dest []byte) (sz int, err error) { // Add_profil // Kdebug_trace // Sigreturn -// Mmap -// Mlock -// Munlock // Atsocket // Kqueue_from_portset_np // Kqueue_portset @@ -588,8 +633,6 @@ func Llistxattr(link string, dest []byte) (sz int, err error) { // Lio_listio // __pthread_cond_wait // Iopolicysys -// Mlockall -// Munlockall // __pthread_kill // __pthread_sigmask // __sigwait @@ -642,7 +685,6 @@ func Llistxattr(link string, dest []byte) (sz int, err error) { // Sendmsg_nocancel // Recvfrom_nocancel // Accept_nocancel -// Msync_nocancel // Fcntl_nocancel // Select_nocancel // Fsync_nocancel diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_linux.go index cc618f7cf..2afe62bf8 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -57,11 +57,15 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { // IoctlSetInt performs an ioctl operation which sets an integer value // on fd, using the specified request number. -func IoctlSetInt(fd int, req uint, value int) (err error) { +func IoctlSetInt(fd int, req uint, value int) error { return ioctl(fd, req, uintptr(value)) } -func IoctlSetTermios(fd int, req uint, value *Termios) (err error) { +func IoctlSetWinsize(fd int, req uint, value *Winsize) error { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + +func IoctlSetTermios(fd int, req uint, value *Termios) error { return ioctl(fd, req, uintptr(unsafe.Pointer(value))) } @@ -73,6 +77,12 @@ func IoctlGetInt(fd int, req uint) (int, error) { return value, err } +func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { + var value Winsize + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + func IoctlGetTermios(fd int, req uint) (*Termios, error) { var value Termios err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) @@ -342,10 +352,14 @@ func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, return } -func Mkfifo(path string, mode uint32) (err error) { +func Mkfifo(path string, mode uint32) error { return Mknod(path, mode|S_IFIFO, 0) } +func Mkfifoat(dirfd int, path string, mode uint32) error { + return Mknodat(dirfd, path, mode|S_IFIFO, 0) +} + func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { if sa.Port < 0 || sa.Port > 0xFFFF { return nil, 0, EINVAL @@ -1265,6 +1279,7 @@ func Setgid(uid int) (err error) { //sys Setpriority(which int, who int, prio int) (err error) //sys Setxattr(path string, attr string, data []byte, flags int) (err error) //sys Sync() +//sys Syncfs(fd int) (err error) //sysnb Sysinfo(info *Sysinfo_t) (err error) //sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error) //sysnb Tgkill(tgid int, tid int, sig syscall.Signal) (err error) @@ -1299,8 +1314,9 @@ func Munmap(b []byte) (err error) { //sys Madvise(b []byte, advice int) (err error) //sys Mprotect(b []byte, prot int) (err error) //sys Mlock(b []byte) (err error) -//sys Munlock(b []byte) (err error) //sys Mlockall(flags int) (err error) +//sys Msync(b []byte, flags int) (err error) +//sys Munlock(b []byte) (err error) //sys Munlockall() (err error) // Vmsplice splices user pages from a slice of Iovecs into a pipe specified by fd, @@ -1368,7 +1384,6 @@ func Vmsplice(fd int, iovs []Iovec, flags int) (int, error) { // ModifyLdt // Mount // MovePages -// Mprotect // MqGetsetattr // MqNotify // MqOpen @@ -1380,7 +1395,6 @@ func Vmsplice(fd int, iovs []Iovec, flags int) (int, error) { // Msgget // Msgrcv // Msgsnd -// Msync // Newfstatat // Nfsservctl // Personality diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_netbsd.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_netbsd.go index 01f6a48c8..e12966845 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_netbsd.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_netbsd.go @@ -170,11 +170,6 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sys Mkdir(path string, mode uint32) (err error) //sys Mkfifo(path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) -//sys Mlock(b []byte) (err error) -//sys Mlockall(flags int) (err error) -//sys Mprotect(b []byte, prot int) (err error) -//sys Munlock(b []byte) (err error) -//sys Munlockall() (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) @@ -210,6 +205,7 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sys munmap(addr uintptr, length uintptr) (err error) //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE +//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) /* * Unimplemented diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_openbsd.go index c0d2b6c80..408e63081 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -149,11 +149,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { //sys Mkdir(path string, mode uint32) (err error) //sys Mkfifo(path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) -//sys Mlock(b []byte) (err error) -//sys Mlockall(flags int) (err error) -//sys Mprotect(b []byte, prot int) (err error) -//sys Munlock(b []byte) (err error) -//sys Munlockall() (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) @@ -193,6 +188,7 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { //sys munmap(addr uintptr, length uintptr) (err error) //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE +//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) /* * Unimplemented @@ -282,6 +278,5 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { // thrsleep // thrwakeup // unlinkat -// utimensat // vfork // writev diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go new file mode 100644 index 000000000..14ddaf3f3 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go @@ -0,0 +1,44 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build arm,openbsd + +package unix + +import "syscall" + +func Getpagesize() int { return syscall.Getpagesize() } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = int64(nsec / 1e9) + ts.Nsec = int32(nsec % 1e9) + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = int32(nsec % 1e9 / 1e3) + tv.Sec = int64(nsec / 1e9) + return +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint32(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint32(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_solaris.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_solaris.go index 4b8ddabda..0d4e5c4e6 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_solaris.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/syscall_solaris.go @@ -581,6 +581,7 @@ func IoctlGetTermio(fd int, req uint) (*Termio, error) { //sys Fchown(fd int, uid int, gid int) (err error) //sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) //sys Fdatasync(fd int) (err error) +//sys Flock(fd int, how int) (err error) //sys Fpathconf(fd int, name int) (val int, err error) //sys Fstat(fd int, stat *Stat_t) (err error) //sys Fstatvfs(fd int, vfsstat *Statvfs_t) (err error) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go index 8e6388835..1c68758b6 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go @@ -1,5 +1,5 @@ // mkerrors.sh -m32 -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build 386,darwin @@ -48,6 +48,7 @@ const ( AF_UNIX = 0x1 AF_UNSPEC = 0x0 AF_UTUN = 0x26 + ALTWERASE = 0x200 B0 = 0x0 B110 = 0x6e B115200 = 0x1c200 @@ -138,9 +139,26 @@ const ( BPF_W = 0x0 BPF_X = 0x8 BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x8000 + BSDLY = 0x8000 CFLUSH = 0xf CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_MONOTONIC_RAW_APPROX = 0x5 + CLOCK_PROCESS_CPUTIME_ID = 0xc + CLOCK_REALTIME = 0x0 + CLOCK_THREAD_CPUTIME_ID = 0x10 + CLOCK_UPTIME_RAW = 0x8 + CLOCK_UPTIME_RAW_APPROX = 0x9 + CR0 = 0x0 + CR1 = 0x1000 + CR2 = 0x2000 + CR3 = 0x3000 + CRDLY = 0x3000 CREAD = 0x800 + CRTSCTS = 0x30000 CS5 = 0x0 CS6 = 0x100 CS7 = 0x200 @@ -332,13 +350,14 @@ const ( ECHONL = 0x10 ECHOPRT = 0x20 EVFILT_AIO = -0x3 + EVFILT_EXCEPT = -0xf EVFILT_FS = -0x9 EVFILT_MACHPORT = -0x8 EVFILT_PROC = -0x5 EVFILT_READ = -0x1 EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0xe - EVFILT_THREADMARKER = 0xe + EVFILT_SYSCOUNT = 0xf + EVFILT_THREADMARKER = 0xf EVFILT_TIMER = -0x7 EVFILT_USER = -0xa EVFILT_VM = -0xc @@ -349,6 +368,7 @@ const ( EV_DELETE = 0x2 EV_DISABLE = 0x8 EV_DISPATCH = 0x80 + EV_DISPATCH2 = 0x180 EV_ENABLE = 0x4 EV_EOF = 0x8000 EV_ERROR = 0x4000 @@ -359,16 +379,25 @@ const ( EV_POLL = 0x1000 EV_RECEIPT = 0x40 EV_SYSFLAGS = 0xf000 + EV_UDATA_SPECIFIC = 0x100 + EV_VANISHED = 0x200 EXTA = 0x4b00 EXTB = 0x9600 EXTPROC = 0x800 FD_CLOEXEC = 0x1 FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x4000 + FFDLY = 0x4000 FLUSHO = 0x800000 F_ADDFILESIGS = 0x3d + F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 + F_ADDFILESIGS_RETURN = 0x61 F_ADDSIGS = 0x3b F_ALLOCATEALL = 0x4 F_ALLOCATECONTIG = 0x2 + F_BARRIERFSYNC = 0x55 + F_CHECK_LV = 0x62 F_CHKCLEAN = 0x29 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x43 @@ -770,11 +799,13 @@ const ( MADV_FREE_REUSABLE = 0x7 MADV_FREE_REUSE = 0x8 MADV_NORMAL = 0x0 + MADV_PAGEOUT = 0xa MADV_RANDOM = 0x1 MADV_SEQUENTIAL = 0x2 MADV_WILLNEED = 0x3 MADV_ZERO_WIRED_PAGES = 0x6 MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 MAP_COPY = 0x2 MAP_FILE = 0x0 MAP_FIXED = 0x10 @@ -786,9 +817,43 @@ const ( MAP_PRIVATE = 0x2 MAP_RENAME = 0x20 MAP_RESERVED0080 = 0x80 + MAP_RESILIENT_CODESIGN = 0x2000 + MAP_RESILIENT_MEDIA = 0x4000 MAP_SHARED = 0x1 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_AUTOMOUNTED = 0x400000 + MNT_CMDFLAGS = 0xf0000 + MNT_CPROTECT = 0x80 + MNT_DEFWRITE = 0x2000000 + MNT_DONTBROWSE = 0x100000 + MNT_DOVOLFS = 0x8000 + MNT_DWAIT = 0x4 + MNT_EXPORTED = 0x100 + MNT_FORCE = 0x80000 + MNT_IGNORE_OWNERSHIP = 0x200000 + MNT_JOURNALED = 0x800000 + MNT_LOCAL = 0x1000 + MNT_MULTILABEL = 0x4000000 + MNT_NOATIME = 0x10000000 + MNT_NOBLOCK = 0x20000 + MNT_NODEV = 0x10 + MNT_NOEXEC = 0x4 + MNT_NOSUID = 0x8 + MNT_NOUSERXATTR = 0x1000000 + MNT_NOWAIT = 0x2 + MNT_QUARANTINE = 0x400 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELOAD = 0x40000 + MNT_ROOTFS = 0x4000 + MNT_SYNCHRONOUS = 0x2 + MNT_UNION = 0x20 + MNT_UNKNOWNPERMISSIONS = 0x200000 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0x17f0f5ff + MNT_WAIT = 0x1 MSG_CTRUNC = 0x20 MSG_DONTROUTE = 0x4 MSG_DONTWAIT = 0x80 @@ -819,7 +884,13 @@ const ( NET_RT_MAXID = 0xa NET_RT_STAT = 0x4 NET_RT_TRASH = 0x5 + NL0 = 0x0 + NL1 = 0x100 + NL2 = 0x200 + NL3 = 0x300 + NLDLY = 0x300 NOFLSH = 0x80000000 + NOKERNINFO = 0x2000000 NOTE_ABSOLUTE = 0x8 NOTE_ATTRIB = 0x8 NOTE_BACKGROUND = 0x40 @@ -843,11 +914,14 @@ const ( NOTE_FFNOP = 0x0 NOTE_FFOR = 0x80000000 NOTE_FORK = 0x40000000 + NOTE_FUNLOCK = 0x100 NOTE_LEEWAY = 0x10 NOTE_LINK = 0x10 NOTE_LOWAT = 0x1 + NOTE_MACH_CONTINUOUS_TIME = 0x80 NOTE_NONE = 0x80 NOTE_NSECONDS = 0x4 + NOTE_OOB = 0x2 NOTE_PCTRLMASK = -0x100000 NOTE_PDATAMASK = 0xfffff NOTE_REAP = 0x10000000 @@ -872,6 +946,7 @@ const ( ONOCR = 0x20 ONOEOT = 0x8 OPOST = 0x1 + OXTABS = 0x4 O_ACCMODE = 0x3 O_ALERT = 0x20000000 O_APPEND = 0x8 @@ -880,6 +955,7 @@ const ( O_CREAT = 0x200 O_DIRECTORY = 0x100000 O_DP_GETRAWENCRYPTED = 0x1 + O_DP_GETRAWUNENCRYPTED = 0x2 O_DSYNC = 0x400000 O_EVTONLY = 0x8000 O_EXCL = 0x800 @@ -932,7 +1008,10 @@ const ( RLIMIT_CPU_USAGE_MONITOR = 0x2 RLIMIT_DATA = 0x2 RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 RLIMIT_STACK = 0x3 RLIM_INFINITY = 0x7fffffffffffffff RTAX_AUTHOR = 0x6 @@ -1102,6 +1181,8 @@ const ( SO_LABEL = 0x1010 SO_LINGER = 0x80 SO_LINGER_SEC = 0x1080 + SO_NETSVC_MARKING_LEVEL = 0x1119 + SO_NET_SERVICE_TYPE = 0x1116 SO_NKE = 0x1021 SO_NOADDRERR = 0x1023 SO_NOSIGPIPE = 0x1022 @@ -1157,11 +1238,22 @@ const ( S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x400 + TAB2 = 0x800 + TAB3 = 0x4 + TABDLY = 0xc04 TCIFLUSH = 0x1 + TCIOFF = 0x3 TCIOFLUSH = 0x3 + TCION = 0x4 TCOFLUSH = 0x2 + TCOOFF = 0x1 + TCOON = 0x2 TCP_CONNECTIONTIMEOUT = 0x20 + TCP_CONNECTION_INFO = 0x106 TCP_ENABLE_ECN = 0x104 + TCP_FASTOPEN = 0x105 TCP_KEEPALIVE = 0x10 TCP_KEEPCNT = 0x102 TCP_KEEPINTVL = 0x101 @@ -1261,6 +1353,11 @@ const ( VKILL = 0x5 VLNEXT = 0xe VMIN = 0x10 + VM_LOADAVG = 0x2 + VM_MACHFACTOR = 0x4 + VM_MAXID = 0x6 + VM_METER = 0x1 + VM_SWAPUSAGE = 0x5 VQUIT = 0x9 VREPRINT = 0x6 VSTART = 0xc diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index 9594f9381..48f63d4f0 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -1,5 +1,5 @@ // mkerrors.sh -m64 -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build amd64,darwin @@ -48,6 +48,7 @@ const ( AF_UNIX = 0x1 AF_UNSPEC = 0x0 AF_UTUN = 0x26 + ALTWERASE = 0x200 B0 = 0x0 B110 = 0x6e B115200 = 0x1c200 @@ -138,9 +139,26 @@ const ( BPF_W = 0x0 BPF_X = 0x8 BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x8000 + BSDLY = 0x8000 CFLUSH = 0xf CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_MONOTONIC_RAW_APPROX = 0x5 + CLOCK_PROCESS_CPUTIME_ID = 0xc + CLOCK_REALTIME = 0x0 + CLOCK_THREAD_CPUTIME_ID = 0x10 + CLOCK_UPTIME_RAW = 0x8 + CLOCK_UPTIME_RAW_APPROX = 0x9 + CR0 = 0x0 + CR1 = 0x1000 + CR2 = 0x2000 + CR3 = 0x3000 + CRDLY = 0x3000 CREAD = 0x800 + CRTSCTS = 0x30000 CS5 = 0x0 CS6 = 0x100 CS7 = 0x200 @@ -332,13 +350,14 @@ const ( ECHONL = 0x10 ECHOPRT = 0x20 EVFILT_AIO = -0x3 + EVFILT_EXCEPT = -0xf EVFILT_FS = -0x9 EVFILT_MACHPORT = -0x8 EVFILT_PROC = -0x5 EVFILT_READ = -0x1 EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0xe - EVFILT_THREADMARKER = 0xe + EVFILT_SYSCOUNT = 0xf + EVFILT_THREADMARKER = 0xf EVFILT_TIMER = -0x7 EVFILT_USER = -0xa EVFILT_VM = -0xc @@ -349,6 +368,7 @@ const ( EV_DELETE = 0x2 EV_DISABLE = 0x8 EV_DISPATCH = 0x80 + EV_DISPATCH2 = 0x180 EV_ENABLE = 0x4 EV_EOF = 0x8000 EV_ERROR = 0x4000 @@ -359,16 +379,25 @@ const ( EV_POLL = 0x1000 EV_RECEIPT = 0x40 EV_SYSFLAGS = 0xf000 + EV_UDATA_SPECIFIC = 0x100 + EV_VANISHED = 0x200 EXTA = 0x4b00 EXTB = 0x9600 EXTPROC = 0x800 FD_CLOEXEC = 0x1 FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x4000 + FFDLY = 0x4000 FLUSHO = 0x800000 F_ADDFILESIGS = 0x3d + F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 + F_ADDFILESIGS_RETURN = 0x61 F_ADDSIGS = 0x3b F_ALLOCATEALL = 0x4 F_ALLOCATECONTIG = 0x2 + F_BARRIERFSYNC = 0x55 + F_CHECK_LV = 0x62 F_CHKCLEAN = 0x29 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x43 @@ -770,11 +799,13 @@ const ( MADV_FREE_REUSABLE = 0x7 MADV_FREE_REUSE = 0x8 MADV_NORMAL = 0x0 + MADV_PAGEOUT = 0xa MADV_RANDOM = 0x1 MADV_SEQUENTIAL = 0x2 MADV_WILLNEED = 0x3 MADV_ZERO_WIRED_PAGES = 0x6 MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 MAP_COPY = 0x2 MAP_FILE = 0x0 MAP_FIXED = 0x10 @@ -786,9 +817,43 @@ const ( MAP_PRIVATE = 0x2 MAP_RENAME = 0x20 MAP_RESERVED0080 = 0x80 + MAP_RESILIENT_CODESIGN = 0x2000 + MAP_RESILIENT_MEDIA = 0x4000 MAP_SHARED = 0x1 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_AUTOMOUNTED = 0x400000 + MNT_CMDFLAGS = 0xf0000 + MNT_CPROTECT = 0x80 + MNT_DEFWRITE = 0x2000000 + MNT_DONTBROWSE = 0x100000 + MNT_DOVOLFS = 0x8000 + MNT_DWAIT = 0x4 + MNT_EXPORTED = 0x100 + MNT_FORCE = 0x80000 + MNT_IGNORE_OWNERSHIP = 0x200000 + MNT_JOURNALED = 0x800000 + MNT_LOCAL = 0x1000 + MNT_MULTILABEL = 0x4000000 + MNT_NOATIME = 0x10000000 + MNT_NOBLOCK = 0x20000 + MNT_NODEV = 0x10 + MNT_NOEXEC = 0x4 + MNT_NOSUID = 0x8 + MNT_NOUSERXATTR = 0x1000000 + MNT_NOWAIT = 0x2 + MNT_QUARANTINE = 0x400 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELOAD = 0x40000 + MNT_ROOTFS = 0x4000 + MNT_SYNCHRONOUS = 0x2 + MNT_UNION = 0x20 + MNT_UNKNOWNPERMISSIONS = 0x200000 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0x17f0f5ff + MNT_WAIT = 0x1 MSG_CTRUNC = 0x20 MSG_DONTROUTE = 0x4 MSG_DONTWAIT = 0x80 @@ -819,7 +884,13 @@ const ( NET_RT_MAXID = 0xa NET_RT_STAT = 0x4 NET_RT_TRASH = 0x5 + NL0 = 0x0 + NL1 = 0x100 + NL2 = 0x200 + NL3 = 0x300 + NLDLY = 0x300 NOFLSH = 0x80000000 + NOKERNINFO = 0x2000000 NOTE_ABSOLUTE = 0x8 NOTE_ATTRIB = 0x8 NOTE_BACKGROUND = 0x40 @@ -843,11 +914,14 @@ const ( NOTE_FFNOP = 0x0 NOTE_FFOR = 0x80000000 NOTE_FORK = 0x40000000 + NOTE_FUNLOCK = 0x100 NOTE_LEEWAY = 0x10 NOTE_LINK = 0x10 NOTE_LOWAT = 0x1 + NOTE_MACH_CONTINUOUS_TIME = 0x80 NOTE_NONE = 0x80 NOTE_NSECONDS = 0x4 + NOTE_OOB = 0x2 NOTE_PCTRLMASK = -0x100000 NOTE_PDATAMASK = 0xfffff NOTE_REAP = 0x10000000 @@ -872,6 +946,7 @@ const ( ONOCR = 0x20 ONOEOT = 0x8 OPOST = 0x1 + OXTABS = 0x4 O_ACCMODE = 0x3 O_ALERT = 0x20000000 O_APPEND = 0x8 @@ -880,6 +955,7 @@ const ( O_CREAT = 0x200 O_DIRECTORY = 0x100000 O_DP_GETRAWENCRYPTED = 0x1 + O_DP_GETRAWUNENCRYPTED = 0x2 O_DSYNC = 0x400000 O_EVTONLY = 0x8000 O_EXCL = 0x800 @@ -932,7 +1008,10 @@ const ( RLIMIT_CPU_USAGE_MONITOR = 0x2 RLIMIT_DATA = 0x2 RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 RLIMIT_STACK = 0x3 RLIM_INFINITY = 0x7fffffffffffffff RTAX_AUTHOR = 0x6 @@ -1102,6 +1181,8 @@ const ( SO_LABEL = 0x1010 SO_LINGER = 0x80 SO_LINGER_SEC = 0x1080 + SO_NETSVC_MARKING_LEVEL = 0x1119 + SO_NET_SERVICE_TYPE = 0x1116 SO_NKE = 0x1021 SO_NOADDRERR = 0x1023 SO_NOSIGPIPE = 0x1022 @@ -1157,11 +1238,22 @@ const ( S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x400 + TAB2 = 0x800 + TAB3 = 0x4 + TABDLY = 0xc04 TCIFLUSH = 0x1 + TCIOFF = 0x3 TCIOFLUSH = 0x3 + TCION = 0x4 TCOFLUSH = 0x2 + TCOOFF = 0x1 + TCOON = 0x2 TCP_CONNECTIONTIMEOUT = 0x20 + TCP_CONNECTION_INFO = 0x106 TCP_ENABLE_ECN = 0x104 + TCP_FASTOPEN = 0x105 TCP_KEEPALIVE = 0x10 TCP_KEEPCNT = 0x102 TCP_KEEPINTVL = 0x101 @@ -1261,6 +1353,11 @@ const ( VKILL = 0x5 VLNEXT = 0xe VMIN = 0x10 + VM_LOADAVG = 0x2 + VM_MACHFACTOR = 0x4 + VM_MAXID = 0x6 + VM_METER = 0x1 + VM_SWAPUSAGE = 0x5 VQUIT = 0x9 VREPRINT = 0x6 VSTART = 0xc diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go index a410e88ed..24cb522d9 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go @@ -1,11 +1,11 @@ // mkerrors.sh -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. + +// +build arm,darwin // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- _const.go -// +build arm,darwin - package unix import "syscall" @@ -48,6 +48,7 @@ const ( AF_UNIX = 0x1 AF_UNSPEC = 0x0 AF_UTUN = 0x26 + ALTWERASE = 0x200 B0 = 0x0 B110 = 0x6e B115200 = 0x1c200 @@ -86,6 +87,7 @@ const ( BIOCSBLEN = 0xc0044266 BIOCSDLT = 0x80044278 BIOCSETF = 0x80104267 + BIOCSETFNR = 0x8010427e BIOCSETIF = 0x8020426c BIOCSHDRCMPLT = 0x80044275 BIOCSRSIG = 0x80044273 @@ -137,9 +139,26 @@ const ( BPF_W = 0x0 BPF_X = 0x8 BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x8000 + BSDLY = 0x8000 CFLUSH = 0xf CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_MONOTONIC_RAW_APPROX = 0x5 + CLOCK_PROCESS_CPUTIME_ID = 0xc + CLOCK_REALTIME = 0x0 + CLOCK_THREAD_CPUTIME_ID = 0x10 + CLOCK_UPTIME_RAW = 0x8 + CLOCK_UPTIME_RAW_APPROX = 0x9 + CR0 = 0x0 + CR1 = 0x1000 + CR2 = 0x2000 + CR3 = 0x3000 + CRDLY = 0x3000 CREAD = 0x800 + CRTSCTS = 0x30000 CS5 = 0x0 CS6 = 0x100 CS7 = 0x200 @@ -152,33 +171,168 @@ const ( CSUSP = 0x1a CTL_MAXNAME = 0xc CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde DLT_APPLE_IP_OVER_IEEE1394 = 0x8a DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 DLT_ATM_CLIP = 0x13 DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 DLT_CHAOS = 0x5 DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb + DLT_ECONET = 0x73 DLT_EN10MB = 0x1 DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HHDLC = 0x79 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 DLT_IEEE802 = 0x6 DLT_IEEE802_11 = 0x69 DLT_IEEE802_11_RADIO = 0x7f DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 DLT_LINUX_SLL = 0x71 DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0xf5 + DLT_MATCHING_MIN = 0x68 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d DLT_PFLOG = 0x75 DLT_PFSYNC = 0x12 + DLT_PPI = 0xc0 DLT_PPP = 0x9 DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 + DLT_PRISM_HEADER = 0x77 DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 DLT_RAW = 0xc + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 DLT_SLIP = 0x8 DLT_SLIP_BSDOS = 0xf + DLT_STANAG_5066_D_PDU = 0xed + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WIHART = 0xdf + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 DT_BLK = 0x6 DT_CHR = 0x2 DT_DIR = 0x4 @@ -196,13 +350,14 @@ const ( ECHONL = 0x10 ECHOPRT = 0x20 EVFILT_AIO = -0x3 + EVFILT_EXCEPT = -0xf EVFILT_FS = -0x9 EVFILT_MACHPORT = -0x8 EVFILT_PROC = -0x5 EVFILT_READ = -0x1 EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0xe - EVFILT_THREADMARKER = 0xe + EVFILT_SYSCOUNT = 0xf + EVFILT_THREADMARKER = 0xf EVFILT_TIMER = -0x7 EVFILT_USER = -0xa EVFILT_VM = -0xc @@ -213,6 +368,7 @@ const ( EV_DELETE = 0x2 EV_DISABLE = 0x8 EV_DISPATCH = 0x80 + EV_DISPATCH2 = 0x180 EV_ENABLE = 0x4 EV_EOF = 0x8000 EV_ERROR = 0x4000 @@ -223,16 +379,25 @@ const ( EV_POLL = 0x1000 EV_RECEIPT = 0x40 EV_SYSFLAGS = 0xf000 + EV_UDATA_SPECIFIC = 0x100 + EV_VANISHED = 0x200 EXTA = 0x4b00 EXTB = 0x9600 EXTPROC = 0x800 FD_CLOEXEC = 0x1 FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x4000 + FFDLY = 0x4000 FLUSHO = 0x800000 F_ADDFILESIGS = 0x3d + F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 + F_ADDFILESIGS_RETURN = 0x61 F_ADDSIGS = 0x3b F_ALLOCATEALL = 0x4 F_ALLOCATECONTIG = 0x2 + F_BARRIERFSYNC = 0x55 + F_CHECK_LV = 0x62 F_CHKCLEAN = 0x29 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x43 @@ -347,6 +512,7 @@ const ( IFT_PDP = 0xff IFT_PFLOG = 0xf5 IFT_PFSYNC = 0xf6 + IFT_PKTAP = 0xfe IFT_PPP = 0x17 IFT_PROPMUX = 0x36 IFT_PROPVIRTUAL = 0x35 @@ -515,7 +681,7 @@ const ( IPV6_FAITH = 0x1d IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 - IPV6_FRAGTTL = 0x78 + IPV6_FRAGTTL = 0x3c IPV6_FW_ADD = 0x1e IPV6_FW_DEL = 0x1f IPV6_FW_FLUSH = 0x20 @@ -633,11 +799,13 @@ const ( MADV_FREE_REUSABLE = 0x7 MADV_FREE_REUSE = 0x8 MADV_NORMAL = 0x0 + MADV_PAGEOUT = 0xa MADV_RANDOM = 0x1 MADV_SEQUENTIAL = 0x2 MADV_WILLNEED = 0x3 MADV_ZERO_WIRED_PAGES = 0x6 MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 MAP_COPY = 0x2 MAP_FILE = 0x0 MAP_FIXED = 0x10 @@ -649,9 +817,43 @@ const ( MAP_PRIVATE = 0x2 MAP_RENAME = 0x20 MAP_RESERVED0080 = 0x80 + MAP_RESILIENT_CODESIGN = 0x2000 + MAP_RESILIENT_MEDIA = 0x4000 MAP_SHARED = 0x1 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_AUTOMOUNTED = 0x400000 + MNT_CMDFLAGS = 0xf0000 + MNT_CPROTECT = 0x80 + MNT_DEFWRITE = 0x2000000 + MNT_DONTBROWSE = 0x100000 + MNT_DOVOLFS = 0x8000 + MNT_DWAIT = 0x4 + MNT_EXPORTED = 0x100 + MNT_FORCE = 0x80000 + MNT_IGNORE_OWNERSHIP = 0x200000 + MNT_JOURNALED = 0x800000 + MNT_LOCAL = 0x1000 + MNT_MULTILABEL = 0x4000000 + MNT_NOATIME = 0x10000000 + MNT_NOBLOCK = 0x20000 + MNT_NODEV = 0x10 + MNT_NOEXEC = 0x4 + MNT_NOSUID = 0x8 + MNT_NOUSERXATTR = 0x1000000 + MNT_NOWAIT = 0x2 + MNT_QUARANTINE = 0x400 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELOAD = 0x40000 + MNT_ROOTFS = 0x4000 + MNT_SYNCHRONOUS = 0x2 + MNT_UNION = 0x20 + MNT_UNKNOWNPERMISSIONS = 0x200000 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0x17f0f5ff + MNT_WAIT = 0x1 MSG_CTRUNC = 0x20 MSG_DONTROUTE = 0x4 MSG_DONTWAIT = 0x80 @@ -682,7 +884,13 @@ const ( NET_RT_MAXID = 0xa NET_RT_STAT = 0x4 NET_RT_TRASH = 0x5 + NL0 = 0x0 + NL1 = 0x100 + NL2 = 0x200 + NL3 = 0x300 + NLDLY = 0x300 NOFLSH = 0x80000000 + NOKERNINFO = 0x2000000 NOTE_ABSOLUTE = 0x8 NOTE_ATTRIB = 0x8 NOTE_BACKGROUND = 0x40 @@ -706,11 +914,14 @@ const ( NOTE_FFNOP = 0x0 NOTE_FFOR = 0x80000000 NOTE_FORK = 0x40000000 + NOTE_FUNLOCK = 0x100 NOTE_LEEWAY = 0x10 NOTE_LINK = 0x10 NOTE_LOWAT = 0x1 + NOTE_MACH_CONTINUOUS_TIME = 0x80 NOTE_NONE = 0x80 NOTE_NSECONDS = 0x4 + NOTE_OOB = 0x2 NOTE_PCTRLMASK = -0x100000 NOTE_PDATAMASK = 0xfffff NOTE_REAP = 0x10000000 @@ -735,6 +946,7 @@ const ( ONOCR = 0x20 ONOEOT = 0x8 OPOST = 0x1 + OXTABS = 0x4 O_ACCMODE = 0x3 O_ALERT = 0x20000000 O_APPEND = 0x8 @@ -743,6 +955,7 @@ const ( O_CREAT = 0x200 O_DIRECTORY = 0x100000 O_DP_GETRAWENCRYPTED = 0x1 + O_DP_GETRAWUNENCRYPTED = 0x2 O_DSYNC = 0x400000 O_EVTONLY = 0x8000 O_EXCL = 0x800 @@ -795,7 +1008,10 @@ const ( RLIMIT_CPU_USAGE_MONITOR = 0x2 RLIMIT_DATA = 0x2 RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 RLIMIT_STACK = 0x3 RLIM_INFINITY = 0x7fffffffffffffff RTAX_AUTHOR = 0x6 @@ -830,6 +1046,7 @@ const ( RTF_LOCAL = 0x200000 RTF_MODIFIED = 0x20 RTF_MULTICAST = 0x800000 + RTF_NOIFREF = 0x2000 RTF_PINNED = 0x100000 RTF_PRCLONING = 0x10000 RTF_PROTO1 = 0x8000 @@ -964,6 +1181,8 @@ const ( SO_LABEL = 0x1010 SO_LINGER = 0x80 SO_LINGER_SEC = 0x1080 + SO_NETSVC_MARKING_LEVEL = 0x1119 + SO_NET_SERVICE_TYPE = 0x1116 SO_NKE = 0x1021 SO_NOADDRERR = 0x1023 SO_NOSIGPIPE = 0x1022 @@ -1019,11 +1238,22 @@ const ( S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x400 + TAB2 = 0x800 + TAB3 = 0x4 + TABDLY = 0xc04 TCIFLUSH = 0x1 + TCIOFF = 0x3 TCIOFLUSH = 0x3 + TCION = 0x4 TCOFLUSH = 0x2 + TCOOFF = 0x1 + TCOON = 0x2 TCP_CONNECTIONTIMEOUT = 0x20 + TCP_CONNECTION_INFO = 0x106 TCP_ENABLE_ECN = 0x104 + TCP_FASTOPEN = 0x105 TCP_KEEPALIVE = 0x10 TCP_KEEPCNT = 0x102 TCP_KEEPINTVL = 0x101 @@ -1123,6 +1353,11 @@ const ( VKILL = 0x5 VLNEXT = 0xe VMIN = 0x10 + VM_LOADAVG = 0x2 + VM_MACHFACTOR = 0x4 + VM_MAXID = 0x6 + VM_METER = 0x1 + VM_SWAPUSAGE = 0x5 VQUIT = 0x9 VREPRINT = 0x6 VSTART = 0xc @@ -1291,3 +1526,148 @@ const ( SIGXCPU = syscall.Signal(0x18) SIGXFSZ = syscall.Signal(0x19) ) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "resource busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "operation timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "device power is off", + 83: "device error", + 84: "value too large to be stored in data type", + 85: "bad executable (or shared library)", + 86: "bad CPU type in executable", + 87: "shared library version mismatch", + 88: "malformed Mach-o file", + 89: "operation canceled", + 90: "identifier removed", + 91: "no message of desired type", + 92: "illegal byte sequence", + 93: "attribute not found", + 94: "bad message", + 95: "EMULTIHOP (Reserved)", + 96: "no message available on STREAM", + 97: "ENOLINK (Reserved)", + 98: "no STREAM resources", + 99: "not a STREAM", + 100: "protocol error", + 101: "STREAM ioctl timeout", + 102: "operation not supported on socket", + 103: "policy not found", + 104: "state not recoverable", + 105: "previous owner died", + 106: "interface output queue is full", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "suspended (signal)", + 18: "suspended", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index 3189c6b34..cc8cc5b57 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -1,5 +1,5 @@ // mkerrors.sh -m64 -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build arm64,darwin @@ -48,6 +48,7 @@ const ( AF_UNIX = 0x1 AF_UNSPEC = 0x0 AF_UTUN = 0x26 + ALTWERASE = 0x200 B0 = 0x0 B110 = 0x6e B115200 = 0x1c200 @@ -138,9 +139,26 @@ const ( BPF_W = 0x0 BPF_X = 0x8 BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x8000 + BSDLY = 0x8000 CFLUSH = 0xf CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_MONOTONIC_RAW_APPROX = 0x5 + CLOCK_PROCESS_CPUTIME_ID = 0xc + CLOCK_REALTIME = 0x0 + CLOCK_THREAD_CPUTIME_ID = 0x10 + CLOCK_UPTIME_RAW = 0x8 + CLOCK_UPTIME_RAW_APPROX = 0x9 + CR0 = 0x0 + CR1 = 0x1000 + CR2 = 0x2000 + CR3 = 0x3000 + CRDLY = 0x3000 CREAD = 0x800 + CRTSCTS = 0x30000 CS5 = 0x0 CS6 = 0x100 CS7 = 0x200 @@ -332,13 +350,14 @@ const ( ECHONL = 0x10 ECHOPRT = 0x20 EVFILT_AIO = -0x3 + EVFILT_EXCEPT = -0xf EVFILT_FS = -0x9 EVFILT_MACHPORT = -0x8 EVFILT_PROC = -0x5 EVFILT_READ = -0x1 EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0xe - EVFILT_THREADMARKER = 0xe + EVFILT_SYSCOUNT = 0xf + EVFILT_THREADMARKER = 0xf EVFILT_TIMER = -0x7 EVFILT_USER = -0xa EVFILT_VM = -0xc @@ -349,6 +368,7 @@ const ( EV_DELETE = 0x2 EV_DISABLE = 0x8 EV_DISPATCH = 0x80 + EV_DISPATCH2 = 0x180 EV_ENABLE = 0x4 EV_EOF = 0x8000 EV_ERROR = 0x4000 @@ -359,16 +379,25 @@ const ( EV_POLL = 0x1000 EV_RECEIPT = 0x40 EV_SYSFLAGS = 0xf000 + EV_UDATA_SPECIFIC = 0x100 + EV_VANISHED = 0x200 EXTA = 0x4b00 EXTB = 0x9600 EXTPROC = 0x800 FD_CLOEXEC = 0x1 FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x4000 + FFDLY = 0x4000 FLUSHO = 0x800000 F_ADDFILESIGS = 0x3d + F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 + F_ADDFILESIGS_RETURN = 0x61 F_ADDSIGS = 0x3b F_ALLOCATEALL = 0x4 F_ALLOCATECONTIG = 0x2 + F_BARRIERFSYNC = 0x55 + F_CHECK_LV = 0x62 F_CHKCLEAN = 0x29 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x43 @@ -770,11 +799,13 @@ const ( MADV_FREE_REUSABLE = 0x7 MADV_FREE_REUSE = 0x8 MADV_NORMAL = 0x0 + MADV_PAGEOUT = 0xa MADV_RANDOM = 0x1 MADV_SEQUENTIAL = 0x2 MADV_WILLNEED = 0x3 MADV_ZERO_WIRED_PAGES = 0x6 MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 MAP_COPY = 0x2 MAP_FILE = 0x0 MAP_FIXED = 0x10 @@ -786,9 +817,43 @@ const ( MAP_PRIVATE = 0x2 MAP_RENAME = 0x20 MAP_RESERVED0080 = 0x80 + MAP_RESILIENT_CODESIGN = 0x2000 + MAP_RESILIENT_MEDIA = 0x4000 MAP_SHARED = 0x1 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_AUTOMOUNTED = 0x400000 + MNT_CMDFLAGS = 0xf0000 + MNT_CPROTECT = 0x80 + MNT_DEFWRITE = 0x2000000 + MNT_DONTBROWSE = 0x100000 + MNT_DOVOLFS = 0x8000 + MNT_DWAIT = 0x4 + MNT_EXPORTED = 0x100 + MNT_FORCE = 0x80000 + MNT_IGNORE_OWNERSHIP = 0x200000 + MNT_JOURNALED = 0x800000 + MNT_LOCAL = 0x1000 + MNT_MULTILABEL = 0x4000000 + MNT_NOATIME = 0x10000000 + MNT_NOBLOCK = 0x20000 + MNT_NODEV = 0x10 + MNT_NOEXEC = 0x4 + MNT_NOSUID = 0x8 + MNT_NOUSERXATTR = 0x1000000 + MNT_NOWAIT = 0x2 + MNT_QUARANTINE = 0x400 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELOAD = 0x40000 + MNT_ROOTFS = 0x4000 + MNT_SYNCHRONOUS = 0x2 + MNT_UNION = 0x20 + MNT_UNKNOWNPERMISSIONS = 0x200000 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0x17f0f5ff + MNT_WAIT = 0x1 MSG_CTRUNC = 0x20 MSG_DONTROUTE = 0x4 MSG_DONTWAIT = 0x80 @@ -819,7 +884,13 @@ const ( NET_RT_MAXID = 0xa NET_RT_STAT = 0x4 NET_RT_TRASH = 0x5 + NL0 = 0x0 + NL1 = 0x100 + NL2 = 0x200 + NL3 = 0x300 + NLDLY = 0x300 NOFLSH = 0x80000000 + NOKERNINFO = 0x2000000 NOTE_ABSOLUTE = 0x8 NOTE_ATTRIB = 0x8 NOTE_BACKGROUND = 0x40 @@ -843,11 +914,14 @@ const ( NOTE_FFNOP = 0x0 NOTE_FFOR = 0x80000000 NOTE_FORK = 0x40000000 + NOTE_FUNLOCK = 0x100 NOTE_LEEWAY = 0x10 NOTE_LINK = 0x10 NOTE_LOWAT = 0x1 + NOTE_MACH_CONTINUOUS_TIME = 0x80 NOTE_NONE = 0x80 NOTE_NSECONDS = 0x4 + NOTE_OOB = 0x2 NOTE_PCTRLMASK = -0x100000 NOTE_PDATAMASK = 0xfffff NOTE_REAP = 0x10000000 @@ -872,6 +946,7 @@ const ( ONOCR = 0x20 ONOEOT = 0x8 OPOST = 0x1 + OXTABS = 0x4 O_ACCMODE = 0x3 O_ALERT = 0x20000000 O_APPEND = 0x8 @@ -880,6 +955,7 @@ const ( O_CREAT = 0x200 O_DIRECTORY = 0x100000 O_DP_GETRAWENCRYPTED = 0x1 + O_DP_GETRAWUNENCRYPTED = 0x2 O_DSYNC = 0x400000 O_EVTONLY = 0x8000 O_EXCL = 0x800 @@ -932,7 +1008,10 @@ const ( RLIMIT_CPU_USAGE_MONITOR = 0x2 RLIMIT_DATA = 0x2 RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 RLIMIT_STACK = 0x3 RLIM_INFINITY = 0x7fffffffffffffff RTAX_AUTHOR = 0x6 @@ -1102,6 +1181,8 @@ const ( SO_LABEL = 0x1010 SO_LINGER = 0x80 SO_LINGER_SEC = 0x1080 + SO_NETSVC_MARKING_LEVEL = 0x1119 + SO_NET_SERVICE_TYPE = 0x1116 SO_NKE = 0x1021 SO_NOADDRERR = 0x1023 SO_NOSIGPIPE = 0x1022 @@ -1157,11 +1238,22 @@ const ( S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x400 + TAB2 = 0x800 + TAB3 = 0x4 + TABDLY = 0xc04 TCIFLUSH = 0x1 + TCIOFF = 0x3 TCIOFLUSH = 0x3 + TCION = 0x4 TCOFLUSH = 0x2 + TCOOFF = 0x1 + TCOON = 0x2 TCP_CONNECTIONTIMEOUT = 0x20 + TCP_CONNECTION_INFO = 0x106 TCP_ENABLE_ECN = 0x104 + TCP_FASTOPEN = 0x105 TCP_KEEPALIVE = 0x10 TCP_KEEPCNT = 0x102 TCP_KEEPINTVL = 0x101 @@ -1261,6 +1353,11 @@ const ( VKILL = 0x5 VLNEXT = 0xe VMIN = 0x10 + VM_LOADAVG = 0x2 + VM_MACHFACTOR = 0x4 + VM_MAXID = 0x6 + VM_METER = 0x1 + VM_SWAPUSAGE = 0x5 VQUIT = 0x9 VREPRINT = 0x6 VSTART = 0xc diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go index 7b95751c3..1d3eec44d 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go @@ -1,5 +1,5 @@ // mkerrors.sh -m32 -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build 386,freebsd @@ -11,1456 +11,1419 @@ package unix import "syscall" const ( - AF_APPLETALK = 0x10 - AF_ARP = 0x23 - AF_ATM = 0x1e - AF_BLUETOOTH = 0x24 - AF_CCITT = 0xa - AF_CHAOS = 0x5 - AF_CNT = 0x15 - AF_COIP = 0x14 - AF_DATAKIT = 0x9 - AF_DECnet = 0xc - AF_DLI = 0xd - AF_E164 = 0x1a - AF_ECMA = 0x8 - AF_HYLINK = 0xf - AF_IEEE80211 = 0x25 - AF_IMPLINK = 0x3 - AF_INET = 0x2 - AF_INET6 = 0x1c - AF_INET6_SDP = 0x2a - AF_INET_SDP = 0x28 - AF_IPX = 0x17 - AF_ISDN = 0x1a - AF_ISO = 0x7 - AF_LAT = 0xe - AF_LINK = 0x12 - AF_LOCAL = 0x1 - AF_MAX = 0x2a - AF_NATM = 0x1d - AF_NETBIOS = 0x6 - AF_NETGRAPH = 0x20 - AF_OSI = 0x7 - AF_PUP = 0x4 - AF_ROUTE = 0x11 - AF_SCLUSTER = 0x22 - AF_SIP = 0x18 - AF_SLOW = 0x21 - AF_SNA = 0xb - AF_UNIX = 0x1 - AF_UNSPEC = 0x0 - AF_VENDOR00 = 0x27 - AF_VENDOR01 = 0x29 - AF_VENDOR02 = 0x2b - AF_VENDOR03 = 0x2d - AF_VENDOR04 = 0x2f - AF_VENDOR05 = 0x31 - AF_VENDOR06 = 0x33 - AF_VENDOR07 = 0x35 - AF_VENDOR08 = 0x37 - AF_VENDOR09 = 0x39 - AF_VENDOR10 = 0x3b - AF_VENDOR11 = 0x3d - AF_VENDOR12 = 0x3f - AF_VENDOR13 = 0x41 - AF_VENDOR14 = 0x43 - AF_VENDOR15 = 0x45 - AF_VENDOR16 = 0x47 - AF_VENDOR17 = 0x49 - AF_VENDOR18 = 0x4b - AF_VENDOR19 = 0x4d - AF_VENDOR20 = 0x4f - AF_VENDOR21 = 0x51 - AF_VENDOR22 = 0x53 - AF_VENDOR23 = 0x55 - AF_VENDOR24 = 0x57 - AF_VENDOR25 = 0x59 - AF_VENDOR26 = 0x5b - AF_VENDOR27 = 0x5d - AF_VENDOR28 = 0x5f - AF_VENDOR29 = 0x61 - AF_VENDOR30 = 0x63 - AF_VENDOR31 = 0x65 - AF_VENDOR32 = 0x67 - AF_VENDOR33 = 0x69 - AF_VENDOR34 = 0x6b - AF_VENDOR35 = 0x6d - AF_VENDOR36 = 0x6f - AF_VENDOR37 = 0x71 - AF_VENDOR38 = 0x73 - AF_VENDOR39 = 0x75 - AF_VENDOR40 = 0x77 - AF_VENDOR41 = 0x79 - AF_VENDOR42 = 0x7b - AF_VENDOR43 = 0x7d - AF_VENDOR44 = 0x7f - AF_VENDOR45 = 0x81 - AF_VENDOR46 = 0x83 - AF_VENDOR47 = 0x85 - B0 = 0x0 - B110 = 0x6e - B115200 = 0x1c200 - B1200 = 0x4b0 - B134 = 0x86 - B14400 = 0x3840 - B150 = 0x96 - B1800 = 0x708 - B19200 = 0x4b00 - B200 = 0xc8 - B230400 = 0x38400 - B2400 = 0x960 - B28800 = 0x7080 - B300 = 0x12c - B38400 = 0x9600 - B460800 = 0x70800 - B4800 = 0x12c0 - B50 = 0x32 - B57600 = 0xe100 - B600 = 0x258 - B7200 = 0x1c20 - B75 = 0x4b - B76800 = 0x12c00 - B921600 = 0xe1000 - B9600 = 0x2580 - BIOCFEEDBACK = 0x8004427c - BIOCFLUSH = 0x20004268 - BIOCGBLEN = 0x40044266 - BIOCGDIRECTION = 0x40044276 - BIOCGDLT = 0x4004426a - BIOCGDLTLIST = 0xc0084279 - BIOCGETBUFMODE = 0x4004427d - BIOCGETIF = 0x4020426b - BIOCGETZMAX = 0x4004427f - BIOCGHDRCMPLT = 0x40044274 - BIOCGRSIG = 0x40044272 - BIOCGRTIMEOUT = 0x4008426e - BIOCGSEESENT = 0x40044276 - BIOCGSTATS = 0x4008426f - BIOCGTSTAMP = 0x40044283 - BIOCIMMEDIATE = 0x80044270 - BIOCLOCK = 0x2000427a - BIOCPROMISC = 0x20004269 - BIOCROTZBUF = 0x400c4280 - BIOCSBLEN = 0xc0044266 - BIOCSDIRECTION = 0x80044277 - BIOCSDLT = 0x80044278 - BIOCSETBUFMODE = 0x8004427e - BIOCSETF = 0x80084267 - BIOCSETFNR = 0x80084282 - BIOCSETIF = 0x8020426c - BIOCSETWF = 0x8008427b - BIOCSETZBUF = 0x800c4281 - BIOCSHDRCMPLT = 0x80044275 - BIOCSRSIG = 0x80044273 - BIOCSRTIMEOUT = 0x8008426d - BIOCSSEESENT = 0x80044277 - BIOCSTSTAMP = 0x80044284 - BIOCVERSION = 0x40044271 - BPF_A = 0x10 - BPF_ABS = 0x20 - BPF_ADD = 0x0 - BPF_ALIGNMENT = 0x4 - BPF_ALU = 0x4 - BPF_AND = 0x50 - BPF_B = 0x10 - BPF_BUFMODE_BUFFER = 0x1 - BPF_BUFMODE_ZBUF = 0x2 - BPF_DIV = 0x30 - BPF_H = 0x8 - BPF_IMM = 0x0 - BPF_IND = 0x40 - BPF_JA = 0x0 - BPF_JEQ = 0x10 - BPF_JGE = 0x30 - BPF_JGT = 0x20 - BPF_JMP = 0x5 - BPF_JSET = 0x40 - BPF_K = 0x0 - BPF_LD = 0x0 - BPF_LDX = 0x1 - BPF_LEN = 0x80 - BPF_LSH = 0x60 - BPF_MAJOR_VERSION = 0x1 - BPF_MAXBUFSIZE = 0x80000 - BPF_MAXINSNS = 0x200 - BPF_MEM = 0x60 - BPF_MEMWORDS = 0x10 - BPF_MINBUFSIZE = 0x20 - BPF_MINOR_VERSION = 0x1 - BPF_MISC = 0x7 - BPF_MSH = 0xa0 - BPF_MUL = 0x20 - BPF_NEG = 0x80 - BPF_OR = 0x40 - BPF_RELEASE = 0x30bb6 - BPF_RET = 0x6 - BPF_RSH = 0x70 - BPF_ST = 0x2 - BPF_STX = 0x3 - BPF_SUB = 0x10 - BPF_TAX = 0x0 - BPF_TXA = 0x80 - BPF_T_BINTIME = 0x2 - BPF_T_BINTIME_FAST = 0x102 - BPF_T_BINTIME_MONOTONIC = 0x202 - BPF_T_BINTIME_MONOTONIC_FAST = 0x302 - BPF_T_FAST = 0x100 - BPF_T_FLAG_MASK = 0x300 - BPF_T_FORMAT_MASK = 0x3 - BPF_T_MICROTIME = 0x0 - BPF_T_MICROTIME_FAST = 0x100 - BPF_T_MICROTIME_MONOTONIC = 0x200 - BPF_T_MICROTIME_MONOTONIC_FAST = 0x300 - BPF_T_MONOTONIC = 0x200 - BPF_T_MONOTONIC_FAST = 0x300 - BPF_T_NANOTIME = 0x1 - BPF_T_NANOTIME_FAST = 0x101 - BPF_T_NANOTIME_MONOTONIC = 0x201 - BPF_T_NANOTIME_MONOTONIC_FAST = 0x301 - BPF_T_NONE = 0x3 - BPF_T_NORMAL = 0x0 - BPF_W = 0x0 - BPF_X = 0x8 - BRKINT = 0x2 - CFLUSH = 0xf - CLOCAL = 0x8000 - CLOCK_MONOTONIC = 0x4 - CLOCK_MONOTONIC_FAST = 0xc - CLOCK_MONOTONIC_PRECISE = 0xb - CLOCK_PROCESS_CPUTIME_ID = 0xf - CLOCK_PROF = 0x2 - CLOCK_REALTIME = 0x0 - CLOCK_REALTIME_FAST = 0xa - CLOCK_REALTIME_PRECISE = 0x9 - CLOCK_SECOND = 0xd - CLOCK_THREAD_CPUTIME_ID = 0xe - CLOCK_UPTIME = 0x5 - CLOCK_UPTIME_FAST = 0x8 - CLOCK_UPTIME_PRECISE = 0x7 - CLOCK_VIRTUAL = 0x1 - CREAD = 0x800 - CS5 = 0x0 - CS6 = 0x100 - CS7 = 0x200 - CS8 = 0x300 - CSIZE = 0x300 - CSTART = 0x11 - CSTATUS = 0x14 - CSTOP = 0x13 - CSTOPB = 0x400 - CSUSP = 0x1a - CTL_MAXNAME = 0x18 - CTL_NET = 0x4 - DLT_A429 = 0xb8 - DLT_A653_ICM = 0xb9 - DLT_AIRONET_HEADER = 0x78 - DLT_AOS = 0xde - DLT_APPLE_IP_OVER_IEEE1394 = 0x8a - DLT_ARCNET = 0x7 - DLT_ARCNET_LINUX = 0x81 - DLT_ATM_CLIP = 0x13 - DLT_ATM_RFC1483 = 0xb - DLT_AURORA = 0x7e - DLT_AX25 = 0x3 - DLT_AX25_KISS = 0xca - DLT_BACNET_MS_TP = 0xa5 - DLT_BLUETOOTH_HCI_H4 = 0xbb - DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 - DLT_CAN20B = 0xbe - DLT_CAN_SOCKETCAN = 0xe3 - DLT_CHAOS = 0x5 - DLT_CHDLC = 0x68 - DLT_CISCO_IOS = 0x76 - DLT_C_HDLC = 0x68 - DLT_C_HDLC_WITH_DIR = 0xcd - DLT_DBUS = 0xe7 - DLT_DECT = 0xdd - DLT_DOCSIS = 0x8f - DLT_DVB_CI = 0xeb - DLT_ECONET = 0x73 - DLT_EN10MB = 0x1 - DLT_EN3MB = 0x2 - DLT_ENC = 0x6d - DLT_ERF = 0xc5 - DLT_ERF_ETH = 0xaf - DLT_ERF_POS = 0xb0 - DLT_FC_2 = 0xe0 - DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 - DLT_FDDI = 0xa - DLT_FLEXRAY = 0xd2 - DLT_FRELAY = 0x6b - DLT_FRELAY_WITH_DIR = 0xce - DLT_GCOM_SERIAL = 0xad - DLT_GCOM_T1E1 = 0xac - DLT_GPF_F = 0xab - DLT_GPF_T = 0xaa - DLT_GPRS_LLC = 0xa9 - DLT_GSMTAP_ABIS = 0xda - DLT_GSMTAP_UM = 0xd9 - DLT_HHDLC = 0x79 - DLT_IBM_SN = 0x92 - DLT_IBM_SP = 0x91 - DLT_IEEE802 = 0x6 - DLT_IEEE802_11 = 0x69 - DLT_IEEE802_11_RADIO = 0x7f - DLT_IEEE802_11_RADIO_AVS = 0xa3 - DLT_IEEE802_15_4 = 0xc3 - DLT_IEEE802_15_4_LINUX = 0xbf - DLT_IEEE802_15_4_NOFCS = 0xe6 - DLT_IEEE802_15_4_NONASK_PHY = 0xd7 - DLT_IEEE802_16_MAC_CPS = 0xbc - DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 - DLT_IPFILTER = 0x74 - DLT_IPMB = 0xc7 - DLT_IPMB_LINUX = 0xd1 - DLT_IPNET = 0xe2 - DLT_IPOIB = 0xf2 - DLT_IPV4 = 0xe4 - DLT_IPV6 = 0xe5 - DLT_IP_OVER_FC = 0x7a - DLT_JUNIPER_ATM1 = 0x89 - DLT_JUNIPER_ATM2 = 0x87 - DLT_JUNIPER_ATM_CEMIC = 0xee - DLT_JUNIPER_CHDLC = 0xb5 - DLT_JUNIPER_ES = 0x84 - DLT_JUNIPER_ETHER = 0xb2 - DLT_JUNIPER_FIBRECHANNEL = 0xea - DLT_JUNIPER_FRELAY = 0xb4 - DLT_JUNIPER_GGSN = 0x85 - DLT_JUNIPER_ISM = 0xc2 - DLT_JUNIPER_MFR = 0x86 - DLT_JUNIPER_MLFR = 0x83 - DLT_JUNIPER_MLPPP = 0x82 - DLT_JUNIPER_MONITOR = 0xa4 - DLT_JUNIPER_PIC_PEER = 0xae - DLT_JUNIPER_PPP = 0xb3 - DLT_JUNIPER_PPPOE = 0xa7 - DLT_JUNIPER_PPPOE_ATM = 0xa8 - DLT_JUNIPER_SERVICES = 0x88 - DLT_JUNIPER_SRX_E2E = 0xe9 - DLT_JUNIPER_ST = 0xc8 - DLT_JUNIPER_VP = 0xb7 - DLT_JUNIPER_VS = 0xe8 - DLT_LAPB_WITH_DIR = 0xcf - DLT_LAPD = 0xcb - DLT_LIN = 0xd4 - DLT_LINUX_EVDEV = 0xd8 - DLT_LINUX_IRDA = 0x90 - DLT_LINUX_LAPD = 0xb1 - DLT_LINUX_PPP_WITHDIRECTION = 0xa6 - DLT_LINUX_SLL = 0x71 - DLT_LOOP = 0x6c - DLT_LTALK = 0x72 - DLT_MATCHING_MAX = 0xf6 - DLT_MATCHING_MIN = 0x68 - DLT_MFR = 0xb6 - DLT_MOST = 0xd3 - DLT_MPEG_2_TS = 0xf3 - DLT_MPLS = 0xdb - DLT_MTP2 = 0x8c - DLT_MTP2_WITH_PHDR = 0x8b - DLT_MTP3 = 0x8d - DLT_MUX27010 = 0xec - DLT_NETANALYZER = 0xf0 - DLT_NETANALYZER_TRANSPARENT = 0xf1 - DLT_NFC_LLCP = 0xf5 - DLT_NFLOG = 0xef - DLT_NG40 = 0xf4 - DLT_NULL = 0x0 - DLT_PCI_EXP = 0x7d - DLT_PFLOG = 0x75 - DLT_PFSYNC = 0x79 - DLT_PPI = 0xc0 - DLT_PPP = 0x9 - DLT_PPP_BSDOS = 0x10 - DLT_PPP_ETHER = 0x33 - DLT_PPP_PPPD = 0xa6 - DLT_PPP_SERIAL = 0x32 - DLT_PPP_WITH_DIR = 0xcc - DLT_PPP_WITH_DIRECTION = 0xa6 - DLT_PRISM_HEADER = 0x77 - DLT_PRONET = 0x4 - DLT_RAIF1 = 0xc6 - DLT_RAW = 0xc - DLT_RIO = 0x7c - DLT_SCCP = 0x8e - DLT_SITA = 0xc4 - DLT_SLIP = 0x8 - DLT_SLIP_BSDOS = 0xf - DLT_STANAG_5066_D_PDU = 0xed - DLT_SUNATM = 0x7b - DLT_SYMANTEC_FIREWALL = 0x63 - DLT_TZSP = 0x80 - DLT_USB = 0xba - DLT_USB_LINUX = 0xbd - DLT_USB_LINUX_MMAPPED = 0xdc - DLT_USER0 = 0x93 - DLT_USER1 = 0x94 - DLT_USER10 = 0x9d - DLT_USER11 = 0x9e - DLT_USER12 = 0x9f - DLT_USER13 = 0xa0 - DLT_USER14 = 0xa1 - DLT_USER15 = 0xa2 - DLT_USER2 = 0x95 - DLT_USER3 = 0x96 - DLT_USER4 = 0x97 - DLT_USER5 = 0x98 - DLT_USER6 = 0x99 - DLT_USER7 = 0x9a - DLT_USER8 = 0x9b - DLT_USER9 = 0x9c - DLT_WIHART = 0xdf - DLT_X2E_SERIAL = 0xd5 - DLT_X2E_XORAYA = 0xd6 - DT_BLK = 0x6 - DT_CHR = 0x2 - DT_DIR = 0x4 - DT_FIFO = 0x1 - DT_LNK = 0xa - DT_REG = 0x8 - DT_SOCK = 0xc - DT_UNKNOWN = 0x0 - DT_WHT = 0xe - ECHO = 0x8 - ECHOCTL = 0x40 - ECHOE = 0x2 - ECHOK = 0x4 - ECHOKE = 0x1 - ECHONL = 0x10 - ECHOPRT = 0x20 - EVFILT_AIO = -0x3 - EVFILT_FS = -0x9 - EVFILT_LIO = -0xa - EVFILT_PROC = -0x5 - EVFILT_READ = -0x1 - EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0xb - EVFILT_TIMER = -0x7 - EVFILT_USER = -0xb - EVFILT_VNODE = -0x4 - EVFILT_WRITE = -0x2 - EV_ADD = 0x1 - EV_CLEAR = 0x20 - EV_DELETE = 0x2 - EV_DISABLE = 0x8 - EV_DISPATCH = 0x80 - EV_DROP = 0x1000 - EV_ENABLE = 0x4 - EV_EOF = 0x8000 - EV_ERROR = 0x4000 - EV_FLAG1 = 0x2000 - EV_ONESHOT = 0x10 - EV_RECEIPT = 0x40 - EV_SYSFLAGS = 0xf000 - EXTA = 0x4b00 - EXTATTR_NAMESPACE_EMPTY = 0x0 - EXTATTR_NAMESPACE_SYSTEM = 0x2 - EXTATTR_NAMESPACE_USER = 0x1 - EXTB = 0x9600 - EXTPROC = 0x800 - FD_CLOEXEC = 0x1 - FD_SETSIZE = 0x400 - FLUSHO = 0x800000 - F_CANCEL = 0x5 - F_DUP2FD = 0xa - F_DUP2FD_CLOEXEC = 0x12 - F_DUPFD = 0x0 - F_DUPFD_CLOEXEC = 0x11 - F_GETFD = 0x1 - F_GETFL = 0x3 - F_GETLK = 0xb - F_GETOWN = 0x5 - F_OGETLK = 0x7 - F_OK = 0x0 - F_OSETLK = 0x8 - F_OSETLKW = 0x9 - F_RDAHEAD = 0x10 - F_RDLCK = 0x1 - F_READAHEAD = 0xf - F_SETFD = 0x2 - F_SETFL = 0x4 - F_SETLK = 0xc - F_SETLKW = 0xd - F_SETLK_REMOTE = 0xe - F_SETOWN = 0x6 - F_UNLCK = 0x2 - F_UNLCKSYS = 0x4 - F_WRLCK = 0x3 - HUPCL = 0x4000 - ICANON = 0x100 - ICMP6_FILTER = 0x12 - ICRNL = 0x100 - IEXTEN = 0x400 - IFAN_ARRIVAL = 0x0 - IFAN_DEPARTURE = 0x1 - IFF_ALLMULTI = 0x200 - IFF_ALTPHYS = 0x4000 - IFF_BROADCAST = 0x2 - IFF_CANTCHANGE = 0x218f72 - IFF_CANTCONFIG = 0x10000 - IFF_DEBUG = 0x4 - IFF_DRV_OACTIVE = 0x400 - IFF_DRV_RUNNING = 0x40 - IFF_DYING = 0x200000 - IFF_LINK0 = 0x1000 - IFF_LINK1 = 0x2000 - IFF_LINK2 = 0x4000 - IFF_LOOPBACK = 0x8 - IFF_MONITOR = 0x40000 - IFF_MULTICAST = 0x8000 - IFF_NOARP = 0x80 - IFF_OACTIVE = 0x400 - IFF_POINTOPOINT = 0x10 - IFF_PPROMISC = 0x20000 - IFF_PROMISC = 0x100 - IFF_RENAMING = 0x400000 - IFF_RUNNING = 0x40 - IFF_SIMPLEX = 0x800 - IFF_SMART = 0x20 - IFF_STATICARP = 0x80000 - IFF_UP = 0x1 - IFNAMSIZ = 0x10 - IFT_1822 = 0x2 - IFT_A12MPPSWITCH = 0x82 - IFT_AAL2 = 0xbb - IFT_AAL5 = 0x31 - IFT_ADSL = 0x5e - IFT_AFLANE8023 = 0x3b - IFT_AFLANE8025 = 0x3c - IFT_ARAP = 0x58 - IFT_ARCNET = 0x23 - IFT_ARCNETPLUS = 0x24 - IFT_ASYNC = 0x54 - IFT_ATM = 0x25 - IFT_ATMDXI = 0x69 - IFT_ATMFUNI = 0x6a - IFT_ATMIMA = 0x6b - IFT_ATMLOGICAL = 0x50 - IFT_ATMRADIO = 0xbd - IFT_ATMSUBINTERFACE = 0x86 - IFT_ATMVCIENDPT = 0xc2 - IFT_ATMVIRTUAL = 0x95 - IFT_BGPPOLICYACCOUNTING = 0xa2 - IFT_BRIDGE = 0xd1 - IFT_BSC = 0x53 - IFT_CARP = 0xf8 - IFT_CCTEMUL = 0x3d - IFT_CEPT = 0x13 - IFT_CES = 0x85 - IFT_CHANNEL = 0x46 - IFT_CNR = 0x55 - IFT_COFFEE = 0x84 - IFT_COMPOSITELINK = 0x9b - IFT_DCN = 0x8d - IFT_DIGITALPOWERLINE = 0x8a - IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba - IFT_DLSW = 0x4a - IFT_DOCSCABLEDOWNSTREAM = 0x80 - IFT_DOCSCABLEMACLAYER = 0x7f - IFT_DOCSCABLEUPSTREAM = 0x81 - IFT_DS0 = 0x51 - IFT_DS0BUNDLE = 0x52 - IFT_DS1FDL = 0xaa - IFT_DS3 = 0x1e - IFT_DTM = 0x8c - IFT_DVBASILN = 0xac - IFT_DVBASIOUT = 0xad - IFT_DVBRCCDOWNSTREAM = 0x93 - IFT_DVBRCCMACLAYER = 0x92 - IFT_DVBRCCUPSTREAM = 0x94 - IFT_ENC = 0xf4 - IFT_EON = 0x19 - IFT_EPLRS = 0x57 - IFT_ESCON = 0x49 - IFT_ETHER = 0x6 - IFT_FAITH = 0xf2 - IFT_FAST = 0x7d - IFT_FASTETHER = 0x3e - IFT_FASTETHERFX = 0x45 - IFT_FDDI = 0xf - IFT_FIBRECHANNEL = 0x38 - IFT_FRAMERELAYINTERCONNECT = 0x3a - IFT_FRAMERELAYMPI = 0x5c - IFT_FRDLCIENDPT = 0xc1 - IFT_FRELAY = 0x20 - IFT_FRELAYDCE = 0x2c - IFT_FRF16MFRBUNDLE = 0xa3 - IFT_FRFORWARD = 0x9e - IFT_G703AT2MB = 0x43 - IFT_G703AT64K = 0x42 - IFT_GIF = 0xf0 - IFT_GIGABITETHERNET = 0x75 - IFT_GR303IDT = 0xb2 - IFT_GR303RDT = 0xb1 - IFT_H323GATEKEEPER = 0xa4 - IFT_H323PROXY = 0xa5 - IFT_HDH1822 = 0x3 - IFT_HDLC = 0x76 - IFT_HDSL2 = 0xa8 - IFT_HIPERLAN2 = 0xb7 - IFT_HIPPI = 0x2f - IFT_HIPPIINTERFACE = 0x39 - IFT_HOSTPAD = 0x5a - IFT_HSSI = 0x2e - IFT_HY = 0xe - IFT_IBM370PARCHAN = 0x48 - IFT_IDSL = 0x9a - IFT_IEEE1394 = 0x90 - IFT_IEEE80211 = 0x47 - IFT_IEEE80212 = 0x37 - IFT_IEEE8023ADLAG = 0xa1 - IFT_IFGSN = 0x91 - IFT_IMT = 0xbe - IFT_INFINIBAND = 0xc7 - IFT_INTERLEAVE = 0x7c - IFT_IP = 0x7e - IFT_IPFORWARD = 0x8e - IFT_IPOVERATM = 0x72 - IFT_IPOVERCDLC = 0x6d - IFT_IPOVERCLAW = 0x6e - IFT_IPSWITCH = 0x4e - IFT_IPXIP = 0xf9 - IFT_ISDN = 0x3f - IFT_ISDNBASIC = 0x14 - IFT_ISDNPRIMARY = 0x15 - IFT_ISDNS = 0x4b - IFT_ISDNU = 0x4c - IFT_ISO88022LLC = 0x29 - IFT_ISO88023 = 0x7 - IFT_ISO88024 = 0x8 - IFT_ISO88025 = 0x9 - IFT_ISO88025CRFPINT = 0x62 - IFT_ISO88025DTR = 0x56 - IFT_ISO88025FIBER = 0x73 - IFT_ISO88026 = 0xa - IFT_ISUP = 0xb3 - IFT_L2VLAN = 0x87 - IFT_L3IPVLAN = 0x88 - IFT_L3IPXVLAN = 0x89 - IFT_LAPB = 0x10 - IFT_LAPD = 0x4d - IFT_LAPF = 0x77 - IFT_LOCALTALK = 0x2a - IFT_LOOP = 0x18 - IFT_MEDIAMAILOVERIP = 0x8b - IFT_MFSIGLINK = 0xa7 - IFT_MIOX25 = 0x26 - IFT_MODEM = 0x30 - IFT_MPC = 0x71 - IFT_MPLS = 0xa6 - IFT_MPLSTUNNEL = 0x96 - IFT_MSDSL = 0x8f - IFT_MVL = 0xbf - IFT_MYRINET = 0x63 - IFT_NFAS = 0xaf - IFT_NSIP = 0x1b - IFT_OPTICALCHANNEL = 0xc3 - IFT_OPTICALTRANSPORT = 0xc4 - IFT_OTHER = 0x1 - IFT_P10 = 0xc - IFT_P80 = 0xd - IFT_PARA = 0x22 - IFT_PFLOG = 0xf6 - IFT_PFSYNC = 0xf7 - IFT_PLC = 0xae - IFT_POS = 0xab - IFT_PPP = 0x17 - IFT_PPPMULTILINKBUNDLE = 0x6c - IFT_PROPBWAP2MP = 0xb8 - IFT_PROPCNLS = 0x59 - IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 - IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 - IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 - IFT_PROPMUX = 0x36 - IFT_PROPVIRTUAL = 0x35 - IFT_PROPWIRELESSP2P = 0x9d - IFT_PTPSERIAL = 0x16 - IFT_PVC = 0xf1 - IFT_QLLC = 0x44 - IFT_RADIOMAC = 0xbc - IFT_RADSL = 0x5f - IFT_REACHDSL = 0xc0 - IFT_RFC1483 = 0x9f - IFT_RS232 = 0x21 - IFT_RSRB = 0x4f - IFT_SDLC = 0x11 - IFT_SDSL = 0x60 - IFT_SHDSL = 0xa9 - IFT_SIP = 0x1f - IFT_SLIP = 0x1c - IFT_SMDSDXI = 0x2b - IFT_SMDSICIP = 0x34 - IFT_SONET = 0x27 - IFT_SONETOVERHEADCHANNEL = 0xb9 - IFT_SONETPATH = 0x32 - IFT_SONETVT = 0x33 - IFT_SRP = 0x97 - IFT_SS7SIGLINK = 0x9c - IFT_STACKTOSTACK = 0x6f - IFT_STARLAN = 0xb - IFT_STF = 0xd7 - IFT_T1 = 0x12 - IFT_TDLC = 0x74 - IFT_TERMPAD = 0x5b - IFT_TR008 = 0xb0 - IFT_TRANSPHDLC = 0x7b - IFT_TUNNEL = 0x83 - IFT_ULTRA = 0x1d - IFT_USB = 0xa0 - IFT_V11 = 0x40 - IFT_V35 = 0x2d - IFT_V36 = 0x41 - IFT_V37 = 0x78 - IFT_VDSL = 0x61 - IFT_VIRTUALIPADDRESS = 0x70 - IFT_VOICEEM = 0x64 - IFT_VOICEENCAP = 0x67 - IFT_VOICEFXO = 0x65 - IFT_VOICEFXS = 0x66 - IFT_VOICEOVERATM = 0x98 - IFT_VOICEOVERFRAMERELAY = 0x99 - IFT_VOICEOVERIP = 0x68 - IFT_X213 = 0x5d - IFT_X25 = 0x5 - IFT_X25DDN = 0x4 - IFT_X25HUNTGROUP = 0x7a - IFT_X25MLP = 0x79 - IFT_X25PLE = 0x28 - IFT_XETHER = 0x1a - IGNBRK = 0x1 - IGNCR = 0x80 - IGNPAR = 0x4 - IMAXBEL = 0x2000 - INLCR = 0x40 - INPCK = 0x10 - IN_CLASSA_HOST = 0xffffff - IN_CLASSA_MAX = 0x80 - IN_CLASSA_NET = 0xff000000 - IN_CLASSA_NSHIFT = 0x18 - IN_CLASSB_HOST = 0xffff - IN_CLASSB_MAX = 0x10000 - IN_CLASSB_NET = 0xffff0000 - IN_CLASSB_NSHIFT = 0x10 - IN_CLASSC_HOST = 0xff - IN_CLASSC_NET = 0xffffff00 - IN_CLASSC_NSHIFT = 0x8 - IN_CLASSD_HOST = 0xfffffff - IN_CLASSD_NET = 0xf0000000 - IN_CLASSD_NSHIFT = 0x1c - IN_LOOPBACKNET = 0x7f - IN_RFC3021_MASK = 0xfffffffe - IPPROTO_3PC = 0x22 - IPPROTO_ADFS = 0x44 - IPPROTO_AH = 0x33 - IPPROTO_AHIP = 0x3d - IPPROTO_APES = 0x63 - IPPROTO_ARGUS = 0xd - IPPROTO_AX25 = 0x5d - IPPROTO_BHA = 0x31 - IPPROTO_BLT = 0x1e - IPPROTO_BRSATMON = 0x4c - IPPROTO_CARP = 0x70 - IPPROTO_CFTP = 0x3e - IPPROTO_CHAOS = 0x10 - IPPROTO_CMTP = 0x26 - IPPROTO_CPHB = 0x49 - IPPROTO_CPNX = 0x48 - IPPROTO_DDP = 0x25 - IPPROTO_DGP = 0x56 - IPPROTO_DIVERT = 0x102 - IPPROTO_DONE = 0x101 - IPPROTO_DSTOPTS = 0x3c - IPPROTO_EGP = 0x8 - IPPROTO_EMCON = 0xe - IPPROTO_ENCAP = 0x62 - IPPROTO_EON = 0x50 - IPPROTO_ESP = 0x32 - IPPROTO_ETHERIP = 0x61 - IPPROTO_FRAGMENT = 0x2c - IPPROTO_GGP = 0x3 - IPPROTO_GMTP = 0x64 - IPPROTO_GRE = 0x2f - IPPROTO_HELLO = 0x3f - IPPROTO_HIP = 0x8b - IPPROTO_HMP = 0x14 - IPPROTO_HOPOPTS = 0x0 - IPPROTO_ICMP = 0x1 - IPPROTO_ICMPV6 = 0x3a - IPPROTO_IDP = 0x16 - IPPROTO_IDPR = 0x23 - IPPROTO_IDRP = 0x2d - IPPROTO_IGMP = 0x2 - IPPROTO_IGP = 0x55 - IPPROTO_IGRP = 0x58 - IPPROTO_IL = 0x28 - IPPROTO_INLSP = 0x34 - IPPROTO_INP = 0x20 - IPPROTO_IP = 0x0 - IPPROTO_IPCOMP = 0x6c - IPPROTO_IPCV = 0x47 - IPPROTO_IPEIP = 0x5e - IPPROTO_IPIP = 0x4 - IPPROTO_IPPC = 0x43 - IPPROTO_IPV4 = 0x4 - IPPROTO_IPV6 = 0x29 - IPPROTO_IRTP = 0x1c - IPPROTO_KRYPTOLAN = 0x41 - IPPROTO_LARP = 0x5b - IPPROTO_LEAF1 = 0x19 - IPPROTO_LEAF2 = 0x1a - IPPROTO_MAX = 0x100 - IPPROTO_MAXID = 0x34 - IPPROTO_MEAS = 0x13 - IPPROTO_MH = 0x87 - IPPROTO_MHRP = 0x30 - IPPROTO_MICP = 0x5f - IPPROTO_MOBILE = 0x37 - IPPROTO_MPLS = 0x89 - IPPROTO_MTP = 0x5c - IPPROTO_MUX = 0x12 - IPPROTO_ND = 0x4d - IPPROTO_NHRP = 0x36 - IPPROTO_NONE = 0x3b - IPPROTO_NSP = 0x1f - IPPROTO_NVPII = 0xb - IPPROTO_OLD_DIVERT = 0xfe - IPPROTO_OSPFIGP = 0x59 - IPPROTO_PFSYNC = 0xf0 - IPPROTO_PGM = 0x71 - IPPROTO_PIGP = 0x9 - IPPROTO_PIM = 0x67 - IPPROTO_PRM = 0x15 - IPPROTO_PUP = 0xc - IPPROTO_PVP = 0x4b - IPPROTO_RAW = 0xff - IPPROTO_RCCMON = 0xa - IPPROTO_RDP = 0x1b - IPPROTO_RESERVED_253 = 0xfd - IPPROTO_RESERVED_254 = 0xfe - IPPROTO_ROUTING = 0x2b - IPPROTO_RSVP = 0x2e - IPPROTO_RVD = 0x42 - IPPROTO_SATEXPAK = 0x40 - IPPROTO_SATMON = 0x45 - IPPROTO_SCCSP = 0x60 - IPPROTO_SCTP = 0x84 - IPPROTO_SDRP = 0x2a - IPPROTO_SEND = 0x103 - IPPROTO_SEP = 0x21 - IPPROTO_SHIM6 = 0x8c - IPPROTO_SKIP = 0x39 - IPPROTO_SPACER = 0x7fff - IPPROTO_SRPC = 0x5a - IPPROTO_ST = 0x7 - IPPROTO_SVMTP = 0x52 - IPPROTO_SWIPE = 0x35 - IPPROTO_TCF = 0x57 - IPPROTO_TCP = 0x6 - IPPROTO_TLSP = 0x38 - IPPROTO_TP = 0x1d - IPPROTO_TPXX = 0x27 - IPPROTO_TRUNK1 = 0x17 - IPPROTO_TRUNK2 = 0x18 - IPPROTO_TTP = 0x54 - IPPROTO_UDP = 0x11 - IPPROTO_UDPLITE = 0x88 - IPPROTO_VINES = 0x53 - IPPROTO_VISA = 0x46 - IPPROTO_VMTP = 0x51 - IPPROTO_WBEXPAK = 0x4f - IPPROTO_WBMON = 0x4e - IPPROTO_WSN = 0x4a - IPPROTO_XNET = 0xf - IPPROTO_XTP = 0x24 - IPV6_AUTOFLOWLABEL = 0x3b - IPV6_BINDANY = 0x40 - IPV6_BINDV6ONLY = 0x1b - IPV6_CHECKSUM = 0x1a - IPV6_DEFAULT_MULTICAST_HOPS = 0x1 - IPV6_DEFAULT_MULTICAST_LOOP = 0x1 - IPV6_DEFHLIM = 0x40 - IPV6_DONTFRAG = 0x3e - IPV6_DSTOPTS = 0x32 - IPV6_FAITH = 0x1d - IPV6_FLOWINFO_MASK = 0xffffff0f - IPV6_FLOWLABEL_MASK = 0xffff0f00 - IPV6_FRAGTTL = 0x78 - IPV6_FW_ADD = 0x1e - IPV6_FW_DEL = 0x1f - IPV6_FW_FLUSH = 0x20 - IPV6_FW_GET = 0x22 - IPV6_FW_ZERO = 0x21 - IPV6_HLIMDEC = 0x1 - IPV6_HOPLIMIT = 0x2f - IPV6_HOPOPTS = 0x31 - IPV6_IPSEC_POLICY = 0x1c - IPV6_JOIN_GROUP = 0xc - IPV6_LEAVE_GROUP = 0xd - IPV6_MAXHLIM = 0xff - IPV6_MAXOPTHDR = 0x800 - IPV6_MAXPACKET = 0xffff - IPV6_MAX_GROUP_SRC_FILTER = 0x200 - IPV6_MAX_MEMBERSHIPS = 0xfff - IPV6_MAX_SOCK_SRC_FILTER = 0x80 - IPV6_MIN_MEMBERSHIPS = 0x1f - IPV6_MMTU = 0x500 - IPV6_MSFILTER = 0x4a - IPV6_MULTICAST_HOPS = 0xa - IPV6_MULTICAST_IF = 0x9 - IPV6_MULTICAST_LOOP = 0xb - IPV6_NEXTHOP = 0x30 - IPV6_PATHMTU = 0x2c - IPV6_PKTINFO = 0x2e - IPV6_PORTRANGE = 0xe - IPV6_PORTRANGE_DEFAULT = 0x0 - IPV6_PORTRANGE_HIGH = 0x1 - IPV6_PORTRANGE_LOW = 0x2 - IPV6_PREFER_TEMPADDR = 0x3f - IPV6_RECVDSTOPTS = 0x28 - IPV6_RECVHOPLIMIT = 0x25 - IPV6_RECVHOPOPTS = 0x27 - IPV6_RECVPATHMTU = 0x2b - IPV6_RECVPKTINFO = 0x24 - IPV6_RECVRTHDR = 0x26 - IPV6_RECVTCLASS = 0x39 - IPV6_RTHDR = 0x33 - IPV6_RTHDRDSTOPTS = 0x23 - IPV6_RTHDR_LOOSE = 0x0 - IPV6_RTHDR_STRICT = 0x1 - IPV6_RTHDR_TYPE_0 = 0x0 - IPV6_SOCKOPT_RESERVED1 = 0x3 - IPV6_TCLASS = 0x3d - IPV6_UNICAST_HOPS = 0x4 - IPV6_USE_MIN_MTU = 0x2a - IPV6_V6ONLY = 0x1b - IPV6_VERSION = 0x60 - IPV6_VERSION_MASK = 0xf0 - IP_ADD_MEMBERSHIP = 0xc - IP_ADD_SOURCE_MEMBERSHIP = 0x46 - IP_BINDANY = 0x18 - IP_BLOCK_SOURCE = 0x48 - IP_DEFAULT_MULTICAST_LOOP = 0x1 - IP_DEFAULT_MULTICAST_TTL = 0x1 - IP_DF = 0x4000 - IP_DONTFRAG = 0x43 - IP_DROP_MEMBERSHIP = 0xd - IP_DROP_SOURCE_MEMBERSHIP = 0x47 - IP_DUMMYNET3 = 0x31 - IP_DUMMYNET_CONFIGURE = 0x3c - IP_DUMMYNET_DEL = 0x3d - IP_DUMMYNET_FLUSH = 0x3e - IP_DUMMYNET_GET = 0x40 - IP_FAITH = 0x16 - IP_FW3 = 0x30 - IP_FW_ADD = 0x32 - IP_FW_DEL = 0x33 - IP_FW_FLUSH = 0x34 - IP_FW_GET = 0x36 - IP_FW_NAT_CFG = 0x38 - IP_FW_NAT_DEL = 0x39 - IP_FW_NAT_GET_CONFIG = 0x3a - IP_FW_NAT_GET_LOG = 0x3b - IP_FW_RESETLOG = 0x37 - IP_FW_TABLE_ADD = 0x28 - IP_FW_TABLE_DEL = 0x29 - IP_FW_TABLE_FLUSH = 0x2a - IP_FW_TABLE_GETSIZE = 0x2b - IP_FW_TABLE_LIST = 0x2c - IP_FW_ZERO = 0x35 - IP_HDRINCL = 0x2 - IP_IPSEC_POLICY = 0x15 - IP_MAXPACKET = 0xffff - IP_MAX_GROUP_SRC_FILTER = 0x200 - IP_MAX_MEMBERSHIPS = 0xfff - IP_MAX_SOCK_MUTE_FILTER = 0x80 - IP_MAX_SOCK_SRC_FILTER = 0x80 - IP_MAX_SOURCE_FILTER = 0x400 - IP_MF = 0x2000 - IP_MINTTL = 0x42 - IP_MIN_MEMBERSHIPS = 0x1f - IP_MSFILTER = 0x4a - IP_MSS = 0x240 - IP_MULTICAST_IF = 0x9 - IP_MULTICAST_LOOP = 0xb - IP_MULTICAST_TTL = 0xa - IP_MULTICAST_VIF = 0xe - IP_OFFMASK = 0x1fff - IP_ONESBCAST = 0x17 - IP_OPTIONS = 0x1 - IP_PORTRANGE = 0x13 - IP_PORTRANGE_DEFAULT = 0x0 - IP_PORTRANGE_HIGH = 0x1 - IP_PORTRANGE_LOW = 0x2 - IP_RECVDSTADDR = 0x7 - IP_RECVIF = 0x14 - IP_RECVOPTS = 0x5 - IP_RECVRETOPTS = 0x6 - IP_RECVTOS = 0x44 - IP_RECVTTL = 0x41 - IP_RETOPTS = 0x8 - IP_RF = 0x8000 - IP_RSVP_OFF = 0x10 - IP_RSVP_ON = 0xf - IP_RSVP_VIF_OFF = 0x12 - IP_RSVP_VIF_ON = 0x11 - IP_SENDSRCADDR = 0x7 - IP_TOS = 0x3 - IP_TTL = 0x4 - IP_UNBLOCK_SOURCE = 0x49 - ISIG = 0x80 - ISTRIP = 0x20 - IXANY = 0x800 - IXOFF = 0x400 - IXON = 0x200 - LOCK_EX = 0x2 - LOCK_NB = 0x4 - LOCK_SH = 0x1 - LOCK_UN = 0x8 - MADV_AUTOSYNC = 0x7 - MADV_CORE = 0x9 - MADV_DONTNEED = 0x4 - MADV_FREE = 0x5 - MADV_NOCORE = 0x8 - MADV_NORMAL = 0x0 - MADV_NOSYNC = 0x6 - MADV_PROTECT = 0xa - MADV_RANDOM = 0x1 - MADV_SEQUENTIAL = 0x2 - MADV_WILLNEED = 0x3 - MAP_ALIGNED_SUPER = 0x1000000 - MAP_ALIGNMENT_MASK = -0x1000000 - MAP_ALIGNMENT_SHIFT = 0x18 - MAP_ANON = 0x1000 - MAP_ANONYMOUS = 0x1000 - MAP_COPY = 0x2 - MAP_EXCL = 0x4000 - MAP_FILE = 0x0 - MAP_FIXED = 0x10 - MAP_HASSEMAPHORE = 0x200 - MAP_NOCORE = 0x20000 - MAP_NORESERVE = 0x40 - MAP_NOSYNC = 0x800 - MAP_PREFAULT_READ = 0x40000 - MAP_PRIVATE = 0x2 - MAP_RENAME = 0x20 - MAP_RESERVED0080 = 0x80 - MAP_RESERVED0100 = 0x100 - MAP_SHARED = 0x1 - MAP_STACK = 0x400 - MCL_CURRENT = 0x1 - MCL_FUTURE = 0x2 - MSG_CMSG_CLOEXEC = 0x40000 - MSG_COMPAT = 0x8000 - MSG_CTRUNC = 0x20 - MSG_DONTROUTE = 0x4 - MSG_DONTWAIT = 0x80 - MSG_EOF = 0x100 - MSG_EOR = 0x8 - MSG_NBIO = 0x4000 - MSG_NOSIGNAL = 0x20000 - MSG_NOTIFICATION = 0x2000 - MSG_OOB = 0x1 - MSG_PEEK = 0x2 - MSG_TRUNC = 0x10 - MSG_WAITALL = 0x40 - MS_ASYNC = 0x1 - MS_INVALIDATE = 0x2 - MS_SYNC = 0x0 - NAME_MAX = 0xff - NET_RT_DUMP = 0x1 - NET_RT_FLAGS = 0x2 - NET_RT_IFLIST = 0x3 - NET_RT_IFLISTL = 0x5 - NET_RT_IFMALIST = 0x4 - NET_RT_MAXID = 0x6 - NOFLSH = 0x80000000 - NOTE_ATTRIB = 0x8 - NOTE_CHILD = 0x4 - NOTE_DELETE = 0x1 - NOTE_EXEC = 0x20000000 - NOTE_EXIT = 0x80000000 - NOTE_EXTEND = 0x4 - NOTE_FFAND = 0x40000000 - NOTE_FFCOPY = 0xc0000000 - NOTE_FFCTRLMASK = 0xc0000000 - NOTE_FFLAGSMASK = 0xffffff - NOTE_FFNOP = 0x0 - NOTE_FFOR = 0x80000000 - NOTE_FORK = 0x40000000 - NOTE_LINK = 0x10 - NOTE_LOWAT = 0x1 - NOTE_PCTRLMASK = 0xf0000000 - NOTE_PDATAMASK = 0xfffff - NOTE_RENAME = 0x20 - NOTE_REVOKE = 0x40 - NOTE_TRACK = 0x1 - NOTE_TRACKERR = 0x2 - NOTE_TRIGGER = 0x1000000 - NOTE_WRITE = 0x2 - OCRNL = 0x10 - ONLCR = 0x2 - ONLRET = 0x40 - ONOCR = 0x20 - ONOEOT = 0x8 - OPOST = 0x1 - O_ACCMODE = 0x3 - O_APPEND = 0x8 - O_ASYNC = 0x40 - O_CLOEXEC = 0x100000 - O_CREAT = 0x200 - O_DIRECT = 0x10000 - O_DIRECTORY = 0x20000 - O_EXCL = 0x800 - O_EXEC = 0x40000 - O_EXLOCK = 0x20 - O_FSYNC = 0x80 - O_NDELAY = 0x4 - O_NOCTTY = 0x8000 - O_NOFOLLOW = 0x100 - O_NONBLOCK = 0x4 - O_RDONLY = 0x0 - O_RDWR = 0x2 - O_SHLOCK = 0x10 - O_SYNC = 0x80 - O_TRUNC = 0x400 - O_TTY_INIT = 0x80000 - O_WRONLY = 0x1 - PARENB = 0x1000 - PARMRK = 0x8 - PARODD = 0x2000 - PENDIN = 0x20000000 - PRIO_PGRP = 0x1 - PRIO_PROCESS = 0x0 - PRIO_USER = 0x2 - PROT_EXEC = 0x4 - PROT_NONE = 0x0 - PROT_READ = 0x1 - PROT_WRITE = 0x2 - RLIMIT_AS = 0xa - RLIMIT_CORE = 0x4 - RLIMIT_CPU = 0x0 - RLIMIT_DATA = 0x2 - RLIMIT_FSIZE = 0x1 - RLIMIT_NOFILE = 0x8 - RLIMIT_STACK = 0x3 - RLIM_INFINITY = 0x7fffffffffffffff - RTAX_AUTHOR = 0x6 - RTAX_BRD = 0x7 - RTAX_DST = 0x0 - RTAX_GATEWAY = 0x1 - RTAX_GENMASK = 0x3 - RTAX_IFA = 0x5 - RTAX_IFP = 0x4 - RTAX_MAX = 0x8 - RTAX_NETMASK = 0x2 - RTA_AUTHOR = 0x40 - RTA_BRD = 0x80 - RTA_DST = 0x1 - RTA_GATEWAY = 0x2 - RTA_GENMASK = 0x8 - RTA_IFA = 0x20 - RTA_IFP = 0x10 - RTA_NETMASK = 0x4 - RTF_BLACKHOLE = 0x1000 - RTF_BROADCAST = 0x400000 - RTF_DONE = 0x40 - RTF_DYNAMIC = 0x10 - RTF_FMASK = 0x1004d808 - RTF_GATEWAY = 0x2 - RTF_GWFLAG_COMPAT = 0x80000000 - RTF_HOST = 0x4 - RTF_LLDATA = 0x400 - RTF_LLINFO = 0x400 - RTF_LOCAL = 0x200000 - RTF_MODIFIED = 0x20 - RTF_MULTICAST = 0x800000 - RTF_PINNED = 0x100000 - RTF_PRCLONING = 0x10000 - RTF_PROTO1 = 0x8000 - RTF_PROTO2 = 0x4000 - RTF_PROTO3 = 0x40000 - RTF_REJECT = 0x8 - RTF_RNH_LOCKED = 0x40000000 - RTF_STATIC = 0x800 - RTF_STICKY = 0x10000000 - RTF_UP = 0x1 - RTF_XRESOLVE = 0x200 - RTM_ADD = 0x1 - RTM_CHANGE = 0x3 - RTM_DELADDR = 0xd - RTM_DELETE = 0x2 - RTM_DELMADDR = 0x10 - RTM_GET = 0x4 - RTM_IEEE80211 = 0x12 - RTM_IFANNOUNCE = 0x11 - RTM_IFINFO = 0xe - RTM_LOCK = 0x8 - RTM_LOSING = 0x5 - RTM_MISS = 0x7 - RTM_NEWADDR = 0xc - RTM_NEWMADDR = 0xf - RTM_OLDADD = 0x9 - RTM_OLDDEL = 0xa - RTM_REDIRECT = 0x6 - RTM_RESOLVE = 0xb - RTM_RTTUNIT = 0xf4240 - RTM_VERSION = 0x5 - RTV_EXPIRE = 0x4 - RTV_HOPCOUNT = 0x2 - RTV_MTU = 0x1 - RTV_RPIPE = 0x8 - RTV_RTT = 0x40 - RTV_RTTVAR = 0x80 - RTV_SPIPE = 0x10 - RTV_SSTHRESH = 0x20 - RTV_WEIGHT = 0x100 - RT_ALL_FIBS = -0x1 - RT_CACHING_CONTEXT = 0x1 - RT_DEFAULT_FIB = 0x0 - RT_NORTREF = 0x2 - RUSAGE_CHILDREN = -0x1 - RUSAGE_SELF = 0x0 - RUSAGE_THREAD = 0x1 - SCM_BINTIME = 0x4 - SCM_CREDS = 0x3 - SCM_RIGHTS = 0x1 - SCM_TIMESTAMP = 0x2 - SHUT_RD = 0x0 - SHUT_RDWR = 0x2 - SHUT_WR = 0x1 - SIOCADDMULTI = 0x80206931 - SIOCADDRT = 0x8030720a - SIOCAIFADDR = 0x8040691a - SIOCAIFGROUP = 0x80246987 - SIOCALIFADDR = 0x8118691b - SIOCATMARK = 0x40047307 - SIOCDELMULTI = 0x80206932 - SIOCDELRT = 0x8030720b - SIOCDIFADDR = 0x80206919 - SIOCDIFGROUP = 0x80246989 - SIOCDIFPHYADDR = 0x80206949 - SIOCDLIFADDR = 0x8118691d - SIOCGDRVSPEC = 0xc01c697b - SIOCGETSGCNT = 0xc0147210 - SIOCGETVIFCNT = 0xc014720f - SIOCGHIWAT = 0x40047301 - SIOCGIFADDR = 0xc0206921 - SIOCGIFBRDADDR = 0xc0206923 - SIOCGIFCAP = 0xc020691f - SIOCGIFCONF = 0xc0086924 - SIOCGIFDESCR = 0xc020692a - SIOCGIFDSTADDR = 0xc0206922 - SIOCGIFFIB = 0xc020695c - SIOCGIFFLAGS = 0xc0206911 - SIOCGIFGENERIC = 0xc020693a - SIOCGIFGMEMB = 0xc024698a - SIOCGIFGROUP = 0xc0246988 - SIOCGIFINDEX = 0xc0206920 - SIOCGIFMAC = 0xc0206926 - SIOCGIFMEDIA = 0xc0286938 - SIOCGIFMETRIC = 0xc0206917 - SIOCGIFMTU = 0xc0206933 - SIOCGIFNETMASK = 0xc0206925 - SIOCGIFPDSTADDR = 0xc0206948 - SIOCGIFPHYS = 0xc0206935 - SIOCGIFPSRCADDR = 0xc0206947 - SIOCGIFSTATUS = 0xc331693b - SIOCGLIFADDR = 0xc118691c - SIOCGLIFPHYADDR = 0xc118694b - SIOCGLOWAT = 0x40047303 - SIOCGPGRP = 0x40047309 - SIOCGPRIVATE_0 = 0xc0206950 - SIOCGPRIVATE_1 = 0xc0206951 - SIOCIFCREATE = 0xc020697a - SIOCIFCREATE2 = 0xc020697c - SIOCIFDESTROY = 0x80206979 - SIOCIFGCLONERS = 0xc00c6978 - SIOCSDRVSPEC = 0x801c697b - SIOCSHIWAT = 0x80047300 - SIOCSIFADDR = 0x8020690c - SIOCSIFBRDADDR = 0x80206913 - SIOCSIFCAP = 0x8020691e - SIOCSIFDESCR = 0x80206929 - SIOCSIFDSTADDR = 0x8020690e - SIOCSIFFIB = 0x8020695d - SIOCSIFFLAGS = 0x80206910 - SIOCSIFGENERIC = 0x80206939 - SIOCSIFLLADDR = 0x8020693c - SIOCSIFMAC = 0x80206927 - SIOCSIFMEDIA = 0xc0206937 - SIOCSIFMETRIC = 0x80206918 - SIOCSIFMTU = 0x80206934 - SIOCSIFNAME = 0x80206928 - SIOCSIFNETMASK = 0x80206916 - SIOCSIFPHYADDR = 0x80406946 - SIOCSIFPHYS = 0x80206936 - SIOCSIFRVNET = 0xc020695b - SIOCSIFVNET = 0xc020695a - SIOCSLIFPHYADDR = 0x8118694a - SIOCSLOWAT = 0x80047302 - SIOCSPGRP = 0x80047308 - SOCK_CLOEXEC = 0x10000000 - SOCK_DGRAM = 0x2 - SOCK_MAXADDRLEN = 0xff - SOCK_NONBLOCK = 0x20000000 - SOCK_RAW = 0x3 - SOCK_RDM = 0x4 - SOCK_SEQPACKET = 0x5 - SOCK_STREAM = 0x1 - SOL_SOCKET = 0xffff - SOMAXCONN = 0x80 - SO_ACCEPTCONN = 0x2 - SO_ACCEPTFILTER = 0x1000 - SO_BINTIME = 0x2000 - SO_BROADCAST = 0x20 - SO_DEBUG = 0x1 - SO_DONTROUTE = 0x10 - SO_ERROR = 0x1007 - SO_KEEPALIVE = 0x8 - SO_LABEL = 0x1009 - SO_LINGER = 0x80 - SO_LISTENINCQLEN = 0x1013 - SO_LISTENQLEN = 0x1012 - SO_LISTENQLIMIT = 0x1011 - SO_NOSIGPIPE = 0x800 - SO_NO_DDP = 0x8000 - SO_NO_OFFLOAD = 0x4000 - SO_OOBINLINE = 0x100 - SO_PEERLABEL = 0x1010 - SO_PROTOCOL = 0x1016 - SO_PROTOTYPE = 0x1016 - SO_RCVBUF = 0x1002 - SO_RCVLOWAT = 0x1004 - SO_RCVTIMEO = 0x1006 - SO_REUSEADDR = 0x4 - SO_REUSEPORT = 0x200 - SO_SETFIB = 0x1014 - SO_SNDBUF = 0x1001 - SO_SNDLOWAT = 0x1003 - SO_SNDTIMEO = 0x1005 - SO_TIMESTAMP = 0x400 - SO_TYPE = 0x1008 - SO_USELOOPBACK = 0x40 - SO_USER_COOKIE = 0x1015 - SO_VENDOR = 0x80000000 - TCIFLUSH = 0x1 - TCIOFLUSH = 0x3 - TCOFLUSH = 0x2 - TCP_CA_NAME_MAX = 0x10 - TCP_CONGESTION = 0x40 - TCP_INFO = 0x20 - TCP_KEEPCNT = 0x400 - TCP_KEEPIDLE = 0x100 - TCP_KEEPINIT = 0x80 - TCP_KEEPINTVL = 0x200 - TCP_MAXBURST = 0x4 - TCP_MAXHLEN = 0x3c - TCP_MAXOLEN = 0x28 - TCP_MAXSEG = 0x2 - TCP_MAXWIN = 0xffff - TCP_MAX_SACK = 0x4 - TCP_MAX_WINSHIFT = 0xe - TCP_MD5SIG = 0x10 - TCP_MINMSS = 0xd8 - TCP_MSS = 0x218 - TCP_NODELAY = 0x1 - TCP_NOOPT = 0x8 - TCP_NOPUSH = 0x4 - TCP_VENDOR = 0x80000000 - TCSAFLUSH = 0x2 - TIOCCBRK = 0x2000747a - TIOCCDTR = 0x20007478 - TIOCCONS = 0x80047462 - TIOCDRAIN = 0x2000745e - TIOCEXCL = 0x2000740d - TIOCEXT = 0x80047460 - TIOCFLUSH = 0x80047410 - TIOCGDRAINWAIT = 0x40047456 - TIOCGETA = 0x402c7413 - TIOCGETD = 0x4004741a - TIOCGPGRP = 0x40047477 - TIOCGPTN = 0x4004740f - TIOCGSID = 0x40047463 - TIOCGWINSZ = 0x40087468 - TIOCMBIC = 0x8004746b - TIOCMBIS = 0x8004746c - TIOCMGDTRWAIT = 0x4004745a - TIOCMGET = 0x4004746a - TIOCMSDTRWAIT = 0x8004745b - TIOCMSET = 0x8004746d - TIOCM_CAR = 0x40 - TIOCM_CD = 0x40 - TIOCM_CTS = 0x20 - TIOCM_DCD = 0x40 - TIOCM_DSR = 0x100 - TIOCM_DTR = 0x2 - TIOCM_LE = 0x1 - TIOCM_RI = 0x80 - TIOCM_RNG = 0x80 - TIOCM_RTS = 0x4 - TIOCM_SR = 0x10 - TIOCM_ST = 0x8 - TIOCNOTTY = 0x20007471 - TIOCNXCL = 0x2000740e - TIOCOUTQ = 0x40047473 - TIOCPKT = 0x80047470 - TIOCPKT_DATA = 0x0 - TIOCPKT_DOSTOP = 0x20 - TIOCPKT_FLUSHREAD = 0x1 - TIOCPKT_FLUSHWRITE = 0x2 - TIOCPKT_IOCTL = 0x40 - TIOCPKT_NOSTOP = 0x10 - TIOCPKT_START = 0x8 - TIOCPKT_STOP = 0x4 - TIOCPTMASTER = 0x2000741c - TIOCSBRK = 0x2000747b - TIOCSCTTY = 0x20007461 - TIOCSDRAINWAIT = 0x80047457 - TIOCSDTR = 0x20007479 - TIOCSETA = 0x802c7414 - TIOCSETAF = 0x802c7416 - TIOCSETAW = 0x802c7415 - TIOCSETD = 0x8004741b - TIOCSIG = 0x2004745f - TIOCSPGRP = 0x80047476 - TIOCSTART = 0x2000746e - TIOCSTAT = 0x20007465 - TIOCSTI = 0x80017472 - TIOCSTOP = 0x2000746f - TIOCSWINSZ = 0x80087467 - TIOCTIMESTAMP = 0x40087459 - TIOCUCNTL = 0x80047466 - TOSTOP = 0x400000 - VDISCARD = 0xf - VDSUSP = 0xb - VEOF = 0x0 - VEOL = 0x1 - VEOL2 = 0x2 - VERASE = 0x3 - VERASE2 = 0x7 - VINTR = 0x8 - VKILL = 0x5 - VLNEXT = 0xe - VMIN = 0x10 - VQUIT = 0x9 - VREPRINT = 0x6 - VSTART = 0xc - VSTATUS = 0x12 - VSTOP = 0xd - VSUSP = 0xa - VTIME = 0x11 - VWERASE = 0x4 - WCONTINUED = 0x4 - WCOREFLAG = 0x80 - WEXITED = 0x10 - WLINUXCLONE = 0x80000000 - WNOHANG = 0x1 - WNOWAIT = 0x8 - WSTOPPED = 0x2 - WTRAPPED = 0x20 - WUNTRACED = 0x2 + AF_APPLETALK = 0x10 + AF_ARP = 0x23 + AF_ATM = 0x1e + AF_BLUETOOTH = 0x24 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x25 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1c + AF_INET6_SDP = 0x2a + AF_INET_SDP = 0x28 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x2a + AF_NATM = 0x1d + AF_NETBIOS = 0x6 + AF_NETGRAPH = 0x20 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x11 + AF_SCLUSTER = 0x22 + AF_SIP = 0x18 + AF_SLOW = 0x21 + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VENDOR00 = 0x27 + AF_VENDOR01 = 0x29 + AF_VENDOR02 = 0x2b + AF_VENDOR03 = 0x2d + AF_VENDOR04 = 0x2f + AF_VENDOR05 = 0x31 + AF_VENDOR06 = 0x33 + AF_VENDOR07 = 0x35 + AF_VENDOR08 = 0x37 + AF_VENDOR09 = 0x39 + AF_VENDOR10 = 0x3b + AF_VENDOR11 = 0x3d + AF_VENDOR12 = 0x3f + AF_VENDOR13 = 0x41 + AF_VENDOR14 = 0x43 + AF_VENDOR15 = 0x45 + AF_VENDOR16 = 0x47 + AF_VENDOR17 = 0x49 + AF_VENDOR18 = 0x4b + AF_VENDOR19 = 0x4d + AF_VENDOR20 = 0x4f + AF_VENDOR21 = 0x51 + AF_VENDOR22 = 0x53 + AF_VENDOR23 = 0x55 + AF_VENDOR24 = 0x57 + AF_VENDOR25 = 0x59 + AF_VENDOR26 = 0x5b + AF_VENDOR27 = 0x5d + AF_VENDOR28 = 0x5f + AF_VENDOR29 = 0x61 + AF_VENDOR30 = 0x63 + AF_VENDOR31 = 0x65 + AF_VENDOR32 = 0x67 + AF_VENDOR33 = 0x69 + AF_VENDOR34 = 0x6b + AF_VENDOR35 = 0x6d + AF_VENDOR36 = 0x6f + AF_VENDOR37 = 0x71 + AF_VENDOR38 = 0x73 + AF_VENDOR39 = 0x75 + AF_VENDOR40 = 0x77 + AF_VENDOR41 = 0x79 + AF_VENDOR42 = 0x7b + AF_VENDOR43 = 0x7d + AF_VENDOR44 = 0x7f + AF_VENDOR45 = 0x81 + AF_VENDOR46 = 0x83 + AF_VENDOR47 = 0x85 + ALTWERASE = 0x200 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B460800 = 0x70800 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B921600 = 0xe1000 + B9600 = 0x2580 + BIOCFEEDBACK = 0x8004427c + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDIRECTION = 0x40044276 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc0084279 + BIOCGETBUFMODE = 0x4004427d + BIOCGETIF = 0x4020426b + BIOCGETZMAX = 0x4004427f + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4008426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCGTSTAMP = 0x40044283 + BIOCIMMEDIATE = 0x80044270 + BIOCLOCK = 0x2000427a + BIOCPROMISC = 0x20004269 + BIOCROTZBUF = 0x400c4280 + BIOCSBLEN = 0xc0044266 + BIOCSDIRECTION = 0x80044277 + BIOCSDLT = 0x80044278 + BIOCSETBUFMODE = 0x8004427e + BIOCSETF = 0x80084267 + BIOCSETFNR = 0x80084282 + BIOCSETIF = 0x8020426c + BIOCSETWF = 0x8008427b + BIOCSETZBUF = 0x800c4281 + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8008426d + BIOCSSEESENT = 0x80044277 + BIOCSTSTAMP = 0x80044284 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_BUFMODE_BUFFER = 0x1 + BPF_BUFMODE_ZBUF = 0x2 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_T_BINTIME = 0x2 + BPF_T_BINTIME_FAST = 0x102 + BPF_T_BINTIME_MONOTONIC = 0x202 + BPF_T_BINTIME_MONOTONIC_FAST = 0x302 + BPF_T_FAST = 0x100 + BPF_T_FLAG_MASK = 0x300 + BPF_T_FORMAT_MASK = 0x3 + BPF_T_MICROTIME = 0x0 + BPF_T_MICROTIME_FAST = 0x100 + BPF_T_MICROTIME_MONOTONIC = 0x200 + BPF_T_MICROTIME_MONOTONIC_FAST = 0x300 + BPF_T_MONOTONIC = 0x200 + BPF_T_MONOTONIC_FAST = 0x300 + BPF_T_NANOTIME = 0x1 + BPF_T_NANOTIME_FAST = 0x101 + BPF_T_NANOTIME_MONOTONIC = 0x201 + BPF_T_NANOTIME_MONOTONIC_FAST = 0x301 + BPF_T_NONE = 0x3 + BPF_T_NORMAL = 0x0 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + CAP_ACCEPT = 0x200000020000000 + CAP_ACL_CHECK = 0x400000000010000 + CAP_ACL_DELETE = 0x400000000020000 + CAP_ACL_GET = 0x400000000040000 + CAP_ACL_SET = 0x400000000080000 + CAP_ALL0 = 0x20007ffffffffff + CAP_ALL1 = 0x4000000001fffff + CAP_BIND = 0x200000040000000 + CAP_BINDAT = 0x200008000000400 + CAP_CHFLAGSAT = 0x200000000001400 + CAP_CONNECT = 0x200000080000000 + CAP_CONNECTAT = 0x200010000000400 + CAP_CREATE = 0x200000000000040 + CAP_EVENT = 0x400000000000020 + CAP_EXTATTR_DELETE = 0x400000000001000 + CAP_EXTATTR_GET = 0x400000000002000 + CAP_EXTATTR_LIST = 0x400000000004000 + CAP_EXTATTR_SET = 0x400000000008000 + CAP_FCHDIR = 0x200000000000800 + CAP_FCHFLAGS = 0x200000000001000 + CAP_FCHMOD = 0x200000000002000 + CAP_FCHMODAT = 0x200000000002400 + CAP_FCHOWN = 0x200000000004000 + CAP_FCHOWNAT = 0x200000000004400 + CAP_FCNTL = 0x200000000008000 + CAP_FCNTL_ALL = 0x78 + CAP_FCNTL_GETFL = 0x8 + CAP_FCNTL_GETOWN = 0x20 + CAP_FCNTL_SETFL = 0x10 + CAP_FCNTL_SETOWN = 0x40 + CAP_FEXECVE = 0x200000000000080 + CAP_FLOCK = 0x200000000010000 + CAP_FPATHCONF = 0x200000000020000 + CAP_FSCK = 0x200000000040000 + CAP_FSTAT = 0x200000000080000 + CAP_FSTATAT = 0x200000000080400 + CAP_FSTATFS = 0x200000000100000 + CAP_FSYNC = 0x200000000000100 + CAP_FTRUNCATE = 0x200000000000200 + CAP_FUTIMES = 0x200000000200000 + CAP_FUTIMESAT = 0x200000000200400 + CAP_GETPEERNAME = 0x200000100000000 + CAP_GETSOCKNAME = 0x200000200000000 + CAP_GETSOCKOPT = 0x200000400000000 + CAP_IOCTL = 0x400000000000080 + CAP_IOCTLS_ALL = 0x7fffffff + CAP_KQUEUE = 0x400000000100040 + CAP_KQUEUE_CHANGE = 0x400000000100000 + CAP_KQUEUE_EVENT = 0x400000000000040 + CAP_LINKAT_SOURCE = 0x200020000000400 + CAP_LINKAT_TARGET = 0x200000000400400 + CAP_LISTEN = 0x200000800000000 + CAP_LOOKUP = 0x200000000000400 + CAP_MAC_GET = 0x400000000000001 + CAP_MAC_SET = 0x400000000000002 + CAP_MKDIRAT = 0x200000000800400 + CAP_MKFIFOAT = 0x200000001000400 + CAP_MKNODAT = 0x200000002000400 + CAP_MMAP = 0x200000000000010 + CAP_MMAP_R = 0x20000000000001d + CAP_MMAP_RW = 0x20000000000001f + CAP_MMAP_RWX = 0x20000000000003f + CAP_MMAP_RX = 0x20000000000003d + CAP_MMAP_W = 0x20000000000001e + CAP_MMAP_WX = 0x20000000000003e + CAP_MMAP_X = 0x20000000000003c + CAP_PDGETPID = 0x400000000000200 + CAP_PDKILL = 0x400000000000800 + CAP_PDWAIT = 0x400000000000400 + CAP_PEELOFF = 0x200001000000000 + CAP_POLL_EVENT = 0x400000000000020 + CAP_PREAD = 0x20000000000000d + CAP_PWRITE = 0x20000000000000e + CAP_READ = 0x200000000000001 + CAP_RECV = 0x200000000000001 + CAP_RENAMEAT_SOURCE = 0x200000004000400 + CAP_RENAMEAT_TARGET = 0x200040000000400 + CAP_RIGHTS_VERSION = 0x0 + CAP_RIGHTS_VERSION_00 = 0x0 + CAP_SEEK = 0x20000000000000c + CAP_SEEK_TELL = 0x200000000000004 + CAP_SEM_GETVALUE = 0x400000000000004 + CAP_SEM_POST = 0x400000000000008 + CAP_SEM_WAIT = 0x400000000000010 + CAP_SEND = 0x200000000000002 + CAP_SETSOCKOPT = 0x200002000000000 + CAP_SHUTDOWN = 0x200004000000000 + CAP_SOCK_CLIENT = 0x200007780000003 + CAP_SOCK_SERVER = 0x200007f60000003 + CAP_SYMLINKAT = 0x200000008000400 + CAP_TTYHOOK = 0x400000000000100 + CAP_UNLINKAT = 0x200000010000400 + CAP_UNUSED0_44 = 0x200080000000000 + CAP_UNUSED0_57 = 0x300000000000000 + CAP_UNUSED1_22 = 0x400000000200000 + CAP_UNUSED1_57 = 0x500000000000000 + CAP_WRITE = 0x200000000000002 + CFLUSH = 0xf + CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x4 + CLOCK_MONOTONIC_FAST = 0xc + CLOCK_MONOTONIC_PRECISE = 0xb + CLOCK_PROCESS_CPUTIME_ID = 0xf + CLOCK_PROF = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_FAST = 0xa + CLOCK_REALTIME_PRECISE = 0x9 + CLOCK_SECOND = 0xd + CLOCK_THREAD_CPUTIME_ID = 0xe + CLOCK_UPTIME = 0x5 + CLOCK_UPTIME_FAST = 0x8 + CLOCK_UPTIME_PRECISE = 0x7 + CLOCK_VIRTUAL = 0x1 + CREAD = 0x800 + CRTSCTS = 0x30000 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0x18 + CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_BREDR_BB = 0xff + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_BLUETOOTH_LE_LL = 0xfb + DLT_BLUETOOTH_LE_LL_WITH_PHDR = 0x100 + DLT_BLUETOOTH_LINUX_MONITOR = 0xfe + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_EPON = 0x103 + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HHDLC = 0x79 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_INFINIBAND = 0xf7 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPMI_HPM_2 = 0x104 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0x104 + DLT_MATCHING_MIN = 0x68 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NETLINK = 0xfd + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x79 + DLT_PKTAP = 0x102 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 + DLT_PRISM_HEADER = 0x77 + DLT_PROFIBUS_DL = 0x101 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RIO = 0x7c + DLT_RTAC_SERIAL = 0xfa + DLT_SCCP = 0x8e + DLT_SCTP = 0xf8 + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DLT_STANAG_5066_D_PDU = 0xed + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USBPCAP = 0xf9 + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WIHART = 0xdf + DLT_WIRESHARK_UPPER_PDU = 0xfc + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_FS = -0x9 + EVFILT_LIO = -0xa + EVFILT_PROC = -0x5 + EVFILT_PROCDESC = -0x8 + EVFILT_READ = -0x1 + EVFILT_SENDFILE = -0xc + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0xc + EVFILT_TIMER = -0x7 + EVFILT_USER = -0xb + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_DROP = 0x1000 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_FLAG2 = 0x4000 + EV_FORCEONESHOT = 0x100 + EV_ONESHOT = 0x10 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTATTR_NAMESPACE_EMPTY = 0x0 + EXTATTR_NAMESPACE_SYSTEM = 0x2 + EXTATTR_NAMESPACE_USER = 0x1 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_CANCEL = 0x5 + F_DUP2FD = 0xa + F_DUP2FD_CLOEXEC = 0x12 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x11 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0xb + F_GETOWN = 0x5 + F_OGETLK = 0x7 + F_OK = 0x0 + F_OSETLK = 0x8 + F_OSETLKW = 0x9 + F_RDAHEAD = 0x10 + F_RDLCK = 0x1 + F_READAHEAD = 0xf + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0xc + F_SETLKW = 0xd + F_SETLK_REMOTE = 0xe + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_UNLCKSYS = 0x4 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x218f52 + IFF_CANTCONFIG = 0x10000 + IFF_DEBUG = 0x4 + IFF_DRV_OACTIVE = 0x400 + IFF_DRV_RUNNING = 0x40 + IFF_DYING = 0x200000 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MONITOR = 0x40000 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PPROMISC = 0x20000 + IFF_PROMISC = 0x100 + IFF_RENAMING = 0x400000 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_STATICARP = 0x80000 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + IFT_BRIDGE = 0xd1 + IFT_CARP = 0xf8 + IFT_IEEE1394 = 0x90 + IFT_INFINIBAND = 0xc7 + IFT_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + IFT_PPP = 0x17 + IFT_PROPVIRTUAL = 0x35 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IN_RFC3021_MASK = 0xfffffffe + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CARP = 0x70 + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0x102 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HIP = 0x8b + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MEAS = 0x13 + IPPROTO_MH = 0x87 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MOBILE = 0x37 + IPPROTO_MPLS = 0x89 + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OLD_DIVERT = 0xfe + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_RESERVED_253 = 0xfd + IPPROTO_RESERVED_254 = 0xfe + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEND = 0x103 + IPPROTO_SEP = 0x21 + IPPROTO_SHIM6 = 0x8c + IPPROTO_SKIP = 0x39 + IPPROTO_SPACER = 0x7fff + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TLSP = 0x38 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_BINDANY = 0x40 + IPV6_BINDMULTI = 0x41 + IPV6_BINDV6ONLY = 0x1b + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_FLOWID = 0x43 + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FLOWTYPE = 0x44 + IPV6_FRAGTTL = 0x78 + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 + IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f + IPV6_MMTU = 0x500 + IPV6_MSFILTER = 0x4a + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_PREFER_TEMPADDR = 0x3f + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVFLOWID = 0x46 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRSSBUCKETID = 0x47 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RSSBUCKETID = 0x45 + IPV6_RSS_LISTEN_BUCKET = 0x42 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BINDANY = 0x18 + IP_BINDMULTI = 0x19 + IP_BLOCK_SOURCE = 0x48 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DONTFRAG = 0x43 + IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 + IP_DUMMYNET3 = 0x31 + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FLOWID = 0x5a + IP_FLOWTYPE = 0x5b + IP_FW3 = 0x30 + IP_FW_ADD = 0x32 + IP_FW_DEL = 0x33 + IP_FW_FLUSH = 0x34 + IP_FW_GET = 0x36 + IP_FW_NAT_CFG = 0x38 + IP_FW_NAT_DEL = 0x39 + IP_FW_NAT_GET_CONFIG = 0x3a + IP_FW_NAT_GET_LOG = 0x3b + IP_FW_RESETLOG = 0x37 + IP_FW_TABLE_ADD = 0x28 + IP_FW_TABLE_DEL = 0x29 + IP_FW_TABLE_FLUSH = 0x2a + IP_FW_TABLE_GETSIZE = 0x2b + IP_FW_TABLE_LIST = 0x2c + IP_FW_ZERO = 0x35 + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 + IP_MAX_SOURCE_FILTER = 0x400 + IP_MF = 0x2000 + IP_MINTTL = 0x42 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_OFFMASK = 0x1fff + IP_ONESBCAST = 0x17 + IP_OPTIONS = 0x1 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVFLOWID = 0x5d + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVRSSBUCKETID = 0x5e + IP_RECVTOS = 0x44 + IP_RECVTTL = 0x41 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSSBUCKETID = 0x5c + IP_RSS_LISTEN_BUCKET = 0x1a + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_SENDSRCADDR = 0x7 + IP_TOS = 0x3 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 + ISIG = 0x80 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_AUTOSYNC = 0x7 + MADV_CORE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_NOCORE = 0x8 + MADV_NORMAL = 0x0 + MADV_NOSYNC = 0x6 + MADV_PROTECT = 0xa + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MAP_ALIGNED_SUPER = 0x1000000 + MAP_ALIGNMENT_MASK = -0x1000000 + MAP_ALIGNMENT_SHIFT = 0x18 + MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 + MAP_COPY = 0x2 + MAP_EXCL = 0x4000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_NOCORE = 0x20000 + MAP_NOSYNC = 0x800 + MAP_PREFAULT_READ = 0x40000 + MAP_PRIVATE = 0x2 + MAP_RESERVED0020 = 0x20 + MAP_RESERVED0040 = 0x40 + MAP_RESERVED0080 = 0x80 + MAP_RESERVED0100 = 0x100 + MAP_SHARED = 0x1 + MAP_STACK = 0x400 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_CMSG_CLOEXEC = 0x40000 + MSG_COMPAT = 0x8000 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_NBIO = 0x4000 + MSG_NOSIGNAL = 0x20000 + MSG_NOTIFICATION = 0x2000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MSG_WAITFORONE = 0x80000 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x2 + MS_SYNC = 0x0 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_IFLISTL = 0x5 + NET_RT_IFMALIST = 0x4 + NOFLSH = 0x80000000 + NOKERNINFO = 0x2000000 + NOTE_ATTRIB = 0x8 + NOTE_CHILD = 0x4 + NOTE_CLOSE = 0x100 + NOTE_CLOSE_WRITE = 0x200 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 + NOTE_FILE_POLL = 0x2 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_MSECONDS = 0x2 + NOTE_NSECONDS = 0x8 + NOTE_OPEN = 0x80 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_READ = 0x400 + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_SECONDS = 0x1 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_USECONDS = 0x4 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + OXTABS = 0x4 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x100000 + O_CREAT = 0x200 + O_DIRECT = 0x10000 + O_DIRECTORY = 0x20000 + O_EXCL = 0x800 + O_EXEC = 0x40000 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_TTY_INIT = 0x80000 + O_VERIFY = 0x200000 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_AS = 0xa + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 + RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x8 + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_FIXEDMTU = 0x80000 + RTF_FMASK = 0x1004d808 + RTF_GATEWAY = 0x2 + RTF_GWFLAG_COMPAT = 0x80000000 + RTF_HOST = 0x4 + RTF_LLDATA = 0x400 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MULTICAST = 0x800000 + RTF_PINNED = 0x100000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_REJECT = 0x8 + RTF_RNH_LOCKED = 0x40000000 + RTF_STATIC = 0x800 + RTF_STICKY = 0x10000000 + RTF_UP = 0x1 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_IEEE80211 = 0x12 + RTM_IFANNOUNCE = 0x11 + RTM_IFINFO = 0xe + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RTV_WEIGHT = 0x100 + RT_ALL_FIBS = -0x1 + RT_BLACKHOLE = 0x40 + RT_CACHING_CONTEXT = 0x1 + RT_DEFAULT_FIB = 0x0 + RT_HAS_GW = 0x80 + RT_HAS_HEADER = 0x10 + RT_HAS_HEADER_BIT = 0x4 + RT_L2_ME = 0x4 + RT_L2_ME_BIT = 0x2 + RT_LLE_CACHE = 0x100 + RT_MAY_LOOP = 0x8 + RT_MAY_LOOP_BIT = 0x3 + RT_NORTREF = 0x2 + RT_REJECT = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_BINTIME = 0x4 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCAIFGROUP = 0x80246987 + SIOCATMARK = 0x40047307 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFGROUP = 0x80246989 + SIOCDIFPHYADDR = 0x80206949 + SIOCGDRVSPEC = 0xc01c697b + SIOCGETSGCNT = 0xc0147210 + SIOCGETVIFCNT = 0xc014720f + SIOCGHIWAT = 0x40047301 + SIOCGI2C = 0xc020693d + SIOCGIFADDR = 0xc0206921 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020691f + SIOCGIFCONF = 0xc0086924 + SIOCGIFDESCR = 0xc020692a + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFIB = 0xc020695c + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGENERIC = 0xc020693a + SIOCGIFGMEMB = 0xc024698a + SIOCGIFGROUP = 0xc0246988 + SIOCGIFINDEX = 0xc0206920 + SIOCGIFMAC = 0xc0206926 + SIOCGIFMEDIA = 0xc0286938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206948 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPSRCADDR = 0xc0206947 + SIOCGIFSTATUS = 0xc331693b + SIOCGIFXMEDIA = 0xc028698b + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCGPRIVATE_0 = 0xc0206950 + SIOCGPRIVATE_1 = 0xc0206951 + SIOCGTUNFIB = 0xc020695e + SIOCIFCREATE = 0xc020697a + SIOCIFCREATE2 = 0xc020697c + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc00c6978 + SIOCSDRVSPEC = 0x801c697b + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020691e + SIOCSIFDESCR = 0x80206929 + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFIB = 0x8020695d + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206927 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNAME = 0x80206928 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x80406946 + SIOCSIFPHYS = 0x80206936 + SIOCSIFRVNET = 0xc020695b + SIOCSIFVNET = 0xc020695a + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SIOCSTUNFIB = 0x8020695f + SOCK_CLOEXEC = 0x10000000 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_NONBLOCK = 0x20000000 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_ACCEPTFILTER = 0x1000 + SO_BINTIME = 0x2000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1009 + SO_LINGER = 0x80 + SO_LISTENINCQLEN = 0x1013 + SO_LISTENQLEN = 0x1012 + SO_LISTENQLIMIT = 0x1011 + SO_NOSIGPIPE = 0x800 + SO_NO_DDP = 0x8000 + SO_NO_OFFLOAD = 0x4000 + SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1010 + SO_PROTOCOL = 0x1016 + SO_PROTOTYPE = 0x1016 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_SETFIB = 0x1014 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + SO_USER_COOKIE = 0x1015 + SO_VENDOR = 0x80000000 + TAB0 = 0x0 + TAB3 = 0x4 + TABDLY = 0x4 + TCIFLUSH = 0x1 + TCIOFF = 0x3 + TCIOFLUSH = 0x3 + TCION = 0x4 + TCOFLUSH = 0x2 + TCOOFF = 0x1 + TCOON = 0x2 + TCP_CA_NAME_MAX = 0x10 + TCP_CCALGOOPT = 0x41 + TCP_CONGESTION = 0x40 + TCP_FASTOPEN = 0x401 + TCP_FUNCTION_BLK = 0x2000 + TCP_FUNCTION_NAME_LEN_MAX = 0x20 + TCP_INFO = 0x20 + TCP_KEEPCNT = 0x400 + TCP_KEEPIDLE = 0x100 + TCP_KEEPINIT = 0x80 + TCP_KEEPINTVL = 0x200 + TCP_MAXBURST = 0x4 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x10 + TCP_MINMSS = 0xd8 + TCP_MSS = 0x218 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_PCAP_IN = 0x1000 + TCP_PCAP_OUT = 0x800 + TCP_VENDOR = 0x80000000 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGPTN = 0x4004740f + TIOCGSID = 0x40047463 + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DCD = 0x40 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTMASTER = 0x2000741c + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2004745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40087459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VERASE2 = 0x7 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x4 + WCOREFLAG = 0x80 + WEXITED = 0x10 + WLINUXCLONE = 0x80000000 + WNOHANG = 0x1 + WNOWAIT = 0x8 + WSTOPPED = 0x2 + WTRAPPED = 0x20 + WUNTRACED = 0x2 ) // Errors diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go index e48e7799a..ac094f9cf 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go @@ -1,5 +1,5 @@ // mkerrors.sh -m64 -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build amd64,freebsd @@ -11,1461 +11,1420 @@ package unix import "syscall" const ( - AF_APPLETALK = 0x10 - AF_ARP = 0x23 - AF_ATM = 0x1e - AF_BLUETOOTH = 0x24 - AF_CCITT = 0xa - AF_CHAOS = 0x5 - AF_CNT = 0x15 - AF_COIP = 0x14 - AF_DATAKIT = 0x9 - AF_DECnet = 0xc - AF_DLI = 0xd - AF_E164 = 0x1a - AF_ECMA = 0x8 - AF_HYLINK = 0xf - AF_IEEE80211 = 0x25 - AF_IMPLINK = 0x3 - AF_INET = 0x2 - AF_INET6 = 0x1c - AF_INET6_SDP = 0x2a - AF_INET_SDP = 0x28 - AF_IPX = 0x17 - AF_ISDN = 0x1a - AF_ISO = 0x7 - AF_LAT = 0xe - AF_LINK = 0x12 - AF_LOCAL = 0x1 - AF_MAX = 0x2a - AF_NATM = 0x1d - AF_NETBIOS = 0x6 - AF_NETGRAPH = 0x20 - AF_OSI = 0x7 - AF_PUP = 0x4 - AF_ROUTE = 0x11 - AF_SCLUSTER = 0x22 - AF_SIP = 0x18 - AF_SLOW = 0x21 - AF_SNA = 0xb - AF_UNIX = 0x1 - AF_UNSPEC = 0x0 - AF_VENDOR00 = 0x27 - AF_VENDOR01 = 0x29 - AF_VENDOR02 = 0x2b - AF_VENDOR03 = 0x2d - AF_VENDOR04 = 0x2f - AF_VENDOR05 = 0x31 - AF_VENDOR06 = 0x33 - AF_VENDOR07 = 0x35 - AF_VENDOR08 = 0x37 - AF_VENDOR09 = 0x39 - AF_VENDOR10 = 0x3b - AF_VENDOR11 = 0x3d - AF_VENDOR12 = 0x3f - AF_VENDOR13 = 0x41 - AF_VENDOR14 = 0x43 - AF_VENDOR15 = 0x45 - AF_VENDOR16 = 0x47 - AF_VENDOR17 = 0x49 - AF_VENDOR18 = 0x4b - AF_VENDOR19 = 0x4d - AF_VENDOR20 = 0x4f - AF_VENDOR21 = 0x51 - AF_VENDOR22 = 0x53 - AF_VENDOR23 = 0x55 - AF_VENDOR24 = 0x57 - AF_VENDOR25 = 0x59 - AF_VENDOR26 = 0x5b - AF_VENDOR27 = 0x5d - AF_VENDOR28 = 0x5f - AF_VENDOR29 = 0x61 - AF_VENDOR30 = 0x63 - AF_VENDOR31 = 0x65 - AF_VENDOR32 = 0x67 - AF_VENDOR33 = 0x69 - AF_VENDOR34 = 0x6b - AF_VENDOR35 = 0x6d - AF_VENDOR36 = 0x6f - AF_VENDOR37 = 0x71 - AF_VENDOR38 = 0x73 - AF_VENDOR39 = 0x75 - AF_VENDOR40 = 0x77 - AF_VENDOR41 = 0x79 - AF_VENDOR42 = 0x7b - AF_VENDOR43 = 0x7d - AF_VENDOR44 = 0x7f - AF_VENDOR45 = 0x81 - AF_VENDOR46 = 0x83 - AF_VENDOR47 = 0x85 - B0 = 0x0 - B110 = 0x6e - B115200 = 0x1c200 - B1200 = 0x4b0 - B134 = 0x86 - B14400 = 0x3840 - B150 = 0x96 - B1800 = 0x708 - B19200 = 0x4b00 - B200 = 0xc8 - B230400 = 0x38400 - B2400 = 0x960 - B28800 = 0x7080 - B300 = 0x12c - B38400 = 0x9600 - B460800 = 0x70800 - B4800 = 0x12c0 - B50 = 0x32 - B57600 = 0xe100 - B600 = 0x258 - B7200 = 0x1c20 - B75 = 0x4b - B76800 = 0x12c00 - B921600 = 0xe1000 - B9600 = 0x2580 - BIOCFEEDBACK = 0x8004427c - BIOCFLUSH = 0x20004268 - BIOCGBLEN = 0x40044266 - BIOCGDIRECTION = 0x40044276 - BIOCGDLT = 0x4004426a - BIOCGDLTLIST = 0xc0104279 - BIOCGETBUFMODE = 0x4004427d - BIOCGETIF = 0x4020426b - BIOCGETZMAX = 0x4008427f - BIOCGHDRCMPLT = 0x40044274 - BIOCGRSIG = 0x40044272 - BIOCGRTIMEOUT = 0x4010426e - BIOCGSEESENT = 0x40044276 - BIOCGSTATS = 0x4008426f - BIOCGTSTAMP = 0x40044283 - BIOCIMMEDIATE = 0x80044270 - BIOCLOCK = 0x2000427a - BIOCPROMISC = 0x20004269 - BIOCROTZBUF = 0x40184280 - BIOCSBLEN = 0xc0044266 - BIOCSDIRECTION = 0x80044277 - BIOCSDLT = 0x80044278 - BIOCSETBUFMODE = 0x8004427e - BIOCSETF = 0x80104267 - BIOCSETFNR = 0x80104282 - BIOCSETIF = 0x8020426c - BIOCSETWF = 0x8010427b - BIOCSETZBUF = 0x80184281 - BIOCSHDRCMPLT = 0x80044275 - BIOCSRSIG = 0x80044273 - BIOCSRTIMEOUT = 0x8010426d - BIOCSSEESENT = 0x80044277 - BIOCSTSTAMP = 0x80044284 - BIOCVERSION = 0x40044271 - BPF_A = 0x10 - BPF_ABS = 0x20 - BPF_ADD = 0x0 - BPF_ALIGNMENT = 0x8 - BPF_ALU = 0x4 - BPF_AND = 0x50 - BPF_B = 0x10 - BPF_BUFMODE_BUFFER = 0x1 - BPF_BUFMODE_ZBUF = 0x2 - BPF_DIV = 0x30 - BPF_H = 0x8 - BPF_IMM = 0x0 - BPF_IND = 0x40 - BPF_JA = 0x0 - BPF_JEQ = 0x10 - BPF_JGE = 0x30 - BPF_JGT = 0x20 - BPF_JMP = 0x5 - BPF_JSET = 0x40 - BPF_K = 0x0 - BPF_LD = 0x0 - BPF_LDX = 0x1 - BPF_LEN = 0x80 - BPF_LSH = 0x60 - BPF_MAJOR_VERSION = 0x1 - BPF_MAXBUFSIZE = 0x80000 - BPF_MAXINSNS = 0x200 - BPF_MEM = 0x60 - BPF_MEMWORDS = 0x10 - BPF_MINBUFSIZE = 0x20 - BPF_MINOR_VERSION = 0x1 - BPF_MISC = 0x7 - BPF_MSH = 0xa0 - BPF_MUL = 0x20 - BPF_NEG = 0x80 - BPF_OR = 0x40 - BPF_RELEASE = 0x30bb6 - BPF_RET = 0x6 - BPF_RSH = 0x70 - BPF_ST = 0x2 - BPF_STX = 0x3 - BPF_SUB = 0x10 - BPF_TAX = 0x0 - BPF_TXA = 0x80 - BPF_T_BINTIME = 0x2 - BPF_T_BINTIME_FAST = 0x102 - BPF_T_BINTIME_MONOTONIC = 0x202 - BPF_T_BINTIME_MONOTONIC_FAST = 0x302 - BPF_T_FAST = 0x100 - BPF_T_FLAG_MASK = 0x300 - BPF_T_FORMAT_MASK = 0x3 - BPF_T_MICROTIME = 0x0 - BPF_T_MICROTIME_FAST = 0x100 - BPF_T_MICROTIME_MONOTONIC = 0x200 - BPF_T_MICROTIME_MONOTONIC_FAST = 0x300 - BPF_T_MONOTONIC = 0x200 - BPF_T_MONOTONIC_FAST = 0x300 - BPF_T_NANOTIME = 0x1 - BPF_T_NANOTIME_FAST = 0x101 - BPF_T_NANOTIME_MONOTONIC = 0x201 - BPF_T_NANOTIME_MONOTONIC_FAST = 0x301 - BPF_T_NONE = 0x3 - BPF_T_NORMAL = 0x0 - BPF_W = 0x0 - BPF_X = 0x8 - BRKINT = 0x2 - CFLUSH = 0xf - CLOCAL = 0x8000 - CLOCK_MONOTONIC = 0x4 - CLOCK_MONOTONIC_FAST = 0xc - CLOCK_MONOTONIC_PRECISE = 0xb - CLOCK_PROCESS_CPUTIME_ID = 0xf - CLOCK_PROF = 0x2 - CLOCK_REALTIME = 0x0 - CLOCK_REALTIME_FAST = 0xa - CLOCK_REALTIME_PRECISE = 0x9 - CLOCK_SECOND = 0xd - CLOCK_THREAD_CPUTIME_ID = 0xe - CLOCK_UPTIME = 0x5 - CLOCK_UPTIME_FAST = 0x8 - CLOCK_UPTIME_PRECISE = 0x7 - CLOCK_VIRTUAL = 0x1 - CREAD = 0x800 - CS5 = 0x0 - CS6 = 0x100 - CS7 = 0x200 - CS8 = 0x300 - CSIZE = 0x300 - CSTART = 0x11 - CSTATUS = 0x14 - CSTOP = 0x13 - CSTOPB = 0x400 - CSUSP = 0x1a - CTL_MAXNAME = 0x18 - CTL_NET = 0x4 - DLT_A429 = 0xb8 - DLT_A653_ICM = 0xb9 - DLT_AIRONET_HEADER = 0x78 - DLT_AOS = 0xde - DLT_APPLE_IP_OVER_IEEE1394 = 0x8a - DLT_ARCNET = 0x7 - DLT_ARCNET_LINUX = 0x81 - DLT_ATM_CLIP = 0x13 - DLT_ATM_RFC1483 = 0xb - DLT_AURORA = 0x7e - DLT_AX25 = 0x3 - DLT_AX25_KISS = 0xca - DLT_BACNET_MS_TP = 0xa5 - DLT_BLUETOOTH_HCI_H4 = 0xbb - DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 - DLT_CAN20B = 0xbe - DLT_CAN_SOCKETCAN = 0xe3 - DLT_CHAOS = 0x5 - DLT_CHDLC = 0x68 - DLT_CISCO_IOS = 0x76 - DLT_C_HDLC = 0x68 - DLT_C_HDLC_WITH_DIR = 0xcd - DLT_DBUS = 0xe7 - DLT_DECT = 0xdd - DLT_DOCSIS = 0x8f - DLT_DVB_CI = 0xeb - DLT_ECONET = 0x73 - DLT_EN10MB = 0x1 - DLT_EN3MB = 0x2 - DLT_ENC = 0x6d - DLT_ERF = 0xc5 - DLT_ERF_ETH = 0xaf - DLT_ERF_POS = 0xb0 - DLT_FC_2 = 0xe0 - DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 - DLT_FDDI = 0xa - DLT_FLEXRAY = 0xd2 - DLT_FRELAY = 0x6b - DLT_FRELAY_WITH_DIR = 0xce - DLT_GCOM_SERIAL = 0xad - DLT_GCOM_T1E1 = 0xac - DLT_GPF_F = 0xab - DLT_GPF_T = 0xaa - DLT_GPRS_LLC = 0xa9 - DLT_GSMTAP_ABIS = 0xda - DLT_GSMTAP_UM = 0xd9 - DLT_HHDLC = 0x79 - DLT_IBM_SN = 0x92 - DLT_IBM_SP = 0x91 - DLT_IEEE802 = 0x6 - DLT_IEEE802_11 = 0x69 - DLT_IEEE802_11_RADIO = 0x7f - DLT_IEEE802_11_RADIO_AVS = 0xa3 - DLT_IEEE802_15_4 = 0xc3 - DLT_IEEE802_15_4_LINUX = 0xbf - DLT_IEEE802_15_4_NOFCS = 0xe6 - DLT_IEEE802_15_4_NONASK_PHY = 0xd7 - DLT_IEEE802_16_MAC_CPS = 0xbc - DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 - DLT_IPFILTER = 0x74 - DLT_IPMB = 0xc7 - DLT_IPMB_LINUX = 0xd1 - DLT_IPNET = 0xe2 - DLT_IPOIB = 0xf2 - DLT_IPV4 = 0xe4 - DLT_IPV6 = 0xe5 - DLT_IP_OVER_FC = 0x7a - DLT_JUNIPER_ATM1 = 0x89 - DLT_JUNIPER_ATM2 = 0x87 - DLT_JUNIPER_ATM_CEMIC = 0xee - DLT_JUNIPER_CHDLC = 0xb5 - DLT_JUNIPER_ES = 0x84 - DLT_JUNIPER_ETHER = 0xb2 - DLT_JUNIPER_FIBRECHANNEL = 0xea - DLT_JUNIPER_FRELAY = 0xb4 - DLT_JUNIPER_GGSN = 0x85 - DLT_JUNIPER_ISM = 0xc2 - DLT_JUNIPER_MFR = 0x86 - DLT_JUNIPER_MLFR = 0x83 - DLT_JUNIPER_MLPPP = 0x82 - DLT_JUNIPER_MONITOR = 0xa4 - DLT_JUNIPER_PIC_PEER = 0xae - DLT_JUNIPER_PPP = 0xb3 - DLT_JUNIPER_PPPOE = 0xa7 - DLT_JUNIPER_PPPOE_ATM = 0xa8 - DLT_JUNIPER_SERVICES = 0x88 - DLT_JUNIPER_SRX_E2E = 0xe9 - DLT_JUNIPER_ST = 0xc8 - DLT_JUNIPER_VP = 0xb7 - DLT_JUNIPER_VS = 0xe8 - DLT_LAPB_WITH_DIR = 0xcf - DLT_LAPD = 0xcb - DLT_LIN = 0xd4 - DLT_LINUX_EVDEV = 0xd8 - DLT_LINUX_IRDA = 0x90 - DLT_LINUX_LAPD = 0xb1 - DLT_LINUX_PPP_WITHDIRECTION = 0xa6 - DLT_LINUX_SLL = 0x71 - DLT_LOOP = 0x6c - DLT_LTALK = 0x72 - DLT_MATCHING_MAX = 0xf6 - DLT_MATCHING_MIN = 0x68 - DLT_MFR = 0xb6 - DLT_MOST = 0xd3 - DLT_MPEG_2_TS = 0xf3 - DLT_MPLS = 0xdb - DLT_MTP2 = 0x8c - DLT_MTP2_WITH_PHDR = 0x8b - DLT_MTP3 = 0x8d - DLT_MUX27010 = 0xec - DLT_NETANALYZER = 0xf0 - DLT_NETANALYZER_TRANSPARENT = 0xf1 - DLT_NFC_LLCP = 0xf5 - DLT_NFLOG = 0xef - DLT_NG40 = 0xf4 - DLT_NULL = 0x0 - DLT_PCI_EXP = 0x7d - DLT_PFLOG = 0x75 - DLT_PFSYNC = 0x79 - DLT_PPI = 0xc0 - DLT_PPP = 0x9 - DLT_PPP_BSDOS = 0x10 - DLT_PPP_ETHER = 0x33 - DLT_PPP_PPPD = 0xa6 - DLT_PPP_SERIAL = 0x32 - DLT_PPP_WITH_DIR = 0xcc - DLT_PPP_WITH_DIRECTION = 0xa6 - DLT_PRISM_HEADER = 0x77 - DLT_PRONET = 0x4 - DLT_RAIF1 = 0xc6 - DLT_RAW = 0xc - DLT_RIO = 0x7c - DLT_SCCP = 0x8e - DLT_SITA = 0xc4 - DLT_SLIP = 0x8 - DLT_SLIP_BSDOS = 0xf - DLT_STANAG_5066_D_PDU = 0xed - DLT_SUNATM = 0x7b - DLT_SYMANTEC_FIREWALL = 0x63 - DLT_TZSP = 0x80 - DLT_USB = 0xba - DLT_USB_LINUX = 0xbd - DLT_USB_LINUX_MMAPPED = 0xdc - DLT_USER0 = 0x93 - DLT_USER1 = 0x94 - DLT_USER10 = 0x9d - DLT_USER11 = 0x9e - DLT_USER12 = 0x9f - DLT_USER13 = 0xa0 - DLT_USER14 = 0xa1 - DLT_USER15 = 0xa2 - DLT_USER2 = 0x95 - DLT_USER3 = 0x96 - DLT_USER4 = 0x97 - DLT_USER5 = 0x98 - DLT_USER6 = 0x99 - DLT_USER7 = 0x9a - DLT_USER8 = 0x9b - DLT_USER9 = 0x9c - DLT_WIHART = 0xdf - DLT_X2E_SERIAL = 0xd5 - DLT_X2E_XORAYA = 0xd6 - DT_BLK = 0x6 - DT_CHR = 0x2 - DT_DIR = 0x4 - DT_FIFO = 0x1 - DT_LNK = 0xa - DT_REG = 0x8 - DT_SOCK = 0xc - DT_UNKNOWN = 0x0 - DT_WHT = 0xe - ECHO = 0x8 - ECHOCTL = 0x40 - ECHOE = 0x2 - ECHOK = 0x4 - ECHOKE = 0x1 - ECHONL = 0x10 - ECHOPRT = 0x20 - EVFILT_AIO = -0x3 - EVFILT_FS = -0x9 - EVFILT_LIO = -0xa - EVFILT_PROC = -0x5 - EVFILT_READ = -0x1 - EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0xb - EVFILT_TIMER = -0x7 - EVFILT_USER = -0xb - EVFILT_VNODE = -0x4 - EVFILT_WRITE = -0x2 - EV_ADD = 0x1 - EV_CLEAR = 0x20 - EV_DELETE = 0x2 - EV_DISABLE = 0x8 - EV_DISPATCH = 0x80 - EV_DROP = 0x1000 - EV_ENABLE = 0x4 - EV_EOF = 0x8000 - EV_ERROR = 0x4000 - EV_FLAG1 = 0x2000 - EV_ONESHOT = 0x10 - EV_RECEIPT = 0x40 - EV_SYSFLAGS = 0xf000 - EXTA = 0x4b00 - EXTATTR_NAMESPACE_EMPTY = 0x0 - EXTATTR_NAMESPACE_SYSTEM = 0x2 - EXTATTR_NAMESPACE_USER = 0x1 - EXTB = 0x9600 - EXTPROC = 0x800 - FD_CLOEXEC = 0x1 - FD_SETSIZE = 0x400 - FLUSHO = 0x800000 - F_CANCEL = 0x5 - F_DUP2FD = 0xa - F_DUP2FD_CLOEXEC = 0x12 - F_DUPFD = 0x0 - F_DUPFD_CLOEXEC = 0x11 - F_GETFD = 0x1 - F_GETFL = 0x3 - F_GETLK = 0xb - F_GETOWN = 0x5 - F_OGETLK = 0x7 - F_OK = 0x0 - F_OSETLK = 0x8 - F_OSETLKW = 0x9 - F_RDAHEAD = 0x10 - F_RDLCK = 0x1 - F_READAHEAD = 0xf - F_SETFD = 0x2 - F_SETFL = 0x4 - F_SETLK = 0xc - F_SETLKW = 0xd - F_SETLK_REMOTE = 0xe - F_SETOWN = 0x6 - F_UNLCK = 0x2 - F_UNLCKSYS = 0x4 - F_WRLCK = 0x3 - HUPCL = 0x4000 - ICANON = 0x100 - ICMP6_FILTER = 0x12 - ICRNL = 0x100 - IEXTEN = 0x400 - IFAN_ARRIVAL = 0x0 - IFAN_DEPARTURE = 0x1 - IFF_ALLMULTI = 0x200 - IFF_ALTPHYS = 0x4000 - IFF_BROADCAST = 0x2 - IFF_CANTCHANGE = 0x218f72 - IFF_CANTCONFIG = 0x10000 - IFF_DEBUG = 0x4 - IFF_DRV_OACTIVE = 0x400 - IFF_DRV_RUNNING = 0x40 - IFF_DYING = 0x200000 - IFF_LINK0 = 0x1000 - IFF_LINK1 = 0x2000 - IFF_LINK2 = 0x4000 - IFF_LOOPBACK = 0x8 - IFF_MONITOR = 0x40000 - IFF_MULTICAST = 0x8000 - IFF_NOARP = 0x80 - IFF_OACTIVE = 0x400 - IFF_POINTOPOINT = 0x10 - IFF_PPROMISC = 0x20000 - IFF_PROMISC = 0x100 - IFF_RENAMING = 0x400000 - IFF_RUNNING = 0x40 - IFF_SIMPLEX = 0x800 - IFF_SMART = 0x20 - IFF_STATICARP = 0x80000 - IFF_UP = 0x1 - IFNAMSIZ = 0x10 - IFT_1822 = 0x2 - IFT_A12MPPSWITCH = 0x82 - IFT_AAL2 = 0xbb - IFT_AAL5 = 0x31 - IFT_ADSL = 0x5e - IFT_AFLANE8023 = 0x3b - IFT_AFLANE8025 = 0x3c - IFT_ARAP = 0x58 - IFT_ARCNET = 0x23 - IFT_ARCNETPLUS = 0x24 - IFT_ASYNC = 0x54 - IFT_ATM = 0x25 - IFT_ATMDXI = 0x69 - IFT_ATMFUNI = 0x6a - IFT_ATMIMA = 0x6b - IFT_ATMLOGICAL = 0x50 - IFT_ATMRADIO = 0xbd - IFT_ATMSUBINTERFACE = 0x86 - IFT_ATMVCIENDPT = 0xc2 - IFT_ATMVIRTUAL = 0x95 - IFT_BGPPOLICYACCOUNTING = 0xa2 - IFT_BRIDGE = 0xd1 - IFT_BSC = 0x53 - IFT_CARP = 0xf8 - IFT_CCTEMUL = 0x3d - IFT_CEPT = 0x13 - IFT_CES = 0x85 - IFT_CHANNEL = 0x46 - IFT_CNR = 0x55 - IFT_COFFEE = 0x84 - IFT_COMPOSITELINK = 0x9b - IFT_DCN = 0x8d - IFT_DIGITALPOWERLINE = 0x8a - IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba - IFT_DLSW = 0x4a - IFT_DOCSCABLEDOWNSTREAM = 0x80 - IFT_DOCSCABLEMACLAYER = 0x7f - IFT_DOCSCABLEUPSTREAM = 0x81 - IFT_DS0 = 0x51 - IFT_DS0BUNDLE = 0x52 - IFT_DS1FDL = 0xaa - IFT_DS3 = 0x1e - IFT_DTM = 0x8c - IFT_DVBASILN = 0xac - IFT_DVBASIOUT = 0xad - IFT_DVBRCCDOWNSTREAM = 0x93 - IFT_DVBRCCMACLAYER = 0x92 - IFT_DVBRCCUPSTREAM = 0x94 - IFT_ENC = 0xf4 - IFT_EON = 0x19 - IFT_EPLRS = 0x57 - IFT_ESCON = 0x49 - IFT_ETHER = 0x6 - IFT_FAITH = 0xf2 - IFT_FAST = 0x7d - IFT_FASTETHER = 0x3e - IFT_FASTETHERFX = 0x45 - IFT_FDDI = 0xf - IFT_FIBRECHANNEL = 0x38 - IFT_FRAMERELAYINTERCONNECT = 0x3a - IFT_FRAMERELAYMPI = 0x5c - IFT_FRDLCIENDPT = 0xc1 - IFT_FRELAY = 0x20 - IFT_FRELAYDCE = 0x2c - IFT_FRF16MFRBUNDLE = 0xa3 - IFT_FRFORWARD = 0x9e - IFT_G703AT2MB = 0x43 - IFT_G703AT64K = 0x42 - IFT_GIF = 0xf0 - IFT_GIGABITETHERNET = 0x75 - IFT_GR303IDT = 0xb2 - IFT_GR303RDT = 0xb1 - IFT_H323GATEKEEPER = 0xa4 - IFT_H323PROXY = 0xa5 - IFT_HDH1822 = 0x3 - IFT_HDLC = 0x76 - IFT_HDSL2 = 0xa8 - IFT_HIPERLAN2 = 0xb7 - IFT_HIPPI = 0x2f - IFT_HIPPIINTERFACE = 0x39 - IFT_HOSTPAD = 0x5a - IFT_HSSI = 0x2e - IFT_HY = 0xe - IFT_IBM370PARCHAN = 0x48 - IFT_IDSL = 0x9a - IFT_IEEE1394 = 0x90 - IFT_IEEE80211 = 0x47 - IFT_IEEE80212 = 0x37 - IFT_IEEE8023ADLAG = 0xa1 - IFT_IFGSN = 0x91 - IFT_IMT = 0xbe - IFT_INFINIBAND = 0xc7 - IFT_INTERLEAVE = 0x7c - IFT_IP = 0x7e - IFT_IPFORWARD = 0x8e - IFT_IPOVERATM = 0x72 - IFT_IPOVERCDLC = 0x6d - IFT_IPOVERCLAW = 0x6e - IFT_IPSWITCH = 0x4e - IFT_IPXIP = 0xf9 - IFT_ISDN = 0x3f - IFT_ISDNBASIC = 0x14 - IFT_ISDNPRIMARY = 0x15 - IFT_ISDNS = 0x4b - IFT_ISDNU = 0x4c - IFT_ISO88022LLC = 0x29 - IFT_ISO88023 = 0x7 - IFT_ISO88024 = 0x8 - IFT_ISO88025 = 0x9 - IFT_ISO88025CRFPINT = 0x62 - IFT_ISO88025DTR = 0x56 - IFT_ISO88025FIBER = 0x73 - IFT_ISO88026 = 0xa - IFT_ISUP = 0xb3 - IFT_L2VLAN = 0x87 - IFT_L3IPVLAN = 0x88 - IFT_L3IPXVLAN = 0x89 - IFT_LAPB = 0x10 - IFT_LAPD = 0x4d - IFT_LAPF = 0x77 - IFT_LOCALTALK = 0x2a - IFT_LOOP = 0x18 - IFT_MEDIAMAILOVERIP = 0x8b - IFT_MFSIGLINK = 0xa7 - IFT_MIOX25 = 0x26 - IFT_MODEM = 0x30 - IFT_MPC = 0x71 - IFT_MPLS = 0xa6 - IFT_MPLSTUNNEL = 0x96 - IFT_MSDSL = 0x8f - IFT_MVL = 0xbf - IFT_MYRINET = 0x63 - IFT_NFAS = 0xaf - IFT_NSIP = 0x1b - IFT_OPTICALCHANNEL = 0xc3 - IFT_OPTICALTRANSPORT = 0xc4 - IFT_OTHER = 0x1 - IFT_P10 = 0xc - IFT_P80 = 0xd - IFT_PARA = 0x22 - IFT_PFLOG = 0xf6 - IFT_PFSYNC = 0xf7 - IFT_PLC = 0xae - IFT_POS = 0xab - IFT_PPP = 0x17 - IFT_PPPMULTILINKBUNDLE = 0x6c - IFT_PROPBWAP2MP = 0xb8 - IFT_PROPCNLS = 0x59 - IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 - IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 - IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 - IFT_PROPMUX = 0x36 - IFT_PROPVIRTUAL = 0x35 - IFT_PROPWIRELESSP2P = 0x9d - IFT_PTPSERIAL = 0x16 - IFT_PVC = 0xf1 - IFT_QLLC = 0x44 - IFT_RADIOMAC = 0xbc - IFT_RADSL = 0x5f - IFT_REACHDSL = 0xc0 - IFT_RFC1483 = 0x9f - IFT_RS232 = 0x21 - IFT_RSRB = 0x4f - IFT_SDLC = 0x11 - IFT_SDSL = 0x60 - IFT_SHDSL = 0xa9 - IFT_SIP = 0x1f - IFT_SLIP = 0x1c - IFT_SMDSDXI = 0x2b - IFT_SMDSICIP = 0x34 - IFT_SONET = 0x27 - IFT_SONETOVERHEADCHANNEL = 0xb9 - IFT_SONETPATH = 0x32 - IFT_SONETVT = 0x33 - IFT_SRP = 0x97 - IFT_SS7SIGLINK = 0x9c - IFT_STACKTOSTACK = 0x6f - IFT_STARLAN = 0xb - IFT_STF = 0xd7 - IFT_T1 = 0x12 - IFT_TDLC = 0x74 - IFT_TERMPAD = 0x5b - IFT_TR008 = 0xb0 - IFT_TRANSPHDLC = 0x7b - IFT_TUNNEL = 0x83 - IFT_ULTRA = 0x1d - IFT_USB = 0xa0 - IFT_V11 = 0x40 - IFT_V35 = 0x2d - IFT_V36 = 0x41 - IFT_V37 = 0x78 - IFT_VDSL = 0x61 - IFT_VIRTUALIPADDRESS = 0x70 - IFT_VOICEEM = 0x64 - IFT_VOICEENCAP = 0x67 - IFT_VOICEFXO = 0x65 - IFT_VOICEFXS = 0x66 - IFT_VOICEOVERATM = 0x98 - IFT_VOICEOVERFRAMERELAY = 0x99 - IFT_VOICEOVERIP = 0x68 - IFT_X213 = 0x5d - IFT_X25 = 0x5 - IFT_X25DDN = 0x4 - IFT_X25HUNTGROUP = 0x7a - IFT_X25MLP = 0x79 - IFT_X25PLE = 0x28 - IFT_XETHER = 0x1a - IGNBRK = 0x1 - IGNCR = 0x80 - IGNPAR = 0x4 - IMAXBEL = 0x2000 - INLCR = 0x40 - INPCK = 0x10 - IN_CLASSA_HOST = 0xffffff - IN_CLASSA_MAX = 0x80 - IN_CLASSA_NET = 0xff000000 - IN_CLASSA_NSHIFT = 0x18 - IN_CLASSB_HOST = 0xffff - IN_CLASSB_MAX = 0x10000 - IN_CLASSB_NET = 0xffff0000 - IN_CLASSB_NSHIFT = 0x10 - IN_CLASSC_HOST = 0xff - IN_CLASSC_NET = 0xffffff00 - IN_CLASSC_NSHIFT = 0x8 - IN_CLASSD_HOST = 0xfffffff - IN_CLASSD_NET = 0xf0000000 - IN_CLASSD_NSHIFT = 0x1c - IN_LOOPBACKNET = 0x7f - IN_RFC3021_MASK = 0xfffffffe - IPPROTO_3PC = 0x22 - IPPROTO_ADFS = 0x44 - IPPROTO_AH = 0x33 - IPPROTO_AHIP = 0x3d - IPPROTO_APES = 0x63 - IPPROTO_ARGUS = 0xd - IPPROTO_AX25 = 0x5d - IPPROTO_BHA = 0x31 - IPPROTO_BLT = 0x1e - IPPROTO_BRSATMON = 0x4c - IPPROTO_CARP = 0x70 - IPPROTO_CFTP = 0x3e - IPPROTO_CHAOS = 0x10 - IPPROTO_CMTP = 0x26 - IPPROTO_CPHB = 0x49 - IPPROTO_CPNX = 0x48 - IPPROTO_DDP = 0x25 - IPPROTO_DGP = 0x56 - IPPROTO_DIVERT = 0x102 - IPPROTO_DONE = 0x101 - IPPROTO_DSTOPTS = 0x3c - IPPROTO_EGP = 0x8 - IPPROTO_EMCON = 0xe - IPPROTO_ENCAP = 0x62 - IPPROTO_EON = 0x50 - IPPROTO_ESP = 0x32 - IPPROTO_ETHERIP = 0x61 - IPPROTO_FRAGMENT = 0x2c - IPPROTO_GGP = 0x3 - IPPROTO_GMTP = 0x64 - IPPROTO_GRE = 0x2f - IPPROTO_HELLO = 0x3f - IPPROTO_HIP = 0x8b - IPPROTO_HMP = 0x14 - IPPROTO_HOPOPTS = 0x0 - IPPROTO_ICMP = 0x1 - IPPROTO_ICMPV6 = 0x3a - IPPROTO_IDP = 0x16 - IPPROTO_IDPR = 0x23 - IPPROTO_IDRP = 0x2d - IPPROTO_IGMP = 0x2 - IPPROTO_IGP = 0x55 - IPPROTO_IGRP = 0x58 - IPPROTO_IL = 0x28 - IPPROTO_INLSP = 0x34 - IPPROTO_INP = 0x20 - IPPROTO_IP = 0x0 - IPPROTO_IPCOMP = 0x6c - IPPROTO_IPCV = 0x47 - IPPROTO_IPEIP = 0x5e - IPPROTO_IPIP = 0x4 - IPPROTO_IPPC = 0x43 - IPPROTO_IPV4 = 0x4 - IPPROTO_IPV6 = 0x29 - IPPROTO_IRTP = 0x1c - IPPROTO_KRYPTOLAN = 0x41 - IPPROTO_LARP = 0x5b - IPPROTO_LEAF1 = 0x19 - IPPROTO_LEAF2 = 0x1a - IPPROTO_MAX = 0x100 - IPPROTO_MAXID = 0x34 - IPPROTO_MEAS = 0x13 - IPPROTO_MH = 0x87 - IPPROTO_MHRP = 0x30 - IPPROTO_MICP = 0x5f - IPPROTO_MOBILE = 0x37 - IPPROTO_MPLS = 0x89 - IPPROTO_MTP = 0x5c - IPPROTO_MUX = 0x12 - IPPROTO_ND = 0x4d - IPPROTO_NHRP = 0x36 - IPPROTO_NONE = 0x3b - IPPROTO_NSP = 0x1f - IPPROTO_NVPII = 0xb - IPPROTO_OLD_DIVERT = 0xfe - IPPROTO_OSPFIGP = 0x59 - IPPROTO_PFSYNC = 0xf0 - IPPROTO_PGM = 0x71 - IPPROTO_PIGP = 0x9 - IPPROTO_PIM = 0x67 - IPPROTO_PRM = 0x15 - IPPROTO_PUP = 0xc - IPPROTO_PVP = 0x4b - IPPROTO_RAW = 0xff - IPPROTO_RCCMON = 0xa - IPPROTO_RDP = 0x1b - IPPROTO_RESERVED_253 = 0xfd - IPPROTO_RESERVED_254 = 0xfe - IPPROTO_ROUTING = 0x2b - IPPROTO_RSVP = 0x2e - IPPROTO_RVD = 0x42 - IPPROTO_SATEXPAK = 0x40 - IPPROTO_SATMON = 0x45 - IPPROTO_SCCSP = 0x60 - IPPROTO_SCTP = 0x84 - IPPROTO_SDRP = 0x2a - IPPROTO_SEND = 0x103 - IPPROTO_SEP = 0x21 - IPPROTO_SHIM6 = 0x8c - IPPROTO_SKIP = 0x39 - IPPROTO_SPACER = 0x7fff - IPPROTO_SRPC = 0x5a - IPPROTO_ST = 0x7 - IPPROTO_SVMTP = 0x52 - IPPROTO_SWIPE = 0x35 - IPPROTO_TCF = 0x57 - IPPROTO_TCP = 0x6 - IPPROTO_TLSP = 0x38 - IPPROTO_TP = 0x1d - IPPROTO_TPXX = 0x27 - IPPROTO_TRUNK1 = 0x17 - IPPROTO_TRUNK2 = 0x18 - IPPROTO_TTP = 0x54 - IPPROTO_UDP = 0x11 - IPPROTO_UDPLITE = 0x88 - IPPROTO_VINES = 0x53 - IPPROTO_VISA = 0x46 - IPPROTO_VMTP = 0x51 - IPPROTO_WBEXPAK = 0x4f - IPPROTO_WBMON = 0x4e - IPPROTO_WSN = 0x4a - IPPROTO_XNET = 0xf - IPPROTO_XTP = 0x24 - IPV6_AUTOFLOWLABEL = 0x3b - IPV6_BINDANY = 0x40 - IPV6_BINDV6ONLY = 0x1b - IPV6_CHECKSUM = 0x1a - IPV6_DEFAULT_MULTICAST_HOPS = 0x1 - IPV6_DEFAULT_MULTICAST_LOOP = 0x1 - IPV6_DEFHLIM = 0x40 - IPV6_DONTFRAG = 0x3e - IPV6_DSTOPTS = 0x32 - IPV6_FAITH = 0x1d - IPV6_FLOWINFO_MASK = 0xffffff0f - IPV6_FLOWLABEL_MASK = 0xffff0f00 - IPV6_FRAGTTL = 0x78 - IPV6_FW_ADD = 0x1e - IPV6_FW_DEL = 0x1f - IPV6_FW_FLUSH = 0x20 - IPV6_FW_GET = 0x22 - IPV6_FW_ZERO = 0x21 - IPV6_HLIMDEC = 0x1 - IPV6_HOPLIMIT = 0x2f - IPV6_HOPOPTS = 0x31 - IPV6_IPSEC_POLICY = 0x1c - IPV6_JOIN_GROUP = 0xc - IPV6_LEAVE_GROUP = 0xd - IPV6_MAXHLIM = 0xff - IPV6_MAXOPTHDR = 0x800 - IPV6_MAXPACKET = 0xffff - IPV6_MAX_GROUP_SRC_FILTER = 0x200 - IPV6_MAX_MEMBERSHIPS = 0xfff - IPV6_MAX_SOCK_SRC_FILTER = 0x80 - IPV6_MIN_MEMBERSHIPS = 0x1f - IPV6_MMTU = 0x500 - IPV6_MSFILTER = 0x4a - IPV6_MULTICAST_HOPS = 0xa - IPV6_MULTICAST_IF = 0x9 - IPV6_MULTICAST_LOOP = 0xb - IPV6_NEXTHOP = 0x30 - IPV6_PATHMTU = 0x2c - IPV6_PKTINFO = 0x2e - IPV6_PORTRANGE = 0xe - IPV6_PORTRANGE_DEFAULT = 0x0 - IPV6_PORTRANGE_HIGH = 0x1 - IPV6_PORTRANGE_LOW = 0x2 - IPV6_PREFER_TEMPADDR = 0x3f - IPV6_RECVDSTOPTS = 0x28 - IPV6_RECVHOPLIMIT = 0x25 - IPV6_RECVHOPOPTS = 0x27 - IPV6_RECVPATHMTU = 0x2b - IPV6_RECVPKTINFO = 0x24 - IPV6_RECVRTHDR = 0x26 - IPV6_RECVTCLASS = 0x39 - IPV6_RTHDR = 0x33 - IPV6_RTHDRDSTOPTS = 0x23 - IPV6_RTHDR_LOOSE = 0x0 - IPV6_RTHDR_STRICT = 0x1 - IPV6_RTHDR_TYPE_0 = 0x0 - IPV6_SOCKOPT_RESERVED1 = 0x3 - IPV6_TCLASS = 0x3d - IPV6_UNICAST_HOPS = 0x4 - IPV6_USE_MIN_MTU = 0x2a - IPV6_V6ONLY = 0x1b - IPV6_VERSION = 0x60 - IPV6_VERSION_MASK = 0xf0 - IP_ADD_MEMBERSHIP = 0xc - IP_ADD_SOURCE_MEMBERSHIP = 0x46 - IP_BINDANY = 0x18 - IP_BLOCK_SOURCE = 0x48 - IP_DEFAULT_MULTICAST_LOOP = 0x1 - IP_DEFAULT_MULTICAST_TTL = 0x1 - IP_DF = 0x4000 - IP_DONTFRAG = 0x43 - IP_DROP_MEMBERSHIP = 0xd - IP_DROP_SOURCE_MEMBERSHIP = 0x47 - IP_DUMMYNET3 = 0x31 - IP_DUMMYNET_CONFIGURE = 0x3c - IP_DUMMYNET_DEL = 0x3d - IP_DUMMYNET_FLUSH = 0x3e - IP_DUMMYNET_GET = 0x40 - IP_FAITH = 0x16 - IP_FW3 = 0x30 - IP_FW_ADD = 0x32 - IP_FW_DEL = 0x33 - IP_FW_FLUSH = 0x34 - IP_FW_GET = 0x36 - IP_FW_NAT_CFG = 0x38 - IP_FW_NAT_DEL = 0x39 - IP_FW_NAT_GET_CONFIG = 0x3a - IP_FW_NAT_GET_LOG = 0x3b - IP_FW_RESETLOG = 0x37 - IP_FW_TABLE_ADD = 0x28 - IP_FW_TABLE_DEL = 0x29 - IP_FW_TABLE_FLUSH = 0x2a - IP_FW_TABLE_GETSIZE = 0x2b - IP_FW_TABLE_LIST = 0x2c - IP_FW_ZERO = 0x35 - IP_HDRINCL = 0x2 - IP_IPSEC_POLICY = 0x15 - IP_MAXPACKET = 0xffff - IP_MAX_GROUP_SRC_FILTER = 0x200 - IP_MAX_MEMBERSHIPS = 0xfff - IP_MAX_SOCK_MUTE_FILTER = 0x80 - IP_MAX_SOCK_SRC_FILTER = 0x80 - IP_MAX_SOURCE_FILTER = 0x400 - IP_MF = 0x2000 - IP_MINTTL = 0x42 - IP_MIN_MEMBERSHIPS = 0x1f - IP_MSFILTER = 0x4a - IP_MSS = 0x240 - IP_MULTICAST_IF = 0x9 - IP_MULTICAST_LOOP = 0xb - IP_MULTICAST_TTL = 0xa - IP_MULTICAST_VIF = 0xe - IP_OFFMASK = 0x1fff - IP_ONESBCAST = 0x17 - IP_OPTIONS = 0x1 - IP_PORTRANGE = 0x13 - IP_PORTRANGE_DEFAULT = 0x0 - IP_PORTRANGE_HIGH = 0x1 - IP_PORTRANGE_LOW = 0x2 - IP_RECVDSTADDR = 0x7 - IP_RECVIF = 0x14 - IP_RECVOPTS = 0x5 - IP_RECVRETOPTS = 0x6 - IP_RECVTOS = 0x44 - IP_RECVTTL = 0x41 - IP_RETOPTS = 0x8 - IP_RF = 0x8000 - IP_RSVP_OFF = 0x10 - IP_RSVP_ON = 0xf - IP_RSVP_VIF_OFF = 0x12 - IP_RSVP_VIF_ON = 0x11 - IP_SENDSRCADDR = 0x7 - IP_TOS = 0x3 - IP_TTL = 0x4 - IP_UNBLOCK_SOURCE = 0x49 - ISIG = 0x80 - ISTRIP = 0x20 - IXANY = 0x800 - IXOFF = 0x400 - IXON = 0x200 - LOCK_EX = 0x2 - LOCK_NB = 0x4 - LOCK_SH = 0x1 - LOCK_UN = 0x8 - MADV_AUTOSYNC = 0x7 - MADV_CORE = 0x9 - MADV_DONTNEED = 0x4 - MADV_FREE = 0x5 - MADV_NOCORE = 0x8 - MADV_NORMAL = 0x0 - MADV_NOSYNC = 0x6 - MADV_PROTECT = 0xa - MADV_RANDOM = 0x1 - MADV_SEQUENTIAL = 0x2 - MADV_WILLNEED = 0x3 - MAP_32BIT = 0x80000 - MAP_ALIGNED_SUPER = 0x1000000 - MAP_ALIGNMENT_MASK = -0x1000000 - MAP_ALIGNMENT_SHIFT = 0x18 - MAP_ANON = 0x1000 - MAP_ANONYMOUS = 0x1000 - MAP_COPY = 0x2 - MAP_EXCL = 0x4000 - MAP_FILE = 0x0 - MAP_FIXED = 0x10 - MAP_HASSEMAPHORE = 0x200 - MAP_NOCORE = 0x20000 - MAP_NORESERVE = 0x40 - MAP_NOSYNC = 0x800 - MAP_PREFAULT_READ = 0x40000 - MAP_PRIVATE = 0x2 - MAP_RENAME = 0x20 - MAP_RESERVED0080 = 0x80 - MAP_RESERVED0100 = 0x100 - MAP_SHARED = 0x1 - MAP_STACK = 0x400 - MCL_CURRENT = 0x1 - MCL_FUTURE = 0x2 - MSG_CMSG_CLOEXEC = 0x40000 - MSG_COMPAT = 0x8000 - MSG_CTRUNC = 0x20 - MSG_DONTROUTE = 0x4 - MSG_DONTWAIT = 0x80 - MSG_EOF = 0x100 - MSG_EOR = 0x8 - MSG_NBIO = 0x4000 - MSG_NOSIGNAL = 0x20000 - MSG_NOTIFICATION = 0x2000 - MSG_OOB = 0x1 - MSG_PEEK = 0x2 - MSG_TRUNC = 0x10 - MSG_WAITALL = 0x40 - MS_ASYNC = 0x1 - MS_INVALIDATE = 0x2 - MS_SYNC = 0x0 - NAME_MAX = 0xff - NET_RT_DUMP = 0x1 - NET_RT_FLAGS = 0x2 - NET_RT_IFLIST = 0x3 - NET_RT_IFLISTL = 0x5 - NET_RT_IFMALIST = 0x4 - NET_RT_MAXID = 0x6 - NOFLSH = 0x80000000 - NOTE_ATTRIB = 0x8 - NOTE_CHILD = 0x4 - NOTE_DELETE = 0x1 - NOTE_EXEC = 0x20000000 - NOTE_EXIT = 0x80000000 - NOTE_EXTEND = 0x4 - NOTE_FFAND = 0x40000000 - NOTE_FFCOPY = 0xc0000000 - NOTE_FFCTRLMASK = 0xc0000000 - NOTE_FFLAGSMASK = 0xffffff - NOTE_FFNOP = 0x0 - NOTE_FFOR = 0x80000000 - NOTE_FORK = 0x40000000 - NOTE_LINK = 0x10 - NOTE_LOWAT = 0x1 - NOTE_MSECONDS = 0x2 - NOTE_NSECONDS = 0x8 - NOTE_PCTRLMASK = 0xf0000000 - NOTE_PDATAMASK = 0xfffff - NOTE_RENAME = 0x20 - NOTE_REVOKE = 0x40 - NOTE_SECONDS = 0x1 - NOTE_TRACK = 0x1 - NOTE_TRACKERR = 0x2 - NOTE_TRIGGER = 0x1000000 - NOTE_USECONDS = 0x4 - NOTE_WRITE = 0x2 - OCRNL = 0x10 - ONLCR = 0x2 - ONLRET = 0x40 - ONOCR = 0x20 - ONOEOT = 0x8 - OPOST = 0x1 - O_ACCMODE = 0x3 - O_APPEND = 0x8 - O_ASYNC = 0x40 - O_CLOEXEC = 0x100000 - O_CREAT = 0x200 - O_DIRECT = 0x10000 - O_DIRECTORY = 0x20000 - O_EXCL = 0x800 - O_EXEC = 0x40000 - O_EXLOCK = 0x20 - O_FSYNC = 0x80 - O_NDELAY = 0x4 - O_NOCTTY = 0x8000 - O_NOFOLLOW = 0x100 - O_NONBLOCK = 0x4 - O_RDONLY = 0x0 - O_RDWR = 0x2 - O_SHLOCK = 0x10 - O_SYNC = 0x80 - O_TRUNC = 0x400 - O_TTY_INIT = 0x80000 - O_WRONLY = 0x1 - PARENB = 0x1000 - PARMRK = 0x8 - PARODD = 0x2000 - PENDIN = 0x20000000 - PRIO_PGRP = 0x1 - PRIO_PROCESS = 0x0 - PRIO_USER = 0x2 - PROT_EXEC = 0x4 - PROT_NONE = 0x0 - PROT_READ = 0x1 - PROT_WRITE = 0x2 - RLIMIT_AS = 0xa - RLIMIT_CORE = 0x4 - RLIMIT_CPU = 0x0 - RLIMIT_DATA = 0x2 - RLIMIT_FSIZE = 0x1 - RLIMIT_NOFILE = 0x8 - RLIMIT_STACK = 0x3 - RLIM_INFINITY = 0x7fffffffffffffff - RTAX_AUTHOR = 0x6 - RTAX_BRD = 0x7 - RTAX_DST = 0x0 - RTAX_GATEWAY = 0x1 - RTAX_GENMASK = 0x3 - RTAX_IFA = 0x5 - RTAX_IFP = 0x4 - RTAX_MAX = 0x8 - RTAX_NETMASK = 0x2 - RTA_AUTHOR = 0x40 - RTA_BRD = 0x80 - RTA_DST = 0x1 - RTA_GATEWAY = 0x2 - RTA_GENMASK = 0x8 - RTA_IFA = 0x20 - RTA_IFP = 0x10 - RTA_NETMASK = 0x4 - RTF_BLACKHOLE = 0x1000 - RTF_BROADCAST = 0x400000 - RTF_DONE = 0x40 - RTF_DYNAMIC = 0x10 - RTF_FMASK = 0x1004d808 - RTF_GATEWAY = 0x2 - RTF_GWFLAG_COMPAT = 0x80000000 - RTF_HOST = 0x4 - RTF_LLDATA = 0x400 - RTF_LLINFO = 0x400 - RTF_LOCAL = 0x200000 - RTF_MODIFIED = 0x20 - RTF_MULTICAST = 0x800000 - RTF_PINNED = 0x100000 - RTF_PRCLONING = 0x10000 - RTF_PROTO1 = 0x8000 - RTF_PROTO2 = 0x4000 - RTF_PROTO3 = 0x40000 - RTF_REJECT = 0x8 - RTF_RNH_LOCKED = 0x40000000 - RTF_STATIC = 0x800 - RTF_STICKY = 0x10000000 - RTF_UP = 0x1 - RTF_XRESOLVE = 0x200 - RTM_ADD = 0x1 - RTM_CHANGE = 0x3 - RTM_DELADDR = 0xd - RTM_DELETE = 0x2 - RTM_DELMADDR = 0x10 - RTM_GET = 0x4 - RTM_IEEE80211 = 0x12 - RTM_IFANNOUNCE = 0x11 - RTM_IFINFO = 0xe - RTM_LOCK = 0x8 - RTM_LOSING = 0x5 - RTM_MISS = 0x7 - RTM_NEWADDR = 0xc - RTM_NEWMADDR = 0xf - RTM_OLDADD = 0x9 - RTM_OLDDEL = 0xa - RTM_REDIRECT = 0x6 - RTM_RESOLVE = 0xb - RTM_RTTUNIT = 0xf4240 - RTM_VERSION = 0x5 - RTV_EXPIRE = 0x4 - RTV_HOPCOUNT = 0x2 - RTV_MTU = 0x1 - RTV_RPIPE = 0x8 - RTV_RTT = 0x40 - RTV_RTTVAR = 0x80 - RTV_SPIPE = 0x10 - RTV_SSTHRESH = 0x20 - RTV_WEIGHT = 0x100 - RT_ALL_FIBS = -0x1 - RT_CACHING_CONTEXT = 0x1 - RT_DEFAULT_FIB = 0x0 - RT_NORTREF = 0x2 - RUSAGE_CHILDREN = -0x1 - RUSAGE_SELF = 0x0 - RUSAGE_THREAD = 0x1 - SCM_BINTIME = 0x4 - SCM_CREDS = 0x3 - SCM_RIGHTS = 0x1 - SCM_TIMESTAMP = 0x2 - SHUT_RD = 0x0 - SHUT_RDWR = 0x2 - SHUT_WR = 0x1 - SIOCADDMULTI = 0x80206931 - SIOCADDRT = 0x8040720a - SIOCAIFADDR = 0x8040691a - SIOCAIFGROUP = 0x80286987 - SIOCALIFADDR = 0x8118691b - SIOCATMARK = 0x40047307 - SIOCDELMULTI = 0x80206932 - SIOCDELRT = 0x8040720b - SIOCDIFADDR = 0x80206919 - SIOCDIFGROUP = 0x80286989 - SIOCDIFPHYADDR = 0x80206949 - SIOCDLIFADDR = 0x8118691d - SIOCGDRVSPEC = 0xc028697b - SIOCGETSGCNT = 0xc0207210 - SIOCGETVIFCNT = 0xc028720f - SIOCGHIWAT = 0x40047301 - SIOCGIFADDR = 0xc0206921 - SIOCGIFBRDADDR = 0xc0206923 - SIOCGIFCAP = 0xc020691f - SIOCGIFCONF = 0xc0106924 - SIOCGIFDESCR = 0xc020692a - SIOCGIFDSTADDR = 0xc0206922 - SIOCGIFFIB = 0xc020695c - SIOCGIFFLAGS = 0xc0206911 - SIOCGIFGENERIC = 0xc020693a - SIOCGIFGMEMB = 0xc028698a - SIOCGIFGROUP = 0xc0286988 - SIOCGIFINDEX = 0xc0206920 - SIOCGIFMAC = 0xc0206926 - SIOCGIFMEDIA = 0xc0306938 - SIOCGIFMETRIC = 0xc0206917 - SIOCGIFMTU = 0xc0206933 - SIOCGIFNETMASK = 0xc0206925 - SIOCGIFPDSTADDR = 0xc0206948 - SIOCGIFPHYS = 0xc0206935 - SIOCGIFPSRCADDR = 0xc0206947 - SIOCGIFSTATUS = 0xc331693b - SIOCGLIFADDR = 0xc118691c - SIOCGLIFPHYADDR = 0xc118694b - SIOCGLOWAT = 0x40047303 - SIOCGPGRP = 0x40047309 - SIOCGPRIVATE_0 = 0xc0206950 - SIOCGPRIVATE_1 = 0xc0206951 - SIOCIFCREATE = 0xc020697a - SIOCIFCREATE2 = 0xc020697c - SIOCIFDESTROY = 0x80206979 - SIOCIFGCLONERS = 0xc0106978 - SIOCSDRVSPEC = 0x8028697b - SIOCSHIWAT = 0x80047300 - SIOCSIFADDR = 0x8020690c - SIOCSIFBRDADDR = 0x80206913 - SIOCSIFCAP = 0x8020691e - SIOCSIFDESCR = 0x80206929 - SIOCSIFDSTADDR = 0x8020690e - SIOCSIFFIB = 0x8020695d - SIOCSIFFLAGS = 0x80206910 - SIOCSIFGENERIC = 0x80206939 - SIOCSIFLLADDR = 0x8020693c - SIOCSIFMAC = 0x80206927 - SIOCSIFMEDIA = 0xc0206937 - SIOCSIFMETRIC = 0x80206918 - SIOCSIFMTU = 0x80206934 - SIOCSIFNAME = 0x80206928 - SIOCSIFNETMASK = 0x80206916 - SIOCSIFPHYADDR = 0x80406946 - SIOCSIFPHYS = 0x80206936 - SIOCSIFRVNET = 0xc020695b - SIOCSIFVNET = 0xc020695a - SIOCSLIFPHYADDR = 0x8118694a - SIOCSLOWAT = 0x80047302 - SIOCSPGRP = 0x80047308 - SOCK_CLOEXEC = 0x10000000 - SOCK_DGRAM = 0x2 - SOCK_MAXADDRLEN = 0xff - SOCK_NONBLOCK = 0x20000000 - SOCK_RAW = 0x3 - SOCK_RDM = 0x4 - SOCK_SEQPACKET = 0x5 - SOCK_STREAM = 0x1 - SOL_SOCKET = 0xffff - SOMAXCONN = 0x80 - SO_ACCEPTCONN = 0x2 - SO_ACCEPTFILTER = 0x1000 - SO_BINTIME = 0x2000 - SO_BROADCAST = 0x20 - SO_DEBUG = 0x1 - SO_DONTROUTE = 0x10 - SO_ERROR = 0x1007 - SO_KEEPALIVE = 0x8 - SO_LABEL = 0x1009 - SO_LINGER = 0x80 - SO_LISTENINCQLEN = 0x1013 - SO_LISTENQLEN = 0x1012 - SO_LISTENQLIMIT = 0x1011 - SO_NOSIGPIPE = 0x800 - SO_NO_DDP = 0x8000 - SO_NO_OFFLOAD = 0x4000 - SO_OOBINLINE = 0x100 - SO_PEERLABEL = 0x1010 - SO_PROTOCOL = 0x1016 - SO_PROTOTYPE = 0x1016 - SO_RCVBUF = 0x1002 - SO_RCVLOWAT = 0x1004 - SO_RCVTIMEO = 0x1006 - SO_REUSEADDR = 0x4 - SO_REUSEPORT = 0x200 - SO_SETFIB = 0x1014 - SO_SNDBUF = 0x1001 - SO_SNDLOWAT = 0x1003 - SO_SNDTIMEO = 0x1005 - SO_TIMESTAMP = 0x400 - SO_TYPE = 0x1008 - SO_USELOOPBACK = 0x40 - SO_USER_COOKIE = 0x1015 - SO_VENDOR = 0x80000000 - TCIFLUSH = 0x1 - TCIOFLUSH = 0x3 - TCOFLUSH = 0x2 - TCP_CA_NAME_MAX = 0x10 - TCP_CONGESTION = 0x40 - TCP_INFO = 0x20 - TCP_KEEPCNT = 0x400 - TCP_KEEPIDLE = 0x100 - TCP_KEEPINIT = 0x80 - TCP_KEEPINTVL = 0x200 - TCP_MAXBURST = 0x4 - TCP_MAXHLEN = 0x3c - TCP_MAXOLEN = 0x28 - TCP_MAXSEG = 0x2 - TCP_MAXWIN = 0xffff - TCP_MAX_SACK = 0x4 - TCP_MAX_WINSHIFT = 0xe - TCP_MD5SIG = 0x10 - TCP_MINMSS = 0xd8 - TCP_MSS = 0x218 - TCP_NODELAY = 0x1 - TCP_NOOPT = 0x8 - TCP_NOPUSH = 0x4 - TCP_VENDOR = 0x80000000 - TCSAFLUSH = 0x2 - TIOCCBRK = 0x2000747a - TIOCCDTR = 0x20007478 - TIOCCONS = 0x80047462 - TIOCDRAIN = 0x2000745e - TIOCEXCL = 0x2000740d - TIOCEXT = 0x80047460 - TIOCFLUSH = 0x80047410 - TIOCGDRAINWAIT = 0x40047456 - TIOCGETA = 0x402c7413 - TIOCGETD = 0x4004741a - TIOCGPGRP = 0x40047477 - TIOCGPTN = 0x4004740f - TIOCGSID = 0x40047463 - TIOCGWINSZ = 0x40087468 - TIOCMBIC = 0x8004746b - TIOCMBIS = 0x8004746c - TIOCMGDTRWAIT = 0x4004745a - TIOCMGET = 0x4004746a - TIOCMSDTRWAIT = 0x8004745b - TIOCMSET = 0x8004746d - TIOCM_CAR = 0x40 - TIOCM_CD = 0x40 - TIOCM_CTS = 0x20 - TIOCM_DCD = 0x40 - TIOCM_DSR = 0x100 - TIOCM_DTR = 0x2 - TIOCM_LE = 0x1 - TIOCM_RI = 0x80 - TIOCM_RNG = 0x80 - TIOCM_RTS = 0x4 - TIOCM_SR = 0x10 - TIOCM_ST = 0x8 - TIOCNOTTY = 0x20007471 - TIOCNXCL = 0x2000740e - TIOCOUTQ = 0x40047473 - TIOCPKT = 0x80047470 - TIOCPKT_DATA = 0x0 - TIOCPKT_DOSTOP = 0x20 - TIOCPKT_FLUSHREAD = 0x1 - TIOCPKT_FLUSHWRITE = 0x2 - TIOCPKT_IOCTL = 0x40 - TIOCPKT_NOSTOP = 0x10 - TIOCPKT_START = 0x8 - TIOCPKT_STOP = 0x4 - TIOCPTMASTER = 0x2000741c - TIOCSBRK = 0x2000747b - TIOCSCTTY = 0x20007461 - TIOCSDRAINWAIT = 0x80047457 - TIOCSDTR = 0x20007479 - TIOCSETA = 0x802c7414 - TIOCSETAF = 0x802c7416 - TIOCSETAW = 0x802c7415 - TIOCSETD = 0x8004741b - TIOCSIG = 0x2004745f - TIOCSPGRP = 0x80047476 - TIOCSTART = 0x2000746e - TIOCSTAT = 0x20007465 - TIOCSTI = 0x80017472 - TIOCSTOP = 0x2000746f - TIOCSWINSZ = 0x80087467 - TIOCTIMESTAMP = 0x40107459 - TIOCUCNTL = 0x80047466 - TOSTOP = 0x400000 - VDISCARD = 0xf - VDSUSP = 0xb - VEOF = 0x0 - VEOL = 0x1 - VEOL2 = 0x2 - VERASE = 0x3 - VERASE2 = 0x7 - VINTR = 0x8 - VKILL = 0x5 - VLNEXT = 0xe - VMIN = 0x10 - VQUIT = 0x9 - VREPRINT = 0x6 - VSTART = 0xc - VSTATUS = 0x12 - VSTOP = 0xd - VSUSP = 0xa - VTIME = 0x11 - VWERASE = 0x4 - WCONTINUED = 0x4 - WCOREFLAG = 0x80 - WEXITED = 0x10 - WLINUXCLONE = 0x80000000 - WNOHANG = 0x1 - WNOWAIT = 0x8 - WSTOPPED = 0x2 - WTRAPPED = 0x20 - WUNTRACED = 0x2 + AF_APPLETALK = 0x10 + AF_ARP = 0x23 + AF_ATM = 0x1e + AF_BLUETOOTH = 0x24 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x25 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1c + AF_INET6_SDP = 0x2a + AF_INET_SDP = 0x28 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x2a + AF_NATM = 0x1d + AF_NETBIOS = 0x6 + AF_NETGRAPH = 0x20 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x11 + AF_SCLUSTER = 0x22 + AF_SIP = 0x18 + AF_SLOW = 0x21 + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VENDOR00 = 0x27 + AF_VENDOR01 = 0x29 + AF_VENDOR02 = 0x2b + AF_VENDOR03 = 0x2d + AF_VENDOR04 = 0x2f + AF_VENDOR05 = 0x31 + AF_VENDOR06 = 0x33 + AF_VENDOR07 = 0x35 + AF_VENDOR08 = 0x37 + AF_VENDOR09 = 0x39 + AF_VENDOR10 = 0x3b + AF_VENDOR11 = 0x3d + AF_VENDOR12 = 0x3f + AF_VENDOR13 = 0x41 + AF_VENDOR14 = 0x43 + AF_VENDOR15 = 0x45 + AF_VENDOR16 = 0x47 + AF_VENDOR17 = 0x49 + AF_VENDOR18 = 0x4b + AF_VENDOR19 = 0x4d + AF_VENDOR20 = 0x4f + AF_VENDOR21 = 0x51 + AF_VENDOR22 = 0x53 + AF_VENDOR23 = 0x55 + AF_VENDOR24 = 0x57 + AF_VENDOR25 = 0x59 + AF_VENDOR26 = 0x5b + AF_VENDOR27 = 0x5d + AF_VENDOR28 = 0x5f + AF_VENDOR29 = 0x61 + AF_VENDOR30 = 0x63 + AF_VENDOR31 = 0x65 + AF_VENDOR32 = 0x67 + AF_VENDOR33 = 0x69 + AF_VENDOR34 = 0x6b + AF_VENDOR35 = 0x6d + AF_VENDOR36 = 0x6f + AF_VENDOR37 = 0x71 + AF_VENDOR38 = 0x73 + AF_VENDOR39 = 0x75 + AF_VENDOR40 = 0x77 + AF_VENDOR41 = 0x79 + AF_VENDOR42 = 0x7b + AF_VENDOR43 = 0x7d + AF_VENDOR44 = 0x7f + AF_VENDOR45 = 0x81 + AF_VENDOR46 = 0x83 + AF_VENDOR47 = 0x85 + ALTWERASE = 0x200 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B460800 = 0x70800 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B921600 = 0xe1000 + B9600 = 0x2580 + BIOCFEEDBACK = 0x8004427c + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDIRECTION = 0x40044276 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc0104279 + BIOCGETBUFMODE = 0x4004427d + BIOCGETIF = 0x4020426b + BIOCGETZMAX = 0x4008427f + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4010426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCGTSTAMP = 0x40044283 + BIOCIMMEDIATE = 0x80044270 + BIOCLOCK = 0x2000427a + BIOCPROMISC = 0x20004269 + BIOCROTZBUF = 0x40184280 + BIOCSBLEN = 0xc0044266 + BIOCSDIRECTION = 0x80044277 + BIOCSDLT = 0x80044278 + BIOCSETBUFMODE = 0x8004427e + BIOCSETF = 0x80104267 + BIOCSETFNR = 0x80104282 + BIOCSETIF = 0x8020426c + BIOCSETWF = 0x8010427b + BIOCSETZBUF = 0x80184281 + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8010426d + BIOCSSEESENT = 0x80044277 + BIOCSTSTAMP = 0x80044284 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x8 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_BUFMODE_BUFFER = 0x1 + BPF_BUFMODE_ZBUF = 0x2 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_T_BINTIME = 0x2 + BPF_T_BINTIME_FAST = 0x102 + BPF_T_BINTIME_MONOTONIC = 0x202 + BPF_T_BINTIME_MONOTONIC_FAST = 0x302 + BPF_T_FAST = 0x100 + BPF_T_FLAG_MASK = 0x300 + BPF_T_FORMAT_MASK = 0x3 + BPF_T_MICROTIME = 0x0 + BPF_T_MICROTIME_FAST = 0x100 + BPF_T_MICROTIME_MONOTONIC = 0x200 + BPF_T_MICROTIME_MONOTONIC_FAST = 0x300 + BPF_T_MONOTONIC = 0x200 + BPF_T_MONOTONIC_FAST = 0x300 + BPF_T_NANOTIME = 0x1 + BPF_T_NANOTIME_FAST = 0x101 + BPF_T_NANOTIME_MONOTONIC = 0x201 + BPF_T_NANOTIME_MONOTONIC_FAST = 0x301 + BPF_T_NONE = 0x3 + BPF_T_NORMAL = 0x0 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + CAP_ACCEPT = 0x200000020000000 + CAP_ACL_CHECK = 0x400000000010000 + CAP_ACL_DELETE = 0x400000000020000 + CAP_ACL_GET = 0x400000000040000 + CAP_ACL_SET = 0x400000000080000 + CAP_ALL0 = 0x20007ffffffffff + CAP_ALL1 = 0x4000000001fffff + CAP_BIND = 0x200000040000000 + CAP_BINDAT = 0x200008000000400 + CAP_CHFLAGSAT = 0x200000000001400 + CAP_CONNECT = 0x200000080000000 + CAP_CONNECTAT = 0x200010000000400 + CAP_CREATE = 0x200000000000040 + CAP_EVENT = 0x400000000000020 + CAP_EXTATTR_DELETE = 0x400000000001000 + CAP_EXTATTR_GET = 0x400000000002000 + CAP_EXTATTR_LIST = 0x400000000004000 + CAP_EXTATTR_SET = 0x400000000008000 + CAP_FCHDIR = 0x200000000000800 + CAP_FCHFLAGS = 0x200000000001000 + CAP_FCHMOD = 0x200000000002000 + CAP_FCHMODAT = 0x200000000002400 + CAP_FCHOWN = 0x200000000004000 + CAP_FCHOWNAT = 0x200000000004400 + CAP_FCNTL = 0x200000000008000 + CAP_FCNTL_ALL = 0x78 + CAP_FCNTL_GETFL = 0x8 + CAP_FCNTL_GETOWN = 0x20 + CAP_FCNTL_SETFL = 0x10 + CAP_FCNTL_SETOWN = 0x40 + CAP_FEXECVE = 0x200000000000080 + CAP_FLOCK = 0x200000000010000 + CAP_FPATHCONF = 0x200000000020000 + CAP_FSCK = 0x200000000040000 + CAP_FSTAT = 0x200000000080000 + CAP_FSTATAT = 0x200000000080400 + CAP_FSTATFS = 0x200000000100000 + CAP_FSYNC = 0x200000000000100 + CAP_FTRUNCATE = 0x200000000000200 + CAP_FUTIMES = 0x200000000200000 + CAP_FUTIMESAT = 0x200000000200400 + CAP_GETPEERNAME = 0x200000100000000 + CAP_GETSOCKNAME = 0x200000200000000 + CAP_GETSOCKOPT = 0x200000400000000 + CAP_IOCTL = 0x400000000000080 + CAP_IOCTLS_ALL = 0x7fffffffffffffff + CAP_KQUEUE = 0x400000000100040 + CAP_KQUEUE_CHANGE = 0x400000000100000 + CAP_KQUEUE_EVENT = 0x400000000000040 + CAP_LINKAT_SOURCE = 0x200020000000400 + CAP_LINKAT_TARGET = 0x200000000400400 + CAP_LISTEN = 0x200000800000000 + CAP_LOOKUP = 0x200000000000400 + CAP_MAC_GET = 0x400000000000001 + CAP_MAC_SET = 0x400000000000002 + CAP_MKDIRAT = 0x200000000800400 + CAP_MKFIFOAT = 0x200000001000400 + CAP_MKNODAT = 0x200000002000400 + CAP_MMAP = 0x200000000000010 + CAP_MMAP_R = 0x20000000000001d + CAP_MMAP_RW = 0x20000000000001f + CAP_MMAP_RWX = 0x20000000000003f + CAP_MMAP_RX = 0x20000000000003d + CAP_MMAP_W = 0x20000000000001e + CAP_MMAP_WX = 0x20000000000003e + CAP_MMAP_X = 0x20000000000003c + CAP_PDGETPID = 0x400000000000200 + CAP_PDKILL = 0x400000000000800 + CAP_PDWAIT = 0x400000000000400 + CAP_PEELOFF = 0x200001000000000 + CAP_POLL_EVENT = 0x400000000000020 + CAP_PREAD = 0x20000000000000d + CAP_PWRITE = 0x20000000000000e + CAP_READ = 0x200000000000001 + CAP_RECV = 0x200000000000001 + CAP_RENAMEAT_SOURCE = 0x200000004000400 + CAP_RENAMEAT_TARGET = 0x200040000000400 + CAP_RIGHTS_VERSION = 0x0 + CAP_RIGHTS_VERSION_00 = 0x0 + CAP_SEEK = 0x20000000000000c + CAP_SEEK_TELL = 0x200000000000004 + CAP_SEM_GETVALUE = 0x400000000000004 + CAP_SEM_POST = 0x400000000000008 + CAP_SEM_WAIT = 0x400000000000010 + CAP_SEND = 0x200000000000002 + CAP_SETSOCKOPT = 0x200002000000000 + CAP_SHUTDOWN = 0x200004000000000 + CAP_SOCK_CLIENT = 0x200007780000003 + CAP_SOCK_SERVER = 0x200007f60000003 + CAP_SYMLINKAT = 0x200000008000400 + CAP_TTYHOOK = 0x400000000000100 + CAP_UNLINKAT = 0x200000010000400 + CAP_UNUSED0_44 = 0x200080000000000 + CAP_UNUSED0_57 = 0x300000000000000 + CAP_UNUSED1_22 = 0x400000000200000 + CAP_UNUSED1_57 = 0x500000000000000 + CAP_WRITE = 0x200000000000002 + CFLUSH = 0xf + CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x4 + CLOCK_MONOTONIC_FAST = 0xc + CLOCK_MONOTONIC_PRECISE = 0xb + CLOCK_PROCESS_CPUTIME_ID = 0xf + CLOCK_PROF = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_FAST = 0xa + CLOCK_REALTIME_PRECISE = 0x9 + CLOCK_SECOND = 0xd + CLOCK_THREAD_CPUTIME_ID = 0xe + CLOCK_UPTIME = 0x5 + CLOCK_UPTIME_FAST = 0x8 + CLOCK_UPTIME_PRECISE = 0x7 + CLOCK_VIRTUAL = 0x1 + CREAD = 0x800 + CRTSCTS = 0x30000 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0x18 + CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_BREDR_BB = 0xff + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_BLUETOOTH_LE_LL = 0xfb + DLT_BLUETOOTH_LE_LL_WITH_PHDR = 0x100 + DLT_BLUETOOTH_LINUX_MONITOR = 0xfe + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_EPON = 0x103 + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HHDLC = 0x79 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_INFINIBAND = 0xf7 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPMI_HPM_2 = 0x104 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0x104 + DLT_MATCHING_MIN = 0x68 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NETLINK = 0xfd + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x79 + DLT_PKTAP = 0x102 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 + DLT_PRISM_HEADER = 0x77 + DLT_PROFIBUS_DL = 0x101 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RIO = 0x7c + DLT_RTAC_SERIAL = 0xfa + DLT_SCCP = 0x8e + DLT_SCTP = 0xf8 + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DLT_STANAG_5066_D_PDU = 0xed + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USBPCAP = 0xf9 + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WIHART = 0xdf + DLT_WIRESHARK_UPPER_PDU = 0xfc + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_FS = -0x9 + EVFILT_LIO = -0xa + EVFILT_PROC = -0x5 + EVFILT_PROCDESC = -0x8 + EVFILT_READ = -0x1 + EVFILT_SENDFILE = -0xc + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0xc + EVFILT_TIMER = -0x7 + EVFILT_USER = -0xb + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_DROP = 0x1000 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_FLAG2 = 0x4000 + EV_FORCEONESHOT = 0x100 + EV_ONESHOT = 0x10 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTATTR_NAMESPACE_EMPTY = 0x0 + EXTATTR_NAMESPACE_SYSTEM = 0x2 + EXTATTR_NAMESPACE_USER = 0x1 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_CANCEL = 0x5 + F_DUP2FD = 0xa + F_DUP2FD_CLOEXEC = 0x12 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x11 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0xb + F_GETOWN = 0x5 + F_OGETLK = 0x7 + F_OK = 0x0 + F_OSETLK = 0x8 + F_OSETLKW = 0x9 + F_RDAHEAD = 0x10 + F_RDLCK = 0x1 + F_READAHEAD = 0xf + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0xc + F_SETLKW = 0xd + F_SETLK_REMOTE = 0xe + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_UNLCKSYS = 0x4 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x218f52 + IFF_CANTCONFIG = 0x10000 + IFF_DEBUG = 0x4 + IFF_DRV_OACTIVE = 0x400 + IFF_DRV_RUNNING = 0x40 + IFF_DYING = 0x200000 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MONITOR = 0x40000 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PPROMISC = 0x20000 + IFF_PROMISC = 0x100 + IFF_RENAMING = 0x400000 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_STATICARP = 0x80000 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + IFT_BRIDGE = 0xd1 + IFT_CARP = 0xf8 + IFT_IEEE1394 = 0x90 + IFT_INFINIBAND = 0xc7 + IFT_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + IFT_PPP = 0x17 + IFT_PROPVIRTUAL = 0x35 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IN_RFC3021_MASK = 0xfffffffe + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CARP = 0x70 + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0x102 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HIP = 0x8b + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MEAS = 0x13 + IPPROTO_MH = 0x87 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MOBILE = 0x37 + IPPROTO_MPLS = 0x89 + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OLD_DIVERT = 0xfe + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_RESERVED_253 = 0xfd + IPPROTO_RESERVED_254 = 0xfe + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEND = 0x103 + IPPROTO_SEP = 0x21 + IPPROTO_SHIM6 = 0x8c + IPPROTO_SKIP = 0x39 + IPPROTO_SPACER = 0x7fff + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TLSP = 0x38 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_BINDANY = 0x40 + IPV6_BINDMULTI = 0x41 + IPV6_BINDV6ONLY = 0x1b + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_FLOWID = 0x43 + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FLOWTYPE = 0x44 + IPV6_FRAGTTL = 0x78 + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 + IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f + IPV6_MMTU = 0x500 + IPV6_MSFILTER = 0x4a + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_PREFER_TEMPADDR = 0x3f + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVFLOWID = 0x46 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRSSBUCKETID = 0x47 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RSSBUCKETID = 0x45 + IPV6_RSS_LISTEN_BUCKET = 0x42 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BINDANY = 0x18 + IP_BINDMULTI = 0x19 + IP_BLOCK_SOURCE = 0x48 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DONTFRAG = 0x43 + IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 + IP_DUMMYNET3 = 0x31 + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FLOWID = 0x5a + IP_FLOWTYPE = 0x5b + IP_FW3 = 0x30 + IP_FW_ADD = 0x32 + IP_FW_DEL = 0x33 + IP_FW_FLUSH = 0x34 + IP_FW_GET = 0x36 + IP_FW_NAT_CFG = 0x38 + IP_FW_NAT_DEL = 0x39 + IP_FW_NAT_GET_CONFIG = 0x3a + IP_FW_NAT_GET_LOG = 0x3b + IP_FW_RESETLOG = 0x37 + IP_FW_TABLE_ADD = 0x28 + IP_FW_TABLE_DEL = 0x29 + IP_FW_TABLE_FLUSH = 0x2a + IP_FW_TABLE_GETSIZE = 0x2b + IP_FW_TABLE_LIST = 0x2c + IP_FW_ZERO = 0x35 + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 + IP_MAX_SOURCE_FILTER = 0x400 + IP_MF = 0x2000 + IP_MINTTL = 0x42 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_OFFMASK = 0x1fff + IP_ONESBCAST = 0x17 + IP_OPTIONS = 0x1 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVFLOWID = 0x5d + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVRSSBUCKETID = 0x5e + IP_RECVTOS = 0x44 + IP_RECVTTL = 0x41 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSSBUCKETID = 0x5c + IP_RSS_LISTEN_BUCKET = 0x1a + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_SENDSRCADDR = 0x7 + IP_TOS = 0x3 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 + ISIG = 0x80 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_AUTOSYNC = 0x7 + MADV_CORE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_NOCORE = 0x8 + MADV_NORMAL = 0x0 + MADV_NOSYNC = 0x6 + MADV_PROTECT = 0xa + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MAP_32BIT = 0x80000 + MAP_ALIGNED_SUPER = 0x1000000 + MAP_ALIGNMENT_MASK = -0x1000000 + MAP_ALIGNMENT_SHIFT = 0x18 + MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 + MAP_COPY = 0x2 + MAP_EXCL = 0x4000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_NOCORE = 0x20000 + MAP_NOSYNC = 0x800 + MAP_PREFAULT_READ = 0x40000 + MAP_PRIVATE = 0x2 + MAP_RESERVED0020 = 0x20 + MAP_RESERVED0040 = 0x40 + MAP_RESERVED0080 = 0x80 + MAP_RESERVED0100 = 0x100 + MAP_SHARED = 0x1 + MAP_STACK = 0x400 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_CMSG_CLOEXEC = 0x40000 + MSG_COMPAT = 0x8000 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_NBIO = 0x4000 + MSG_NOSIGNAL = 0x20000 + MSG_NOTIFICATION = 0x2000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MSG_WAITFORONE = 0x80000 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x2 + MS_SYNC = 0x0 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_IFLISTL = 0x5 + NET_RT_IFMALIST = 0x4 + NOFLSH = 0x80000000 + NOKERNINFO = 0x2000000 + NOTE_ATTRIB = 0x8 + NOTE_CHILD = 0x4 + NOTE_CLOSE = 0x100 + NOTE_CLOSE_WRITE = 0x200 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 + NOTE_FILE_POLL = 0x2 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_MSECONDS = 0x2 + NOTE_NSECONDS = 0x8 + NOTE_OPEN = 0x80 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_READ = 0x400 + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_SECONDS = 0x1 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_USECONDS = 0x4 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + OXTABS = 0x4 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x100000 + O_CREAT = 0x200 + O_DIRECT = 0x10000 + O_DIRECTORY = 0x20000 + O_EXCL = 0x800 + O_EXEC = 0x40000 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_TTY_INIT = 0x80000 + O_VERIFY = 0x200000 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_AS = 0xa + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 + RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x8 + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_FIXEDMTU = 0x80000 + RTF_FMASK = 0x1004d808 + RTF_GATEWAY = 0x2 + RTF_GWFLAG_COMPAT = 0x80000000 + RTF_HOST = 0x4 + RTF_LLDATA = 0x400 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MULTICAST = 0x800000 + RTF_PINNED = 0x100000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_REJECT = 0x8 + RTF_RNH_LOCKED = 0x40000000 + RTF_STATIC = 0x800 + RTF_STICKY = 0x10000000 + RTF_UP = 0x1 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_IEEE80211 = 0x12 + RTM_IFANNOUNCE = 0x11 + RTM_IFINFO = 0xe + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RTV_WEIGHT = 0x100 + RT_ALL_FIBS = -0x1 + RT_BLACKHOLE = 0x40 + RT_CACHING_CONTEXT = 0x1 + RT_DEFAULT_FIB = 0x0 + RT_HAS_GW = 0x80 + RT_HAS_HEADER = 0x10 + RT_HAS_HEADER_BIT = 0x4 + RT_L2_ME = 0x4 + RT_L2_ME_BIT = 0x2 + RT_LLE_CACHE = 0x100 + RT_MAY_LOOP = 0x8 + RT_MAY_LOOP_BIT = 0x3 + RT_NORTREF = 0x2 + RT_REJECT = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_BINTIME = 0x4 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCAIFGROUP = 0x80286987 + SIOCATMARK = 0x40047307 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFGROUP = 0x80286989 + SIOCDIFPHYADDR = 0x80206949 + SIOCGDRVSPEC = 0xc028697b + SIOCGETSGCNT = 0xc0207210 + SIOCGETVIFCNT = 0xc028720f + SIOCGHIWAT = 0x40047301 + SIOCGI2C = 0xc020693d + SIOCGIFADDR = 0xc0206921 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020691f + SIOCGIFCONF = 0xc0106924 + SIOCGIFDESCR = 0xc020692a + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFIB = 0xc020695c + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGENERIC = 0xc020693a + SIOCGIFGMEMB = 0xc028698a + SIOCGIFGROUP = 0xc0286988 + SIOCGIFINDEX = 0xc0206920 + SIOCGIFMAC = 0xc0206926 + SIOCGIFMEDIA = 0xc0306938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206948 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPSRCADDR = 0xc0206947 + SIOCGIFSTATUS = 0xc331693b + SIOCGIFXMEDIA = 0xc030698b + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCGPRIVATE_0 = 0xc0206950 + SIOCGPRIVATE_1 = 0xc0206951 + SIOCGTUNFIB = 0xc020695e + SIOCIFCREATE = 0xc020697a + SIOCIFCREATE2 = 0xc020697c + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc0106978 + SIOCSDRVSPEC = 0x8028697b + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020691e + SIOCSIFDESCR = 0x80206929 + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFIB = 0x8020695d + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206927 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNAME = 0x80206928 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x80406946 + SIOCSIFPHYS = 0x80206936 + SIOCSIFRVNET = 0xc020695b + SIOCSIFVNET = 0xc020695a + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SIOCSTUNFIB = 0x8020695f + SOCK_CLOEXEC = 0x10000000 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_NONBLOCK = 0x20000000 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_ACCEPTFILTER = 0x1000 + SO_BINTIME = 0x2000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1009 + SO_LINGER = 0x80 + SO_LISTENINCQLEN = 0x1013 + SO_LISTENQLEN = 0x1012 + SO_LISTENQLIMIT = 0x1011 + SO_NOSIGPIPE = 0x800 + SO_NO_DDP = 0x8000 + SO_NO_OFFLOAD = 0x4000 + SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1010 + SO_PROTOCOL = 0x1016 + SO_PROTOTYPE = 0x1016 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_SETFIB = 0x1014 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + SO_USER_COOKIE = 0x1015 + SO_VENDOR = 0x80000000 + TAB0 = 0x0 + TAB3 = 0x4 + TABDLY = 0x4 + TCIFLUSH = 0x1 + TCIOFF = 0x3 + TCIOFLUSH = 0x3 + TCION = 0x4 + TCOFLUSH = 0x2 + TCOOFF = 0x1 + TCOON = 0x2 + TCP_CA_NAME_MAX = 0x10 + TCP_CCALGOOPT = 0x41 + TCP_CONGESTION = 0x40 + TCP_FASTOPEN = 0x401 + TCP_FUNCTION_BLK = 0x2000 + TCP_FUNCTION_NAME_LEN_MAX = 0x20 + TCP_INFO = 0x20 + TCP_KEEPCNT = 0x400 + TCP_KEEPIDLE = 0x100 + TCP_KEEPINIT = 0x80 + TCP_KEEPINTVL = 0x200 + TCP_MAXBURST = 0x4 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x10 + TCP_MINMSS = 0xd8 + TCP_MSS = 0x218 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_PCAP_IN = 0x1000 + TCP_PCAP_OUT = 0x800 + TCP_VENDOR = 0x80000000 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGPTN = 0x4004740f + TIOCGSID = 0x40047463 + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DCD = 0x40 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTMASTER = 0x2000741c + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2004745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40107459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VERASE2 = 0x7 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x4 + WCOREFLAG = 0x80 + WEXITED = 0x10 + WLINUXCLONE = 0x80000000 + WNOHANG = 0x1 + WNOWAIT = 0x8 + WSTOPPED = 0x2 + WTRAPPED = 0x20 + WUNTRACED = 0x2 ) // Errors diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go index 2afbe2d5e..c5c6f13e5 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go @@ -1,5 +1,5 @@ // mkerrors.sh -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build arm,freebsd @@ -11,1442 +11,1428 @@ package unix import "syscall" const ( - AF_APPLETALK = 0x10 - AF_ARP = 0x23 - AF_ATM = 0x1e - AF_BLUETOOTH = 0x24 - AF_CCITT = 0xa - AF_CHAOS = 0x5 - AF_CNT = 0x15 - AF_COIP = 0x14 - AF_DATAKIT = 0x9 - AF_DECnet = 0xc - AF_DLI = 0xd - AF_E164 = 0x1a - AF_ECMA = 0x8 - AF_HYLINK = 0xf - AF_IEEE80211 = 0x25 - AF_IMPLINK = 0x3 - AF_INET = 0x2 - AF_INET6 = 0x1c - AF_INET6_SDP = 0x2a - AF_INET_SDP = 0x28 - AF_IPX = 0x17 - AF_ISDN = 0x1a - AF_ISO = 0x7 - AF_LAT = 0xe - AF_LINK = 0x12 - AF_LOCAL = 0x1 - AF_MAX = 0x2a - AF_NATM = 0x1d - AF_NETBIOS = 0x6 - AF_NETGRAPH = 0x20 - AF_OSI = 0x7 - AF_PUP = 0x4 - AF_ROUTE = 0x11 - AF_SCLUSTER = 0x22 - AF_SIP = 0x18 - AF_SLOW = 0x21 - AF_SNA = 0xb - AF_UNIX = 0x1 - AF_UNSPEC = 0x0 - AF_VENDOR00 = 0x27 - AF_VENDOR01 = 0x29 - AF_VENDOR02 = 0x2b - AF_VENDOR03 = 0x2d - AF_VENDOR04 = 0x2f - AF_VENDOR05 = 0x31 - AF_VENDOR06 = 0x33 - AF_VENDOR07 = 0x35 - AF_VENDOR08 = 0x37 - AF_VENDOR09 = 0x39 - AF_VENDOR10 = 0x3b - AF_VENDOR11 = 0x3d - AF_VENDOR12 = 0x3f - AF_VENDOR13 = 0x41 - AF_VENDOR14 = 0x43 - AF_VENDOR15 = 0x45 - AF_VENDOR16 = 0x47 - AF_VENDOR17 = 0x49 - AF_VENDOR18 = 0x4b - AF_VENDOR19 = 0x4d - AF_VENDOR20 = 0x4f - AF_VENDOR21 = 0x51 - AF_VENDOR22 = 0x53 - AF_VENDOR23 = 0x55 - AF_VENDOR24 = 0x57 - AF_VENDOR25 = 0x59 - AF_VENDOR26 = 0x5b - AF_VENDOR27 = 0x5d - AF_VENDOR28 = 0x5f - AF_VENDOR29 = 0x61 - AF_VENDOR30 = 0x63 - AF_VENDOR31 = 0x65 - AF_VENDOR32 = 0x67 - AF_VENDOR33 = 0x69 - AF_VENDOR34 = 0x6b - AF_VENDOR35 = 0x6d - AF_VENDOR36 = 0x6f - AF_VENDOR37 = 0x71 - AF_VENDOR38 = 0x73 - AF_VENDOR39 = 0x75 - AF_VENDOR40 = 0x77 - AF_VENDOR41 = 0x79 - AF_VENDOR42 = 0x7b - AF_VENDOR43 = 0x7d - AF_VENDOR44 = 0x7f - AF_VENDOR45 = 0x81 - AF_VENDOR46 = 0x83 - AF_VENDOR47 = 0x85 - B0 = 0x0 - B110 = 0x6e - B115200 = 0x1c200 - B1200 = 0x4b0 - B134 = 0x86 - B14400 = 0x3840 - B150 = 0x96 - B1800 = 0x708 - B19200 = 0x4b00 - B200 = 0xc8 - B230400 = 0x38400 - B2400 = 0x960 - B28800 = 0x7080 - B300 = 0x12c - B38400 = 0x9600 - B460800 = 0x70800 - B4800 = 0x12c0 - B50 = 0x32 - B57600 = 0xe100 - B600 = 0x258 - B7200 = 0x1c20 - B75 = 0x4b - B76800 = 0x12c00 - B921600 = 0xe1000 - B9600 = 0x2580 - BIOCFEEDBACK = 0x8004427c - BIOCFLUSH = 0x20004268 - BIOCGBLEN = 0x40044266 - BIOCGDIRECTION = 0x40044276 - BIOCGDLT = 0x4004426a - BIOCGDLTLIST = 0xc0084279 - BIOCGETBUFMODE = 0x4004427d - BIOCGETIF = 0x4020426b - BIOCGETZMAX = 0x4004427f - BIOCGHDRCMPLT = 0x40044274 - BIOCGRSIG = 0x40044272 - BIOCGRTIMEOUT = 0x4008426e - BIOCGSEESENT = 0x40044276 - BIOCGSTATS = 0x4008426f - BIOCGTSTAMP = 0x40044283 - BIOCIMMEDIATE = 0x80044270 - BIOCLOCK = 0x2000427a - BIOCPROMISC = 0x20004269 - BIOCROTZBUF = 0x400c4280 - BIOCSBLEN = 0xc0044266 - BIOCSDIRECTION = 0x80044277 - BIOCSDLT = 0x80044278 - BIOCSETBUFMODE = 0x8004427e - BIOCSETF = 0x80084267 - BIOCSETFNR = 0x80084282 - BIOCSETIF = 0x8020426c - BIOCSETWF = 0x8008427b - BIOCSETZBUF = 0x800c4281 - BIOCSHDRCMPLT = 0x80044275 - BIOCSRSIG = 0x80044273 - BIOCSRTIMEOUT = 0x8008426d - BIOCSSEESENT = 0x80044277 - BIOCSTSTAMP = 0x80044284 - BIOCVERSION = 0x40044271 - BPF_A = 0x10 - BPF_ABS = 0x20 - BPF_ADD = 0x0 - BPF_ALIGNMENT = 0x4 - BPF_ALU = 0x4 - BPF_AND = 0x50 - BPF_B = 0x10 - BPF_BUFMODE_BUFFER = 0x1 - BPF_BUFMODE_ZBUF = 0x2 - BPF_DIV = 0x30 - BPF_H = 0x8 - BPF_IMM = 0x0 - BPF_IND = 0x40 - BPF_JA = 0x0 - BPF_JEQ = 0x10 - BPF_JGE = 0x30 - BPF_JGT = 0x20 - BPF_JMP = 0x5 - BPF_JSET = 0x40 - BPF_K = 0x0 - BPF_LD = 0x0 - BPF_LDX = 0x1 - BPF_LEN = 0x80 - BPF_LSH = 0x60 - BPF_MAJOR_VERSION = 0x1 - BPF_MAXBUFSIZE = 0x80000 - BPF_MAXINSNS = 0x200 - BPF_MEM = 0x60 - BPF_MEMWORDS = 0x10 - BPF_MINBUFSIZE = 0x20 - BPF_MINOR_VERSION = 0x1 - BPF_MISC = 0x7 - BPF_MSH = 0xa0 - BPF_MUL = 0x20 - BPF_NEG = 0x80 - BPF_OR = 0x40 - BPF_RELEASE = 0x30bb6 - BPF_RET = 0x6 - BPF_RSH = 0x70 - BPF_ST = 0x2 - BPF_STX = 0x3 - BPF_SUB = 0x10 - BPF_TAX = 0x0 - BPF_TXA = 0x80 - BPF_T_BINTIME = 0x2 - BPF_T_BINTIME_FAST = 0x102 - BPF_T_BINTIME_MONOTONIC = 0x202 - BPF_T_BINTIME_MONOTONIC_FAST = 0x302 - BPF_T_FAST = 0x100 - BPF_T_FLAG_MASK = 0x300 - BPF_T_FORMAT_MASK = 0x3 - BPF_T_MICROTIME = 0x0 - BPF_T_MICROTIME_FAST = 0x100 - BPF_T_MICROTIME_MONOTONIC = 0x200 - BPF_T_MICROTIME_MONOTONIC_FAST = 0x300 - BPF_T_MONOTONIC = 0x200 - BPF_T_MONOTONIC_FAST = 0x300 - BPF_T_NANOTIME = 0x1 - BPF_T_NANOTIME_FAST = 0x101 - BPF_T_NANOTIME_MONOTONIC = 0x201 - BPF_T_NANOTIME_MONOTONIC_FAST = 0x301 - BPF_T_NONE = 0x3 - BPF_T_NORMAL = 0x0 - BPF_W = 0x0 - BPF_X = 0x8 - BRKINT = 0x2 - CFLUSH = 0xf - CLOCAL = 0x8000 - CREAD = 0x800 - CS5 = 0x0 - CS6 = 0x100 - CS7 = 0x200 - CS8 = 0x300 - CSIZE = 0x300 - CSTART = 0x11 - CSTATUS = 0x14 - CSTOP = 0x13 - CSTOPB = 0x400 - CSUSP = 0x1a - CTL_MAXNAME = 0x18 - CTL_NET = 0x4 - DLT_A429 = 0xb8 - DLT_A653_ICM = 0xb9 - DLT_AIRONET_HEADER = 0x78 - DLT_AOS = 0xde - DLT_APPLE_IP_OVER_IEEE1394 = 0x8a - DLT_ARCNET = 0x7 - DLT_ARCNET_LINUX = 0x81 - DLT_ATM_CLIP = 0x13 - DLT_ATM_RFC1483 = 0xb - DLT_AURORA = 0x7e - DLT_AX25 = 0x3 - DLT_AX25_KISS = 0xca - DLT_BACNET_MS_TP = 0xa5 - DLT_BLUETOOTH_HCI_H4 = 0xbb - DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 - DLT_CAN20B = 0xbe - DLT_CAN_SOCKETCAN = 0xe3 - DLT_CHAOS = 0x5 - DLT_CHDLC = 0x68 - DLT_CISCO_IOS = 0x76 - DLT_C_HDLC = 0x68 - DLT_C_HDLC_WITH_DIR = 0xcd - DLT_DBUS = 0xe7 - DLT_DECT = 0xdd - DLT_DOCSIS = 0x8f - DLT_DVB_CI = 0xeb - DLT_ECONET = 0x73 - DLT_EN10MB = 0x1 - DLT_EN3MB = 0x2 - DLT_ENC = 0x6d - DLT_ERF = 0xc5 - DLT_ERF_ETH = 0xaf - DLT_ERF_POS = 0xb0 - DLT_FC_2 = 0xe0 - DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 - DLT_FDDI = 0xa - DLT_FLEXRAY = 0xd2 - DLT_FRELAY = 0x6b - DLT_FRELAY_WITH_DIR = 0xce - DLT_GCOM_SERIAL = 0xad - DLT_GCOM_T1E1 = 0xac - DLT_GPF_F = 0xab - DLT_GPF_T = 0xaa - DLT_GPRS_LLC = 0xa9 - DLT_GSMTAP_ABIS = 0xda - DLT_GSMTAP_UM = 0xd9 - DLT_HHDLC = 0x79 - DLT_IBM_SN = 0x92 - DLT_IBM_SP = 0x91 - DLT_IEEE802 = 0x6 - DLT_IEEE802_11 = 0x69 - DLT_IEEE802_11_RADIO = 0x7f - DLT_IEEE802_11_RADIO_AVS = 0xa3 - DLT_IEEE802_15_4 = 0xc3 - DLT_IEEE802_15_4_LINUX = 0xbf - DLT_IEEE802_15_4_NOFCS = 0xe6 - DLT_IEEE802_15_4_NONASK_PHY = 0xd7 - DLT_IEEE802_16_MAC_CPS = 0xbc - DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 - DLT_IPFILTER = 0x74 - DLT_IPMB = 0xc7 - DLT_IPMB_LINUX = 0xd1 - DLT_IPNET = 0xe2 - DLT_IPOIB = 0xf2 - DLT_IPV4 = 0xe4 - DLT_IPV6 = 0xe5 - DLT_IP_OVER_FC = 0x7a - DLT_JUNIPER_ATM1 = 0x89 - DLT_JUNIPER_ATM2 = 0x87 - DLT_JUNIPER_ATM_CEMIC = 0xee - DLT_JUNIPER_CHDLC = 0xb5 - DLT_JUNIPER_ES = 0x84 - DLT_JUNIPER_ETHER = 0xb2 - DLT_JUNIPER_FIBRECHANNEL = 0xea - DLT_JUNIPER_FRELAY = 0xb4 - DLT_JUNIPER_GGSN = 0x85 - DLT_JUNIPER_ISM = 0xc2 - DLT_JUNIPER_MFR = 0x86 - DLT_JUNIPER_MLFR = 0x83 - DLT_JUNIPER_MLPPP = 0x82 - DLT_JUNIPER_MONITOR = 0xa4 - DLT_JUNIPER_PIC_PEER = 0xae - DLT_JUNIPER_PPP = 0xb3 - DLT_JUNIPER_PPPOE = 0xa7 - DLT_JUNIPER_PPPOE_ATM = 0xa8 - DLT_JUNIPER_SERVICES = 0x88 - DLT_JUNIPER_SRX_E2E = 0xe9 - DLT_JUNIPER_ST = 0xc8 - DLT_JUNIPER_VP = 0xb7 - DLT_JUNIPER_VS = 0xe8 - DLT_LAPB_WITH_DIR = 0xcf - DLT_LAPD = 0xcb - DLT_LIN = 0xd4 - DLT_LINUX_EVDEV = 0xd8 - DLT_LINUX_IRDA = 0x90 - DLT_LINUX_LAPD = 0xb1 - DLT_LINUX_PPP_WITHDIRECTION = 0xa6 - DLT_LINUX_SLL = 0x71 - DLT_LOOP = 0x6c - DLT_LTALK = 0x72 - DLT_MATCHING_MAX = 0xf6 - DLT_MATCHING_MIN = 0x68 - DLT_MFR = 0xb6 - DLT_MOST = 0xd3 - DLT_MPEG_2_TS = 0xf3 - DLT_MPLS = 0xdb - DLT_MTP2 = 0x8c - DLT_MTP2_WITH_PHDR = 0x8b - DLT_MTP3 = 0x8d - DLT_MUX27010 = 0xec - DLT_NETANALYZER = 0xf0 - DLT_NETANALYZER_TRANSPARENT = 0xf1 - DLT_NFC_LLCP = 0xf5 - DLT_NFLOG = 0xef - DLT_NG40 = 0xf4 - DLT_NULL = 0x0 - DLT_PCI_EXP = 0x7d - DLT_PFLOG = 0x75 - DLT_PFSYNC = 0x79 - DLT_PPI = 0xc0 - DLT_PPP = 0x9 - DLT_PPP_BSDOS = 0x10 - DLT_PPP_ETHER = 0x33 - DLT_PPP_PPPD = 0xa6 - DLT_PPP_SERIAL = 0x32 - DLT_PPP_WITH_DIR = 0xcc - DLT_PPP_WITH_DIRECTION = 0xa6 - DLT_PRISM_HEADER = 0x77 - DLT_PRONET = 0x4 - DLT_RAIF1 = 0xc6 - DLT_RAW = 0xc - DLT_RIO = 0x7c - DLT_SCCP = 0x8e - DLT_SITA = 0xc4 - DLT_SLIP = 0x8 - DLT_SLIP_BSDOS = 0xf - DLT_STANAG_5066_D_PDU = 0xed - DLT_SUNATM = 0x7b - DLT_SYMANTEC_FIREWALL = 0x63 - DLT_TZSP = 0x80 - DLT_USB = 0xba - DLT_USB_LINUX = 0xbd - DLT_USB_LINUX_MMAPPED = 0xdc - DLT_USER0 = 0x93 - DLT_USER1 = 0x94 - DLT_USER10 = 0x9d - DLT_USER11 = 0x9e - DLT_USER12 = 0x9f - DLT_USER13 = 0xa0 - DLT_USER14 = 0xa1 - DLT_USER15 = 0xa2 - DLT_USER2 = 0x95 - DLT_USER3 = 0x96 - DLT_USER4 = 0x97 - DLT_USER5 = 0x98 - DLT_USER6 = 0x99 - DLT_USER7 = 0x9a - DLT_USER8 = 0x9b - DLT_USER9 = 0x9c - DLT_WIHART = 0xdf - DLT_X2E_SERIAL = 0xd5 - DLT_X2E_XORAYA = 0xd6 - DT_BLK = 0x6 - DT_CHR = 0x2 - DT_DIR = 0x4 - DT_FIFO = 0x1 - DT_LNK = 0xa - DT_REG = 0x8 - DT_SOCK = 0xc - DT_UNKNOWN = 0x0 - DT_WHT = 0xe - ECHO = 0x8 - ECHOCTL = 0x40 - ECHOE = 0x2 - ECHOK = 0x4 - ECHOKE = 0x1 - ECHONL = 0x10 - ECHOPRT = 0x20 - EVFILT_AIO = -0x3 - EVFILT_FS = -0x9 - EVFILT_LIO = -0xa - EVFILT_PROC = -0x5 - EVFILT_READ = -0x1 - EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0xb - EVFILT_TIMER = -0x7 - EVFILT_USER = -0xb - EVFILT_VNODE = -0x4 - EVFILT_WRITE = -0x2 - EV_ADD = 0x1 - EV_CLEAR = 0x20 - EV_DELETE = 0x2 - EV_DISABLE = 0x8 - EV_DISPATCH = 0x80 - EV_DROP = 0x1000 - EV_ENABLE = 0x4 - EV_EOF = 0x8000 - EV_ERROR = 0x4000 - EV_FLAG1 = 0x2000 - EV_ONESHOT = 0x10 - EV_RECEIPT = 0x40 - EV_SYSFLAGS = 0xf000 - EXTA = 0x4b00 - EXTATTR_NAMESPACE_EMPTY = 0x0 - EXTATTR_NAMESPACE_SYSTEM = 0x2 - EXTATTR_NAMESPACE_USER = 0x1 - EXTB = 0x9600 - EXTPROC = 0x800 - FD_CLOEXEC = 0x1 - FD_SETSIZE = 0x400 - FLUSHO = 0x800000 - F_CANCEL = 0x5 - F_DUP2FD = 0xa - F_DUP2FD_CLOEXEC = 0x12 - F_DUPFD = 0x0 - F_DUPFD_CLOEXEC = 0x11 - F_GETFD = 0x1 - F_GETFL = 0x3 - F_GETLK = 0xb - F_GETOWN = 0x5 - F_OGETLK = 0x7 - F_OK = 0x0 - F_OSETLK = 0x8 - F_OSETLKW = 0x9 - F_RDAHEAD = 0x10 - F_RDLCK = 0x1 - F_READAHEAD = 0xf - F_SETFD = 0x2 - F_SETFL = 0x4 - F_SETLK = 0xc - F_SETLKW = 0xd - F_SETLK_REMOTE = 0xe - F_SETOWN = 0x6 - F_UNLCK = 0x2 - F_UNLCKSYS = 0x4 - F_WRLCK = 0x3 - HUPCL = 0x4000 - ICANON = 0x100 - ICMP6_FILTER = 0x12 - ICRNL = 0x100 - IEXTEN = 0x400 - IFAN_ARRIVAL = 0x0 - IFAN_DEPARTURE = 0x1 - IFF_ALLMULTI = 0x200 - IFF_ALTPHYS = 0x4000 - IFF_BROADCAST = 0x2 - IFF_CANTCHANGE = 0x218f72 - IFF_CANTCONFIG = 0x10000 - IFF_DEBUG = 0x4 - IFF_DRV_OACTIVE = 0x400 - IFF_DRV_RUNNING = 0x40 - IFF_DYING = 0x200000 - IFF_LINK0 = 0x1000 - IFF_LINK1 = 0x2000 - IFF_LINK2 = 0x4000 - IFF_LOOPBACK = 0x8 - IFF_MONITOR = 0x40000 - IFF_MULTICAST = 0x8000 - IFF_NOARP = 0x80 - IFF_OACTIVE = 0x400 - IFF_POINTOPOINT = 0x10 - IFF_PPROMISC = 0x20000 - IFF_PROMISC = 0x100 - IFF_RENAMING = 0x400000 - IFF_RUNNING = 0x40 - IFF_SIMPLEX = 0x800 - IFF_SMART = 0x20 - IFF_STATICARP = 0x80000 - IFF_UP = 0x1 - IFNAMSIZ = 0x10 - IFT_1822 = 0x2 - IFT_A12MPPSWITCH = 0x82 - IFT_AAL2 = 0xbb - IFT_AAL5 = 0x31 - IFT_ADSL = 0x5e - IFT_AFLANE8023 = 0x3b - IFT_AFLANE8025 = 0x3c - IFT_ARAP = 0x58 - IFT_ARCNET = 0x23 - IFT_ARCNETPLUS = 0x24 - IFT_ASYNC = 0x54 - IFT_ATM = 0x25 - IFT_ATMDXI = 0x69 - IFT_ATMFUNI = 0x6a - IFT_ATMIMA = 0x6b - IFT_ATMLOGICAL = 0x50 - IFT_ATMRADIO = 0xbd - IFT_ATMSUBINTERFACE = 0x86 - IFT_ATMVCIENDPT = 0xc2 - IFT_ATMVIRTUAL = 0x95 - IFT_BGPPOLICYACCOUNTING = 0xa2 - IFT_BRIDGE = 0xd1 - IFT_BSC = 0x53 - IFT_CARP = 0xf8 - IFT_CCTEMUL = 0x3d - IFT_CEPT = 0x13 - IFT_CES = 0x85 - IFT_CHANNEL = 0x46 - IFT_CNR = 0x55 - IFT_COFFEE = 0x84 - IFT_COMPOSITELINK = 0x9b - IFT_DCN = 0x8d - IFT_DIGITALPOWERLINE = 0x8a - IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba - IFT_DLSW = 0x4a - IFT_DOCSCABLEDOWNSTREAM = 0x80 - IFT_DOCSCABLEMACLAYER = 0x7f - IFT_DOCSCABLEUPSTREAM = 0x81 - IFT_DS0 = 0x51 - IFT_DS0BUNDLE = 0x52 - IFT_DS1FDL = 0xaa - IFT_DS3 = 0x1e - IFT_DTM = 0x8c - IFT_DVBASILN = 0xac - IFT_DVBASIOUT = 0xad - IFT_DVBRCCDOWNSTREAM = 0x93 - IFT_DVBRCCMACLAYER = 0x92 - IFT_DVBRCCUPSTREAM = 0x94 - IFT_ENC = 0xf4 - IFT_EON = 0x19 - IFT_EPLRS = 0x57 - IFT_ESCON = 0x49 - IFT_ETHER = 0x6 - IFT_FAITH = 0xf2 - IFT_FAST = 0x7d - IFT_FASTETHER = 0x3e - IFT_FASTETHERFX = 0x45 - IFT_FDDI = 0xf - IFT_FIBRECHANNEL = 0x38 - IFT_FRAMERELAYINTERCONNECT = 0x3a - IFT_FRAMERELAYMPI = 0x5c - IFT_FRDLCIENDPT = 0xc1 - IFT_FRELAY = 0x20 - IFT_FRELAYDCE = 0x2c - IFT_FRF16MFRBUNDLE = 0xa3 - IFT_FRFORWARD = 0x9e - IFT_G703AT2MB = 0x43 - IFT_G703AT64K = 0x42 - IFT_GIF = 0xf0 - IFT_GIGABITETHERNET = 0x75 - IFT_GR303IDT = 0xb2 - IFT_GR303RDT = 0xb1 - IFT_H323GATEKEEPER = 0xa4 - IFT_H323PROXY = 0xa5 - IFT_HDH1822 = 0x3 - IFT_HDLC = 0x76 - IFT_HDSL2 = 0xa8 - IFT_HIPERLAN2 = 0xb7 - IFT_HIPPI = 0x2f - IFT_HIPPIINTERFACE = 0x39 - IFT_HOSTPAD = 0x5a - IFT_HSSI = 0x2e - IFT_HY = 0xe - IFT_IBM370PARCHAN = 0x48 - IFT_IDSL = 0x9a - IFT_IEEE1394 = 0x90 - IFT_IEEE80211 = 0x47 - IFT_IEEE80212 = 0x37 - IFT_IEEE8023ADLAG = 0xa1 - IFT_IFGSN = 0x91 - IFT_IMT = 0xbe - IFT_INFINIBAND = 0xc7 - IFT_INTERLEAVE = 0x7c - IFT_IP = 0x7e - IFT_IPFORWARD = 0x8e - IFT_IPOVERATM = 0x72 - IFT_IPOVERCDLC = 0x6d - IFT_IPOVERCLAW = 0x6e - IFT_IPSWITCH = 0x4e - IFT_IPXIP = 0xf9 - IFT_ISDN = 0x3f - IFT_ISDNBASIC = 0x14 - IFT_ISDNPRIMARY = 0x15 - IFT_ISDNS = 0x4b - IFT_ISDNU = 0x4c - IFT_ISO88022LLC = 0x29 - IFT_ISO88023 = 0x7 - IFT_ISO88024 = 0x8 - IFT_ISO88025 = 0x9 - IFT_ISO88025CRFPINT = 0x62 - IFT_ISO88025DTR = 0x56 - IFT_ISO88025FIBER = 0x73 - IFT_ISO88026 = 0xa - IFT_ISUP = 0xb3 - IFT_L2VLAN = 0x87 - IFT_L3IPVLAN = 0x88 - IFT_L3IPXVLAN = 0x89 - IFT_LAPB = 0x10 - IFT_LAPD = 0x4d - IFT_LAPF = 0x77 - IFT_LOCALTALK = 0x2a - IFT_LOOP = 0x18 - IFT_MEDIAMAILOVERIP = 0x8b - IFT_MFSIGLINK = 0xa7 - IFT_MIOX25 = 0x26 - IFT_MODEM = 0x30 - IFT_MPC = 0x71 - IFT_MPLS = 0xa6 - IFT_MPLSTUNNEL = 0x96 - IFT_MSDSL = 0x8f - IFT_MVL = 0xbf - IFT_MYRINET = 0x63 - IFT_NFAS = 0xaf - IFT_NSIP = 0x1b - IFT_OPTICALCHANNEL = 0xc3 - IFT_OPTICALTRANSPORT = 0xc4 - IFT_OTHER = 0x1 - IFT_P10 = 0xc - IFT_P80 = 0xd - IFT_PARA = 0x22 - IFT_PFLOG = 0xf6 - IFT_PFSYNC = 0xf7 - IFT_PLC = 0xae - IFT_POS = 0xab - IFT_PPP = 0x17 - IFT_PPPMULTILINKBUNDLE = 0x6c - IFT_PROPBWAP2MP = 0xb8 - IFT_PROPCNLS = 0x59 - IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 - IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 - IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 - IFT_PROPMUX = 0x36 - IFT_PROPVIRTUAL = 0x35 - IFT_PROPWIRELESSP2P = 0x9d - IFT_PTPSERIAL = 0x16 - IFT_PVC = 0xf1 - IFT_QLLC = 0x44 - IFT_RADIOMAC = 0xbc - IFT_RADSL = 0x5f - IFT_REACHDSL = 0xc0 - IFT_RFC1483 = 0x9f - IFT_RS232 = 0x21 - IFT_RSRB = 0x4f - IFT_SDLC = 0x11 - IFT_SDSL = 0x60 - IFT_SHDSL = 0xa9 - IFT_SIP = 0x1f - IFT_SLIP = 0x1c - IFT_SMDSDXI = 0x2b - IFT_SMDSICIP = 0x34 - IFT_SONET = 0x27 - IFT_SONETOVERHEADCHANNEL = 0xb9 - IFT_SONETPATH = 0x32 - IFT_SONETVT = 0x33 - IFT_SRP = 0x97 - IFT_SS7SIGLINK = 0x9c - IFT_STACKTOSTACK = 0x6f - IFT_STARLAN = 0xb - IFT_STF = 0xd7 - IFT_T1 = 0x12 - IFT_TDLC = 0x74 - IFT_TERMPAD = 0x5b - IFT_TR008 = 0xb0 - IFT_TRANSPHDLC = 0x7b - IFT_TUNNEL = 0x83 - IFT_ULTRA = 0x1d - IFT_USB = 0xa0 - IFT_V11 = 0x40 - IFT_V35 = 0x2d - IFT_V36 = 0x41 - IFT_V37 = 0x78 - IFT_VDSL = 0x61 - IFT_VIRTUALIPADDRESS = 0x70 - IFT_VOICEEM = 0x64 - IFT_VOICEENCAP = 0x67 - IFT_VOICEFXO = 0x65 - IFT_VOICEFXS = 0x66 - IFT_VOICEOVERATM = 0x98 - IFT_VOICEOVERFRAMERELAY = 0x99 - IFT_VOICEOVERIP = 0x68 - IFT_X213 = 0x5d - IFT_X25 = 0x5 - IFT_X25DDN = 0x4 - IFT_X25HUNTGROUP = 0x7a - IFT_X25MLP = 0x79 - IFT_X25PLE = 0x28 - IFT_XETHER = 0x1a - IGNBRK = 0x1 - IGNCR = 0x80 - IGNPAR = 0x4 - IMAXBEL = 0x2000 - INLCR = 0x40 - INPCK = 0x10 - IN_CLASSA_HOST = 0xffffff - IN_CLASSA_MAX = 0x80 - IN_CLASSA_NET = 0xff000000 - IN_CLASSA_NSHIFT = 0x18 - IN_CLASSB_HOST = 0xffff - IN_CLASSB_MAX = 0x10000 - IN_CLASSB_NET = 0xffff0000 - IN_CLASSB_NSHIFT = 0x10 - IN_CLASSC_HOST = 0xff - IN_CLASSC_NET = 0xffffff00 - IN_CLASSC_NSHIFT = 0x8 - IN_CLASSD_HOST = 0xfffffff - IN_CLASSD_NET = 0xf0000000 - IN_CLASSD_NSHIFT = 0x1c - IN_LOOPBACKNET = 0x7f - IN_RFC3021_MASK = 0xfffffffe - IPPROTO_3PC = 0x22 - IPPROTO_ADFS = 0x44 - IPPROTO_AH = 0x33 - IPPROTO_AHIP = 0x3d - IPPROTO_APES = 0x63 - IPPROTO_ARGUS = 0xd - IPPROTO_AX25 = 0x5d - IPPROTO_BHA = 0x31 - IPPROTO_BLT = 0x1e - IPPROTO_BRSATMON = 0x4c - IPPROTO_CARP = 0x70 - IPPROTO_CFTP = 0x3e - IPPROTO_CHAOS = 0x10 - IPPROTO_CMTP = 0x26 - IPPROTO_CPHB = 0x49 - IPPROTO_CPNX = 0x48 - IPPROTO_DDP = 0x25 - IPPROTO_DGP = 0x56 - IPPROTO_DIVERT = 0x102 - IPPROTO_DONE = 0x101 - IPPROTO_DSTOPTS = 0x3c - IPPROTO_EGP = 0x8 - IPPROTO_EMCON = 0xe - IPPROTO_ENCAP = 0x62 - IPPROTO_EON = 0x50 - IPPROTO_ESP = 0x32 - IPPROTO_ETHERIP = 0x61 - IPPROTO_FRAGMENT = 0x2c - IPPROTO_GGP = 0x3 - IPPROTO_GMTP = 0x64 - IPPROTO_GRE = 0x2f - IPPROTO_HELLO = 0x3f - IPPROTO_HIP = 0x8b - IPPROTO_HMP = 0x14 - IPPROTO_HOPOPTS = 0x0 - IPPROTO_ICMP = 0x1 - IPPROTO_ICMPV6 = 0x3a - IPPROTO_IDP = 0x16 - IPPROTO_IDPR = 0x23 - IPPROTO_IDRP = 0x2d - IPPROTO_IGMP = 0x2 - IPPROTO_IGP = 0x55 - IPPROTO_IGRP = 0x58 - IPPROTO_IL = 0x28 - IPPROTO_INLSP = 0x34 - IPPROTO_INP = 0x20 - IPPROTO_IP = 0x0 - IPPROTO_IPCOMP = 0x6c - IPPROTO_IPCV = 0x47 - IPPROTO_IPEIP = 0x5e - IPPROTO_IPIP = 0x4 - IPPROTO_IPPC = 0x43 - IPPROTO_IPV4 = 0x4 - IPPROTO_IPV6 = 0x29 - IPPROTO_IRTP = 0x1c - IPPROTO_KRYPTOLAN = 0x41 - IPPROTO_LARP = 0x5b - IPPROTO_LEAF1 = 0x19 - IPPROTO_LEAF2 = 0x1a - IPPROTO_MAX = 0x100 - IPPROTO_MAXID = 0x34 - IPPROTO_MEAS = 0x13 - IPPROTO_MH = 0x87 - IPPROTO_MHRP = 0x30 - IPPROTO_MICP = 0x5f - IPPROTO_MOBILE = 0x37 - IPPROTO_MPLS = 0x89 - IPPROTO_MTP = 0x5c - IPPROTO_MUX = 0x12 - IPPROTO_ND = 0x4d - IPPROTO_NHRP = 0x36 - IPPROTO_NONE = 0x3b - IPPROTO_NSP = 0x1f - IPPROTO_NVPII = 0xb - IPPROTO_OLD_DIVERT = 0xfe - IPPROTO_OSPFIGP = 0x59 - IPPROTO_PFSYNC = 0xf0 - IPPROTO_PGM = 0x71 - IPPROTO_PIGP = 0x9 - IPPROTO_PIM = 0x67 - IPPROTO_PRM = 0x15 - IPPROTO_PUP = 0xc - IPPROTO_PVP = 0x4b - IPPROTO_RAW = 0xff - IPPROTO_RCCMON = 0xa - IPPROTO_RDP = 0x1b - IPPROTO_RESERVED_253 = 0xfd - IPPROTO_RESERVED_254 = 0xfe - IPPROTO_ROUTING = 0x2b - IPPROTO_RSVP = 0x2e - IPPROTO_RVD = 0x42 - IPPROTO_SATEXPAK = 0x40 - IPPROTO_SATMON = 0x45 - IPPROTO_SCCSP = 0x60 - IPPROTO_SCTP = 0x84 - IPPROTO_SDRP = 0x2a - IPPROTO_SEND = 0x103 - IPPROTO_SEP = 0x21 - IPPROTO_SHIM6 = 0x8c - IPPROTO_SKIP = 0x39 - IPPROTO_SPACER = 0x7fff - IPPROTO_SRPC = 0x5a - IPPROTO_ST = 0x7 - IPPROTO_SVMTP = 0x52 - IPPROTO_SWIPE = 0x35 - IPPROTO_TCF = 0x57 - IPPROTO_TCP = 0x6 - IPPROTO_TLSP = 0x38 - IPPROTO_TP = 0x1d - IPPROTO_TPXX = 0x27 - IPPROTO_TRUNK1 = 0x17 - IPPROTO_TRUNK2 = 0x18 - IPPROTO_TTP = 0x54 - IPPROTO_UDP = 0x11 - IPPROTO_UDPLITE = 0x88 - IPPROTO_VINES = 0x53 - IPPROTO_VISA = 0x46 - IPPROTO_VMTP = 0x51 - IPPROTO_WBEXPAK = 0x4f - IPPROTO_WBMON = 0x4e - IPPROTO_WSN = 0x4a - IPPROTO_XNET = 0xf - IPPROTO_XTP = 0x24 - IPV6_AUTOFLOWLABEL = 0x3b - IPV6_BINDANY = 0x40 - IPV6_BINDV6ONLY = 0x1b - IPV6_CHECKSUM = 0x1a - IPV6_DEFAULT_MULTICAST_HOPS = 0x1 - IPV6_DEFAULT_MULTICAST_LOOP = 0x1 - IPV6_DEFHLIM = 0x40 - IPV6_DONTFRAG = 0x3e - IPV6_DSTOPTS = 0x32 - IPV6_FAITH = 0x1d - IPV6_FLOWINFO_MASK = 0xffffff0f - IPV6_FLOWLABEL_MASK = 0xffff0f00 - IPV6_FRAGTTL = 0x78 - IPV6_FW_ADD = 0x1e - IPV6_FW_DEL = 0x1f - IPV6_FW_FLUSH = 0x20 - IPV6_FW_GET = 0x22 - IPV6_FW_ZERO = 0x21 - IPV6_HLIMDEC = 0x1 - IPV6_HOPLIMIT = 0x2f - IPV6_HOPOPTS = 0x31 - IPV6_IPSEC_POLICY = 0x1c - IPV6_JOIN_GROUP = 0xc - IPV6_LEAVE_GROUP = 0xd - IPV6_MAXHLIM = 0xff - IPV6_MAXOPTHDR = 0x800 - IPV6_MAXPACKET = 0xffff - IPV6_MAX_GROUP_SRC_FILTER = 0x200 - IPV6_MAX_MEMBERSHIPS = 0xfff - IPV6_MAX_SOCK_SRC_FILTER = 0x80 - IPV6_MIN_MEMBERSHIPS = 0x1f - IPV6_MMTU = 0x500 - IPV6_MSFILTER = 0x4a - IPV6_MULTICAST_HOPS = 0xa - IPV6_MULTICAST_IF = 0x9 - IPV6_MULTICAST_LOOP = 0xb - IPV6_NEXTHOP = 0x30 - IPV6_PATHMTU = 0x2c - IPV6_PKTINFO = 0x2e - IPV6_PORTRANGE = 0xe - IPV6_PORTRANGE_DEFAULT = 0x0 - IPV6_PORTRANGE_HIGH = 0x1 - IPV6_PORTRANGE_LOW = 0x2 - IPV6_PREFER_TEMPADDR = 0x3f - IPV6_RECVDSTOPTS = 0x28 - IPV6_RECVHOPLIMIT = 0x25 - IPV6_RECVHOPOPTS = 0x27 - IPV6_RECVPATHMTU = 0x2b - IPV6_RECVPKTINFO = 0x24 - IPV6_RECVRTHDR = 0x26 - IPV6_RECVTCLASS = 0x39 - IPV6_RTHDR = 0x33 - IPV6_RTHDRDSTOPTS = 0x23 - IPV6_RTHDR_LOOSE = 0x0 - IPV6_RTHDR_STRICT = 0x1 - IPV6_RTHDR_TYPE_0 = 0x0 - IPV6_SOCKOPT_RESERVED1 = 0x3 - IPV6_TCLASS = 0x3d - IPV6_UNICAST_HOPS = 0x4 - IPV6_USE_MIN_MTU = 0x2a - IPV6_V6ONLY = 0x1b - IPV6_VERSION = 0x60 - IPV6_VERSION_MASK = 0xf0 - IP_ADD_MEMBERSHIP = 0xc - IP_ADD_SOURCE_MEMBERSHIP = 0x46 - IP_BINDANY = 0x18 - IP_BLOCK_SOURCE = 0x48 - IP_DEFAULT_MULTICAST_LOOP = 0x1 - IP_DEFAULT_MULTICAST_TTL = 0x1 - IP_DF = 0x4000 - IP_DONTFRAG = 0x43 - IP_DROP_MEMBERSHIP = 0xd - IP_DROP_SOURCE_MEMBERSHIP = 0x47 - IP_DUMMYNET3 = 0x31 - IP_DUMMYNET_CONFIGURE = 0x3c - IP_DUMMYNET_DEL = 0x3d - IP_DUMMYNET_FLUSH = 0x3e - IP_DUMMYNET_GET = 0x40 - IP_FAITH = 0x16 - IP_FW3 = 0x30 - IP_FW_ADD = 0x32 - IP_FW_DEL = 0x33 - IP_FW_FLUSH = 0x34 - IP_FW_GET = 0x36 - IP_FW_NAT_CFG = 0x38 - IP_FW_NAT_DEL = 0x39 - IP_FW_NAT_GET_CONFIG = 0x3a - IP_FW_NAT_GET_LOG = 0x3b - IP_FW_RESETLOG = 0x37 - IP_FW_TABLE_ADD = 0x28 - IP_FW_TABLE_DEL = 0x29 - IP_FW_TABLE_FLUSH = 0x2a - IP_FW_TABLE_GETSIZE = 0x2b - IP_FW_TABLE_LIST = 0x2c - IP_FW_ZERO = 0x35 - IP_HDRINCL = 0x2 - IP_IPSEC_POLICY = 0x15 - IP_MAXPACKET = 0xffff - IP_MAX_GROUP_SRC_FILTER = 0x200 - IP_MAX_MEMBERSHIPS = 0xfff - IP_MAX_SOCK_MUTE_FILTER = 0x80 - IP_MAX_SOCK_SRC_FILTER = 0x80 - IP_MAX_SOURCE_FILTER = 0x400 - IP_MF = 0x2000 - IP_MINTTL = 0x42 - IP_MIN_MEMBERSHIPS = 0x1f - IP_MSFILTER = 0x4a - IP_MSS = 0x240 - IP_MULTICAST_IF = 0x9 - IP_MULTICAST_LOOP = 0xb - IP_MULTICAST_TTL = 0xa - IP_MULTICAST_VIF = 0xe - IP_OFFMASK = 0x1fff - IP_ONESBCAST = 0x17 - IP_OPTIONS = 0x1 - IP_PORTRANGE = 0x13 - IP_PORTRANGE_DEFAULT = 0x0 - IP_PORTRANGE_HIGH = 0x1 - IP_PORTRANGE_LOW = 0x2 - IP_RECVDSTADDR = 0x7 - IP_RECVIF = 0x14 - IP_RECVOPTS = 0x5 - IP_RECVRETOPTS = 0x6 - IP_RECVTOS = 0x44 - IP_RECVTTL = 0x41 - IP_RETOPTS = 0x8 - IP_RF = 0x8000 - IP_RSVP_OFF = 0x10 - IP_RSVP_ON = 0xf - IP_RSVP_VIF_OFF = 0x12 - IP_RSVP_VIF_ON = 0x11 - IP_SENDSRCADDR = 0x7 - IP_TOS = 0x3 - IP_TTL = 0x4 - IP_UNBLOCK_SOURCE = 0x49 - ISIG = 0x80 - ISTRIP = 0x20 - IXANY = 0x800 - IXOFF = 0x400 - IXON = 0x200 - LOCK_EX = 0x2 - LOCK_NB = 0x4 - LOCK_SH = 0x1 - LOCK_UN = 0x8 - MADV_AUTOSYNC = 0x7 - MADV_CORE = 0x9 - MADV_DONTNEED = 0x4 - MADV_FREE = 0x5 - MADV_NOCORE = 0x8 - MADV_NORMAL = 0x0 - MADV_NOSYNC = 0x6 - MADV_PROTECT = 0xa - MADV_RANDOM = 0x1 - MADV_SEQUENTIAL = 0x2 - MADV_WILLNEED = 0x3 - MAP_ALIGNED_SUPER = 0x1000000 - MAP_ALIGNMENT_MASK = -0x1000000 - MAP_ALIGNMENT_SHIFT = 0x18 - MAP_ANON = 0x1000 - MAP_ANONYMOUS = 0x1000 - MAP_COPY = 0x2 - MAP_EXCL = 0x4000 - MAP_FILE = 0x0 - MAP_FIXED = 0x10 - MAP_HASSEMAPHORE = 0x200 - MAP_NOCORE = 0x20000 - MAP_NORESERVE = 0x40 - MAP_NOSYNC = 0x800 - MAP_PREFAULT_READ = 0x40000 - MAP_PRIVATE = 0x2 - MAP_RENAME = 0x20 - MAP_RESERVED0080 = 0x80 - MAP_RESERVED0100 = 0x100 - MAP_SHARED = 0x1 - MAP_STACK = 0x400 - MCL_CURRENT = 0x1 - MCL_FUTURE = 0x2 - MSG_CMSG_CLOEXEC = 0x40000 - MSG_COMPAT = 0x8000 - MSG_CTRUNC = 0x20 - MSG_DONTROUTE = 0x4 - MSG_DONTWAIT = 0x80 - MSG_EOF = 0x100 - MSG_EOR = 0x8 - MSG_NBIO = 0x4000 - MSG_NOSIGNAL = 0x20000 - MSG_NOTIFICATION = 0x2000 - MSG_OOB = 0x1 - MSG_PEEK = 0x2 - MSG_TRUNC = 0x10 - MSG_WAITALL = 0x40 - MS_ASYNC = 0x1 - MS_INVALIDATE = 0x2 - MS_SYNC = 0x0 - NAME_MAX = 0xff - NET_RT_DUMP = 0x1 - NET_RT_FLAGS = 0x2 - NET_RT_IFLIST = 0x3 - NET_RT_IFLISTL = 0x5 - NET_RT_IFMALIST = 0x4 - NET_RT_MAXID = 0x6 - NOFLSH = 0x80000000 - NOTE_ATTRIB = 0x8 - NOTE_CHILD = 0x4 - NOTE_DELETE = 0x1 - NOTE_EXEC = 0x20000000 - NOTE_EXIT = 0x80000000 - NOTE_EXTEND = 0x4 - NOTE_FFAND = 0x40000000 - NOTE_FFCOPY = 0xc0000000 - NOTE_FFCTRLMASK = 0xc0000000 - NOTE_FFLAGSMASK = 0xffffff - NOTE_FFNOP = 0x0 - NOTE_FFOR = 0x80000000 - NOTE_FORK = 0x40000000 - NOTE_LINK = 0x10 - NOTE_LOWAT = 0x1 - NOTE_PCTRLMASK = 0xf0000000 - NOTE_PDATAMASK = 0xfffff - NOTE_RENAME = 0x20 - NOTE_REVOKE = 0x40 - NOTE_TRACK = 0x1 - NOTE_TRACKERR = 0x2 - NOTE_TRIGGER = 0x1000000 - NOTE_WRITE = 0x2 - OCRNL = 0x10 - ONLCR = 0x2 - ONLRET = 0x40 - ONOCR = 0x20 - ONOEOT = 0x8 - OPOST = 0x1 - O_ACCMODE = 0x3 - O_APPEND = 0x8 - O_ASYNC = 0x40 - O_CLOEXEC = 0x100000 - O_CREAT = 0x200 - O_DIRECT = 0x10000 - O_DIRECTORY = 0x20000 - O_EXCL = 0x800 - O_EXEC = 0x40000 - O_EXLOCK = 0x20 - O_FSYNC = 0x80 - O_NDELAY = 0x4 - O_NOCTTY = 0x8000 - O_NOFOLLOW = 0x100 - O_NONBLOCK = 0x4 - O_RDONLY = 0x0 - O_RDWR = 0x2 - O_SHLOCK = 0x10 - O_SYNC = 0x80 - O_TRUNC = 0x400 - O_TTY_INIT = 0x80000 - O_WRONLY = 0x1 - PARENB = 0x1000 - PARMRK = 0x8 - PARODD = 0x2000 - PENDIN = 0x20000000 - PRIO_PGRP = 0x1 - PRIO_PROCESS = 0x0 - PRIO_USER = 0x2 - PROT_EXEC = 0x4 - PROT_NONE = 0x0 - PROT_READ = 0x1 - PROT_WRITE = 0x2 - RLIMIT_AS = 0xa - RLIMIT_CORE = 0x4 - RLIMIT_CPU = 0x0 - RLIMIT_DATA = 0x2 - RLIMIT_FSIZE = 0x1 - RLIMIT_NOFILE = 0x8 - RLIMIT_STACK = 0x3 - RLIM_INFINITY = 0x7fffffffffffffff - RTAX_AUTHOR = 0x6 - RTAX_BRD = 0x7 - RTAX_DST = 0x0 - RTAX_GATEWAY = 0x1 - RTAX_GENMASK = 0x3 - RTAX_IFA = 0x5 - RTAX_IFP = 0x4 - RTAX_MAX = 0x8 - RTAX_NETMASK = 0x2 - RTA_AUTHOR = 0x40 - RTA_BRD = 0x80 - RTA_DST = 0x1 - RTA_GATEWAY = 0x2 - RTA_GENMASK = 0x8 - RTA_IFA = 0x20 - RTA_IFP = 0x10 - RTA_NETMASK = 0x4 - RTF_BLACKHOLE = 0x1000 - RTF_BROADCAST = 0x400000 - RTF_DONE = 0x40 - RTF_DYNAMIC = 0x10 - RTF_FMASK = 0x1004d808 - RTF_GATEWAY = 0x2 - RTF_GWFLAG_COMPAT = 0x80000000 - RTF_HOST = 0x4 - RTF_LLDATA = 0x400 - RTF_LLINFO = 0x400 - RTF_LOCAL = 0x200000 - RTF_MODIFIED = 0x20 - RTF_MULTICAST = 0x800000 - RTF_PINNED = 0x100000 - RTF_PRCLONING = 0x10000 - RTF_PROTO1 = 0x8000 - RTF_PROTO2 = 0x4000 - RTF_PROTO3 = 0x40000 - RTF_REJECT = 0x8 - RTF_RNH_LOCKED = 0x40000000 - RTF_STATIC = 0x800 - RTF_STICKY = 0x10000000 - RTF_UP = 0x1 - RTF_XRESOLVE = 0x200 - RTM_ADD = 0x1 - RTM_CHANGE = 0x3 - RTM_DELADDR = 0xd - RTM_DELETE = 0x2 - RTM_DELMADDR = 0x10 - RTM_GET = 0x4 - RTM_IEEE80211 = 0x12 - RTM_IFANNOUNCE = 0x11 - RTM_IFINFO = 0xe - RTM_LOCK = 0x8 - RTM_LOSING = 0x5 - RTM_MISS = 0x7 - RTM_NEWADDR = 0xc - RTM_NEWMADDR = 0xf - RTM_OLDADD = 0x9 - RTM_OLDDEL = 0xa - RTM_REDIRECT = 0x6 - RTM_RESOLVE = 0xb - RTM_RTTUNIT = 0xf4240 - RTM_VERSION = 0x5 - RTV_EXPIRE = 0x4 - RTV_HOPCOUNT = 0x2 - RTV_MTU = 0x1 - RTV_RPIPE = 0x8 - RTV_RTT = 0x40 - RTV_RTTVAR = 0x80 - RTV_SPIPE = 0x10 - RTV_SSTHRESH = 0x20 - RTV_WEIGHT = 0x100 - RT_ALL_FIBS = -0x1 - RT_CACHING_CONTEXT = 0x1 - RT_DEFAULT_FIB = 0x0 - RT_NORTREF = 0x2 - RUSAGE_CHILDREN = -0x1 - RUSAGE_SELF = 0x0 - RUSAGE_THREAD = 0x1 - SCM_BINTIME = 0x4 - SCM_CREDS = 0x3 - SCM_RIGHTS = 0x1 - SCM_TIMESTAMP = 0x2 - SHUT_RD = 0x0 - SHUT_RDWR = 0x2 - SHUT_WR = 0x1 - SIOCADDMULTI = 0x80206931 - SIOCADDRT = 0x8030720a - SIOCAIFADDR = 0x8040691a - SIOCAIFGROUP = 0x80246987 - SIOCALIFADDR = 0x8118691b - SIOCATMARK = 0x40047307 - SIOCDELMULTI = 0x80206932 - SIOCDELRT = 0x8030720b - SIOCDIFADDR = 0x80206919 - SIOCDIFGROUP = 0x80246989 - SIOCDIFPHYADDR = 0x80206949 - SIOCDLIFADDR = 0x8118691d - SIOCGDRVSPEC = 0xc01c697b - SIOCGETSGCNT = 0xc0147210 - SIOCGETVIFCNT = 0xc014720f - SIOCGHIWAT = 0x40047301 - SIOCGIFADDR = 0xc0206921 - SIOCGIFBRDADDR = 0xc0206923 - SIOCGIFCAP = 0xc020691f - SIOCGIFCONF = 0xc0086924 - SIOCGIFDESCR = 0xc020692a - SIOCGIFDSTADDR = 0xc0206922 - SIOCGIFFIB = 0xc020695c - SIOCGIFFLAGS = 0xc0206911 - SIOCGIFGENERIC = 0xc020693a - SIOCGIFGMEMB = 0xc024698a - SIOCGIFGROUP = 0xc0246988 - SIOCGIFINDEX = 0xc0206920 - SIOCGIFMAC = 0xc0206926 - SIOCGIFMEDIA = 0xc0286938 - SIOCGIFMETRIC = 0xc0206917 - SIOCGIFMTU = 0xc0206933 - SIOCGIFNETMASK = 0xc0206925 - SIOCGIFPDSTADDR = 0xc0206948 - SIOCGIFPHYS = 0xc0206935 - SIOCGIFPSRCADDR = 0xc0206947 - SIOCGIFSTATUS = 0xc331693b - SIOCGLIFADDR = 0xc118691c - SIOCGLIFPHYADDR = 0xc118694b - SIOCGLOWAT = 0x40047303 - SIOCGPGRP = 0x40047309 - SIOCGPRIVATE_0 = 0xc0206950 - SIOCGPRIVATE_1 = 0xc0206951 - SIOCIFCREATE = 0xc020697a - SIOCIFCREATE2 = 0xc020697c - SIOCIFDESTROY = 0x80206979 - SIOCIFGCLONERS = 0xc00c6978 - SIOCSDRVSPEC = 0x801c697b - SIOCSHIWAT = 0x80047300 - SIOCSIFADDR = 0x8020690c - SIOCSIFBRDADDR = 0x80206913 - SIOCSIFCAP = 0x8020691e - SIOCSIFDESCR = 0x80206929 - SIOCSIFDSTADDR = 0x8020690e - SIOCSIFFIB = 0x8020695d - SIOCSIFFLAGS = 0x80206910 - SIOCSIFGENERIC = 0x80206939 - SIOCSIFLLADDR = 0x8020693c - SIOCSIFMAC = 0x80206927 - SIOCSIFMEDIA = 0xc0206937 - SIOCSIFMETRIC = 0x80206918 - SIOCSIFMTU = 0x80206934 - SIOCSIFNAME = 0x80206928 - SIOCSIFNETMASK = 0x80206916 - SIOCSIFPHYADDR = 0x80406946 - SIOCSIFPHYS = 0x80206936 - SIOCSIFRVNET = 0xc020695b - SIOCSIFVNET = 0xc020695a - SIOCSLIFPHYADDR = 0x8118694a - SIOCSLOWAT = 0x80047302 - SIOCSPGRP = 0x80047308 - SOCK_CLOEXEC = 0x10000000 - SOCK_DGRAM = 0x2 - SOCK_MAXADDRLEN = 0xff - SOCK_NONBLOCK = 0x20000000 - SOCK_RAW = 0x3 - SOCK_RDM = 0x4 - SOCK_SEQPACKET = 0x5 - SOCK_STREAM = 0x1 - SOL_SOCKET = 0xffff - SOMAXCONN = 0x80 - SO_ACCEPTCONN = 0x2 - SO_ACCEPTFILTER = 0x1000 - SO_BINTIME = 0x2000 - SO_BROADCAST = 0x20 - SO_DEBUG = 0x1 - SO_DONTROUTE = 0x10 - SO_ERROR = 0x1007 - SO_KEEPALIVE = 0x8 - SO_LABEL = 0x1009 - SO_LINGER = 0x80 - SO_LISTENINCQLEN = 0x1013 - SO_LISTENQLEN = 0x1012 - SO_LISTENQLIMIT = 0x1011 - SO_NOSIGPIPE = 0x800 - SO_NO_DDP = 0x8000 - SO_NO_OFFLOAD = 0x4000 - SO_OOBINLINE = 0x100 - SO_PEERLABEL = 0x1010 - SO_PROTOCOL = 0x1016 - SO_PROTOTYPE = 0x1016 - SO_RCVBUF = 0x1002 - SO_RCVLOWAT = 0x1004 - SO_RCVTIMEO = 0x1006 - SO_REUSEADDR = 0x4 - SO_REUSEPORT = 0x200 - SO_SETFIB = 0x1014 - SO_SNDBUF = 0x1001 - SO_SNDLOWAT = 0x1003 - SO_SNDTIMEO = 0x1005 - SO_TIMESTAMP = 0x400 - SO_TYPE = 0x1008 - SO_USELOOPBACK = 0x40 - SO_USER_COOKIE = 0x1015 - SO_VENDOR = 0x80000000 - TCIFLUSH = 0x1 - TCIOFLUSH = 0x3 - TCOFLUSH = 0x2 - TCP_CA_NAME_MAX = 0x10 - TCP_CONGESTION = 0x40 - TCP_INFO = 0x20 - TCP_KEEPCNT = 0x400 - TCP_KEEPIDLE = 0x100 - TCP_KEEPINIT = 0x80 - TCP_KEEPINTVL = 0x200 - TCP_MAXBURST = 0x4 - TCP_MAXHLEN = 0x3c - TCP_MAXOLEN = 0x28 - TCP_MAXSEG = 0x2 - TCP_MAXWIN = 0xffff - TCP_MAX_SACK = 0x4 - TCP_MAX_WINSHIFT = 0xe - TCP_MD5SIG = 0x10 - TCP_MINMSS = 0xd8 - TCP_MSS = 0x218 - TCP_NODELAY = 0x1 - TCP_NOOPT = 0x8 - TCP_NOPUSH = 0x4 - TCP_VENDOR = 0x80000000 - TCSAFLUSH = 0x2 - TIOCCBRK = 0x2000747a - TIOCCDTR = 0x20007478 - TIOCCONS = 0x80047462 - TIOCDRAIN = 0x2000745e - TIOCEXCL = 0x2000740d - TIOCEXT = 0x80047460 - TIOCFLUSH = 0x80047410 - TIOCGDRAINWAIT = 0x40047456 - TIOCGETA = 0x402c7413 - TIOCGETD = 0x4004741a - TIOCGPGRP = 0x40047477 - TIOCGPTN = 0x4004740f - TIOCGSID = 0x40047463 - TIOCGWINSZ = 0x40087468 - TIOCMBIC = 0x8004746b - TIOCMBIS = 0x8004746c - TIOCMGDTRWAIT = 0x4004745a - TIOCMGET = 0x4004746a - TIOCMSDTRWAIT = 0x8004745b - TIOCMSET = 0x8004746d - TIOCM_CAR = 0x40 - TIOCM_CD = 0x40 - TIOCM_CTS = 0x20 - TIOCM_DCD = 0x40 - TIOCM_DSR = 0x100 - TIOCM_DTR = 0x2 - TIOCM_LE = 0x1 - TIOCM_RI = 0x80 - TIOCM_RNG = 0x80 - TIOCM_RTS = 0x4 - TIOCM_SR = 0x10 - TIOCM_ST = 0x8 - TIOCNOTTY = 0x20007471 - TIOCNXCL = 0x2000740e - TIOCOUTQ = 0x40047473 - TIOCPKT = 0x80047470 - TIOCPKT_DATA = 0x0 - TIOCPKT_DOSTOP = 0x20 - TIOCPKT_FLUSHREAD = 0x1 - TIOCPKT_FLUSHWRITE = 0x2 - TIOCPKT_IOCTL = 0x40 - TIOCPKT_NOSTOP = 0x10 - TIOCPKT_START = 0x8 - TIOCPKT_STOP = 0x4 - TIOCPTMASTER = 0x2000741c - TIOCSBRK = 0x2000747b - TIOCSCTTY = 0x20007461 - TIOCSDRAINWAIT = 0x80047457 - TIOCSDTR = 0x20007479 - TIOCSETA = 0x802c7414 - TIOCSETAF = 0x802c7416 - TIOCSETAW = 0x802c7415 - TIOCSETD = 0x8004741b - TIOCSIG = 0x2004745f - TIOCSPGRP = 0x80047476 - TIOCSTART = 0x2000746e - TIOCSTAT = 0x20007465 - TIOCSTI = 0x80017472 - TIOCSTOP = 0x2000746f - TIOCSWINSZ = 0x80087467 - TIOCTIMESTAMP = 0x40087459 - TIOCUCNTL = 0x80047466 - TOSTOP = 0x400000 - VDISCARD = 0xf - VDSUSP = 0xb - VEOF = 0x0 - VEOL = 0x1 - VEOL2 = 0x2 - VERASE = 0x3 - VERASE2 = 0x7 - VINTR = 0x8 - VKILL = 0x5 - VLNEXT = 0xe - VMIN = 0x10 - VQUIT = 0x9 - VREPRINT = 0x6 - VSTART = 0xc - VSTATUS = 0x12 - VSTOP = 0xd - VSUSP = 0xa - VTIME = 0x11 - VWERASE = 0x4 - WCONTINUED = 0x4 - WCOREFLAG = 0x80 - WEXITED = 0x10 - WLINUXCLONE = 0x80000000 - WNOHANG = 0x1 - WNOWAIT = 0x8 - WSTOPPED = 0x2 - WTRAPPED = 0x20 - WUNTRACED = 0x2 + AF_APPLETALK = 0x10 + AF_ARP = 0x23 + AF_ATM = 0x1e + AF_BLUETOOTH = 0x24 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x25 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1c + AF_INET6_SDP = 0x2a + AF_INET_SDP = 0x28 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x2a + AF_NATM = 0x1d + AF_NETBIOS = 0x6 + AF_NETGRAPH = 0x20 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x11 + AF_SCLUSTER = 0x22 + AF_SIP = 0x18 + AF_SLOW = 0x21 + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VENDOR00 = 0x27 + AF_VENDOR01 = 0x29 + AF_VENDOR02 = 0x2b + AF_VENDOR03 = 0x2d + AF_VENDOR04 = 0x2f + AF_VENDOR05 = 0x31 + AF_VENDOR06 = 0x33 + AF_VENDOR07 = 0x35 + AF_VENDOR08 = 0x37 + AF_VENDOR09 = 0x39 + AF_VENDOR10 = 0x3b + AF_VENDOR11 = 0x3d + AF_VENDOR12 = 0x3f + AF_VENDOR13 = 0x41 + AF_VENDOR14 = 0x43 + AF_VENDOR15 = 0x45 + AF_VENDOR16 = 0x47 + AF_VENDOR17 = 0x49 + AF_VENDOR18 = 0x4b + AF_VENDOR19 = 0x4d + AF_VENDOR20 = 0x4f + AF_VENDOR21 = 0x51 + AF_VENDOR22 = 0x53 + AF_VENDOR23 = 0x55 + AF_VENDOR24 = 0x57 + AF_VENDOR25 = 0x59 + AF_VENDOR26 = 0x5b + AF_VENDOR27 = 0x5d + AF_VENDOR28 = 0x5f + AF_VENDOR29 = 0x61 + AF_VENDOR30 = 0x63 + AF_VENDOR31 = 0x65 + AF_VENDOR32 = 0x67 + AF_VENDOR33 = 0x69 + AF_VENDOR34 = 0x6b + AF_VENDOR35 = 0x6d + AF_VENDOR36 = 0x6f + AF_VENDOR37 = 0x71 + AF_VENDOR38 = 0x73 + AF_VENDOR39 = 0x75 + AF_VENDOR40 = 0x77 + AF_VENDOR41 = 0x79 + AF_VENDOR42 = 0x7b + AF_VENDOR43 = 0x7d + AF_VENDOR44 = 0x7f + AF_VENDOR45 = 0x81 + AF_VENDOR46 = 0x83 + AF_VENDOR47 = 0x85 + ALTWERASE = 0x200 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B460800 = 0x70800 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B921600 = 0xe1000 + B9600 = 0x2580 + BIOCFEEDBACK = 0x8004427c + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDIRECTION = 0x40044276 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc0084279 + BIOCGETBUFMODE = 0x4004427d + BIOCGETIF = 0x4020426b + BIOCGETZMAX = 0x4004427f + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4010426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCGTSTAMP = 0x40044283 + BIOCIMMEDIATE = 0x80044270 + BIOCLOCK = 0x2000427a + BIOCPROMISC = 0x20004269 + BIOCROTZBUF = 0x400c4280 + BIOCSBLEN = 0xc0044266 + BIOCSDIRECTION = 0x80044277 + BIOCSDLT = 0x80044278 + BIOCSETBUFMODE = 0x8004427e + BIOCSETF = 0x80084267 + BIOCSETFNR = 0x80084282 + BIOCSETIF = 0x8020426c + BIOCSETWF = 0x8008427b + BIOCSETZBUF = 0x800c4281 + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8010426d + BIOCSSEESENT = 0x80044277 + BIOCSTSTAMP = 0x80044284 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_BUFMODE_BUFFER = 0x1 + BPF_BUFMODE_ZBUF = 0x2 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_T_BINTIME = 0x2 + BPF_T_BINTIME_FAST = 0x102 + BPF_T_BINTIME_MONOTONIC = 0x202 + BPF_T_BINTIME_MONOTONIC_FAST = 0x302 + BPF_T_FAST = 0x100 + BPF_T_FLAG_MASK = 0x300 + BPF_T_FORMAT_MASK = 0x3 + BPF_T_MICROTIME = 0x0 + BPF_T_MICROTIME_FAST = 0x100 + BPF_T_MICROTIME_MONOTONIC = 0x200 + BPF_T_MICROTIME_MONOTONIC_FAST = 0x300 + BPF_T_MONOTONIC = 0x200 + BPF_T_MONOTONIC_FAST = 0x300 + BPF_T_NANOTIME = 0x1 + BPF_T_NANOTIME_FAST = 0x101 + BPF_T_NANOTIME_MONOTONIC = 0x201 + BPF_T_NANOTIME_MONOTONIC_FAST = 0x301 + BPF_T_NONE = 0x3 + BPF_T_NORMAL = 0x0 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + CAP_ACCEPT = 0x200000020000000 + CAP_ACL_CHECK = 0x400000000010000 + CAP_ACL_DELETE = 0x400000000020000 + CAP_ACL_GET = 0x400000000040000 + CAP_ACL_SET = 0x400000000080000 + CAP_ALL0 = 0x20007ffffffffff + CAP_ALL1 = 0x4000000001fffff + CAP_BIND = 0x200000040000000 + CAP_BINDAT = 0x200008000000400 + CAP_CHFLAGSAT = 0x200000000001400 + CAP_CONNECT = 0x200000080000000 + CAP_CONNECTAT = 0x200010000000400 + CAP_CREATE = 0x200000000000040 + CAP_EVENT = 0x400000000000020 + CAP_EXTATTR_DELETE = 0x400000000001000 + CAP_EXTATTR_GET = 0x400000000002000 + CAP_EXTATTR_LIST = 0x400000000004000 + CAP_EXTATTR_SET = 0x400000000008000 + CAP_FCHDIR = 0x200000000000800 + CAP_FCHFLAGS = 0x200000000001000 + CAP_FCHMOD = 0x200000000002000 + CAP_FCHMODAT = 0x200000000002400 + CAP_FCHOWN = 0x200000000004000 + CAP_FCHOWNAT = 0x200000000004400 + CAP_FCNTL = 0x200000000008000 + CAP_FCNTL_ALL = 0x78 + CAP_FCNTL_GETFL = 0x8 + CAP_FCNTL_GETOWN = 0x20 + CAP_FCNTL_SETFL = 0x10 + CAP_FCNTL_SETOWN = 0x40 + CAP_FEXECVE = 0x200000000000080 + CAP_FLOCK = 0x200000000010000 + CAP_FPATHCONF = 0x200000000020000 + CAP_FSCK = 0x200000000040000 + CAP_FSTAT = 0x200000000080000 + CAP_FSTATAT = 0x200000000080400 + CAP_FSTATFS = 0x200000000100000 + CAP_FSYNC = 0x200000000000100 + CAP_FTRUNCATE = 0x200000000000200 + CAP_FUTIMES = 0x200000000200000 + CAP_FUTIMESAT = 0x200000000200400 + CAP_GETPEERNAME = 0x200000100000000 + CAP_GETSOCKNAME = 0x200000200000000 + CAP_GETSOCKOPT = 0x200000400000000 + CAP_IOCTL = 0x400000000000080 + CAP_IOCTLS_ALL = 0x7fffffff + CAP_KQUEUE = 0x400000000100040 + CAP_KQUEUE_CHANGE = 0x400000000100000 + CAP_KQUEUE_EVENT = 0x400000000000040 + CAP_LINKAT_SOURCE = 0x200020000000400 + CAP_LINKAT_TARGET = 0x200000000400400 + CAP_LISTEN = 0x200000800000000 + CAP_LOOKUP = 0x200000000000400 + CAP_MAC_GET = 0x400000000000001 + CAP_MAC_SET = 0x400000000000002 + CAP_MKDIRAT = 0x200000000800400 + CAP_MKFIFOAT = 0x200000001000400 + CAP_MKNODAT = 0x200000002000400 + CAP_MMAP = 0x200000000000010 + CAP_MMAP_R = 0x20000000000001d + CAP_MMAP_RW = 0x20000000000001f + CAP_MMAP_RWX = 0x20000000000003f + CAP_MMAP_RX = 0x20000000000003d + CAP_MMAP_W = 0x20000000000001e + CAP_MMAP_WX = 0x20000000000003e + CAP_MMAP_X = 0x20000000000003c + CAP_PDGETPID = 0x400000000000200 + CAP_PDKILL = 0x400000000000800 + CAP_PDWAIT = 0x400000000000400 + CAP_PEELOFF = 0x200001000000000 + CAP_POLL_EVENT = 0x400000000000020 + CAP_PREAD = 0x20000000000000d + CAP_PWRITE = 0x20000000000000e + CAP_READ = 0x200000000000001 + CAP_RECV = 0x200000000000001 + CAP_RENAMEAT_SOURCE = 0x200000004000400 + CAP_RENAMEAT_TARGET = 0x200040000000400 + CAP_RIGHTS_VERSION = 0x0 + CAP_RIGHTS_VERSION_00 = 0x0 + CAP_SEEK = 0x20000000000000c + CAP_SEEK_TELL = 0x200000000000004 + CAP_SEM_GETVALUE = 0x400000000000004 + CAP_SEM_POST = 0x400000000000008 + CAP_SEM_WAIT = 0x400000000000010 + CAP_SEND = 0x200000000000002 + CAP_SETSOCKOPT = 0x200002000000000 + CAP_SHUTDOWN = 0x200004000000000 + CAP_SOCK_CLIENT = 0x200007780000003 + CAP_SOCK_SERVER = 0x200007f60000003 + CAP_SYMLINKAT = 0x200000008000400 + CAP_TTYHOOK = 0x400000000000100 + CAP_UNLINKAT = 0x200000010000400 + CAP_UNUSED0_44 = 0x200080000000000 + CAP_UNUSED0_57 = 0x300000000000000 + CAP_UNUSED1_22 = 0x400000000200000 + CAP_UNUSED1_57 = 0x500000000000000 + CAP_WRITE = 0x200000000000002 + CFLUSH = 0xf + CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x4 + CLOCK_MONOTONIC_FAST = 0xc + CLOCK_MONOTONIC_PRECISE = 0xb + CLOCK_PROCESS_CPUTIME_ID = 0xf + CLOCK_PROF = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_FAST = 0xa + CLOCK_REALTIME_PRECISE = 0x9 + CLOCK_SECOND = 0xd + CLOCK_THREAD_CPUTIME_ID = 0xe + CLOCK_UPTIME = 0x5 + CLOCK_UPTIME_FAST = 0x8 + CLOCK_UPTIME_PRECISE = 0x7 + CLOCK_VIRTUAL = 0x1 + CREAD = 0x800 + CRTSCTS = 0x30000 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0x18 + CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_BREDR_BB = 0xff + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_BLUETOOTH_LE_LL = 0xfb + DLT_BLUETOOTH_LE_LL_WITH_PHDR = 0x100 + DLT_BLUETOOTH_LINUX_MONITOR = 0xfe + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 + DLT_CLASS_NETBSD_RAWAF = 0x2240000 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_EPON = 0x103 + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_INFINIBAND = 0xf7 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPMI_HPM_2 = 0x104 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_ISO_14443 = 0x108 + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0x109 + DLT_MATCHING_MIN = 0x68 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NETLINK = 0xfd + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x79 + DLT_PKTAP = 0x102 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0xe + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 + DLT_PRISM_HEADER = 0x77 + DLT_PROFIBUS_DL = 0x101 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RDS = 0x109 + DLT_REDBACK_SMARTEDGE = 0x20 + DLT_RIO = 0x7c + DLT_RTAC_SERIAL = 0xfa + DLT_SCCP = 0x8e + DLT_SCTP = 0xf8 + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xd + DLT_STANAG_5066_D_PDU = 0xed + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USBPCAP = 0xf9 + DLT_USB_FREEBSD = 0xba + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WATTSTOPPER_DLM = 0x107 + DLT_WIHART = 0xdf + DLT_WIRESHARK_UPPER_PDU = 0xfc + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DLT_ZWAVE_R1_R2 = 0x105 + DLT_ZWAVE_R3 = 0x106 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_FS = -0x9 + EVFILT_LIO = -0xa + EVFILT_PROC = -0x5 + EVFILT_PROCDESC = -0x8 + EVFILT_READ = -0x1 + EVFILT_SENDFILE = -0xc + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0xc + EVFILT_TIMER = -0x7 + EVFILT_USER = -0xb + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_DROP = 0x1000 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_FLAG2 = 0x4000 + EV_FORCEONESHOT = 0x100 + EV_ONESHOT = 0x10 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTATTR_NAMESPACE_EMPTY = 0x0 + EXTATTR_NAMESPACE_SYSTEM = 0x2 + EXTATTR_NAMESPACE_USER = 0x1 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_CANCEL = 0x5 + F_DUP2FD = 0xa + F_DUP2FD_CLOEXEC = 0x12 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x11 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0xb + F_GETOWN = 0x5 + F_OGETLK = 0x7 + F_OK = 0x0 + F_OSETLK = 0x8 + F_OSETLKW = 0x9 + F_RDAHEAD = 0x10 + F_RDLCK = 0x1 + F_READAHEAD = 0xf + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0xc + F_SETLKW = 0xd + F_SETLK_REMOTE = 0xe + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_UNLCKSYS = 0x4 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x218f52 + IFF_CANTCONFIG = 0x10000 + IFF_DEBUG = 0x4 + IFF_DRV_OACTIVE = 0x400 + IFF_DRV_RUNNING = 0x40 + IFF_DYING = 0x200000 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MONITOR = 0x40000 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PPROMISC = 0x20000 + IFF_PROMISC = 0x100 + IFF_RENAMING = 0x400000 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_STATICARP = 0x80000 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + IFT_BRIDGE = 0xd1 + IFT_CARP = 0xf8 + IFT_IEEE1394 = 0x90 + IFT_INFINIBAND = 0xc7 + IFT_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + IFT_PPP = 0x17 + IFT_PROPVIRTUAL = 0x35 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IN_RFC3021_MASK = 0xfffffffe + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CARP = 0x70 + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0x102 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HIP = 0x8b + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MEAS = 0x13 + IPPROTO_MH = 0x87 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MOBILE = 0x37 + IPPROTO_MPLS = 0x89 + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OLD_DIVERT = 0xfe + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_RESERVED_253 = 0xfd + IPPROTO_RESERVED_254 = 0xfe + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEND = 0x103 + IPPROTO_SEP = 0x21 + IPPROTO_SHIM6 = 0x8c + IPPROTO_SKIP = 0x39 + IPPROTO_SPACER = 0x7fff + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TLSP = 0x38 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_BINDANY = 0x40 + IPV6_BINDMULTI = 0x41 + IPV6_BINDV6ONLY = 0x1b + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_FLOWID = 0x43 + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FLOWTYPE = 0x44 + IPV6_FRAGTTL = 0x78 + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 + IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f + IPV6_MMTU = 0x500 + IPV6_MSFILTER = 0x4a + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_PREFER_TEMPADDR = 0x3f + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVFLOWID = 0x46 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRSSBUCKETID = 0x47 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RSSBUCKETID = 0x45 + IPV6_RSS_LISTEN_BUCKET = 0x42 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BINDANY = 0x18 + IP_BINDMULTI = 0x19 + IP_BLOCK_SOURCE = 0x48 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DONTFRAG = 0x43 + IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 + IP_DUMMYNET3 = 0x31 + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FLOWID = 0x5a + IP_FLOWTYPE = 0x5b + IP_FW3 = 0x30 + IP_FW_ADD = 0x32 + IP_FW_DEL = 0x33 + IP_FW_FLUSH = 0x34 + IP_FW_GET = 0x36 + IP_FW_NAT_CFG = 0x38 + IP_FW_NAT_DEL = 0x39 + IP_FW_NAT_GET_CONFIG = 0x3a + IP_FW_NAT_GET_LOG = 0x3b + IP_FW_RESETLOG = 0x37 + IP_FW_TABLE_ADD = 0x28 + IP_FW_TABLE_DEL = 0x29 + IP_FW_TABLE_FLUSH = 0x2a + IP_FW_TABLE_GETSIZE = 0x2b + IP_FW_TABLE_LIST = 0x2c + IP_FW_ZERO = 0x35 + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 + IP_MAX_SOURCE_FILTER = 0x400 + IP_MF = 0x2000 + IP_MINTTL = 0x42 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_OFFMASK = 0x1fff + IP_ONESBCAST = 0x17 + IP_OPTIONS = 0x1 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVFLOWID = 0x5d + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVRSSBUCKETID = 0x5e + IP_RECVTOS = 0x44 + IP_RECVTTL = 0x41 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSSBUCKETID = 0x5c + IP_RSS_LISTEN_BUCKET = 0x1a + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_SENDSRCADDR = 0x7 + IP_TOS = 0x3 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 + ISIG = 0x80 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_AUTOSYNC = 0x7 + MADV_CORE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_NOCORE = 0x8 + MADV_NORMAL = 0x0 + MADV_NOSYNC = 0x6 + MADV_PROTECT = 0xa + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MAP_ALIGNED_SUPER = 0x1000000 + MAP_ALIGNMENT_MASK = -0x1000000 + MAP_ALIGNMENT_SHIFT = 0x18 + MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 + MAP_COPY = 0x2 + MAP_EXCL = 0x4000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GUARD = 0x2000 + MAP_HASSEMAPHORE = 0x200 + MAP_NOCORE = 0x20000 + MAP_NOSYNC = 0x800 + MAP_PREFAULT_READ = 0x40000 + MAP_PRIVATE = 0x2 + MAP_RESERVED0020 = 0x20 + MAP_RESERVED0040 = 0x40 + MAP_RESERVED0080 = 0x80 + MAP_RESERVED0100 = 0x100 + MAP_SHARED = 0x1 + MAP_STACK = 0x400 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_CMSG_CLOEXEC = 0x40000 + MSG_COMPAT = 0x8000 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_NBIO = 0x4000 + MSG_NOSIGNAL = 0x20000 + MSG_NOTIFICATION = 0x2000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MSG_WAITFORONE = 0x80000 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x2 + MS_SYNC = 0x0 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_IFLISTL = 0x5 + NET_RT_IFMALIST = 0x4 + NOFLSH = 0x80000000 + NOKERNINFO = 0x2000000 + NOTE_ATTRIB = 0x8 + NOTE_CHILD = 0x4 + NOTE_CLOSE = 0x100 + NOTE_CLOSE_WRITE = 0x200 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 + NOTE_FILE_POLL = 0x2 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_MSECONDS = 0x2 + NOTE_NSECONDS = 0x8 + NOTE_OPEN = 0x80 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_READ = 0x400 + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_SECONDS = 0x1 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_USECONDS = 0x4 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + OXTABS = 0x4 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x100000 + O_CREAT = 0x200 + O_DIRECT = 0x10000 + O_DIRECTORY = 0x20000 + O_EXCL = 0x800 + O_EXEC = 0x40000 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_TTY_INIT = 0x80000 + O_VERIFY = 0x200000 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_AS = 0xa + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 + RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x8 + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_FIXEDMTU = 0x80000 + RTF_FMASK = 0x1004d808 + RTF_GATEWAY = 0x2 + RTF_GWFLAG_COMPAT = 0x80000000 + RTF_HOST = 0x4 + RTF_LLDATA = 0x400 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MULTICAST = 0x800000 + RTF_PINNED = 0x100000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_REJECT = 0x8 + RTF_RNH_LOCKED = 0x40000000 + RTF_STATIC = 0x800 + RTF_STICKY = 0x10000000 + RTF_UP = 0x1 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_IEEE80211 = 0x12 + RTM_IFANNOUNCE = 0x11 + RTM_IFINFO = 0xe + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RTV_WEIGHT = 0x100 + RT_ALL_FIBS = -0x1 + RT_BLACKHOLE = 0x40 + RT_CACHING_CONTEXT = 0x1 + RT_DEFAULT_FIB = 0x0 + RT_HAS_GW = 0x80 + RT_HAS_HEADER = 0x10 + RT_HAS_HEADER_BIT = 0x4 + RT_L2_ME = 0x4 + RT_L2_ME_BIT = 0x2 + RT_LLE_CACHE = 0x100 + RT_MAY_LOOP = 0x8 + RT_MAY_LOOP_BIT = 0x3 + RT_NORTREF = 0x2 + RT_REJECT = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_BINTIME = 0x4 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCAIFGROUP = 0x80246987 + SIOCATMARK = 0x40047307 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFGROUP = 0x80246989 + SIOCDIFPHYADDR = 0x80206949 + SIOCGDRVSPEC = 0xc01c697b + SIOCGETSGCNT = 0xc0147210 + SIOCGETVIFCNT = 0xc014720f + SIOCGHIWAT = 0x40047301 + SIOCGHWADDR = 0xc020693e + SIOCGI2C = 0xc020693d + SIOCGIFADDR = 0xc0206921 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020691f + SIOCGIFCONF = 0xc0086924 + SIOCGIFDESCR = 0xc020692a + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFIB = 0xc020695c + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGENERIC = 0xc020693a + SIOCGIFGMEMB = 0xc024698a + SIOCGIFGROUP = 0xc0246988 + SIOCGIFINDEX = 0xc0206920 + SIOCGIFMAC = 0xc0206926 + SIOCGIFMEDIA = 0xc0286938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206948 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPSRCADDR = 0xc0206947 + SIOCGIFSTATUS = 0xc331693b + SIOCGIFXMEDIA = 0xc028698b + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCGPRIVATE_0 = 0xc0206950 + SIOCGPRIVATE_1 = 0xc0206951 + SIOCGTUNFIB = 0xc020695e + SIOCIFCREATE = 0xc020697a + SIOCIFCREATE2 = 0xc020697c + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc00c6978 + SIOCSDRVSPEC = 0x801c697b + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020691e + SIOCSIFDESCR = 0x80206929 + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFIB = 0x8020695d + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206927 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNAME = 0x80206928 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x80406946 + SIOCSIFPHYS = 0x80206936 + SIOCSIFRVNET = 0xc020695b + SIOCSIFVNET = 0xc020695a + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SIOCSTUNFIB = 0x8020695f + SOCK_CLOEXEC = 0x10000000 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_NONBLOCK = 0x20000000 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_ACCEPTFILTER = 0x1000 + SO_BINTIME = 0x2000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1009 + SO_LINGER = 0x80 + SO_LISTENINCQLEN = 0x1013 + SO_LISTENQLEN = 0x1012 + SO_LISTENQLIMIT = 0x1011 + SO_NOSIGPIPE = 0x800 + SO_NO_DDP = 0x8000 + SO_NO_OFFLOAD = 0x4000 + SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1010 + SO_PROTOCOL = 0x1016 + SO_PROTOTYPE = 0x1016 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_SETFIB = 0x1014 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + SO_USER_COOKIE = 0x1015 + SO_VENDOR = 0x80000000 + TAB0 = 0x0 + TAB3 = 0x4 + TABDLY = 0x4 + TCIFLUSH = 0x1 + TCIOFF = 0x3 + TCIOFLUSH = 0x3 + TCION = 0x4 + TCOFLUSH = 0x2 + TCOOFF = 0x1 + TCOON = 0x2 + TCP_CA_NAME_MAX = 0x10 + TCP_CCALGOOPT = 0x41 + TCP_CONGESTION = 0x40 + TCP_FASTOPEN = 0x401 + TCP_FUNCTION_BLK = 0x2000 + TCP_FUNCTION_NAME_LEN_MAX = 0x20 + TCP_INFO = 0x20 + TCP_KEEPCNT = 0x400 + TCP_KEEPIDLE = 0x100 + TCP_KEEPINIT = 0x80 + TCP_KEEPINTVL = 0x200 + TCP_MAXBURST = 0x4 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x10 + TCP_MINMSS = 0xd8 + TCP_MSS = 0x218 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_PCAP_IN = 0x1000 + TCP_PCAP_OUT = 0x800 + TCP_VENDOR = 0x80000000 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGPTN = 0x4004740f + TIOCGSID = 0x40047463 + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DCD = 0x40 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTMASTER = 0x2000741c + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2004745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40107459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VERASE2 = 0x7 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x4 + WCOREFLAG = 0x80 + WEXITED = 0x10 + WLINUXCLONE = 0x80000000 + WNOHANG = 0x1 + WNOWAIT = 0x8 + WSTOPPED = 0x2 + WTRAPPED = 0x20 + WUNTRACED = 0x2 ) // Errors diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index 4723162f7..a6b3b5f14 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -1413,6 +1413,16 @@ const ( SIOCADDMULTI = 0x8931 SIOCADDRT = 0x890b SIOCATMARK = 0x8905 + SIOCBONDCHANGEACTIVE = 0x8995 + SIOCBONDENSLAVE = 0x8990 + SIOCBONDINFOQUERY = 0x8994 + SIOCBONDRELEASE = 0x8991 + SIOCBONDSETHWADDR = 0x8992 + SIOCBONDSLAVEINFOQUERY = 0x8993 + SIOCBRADDBR = 0x89a0 + SIOCBRADDIF = 0x89a2 + SIOCBRDELBR = 0x89a1 + SIOCBRDELIF = 0x89a3 SIOCDARP = 0x8953 SIOCDELDLCI = 0x8981 SIOCDELMULTI = 0x8932 @@ -1420,7 +1430,9 @@ const ( SIOCDEVPRIVATE = 0x89f0 SIOCDIFADDR = 0x8936 SIOCDRARP = 0x8960 + SIOCETHTOOL = 0x8946 SIOCGARP = 0x8954 + SIOCGHWTSTAMP = 0x89b1 SIOCGIFADDR = 0x8915 SIOCGIFBR = 0x8940 SIOCGIFBRDADDR = 0x8919 @@ -1440,13 +1452,21 @@ const ( SIOCGIFPFLAGS = 0x8935 SIOCGIFSLAVE = 0x8929 SIOCGIFTXQLEN = 0x8942 + SIOCGIFVLAN = 0x8982 + SIOCGMIIPHY = 0x8947 + SIOCGMIIREG = 0x8948 SIOCGPGRP = 0x8904 SIOCGRARP = 0x8961 + SIOCGSKNS = 0x894c SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 + SIOCINQ = 0x541b + SIOCOUTQ = 0x5411 + SIOCOUTQNSD = 0x894b SIOCPROTOPRIVATE = 0x89e0 SIOCRTMSG = 0x890d SIOCSARP = 0x8955 + SIOCSHWTSTAMP = 0x89b0 SIOCSIFADDR = 0x8916 SIOCSIFBR = 0x8941 SIOCSIFBRDADDR = 0x891a @@ -1465,11 +1485,15 @@ const ( SIOCSIFPFLAGS = 0x8934 SIOCSIFSLAVE = 0x8930 SIOCSIFTXQLEN = 0x8943 + SIOCSIFVLAN = 0x8983 + SIOCSMIIREG = 0x8949 SIOCSPGRP = 0x8902 SIOCSRARP = 0x8962 + SIOCWANDEV = 0x894a SOCK_CLOEXEC = 0x80000 SOCK_DCCP = 0x6 SOCK_DGRAM = 0x2 + SOCK_IOC_TYPE = 0x89 SOCK_NONBLOCK = 0x800 SOCK_PACKET = 0xa SOCK_RAW = 0x3 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index b5c978ece..4ffc8d29c 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -1414,6 +1414,16 @@ const ( SIOCADDMULTI = 0x8931 SIOCADDRT = 0x890b SIOCATMARK = 0x8905 + SIOCBONDCHANGEACTIVE = 0x8995 + SIOCBONDENSLAVE = 0x8990 + SIOCBONDINFOQUERY = 0x8994 + SIOCBONDRELEASE = 0x8991 + SIOCBONDSETHWADDR = 0x8992 + SIOCBONDSLAVEINFOQUERY = 0x8993 + SIOCBRADDBR = 0x89a0 + SIOCBRADDIF = 0x89a2 + SIOCBRDELBR = 0x89a1 + SIOCBRDELIF = 0x89a3 SIOCDARP = 0x8953 SIOCDELDLCI = 0x8981 SIOCDELMULTI = 0x8932 @@ -1421,7 +1431,9 @@ const ( SIOCDEVPRIVATE = 0x89f0 SIOCDIFADDR = 0x8936 SIOCDRARP = 0x8960 + SIOCETHTOOL = 0x8946 SIOCGARP = 0x8954 + SIOCGHWTSTAMP = 0x89b1 SIOCGIFADDR = 0x8915 SIOCGIFBR = 0x8940 SIOCGIFBRDADDR = 0x8919 @@ -1441,13 +1453,21 @@ const ( SIOCGIFPFLAGS = 0x8935 SIOCGIFSLAVE = 0x8929 SIOCGIFTXQLEN = 0x8942 + SIOCGIFVLAN = 0x8982 + SIOCGMIIPHY = 0x8947 + SIOCGMIIREG = 0x8948 SIOCGPGRP = 0x8904 SIOCGRARP = 0x8961 + SIOCGSKNS = 0x894c SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 + SIOCINQ = 0x541b + SIOCOUTQ = 0x5411 + SIOCOUTQNSD = 0x894b SIOCPROTOPRIVATE = 0x89e0 SIOCRTMSG = 0x890d SIOCSARP = 0x8955 + SIOCSHWTSTAMP = 0x89b0 SIOCSIFADDR = 0x8916 SIOCSIFBR = 0x8941 SIOCSIFBRDADDR = 0x891a @@ -1466,11 +1486,15 @@ const ( SIOCSIFPFLAGS = 0x8934 SIOCSIFSLAVE = 0x8930 SIOCSIFTXQLEN = 0x8943 + SIOCSIFVLAN = 0x8983 + SIOCSMIIREG = 0x8949 SIOCSPGRP = 0x8902 SIOCSRARP = 0x8962 + SIOCWANDEV = 0x894a SOCK_CLOEXEC = 0x80000 SOCK_DCCP = 0x6 SOCK_DGRAM = 0x2 + SOCK_IOC_TYPE = 0x89 SOCK_NONBLOCK = 0x800 SOCK_PACKET = 0xa SOCK_RAW = 0x3 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 0ae0e8c41..f4b178ef1 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -1418,6 +1418,16 @@ const ( SIOCADDMULTI = 0x8931 SIOCADDRT = 0x890b SIOCATMARK = 0x8905 + SIOCBONDCHANGEACTIVE = 0x8995 + SIOCBONDENSLAVE = 0x8990 + SIOCBONDINFOQUERY = 0x8994 + SIOCBONDRELEASE = 0x8991 + SIOCBONDSETHWADDR = 0x8992 + SIOCBONDSLAVEINFOQUERY = 0x8993 + SIOCBRADDBR = 0x89a0 + SIOCBRADDIF = 0x89a2 + SIOCBRDELBR = 0x89a1 + SIOCBRDELIF = 0x89a3 SIOCDARP = 0x8953 SIOCDELDLCI = 0x8981 SIOCDELMULTI = 0x8932 @@ -1425,7 +1435,9 @@ const ( SIOCDEVPRIVATE = 0x89f0 SIOCDIFADDR = 0x8936 SIOCDRARP = 0x8960 + SIOCETHTOOL = 0x8946 SIOCGARP = 0x8954 + SIOCGHWTSTAMP = 0x89b1 SIOCGIFADDR = 0x8915 SIOCGIFBR = 0x8940 SIOCGIFBRDADDR = 0x8919 @@ -1445,13 +1457,21 @@ const ( SIOCGIFPFLAGS = 0x8935 SIOCGIFSLAVE = 0x8929 SIOCGIFTXQLEN = 0x8942 + SIOCGIFVLAN = 0x8982 + SIOCGMIIPHY = 0x8947 + SIOCGMIIREG = 0x8948 SIOCGPGRP = 0x8904 SIOCGRARP = 0x8961 + SIOCGSKNS = 0x894c SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 + SIOCINQ = 0x541b + SIOCOUTQ = 0x5411 + SIOCOUTQNSD = 0x894b SIOCPROTOPRIVATE = 0x89e0 SIOCRTMSG = 0x890d SIOCSARP = 0x8955 + SIOCSHWTSTAMP = 0x89b0 SIOCSIFADDR = 0x8916 SIOCSIFBR = 0x8941 SIOCSIFBRDADDR = 0x891a @@ -1470,11 +1490,15 @@ const ( SIOCSIFPFLAGS = 0x8934 SIOCSIFSLAVE = 0x8930 SIOCSIFTXQLEN = 0x8943 + SIOCSIFVLAN = 0x8983 + SIOCSMIIREG = 0x8949 SIOCSPGRP = 0x8902 SIOCSRARP = 0x8962 + SIOCWANDEV = 0x894a SOCK_CLOEXEC = 0x80000 SOCK_DCCP = 0x6 SOCK_DGRAM = 0x2 + SOCK_IOC_TYPE = 0x89 SOCK_NONBLOCK = 0x800 SOCK_PACKET = 0xa SOCK_RAW = 0x3 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 3c53a84c3..495f13b61 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -1403,6 +1403,16 @@ const ( SIOCADDMULTI = 0x8931 SIOCADDRT = 0x890b SIOCATMARK = 0x8905 + SIOCBONDCHANGEACTIVE = 0x8995 + SIOCBONDENSLAVE = 0x8990 + SIOCBONDINFOQUERY = 0x8994 + SIOCBONDRELEASE = 0x8991 + SIOCBONDSETHWADDR = 0x8992 + SIOCBONDSLAVEINFOQUERY = 0x8993 + SIOCBRADDBR = 0x89a0 + SIOCBRADDIF = 0x89a2 + SIOCBRDELBR = 0x89a1 + SIOCBRDELIF = 0x89a3 SIOCDARP = 0x8953 SIOCDELDLCI = 0x8981 SIOCDELMULTI = 0x8932 @@ -1410,7 +1420,9 @@ const ( SIOCDEVPRIVATE = 0x89f0 SIOCDIFADDR = 0x8936 SIOCDRARP = 0x8960 + SIOCETHTOOL = 0x8946 SIOCGARP = 0x8954 + SIOCGHWTSTAMP = 0x89b1 SIOCGIFADDR = 0x8915 SIOCGIFBR = 0x8940 SIOCGIFBRDADDR = 0x8919 @@ -1430,13 +1442,21 @@ const ( SIOCGIFPFLAGS = 0x8935 SIOCGIFSLAVE = 0x8929 SIOCGIFTXQLEN = 0x8942 + SIOCGIFVLAN = 0x8982 + SIOCGMIIPHY = 0x8947 + SIOCGMIIREG = 0x8948 SIOCGPGRP = 0x8904 SIOCGRARP = 0x8961 + SIOCGSKNS = 0x894c SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 + SIOCINQ = 0x541b + SIOCOUTQ = 0x5411 + SIOCOUTQNSD = 0x894b SIOCPROTOPRIVATE = 0x89e0 SIOCRTMSG = 0x890d SIOCSARP = 0x8955 + SIOCSHWTSTAMP = 0x89b0 SIOCSIFADDR = 0x8916 SIOCSIFBR = 0x8941 SIOCSIFBRDADDR = 0x891a @@ -1455,11 +1475,15 @@ const ( SIOCSIFPFLAGS = 0x8934 SIOCSIFSLAVE = 0x8930 SIOCSIFTXQLEN = 0x8943 + SIOCSIFVLAN = 0x8983 + SIOCSMIIREG = 0x8949 SIOCSPGRP = 0x8902 SIOCSRARP = 0x8962 + SIOCWANDEV = 0x894a SOCK_CLOEXEC = 0x80000 SOCK_DCCP = 0x6 SOCK_DGRAM = 0x2 + SOCK_IOC_TYPE = 0x89 SOCK_NONBLOCK = 0x800 SOCK_PACKET = 0xa SOCK_RAW = 0x3 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index 23e845e57..59651e415 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -1415,6 +1415,16 @@ const ( SIOCADDMULTI = 0x8931 SIOCADDRT = 0x890b SIOCATMARK = 0x40047307 + SIOCBONDCHANGEACTIVE = 0x8995 + SIOCBONDENSLAVE = 0x8990 + SIOCBONDINFOQUERY = 0x8994 + SIOCBONDRELEASE = 0x8991 + SIOCBONDSETHWADDR = 0x8992 + SIOCBONDSLAVEINFOQUERY = 0x8993 + SIOCBRADDBR = 0x89a0 + SIOCBRADDIF = 0x89a2 + SIOCBRDELBR = 0x89a1 + SIOCBRDELIF = 0x89a3 SIOCDARP = 0x8953 SIOCDELDLCI = 0x8981 SIOCDELMULTI = 0x8932 @@ -1422,7 +1432,9 @@ const ( SIOCDEVPRIVATE = 0x89f0 SIOCDIFADDR = 0x8936 SIOCDRARP = 0x8960 + SIOCETHTOOL = 0x8946 SIOCGARP = 0x8954 + SIOCGHWTSTAMP = 0x89b1 SIOCGIFADDR = 0x8915 SIOCGIFBR = 0x8940 SIOCGIFBRDADDR = 0x8919 @@ -1442,13 +1454,21 @@ const ( SIOCGIFPFLAGS = 0x8935 SIOCGIFSLAVE = 0x8929 SIOCGIFTXQLEN = 0x8942 + SIOCGIFVLAN = 0x8982 + SIOCGMIIPHY = 0x8947 + SIOCGMIIREG = 0x8948 SIOCGPGRP = 0x40047309 SIOCGRARP = 0x8961 + SIOCGSKNS = 0x894c SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 + SIOCINQ = 0x467f + SIOCOUTQ = 0x7472 + SIOCOUTQNSD = 0x894b SIOCPROTOPRIVATE = 0x89e0 SIOCRTMSG = 0x890d SIOCSARP = 0x8955 + SIOCSHWTSTAMP = 0x89b0 SIOCSIFADDR = 0x8916 SIOCSIFBR = 0x8941 SIOCSIFBRDADDR = 0x891a @@ -1467,11 +1487,15 @@ const ( SIOCSIFPFLAGS = 0x8934 SIOCSIFSLAVE = 0x8930 SIOCSIFTXQLEN = 0x8943 + SIOCSIFVLAN = 0x8983 + SIOCSMIIREG = 0x8949 SIOCSPGRP = 0x80047308 SIOCSRARP = 0x8962 + SIOCWANDEV = 0x894a SOCK_CLOEXEC = 0x80000 SOCK_DCCP = 0x6 SOCK_DGRAM = 0x1 + SOCK_IOC_TYPE = 0x89 SOCK_NONBLOCK = 0x80 SOCK_PACKET = 0xa SOCK_RAW = 0x3 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index d27b373c3..a09bf9b18 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -1415,6 +1415,16 @@ const ( SIOCADDMULTI = 0x8931 SIOCADDRT = 0x890b SIOCATMARK = 0x40047307 + SIOCBONDCHANGEACTIVE = 0x8995 + SIOCBONDENSLAVE = 0x8990 + SIOCBONDINFOQUERY = 0x8994 + SIOCBONDRELEASE = 0x8991 + SIOCBONDSETHWADDR = 0x8992 + SIOCBONDSLAVEINFOQUERY = 0x8993 + SIOCBRADDBR = 0x89a0 + SIOCBRADDIF = 0x89a2 + SIOCBRDELBR = 0x89a1 + SIOCBRDELIF = 0x89a3 SIOCDARP = 0x8953 SIOCDELDLCI = 0x8981 SIOCDELMULTI = 0x8932 @@ -1422,7 +1432,9 @@ const ( SIOCDEVPRIVATE = 0x89f0 SIOCDIFADDR = 0x8936 SIOCDRARP = 0x8960 + SIOCETHTOOL = 0x8946 SIOCGARP = 0x8954 + SIOCGHWTSTAMP = 0x89b1 SIOCGIFADDR = 0x8915 SIOCGIFBR = 0x8940 SIOCGIFBRDADDR = 0x8919 @@ -1442,13 +1454,21 @@ const ( SIOCGIFPFLAGS = 0x8935 SIOCGIFSLAVE = 0x8929 SIOCGIFTXQLEN = 0x8942 + SIOCGIFVLAN = 0x8982 + SIOCGMIIPHY = 0x8947 + SIOCGMIIREG = 0x8948 SIOCGPGRP = 0x40047309 SIOCGRARP = 0x8961 + SIOCGSKNS = 0x894c SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 + SIOCINQ = 0x467f + SIOCOUTQ = 0x7472 + SIOCOUTQNSD = 0x894b SIOCPROTOPRIVATE = 0x89e0 SIOCRTMSG = 0x890d SIOCSARP = 0x8955 + SIOCSHWTSTAMP = 0x89b0 SIOCSIFADDR = 0x8916 SIOCSIFBR = 0x8941 SIOCSIFBRDADDR = 0x891a @@ -1467,11 +1487,15 @@ const ( SIOCSIFPFLAGS = 0x8934 SIOCSIFSLAVE = 0x8930 SIOCSIFTXQLEN = 0x8943 + SIOCSIFVLAN = 0x8983 + SIOCSMIIREG = 0x8949 SIOCSPGRP = 0x80047308 SIOCSRARP = 0x8962 + SIOCWANDEV = 0x894a SOCK_CLOEXEC = 0x80000 SOCK_DCCP = 0x6 SOCK_DGRAM = 0x1 + SOCK_IOC_TYPE = 0x89 SOCK_NONBLOCK = 0x80 SOCK_PACKET = 0xa SOCK_RAW = 0x3 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index b31460180..72a0083c4 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -1415,6 +1415,16 @@ const ( SIOCADDMULTI = 0x8931 SIOCADDRT = 0x890b SIOCATMARK = 0x40047307 + SIOCBONDCHANGEACTIVE = 0x8995 + SIOCBONDENSLAVE = 0x8990 + SIOCBONDINFOQUERY = 0x8994 + SIOCBONDRELEASE = 0x8991 + SIOCBONDSETHWADDR = 0x8992 + SIOCBONDSLAVEINFOQUERY = 0x8993 + SIOCBRADDBR = 0x89a0 + SIOCBRADDIF = 0x89a2 + SIOCBRDELBR = 0x89a1 + SIOCBRDELIF = 0x89a3 SIOCDARP = 0x8953 SIOCDELDLCI = 0x8981 SIOCDELMULTI = 0x8932 @@ -1422,7 +1432,9 @@ const ( SIOCDEVPRIVATE = 0x89f0 SIOCDIFADDR = 0x8936 SIOCDRARP = 0x8960 + SIOCETHTOOL = 0x8946 SIOCGARP = 0x8954 + SIOCGHWTSTAMP = 0x89b1 SIOCGIFADDR = 0x8915 SIOCGIFBR = 0x8940 SIOCGIFBRDADDR = 0x8919 @@ -1442,13 +1454,21 @@ const ( SIOCGIFPFLAGS = 0x8935 SIOCGIFSLAVE = 0x8929 SIOCGIFTXQLEN = 0x8942 + SIOCGIFVLAN = 0x8982 + SIOCGMIIPHY = 0x8947 + SIOCGMIIREG = 0x8948 SIOCGPGRP = 0x40047309 SIOCGRARP = 0x8961 + SIOCGSKNS = 0x894c SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 + SIOCINQ = 0x467f + SIOCOUTQ = 0x7472 + SIOCOUTQNSD = 0x894b SIOCPROTOPRIVATE = 0x89e0 SIOCRTMSG = 0x890d SIOCSARP = 0x8955 + SIOCSHWTSTAMP = 0x89b0 SIOCSIFADDR = 0x8916 SIOCSIFBR = 0x8941 SIOCSIFBRDADDR = 0x891a @@ -1467,11 +1487,15 @@ const ( SIOCSIFPFLAGS = 0x8934 SIOCSIFSLAVE = 0x8930 SIOCSIFTXQLEN = 0x8943 + SIOCSIFVLAN = 0x8983 + SIOCSMIIREG = 0x8949 SIOCSPGRP = 0x80047308 SIOCSRARP = 0x8962 + SIOCWANDEV = 0x894a SOCK_CLOEXEC = 0x80000 SOCK_DCCP = 0x6 SOCK_DGRAM = 0x1 + SOCK_IOC_TYPE = 0x89 SOCK_NONBLOCK = 0x80 SOCK_PACKET = 0xa SOCK_RAW = 0x3 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index aa69fe628..84c0e3cc1 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -1415,6 +1415,16 @@ const ( SIOCADDMULTI = 0x8931 SIOCADDRT = 0x890b SIOCATMARK = 0x40047307 + SIOCBONDCHANGEACTIVE = 0x8995 + SIOCBONDENSLAVE = 0x8990 + SIOCBONDINFOQUERY = 0x8994 + SIOCBONDRELEASE = 0x8991 + SIOCBONDSETHWADDR = 0x8992 + SIOCBONDSLAVEINFOQUERY = 0x8993 + SIOCBRADDBR = 0x89a0 + SIOCBRADDIF = 0x89a2 + SIOCBRDELBR = 0x89a1 + SIOCBRDELIF = 0x89a3 SIOCDARP = 0x8953 SIOCDELDLCI = 0x8981 SIOCDELMULTI = 0x8932 @@ -1422,7 +1432,9 @@ const ( SIOCDEVPRIVATE = 0x89f0 SIOCDIFADDR = 0x8936 SIOCDRARP = 0x8960 + SIOCETHTOOL = 0x8946 SIOCGARP = 0x8954 + SIOCGHWTSTAMP = 0x89b1 SIOCGIFADDR = 0x8915 SIOCGIFBR = 0x8940 SIOCGIFBRDADDR = 0x8919 @@ -1442,13 +1454,21 @@ const ( SIOCGIFPFLAGS = 0x8935 SIOCGIFSLAVE = 0x8929 SIOCGIFTXQLEN = 0x8942 + SIOCGIFVLAN = 0x8982 + SIOCGMIIPHY = 0x8947 + SIOCGMIIREG = 0x8948 SIOCGPGRP = 0x40047309 SIOCGRARP = 0x8961 + SIOCGSKNS = 0x894c SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 + SIOCINQ = 0x467f + SIOCOUTQ = 0x7472 + SIOCOUTQNSD = 0x894b SIOCPROTOPRIVATE = 0x89e0 SIOCRTMSG = 0x890d SIOCSARP = 0x8955 + SIOCSHWTSTAMP = 0x89b0 SIOCSIFADDR = 0x8916 SIOCSIFBR = 0x8941 SIOCSIFBRDADDR = 0x891a @@ -1467,11 +1487,15 @@ const ( SIOCSIFPFLAGS = 0x8934 SIOCSIFSLAVE = 0x8930 SIOCSIFTXQLEN = 0x8943 + SIOCSIFVLAN = 0x8983 + SIOCSMIIREG = 0x8949 SIOCSPGRP = 0x80047308 SIOCSRARP = 0x8962 + SIOCWANDEV = 0x894a SOCK_CLOEXEC = 0x80000 SOCK_DCCP = 0x6 SOCK_DGRAM = 0x1 + SOCK_IOC_TYPE = 0x89 SOCK_NONBLOCK = 0x80 SOCK_PACKET = 0xa SOCK_RAW = 0x3 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index 6438fc855..8e4606e06 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -1471,6 +1471,16 @@ const ( SIOCADDMULTI = 0x8931 SIOCADDRT = 0x890b SIOCATMARK = 0x8905 + SIOCBONDCHANGEACTIVE = 0x8995 + SIOCBONDENSLAVE = 0x8990 + SIOCBONDINFOQUERY = 0x8994 + SIOCBONDRELEASE = 0x8991 + SIOCBONDSETHWADDR = 0x8992 + SIOCBONDSLAVEINFOQUERY = 0x8993 + SIOCBRADDBR = 0x89a0 + SIOCBRADDIF = 0x89a2 + SIOCBRDELBR = 0x89a1 + SIOCBRDELIF = 0x89a3 SIOCDARP = 0x8953 SIOCDELDLCI = 0x8981 SIOCDELMULTI = 0x8932 @@ -1478,7 +1488,9 @@ const ( SIOCDEVPRIVATE = 0x89f0 SIOCDIFADDR = 0x8936 SIOCDRARP = 0x8960 + SIOCETHTOOL = 0x8946 SIOCGARP = 0x8954 + SIOCGHWTSTAMP = 0x89b1 SIOCGIFADDR = 0x8915 SIOCGIFBR = 0x8940 SIOCGIFBRDADDR = 0x8919 @@ -1498,13 +1510,21 @@ const ( SIOCGIFPFLAGS = 0x8935 SIOCGIFSLAVE = 0x8929 SIOCGIFTXQLEN = 0x8942 + SIOCGIFVLAN = 0x8982 + SIOCGMIIPHY = 0x8947 + SIOCGMIIREG = 0x8948 SIOCGPGRP = 0x8904 SIOCGRARP = 0x8961 + SIOCGSKNS = 0x894c SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 + SIOCINQ = 0x4004667f + SIOCOUTQ = 0x40047473 + SIOCOUTQNSD = 0x894b SIOCPROTOPRIVATE = 0x89e0 SIOCRTMSG = 0x890d SIOCSARP = 0x8955 + SIOCSHWTSTAMP = 0x89b0 SIOCSIFADDR = 0x8916 SIOCSIFBR = 0x8941 SIOCSIFBRDADDR = 0x891a @@ -1523,11 +1543,15 @@ const ( SIOCSIFPFLAGS = 0x8934 SIOCSIFSLAVE = 0x8930 SIOCSIFTXQLEN = 0x8943 + SIOCSIFVLAN = 0x8983 + SIOCSMIIREG = 0x8949 SIOCSPGRP = 0x8902 SIOCSRARP = 0x8962 + SIOCWANDEV = 0x894a SOCK_CLOEXEC = 0x80000 SOCK_DCCP = 0x6 SOCK_DGRAM = 0x2 + SOCK_IOC_TYPE = 0x89 SOCK_NONBLOCK = 0x800 SOCK_PACKET = 0xa SOCK_RAW = 0x3 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index 00c9942d3..16ed19311 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -1471,6 +1471,16 @@ const ( SIOCADDMULTI = 0x8931 SIOCADDRT = 0x890b SIOCATMARK = 0x8905 + SIOCBONDCHANGEACTIVE = 0x8995 + SIOCBONDENSLAVE = 0x8990 + SIOCBONDINFOQUERY = 0x8994 + SIOCBONDRELEASE = 0x8991 + SIOCBONDSETHWADDR = 0x8992 + SIOCBONDSLAVEINFOQUERY = 0x8993 + SIOCBRADDBR = 0x89a0 + SIOCBRADDIF = 0x89a2 + SIOCBRDELBR = 0x89a1 + SIOCBRDELIF = 0x89a3 SIOCDARP = 0x8953 SIOCDELDLCI = 0x8981 SIOCDELMULTI = 0x8932 @@ -1478,7 +1488,9 @@ const ( SIOCDEVPRIVATE = 0x89f0 SIOCDIFADDR = 0x8936 SIOCDRARP = 0x8960 + SIOCETHTOOL = 0x8946 SIOCGARP = 0x8954 + SIOCGHWTSTAMP = 0x89b1 SIOCGIFADDR = 0x8915 SIOCGIFBR = 0x8940 SIOCGIFBRDADDR = 0x8919 @@ -1498,13 +1510,21 @@ const ( SIOCGIFPFLAGS = 0x8935 SIOCGIFSLAVE = 0x8929 SIOCGIFTXQLEN = 0x8942 + SIOCGIFVLAN = 0x8982 + SIOCGMIIPHY = 0x8947 + SIOCGMIIREG = 0x8948 SIOCGPGRP = 0x8904 SIOCGRARP = 0x8961 + SIOCGSKNS = 0x894c SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 + SIOCINQ = 0x4004667f + SIOCOUTQ = 0x40047473 + SIOCOUTQNSD = 0x894b SIOCPROTOPRIVATE = 0x89e0 SIOCRTMSG = 0x890d SIOCSARP = 0x8955 + SIOCSHWTSTAMP = 0x89b0 SIOCSIFADDR = 0x8916 SIOCSIFBR = 0x8941 SIOCSIFBRDADDR = 0x891a @@ -1523,11 +1543,15 @@ const ( SIOCSIFPFLAGS = 0x8934 SIOCSIFSLAVE = 0x8930 SIOCSIFTXQLEN = 0x8943 + SIOCSIFVLAN = 0x8983 + SIOCSMIIREG = 0x8949 SIOCSPGRP = 0x8902 SIOCSRARP = 0x8962 + SIOCWANDEV = 0x894a SOCK_CLOEXEC = 0x80000 SOCK_DCCP = 0x6 SOCK_DGRAM = 0x2 + SOCK_IOC_TYPE = 0x89 SOCK_NONBLOCK = 0x800 SOCK_PACKET = 0xa SOCK_RAW = 0x3 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 89674f3aa..bd385f809 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -1475,6 +1475,16 @@ const ( SIOCADDMULTI = 0x8931 SIOCADDRT = 0x890b SIOCATMARK = 0x8905 + SIOCBONDCHANGEACTIVE = 0x8995 + SIOCBONDENSLAVE = 0x8990 + SIOCBONDINFOQUERY = 0x8994 + SIOCBONDRELEASE = 0x8991 + SIOCBONDSETHWADDR = 0x8992 + SIOCBONDSLAVEINFOQUERY = 0x8993 + SIOCBRADDBR = 0x89a0 + SIOCBRADDIF = 0x89a2 + SIOCBRDELBR = 0x89a1 + SIOCBRDELIF = 0x89a3 SIOCDARP = 0x8953 SIOCDELDLCI = 0x8981 SIOCDELMULTI = 0x8932 @@ -1482,7 +1492,9 @@ const ( SIOCDEVPRIVATE = 0x89f0 SIOCDIFADDR = 0x8936 SIOCDRARP = 0x8960 + SIOCETHTOOL = 0x8946 SIOCGARP = 0x8954 + SIOCGHWTSTAMP = 0x89b1 SIOCGIFADDR = 0x8915 SIOCGIFBR = 0x8940 SIOCGIFBRDADDR = 0x8919 @@ -1502,13 +1514,21 @@ const ( SIOCGIFPFLAGS = 0x8935 SIOCGIFSLAVE = 0x8929 SIOCGIFTXQLEN = 0x8942 + SIOCGIFVLAN = 0x8982 + SIOCGMIIPHY = 0x8947 + SIOCGMIIREG = 0x8948 SIOCGPGRP = 0x8904 SIOCGRARP = 0x8961 + SIOCGSKNS = 0x894c SIOCGSTAMP = 0x8906 SIOCGSTAMPNS = 0x8907 + SIOCINQ = 0x541b + SIOCOUTQ = 0x5411 + SIOCOUTQNSD = 0x894b SIOCPROTOPRIVATE = 0x89e0 SIOCRTMSG = 0x890d SIOCSARP = 0x8955 + SIOCSHWTSTAMP = 0x89b0 SIOCSIFADDR = 0x8916 SIOCSIFBR = 0x8941 SIOCSIFBRDADDR = 0x891a @@ -1527,11 +1547,15 @@ const ( SIOCSIFPFLAGS = 0x8934 SIOCSIFSLAVE = 0x8930 SIOCSIFTXQLEN = 0x8943 + SIOCSIFVLAN = 0x8983 + SIOCSMIIREG = 0x8949 SIOCSPGRP = 0x8902 SIOCSRARP = 0x8962 + SIOCWANDEV = 0x894a SOCK_CLOEXEC = 0x80000 SOCK_DCCP = 0x6 SOCK_DGRAM = 0x2 + SOCK_IOC_TYPE = 0x89 SOCK_NONBLOCK = 0x800 SOCK_PACKET = 0xa SOCK_RAW = 0x3 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go index ac85ca645..206c75f09 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go @@ -1006,6 +1006,9 @@ const ( MSG_TRUNC = 0x10 MSG_USERFLAGS = 0xffffff MSG_WAITALL = 0x40 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x2 + MS_SYNC = 0x4 NAME_MAX = 0x1ff NET_RT_DUMP = 0x1 NET_RT_FLAGS = 0x2 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go new file mode 100644 index 000000000..3ed0b2602 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go @@ -0,0 +1,1586 @@ +// mkerrors.sh +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- _const.go + +// +build arm,openbsd + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_BLUETOOTH = 0x20 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_ENCAP = 0x1c + AF_HYLINK = 0xf + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x18 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_KEY = 0x1e + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x24 + AF_MPLS = 0x21 + AF_NATM = 0x1b + AF_NS = 0x6 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x11 + AF_SIP = 0x1d + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + ARPHRD_ETHER = 0x1 + ARPHRD_FRELAY = 0xf + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B9600 = 0x2580 + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDIRFILT = 0x4004427c + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc008427b + BIOCGETIF = 0x4020426b + BIOCGFILDROP = 0x40044278 + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044273 + BIOCGRTIMEOUT = 0x400c426e + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCLOCK = 0x20004276 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDIRFILT = 0x8004427d + BIOCSDLT = 0x8004427a + BIOCSETF = 0x80084267 + BIOCSETIF = 0x8020426c + BIOCSETWF = 0x80084277 + BIOCSFILDROP = 0x80044279 + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044272 + BIOCSRTIMEOUT = 0x800c426d + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIRECTION_IN = 0x1 + BPF_DIRECTION_OUT = 0x2 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x200000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0xff + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + DIOCOSFPFLUSH = 0x2000444e + DLT_ARCNET = 0x7 + DLT_ATM_RFC1483 = 0xb + DLT_AX25 = 0x3 + DLT_CHAOS = 0x5 + DLT_C_HDLC = 0x68 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0xd + DLT_FDDI = 0xa + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_LOOP = 0xc + DLT_MPLS = 0xdb + DLT_NULL = 0x0 + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_SERIAL = 0x32 + DLT_PRONET = 0x4 + DLT_RAW = 0xe + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EMT_TAGOVF = 0x1 + EMUL_ENABLED = 0x1 + EMUL_NATIVE = 0x2 + ENDRUNDISC = 0x9 + ETHERMIN = 0x2e + ETHERMTU = 0x5dc + ETHERTYPE_8023 = 0x4 + ETHERTYPE_AARP = 0x80f3 + ETHERTYPE_ACCTON = 0x8390 + ETHERTYPE_AEONIC = 0x8036 + ETHERTYPE_ALPHA = 0x814a + ETHERTYPE_AMBER = 0x6008 + ETHERTYPE_AMOEBA = 0x8145 + ETHERTYPE_AOE = 0x88a2 + ETHERTYPE_APOLLO = 0x80f7 + ETHERTYPE_APOLLODOMAIN = 0x8019 + ETHERTYPE_APPLETALK = 0x809b + ETHERTYPE_APPLITEK = 0x80c7 + ETHERTYPE_ARGONAUT = 0x803a + ETHERTYPE_ARP = 0x806 + ETHERTYPE_AT = 0x809b + ETHERTYPE_ATALK = 0x809b + ETHERTYPE_ATOMIC = 0x86df + ETHERTYPE_ATT = 0x8069 + ETHERTYPE_ATTSTANFORD = 0x8008 + ETHERTYPE_AUTOPHON = 0x806a + ETHERTYPE_AXIS = 0x8856 + ETHERTYPE_BCLOOP = 0x9003 + ETHERTYPE_BOFL = 0x8102 + ETHERTYPE_CABLETRON = 0x7034 + ETHERTYPE_CHAOS = 0x804 + ETHERTYPE_COMDESIGN = 0x806c + ETHERTYPE_COMPUGRAPHIC = 0x806d + ETHERTYPE_COUNTERPOINT = 0x8062 + ETHERTYPE_CRONUS = 0x8004 + ETHERTYPE_CRONUSVLN = 0x8003 + ETHERTYPE_DCA = 0x1234 + ETHERTYPE_DDE = 0x807b + ETHERTYPE_DEBNI = 0xaaaa + ETHERTYPE_DECAM = 0x8048 + ETHERTYPE_DECCUST = 0x6006 + ETHERTYPE_DECDIAG = 0x6005 + ETHERTYPE_DECDNS = 0x803c + ETHERTYPE_DECDTS = 0x803e + ETHERTYPE_DECEXPER = 0x6000 + ETHERTYPE_DECLAST = 0x8041 + ETHERTYPE_DECLTM = 0x803f + ETHERTYPE_DECMUMPS = 0x6009 + ETHERTYPE_DECNETBIOS = 0x8040 + ETHERTYPE_DELTACON = 0x86de + ETHERTYPE_DIDDLE = 0x4321 + ETHERTYPE_DLOG1 = 0x660 + ETHERTYPE_DLOG2 = 0x661 + ETHERTYPE_DN = 0x6003 + ETHERTYPE_DOGFIGHT = 0x1989 + ETHERTYPE_DSMD = 0x8039 + ETHERTYPE_ECMA = 0x803 + ETHERTYPE_ENCRYPT = 0x803d + ETHERTYPE_ES = 0x805d + ETHERTYPE_EXCELAN = 0x8010 + ETHERTYPE_EXPERDATA = 0x8049 + ETHERTYPE_FLIP = 0x8146 + ETHERTYPE_FLOWCONTROL = 0x8808 + ETHERTYPE_FRARP = 0x808 + ETHERTYPE_GENDYN = 0x8068 + ETHERTYPE_HAYES = 0x8130 + ETHERTYPE_HIPPI_FP = 0x8180 + ETHERTYPE_HITACHI = 0x8820 + ETHERTYPE_HP = 0x8005 + ETHERTYPE_IEEEPUP = 0xa00 + ETHERTYPE_IEEEPUPAT = 0xa01 + ETHERTYPE_IMLBL = 0x4c42 + ETHERTYPE_IMLBLDIAG = 0x424c + ETHERTYPE_IP = 0x800 + ETHERTYPE_IPAS = 0x876c + ETHERTYPE_IPV6 = 0x86dd + ETHERTYPE_IPX = 0x8137 + ETHERTYPE_IPXNEW = 0x8037 + ETHERTYPE_KALPANA = 0x8582 + ETHERTYPE_LANBRIDGE = 0x8038 + ETHERTYPE_LANPROBE = 0x8888 + ETHERTYPE_LAT = 0x6004 + ETHERTYPE_LBACK = 0x9000 + ETHERTYPE_LITTLE = 0x8060 + ETHERTYPE_LLDP = 0x88cc + ETHERTYPE_LOGICRAFT = 0x8148 + ETHERTYPE_LOOPBACK = 0x9000 + ETHERTYPE_MATRA = 0x807a + ETHERTYPE_MAX = 0xffff + ETHERTYPE_MERIT = 0x807c + ETHERTYPE_MICP = 0x873a + ETHERTYPE_MOPDL = 0x6001 + ETHERTYPE_MOPRC = 0x6002 + ETHERTYPE_MOTOROLA = 0x818d + ETHERTYPE_MPLS = 0x8847 + ETHERTYPE_MPLS_MCAST = 0x8848 + ETHERTYPE_MUMPS = 0x813f + ETHERTYPE_NBPCC = 0x3c04 + ETHERTYPE_NBPCLAIM = 0x3c09 + ETHERTYPE_NBPCLREQ = 0x3c05 + ETHERTYPE_NBPCLRSP = 0x3c06 + ETHERTYPE_NBPCREQ = 0x3c02 + ETHERTYPE_NBPCRSP = 0x3c03 + ETHERTYPE_NBPDG = 0x3c07 + ETHERTYPE_NBPDGB = 0x3c08 + ETHERTYPE_NBPDLTE = 0x3c0a + ETHERTYPE_NBPRAR = 0x3c0c + ETHERTYPE_NBPRAS = 0x3c0b + ETHERTYPE_NBPRST = 0x3c0d + ETHERTYPE_NBPSCD = 0x3c01 + ETHERTYPE_NBPVCD = 0x3c00 + ETHERTYPE_NBS = 0x802 + ETHERTYPE_NCD = 0x8149 + ETHERTYPE_NESTAR = 0x8006 + ETHERTYPE_NETBEUI = 0x8191 + ETHERTYPE_NOVELL = 0x8138 + ETHERTYPE_NS = 0x600 + ETHERTYPE_NSAT = 0x601 + ETHERTYPE_NSCOMPAT = 0x807 + ETHERTYPE_NTRAILER = 0x10 + ETHERTYPE_OS9 = 0x7007 + ETHERTYPE_OS9NET = 0x7009 + ETHERTYPE_PACER = 0x80c6 + ETHERTYPE_PAE = 0x888e + ETHERTYPE_PCS = 0x4242 + ETHERTYPE_PLANNING = 0x8044 + ETHERTYPE_PPP = 0x880b + ETHERTYPE_PPPOE = 0x8864 + ETHERTYPE_PPPOEDISC = 0x8863 + ETHERTYPE_PRIMENTS = 0x7031 + ETHERTYPE_PUP = 0x200 + ETHERTYPE_PUPAT = 0x200 + ETHERTYPE_QINQ = 0x88a8 + ETHERTYPE_RACAL = 0x7030 + ETHERTYPE_RATIONAL = 0x8150 + ETHERTYPE_RAWFR = 0x6559 + ETHERTYPE_RCL = 0x1995 + ETHERTYPE_RDP = 0x8739 + ETHERTYPE_RETIX = 0x80f2 + ETHERTYPE_REVARP = 0x8035 + ETHERTYPE_SCA = 0x6007 + ETHERTYPE_SECTRA = 0x86db + ETHERTYPE_SECUREDATA = 0x876d + ETHERTYPE_SGITW = 0x817e + ETHERTYPE_SG_BOUNCE = 0x8016 + ETHERTYPE_SG_DIAG = 0x8013 + ETHERTYPE_SG_NETGAMES = 0x8014 + ETHERTYPE_SG_RESV = 0x8015 + ETHERTYPE_SIMNET = 0x5208 + ETHERTYPE_SLOW = 0x8809 + ETHERTYPE_SNA = 0x80d5 + ETHERTYPE_SNMP = 0x814c + ETHERTYPE_SONIX = 0xfaf5 + ETHERTYPE_SPIDER = 0x809f + ETHERTYPE_SPRITE = 0x500 + ETHERTYPE_STP = 0x8181 + ETHERTYPE_TALARIS = 0x812b + ETHERTYPE_TALARISMC = 0x852b + ETHERTYPE_TCPCOMP = 0x876b + ETHERTYPE_TCPSM = 0x9002 + ETHERTYPE_TEC = 0x814f + ETHERTYPE_TIGAN = 0x802f + ETHERTYPE_TRAIL = 0x1000 + ETHERTYPE_TRANSETHER = 0x6558 + ETHERTYPE_TYMSHARE = 0x802e + ETHERTYPE_UBBST = 0x7005 + ETHERTYPE_UBDEBUG = 0x900 + ETHERTYPE_UBDIAGLOOP = 0x7002 + ETHERTYPE_UBDL = 0x7000 + ETHERTYPE_UBNIU = 0x7001 + ETHERTYPE_UBNMC = 0x7003 + ETHERTYPE_VALID = 0x1600 + ETHERTYPE_VARIAN = 0x80dd + ETHERTYPE_VAXELN = 0x803b + ETHERTYPE_VEECO = 0x8067 + ETHERTYPE_VEXP = 0x805b + ETHERTYPE_VGLAB = 0x8131 + ETHERTYPE_VINES = 0xbad + ETHERTYPE_VINESECHO = 0xbaf + ETHERTYPE_VINESLOOP = 0xbae + ETHERTYPE_VITAL = 0xff00 + ETHERTYPE_VLAN = 0x8100 + ETHERTYPE_VLTLMAN = 0x8080 + ETHERTYPE_VPROD = 0x805c + ETHERTYPE_VURESERVED = 0x8147 + ETHERTYPE_WATERLOO = 0x8130 + ETHERTYPE_WELLFLEET = 0x8103 + ETHERTYPE_X25 = 0x805 + ETHERTYPE_X75 = 0x801 + ETHERTYPE_XNSSM = 0x9001 + ETHERTYPE_XTP = 0x817d + ETHER_ADDR_LEN = 0x6 + ETHER_ALIGN = 0x2 + ETHER_CRC_LEN = 0x4 + ETHER_CRC_POLY_BE = 0x4c11db6 + ETHER_CRC_POLY_LE = 0xedb88320 + ETHER_HDR_LEN = 0xe + ETHER_MAX_DIX_LEN = 0x600 + ETHER_MAX_LEN = 0x5ee + ETHER_MIN_LEN = 0x40 + ETHER_TYPE_LEN = 0x2 + ETHER_VLAN_ENCAP_LEN = 0x4 + EVFILT_AIO = -0x3 + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0x7 + EVFILT_TIMER = -0x7 + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0xa + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETOWN = 0x5 + F_RDLCK = 0x1 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFA_ROUTE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x8e52 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + IFT_1822 = 0x2 + IFT_A12MPPSWITCH = 0x82 + IFT_AAL2 = 0xbb + IFT_AAL5 = 0x31 + IFT_ADSL = 0x5e + IFT_AFLANE8023 = 0x3b + IFT_AFLANE8025 = 0x3c + IFT_ARAP = 0x58 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ASYNC = 0x54 + IFT_ATM = 0x25 + IFT_ATMDXI = 0x69 + IFT_ATMFUNI = 0x6a + IFT_ATMIMA = 0x6b + IFT_ATMLOGICAL = 0x50 + IFT_ATMRADIO = 0xbd + IFT_ATMSUBINTERFACE = 0x86 + IFT_ATMVCIENDPT = 0xc2 + IFT_ATMVIRTUAL = 0x95 + IFT_BGPPOLICYACCOUNTING = 0xa2 + IFT_BLUETOOTH = 0xf8 + IFT_BRIDGE = 0xd1 + IFT_BSC = 0x53 + IFT_CARP = 0xf7 + IFT_CCTEMUL = 0x3d + IFT_CEPT = 0x13 + IFT_CES = 0x85 + IFT_CHANNEL = 0x46 + IFT_CNR = 0x55 + IFT_COFFEE = 0x84 + IFT_COMPOSITELINK = 0x9b + IFT_DCN = 0x8d + IFT_DIGITALPOWERLINE = 0x8a + IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba + IFT_DLSW = 0x4a + IFT_DOCSCABLEDOWNSTREAM = 0x80 + IFT_DOCSCABLEMACLAYER = 0x7f + IFT_DOCSCABLEUPSTREAM = 0x81 + IFT_DOCSCABLEUPSTREAMCHANNEL = 0xcd + IFT_DS0 = 0x51 + IFT_DS0BUNDLE = 0x52 + IFT_DS1FDL = 0xaa + IFT_DS3 = 0x1e + IFT_DTM = 0x8c + IFT_DUMMY = 0xf1 + IFT_DVBASILN = 0xac + IFT_DVBASIOUT = 0xad + IFT_DVBRCCDOWNSTREAM = 0x93 + IFT_DVBRCCMACLAYER = 0x92 + IFT_DVBRCCUPSTREAM = 0x94 + IFT_ECONET = 0xce + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_EPLRS = 0x57 + IFT_ESCON = 0x49 + IFT_ETHER = 0x6 + IFT_FAITH = 0xf3 + IFT_FAST = 0x7d + IFT_FASTETHER = 0x3e + IFT_FASTETHERFX = 0x45 + IFT_FDDI = 0xf + IFT_FIBRECHANNEL = 0x38 + IFT_FRAMERELAYINTERCONNECT = 0x3a + IFT_FRAMERELAYMPI = 0x5c + IFT_FRDLCIENDPT = 0xc1 + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_FRF16MFRBUNDLE = 0xa3 + IFT_FRFORWARD = 0x9e + IFT_G703AT2MB = 0x43 + IFT_G703AT64K = 0x42 + IFT_GIF = 0xf0 + IFT_GIGABITETHERNET = 0x75 + IFT_GR303IDT = 0xb2 + IFT_GR303RDT = 0xb1 + IFT_H323GATEKEEPER = 0xa4 + IFT_H323PROXY = 0xa5 + IFT_HDH1822 = 0x3 + IFT_HDLC = 0x76 + IFT_HDSL2 = 0xa8 + IFT_HIPERLAN2 = 0xb7 + IFT_HIPPI = 0x2f + IFT_HIPPIINTERFACE = 0x39 + IFT_HOSTPAD = 0x5a + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IBM370PARCHAN = 0x48 + IFT_IDSL = 0x9a + IFT_IEEE1394 = 0x90 + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INFINIBAND = 0xc7 + IFT_INTERLEAVE = 0x7c + IFT_IP = 0x7e + IFT_IPFORWARD = 0x8e + IFT_IPOVERATM = 0x72 + IFT_IPOVERCDLC = 0x6d + IFT_IPOVERCLAW = 0x6e + IFT_IPSWITCH = 0x4e + IFT_ISDN = 0x3f + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISDNS = 0x4b + IFT_ISDNU = 0x4c + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88025CRFPINT = 0x62 + IFT_ISO88025DTR = 0x56 + IFT_ISO88025FIBER = 0x73 + IFT_ISO88026 = 0xa + IFT_ISUP = 0xb3 + IFT_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + IFT_L3IPXVLAN = 0x89 + IFT_LAPB = 0x10 + IFT_LAPD = 0x4d + IFT_LAPF = 0x77 + IFT_LINEGROUP = 0xd2 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MEDIAMAILOVERIP = 0x8b + IFT_MFSIGLINK = 0xa7 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_MPC = 0x71 + IFT_MPLS = 0xa6 + IFT_MPLSTUNNEL = 0x96 + IFT_MSDSL = 0x8f + IFT_MVL = 0xbf + IFT_MYRINET = 0x63 + IFT_NFAS = 0xaf + IFT_NSIP = 0x1b + IFT_OPTICALCHANNEL = 0xc3 + IFT_OPTICALTRANSPORT = 0xc4 + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PFLOG = 0xf5 + IFT_PFLOW = 0xf9 + IFT_PFSYNC = 0xf6 + IFT_PLC = 0xae + IFT_PON155 = 0xcf + IFT_PON622 = 0xd0 + IFT_POS = 0xab + IFT_PPP = 0x17 + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPATM = 0xc5 + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PROPWIRELESSP2P = 0x9d + IFT_PTPSERIAL = 0x16 + IFT_PVC = 0xf2 + IFT_Q2931 = 0xc9 + IFT_QLLC = 0x44 + IFT_RADIOMAC = 0xbc + IFT_RADSL = 0x5f + IFT_REACHDSL = 0xc0 + IFT_RFC1483 = 0x9f + IFT_RS232 = 0x21 + IFT_RSRB = 0x4f + IFT_SDLC = 0x11 + IFT_SDSL = 0x60 + IFT_SHDSL = 0xa9 + IFT_SIP = 0x1f + IFT_SIPSIG = 0xcc + IFT_SIPTG = 0xcb + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETOVERHEADCHANNEL = 0xb9 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_SRP = 0x97 + IFT_SS7SIGLINK = 0x9c + IFT_STACKTOSTACK = 0x6f + IFT_STARLAN = 0xb + IFT_T1 = 0x12 + IFT_TDLC = 0x74 + IFT_TELINK = 0xc8 + IFT_TERMPAD = 0x5b + IFT_TR008 = 0xb0 + IFT_TRANSPHDLC = 0x7b + IFT_TUNNEL = 0x83 + IFT_ULTRA = 0x1d + IFT_USB = 0xa0 + IFT_V11 = 0x40 + IFT_V35 = 0x2d + IFT_V36 = 0x41 + IFT_V37 = 0x78 + IFT_VDSL = 0x61 + IFT_VIRTUALIPADDRESS = 0x70 + IFT_VIRTUALTG = 0xca + IFT_VOICEDID = 0xd5 + IFT_VOICEEM = 0x64 + IFT_VOICEEMFGD = 0xd3 + IFT_VOICEENCAP = 0x67 + IFT_VOICEFGDEANA = 0xd4 + IFT_VOICEFXO = 0x65 + IFT_VOICEFXS = 0x66 + IFT_VOICEOVERATM = 0x98 + IFT_VOICEOVERCABLE = 0xc6 + IFT_VOICEOVERFRAMERELAY = 0x99 + IFT_VOICEOVERIP = 0x68 + IFT_X213 = 0x5d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25HUNTGROUP = 0x7a + IFT_X25MLP = 0x79 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IN_RFC3021_HOST = 0x1 + IN_RFC3021_NET = 0xfffffffe + IN_RFC3021_NSHIFT = 0x1f + IPPROTO_AH = 0x33 + IPPROTO_CARP = 0x70 + IPPROTO_DIVERT = 0x102 + IPPROTO_DIVERT_INIT = 0x2 + IPPROTO_DIVERT_RESP = 0x1 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPIP = 0x4 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x103 + IPPROTO_MOBILE = 0x37 + IPPROTO_MPLS = 0x89 + IPPROTO_NONE = 0x3b + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPV6_AUTH_LEVEL = 0x35 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_ESP_NETWORK_LEVEL = 0x37 + IPV6_ESP_TRANS_LEVEL = 0x36 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x78 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPCOMP_LEVEL = 0x3c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXPACKET = 0xffff + IPV6_MMTU = 0x500 + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_OPTIONS = 0x1 + IPV6_PATHMTU = 0x2c + IPV6_PIPEX = 0x3f + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVDSTPORT = 0x40 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RTABLE = 0x1021 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_AUTH_LEVEL = 0x14 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DIVERTFL = 0x1022 + IP_DROP_MEMBERSHIP = 0xd + IP_ESP_NETWORK_LEVEL = 0x16 + IP_ESP_TRANS_LEVEL = 0x15 + IP_HDRINCL = 0x2 + IP_IPCOMP_LEVEL = 0x1d + IP_IPSECFLOWINFO = 0x24 + IP_IPSEC_LOCAL_AUTH = 0x1b + IP_IPSEC_LOCAL_CRED = 0x19 + IP_IPSEC_LOCAL_ID = 0x17 + IP_IPSEC_REMOTE_AUTH = 0x1c + IP_IPSEC_REMOTE_CRED = 0x1a + IP_IPSEC_REMOTE_ID = 0x18 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0xfff + IP_MF = 0x2000 + IP_MINTTL = 0x20 + IP_MIN_MEMBERSHIPS = 0xf + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x1 + IP_PIPEX = 0x22 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVDSTPORT = 0x21 + IP_RECVIF = 0x1e + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVRTABLE = 0x23 + IP_RECVTTL = 0x1f + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RTABLE = 0x1021 + IP_TOS = 0x3 + IP_TTL = 0x4 + ISIG = 0x80 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LCNT_OVERLOAD_FLUSH = 0x6 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x6 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_SPACEAVAIL = 0x5 + MADV_WILLNEED = 0x3 + MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 + MAP_COPY = 0x2 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_FLAGMASK = 0x3ff7 + MAP_HASSEMAPHORE = 0x0 + MAP_INHERIT = 0x0 + MAP_INHERIT_COPY = 0x1 + MAP_INHERIT_NONE = 0x2 + MAP_INHERIT_SHARE = 0x0 + MAP_INHERIT_ZERO = 0x3 + MAP_NOEXTEND = 0x0 + MAP_NORESERVE = 0x0 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x0 + MAP_SHARED = 0x1 + MAP_TRYFIXED = 0x0 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_BCAST = 0x100 + MSG_CMSG_CLOEXEC = 0x800 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOR = 0x8 + MSG_MCAST = 0x200 + MSG_NOSIGNAL = 0x400 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x4 + MS_SYNC = 0x2 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_MAXID = 0x6 + NET_RT_STATS = 0x4 + NET_RT_TABLE = 0x5 + NOFLSH = 0x80000000 + NOTE_ATTRIB = 0x8 + NOTE_CHILD = 0x4 + NOTE_DELETE = 0x1 + NOTE_EOF = 0x2 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRUNCATE = 0x80 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + ONLCR = 0x2 + ONLRET = 0x80 + ONOCR = 0x40 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x10000 + O_CREAT = 0x200 + O_DIRECTORY = 0x20000 + O_DSYNC = 0x80 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x80 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PF_FLUSH = 0x1 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_LABEL = 0xa + RTAX_MAX = 0xb + RTAX_NETMASK = 0x2 + RTAX_SRC = 0x8 + RTAX_SRCMASK = 0x9 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_LABEL = 0x400 + RTA_NETMASK = 0x4 + RTA_SRC = 0x100 + RTA_SRCMASK = 0x200 + RTF_ANNOUNCE = 0x4000 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_CLONED = 0x10000 + RTF_CLONING = 0x100 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_FMASK = 0x70f808 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MASK = 0x80 + RTF_MODIFIED = 0x20 + RTF_MPATH = 0x40000 + RTF_MPLS = 0x100000 + RTF_PERMANENT_ARP = 0x2000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x2000 + RTF_REJECT = 0x8 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_USETRAILERS = 0x8000 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DESYNC = 0x10 + RTM_GET = 0x4 + RTM_IFANNOUNCE = 0xf + RTM_IFINFO = 0xe + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MAXSIZE = 0x800 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RT_TABLEID_MAX = 0xff + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x4 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCAIFGROUP = 0x80246987 + SIOCALIFADDR = 0x8218691c + SIOCATMARK = 0x40047307 + SIOCBRDGADD = 0x8054693c + SIOCBRDGADDS = 0x80546941 + SIOCBRDGARL = 0x806e694d + SIOCBRDGDADDR = 0x81286947 + SIOCBRDGDEL = 0x8054693d + SIOCBRDGDELS = 0x80546942 + SIOCBRDGFLUSH = 0x80546948 + SIOCBRDGFRL = 0x806e694e + SIOCBRDGGCACHE = 0xc0146941 + SIOCBRDGGFD = 0xc0146952 + SIOCBRDGGHT = 0xc0146951 + SIOCBRDGGIFFLGS = 0xc054693e + SIOCBRDGGMA = 0xc0146953 + SIOCBRDGGPARAM = 0xc03c6958 + SIOCBRDGGPRI = 0xc0146950 + SIOCBRDGGRL = 0xc028694f + SIOCBRDGGSIFS = 0xc054693c + SIOCBRDGGTO = 0xc0146946 + SIOCBRDGIFS = 0xc0546942 + SIOCBRDGRTS = 0xc0186943 + SIOCBRDGSADDR = 0xc1286944 + SIOCBRDGSCACHE = 0x80146940 + SIOCBRDGSFD = 0x80146952 + SIOCBRDGSHT = 0x80146951 + SIOCBRDGSIFCOST = 0x80546955 + SIOCBRDGSIFFLGS = 0x8054693f + SIOCBRDGSIFPRIO = 0x80546954 + SIOCBRDGSMA = 0x80146953 + SIOCBRDGSPRI = 0x80146950 + SIOCBRDGSPROTO = 0x8014695a + SIOCBRDGSTO = 0x80146945 + SIOCBRDGSTXHC = 0x80146959 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFGROUP = 0x80246989 + SIOCDIFPHYADDR = 0x80206949 + SIOCDLIFADDR = 0x8218691e + SIOCGETKALIVE = 0xc01869a4 + SIOCGETLABEL = 0x8020699a + SIOCGETPFLOW = 0xc02069fe + SIOCGETPFSYNC = 0xc02069f8 + SIOCGETSGCNT = 0xc0147534 + SIOCGETVIFCNT = 0xc0147533 + SIOCGETVLAN = 0xc0206990 + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0206921 + SIOCGIFASYNCMAP = 0xc020697c + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCONF = 0xc0086924 + SIOCGIFDATA = 0xc020691b + SIOCGIFDESCR = 0xc0206981 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGATTR = 0xc024698b + SIOCGIFGENERIC = 0xc020693a + SIOCGIFGMEMB = 0xc024698a + SIOCGIFGROUP = 0xc0246988 + SIOCGIFHARDMTU = 0xc02069a5 + SIOCGIFMEDIA = 0xc0286936 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc020697e + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206948 + SIOCGIFPRIORITY = 0xc020699c + SIOCGIFPSRCADDR = 0xc0206947 + SIOCGIFRDOMAIN = 0xc02069a0 + SIOCGIFRTLABEL = 0xc0206983 + SIOCGIFRXR = 0x802069aa + SIOCGIFTIMESLOT = 0xc0206986 + SIOCGIFXFLAGS = 0xc020699e + SIOCGLIFADDR = 0xc218691d + SIOCGLIFPHYADDR = 0xc218694b + SIOCGLIFPHYRTABLE = 0xc02069a2 + SIOCGLIFPHYTTL = 0xc02069a9 + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCGSPPPPARAMS = 0xc0206994 + SIOCGVH = 0xc02069f6 + SIOCGVNETID = 0xc02069a7 + SIOCIFCREATE = 0x8020697a + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc00c6978 + SIOCSETKALIVE = 0x801869a3 + SIOCSETLABEL = 0x80206999 + SIOCSETPFLOW = 0x802069fd + SIOCSETPFSYNC = 0x802069f7 + SIOCSETVLAN = 0x8020698f + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFASYNCMAP = 0x8020697d + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFDESCR = 0x80206980 + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGATTR = 0x8024698c + SIOCSIFGENERIC = 0x80206939 + SIOCSIFLLADDR = 0x8020691f + SIOCSIFMEDIA = 0xc0206935 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x8020697f + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x80406946 + SIOCSIFPRIORITY = 0x8020699b + SIOCSIFRDOMAIN = 0x8020699f + SIOCSIFRTLABEL = 0x80206982 + SIOCSIFTIMESLOT = 0x80206985 + SIOCSIFXFLAGS = 0x8020699d + SIOCSLIFPHYADDR = 0x8218694a + SIOCSLIFPHYRTABLE = 0x802069a1 + SIOCSLIFPHYTTL = 0x802069a8 + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SIOCSSPPPPARAMS = 0x80206993 + SIOCSVH = 0xc02069f5 + SIOCSVNETID = 0x802069a6 + SOCK_CLOEXEC = 0x8000 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x4000 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_BINDANY = 0x1000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_NETPROC = 0x1020 + SO_OOBINLINE = 0x100 + SO_PEERCRED = 0x1022 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_RTABLE = 0x1021 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_SPLICE = 0x1023 + SO_TIMESTAMP = 0x800 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_MAXBURST = 0x4 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x3 + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x4 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_NOPUSH = 0x10 + TCP_NSTATES = 0xb + TCP_SACK_ENABLE = 0x8 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLAG_CLOCAL = 0x2 + TIOCFLAG_CRTSCTS = 0x4 + TIOCFLAG_MDMBUF = 0x8 + TIOCFLAG_PPS = 0x10 + TIOCFLAG_SOFTCAR = 0x1 + TIOCFLUSH = 0x80047410 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGFLAGS = 0x4004745d + TIOCGPGRP = 0x40047477 + TIOCGSID = 0x40047463 + TIOCGTSTAMP = 0x400c745b + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGET = 0x4004746a + TIOCMODG = 0x4004746a + TIOCMODS = 0x8004746d + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSFLAGS = 0x8004745c + TIOCSIG = 0x8004745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x80047465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSTSTAMP = 0x8008745a + TIOCSWINSZ = 0x80087467 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WALTSIG = 0x4 + WCONTINUED = 0x8 + WCOREFLAG = 0x80 + WNOHANG = 0x1 + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADF = syscall.Errno(0x9) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x58) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x59) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EIPSEC = syscall.Errno(0x52) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x5b) + ELOOP = syscall.Errno(0x3e) + EMEDIUMTYPE = syscall.Errno(0x56) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x53) + ENOBUFS = syscall.Errno(0x37) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOMEDIUM = syscall.Errno(0x55) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x5a) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x5b) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x2d) + EOVERFLOW = syscall.Errno(0x57) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTHR = syscall.Signal(0x20) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "connection timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "IPsec processing failure", + 83: "attribute not found", + 84: "illegal byte sequence", + 85: "no medium found", + 86: "wrong medium type", + 87: "value too large to be stored in data type", + 88: "operation canceled", + 89: "identifier removed", + 90: "no message of desired type", + 91: "not supported", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "stopped (signal)", + 18: "stopped", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", + 32: "thread AST", +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go index e48f4a5c1..10491e9ed 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go @@ -1,5 +1,5 @@ // mksyscall.pl -l32 -tags darwin,386 syscall_bsd.go syscall_darwin.go syscall_darwin_386.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build darwin,386 @@ -266,6 +266,106 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) if e1 != 0 { @@ -298,6 +398,16 @@ func kill(pid int, signum int, posix int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -456,6 +566,21 @@ func Exit(code int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchdir(fd int) (err error) { _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) if e1 != 0 { @@ -486,6 +611,21 @@ func Fchmod(fd int, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { @@ -496,6 +636,21 @@ func Fchown(fd int, uid int, gid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Flock(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) if e1 != 0 { @@ -745,6 +900,26 @@ func Link(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Listen(s int, backlog int) (err error) { _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) if e1 != 0 { @@ -785,13 +960,13 @@ func Mkdir(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mkfifo(path string, mode uint32) (err error) { +func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) if e1 != 0 { err = errnoErr(e1) } @@ -800,39 +975,13 @@ func Mkfifo(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mknod(path string, mode uint32, dev int) (err error) { +func Mkfifo(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlockall(flags int) (err error) { - _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } @@ -841,14 +990,13 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mprotect(b []byte, prot int) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) if e1 != 0 { err = errnoErr(e1) } @@ -857,24 +1005,14 @@ func Mprotect(b []byte, prot int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Munlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + fd = int(r0) if e1 != 0 { err = errnoErr(e1) } @@ -883,13 +1021,13 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Open(path string, mode int, perm uint32) (fd int, err error) { +func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0) fd = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -988,6 +1126,28 @@ func Readlink(path string, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Rename(from string, to string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(from) @@ -1008,6 +1168,26 @@ func Rename(from string, to string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Renameat(fromfd int, from string, tofd int, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Revoke(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1245,6 +1425,26 @@ func Symlink(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sync() (err error) { _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) if e1 != 0 { @@ -1308,6 +1508,21 @@ func Unlink(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Unmount(path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 672ada0e4..5f1f6bfef 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -1,5 +1,5 @@ // mksyscall.pl -tags darwin,amd64 syscall_bsd.go syscall_darwin.go syscall_darwin_amd64.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build darwin,amd64 @@ -266,6 +266,106 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) if e1 != 0 { @@ -298,6 +398,16 @@ func kill(pid int, signum int, posix int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -456,6 +566,21 @@ func Exit(code int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchdir(fd int) (err error) { _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) if e1 != 0 { @@ -486,6 +611,21 @@ func Fchmod(fd int, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { @@ -496,6 +636,21 @@ func Fchown(fd int, uid int, gid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Flock(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) if e1 != 0 { @@ -745,6 +900,26 @@ func Link(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Listen(s int, backlog int) (err error) { _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) if e1 != 0 { @@ -785,13 +960,13 @@ func Mkdir(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mkfifo(path string, mode uint32) (err error) { +func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) if e1 != 0 { err = errnoErr(e1) } @@ -800,39 +975,13 @@ func Mkfifo(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mknod(path string, mode uint32, dev int) (err error) { +func Mkfifo(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlockall(flags int) (err error) { - _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } @@ -841,14 +990,13 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mprotect(b []byte, prot int) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) if e1 != 0 { err = errnoErr(e1) } @@ -857,24 +1005,14 @@ func Mprotect(b []byte, prot int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Munlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + fd = int(r0) if e1 != 0 { err = errnoErr(e1) } @@ -883,13 +1021,13 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Open(path string, mode int, perm uint32) (fd int, err error) { +func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0) fd = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -988,6 +1126,28 @@ func Readlink(path string, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Rename(from string, to string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(from) @@ -1008,6 +1168,26 @@ func Rename(from string, to string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Renameat(fromfd int, from string, tofd int, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Revoke(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1245,6 +1425,26 @@ func Symlink(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sync() (err error) { _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) if e1 != 0 { @@ -1308,6 +1508,21 @@ func Unlink(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Unmount(path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1383,21 +1598,6 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) { r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) sec = int64(r0) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go index d516409db..7a4097459 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go @@ -1,5 +1,5 @@ -// mksyscall.pl -l32 -tags darwin,arm syscall_bsd.go syscall_darwin.go syscall_darwin_arm.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// mksyscall.pl -tags darwin,arm syscall_bsd.go syscall_darwin.go syscall_darwin_arm.go +// Code generated by the command above; see README.md. DO NOT EDIT. // +build darwin,arm @@ -221,7 +221,7 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) } else { _p0 = unsafe.Pointer(&_zero) } - _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + _, _, e1 := Syscall6(SYS_SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) if e1 != 0 { err = errnoErr(e1) } @@ -266,6 +266,106 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) if e1 != 0 { @@ -298,6 +398,16 @@ func kill(pid int, signum int, posix int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -456,6 +566,21 @@ func Exit(code int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchdir(fd int) (err error) { _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) if e1 != 0 { @@ -486,6 +611,21 @@ func Fchmod(fd int, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { @@ -496,6 +636,21 @@ func Fchown(fd int, uid int, gid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Flock(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) if e1 != 0 { @@ -745,6 +900,26 @@ func Link(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Listen(s int, backlog int) (err error) { _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) if e1 != 0 { @@ -785,13 +960,13 @@ func Mkdir(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mkfifo(path string, mode uint32) (err error) { +func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) if e1 != 0 { err = errnoErr(e1) } @@ -800,39 +975,13 @@ func Mkfifo(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mknod(path string, mode uint32, dev int) (err error) { +func Mkfifo(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlockall(flags int) (err error) { - _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } @@ -841,14 +990,13 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mprotect(b []byte, prot int) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) if e1 != 0 { err = errnoErr(e1) } @@ -857,24 +1005,14 @@ func Mprotect(b []byte, prot int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Munlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + fd = int(r0) if e1 != 0 { err = errnoErr(e1) } @@ -883,13 +1021,13 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Open(path string, mode int, perm uint32) (fd int, err error) { +func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0) fd = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -988,6 +1126,28 @@ func Readlink(path string, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Rename(from string, to string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(from) @@ -1008,6 +1168,26 @@ func Rename(from string, to string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Renameat(fromfd int, from string, tofd int, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Revoke(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1245,6 +1425,26 @@ func Symlink(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sync() (err error) { _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) if e1 != 0 { @@ -1308,6 +1508,21 @@ func Unlink(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Unmount(path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index e97759c35..07c6ebc9f 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -1,5 +1,5 @@ // mksyscall.pl -tags darwin,arm64 syscall_bsd.go syscall_darwin.go syscall_darwin_arm64.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build darwin,arm64 @@ -266,6 +266,106 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) if e1 != 0 { @@ -298,6 +398,16 @@ func kill(pid int, signum int, posix int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -456,6 +566,21 @@ func Exit(code int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchdir(fd int) (err error) { _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) if e1 != 0 { @@ -486,6 +611,21 @@ func Fchmod(fd int, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { @@ -496,6 +636,21 @@ func Fchown(fd int, uid int, gid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Flock(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) if e1 != 0 { @@ -745,6 +900,26 @@ func Link(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Listen(s int, backlog int) (err error) { _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) if e1 != 0 { @@ -785,13 +960,13 @@ func Mkdir(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mkfifo(path string, mode uint32) (err error) { +func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) if e1 != 0 { err = errnoErr(e1) } @@ -800,39 +975,13 @@ func Mkfifo(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mknod(path string, mode uint32, dev int) (err error) { +func Mkfifo(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlockall(flags int) (err error) { - _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } @@ -841,14 +990,13 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mprotect(b []byte, prot int) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) if e1 != 0 { err = errnoErr(e1) } @@ -857,24 +1005,14 @@ func Mprotect(b []byte, prot int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Munlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + fd = int(r0) if e1 != 0 { err = errnoErr(e1) } @@ -883,13 +1021,13 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Open(path string, mode int, perm uint32) (fd int, err error) { +func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0) fd = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -988,6 +1126,28 @@ func Readlink(path string, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Rename(from string, to string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(from) @@ -1008,6 +1168,26 @@ func Rename(from string, to string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Renameat(fromfd int, from string, tofd int, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Revoke(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1245,6 +1425,26 @@ func Symlink(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sync() (err error) { _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) if e1 != 0 { @@ -1308,6 +1508,21 @@ func Unlink(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Unmount(path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go index eafceb8e8..7fa205cd0 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go @@ -266,6 +266,106 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func pipe() (r int, w int, err error) { r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) r = int(r0) @@ -829,74 +929,6 @@ func Mknod(path string, mode uint32, dev int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlockall(flags int) (err error) { - _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mprotect(b []byte, prot int) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { @@ -1391,3 +1423,18 @@ func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go index f53801cee..1a0bb4cb0 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go @@ -1,5 +1,5 @@ // mksyscall.pl -l32 -tags freebsd,386 syscall_bsd.go syscall_freebsd.go syscall_freebsd_386.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build freebsd,386 @@ -266,6 +266,106 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func pipe() (r int, w int, err error) { r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) r = int(r0) @@ -278,6 +378,16 @@ func pipe() (r int, w int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -303,6 +413,36 @@ func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CapEnter() (err error) { + _, _, e1 := Syscall(SYS_CAP_ENTER, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func capRightsGet(version int, fd int, rightsp *CapRights) (err error) { + _, _, e1 := Syscall(SYS___CAP_RIGHTS_GET, uintptr(version), uintptr(fd), uintptr(unsafe.Pointer(rightsp))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func capRightsLimit(fd int, rightsp *CapRights) (err error) { + _, _, e1 := Syscall(SYS_CAP_RIGHTS_LIMIT, uintptr(fd), uintptr(unsafe.Pointer(rightsp)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Chdir(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -640,6 +780,21 @@ func Fadvise(fd int, offset int64, length int64, advice int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchdir(fd int) (err error) { _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) if e1 != 0 { @@ -670,6 +825,21 @@ func Fchmod(fd int, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { @@ -680,6 +850,21 @@ func Fchown(fd int, uid int, gid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Flock(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) if e1 != 0 { @@ -949,6 +1134,26 @@ func Link(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Listen(s int, backlog int) (err error) { _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) if e1 != 0 { @@ -989,13 +1194,13 @@ func Mkdir(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mkfifo(path string, mode uint32) (err error) { +func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) if e1 != 0 { err = errnoErr(e1) } @@ -1004,39 +1209,13 @@ func Mkfifo(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mknod(path string, mode uint32, dev int) (err error) { +func Mkfifo(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlockall(flags int) (err error) { - _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } @@ -1045,14 +1224,13 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mprotect(b []byte, prot int) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) if e1 != 0 { err = errnoErr(e1) } @@ -1061,14 +1239,8 @@ func Mprotect(b []byte, prot int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Munlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { err = errnoErr(e1) } @@ -1077,18 +1249,14 @@ func Munlock(b []byte) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) - if e1 != 0 { - err = errnoErr(e1) +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Nanosleep(time *Timespec, leftover *Timespec) (err error) { - _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + fd = int(r0) if e1 != 0 { err = errnoErr(e1) } @@ -1097,13 +1265,13 @@ func Nanosleep(time *Timespec, leftover *Timespec) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Open(path string, mode int, perm uint32) (fd int, err error) { +func Openat(fdat int, path string, mode int, perm uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(fdat), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0) fd = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -1202,6 +1370,28 @@ func Readlink(path string, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Rename(from string, to string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(from) @@ -1222,6 +1412,26 @@ func Rename(from string, to string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Renameat(fromfd int, from string, tofd int, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Revoke(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1469,6 +1679,26 @@ func Symlink(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sync() (err error) { _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) if e1 != 0 { @@ -1532,6 +1762,21 @@ func Unlink(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Unmount(path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1615,3 +1860,18 @@ func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go index 55b07412c..ac1e8e013 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go @@ -1,5 +1,5 @@ // mksyscall.pl -tags freebsd,amd64 syscall_bsd.go syscall_freebsd.go syscall_freebsd_amd64.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build freebsd,amd64 @@ -266,6 +266,106 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func pipe() (r int, w int, err error) { r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) r = int(r0) @@ -278,6 +378,16 @@ func pipe() (r int, w int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -303,6 +413,36 @@ func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CapEnter() (err error) { + _, _, e1 := Syscall(SYS_CAP_ENTER, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func capRightsGet(version int, fd int, rightsp *CapRights) (err error) { + _, _, e1 := Syscall(SYS___CAP_RIGHTS_GET, uintptr(version), uintptr(fd), uintptr(unsafe.Pointer(rightsp))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func capRightsLimit(fd int, rightsp *CapRights) (err error) { + _, _, e1 := Syscall(SYS_CAP_RIGHTS_LIMIT, uintptr(fd), uintptr(unsafe.Pointer(rightsp)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Chdir(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -640,6 +780,21 @@ func Fadvise(fd int, offset int64, length int64, advice int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchdir(fd int) (err error) { _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) if e1 != 0 { @@ -670,6 +825,21 @@ func Fchmod(fd int, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { @@ -680,6 +850,21 @@ func Fchown(fd int, uid int, gid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Flock(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) if e1 != 0 { @@ -949,6 +1134,26 @@ func Link(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Listen(s int, backlog int) (err error) { _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) if e1 != 0 { @@ -989,13 +1194,13 @@ func Mkdir(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mkfifo(path string, mode uint32) (err error) { +func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) if e1 != 0 { err = errnoErr(e1) } @@ -1004,39 +1209,13 @@ func Mkfifo(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mknod(path string, mode uint32, dev int) (err error) { +func Mkfifo(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlockall(flags int) (err error) { - _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } @@ -1045,14 +1224,13 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mprotect(b []byte, prot int) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) if e1 != 0 { err = errnoErr(e1) } @@ -1061,14 +1239,8 @@ func Mprotect(b []byte, prot int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Munlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { err = errnoErr(e1) } @@ -1077,18 +1249,14 @@ func Munlock(b []byte) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) - if e1 != 0 { - err = errnoErr(e1) +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Nanosleep(time *Timespec, leftover *Timespec) (err error) { - _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + fd = int(r0) if e1 != 0 { err = errnoErr(e1) } @@ -1097,13 +1265,13 @@ func Nanosleep(time *Timespec, leftover *Timespec) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Open(path string, mode int, perm uint32) (fd int, err error) { +func Openat(fdat int, path string, mode int, perm uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(fdat), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0) fd = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -1202,6 +1370,28 @@ func Readlink(path string, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Rename(from string, to string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(from) @@ -1222,6 +1412,26 @@ func Rename(from string, to string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Renameat(fromfd int, from string, tofd int, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Revoke(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1469,6 +1679,26 @@ func Symlink(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sync() (err error) { _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) if e1 != 0 { @@ -1532,6 +1762,21 @@ func Unlink(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Unmount(path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1615,3 +1860,18 @@ func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go index 0e9b42bf4..2b4e6acf0 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go @@ -1,5 +1,5 @@ // mksyscall.pl -l32 -arm -tags freebsd,arm syscall_bsd.go syscall_freebsd.go syscall_freebsd_arm.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build freebsd,arm @@ -266,6 +266,106 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func pipe() (r int, w int, err error) { r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) r = int(r0) @@ -278,6 +378,16 @@ func pipe() (r int, w int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -303,6 +413,36 @@ func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CapEnter() (err error) { + _, _, e1 := Syscall(SYS_CAP_ENTER, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func capRightsGet(version int, fd int, rightsp *CapRights) (err error) { + _, _, e1 := Syscall(SYS___CAP_RIGHTS_GET, uintptr(version), uintptr(fd), uintptr(unsafe.Pointer(rightsp))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func capRightsLimit(fd int, rightsp *CapRights) (err error) { + _, _, e1 := Syscall(SYS_CAP_RIGHTS_LIMIT, uintptr(fd), uintptr(unsafe.Pointer(rightsp)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Chdir(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -640,6 +780,21 @@ func Fadvise(fd int, offset int64, length int64, advice int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchdir(fd int) (err error) { _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) if e1 != 0 { @@ -670,6 +825,21 @@ func Fchmod(fd int, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { @@ -680,6 +850,21 @@ func Fchown(fd int, uid int, gid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Flock(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) if e1 != 0 { @@ -949,6 +1134,26 @@ func Link(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Listen(s int, backlog int) (err error) { _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) if e1 != 0 { @@ -989,13 +1194,13 @@ func Mkdir(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mkfifo(path string, mode uint32) (err error) { +func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) if e1 != 0 { err = errnoErr(e1) } @@ -1004,39 +1209,13 @@ func Mkfifo(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mknod(path string, mode uint32, dev int) (err error) { +func Mkfifo(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlockall(flags int) (err error) { - _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } @@ -1045,14 +1224,13 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mprotect(b []byte, prot int) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) if e1 != 0 { err = errnoErr(e1) } @@ -1061,14 +1239,8 @@ func Mprotect(b []byte, prot int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Munlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { err = errnoErr(e1) } @@ -1077,18 +1249,14 @@ func Munlock(b []byte) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) - if e1 != 0 { - err = errnoErr(e1) +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Nanosleep(time *Timespec, leftover *Timespec) (err error) { - _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + fd = int(r0) if e1 != 0 { err = errnoErr(e1) } @@ -1097,13 +1265,13 @@ func Nanosleep(time *Timespec, leftover *Timespec) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Open(path string, mode int, perm uint32) (fd int, err error) { +func Openat(fdat int, path string, mode int, perm uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(fdat), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0) fd = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -1202,6 +1370,28 @@ func Readlink(path string, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Rename(from string, to string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(from) @@ -1222,6 +1412,26 @@ func Rename(from string, to string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Renameat(fromfd int, from string, tofd int, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Revoke(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1469,6 +1679,26 @@ func Symlink(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sync() (err error) { _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) if e1 != 0 { @@ -1532,6 +1762,21 @@ func Unlink(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Unmount(path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1615,3 +1860,18 @@ func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go index 6c0845071..38c1bbdf9 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -1234,6 +1234,16 @@ func Sync() { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Syncfs(fd int) (err error) { + _, _, e1 := Syscall(SYS_SYNCFS, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sysinfo(info *Sysinfo_t) (err error) { _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) if e1 != 0 { @@ -1462,6 +1472,22 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Munlockall() (err error) { _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go index f34418dd1..dc8fe0a84 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -1234,6 +1234,16 @@ func Sync() { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Syncfs(fd int) (err error) { + _, _, e1 := Syscall(SYS_SYNCFS, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sysinfo(info *Sysinfo_t) (err error) { _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) if e1 != 0 { @@ -1462,6 +1472,22 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Munlockall() (err error) { _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go index 92b4716ef..4d2804278 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -1234,6 +1234,16 @@ func Sync() { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Syncfs(fd int) (err error) { + _, _, e1 := Syscall(SYS_SYNCFS, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sysinfo(info *Sysinfo_t) (err error) { _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) if e1 != 0 { @@ -1462,6 +1472,22 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Munlockall() (err error) { _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go index ec5592043..20ad4b6c9 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -1234,6 +1234,16 @@ func Sync() { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Syncfs(fd int) (err error) { + _, _, e1 := Syscall(SYS_SYNCFS, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sysinfo(info *Sysinfo_t) (err error) { _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) if e1 != 0 { @@ -1462,6 +1472,22 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Munlockall() (err error) { _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go index e6c2bf52a..9f194dc4a 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go @@ -1234,6 +1234,16 @@ func Sync() { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Syncfs(fd int) (err error) { + _, _, e1 := Syscall(SYS_SYNCFS, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sysinfo(info *Sysinfo_t) (err error) { _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) if e1 != 0 { @@ -1462,6 +1472,22 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Munlockall() (err error) { _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go index f77f1d096..4fde3ef08 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -1234,6 +1234,16 @@ func Sync() { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Syncfs(fd int) (err error) { + _, _, e1 := Syscall(SYS_SYNCFS, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sysinfo(info *Sysinfo_t) (err error) { _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) if e1 != 0 { @@ -1462,6 +1472,22 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Munlockall() (err error) { _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go index d6ce86112..f6463423c 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -1234,6 +1234,16 @@ func Sync() { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Syncfs(fd int) (err error) { + _, _, e1 := Syscall(SYS_SYNCFS, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sysinfo(info *Sysinfo_t) (err error) { _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) if e1 != 0 { @@ -1462,6 +1472,22 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Munlockall() (err error) { _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go index c0134065a..964591e5e 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go @@ -1234,6 +1234,16 @@ func Sync() { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Syncfs(fd int) (err error) { + _, _, e1 := Syscall(SYS_SYNCFS, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sysinfo(info *Sysinfo_t) (err error) { _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) if e1 != 0 { @@ -1462,6 +1472,22 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Munlockall() (err error) { _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go index 6b7a291cd..204ab1ae3 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -1234,6 +1234,16 @@ func Sync() { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Syncfs(fd int) (err error) { + _, _, e1 := Syscall(SYS_SYNCFS, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sysinfo(info *Sysinfo_t) (err error) { _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) if e1 != 0 { @@ -1462,6 +1472,22 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Munlockall() (err error) { _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go index 7585277ed..a8a2b0b0a 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -1234,6 +1234,16 @@ func Sync() { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Syncfs(fd int) (err error) { + _, _, e1 := Syscall(SYS_SYNCFS, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sysinfo(info *Sysinfo_t) (err error) { _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) if e1 != 0 { @@ -1462,6 +1472,22 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Munlockall() (err error) { _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index 987ce8664..b6ff9e392 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -1234,6 +1234,16 @@ func Sync() { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Syncfs(fd int) (err error) { + _, _, e1 := Syscall(SYS_SYNCFS, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sysinfo(info *Sysinfo_t) (err error) { _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) if e1 != 0 { @@ -1462,6 +1472,22 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Munlockall() (err error) { _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go index 3182345ec..db99fd0c9 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go @@ -1,5 +1,5 @@ // mksyscall.pl -l32 -netbsd -tags netbsd,386 syscall_bsd.go syscall_netbsd.go syscall_netbsd_386.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build netbsd,386 @@ -266,6 +266,106 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func pipe() (fd1 int, fd2 int, err error) { r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) fd1 = int(r0) @@ -777,74 +877,6 @@ func Mknod(path string, mode uint32, dev int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlockall(flags int) (err error) { - _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mprotect(b []byte, prot int) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { @@ -1297,3 +1329,18 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go index 74ba8189a..7b6c2c87e 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go @@ -1,5 +1,5 @@ // mksyscall.pl -netbsd -tags netbsd,amd64 syscall_bsd.go syscall_netbsd.go syscall_netbsd_amd64.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build netbsd,amd64 @@ -266,6 +266,106 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func pipe() (fd1 int, fd2 int, err error) { r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) fd1 = int(r0) @@ -777,74 +877,6 @@ func Mknod(path string, mode uint32, dev int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlockall(flags int) (err error) { - _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mprotect(b []byte, prot int) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { @@ -1297,3 +1329,18 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go index 1f346e2f5..0f4cc3b52 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go @@ -1,5 +1,5 @@ -// mksyscall.pl -l32 -arm -tags netbsd,arm syscall_bsd.go syscall_netbsd.go syscall_netbsd_arm.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// mksyscall.pl -l32 -netbsd -arm -tags netbsd,arm syscall_bsd.go syscall_netbsd.go syscall_netbsd_arm.go +// Code generated by the command above; see README.md. DO NOT EDIT. // +build netbsd,arm @@ -266,6 +266,106 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func pipe() (fd1 int, fd2 int, err error) { r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) fd1 = int(r0) @@ -777,74 +877,6 @@ func Mknod(path string, mode uint32, dev int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlockall(flags int) (err error) { - _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mprotect(b []byte, prot int) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { @@ -1297,3 +1329,18 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index ca3e81392..7baea87c7 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1,5 +1,5 @@ // mksyscall.pl -l32 -openbsd -tags openbsd,386 syscall_bsd.go syscall_openbsd.go syscall_openbsd_386.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build openbsd,386 @@ -266,6 +266,106 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func pipe(p *[2]_C_int) (err error) { _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) if e1 != 0 { @@ -785,74 +885,6 @@ func Mknod(path string, mode uint32, dev int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlockall(flags int) (err error) { - _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mprotect(b []byte, prot int) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { @@ -1355,3 +1387,18 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index bf63d552e..0d69ce6b5 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1,5 +1,5 @@ // mksyscall.pl -openbsd -tags openbsd,amd64 syscall_bsd.go syscall_openbsd.go syscall_openbsd_amd64.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build openbsd,amd64 @@ -266,6 +266,106 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func pipe(p *[2]_C_int) (err error) { _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) if e1 != 0 { @@ -785,74 +885,6 @@ func Mknod(path string, mode uint32, dev int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mlockall(flags int) (err error) { - _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Mprotect(b []byte, prot int) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlock(b []byte) (err error) { - var _p0 unsafe.Pointer - if len(b) > 0 { - _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { @@ -1355,3 +1387,18 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go new file mode 100644 index 000000000..41572c26e --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -0,0 +1,1404 @@ +// mksyscall.pl -l32 -openbsd -arm -tags openbsd,arm syscall_bsd.go syscall_openbsd.go syscall_openbsd_arm.go +// Code generated by the command above; see README.md. DO NOT EDIT. + +// +build openbsd,arm + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe(p *[2]_C_int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall6(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, signum syscall.Signal) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(whence), 0) + newoffset = int64(int64(r1)<<32 | int64(r0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), uintptr(pos>>32), 0) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go index d1ed02103..4287133d0 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go @@ -43,6 +43,7 @@ import ( //go:cgo_import_dynamic libc_fchown fchown "libc.so" //go:cgo_import_dynamic libc_fchownat fchownat "libc.so" //go:cgo_import_dynamic libc_fdatasync fdatasync "libc.so" +//go:cgo_import_dynamic libc_flock flock "libc.so" //go:cgo_import_dynamic libc_fpathconf fpathconf "libc.so" //go:cgo_import_dynamic libc_fstat fstat "libc.so" //go:cgo_import_dynamic libc_fstatvfs fstatvfs "libc.so" @@ -163,6 +164,7 @@ import ( //go:linkname procFchown libc_fchown //go:linkname procFchownat libc_fchownat //go:linkname procFdatasync libc_fdatasync +//go:linkname procFlock libc_flock //go:linkname procFpathconf libc_fpathconf //go:linkname procFstat libc_fstat //go:linkname procFstatvfs libc_fstatvfs @@ -284,6 +286,7 @@ var ( procFchown, procFchownat, procFdatasync, + procFlock, procFpathconf, procFstat, procFstatvfs, @@ -702,6 +705,14 @@ func Fdatasync(fd int) (err error) { return } +func Flock(fd int, how int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFlock)), 2, uintptr(fd), uintptr(how), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + func Fpathconf(fd int, name int) (val int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFpathconf)), 2, uintptr(fd), uintptr(name), 0, 0, 0, 0) val = int(r0) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go index b8c9aea85..41cb6ed39 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go @@ -1,5 +1,5 @@ -// mksysnum_darwin.pl /usr/include/sys/syscall.h -// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// mksysnum_darwin.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/usr/include/sys/syscall.h +// Code generated by the command above; see README.md. DO NOT EDIT. // +build arm,darwin @@ -121,12 +121,14 @@ const ( SYS_CSOPS = 169 SYS_CSOPS_AUDITTOKEN = 170 SYS_WAITID = 173 + SYS_KDEBUG_TYPEFILTER = 177 + SYS_KDEBUG_TRACE_STRING = 178 + SYS_KDEBUG_TRACE64 = 179 SYS_KDEBUG_TRACE = 180 SYS_SETGID = 181 SYS_SETEGID = 182 SYS_SETEUID = 183 SYS_SIGRETURN = 184 - SYS_CHUD = 185 SYS_FDATASYNC = 187 SYS_STAT = 188 SYS_FSTAT = 189 @@ -140,17 +142,10 @@ const ( SYS_LSEEK = 199 SYS_TRUNCATE = 200 SYS_FTRUNCATE = 201 - SYS___SYSCTL = 202 + SYS_SYSCTL = 202 SYS_MLOCK = 203 SYS_MUNLOCK = 204 SYS_UNDELETE = 205 - SYS_ATSOCKET = 206 - SYS_ATGETMSG = 207 - SYS_ATPUTMSG = 208 - SYS_ATPSNDREQ = 209 - SYS_ATPSNDRSP = 210 - SYS_ATPGETREQ = 211 - SYS_ATPGETRSP = 212 SYS_OPEN_DPROTECTED_NP = 216 SYS_GETATTRLIST = 220 SYS_SETATTRLIST = 221 @@ -202,9 +197,7 @@ const ( SYS_SEM_WAIT = 271 SYS_SEM_TRYWAIT = 272 SYS_SEM_POST = 273 - SYS_SEM_GETVALUE = 274 - SYS_SEM_INIT = 275 - SYS_SEM_DESTROY = 276 + SYS_SYSCTLBYNAME = 274 SYS_OPEN_EXTENDED = 277 SYS_UMASK_EXTENDED = 278 SYS_STAT_EXTENDED = 279 @@ -286,7 +279,6 @@ const ( SYS_KQUEUE = 362 SYS_KEVENT = 363 SYS_LCHOWN = 364 - SYS_STACK_SNAPSHOT = 365 SYS_BSDTHREAD_REGISTER = 366 SYS_WORKQ_OPEN = 367 SYS_WORKQ_KERNRETURN = 368 @@ -295,6 +287,7 @@ const ( SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL = 371 SYS_THREAD_SELFID = 372 SYS_LEDGER = 373 + SYS_KEVENT_QOS = 374 SYS___MAC_EXECVE = 380 SYS___MAC_SYSCALL = 381 SYS___MAC_GET_FILE = 382 @@ -306,11 +299,8 @@ const ( SYS___MAC_GET_FD = 388 SYS___MAC_SET_FD = 389 SYS___MAC_GET_PID = 390 - SYS___MAC_GET_LCID = 391 - SYS___MAC_GET_LCTX = 392 - SYS___MAC_SET_LCTX = 393 - SYS_SETLCID = 394 - SYS_GETLCID = 395 + SYS_PSELECT = 394 + SYS_PSELECT_NOCANCEL = 395 SYS_READ_NOCANCEL = 396 SYS_WRITE_NOCANCEL = 397 SYS_OPEN_NOCANCEL = 398 @@ -354,5 +344,83 @@ const ( SYS_PID_SHUTDOWN_SOCKETS = 436 SYS_SHARED_REGION_MAP_AND_SLIDE_NP = 438 SYS_KAS_INFO = 439 - SYS_MAXSYSCALL = 440 + SYS_MEMORYSTATUS_CONTROL = 440 + SYS_GUARDED_OPEN_NP = 441 + SYS_GUARDED_CLOSE_NP = 442 + SYS_GUARDED_KQUEUE_NP = 443 + SYS_CHANGE_FDGUARD_NP = 444 + SYS_USRCTL = 445 + SYS_PROC_RLIMIT_CONTROL = 446 + SYS_CONNECTX = 447 + SYS_DISCONNECTX = 448 + SYS_PEELOFF = 449 + SYS_SOCKET_DELEGATE = 450 + SYS_TELEMETRY = 451 + SYS_PROC_UUID_POLICY = 452 + SYS_MEMORYSTATUS_GET_LEVEL = 453 + SYS_SYSTEM_OVERRIDE = 454 + SYS_VFS_PURGE = 455 + SYS_SFI_CTL = 456 + SYS_SFI_PIDCTL = 457 + SYS_COALITION = 458 + SYS_COALITION_INFO = 459 + SYS_NECP_MATCH_POLICY = 460 + SYS_GETATTRLISTBULK = 461 + SYS_CLONEFILEAT = 462 + SYS_OPENAT = 463 + SYS_OPENAT_NOCANCEL = 464 + SYS_RENAMEAT = 465 + SYS_FACCESSAT = 466 + SYS_FCHMODAT = 467 + SYS_FCHOWNAT = 468 + SYS_FSTATAT = 469 + SYS_FSTATAT64 = 470 + SYS_LINKAT = 471 + SYS_UNLINKAT = 472 + SYS_READLINKAT = 473 + SYS_SYMLINKAT = 474 + SYS_MKDIRAT = 475 + SYS_GETATTRLISTAT = 476 + SYS_PROC_TRACE_LOG = 477 + SYS_BSDTHREAD_CTL = 478 + SYS_OPENBYID_NP = 479 + SYS_RECVMSG_X = 480 + SYS_SENDMSG_X = 481 + SYS_THREAD_SELFUSAGE = 482 + SYS_CSRCTL = 483 + SYS_GUARDED_OPEN_DPROTECTED_NP = 484 + SYS_GUARDED_WRITE_NP = 485 + SYS_GUARDED_PWRITE_NP = 486 + SYS_GUARDED_WRITEV_NP = 487 + SYS_RENAMEATX_NP = 488 + SYS_MREMAP_ENCRYPTED = 489 + SYS_NETAGENT_TRIGGER = 490 + SYS_STACK_SNAPSHOT_WITH_CONFIG = 491 + SYS_MICROSTACKSHOT = 492 + SYS_GRAB_PGO_DATA = 493 + SYS_PERSONA = 494 + SYS_WORK_INTERVAL_CTL = 499 + SYS_GETENTROPY = 500 + SYS_NECP_OPEN = 501 + SYS_NECP_CLIENT_ACTION = 502 + SYS___NEXUS_OPEN = 503 + SYS___NEXUS_REGISTER = 504 + SYS___NEXUS_DEREGISTER = 505 + SYS___NEXUS_CREATE = 506 + SYS___NEXUS_DESTROY = 507 + SYS___NEXUS_GET_OPT = 508 + SYS___NEXUS_SET_OPT = 509 + SYS___CHANNEL_OPEN = 510 + SYS___CHANNEL_GET_INFO = 511 + SYS___CHANNEL_SYNC = 512 + SYS___CHANNEL_GET_OPT = 513 + SYS___CHANNEL_SET_OPT = 514 + SYS_ULOCK_WAIT = 515 + SYS_ULOCK_WAKE = 516 + SYS_FCLONEFILEAT = 517 + SYS_FS_SNAPSHOT = 518 + SYS_TERMINATE_WITH_PAYLOAD = 520 + SYS_ABORT_WITH_PAYLOAD = 521 + SYS_MAXSYSCALL = 522 + SYS_INVALID = 63 ) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go index 26677ebbf..075816c34 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go @@ -1,5 +1,5 @@ -// mksysnum_darwin.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk/usr/include/sys/syscall.h -// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// mksysnum_darwin.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/usr/include/sys/syscall.h +// Code generated by the command above; see README.md. DO NOT EDIT. // +build arm64,darwin @@ -121,13 +121,14 @@ const ( SYS_CSOPS = 169 SYS_CSOPS_AUDITTOKEN = 170 SYS_WAITID = 173 + SYS_KDEBUG_TYPEFILTER = 177 + SYS_KDEBUG_TRACE_STRING = 178 SYS_KDEBUG_TRACE64 = 179 SYS_KDEBUG_TRACE = 180 SYS_SETGID = 181 SYS_SETEGID = 182 SYS_SETEUID = 183 SYS_SIGRETURN = 184 - SYS_CHUD = 185 SYS_FDATASYNC = 187 SYS_STAT = 188 SYS_FSTAT = 189 @@ -278,7 +279,6 @@ const ( SYS_KQUEUE = 362 SYS_KEVENT = 363 SYS_LCHOWN = 364 - SYS_STACK_SNAPSHOT = 365 SYS_BSDTHREAD_REGISTER = 366 SYS_WORKQ_OPEN = 367 SYS_WORKQ_KERNRETURN = 368 @@ -287,6 +287,7 @@ const ( SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL = 371 SYS_THREAD_SELFID = 372 SYS_LEDGER = 373 + SYS_KEVENT_QOS = 374 SYS___MAC_EXECVE = 380 SYS___MAC_SYSCALL = 381 SYS___MAC_GET_FILE = 382 @@ -298,11 +299,8 @@ const ( SYS___MAC_GET_FD = 388 SYS___MAC_SET_FD = 389 SYS___MAC_GET_PID = 390 - SYS___MAC_GET_LCID = 391 - SYS___MAC_GET_LCTX = 392 - SYS___MAC_SET_LCTX = 393 - SYS_SETLCID = 394 - SYS_GETLCID = 395 + SYS_PSELECT = 394 + SYS_PSELECT_NOCANCEL = 395 SYS_READ_NOCANCEL = 396 SYS_WRITE_NOCANCEL = 397 SYS_OPEN_NOCANCEL = 398 @@ -351,6 +349,7 @@ const ( SYS_GUARDED_CLOSE_NP = 442 SYS_GUARDED_KQUEUE_NP = 443 SYS_CHANGE_FDGUARD_NP = 444 + SYS_USRCTL = 445 SYS_PROC_RLIMIT_CONTROL = 446 SYS_CONNECTX = 447 SYS_DISCONNECTX = 448 @@ -367,6 +366,7 @@ const ( SYS_COALITION_INFO = 459 SYS_NECP_MATCH_POLICY = 460 SYS_GETATTRLISTBULK = 461 + SYS_CLONEFILEAT = 462 SYS_OPENAT = 463 SYS_OPENAT_NOCANCEL = 464 SYS_RENAMEAT = 465 @@ -392,7 +392,35 @@ const ( SYS_GUARDED_WRITE_NP = 485 SYS_GUARDED_PWRITE_NP = 486 SYS_GUARDED_WRITEV_NP = 487 - SYS_RENAME_EXT = 488 + SYS_RENAMEATX_NP = 488 SYS_MREMAP_ENCRYPTED = 489 - SYS_MAXSYSCALL = 490 + SYS_NETAGENT_TRIGGER = 490 + SYS_STACK_SNAPSHOT_WITH_CONFIG = 491 + SYS_MICROSTACKSHOT = 492 + SYS_GRAB_PGO_DATA = 493 + SYS_PERSONA = 494 + SYS_WORK_INTERVAL_CTL = 499 + SYS_GETENTROPY = 500 + SYS_NECP_OPEN = 501 + SYS_NECP_CLIENT_ACTION = 502 + SYS___NEXUS_OPEN = 503 + SYS___NEXUS_REGISTER = 504 + SYS___NEXUS_DEREGISTER = 505 + SYS___NEXUS_CREATE = 506 + SYS___NEXUS_DESTROY = 507 + SYS___NEXUS_GET_OPT = 508 + SYS___NEXUS_SET_OPT = 509 + SYS___CHANNEL_OPEN = 510 + SYS___CHANNEL_GET_INFO = 511 + SYS___CHANNEL_SYNC = 512 + SYS___CHANNEL_GET_OPT = 513 + SYS___CHANNEL_SET_OPT = 514 + SYS_ULOCK_WAIT = 515 + SYS_ULOCK_WAKE = 516 + SYS_FCLONEFILEAT = 517 + SYS_FS_SNAPSHOT = 518 + SYS_TERMINATE_WITH_PAYLOAD = 520 + SYS_ABORT_WITH_PAYLOAD = 521 + SYS_MAXSYSCALL = 522 + SYS_INVALID = 63 ) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go index 262a84536..b64a8122c 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go @@ -1,5 +1,5 @@ // mksysnum_freebsd.pl -// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build 386,freebsd @@ -7,345 +7,347 @@ package unix const ( // SYS_NOSYS = 0; // { int nosys(void); } syscall nosys_args int - SYS_EXIT = 1 // { void sys_exit(int rval); } exit \ - SYS_FORK = 2 // { int fork(void); } - SYS_READ = 3 // { ssize_t read(int fd, void *buf, \ - SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, \ - SYS_OPEN = 5 // { int open(char *path, int flags, int mode); } - SYS_CLOSE = 6 // { int close(int fd); } - SYS_WAIT4 = 7 // { int wait4(int pid, int *status, \ - SYS_LINK = 9 // { int link(char *path, char *link); } - SYS_UNLINK = 10 // { int unlink(char *path); } - SYS_CHDIR = 12 // { int chdir(char *path); } - SYS_FCHDIR = 13 // { int fchdir(int fd); } - SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); } - SYS_CHMOD = 15 // { int chmod(char *path, int mode); } - SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); } - SYS_OBREAK = 17 // { int obreak(char *nsize); } break \ - SYS_GETPID = 20 // { pid_t getpid(void); } - SYS_MOUNT = 21 // { int mount(char *type, char *path, \ - SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); } - SYS_SETUID = 23 // { int setuid(uid_t uid); } - SYS_GETUID = 24 // { uid_t getuid(void); } - SYS_GETEUID = 25 // { uid_t geteuid(void); } - SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, \ - SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, \ - SYS_SENDMSG = 28 // { int sendmsg(int s, struct msghdr *msg, \ - SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, \ - SYS_ACCEPT = 30 // { int accept(int s, \ - SYS_GETPEERNAME = 31 // { int getpeername(int fdes, \ - SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, \ - SYS_ACCESS = 33 // { int access(char *path, int amode); } - SYS_CHFLAGS = 34 // { int chflags(const char *path, u_long flags); } - SYS_FCHFLAGS = 35 // { int fchflags(int fd, u_long flags); } - SYS_SYNC = 36 // { int sync(void); } - SYS_KILL = 37 // { int kill(int pid, int signum); } - SYS_GETPPID = 39 // { pid_t getppid(void); } - SYS_DUP = 41 // { int dup(u_int fd); } - SYS_PIPE = 42 // { int pipe(void); } - SYS_GETEGID = 43 // { gid_t getegid(void); } - SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \ - SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, \ - SYS_GETGID = 47 // { gid_t getgid(void); } - SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int \ - SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); } - SYS_ACCT = 51 // { int acct(char *path); } - SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, \ - SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, \ - SYS_REBOOT = 55 // { int reboot(int opt); } - SYS_REVOKE = 56 // { int revoke(char *path); } - SYS_SYMLINK = 57 // { int symlink(char *path, char *link); } - SYS_READLINK = 58 // { ssize_t readlink(char *path, char *buf, \ - SYS_EXECVE = 59 // { int execve(char *fname, char **argv, \ - SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args \ - SYS_CHROOT = 61 // { int chroot(char *path); } - SYS_MSYNC = 65 // { int msync(void *addr, size_t len, \ - SYS_VFORK = 66 // { int vfork(void); } - SYS_SBRK = 69 // { int sbrk(int incr); } - SYS_SSTK = 70 // { int sstk(int incr); } - SYS_OVADVISE = 72 // { int ovadvise(int anom); } vadvise \ - SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); } - SYS_MPROTECT = 74 // { int mprotect(const void *addr, size_t len, \ - SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, \ - SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \ - SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, \ - SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, \ - SYS_GETPGRP = 81 // { int getpgrp(void); } - SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); } - SYS_SETITIMER = 83 // { int setitimer(u_int which, struct \ - SYS_SWAPON = 85 // { int swapon(char *name); } - SYS_GETITIMER = 86 // { int getitimer(u_int which, \ - SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); } - SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); } - SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); } - SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \ - SYS_FSYNC = 95 // { int fsync(int fd); } - SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, \ - SYS_SOCKET = 97 // { int socket(int domain, int type, \ - SYS_CONNECT = 98 // { int connect(int s, caddr_t name, \ - SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); } - SYS_BIND = 104 // { int bind(int s, caddr_t name, \ - SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \ - SYS_LISTEN = 106 // { int listen(int s, int backlog); } - SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \ - SYS_GETRUSAGE = 117 // { int getrusage(int who, \ - SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \ - SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, \ - SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \ - SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \ - SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); } - SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); } - SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); } - SYS_SETREGID = 127 // { int setregid(int rgid, int egid); } - SYS_RENAME = 128 // { int rename(char *from, char *to); } - SYS_FLOCK = 131 // { int flock(int fd, int how); } - SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); } - SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \ - SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); } - SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, \ - SYS_MKDIR = 136 // { int mkdir(char *path, int mode); } - SYS_RMDIR = 137 // { int rmdir(char *path); } - SYS_UTIMES = 138 // { int utimes(char *path, \ - SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \ - SYS_SETSID = 147 // { int setsid(void); } - SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \ - SYS_LGETFH = 160 // { int lgetfh(char *fname, \ - SYS_GETFH = 161 // { int getfh(char *fname, \ - SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); } - SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \ - SYS_FREEBSD6_PREAD = 173 // { ssize_t freebsd6_pread(int fd, void *buf, \ - SYS_FREEBSD6_PWRITE = 174 // { ssize_t freebsd6_pwrite(int fd, \ - SYS_SETFIB = 175 // { int setfib(int fibnum); } - SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); } - SYS_SETGID = 181 // { int setgid(gid_t gid); } - SYS_SETEGID = 182 // { int setegid(gid_t egid); } - SYS_SETEUID = 183 // { int seteuid(uid_t euid); } - SYS_STAT = 188 // { int stat(char *path, struct stat *ub); } - SYS_FSTAT = 189 // { int fstat(int fd, struct stat *sb); } - SYS_LSTAT = 190 // { int lstat(char *path, struct stat *ub); } - SYS_PATHCONF = 191 // { int pathconf(char *path, int name); } - SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); } - SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \ - SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \ - SYS_GETDIRENTRIES = 196 // { int getdirentries(int fd, char *buf, \ - SYS_FREEBSD6_MMAP = 197 // { caddr_t freebsd6_mmap(caddr_t addr, \ - SYS_FREEBSD6_LSEEK = 199 // { off_t freebsd6_lseek(int fd, int pad, \ - SYS_FREEBSD6_TRUNCATE = 200 // { int freebsd6_truncate(char *path, int pad, \ - SYS_FREEBSD6_FTRUNCATE = 201 // { int freebsd6_ftruncate(int fd, int pad, \ - SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, \ - SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); } - SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); } - SYS_UNDELETE = 205 // { int undelete(char *path); } - SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); } - SYS_GETPGID = 207 // { int getpgid(pid_t pid); } - SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \ - SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \ - SYS_CLOCK_SETTIME = 233 // { int clock_settime( \ - SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \ - SYS_KTIMER_CREATE = 235 // { int ktimer_create(clockid_t clock_id, \ - SYS_KTIMER_DELETE = 236 // { int ktimer_delete(int timerid); } - SYS_KTIMER_SETTIME = 237 // { int ktimer_settime(int timerid, int flags, \ - SYS_KTIMER_GETTIME = 238 // { int ktimer_gettime(int timerid, struct \ - SYS_KTIMER_GETOVERRUN = 239 // { int ktimer_getoverrun(int timerid); } - SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \ - SYS_FFCLOCK_GETCOUNTER = 241 // { int ffclock_getcounter(ffcounter *ffcount); } - SYS_FFCLOCK_SETESTIMATE = 242 // { int ffclock_setestimate( \ - SYS_FFCLOCK_GETESTIMATE = 243 // { int ffclock_getestimate( \ - SYS_CLOCK_GETCPUCLOCKID2 = 247 // { int clock_getcpuclockid2(id_t id,\ - SYS_NTP_GETTIME = 248 // { int ntp_gettime(struct ntptimeval *ntvp); } - SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, \ - SYS_RFORK = 251 // { int rfork(int flags); } - SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, \ - SYS_ISSETUGID = 253 // { int issetugid(void); } - SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); } - SYS_GETDENTS = 272 // { int getdents(int fd, char *buf, \ - SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); } - SYS_LUTIMES = 276 // { int lutimes(char *path, \ - SYS_NSTAT = 278 // { int nstat(char *path, struct nstat *ub); } - SYS_NFSTAT = 279 // { int nfstat(int fd, struct nstat *sb); } - SYS_NLSTAT = 280 // { int nlstat(char *path, struct nstat *ub); } - SYS_PREADV = 289 // { ssize_t preadv(int fd, struct iovec *iovp, \ - SYS_PWRITEV = 290 // { ssize_t pwritev(int fd, struct iovec *iovp, \ - SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, \ - SYS_FHSTAT = 299 // { int fhstat(const struct fhandle *u_fhp, \ - SYS_MODNEXT = 300 // { int modnext(int modid); } - SYS_MODSTAT = 301 // { int modstat(int modid, \ - SYS_MODFNEXT = 302 // { int modfnext(int modid); } - SYS_MODFIND = 303 // { int modfind(const char *name); } - SYS_KLDLOAD = 304 // { int kldload(const char *file); } - SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); } - SYS_KLDFIND = 306 // { int kldfind(const char *file); } - SYS_KLDNEXT = 307 // { int kldnext(int fileid); } - SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct \ - SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); } - SYS_GETSID = 310 // { int getsid(pid_t pid); } - SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, \ - SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, \ - SYS_YIELD = 321 // { int yield(void); } - SYS_MLOCKALL = 324 // { int mlockall(int how); } - SYS_MUNLOCKALL = 325 // { int munlockall(void); } - SYS___GETCWD = 326 // { int __getcwd(char *buf, u_int buflen); } - SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, \ - SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct \ - SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int \ - SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); } - SYS_SCHED_YIELD = 331 // { int sched_yield (void); } - SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); } - SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); } - SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, \ - SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); } - SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, \ - SYS_JAIL = 338 // { int jail(struct jail *jail); } - SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, \ - SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); } - SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); } - SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set, \ - SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set, \ - SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \ - SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \ - SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, \ - SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, \ - SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \ - SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, \ - SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \ - SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, \ - SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \ - SYS_EXTATTR_SET_FILE = 356 // { ssize_t extattr_set_file( \ - SYS_EXTATTR_GET_FILE = 357 // { ssize_t extattr_get_file( \ - SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \ - SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, \ - SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, \ - SYS_KQUEUE = 362 // { int kqueue(void); } - SYS_KEVENT = 363 // { int kevent(int fd, \ - SYS_EXTATTR_SET_FD = 371 // { ssize_t extattr_set_fd(int fd, \ - SYS_EXTATTR_GET_FD = 372 // { ssize_t extattr_get_fd(int fd, \ - SYS_EXTATTR_DELETE_FD = 373 // { int extattr_delete_fd(int fd, \ - SYS___SETUGID = 374 // { int __setugid(int flag); } - SYS_EACCESS = 376 // { int eaccess(char *path, int amode); } - SYS_NMOUNT = 378 // { int nmount(struct iovec *iovp, \ - SYS___MAC_GET_PROC = 384 // { int __mac_get_proc(struct mac *mac_p); } - SYS___MAC_SET_PROC = 385 // { int __mac_set_proc(struct mac *mac_p); } - SYS___MAC_GET_FD = 386 // { int __mac_get_fd(int fd, \ - SYS___MAC_GET_FILE = 387 // { int __mac_get_file(const char *path_p, \ - SYS___MAC_SET_FD = 388 // { int __mac_set_fd(int fd, \ - SYS___MAC_SET_FILE = 389 // { int __mac_set_file(const char *path_p, \ - SYS_KENV = 390 // { int kenv(int what, const char *name, \ - SYS_LCHFLAGS = 391 // { int lchflags(const char *path, \ - SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, \ - SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, \ - SYS_MAC_SYSCALL = 394 // { int mac_syscall(const char *policy, \ - SYS_GETFSSTAT = 395 // { int getfsstat(struct statfs *buf, \ - SYS_STATFS = 396 // { int statfs(char *path, \ - SYS_FSTATFS = 397 // { int fstatfs(int fd, struct statfs *buf); } - SYS_FHSTATFS = 398 // { int fhstatfs(const struct fhandle *u_fhp, \ - SYS___MAC_GET_PID = 409 // { int __mac_get_pid(pid_t pid, \ - SYS___MAC_GET_LINK = 410 // { int __mac_get_link(const char *path_p, \ - SYS___MAC_SET_LINK = 411 // { int __mac_set_link(const char *path_p, \ - SYS_EXTATTR_SET_LINK = 412 // { ssize_t extattr_set_link( \ - SYS_EXTATTR_GET_LINK = 413 // { ssize_t extattr_get_link( \ - SYS_EXTATTR_DELETE_LINK = 414 // { int extattr_delete_link( \ - SYS___MAC_EXECVE = 415 // { int __mac_execve(char *fname, char **argv, \ - SYS_SIGACTION = 416 // { int sigaction(int sig, \ - SYS_SIGRETURN = 417 // { int sigreturn( \ - SYS_GETCONTEXT = 421 // { int getcontext(struct __ucontext *ucp); } - SYS_SETCONTEXT = 422 // { int setcontext( \ - SYS_SWAPCONTEXT = 423 // { int swapcontext(struct __ucontext *oucp, \ - SYS_SWAPOFF = 424 // { int swapoff(const char *name); } - SYS___ACL_GET_LINK = 425 // { int __acl_get_link(const char *path, \ - SYS___ACL_SET_LINK = 426 // { int __acl_set_link(const char *path, \ - SYS___ACL_DELETE_LINK = 427 // { int __acl_delete_link(const char *path, \ - SYS___ACL_ACLCHECK_LINK = 428 // { int __acl_aclcheck_link(const char *path, \ - SYS_SIGWAIT = 429 // { int sigwait(const sigset_t *set, \ - SYS_THR_CREATE = 430 // { int thr_create(ucontext_t *ctx, long *id, \ - SYS_THR_EXIT = 431 // { void thr_exit(long *state); } - SYS_THR_SELF = 432 // { int thr_self(long *id); } - SYS_THR_KILL = 433 // { int thr_kill(long id, int sig); } - SYS__UMTX_LOCK = 434 // { int _umtx_lock(struct umtx *umtx); } - SYS__UMTX_UNLOCK = 435 // { int _umtx_unlock(struct umtx *umtx); } - SYS_JAIL_ATTACH = 436 // { int jail_attach(int jid); } - SYS_EXTATTR_LIST_FD = 437 // { ssize_t extattr_list_fd(int fd, \ - SYS_EXTATTR_LIST_FILE = 438 // { ssize_t extattr_list_file( \ - SYS_EXTATTR_LIST_LINK = 439 // { ssize_t extattr_list_link( \ - SYS_THR_SUSPEND = 442 // { int thr_suspend( \ - SYS_THR_WAKE = 443 // { int thr_wake(long id); } - SYS_KLDUNLOADF = 444 // { int kldunloadf(int fileid, int flags); } - SYS_AUDIT = 445 // { int audit(const void *record, \ - SYS_AUDITON = 446 // { int auditon(int cmd, void *data, \ - SYS_GETAUID = 447 // { int getauid(uid_t *auid); } - SYS_SETAUID = 448 // { int setauid(uid_t *auid); } - SYS_GETAUDIT = 449 // { int getaudit(struct auditinfo *auditinfo); } - SYS_SETAUDIT = 450 // { int setaudit(struct auditinfo *auditinfo); } - SYS_GETAUDIT_ADDR = 451 // { int getaudit_addr( \ - SYS_SETAUDIT_ADDR = 452 // { int setaudit_addr( \ - SYS_AUDITCTL = 453 // { int auditctl(char *path); } - SYS__UMTX_OP = 454 // { int _umtx_op(void *obj, int op, \ - SYS_THR_NEW = 455 // { int thr_new(struct thr_param *param, \ - SYS_SIGQUEUE = 456 // { int sigqueue(pid_t pid, int signum, void *value); } - SYS_ABORT2 = 463 // { int abort2(const char *why, int nargs, void **args); } - SYS_THR_SET_NAME = 464 // { int thr_set_name(long id, const char *name); } - SYS_RTPRIO_THREAD = 466 // { int rtprio_thread(int function, \ - SYS_SCTP_PEELOFF = 471 // { int sctp_peeloff(int sd, uint32_t name); } - SYS_SCTP_GENERIC_SENDMSG = 472 // { int sctp_generic_sendmsg(int sd, caddr_t msg, int mlen, \ - SYS_SCTP_GENERIC_SENDMSG_IOV = 473 // { int sctp_generic_sendmsg_iov(int sd, struct iovec *iov, int iovlen, \ - SYS_SCTP_GENERIC_RECVMSG = 474 // { int sctp_generic_recvmsg(int sd, struct iovec *iov, int iovlen, \ - SYS_PREAD = 475 // { ssize_t pread(int fd, void *buf, \ - SYS_PWRITE = 476 // { ssize_t pwrite(int fd, const void *buf, \ - SYS_MMAP = 477 // { caddr_t mmap(caddr_t addr, size_t len, \ - SYS_LSEEK = 478 // { off_t lseek(int fd, off_t offset, \ - SYS_TRUNCATE = 479 // { int truncate(char *path, off_t length); } - SYS_FTRUNCATE = 480 // { int ftruncate(int fd, off_t length); } - SYS_THR_KILL2 = 481 // { int thr_kill2(pid_t pid, long id, int sig); } - SYS_SHM_OPEN = 482 // { int shm_open(const char *path, int flags, \ - SYS_SHM_UNLINK = 483 // { int shm_unlink(const char *path); } - SYS_CPUSET = 484 // { int cpuset(cpusetid_t *setid); } - SYS_CPUSET_SETID = 485 // { int cpuset_setid(cpuwhich_t which, id_t id, \ - SYS_CPUSET_GETID = 486 // { int cpuset_getid(cpulevel_t level, \ - SYS_CPUSET_GETAFFINITY = 487 // { int cpuset_getaffinity(cpulevel_t level, \ - SYS_CPUSET_SETAFFINITY = 488 // { int cpuset_setaffinity(cpulevel_t level, \ - SYS_FACCESSAT = 489 // { int faccessat(int fd, char *path, int amode, \ - SYS_FCHMODAT = 490 // { int fchmodat(int fd, char *path, mode_t mode, \ - SYS_FCHOWNAT = 491 // { int fchownat(int fd, char *path, uid_t uid, \ - SYS_FEXECVE = 492 // { int fexecve(int fd, char **argv, \ - SYS_FSTATAT = 493 // { int fstatat(int fd, char *path, \ - SYS_FUTIMESAT = 494 // { int futimesat(int fd, char *path, \ - SYS_LINKAT = 495 // { int linkat(int fd1, char *path1, int fd2, \ - SYS_MKDIRAT = 496 // { int mkdirat(int fd, char *path, mode_t mode); } - SYS_MKFIFOAT = 497 // { int mkfifoat(int fd, char *path, mode_t mode); } - SYS_MKNODAT = 498 // { int mknodat(int fd, char *path, mode_t mode, \ - SYS_OPENAT = 499 // { int openat(int fd, char *path, int flag, \ - SYS_READLINKAT = 500 // { int readlinkat(int fd, char *path, char *buf, \ - SYS_RENAMEAT = 501 // { int renameat(int oldfd, char *old, int newfd, \ - SYS_SYMLINKAT = 502 // { int symlinkat(char *path1, int fd, \ - SYS_UNLINKAT = 503 // { int unlinkat(int fd, char *path, int flag); } - SYS_POSIX_OPENPT = 504 // { int posix_openpt(int flags); } - SYS_JAIL_GET = 506 // { int jail_get(struct iovec *iovp, \ - SYS_JAIL_SET = 507 // { int jail_set(struct iovec *iovp, \ - SYS_JAIL_REMOVE = 508 // { int jail_remove(int jid); } - SYS_CLOSEFROM = 509 // { int closefrom(int lowfd); } - SYS_LPATHCONF = 513 // { int lpathconf(char *path, int name); } - SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); } - SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \ - SYS_CAP_ENTER = 516 // { int cap_enter(void); } - SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); } - SYS_PDFORK = 518 // { int pdfork(int *fdp, int flags); } - SYS_PDKILL = 519 // { int pdkill(int fd, int signum); } - SYS_PDGETPID = 520 // { int pdgetpid(int fd, pid_t *pidp); } - SYS_PSELECT = 522 // { int pselect(int nd, fd_set *in, \ - SYS_GETLOGINCLASS = 523 // { int getloginclass(char *namebuf, \ - SYS_SETLOGINCLASS = 524 // { int setloginclass(const char *namebuf); } - SYS_RCTL_GET_RACCT = 525 // { int rctl_get_racct(const void *inbufp, \ - SYS_RCTL_GET_RULES = 526 // { int rctl_get_rules(const void *inbufp, \ - SYS_RCTL_GET_LIMITS = 527 // { int rctl_get_limits(const void *inbufp, \ - SYS_RCTL_ADD_RULE = 528 // { int rctl_add_rule(const void *inbufp, \ - SYS_RCTL_REMOVE_RULE = 529 // { int rctl_remove_rule(const void *inbufp, \ - SYS_POSIX_FALLOCATE = 530 // { int posix_fallocate(int fd, \ - SYS_POSIX_FADVISE = 531 // { int posix_fadvise(int fd, off_t offset, \ - SYS_WAIT6 = 532 // { int wait6(idtype_t idtype, id_t id, \ - SYS_BINDAT = 538 // { int bindat(int fd, int s, caddr_t name, \ - SYS_CONNECTAT = 539 // { int connectat(int fd, int s, caddr_t name, \ - SYS_CHFLAGSAT = 540 // { int chflagsat(int fd, const char *path, \ - SYS_ACCEPT4 = 541 // { int accept4(int s, \ - SYS_PIPE2 = 542 // { int pipe2(int *fildes, int flags); } - SYS_PROCCTL = 544 // { int procctl(idtype_t idtype, id_t id, \ - SYS_PPOLL = 545 // { int ppoll(struct pollfd *fds, u_int nfds, \ + SYS_EXIT = 1 // { void sys_exit(int rval); } exit \ + SYS_FORK = 2 // { int fork(void); } + SYS_READ = 3 // { ssize_t read(int fd, void *buf, \ + SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, \ + SYS_OPEN = 5 // { int open(char *path, int flags, int mode); } + SYS_CLOSE = 6 // { int close(int fd); } + SYS_WAIT4 = 7 // { int wait4(int pid, int *status, \ + SYS_LINK = 9 // { int link(char *path, char *link); } + SYS_UNLINK = 10 // { int unlink(char *path); } + SYS_CHDIR = 12 // { int chdir(char *path); } + SYS_FCHDIR = 13 // { int fchdir(int fd); } + SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); } + SYS_CHMOD = 15 // { int chmod(char *path, int mode); } + SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); } + SYS_OBREAK = 17 // { int obreak(char *nsize); } break \ + SYS_GETPID = 20 // { pid_t getpid(void); } + SYS_MOUNT = 21 // { int mount(char *type, char *path, \ + SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); } + SYS_SETUID = 23 // { int setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t getuid(void); } + SYS_GETEUID = 25 // { uid_t geteuid(void); } + SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, \ + SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, \ + SYS_SENDMSG = 28 // { int sendmsg(int s, struct msghdr *msg, \ + SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, \ + SYS_ACCEPT = 30 // { int accept(int s, \ + SYS_GETPEERNAME = 31 // { int getpeername(int fdes, \ + SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, \ + SYS_ACCESS = 33 // { int access(char *path, int amode); } + SYS_CHFLAGS = 34 // { int chflags(const char *path, u_long flags); } + SYS_FCHFLAGS = 35 // { int fchflags(int fd, u_long flags); } + SYS_SYNC = 36 // { int sync(void); } + SYS_KILL = 37 // { int kill(int pid, int signum); } + SYS_GETPPID = 39 // { pid_t getppid(void); } + SYS_DUP = 41 // { int dup(u_int fd); } + SYS_PIPE = 42 // { int pipe(void); } + SYS_GETEGID = 43 // { gid_t getegid(void); } + SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \ + SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, \ + SYS_GETGID = 47 // { gid_t getgid(void); } + SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int \ + SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); } + SYS_ACCT = 51 // { int acct(char *path); } + SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, \ + SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, \ + SYS_REBOOT = 55 // { int reboot(int opt); } + SYS_REVOKE = 56 // { int revoke(char *path); } + SYS_SYMLINK = 57 // { int symlink(char *path, char *link); } + SYS_READLINK = 58 // { ssize_t readlink(char *path, char *buf, \ + SYS_EXECVE = 59 // { int execve(char *fname, char **argv, \ + SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args \ + SYS_CHROOT = 61 // { int chroot(char *path); } + SYS_MSYNC = 65 // { int msync(void *addr, size_t len, \ + SYS_VFORK = 66 // { int vfork(void); } + SYS_SBRK = 69 // { int sbrk(int incr); } + SYS_SSTK = 70 // { int sstk(int incr); } + SYS_OVADVISE = 72 // { int ovadvise(int anom); } vadvise \ + SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int mprotect(const void *addr, size_t len, \ + SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, \ + SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \ + SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, \ + SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, \ + SYS_GETPGRP = 81 // { int getpgrp(void); } + SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); } + SYS_SETITIMER = 83 // { int setitimer(u_int which, struct \ + SYS_SWAPON = 85 // { int swapon(char *name); } + SYS_GETITIMER = 86 // { int getitimer(u_int which, \ + SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); } + SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); } + SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); } + SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \ + SYS_FSYNC = 95 // { int fsync(int fd); } + SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, \ + SYS_SOCKET = 97 // { int socket(int domain, int type, \ + SYS_CONNECT = 98 // { int connect(int s, caddr_t name, \ + SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); } + SYS_BIND = 104 // { int bind(int s, caddr_t name, \ + SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \ + SYS_LISTEN = 106 // { int listen(int s, int backlog); } + SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \ + SYS_GETRUSAGE = 117 // { int getrusage(int who, \ + SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \ + SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, \ + SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \ + SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \ + SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); } + SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); } + SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); } + SYS_SETREGID = 127 // { int setregid(int rgid, int egid); } + SYS_RENAME = 128 // { int rename(char *from, char *to); } + SYS_FLOCK = 131 // { int flock(int fd, int how); } + SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); } + SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \ + SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, \ + SYS_MKDIR = 136 // { int mkdir(char *path, int mode); } + SYS_RMDIR = 137 // { int rmdir(char *path); } + SYS_UTIMES = 138 // { int utimes(char *path, \ + SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \ + SYS_SETSID = 147 // { int setsid(void); } + SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \ + SYS_LGETFH = 160 // { int lgetfh(char *fname, \ + SYS_GETFH = 161 // { int getfh(char *fname, \ + SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); } + SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \ + SYS_FREEBSD6_PREAD = 173 // { ssize_t freebsd6_pread(int fd, void *buf, \ + SYS_FREEBSD6_PWRITE = 174 // { ssize_t freebsd6_pwrite(int fd, \ + SYS_SETFIB = 175 // { int setfib(int fibnum); } + SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); } + SYS_SETGID = 181 // { int setgid(gid_t gid); } + SYS_SETEGID = 182 // { int setegid(gid_t egid); } + SYS_SETEUID = 183 // { int seteuid(uid_t euid); } + SYS_STAT = 188 // { int stat(char *path, struct stat *ub); } + SYS_FSTAT = 189 // { int fstat(int fd, struct stat *sb); } + SYS_LSTAT = 190 // { int lstat(char *path, struct stat *ub); } + SYS_PATHCONF = 191 // { int pathconf(char *path, int name); } + SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); } + SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \ + SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \ + SYS_GETDIRENTRIES = 196 // { int getdirentries(int fd, char *buf, \ + SYS_FREEBSD6_MMAP = 197 // { caddr_t freebsd6_mmap(caddr_t addr, \ + SYS_FREEBSD6_LSEEK = 199 // { off_t freebsd6_lseek(int fd, int pad, \ + SYS_FREEBSD6_TRUNCATE = 200 // { int freebsd6_truncate(char *path, int pad, \ + SYS_FREEBSD6_FTRUNCATE = 201 // { int freebsd6_ftruncate(int fd, int pad, \ + SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, \ + SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); } + SYS_UNDELETE = 205 // { int undelete(char *path); } + SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); } + SYS_GETPGID = 207 // { int getpgid(pid_t pid); } + SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \ + SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \ + SYS_CLOCK_SETTIME = 233 // { int clock_settime( \ + SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \ + SYS_KTIMER_CREATE = 235 // { int ktimer_create(clockid_t clock_id, \ + SYS_KTIMER_DELETE = 236 // { int ktimer_delete(int timerid); } + SYS_KTIMER_SETTIME = 237 // { int ktimer_settime(int timerid, int flags, \ + SYS_KTIMER_GETTIME = 238 // { int ktimer_gettime(int timerid, struct \ + SYS_KTIMER_GETOVERRUN = 239 // { int ktimer_getoverrun(int timerid); } + SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \ + SYS_FFCLOCK_GETCOUNTER = 241 // { int ffclock_getcounter(ffcounter *ffcount); } + SYS_FFCLOCK_SETESTIMATE = 242 // { int ffclock_setestimate( \ + SYS_FFCLOCK_GETESTIMATE = 243 // { int ffclock_getestimate( \ + SYS_CLOCK_GETCPUCLOCKID2 = 247 // { int clock_getcpuclockid2(id_t id,\ + SYS_NTP_GETTIME = 248 // { int ntp_gettime(struct ntptimeval *ntvp); } + SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, \ + SYS_RFORK = 251 // { int rfork(int flags); } + SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, \ + SYS_ISSETUGID = 253 // { int issetugid(void); } + SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); } + SYS_GETDENTS = 272 // { int getdents(int fd, char *buf, \ + SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); } + SYS_LUTIMES = 276 // { int lutimes(char *path, \ + SYS_NSTAT = 278 // { int nstat(char *path, struct nstat *ub); } + SYS_NFSTAT = 279 // { int nfstat(int fd, struct nstat *sb); } + SYS_NLSTAT = 280 // { int nlstat(char *path, struct nstat *ub); } + SYS_PREADV = 289 // { ssize_t preadv(int fd, struct iovec *iovp, \ + SYS_PWRITEV = 290 // { ssize_t pwritev(int fd, struct iovec *iovp, \ + SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, \ + SYS_FHSTAT = 299 // { int fhstat(const struct fhandle *u_fhp, \ + SYS_MODNEXT = 300 // { int modnext(int modid); } + SYS_MODSTAT = 301 // { int modstat(int modid, \ + SYS_MODFNEXT = 302 // { int modfnext(int modid); } + SYS_MODFIND = 303 // { int modfind(const char *name); } + SYS_KLDLOAD = 304 // { int kldload(const char *file); } + SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); } + SYS_KLDFIND = 306 // { int kldfind(const char *file); } + SYS_KLDNEXT = 307 // { int kldnext(int fileid); } + SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct \ + SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); } + SYS_GETSID = 310 // { int getsid(pid_t pid); } + SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, \ + SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, \ + SYS_YIELD = 321 // { int yield(void); } + SYS_MLOCKALL = 324 // { int mlockall(int how); } + SYS_MUNLOCKALL = 325 // { int munlockall(void); } + SYS___GETCWD = 326 // { int __getcwd(char *buf, u_int buflen); } + SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, \ + SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct \ + SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int \ + SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); } + SYS_SCHED_YIELD = 331 // { int sched_yield (void); } + SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); } + SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); } + SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, \ + SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); } + SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, \ + SYS_JAIL = 338 // { int jail(struct jail *jail); } + SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, \ + SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); } + SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); } + SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set, \ + SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set, \ + SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \ + SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \ + SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, \ + SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, \ + SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \ + SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, \ + SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \ + SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, \ + SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \ + SYS_EXTATTR_SET_FILE = 356 // { ssize_t extattr_set_file( \ + SYS_EXTATTR_GET_FILE = 357 // { ssize_t extattr_get_file( \ + SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \ + SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, \ + SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, \ + SYS_KQUEUE = 362 // { int kqueue(void); } + SYS_KEVENT = 363 // { int kevent(int fd, \ + SYS_EXTATTR_SET_FD = 371 // { ssize_t extattr_set_fd(int fd, \ + SYS_EXTATTR_GET_FD = 372 // { ssize_t extattr_get_fd(int fd, \ + SYS_EXTATTR_DELETE_FD = 373 // { int extattr_delete_fd(int fd, \ + SYS___SETUGID = 374 // { int __setugid(int flag); } + SYS_EACCESS = 376 // { int eaccess(char *path, int amode); } + SYS_NMOUNT = 378 // { int nmount(struct iovec *iovp, \ + SYS___MAC_GET_PROC = 384 // { int __mac_get_proc(struct mac *mac_p); } + SYS___MAC_SET_PROC = 385 // { int __mac_set_proc(struct mac *mac_p); } + SYS___MAC_GET_FD = 386 // { int __mac_get_fd(int fd, \ + SYS___MAC_GET_FILE = 387 // { int __mac_get_file(const char *path_p, \ + SYS___MAC_SET_FD = 388 // { int __mac_set_fd(int fd, \ + SYS___MAC_SET_FILE = 389 // { int __mac_set_file(const char *path_p, \ + SYS_KENV = 390 // { int kenv(int what, const char *name, \ + SYS_LCHFLAGS = 391 // { int lchflags(const char *path, \ + SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, \ + SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, \ + SYS_MAC_SYSCALL = 394 // { int mac_syscall(const char *policy, \ + SYS_GETFSSTAT = 395 // { int getfsstat(struct statfs *buf, \ + SYS_STATFS = 396 // { int statfs(char *path, \ + SYS_FSTATFS = 397 // { int fstatfs(int fd, struct statfs *buf); } + SYS_FHSTATFS = 398 // { int fhstatfs(const struct fhandle *u_fhp, \ + SYS___MAC_GET_PID = 409 // { int __mac_get_pid(pid_t pid, \ + SYS___MAC_GET_LINK = 410 // { int __mac_get_link(const char *path_p, \ + SYS___MAC_SET_LINK = 411 // { int __mac_set_link(const char *path_p, \ + SYS_EXTATTR_SET_LINK = 412 // { ssize_t extattr_set_link( \ + SYS_EXTATTR_GET_LINK = 413 // { ssize_t extattr_get_link( \ + SYS_EXTATTR_DELETE_LINK = 414 // { int extattr_delete_link( \ + SYS___MAC_EXECVE = 415 // { int __mac_execve(char *fname, char **argv, \ + SYS_SIGACTION = 416 // { int sigaction(int sig, \ + SYS_SIGRETURN = 417 // { int sigreturn( \ + SYS_GETCONTEXT = 421 // { int getcontext(struct __ucontext *ucp); } + SYS_SETCONTEXT = 422 // { int setcontext( \ + SYS_SWAPCONTEXT = 423 // { int swapcontext(struct __ucontext *oucp, \ + SYS_SWAPOFF = 424 // { int swapoff(const char *name); } + SYS___ACL_GET_LINK = 425 // { int __acl_get_link(const char *path, \ + SYS___ACL_SET_LINK = 426 // { int __acl_set_link(const char *path, \ + SYS___ACL_DELETE_LINK = 427 // { int __acl_delete_link(const char *path, \ + SYS___ACL_ACLCHECK_LINK = 428 // { int __acl_aclcheck_link(const char *path, \ + SYS_SIGWAIT = 429 // { int sigwait(const sigset_t *set, \ + SYS_THR_CREATE = 430 // { int thr_create(ucontext_t *ctx, long *id, \ + SYS_THR_EXIT = 431 // { void thr_exit(long *state); } + SYS_THR_SELF = 432 // { int thr_self(long *id); } + SYS_THR_KILL = 433 // { int thr_kill(long id, int sig); } + SYS__UMTX_LOCK = 434 // { int _umtx_lock(struct umtx *umtx); } + SYS__UMTX_UNLOCK = 435 // { int _umtx_unlock(struct umtx *umtx); } + SYS_JAIL_ATTACH = 436 // { int jail_attach(int jid); } + SYS_EXTATTR_LIST_FD = 437 // { ssize_t extattr_list_fd(int fd, \ + SYS_EXTATTR_LIST_FILE = 438 // { ssize_t extattr_list_file( \ + SYS_EXTATTR_LIST_LINK = 439 // { ssize_t extattr_list_link( \ + SYS_THR_SUSPEND = 442 // { int thr_suspend( \ + SYS_THR_WAKE = 443 // { int thr_wake(long id); } + SYS_KLDUNLOADF = 444 // { int kldunloadf(int fileid, int flags); } + SYS_AUDIT = 445 // { int audit(const void *record, \ + SYS_AUDITON = 446 // { int auditon(int cmd, void *data, \ + SYS_GETAUID = 447 // { int getauid(uid_t *auid); } + SYS_SETAUID = 448 // { int setauid(uid_t *auid); } + SYS_GETAUDIT = 449 // { int getaudit(struct auditinfo *auditinfo); } + SYS_SETAUDIT = 450 // { int setaudit(struct auditinfo *auditinfo); } + SYS_GETAUDIT_ADDR = 451 // { int getaudit_addr( \ + SYS_SETAUDIT_ADDR = 452 // { int setaudit_addr( \ + SYS_AUDITCTL = 453 // { int auditctl(char *path); } + SYS__UMTX_OP = 454 // { int _umtx_op(void *obj, int op, \ + SYS_THR_NEW = 455 // { int thr_new(struct thr_param *param, \ + SYS_SIGQUEUE = 456 // { int sigqueue(pid_t pid, int signum, void *value); } + SYS_ABORT2 = 463 // { int abort2(const char *why, int nargs, void **args); } + SYS_THR_SET_NAME = 464 // { int thr_set_name(long id, const char *name); } + SYS_RTPRIO_THREAD = 466 // { int rtprio_thread(int function, \ + SYS_PREAD = 475 // { ssize_t pread(int fd, void *buf, \ + SYS_PWRITE = 476 // { ssize_t pwrite(int fd, const void *buf, \ + SYS_MMAP = 477 // { caddr_t mmap(caddr_t addr, size_t len, \ + SYS_LSEEK = 478 // { off_t lseek(int fd, off_t offset, \ + SYS_TRUNCATE = 479 // { int truncate(char *path, off_t length); } + SYS_FTRUNCATE = 480 // { int ftruncate(int fd, off_t length); } + SYS_THR_KILL2 = 481 // { int thr_kill2(pid_t pid, long id, int sig); } + SYS_SHM_OPEN = 482 // { int shm_open(const char *path, int flags, \ + SYS_SHM_UNLINK = 483 // { int shm_unlink(const char *path); } + SYS_CPUSET = 484 // { int cpuset(cpusetid_t *setid); } + SYS_CPUSET_SETID = 485 // { int cpuset_setid(cpuwhich_t which, id_t id, \ + SYS_CPUSET_GETID = 486 // { int cpuset_getid(cpulevel_t level, \ + SYS_CPUSET_GETAFFINITY = 487 // { int cpuset_getaffinity(cpulevel_t level, \ + SYS_CPUSET_SETAFFINITY = 488 // { int cpuset_setaffinity(cpulevel_t level, \ + SYS_FACCESSAT = 489 // { int faccessat(int fd, char *path, int amode, \ + SYS_FCHMODAT = 490 // { int fchmodat(int fd, char *path, mode_t mode, \ + SYS_FCHOWNAT = 491 // { int fchownat(int fd, char *path, uid_t uid, \ + SYS_FEXECVE = 492 // { int fexecve(int fd, char **argv, \ + SYS_FSTATAT = 493 // { int fstatat(int fd, char *path, \ + SYS_FUTIMESAT = 494 // { int futimesat(int fd, char *path, \ + SYS_LINKAT = 495 // { int linkat(int fd1, char *path1, int fd2, \ + SYS_MKDIRAT = 496 // { int mkdirat(int fd, char *path, mode_t mode); } + SYS_MKFIFOAT = 497 // { int mkfifoat(int fd, char *path, mode_t mode); } + SYS_MKNODAT = 498 // { int mknodat(int fd, char *path, mode_t mode, \ + SYS_OPENAT = 499 // { int openat(int fd, char *path, int flag, \ + SYS_READLINKAT = 500 // { int readlinkat(int fd, char *path, char *buf, \ + SYS_RENAMEAT = 501 // { int renameat(int oldfd, char *old, int newfd, \ + SYS_SYMLINKAT = 502 // { int symlinkat(char *path1, int fd, \ + SYS_UNLINKAT = 503 // { int unlinkat(int fd, char *path, int flag); } + SYS_POSIX_OPENPT = 504 // { int posix_openpt(int flags); } + SYS_JAIL_GET = 506 // { int jail_get(struct iovec *iovp, \ + SYS_JAIL_SET = 507 // { int jail_set(struct iovec *iovp, \ + SYS_JAIL_REMOVE = 508 // { int jail_remove(int jid); } + SYS_CLOSEFROM = 509 // { int closefrom(int lowfd); } + SYS_LPATHCONF = 513 // { int lpathconf(char *path, int name); } + SYS___CAP_RIGHTS_GET = 515 // { int __cap_rights_get(int version, \ + SYS_CAP_ENTER = 516 // { int cap_enter(void); } + SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); } + SYS_PDFORK = 518 // { int pdfork(int *fdp, int flags); } + SYS_PDKILL = 519 // { int pdkill(int fd, int signum); } + SYS_PDGETPID = 520 // { int pdgetpid(int fd, pid_t *pidp); } + SYS_PSELECT = 522 // { int pselect(int nd, fd_set *in, \ + SYS_GETLOGINCLASS = 523 // { int getloginclass(char *namebuf, \ + SYS_SETLOGINCLASS = 524 // { int setloginclass(const char *namebuf); } + SYS_RCTL_GET_RACCT = 525 // { int rctl_get_racct(const void *inbufp, \ + SYS_RCTL_GET_RULES = 526 // { int rctl_get_rules(const void *inbufp, \ + SYS_RCTL_GET_LIMITS = 527 // { int rctl_get_limits(const void *inbufp, \ + SYS_RCTL_ADD_RULE = 528 // { int rctl_add_rule(const void *inbufp, \ + SYS_RCTL_REMOVE_RULE = 529 // { int rctl_remove_rule(const void *inbufp, \ + SYS_POSIX_FALLOCATE = 530 // { int posix_fallocate(int fd, \ + SYS_POSIX_FADVISE = 531 // { int posix_fadvise(int fd, off_t offset, \ + SYS_WAIT6 = 532 // { int wait6(idtype_t idtype, id_t id, \ + SYS_CAP_RIGHTS_LIMIT = 533 // { int cap_rights_limit(int fd, \ + SYS_CAP_IOCTLS_LIMIT = 534 // { int cap_ioctls_limit(int fd, \ + SYS_CAP_IOCTLS_GET = 535 // { ssize_t cap_ioctls_get(int fd, \ + SYS_CAP_FCNTLS_LIMIT = 536 // { int cap_fcntls_limit(int fd, \ + SYS_CAP_FCNTLS_GET = 537 // { int cap_fcntls_get(int fd, \ + SYS_BINDAT = 538 // { int bindat(int fd, int s, caddr_t name, \ + SYS_CONNECTAT = 539 // { int connectat(int fd, int s, caddr_t name, \ + SYS_CHFLAGSAT = 540 // { int chflagsat(int fd, const char *path, \ + SYS_ACCEPT4 = 541 // { int accept4(int s, \ + SYS_PIPE2 = 542 // { int pipe2(int *fildes, int flags); } + SYS_PROCCTL = 544 // { int procctl(idtype_t idtype, id_t id, \ + SYS_PPOLL = 545 // { int ppoll(struct pollfd *fds, u_int nfds, \ + SYS_FUTIMENS = 546 // { int futimens(int fd, \ + SYS_UTIMENSAT = 547 // { int utimensat(int fd, \ ) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go index 57a60ea12..81722ac9f 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go @@ -1,5 +1,5 @@ // mksysnum_freebsd.pl -// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build amd64,freebsd @@ -7,345 +7,347 @@ package unix const ( // SYS_NOSYS = 0; // { int nosys(void); } syscall nosys_args int - SYS_EXIT = 1 // { void sys_exit(int rval); } exit \ - SYS_FORK = 2 // { int fork(void); } - SYS_READ = 3 // { ssize_t read(int fd, void *buf, \ - SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, \ - SYS_OPEN = 5 // { int open(char *path, int flags, int mode); } - SYS_CLOSE = 6 // { int close(int fd); } - SYS_WAIT4 = 7 // { int wait4(int pid, int *status, \ - SYS_LINK = 9 // { int link(char *path, char *link); } - SYS_UNLINK = 10 // { int unlink(char *path); } - SYS_CHDIR = 12 // { int chdir(char *path); } - SYS_FCHDIR = 13 // { int fchdir(int fd); } - SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); } - SYS_CHMOD = 15 // { int chmod(char *path, int mode); } - SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); } - SYS_OBREAK = 17 // { int obreak(char *nsize); } break \ - SYS_GETPID = 20 // { pid_t getpid(void); } - SYS_MOUNT = 21 // { int mount(char *type, char *path, \ - SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); } - SYS_SETUID = 23 // { int setuid(uid_t uid); } - SYS_GETUID = 24 // { uid_t getuid(void); } - SYS_GETEUID = 25 // { uid_t geteuid(void); } - SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, \ - SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, \ - SYS_SENDMSG = 28 // { int sendmsg(int s, struct msghdr *msg, \ - SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, \ - SYS_ACCEPT = 30 // { int accept(int s, \ - SYS_GETPEERNAME = 31 // { int getpeername(int fdes, \ - SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, \ - SYS_ACCESS = 33 // { int access(char *path, int amode); } - SYS_CHFLAGS = 34 // { int chflags(const char *path, u_long flags); } - SYS_FCHFLAGS = 35 // { int fchflags(int fd, u_long flags); } - SYS_SYNC = 36 // { int sync(void); } - SYS_KILL = 37 // { int kill(int pid, int signum); } - SYS_GETPPID = 39 // { pid_t getppid(void); } - SYS_DUP = 41 // { int dup(u_int fd); } - SYS_PIPE = 42 // { int pipe(void); } - SYS_GETEGID = 43 // { gid_t getegid(void); } - SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \ - SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, \ - SYS_GETGID = 47 // { gid_t getgid(void); } - SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int \ - SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); } - SYS_ACCT = 51 // { int acct(char *path); } - SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, \ - SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, \ - SYS_REBOOT = 55 // { int reboot(int opt); } - SYS_REVOKE = 56 // { int revoke(char *path); } - SYS_SYMLINK = 57 // { int symlink(char *path, char *link); } - SYS_READLINK = 58 // { ssize_t readlink(char *path, char *buf, \ - SYS_EXECVE = 59 // { int execve(char *fname, char **argv, \ - SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args \ - SYS_CHROOT = 61 // { int chroot(char *path); } - SYS_MSYNC = 65 // { int msync(void *addr, size_t len, \ - SYS_VFORK = 66 // { int vfork(void); } - SYS_SBRK = 69 // { int sbrk(int incr); } - SYS_SSTK = 70 // { int sstk(int incr); } - SYS_OVADVISE = 72 // { int ovadvise(int anom); } vadvise \ - SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); } - SYS_MPROTECT = 74 // { int mprotect(const void *addr, size_t len, \ - SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, \ - SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \ - SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, \ - SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, \ - SYS_GETPGRP = 81 // { int getpgrp(void); } - SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); } - SYS_SETITIMER = 83 // { int setitimer(u_int which, struct \ - SYS_SWAPON = 85 // { int swapon(char *name); } - SYS_GETITIMER = 86 // { int getitimer(u_int which, \ - SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); } - SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); } - SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); } - SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \ - SYS_FSYNC = 95 // { int fsync(int fd); } - SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, \ - SYS_SOCKET = 97 // { int socket(int domain, int type, \ - SYS_CONNECT = 98 // { int connect(int s, caddr_t name, \ - SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); } - SYS_BIND = 104 // { int bind(int s, caddr_t name, \ - SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \ - SYS_LISTEN = 106 // { int listen(int s, int backlog); } - SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \ - SYS_GETRUSAGE = 117 // { int getrusage(int who, \ - SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \ - SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, \ - SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \ - SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \ - SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); } - SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); } - SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); } - SYS_SETREGID = 127 // { int setregid(int rgid, int egid); } - SYS_RENAME = 128 // { int rename(char *from, char *to); } - SYS_FLOCK = 131 // { int flock(int fd, int how); } - SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); } - SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \ - SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); } - SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, \ - SYS_MKDIR = 136 // { int mkdir(char *path, int mode); } - SYS_RMDIR = 137 // { int rmdir(char *path); } - SYS_UTIMES = 138 // { int utimes(char *path, \ - SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \ - SYS_SETSID = 147 // { int setsid(void); } - SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \ - SYS_LGETFH = 160 // { int lgetfh(char *fname, \ - SYS_GETFH = 161 // { int getfh(char *fname, \ - SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); } - SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \ - SYS_FREEBSD6_PREAD = 173 // { ssize_t freebsd6_pread(int fd, void *buf, \ - SYS_FREEBSD6_PWRITE = 174 // { ssize_t freebsd6_pwrite(int fd, \ - SYS_SETFIB = 175 // { int setfib(int fibnum); } - SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); } - SYS_SETGID = 181 // { int setgid(gid_t gid); } - SYS_SETEGID = 182 // { int setegid(gid_t egid); } - SYS_SETEUID = 183 // { int seteuid(uid_t euid); } - SYS_STAT = 188 // { int stat(char *path, struct stat *ub); } - SYS_FSTAT = 189 // { int fstat(int fd, struct stat *sb); } - SYS_LSTAT = 190 // { int lstat(char *path, struct stat *ub); } - SYS_PATHCONF = 191 // { int pathconf(char *path, int name); } - SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); } - SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \ - SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \ - SYS_GETDIRENTRIES = 196 // { int getdirentries(int fd, char *buf, \ - SYS_FREEBSD6_MMAP = 197 // { caddr_t freebsd6_mmap(caddr_t addr, \ - SYS_FREEBSD6_LSEEK = 199 // { off_t freebsd6_lseek(int fd, int pad, \ - SYS_FREEBSD6_TRUNCATE = 200 // { int freebsd6_truncate(char *path, int pad, \ - SYS_FREEBSD6_FTRUNCATE = 201 // { int freebsd6_ftruncate(int fd, int pad, \ - SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, \ - SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); } - SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); } - SYS_UNDELETE = 205 // { int undelete(char *path); } - SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); } - SYS_GETPGID = 207 // { int getpgid(pid_t pid); } - SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \ - SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \ - SYS_CLOCK_SETTIME = 233 // { int clock_settime( \ - SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \ - SYS_KTIMER_CREATE = 235 // { int ktimer_create(clockid_t clock_id, \ - SYS_KTIMER_DELETE = 236 // { int ktimer_delete(int timerid); } - SYS_KTIMER_SETTIME = 237 // { int ktimer_settime(int timerid, int flags, \ - SYS_KTIMER_GETTIME = 238 // { int ktimer_gettime(int timerid, struct \ - SYS_KTIMER_GETOVERRUN = 239 // { int ktimer_getoverrun(int timerid); } - SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \ - SYS_FFCLOCK_GETCOUNTER = 241 // { int ffclock_getcounter(ffcounter *ffcount); } - SYS_FFCLOCK_SETESTIMATE = 242 // { int ffclock_setestimate( \ - SYS_FFCLOCK_GETESTIMATE = 243 // { int ffclock_getestimate( \ - SYS_CLOCK_GETCPUCLOCKID2 = 247 // { int clock_getcpuclockid2(id_t id,\ - SYS_NTP_GETTIME = 248 // { int ntp_gettime(struct ntptimeval *ntvp); } - SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, \ - SYS_RFORK = 251 // { int rfork(int flags); } - SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, \ - SYS_ISSETUGID = 253 // { int issetugid(void); } - SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); } - SYS_GETDENTS = 272 // { int getdents(int fd, char *buf, \ - SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); } - SYS_LUTIMES = 276 // { int lutimes(char *path, \ - SYS_NSTAT = 278 // { int nstat(char *path, struct nstat *ub); } - SYS_NFSTAT = 279 // { int nfstat(int fd, struct nstat *sb); } - SYS_NLSTAT = 280 // { int nlstat(char *path, struct nstat *ub); } - SYS_PREADV = 289 // { ssize_t preadv(int fd, struct iovec *iovp, \ - SYS_PWRITEV = 290 // { ssize_t pwritev(int fd, struct iovec *iovp, \ - SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, \ - SYS_FHSTAT = 299 // { int fhstat(const struct fhandle *u_fhp, \ - SYS_MODNEXT = 300 // { int modnext(int modid); } - SYS_MODSTAT = 301 // { int modstat(int modid, \ - SYS_MODFNEXT = 302 // { int modfnext(int modid); } - SYS_MODFIND = 303 // { int modfind(const char *name); } - SYS_KLDLOAD = 304 // { int kldload(const char *file); } - SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); } - SYS_KLDFIND = 306 // { int kldfind(const char *file); } - SYS_KLDNEXT = 307 // { int kldnext(int fileid); } - SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct \ - SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); } - SYS_GETSID = 310 // { int getsid(pid_t pid); } - SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, \ - SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, \ - SYS_YIELD = 321 // { int yield(void); } - SYS_MLOCKALL = 324 // { int mlockall(int how); } - SYS_MUNLOCKALL = 325 // { int munlockall(void); } - SYS___GETCWD = 326 // { int __getcwd(char *buf, u_int buflen); } - SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, \ - SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct \ - SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int \ - SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); } - SYS_SCHED_YIELD = 331 // { int sched_yield (void); } - SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); } - SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); } - SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, \ - SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); } - SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, \ - SYS_JAIL = 338 // { int jail(struct jail *jail); } - SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, \ - SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); } - SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); } - SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set, \ - SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set, \ - SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \ - SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \ - SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, \ - SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, \ - SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \ - SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, \ - SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \ - SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, \ - SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \ - SYS_EXTATTR_SET_FILE = 356 // { ssize_t extattr_set_file( \ - SYS_EXTATTR_GET_FILE = 357 // { ssize_t extattr_get_file( \ - SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \ - SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, \ - SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, \ - SYS_KQUEUE = 362 // { int kqueue(void); } - SYS_KEVENT = 363 // { int kevent(int fd, \ - SYS_EXTATTR_SET_FD = 371 // { ssize_t extattr_set_fd(int fd, \ - SYS_EXTATTR_GET_FD = 372 // { ssize_t extattr_get_fd(int fd, \ - SYS_EXTATTR_DELETE_FD = 373 // { int extattr_delete_fd(int fd, \ - SYS___SETUGID = 374 // { int __setugid(int flag); } - SYS_EACCESS = 376 // { int eaccess(char *path, int amode); } - SYS_NMOUNT = 378 // { int nmount(struct iovec *iovp, \ - SYS___MAC_GET_PROC = 384 // { int __mac_get_proc(struct mac *mac_p); } - SYS___MAC_SET_PROC = 385 // { int __mac_set_proc(struct mac *mac_p); } - SYS___MAC_GET_FD = 386 // { int __mac_get_fd(int fd, \ - SYS___MAC_GET_FILE = 387 // { int __mac_get_file(const char *path_p, \ - SYS___MAC_SET_FD = 388 // { int __mac_set_fd(int fd, \ - SYS___MAC_SET_FILE = 389 // { int __mac_set_file(const char *path_p, \ - SYS_KENV = 390 // { int kenv(int what, const char *name, \ - SYS_LCHFLAGS = 391 // { int lchflags(const char *path, \ - SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, \ - SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, \ - SYS_MAC_SYSCALL = 394 // { int mac_syscall(const char *policy, \ - SYS_GETFSSTAT = 395 // { int getfsstat(struct statfs *buf, \ - SYS_STATFS = 396 // { int statfs(char *path, \ - SYS_FSTATFS = 397 // { int fstatfs(int fd, struct statfs *buf); } - SYS_FHSTATFS = 398 // { int fhstatfs(const struct fhandle *u_fhp, \ - SYS___MAC_GET_PID = 409 // { int __mac_get_pid(pid_t pid, \ - SYS___MAC_GET_LINK = 410 // { int __mac_get_link(const char *path_p, \ - SYS___MAC_SET_LINK = 411 // { int __mac_set_link(const char *path_p, \ - SYS_EXTATTR_SET_LINK = 412 // { ssize_t extattr_set_link( \ - SYS_EXTATTR_GET_LINK = 413 // { ssize_t extattr_get_link( \ - SYS_EXTATTR_DELETE_LINK = 414 // { int extattr_delete_link( \ - SYS___MAC_EXECVE = 415 // { int __mac_execve(char *fname, char **argv, \ - SYS_SIGACTION = 416 // { int sigaction(int sig, \ - SYS_SIGRETURN = 417 // { int sigreturn( \ - SYS_GETCONTEXT = 421 // { int getcontext(struct __ucontext *ucp); } - SYS_SETCONTEXT = 422 // { int setcontext( \ - SYS_SWAPCONTEXT = 423 // { int swapcontext(struct __ucontext *oucp, \ - SYS_SWAPOFF = 424 // { int swapoff(const char *name); } - SYS___ACL_GET_LINK = 425 // { int __acl_get_link(const char *path, \ - SYS___ACL_SET_LINK = 426 // { int __acl_set_link(const char *path, \ - SYS___ACL_DELETE_LINK = 427 // { int __acl_delete_link(const char *path, \ - SYS___ACL_ACLCHECK_LINK = 428 // { int __acl_aclcheck_link(const char *path, \ - SYS_SIGWAIT = 429 // { int sigwait(const sigset_t *set, \ - SYS_THR_CREATE = 430 // { int thr_create(ucontext_t *ctx, long *id, \ - SYS_THR_EXIT = 431 // { void thr_exit(long *state); } - SYS_THR_SELF = 432 // { int thr_self(long *id); } - SYS_THR_KILL = 433 // { int thr_kill(long id, int sig); } - SYS__UMTX_LOCK = 434 // { int _umtx_lock(struct umtx *umtx); } - SYS__UMTX_UNLOCK = 435 // { int _umtx_unlock(struct umtx *umtx); } - SYS_JAIL_ATTACH = 436 // { int jail_attach(int jid); } - SYS_EXTATTR_LIST_FD = 437 // { ssize_t extattr_list_fd(int fd, \ - SYS_EXTATTR_LIST_FILE = 438 // { ssize_t extattr_list_file( \ - SYS_EXTATTR_LIST_LINK = 439 // { ssize_t extattr_list_link( \ - SYS_THR_SUSPEND = 442 // { int thr_suspend( \ - SYS_THR_WAKE = 443 // { int thr_wake(long id); } - SYS_KLDUNLOADF = 444 // { int kldunloadf(int fileid, int flags); } - SYS_AUDIT = 445 // { int audit(const void *record, \ - SYS_AUDITON = 446 // { int auditon(int cmd, void *data, \ - SYS_GETAUID = 447 // { int getauid(uid_t *auid); } - SYS_SETAUID = 448 // { int setauid(uid_t *auid); } - SYS_GETAUDIT = 449 // { int getaudit(struct auditinfo *auditinfo); } - SYS_SETAUDIT = 450 // { int setaudit(struct auditinfo *auditinfo); } - SYS_GETAUDIT_ADDR = 451 // { int getaudit_addr( \ - SYS_SETAUDIT_ADDR = 452 // { int setaudit_addr( \ - SYS_AUDITCTL = 453 // { int auditctl(char *path); } - SYS__UMTX_OP = 454 // { int _umtx_op(void *obj, int op, \ - SYS_THR_NEW = 455 // { int thr_new(struct thr_param *param, \ - SYS_SIGQUEUE = 456 // { int sigqueue(pid_t pid, int signum, void *value); } - SYS_ABORT2 = 463 // { int abort2(const char *why, int nargs, void **args); } - SYS_THR_SET_NAME = 464 // { int thr_set_name(long id, const char *name); } - SYS_RTPRIO_THREAD = 466 // { int rtprio_thread(int function, \ - SYS_SCTP_PEELOFF = 471 // { int sctp_peeloff(int sd, uint32_t name); } - SYS_SCTP_GENERIC_SENDMSG = 472 // { int sctp_generic_sendmsg(int sd, caddr_t msg, int mlen, \ - SYS_SCTP_GENERIC_SENDMSG_IOV = 473 // { int sctp_generic_sendmsg_iov(int sd, struct iovec *iov, int iovlen, \ - SYS_SCTP_GENERIC_RECVMSG = 474 // { int sctp_generic_recvmsg(int sd, struct iovec *iov, int iovlen, \ - SYS_PREAD = 475 // { ssize_t pread(int fd, void *buf, \ - SYS_PWRITE = 476 // { ssize_t pwrite(int fd, const void *buf, \ - SYS_MMAP = 477 // { caddr_t mmap(caddr_t addr, size_t len, \ - SYS_LSEEK = 478 // { off_t lseek(int fd, off_t offset, \ - SYS_TRUNCATE = 479 // { int truncate(char *path, off_t length); } - SYS_FTRUNCATE = 480 // { int ftruncate(int fd, off_t length); } - SYS_THR_KILL2 = 481 // { int thr_kill2(pid_t pid, long id, int sig); } - SYS_SHM_OPEN = 482 // { int shm_open(const char *path, int flags, \ - SYS_SHM_UNLINK = 483 // { int shm_unlink(const char *path); } - SYS_CPUSET = 484 // { int cpuset(cpusetid_t *setid); } - SYS_CPUSET_SETID = 485 // { int cpuset_setid(cpuwhich_t which, id_t id, \ - SYS_CPUSET_GETID = 486 // { int cpuset_getid(cpulevel_t level, \ - SYS_CPUSET_GETAFFINITY = 487 // { int cpuset_getaffinity(cpulevel_t level, \ - SYS_CPUSET_SETAFFINITY = 488 // { int cpuset_setaffinity(cpulevel_t level, \ - SYS_FACCESSAT = 489 // { int faccessat(int fd, char *path, int amode, \ - SYS_FCHMODAT = 490 // { int fchmodat(int fd, char *path, mode_t mode, \ - SYS_FCHOWNAT = 491 // { int fchownat(int fd, char *path, uid_t uid, \ - SYS_FEXECVE = 492 // { int fexecve(int fd, char **argv, \ - SYS_FSTATAT = 493 // { int fstatat(int fd, char *path, \ - SYS_FUTIMESAT = 494 // { int futimesat(int fd, char *path, \ - SYS_LINKAT = 495 // { int linkat(int fd1, char *path1, int fd2, \ - SYS_MKDIRAT = 496 // { int mkdirat(int fd, char *path, mode_t mode); } - SYS_MKFIFOAT = 497 // { int mkfifoat(int fd, char *path, mode_t mode); } - SYS_MKNODAT = 498 // { int mknodat(int fd, char *path, mode_t mode, \ - SYS_OPENAT = 499 // { int openat(int fd, char *path, int flag, \ - SYS_READLINKAT = 500 // { int readlinkat(int fd, char *path, char *buf, \ - SYS_RENAMEAT = 501 // { int renameat(int oldfd, char *old, int newfd, \ - SYS_SYMLINKAT = 502 // { int symlinkat(char *path1, int fd, \ - SYS_UNLINKAT = 503 // { int unlinkat(int fd, char *path, int flag); } - SYS_POSIX_OPENPT = 504 // { int posix_openpt(int flags); } - SYS_JAIL_GET = 506 // { int jail_get(struct iovec *iovp, \ - SYS_JAIL_SET = 507 // { int jail_set(struct iovec *iovp, \ - SYS_JAIL_REMOVE = 508 // { int jail_remove(int jid); } - SYS_CLOSEFROM = 509 // { int closefrom(int lowfd); } - SYS_LPATHCONF = 513 // { int lpathconf(char *path, int name); } - SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); } - SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \ - SYS_CAP_ENTER = 516 // { int cap_enter(void); } - SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); } - SYS_PDFORK = 518 // { int pdfork(int *fdp, int flags); } - SYS_PDKILL = 519 // { int pdkill(int fd, int signum); } - SYS_PDGETPID = 520 // { int pdgetpid(int fd, pid_t *pidp); } - SYS_PSELECT = 522 // { int pselect(int nd, fd_set *in, \ - SYS_GETLOGINCLASS = 523 // { int getloginclass(char *namebuf, \ - SYS_SETLOGINCLASS = 524 // { int setloginclass(const char *namebuf); } - SYS_RCTL_GET_RACCT = 525 // { int rctl_get_racct(const void *inbufp, \ - SYS_RCTL_GET_RULES = 526 // { int rctl_get_rules(const void *inbufp, \ - SYS_RCTL_GET_LIMITS = 527 // { int rctl_get_limits(const void *inbufp, \ - SYS_RCTL_ADD_RULE = 528 // { int rctl_add_rule(const void *inbufp, \ - SYS_RCTL_REMOVE_RULE = 529 // { int rctl_remove_rule(const void *inbufp, \ - SYS_POSIX_FALLOCATE = 530 // { int posix_fallocate(int fd, \ - SYS_POSIX_FADVISE = 531 // { int posix_fadvise(int fd, off_t offset, \ - SYS_WAIT6 = 532 // { int wait6(idtype_t idtype, id_t id, \ - SYS_BINDAT = 538 // { int bindat(int fd, int s, caddr_t name, \ - SYS_CONNECTAT = 539 // { int connectat(int fd, int s, caddr_t name, \ - SYS_CHFLAGSAT = 540 // { int chflagsat(int fd, const char *path, \ - SYS_ACCEPT4 = 541 // { int accept4(int s, \ - SYS_PIPE2 = 542 // { int pipe2(int *fildes, int flags); } - SYS_PROCCTL = 544 // { int procctl(idtype_t idtype, id_t id, \ - SYS_PPOLL = 545 // { int ppoll(struct pollfd *fds, u_int nfds, \ + SYS_EXIT = 1 // { void sys_exit(int rval); } exit \ + SYS_FORK = 2 // { int fork(void); } + SYS_READ = 3 // { ssize_t read(int fd, void *buf, \ + SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, \ + SYS_OPEN = 5 // { int open(char *path, int flags, int mode); } + SYS_CLOSE = 6 // { int close(int fd); } + SYS_WAIT4 = 7 // { int wait4(int pid, int *status, \ + SYS_LINK = 9 // { int link(char *path, char *link); } + SYS_UNLINK = 10 // { int unlink(char *path); } + SYS_CHDIR = 12 // { int chdir(char *path); } + SYS_FCHDIR = 13 // { int fchdir(int fd); } + SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); } + SYS_CHMOD = 15 // { int chmod(char *path, int mode); } + SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); } + SYS_OBREAK = 17 // { int obreak(char *nsize); } break \ + SYS_GETPID = 20 // { pid_t getpid(void); } + SYS_MOUNT = 21 // { int mount(char *type, char *path, \ + SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); } + SYS_SETUID = 23 // { int setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t getuid(void); } + SYS_GETEUID = 25 // { uid_t geteuid(void); } + SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, \ + SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, \ + SYS_SENDMSG = 28 // { int sendmsg(int s, struct msghdr *msg, \ + SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, \ + SYS_ACCEPT = 30 // { int accept(int s, \ + SYS_GETPEERNAME = 31 // { int getpeername(int fdes, \ + SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, \ + SYS_ACCESS = 33 // { int access(char *path, int amode); } + SYS_CHFLAGS = 34 // { int chflags(const char *path, u_long flags); } + SYS_FCHFLAGS = 35 // { int fchflags(int fd, u_long flags); } + SYS_SYNC = 36 // { int sync(void); } + SYS_KILL = 37 // { int kill(int pid, int signum); } + SYS_GETPPID = 39 // { pid_t getppid(void); } + SYS_DUP = 41 // { int dup(u_int fd); } + SYS_PIPE = 42 // { int pipe(void); } + SYS_GETEGID = 43 // { gid_t getegid(void); } + SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \ + SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, \ + SYS_GETGID = 47 // { gid_t getgid(void); } + SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int \ + SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); } + SYS_ACCT = 51 // { int acct(char *path); } + SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, \ + SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, \ + SYS_REBOOT = 55 // { int reboot(int opt); } + SYS_REVOKE = 56 // { int revoke(char *path); } + SYS_SYMLINK = 57 // { int symlink(char *path, char *link); } + SYS_READLINK = 58 // { ssize_t readlink(char *path, char *buf, \ + SYS_EXECVE = 59 // { int execve(char *fname, char **argv, \ + SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args \ + SYS_CHROOT = 61 // { int chroot(char *path); } + SYS_MSYNC = 65 // { int msync(void *addr, size_t len, \ + SYS_VFORK = 66 // { int vfork(void); } + SYS_SBRK = 69 // { int sbrk(int incr); } + SYS_SSTK = 70 // { int sstk(int incr); } + SYS_OVADVISE = 72 // { int ovadvise(int anom); } vadvise \ + SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int mprotect(const void *addr, size_t len, \ + SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, \ + SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \ + SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, \ + SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, \ + SYS_GETPGRP = 81 // { int getpgrp(void); } + SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); } + SYS_SETITIMER = 83 // { int setitimer(u_int which, struct \ + SYS_SWAPON = 85 // { int swapon(char *name); } + SYS_GETITIMER = 86 // { int getitimer(u_int which, \ + SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); } + SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); } + SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); } + SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \ + SYS_FSYNC = 95 // { int fsync(int fd); } + SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, \ + SYS_SOCKET = 97 // { int socket(int domain, int type, \ + SYS_CONNECT = 98 // { int connect(int s, caddr_t name, \ + SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); } + SYS_BIND = 104 // { int bind(int s, caddr_t name, \ + SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \ + SYS_LISTEN = 106 // { int listen(int s, int backlog); } + SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \ + SYS_GETRUSAGE = 117 // { int getrusage(int who, \ + SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \ + SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, \ + SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \ + SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \ + SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); } + SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); } + SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); } + SYS_SETREGID = 127 // { int setregid(int rgid, int egid); } + SYS_RENAME = 128 // { int rename(char *from, char *to); } + SYS_FLOCK = 131 // { int flock(int fd, int how); } + SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); } + SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \ + SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, \ + SYS_MKDIR = 136 // { int mkdir(char *path, int mode); } + SYS_RMDIR = 137 // { int rmdir(char *path); } + SYS_UTIMES = 138 // { int utimes(char *path, \ + SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \ + SYS_SETSID = 147 // { int setsid(void); } + SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \ + SYS_LGETFH = 160 // { int lgetfh(char *fname, \ + SYS_GETFH = 161 // { int getfh(char *fname, \ + SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); } + SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \ + SYS_FREEBSD6_PREAD = 173 // { ssize_t freebsd6_pread(int fd, void *buf, \ + SYS_FREEBSD6_PWRITE = 174 // { ssize_t freebsd6_pwrite(int fd, \ + SYS_SETFIB = 175 // { int setfib(int fibnum); } + SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); } + SYS_SETGID = 181 // { int setgid(gid_t gid); } + SYS_SETEGID = 182 // { int setegid(gid_t egid); } + SYS_SETEUID = 183 // { int seteuid(uid_t euid); } + SYS_STAT = 188 // { int stat(char *path, struct stat *ub); } + SYS_FSTAT = 189 // { int fstat(int fd, struct stat *sb); } + SYS_LSTAT = 190 // { int lstat(char *path, struct stat *ub); } + SYS_PATHCONF = 191 // { int pathconf(char *path, int name); } + SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); } + SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \ + SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \ + SYS_GETDIRENTRIES = 196 // { int getdirentries(int fd, char *buf, \ + SYS_FREEBSD6_MMAP = 197 // { caddr_t freebsd6_mmap(caddr_t addr, \ + SYS_FREEBSD6_LSEEK = 199 // { off_t freebsd6_lseek(int fd, int pad, \ + SYS_FREEBSD6_TRUNCATE = 200 // { int freebsd6_truncate(char *path, int pad, \ + SYS_FREEBSD6_FTRUNCATE = 201 // { int freebsd6_ftruncate(int fd, int pad, \ + SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, \ + SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); } + SYS_UNDELETE = 205 // { int undelete(char *path); } + SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); } + SYS_GETPGID = 207 // { int getpgid(pid_t pid); } + SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \ + SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \ + SYS_CLOCK_SETTIME = 233 // { int clock_settime( \ + SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \ + SYS_KTIMER_CREATE = 235 // { int ktimer_create(clockid_t clock_id, \ + SYS_KTIMER_DELETE = 236 // { int ktimer_delete(int timerid); } + SYS_KTIMER_SETTIME = 237 // { int ktimer_settime(int timerid, int flags, \ + SYS_KTIMER_GETTIME = 238 // { int ktimer_gettime(int timerid, struct \ + SYS_KTIMER_GETOVERRUN = 239 // { int ktimer_getoverrun(int timerid); } + SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \ + SYS_FFCLOCK_GETCOUNTER = 241 // { int ffclock_getcounter(ffcounter *ffcount); } + SYS_FFCLOCK_SETESTIMATE = 242 // { int ffclock_setestimate( \ + SYS_FFCLOCK_GETESTIMATE = 243 // { int ffclock_getestimate( \ + SYS_CLOCK_GETCPUCLOCKID2 = 247 // { int clock_getcpuclockid2(id_t id,\ + SYS_NTP_GETTIME = 248 // { int ntp_gettime(struct ntptimeval *ntvp); } + SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, \ + SYS_RFORK = 251 // { int rfork(int flags); } + SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, \ + SYS_ISSETUGID = 253 // { int issetugid(void); } + SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); } + SYS_GETDENTS = 272 // { int getdents(int fd, char *buf, \ + SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); } + SYS_LUTIMES = 276 // { int lutimes(char *path, \ + SYS_NSTAT = 278 // { int nstat(char *path, struct nstat *ub); } + SYS_NFSTAT = 279 // { int nfstat(int fd, struct nstat *sb); } + SYS_NLSTAT = 280 // { int nlstat(char *path, struct nstat *ub); } + SYS_PREADV = 289 // { ssize_t preadv(int fd, struct iovec *iovp, \ + SYS_PWRITEV = 290 // { ssize_t pwritev(int fd, struct iovec *iovp, \ + SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, \ + SYS_FHSTAT = 299 // { int fhstat(const struct fhandle *u_fhp, \ + SYS_MODNEXT = 300 // { int modnext(int modid); } + SYS_MODSTAT = 301 // { int modstat(int modid, \ + SYS_MODFNEXT = 302 // { int modfnext(int modid); } + SYS_MODFIND = 303 // { int modfind(const char *name); } + SYS_KLDLOAD = 304 // { int kldload(const char *file); } + SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); } + SYS_KLDFIND = 306 // { int kldfind(const char *file); } + SYS_KLDNEXT = 307 // { int kldnext(int fileid); } + SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct \ + SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); } + SYS_GETSID = 310 // { int getsid(pid_t pid); } + SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, \ + SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, \ + SYS_YIELD = 321 // { int yield(void); } + SYS_MLOCKALL = 324 // { int mlockall(int how); } + SYS_MUNLOCKALL = 325 // { int munlockall(void); } + SYS___GETCWD = 326 // { int __getcwd(char *buf, u_int buflen); } + SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, \ + SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct \ + SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int \ + SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); } + SYS_SCHED_YIELD = 331 // { int sched_yield (void); } + SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); } + SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); } + SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, \ + SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); } + SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, \ + SYS_JAIL = 338 // { int jail(struct jail *jail); } + SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, \ + SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); } + SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); } + SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set, \ + SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set, \ + SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \ + SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \ + SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, \ + SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, \ + SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \ + SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, \ + SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \ + SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, \ + SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \ + SYS_EXTATTR_SET_FILE = 356 // { ssize_t extattr_set_file( \ + SYS_EXTATTR_GET_FILE = 357 // { ssize_t extattr_get_file( \ + SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \ + SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, \ + SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, \ + SYS_KQUEUE = 362 // { int kqueue(void); } + SYS_KEVENT = 363 // { int kevent(int fd, \ + SYS_EXTATTR_SET_FD = 371 // { ssize_t extattr_set_fd(int fd, \ + SYS_EXTATTR_GET_FD = 372 // { ssize_t extattr_get_fd(int fd, \ + SYS_EXTATTR_DELETE_FD = 373 // { int extattr_delete_fd(int fd, \ + SYS___SETUGID = 374 // { int __setugid(int flag); } + SYS_EACCESS = 376 // { int eaccess(char *path, int amode); } + SYS_NMOUNT = 378 // { int nmount(struct iovec *iovp, \ + SYS___MAC_GET_PROC = 384 // { int __mac_get_proc(struct mac *mac_p); } + SYS___MAC_SET_PROC = 385 // { int __mac_set_proc(struct mac *mac_p); } + SYS___MAC_GET_FD = 386 // { int __mac_get_fd(int fd, \ + SYS___MAC_GET_FILE = 387 // { int __mac_get_file(const char *path_p, \ + SYS___MAC_SET_FD = 388 // { int __mac_set_fd(int fd, \ + SYS___MAC_SET_FILE = 389 // { int __mac_set_file(const char *path_p, \ + SYS_KENV = 390 // { int kenv(int what, const char *name, \ + SYS_LCHFLAGS = 391 // { int lchflags(const char *path, \ + SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, \ + SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, \ + SYS_MAC_SYSCALL = 394 // { int mac_syscall(const char *policy, \ + SYS_GETFSSTAT = 395 // { int getfsstat(struct statfs *buf, \ + SYS_STATFS = 396 // { int statfs(char *path, \ + SYS_FSTATFS = 397 // { int fstatfs(int fd, struct statfs *buf); } + SYS_FHSTATFS = 398 // { int fhstatfs(const struct fhandle *u_fhp, \ + SYS___MAC_GET_PID = 409 // { int __mac_get_pid(pid_t pid, \ + SYS___MAC_GET_LINK = 410 // { int __mac_get_link(const char *path_p, \ + SYS___MAC_SET_LINK = 411 // { int __mac_set_link(const char *path_p, \ + SYS_EXTATTR_SET_LINK = 412 // { ssize_t extattr_set_link( \ + SYS_EXTATTR_GET_LINK = 413 // { ssize_t extattr_get_link( \ + SYS_EXTATTR_DELETE_LINK = 414 // { int extattr_delete_link( \ + SYS___MAC_EXECVE = 415 // { int __mac_execve(char *fname, char **argv, \ + SYS_SIGACTION = 416 // { int sigaction(int sig, \ + SYS_SIGRETURN = 417 // { int sigreturn( \ + SYS_GETCONTEXT = 421 // { int getcontext(struct __ucontext *ucp); } + SYS_SETCONTEXT = 422 // { int setcontext( \ + SYS_SWAPCONTEXT = 423 // { int swapcontext(struct __ucontext *oucp, \ + SYS_SWAPOFF = 424 // { int swapoff(const char *name); } + SYS___ACL_GET_LINK = 425 // { int __acl_get_link(const char *path, \ + SYS___ACL_SET_LINK = 426 // { int __acl_set_link(const char *path, \ + SYS___ACL_DELETE_LINK = 427 // { int __acl_delete_link(const char *path, \ + SYS___ACL_ACLCHECK_LINK = 428 // { int __acl_aclcheck_link(const char *path, \ + SYS_SIGWAIT = 429 // { int sigwait(const sigset_t *set, \ + SYS_THR_CREATE = 430 // { int thr_create(ucontext_t *ctx, long *id, \ + SYS_THR_EXIT = 431 // { void thr_exit(long *state); } + SYS_THR_SELF = 432 // { int thr_self(long *id); } + SYS_THR_KILL = 433 // { int thr_kill(long id, int sig); } + SYS__UMTX_LOCK = 434 // { int _umtx_lock(struct umtx *umtx); } + SYS__UMTX_UNLOCK = 435 // { int _umtx_unlock(struct umtx *umtx); } + SYS_JAIL_ATTACH = 436 // { int jail_attach(int jid); } + SYS_EXTATTR_LIST_FD = 437 // { ssize_t extattr_list_fd(int fd, \ + SYS_EXTATTR_LIST_FILE = 438 // { ssize_t extattr_list_file( \ + SYS_EXTATTR_LIST_LINK = 439 // { ssize_t extattr_list_link( \ + SYS_THR_SUSPEND = 442 // { int thr_suspend( \ + SYS_THR_WAKE = 443 // { int thr_wake(long id); } + SYS_KLDUNLOADF = 444 // { int kldunloadf(int fileid, int flags); } + SYS_AUDIT = 445 // { int audit(const void *record, \ + SYS_AUDITON = 446 // { int auditon(int cmd, void *data, \ + SYS_GETAUID = 447 // { int getauid(uid_t *auid); } + SYS_SETAUID = 448 // { int setauid(uid_t *auid); } + SYS_GETAUDIT = 449 // { int getaudit(struct auditinfo *auditinfo); } + SYS_SETAUDIT = 450 // { int setaudit(struct auditinfo *auditinfo); } + SYS_GETAUDIT_ADDR = 451 // { int getaudit_addr( \ + SYS_SETAUDIT_ADDR = 452 // { int setaudit_addr( \ + SYS_AUDITCTL = 453 // { int auditctl(char *path); } + SYS__UMTX_OP = 454 // { int _umtx_op(void *obj, int op, \ + SYS_THR_NEW = 455 // { int thr_new(struct thr_param *param, \ + SYS_SIGQUEUE = 456 // { int sigqueue(pid_t pid, int signum, void *value); } + SYS_ABORT2 = 463 // { int abort2(const char *why, int nargs, void **args); } + SYS_THR_SET_NAME = 464 // { int thr_set_name(long id, const char *name); } + SYS_RTPRIO_THREAD = 466 // { int rtprio_thread(int function, \ + SYS_PREAD = 475 // { ssize_t pread(int fd, void *buf, \ + SYS_PWRITE = 476 // { ssize_t pwrite(int fd, const void *buf, \ + SYS_MMAP = 477 // { caddr_t mmap(caddr_t addr, size_t len, \ + SYS_LSEEK = 478 // { off_t lseek(int fd, off_t offset, \ + SYS_TRUNCATE = 479 // { int truncate(char *path, off_t length); } + SYS_FTRUNCATE = 480 // { int ftruncate(int fd, off_t length); } + SYS_THR_KILL2 = 481 // { int thr_kill2(pid_t pid, long id, int sig); } + SYS_SHM_OPEN = 482 // { int shm_open(const char *path, int flags, \ + SYS_SHM_UNLINK = 483 // { int shm_unlink(const char *path); } + SYS_CPUSET = 484 // { int cpuset(cpusetid_t *setid); } + SYS_CPUSET_SETID = 485 // { int cpuset_setid(cpuwhich_t which, id_t id, \ + SYS_CPUSET_GETID = 486 // { int cpuset_getid(cpulevel_t level, \ + SYS_CPUSET_GETAFFINITY = 487 // { int cpuset_getaffinity(cpulevel_t level, \ + SYS_CPUSET_SETAFFINITY = 488 // { int cpuset_setaffinity(cpulevel_t level, \ + SYS_FACCESSAT = 489 // { int faccessat(int fd, char *path, int amode, \ + SYS_FCHMODAT = 490 // { int fchmodat(int fd, char *path, mode_t mode, \ + SYS_FCHOWNAT = 491 // { int fchownat(int fd, char *path, uid_t uid, \ + SYS_FEXECVE = 492 // { int fexecve(int fd, char **argv, \ + SYS_FSTATAT = 493 // { int fstatat(int fd, char *path, \ + SYS_FUTIMESAT = 494 // { int futimesat(int fd, char *path, \ + SYS_LINKAT = 495 // { int linkat(int fd1, char *path1, int fd2, \ + SYS_MKDIRAT = 496 // { int mkdirat(int fd, char *path, mode_t mode); } + SYS_MKFIFOAT = 497 // { int mkfifoat(int fd, char *path, mode_t mode); } + SYS_MKNODAT = 498 // { int mknodat(int fd, char *path, mode_t mode, \ + SYS_OPENAT = 499 // { int openat(int fd, char *path, int flag, \ + SYS_READLINKAT = 500 // { int readlinkat(int fd, char *path, char *buf, \ + SYS_RENAMEAT = 501 // { int renameat(int oldfd, char *old, int newfd, \ + SYS_SYMLINKAT = 502 // { int symlinkat(char *path1, int fd, \ + SYS_UNLINKAT = 503 // { int unlinkat(int fd, char *path, int flag); } + SYS_POSIX_OPENPT = 504 // { int posix_openpt(int flags); } + SYS_JAIL_GET = 506 // { int jail_get(struct iovec *iovp, \ + SYS_JAIL_SET = 507 // { int jail_set(struct iovec *iovp, \ + SYS_JAIL_REMOVE = 508 // { int jail_remove(int jid); } + SYS_CLOSEFROM = 509 // { int closefrom(int lowfd); } + SYS_LPATHCONF = 513 // { int lpathconf(char *path, int name); } + SYS___CAP_RIGHTS_GET = 515 // { int __cap_rights_get(int version, \ + SYS_CAP_ENTER = 516 // { int cap_enter(void); } + SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); } + SYS_PDFORK = 518 // { int pdfork(int *fdp, int flags); } + SYS_PDKILL = 519 // { int pdkill(int fd, int signum); } + SYS_PDGETPID = 520 // { int pdgetpid(int fd, pid_t *pidp); } + SYS_PSELECT = 522 // { int pselect(int nd, fd_set *in, \ + SYS_GETLOGINCLASS = 523 // { int getloginclass(char *namebuf, \ + SYS_SETLOGINCLASS = 524 // { int setloginclass(const char *namebuf); } + SYS_RCTL_GET_RACCT = 525 // { int rctl_get_racct(const void *inbufp, \ + SYS_RCTL_GET_RULES = 526 // { int rctl_get_rules(const void *inbufp, \ + SYS_RCTL_GET_LIMITS = 527 // { int rctl_get_limits(const void *inbufp, \ + SYS_RCTL_ADD_RULE = 528 // { int rctl_add_rule(const void *inbufp, \ + SYS_RCTL_REMOVE_RULE = 529 // { int rctl_remove_rule(const void *inbufp, \ + SYS_POSIX_FALLOCATE = 530 // { int posix_fallocate(int fd, \ + SYS_POSIX_FADVISE = 531 // { int posix_fadvise(int fd, off_t offset, \ + SYS_WAIT6 = 532 // { int wait6(idtype_t idtype, id_t id, \ + SYS_CAP_RIGHTS_LIMIT = 533 // { int cap_rights_limit(int fd, \ + SYS_CAP_IOCTLS_LIMIT = 534 // { int cap_ioctls_limit(int fd, \ + SYS_CAP_IOCTLS_GET = 535 // { ssize_t cap_ioctls_get(int fd, \ + SYS_CAP_FCNTLS_LIMIT = 536 // { int cap_fcntls_limit(int fd, \ + SYS_CAP_FCNTLS_GET = 537 // { int cap_fcntls_get(int fd, \ + SYS_BINDAT = 538 // { int bindat(int fd, int s, caddr_t name, \ + SYS_CONNECTAT = 539 // { int connectat(int fd, int s, caddr_t name, \ + SYS_CHFLAGSAT = 540 // { int chflagsat(int fd, const char *path, \ + SYS_ACCEPT4 = 541 // { int accept4(int s, \ + SYS_PIPE2 = 542 // { int pipe2(int *fildes, int flags); } + SYS_PROCCTL = 544 // { int procctl(idtype_t idtype, id_t id, \ + SYS_PPOLL = 545 // { int ppoll(struct pollfd *fds, u_int nfds, \ + SYS_FUTIMENS = 546 // { int futimens(int fd, \ + SYS_UTIMENSAT = 547 // { int utimensat(int fd, \ ) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go index 206b9f612..448831418 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go @@ -1,5 +1,5 @@ // mksysnum_freebsd.pl -// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build arm,freebsd @@ -7,345 +7,347 @@ package unix const ( // SYS_NOSYS = 0; // { int nosys(void); } syscall nosys_args int - SYS_EXIT = 1 // { void sys_exit(int rval); } exit \ - SYS_FORK = 2 // { int fork(void); } - SYS_READ = 3 // { ssize_t read(int fd, void *buf, \ - SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, \ - SYS_OPEN = 5 // { int open(char *path, int flags, int mode); } - SYS_CLOSE = 6 // { int close(int fd); } - SYS_WAIT4 = 7 // { int wait4(int pid, int *status, \ - SYS_LINK = 9 // { int link(char *path, char *link); } - SYS_UNLINK = 10 // { int unlink(char *path); } - SYS_CHDIR = 12 // { int chdir(char *path); } - SYS_FCHDIR = 13 // { int fchdir(int fd); } - SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); } - SYS_CHMOD = 15 // { int chmod(char *path, int mode); } - SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); } - SYS_OBREAK = 17 // { int obreak(char *nsize); } break \ - SYS_GETPID = 20 // { pid_t getpid(void); } - SYS_MOUNT = 21 // { int mount(char *type, char *path, \ - SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); } - SYS_SETUID = 23 // { int setuid(uid_t uid); } - SYS_GETUID = 24 // { uid_t getuid(void); } - SYS_GETEUID = 25 // { uid_t geteuid(void); } - SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, \ - SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, \ - SYS_SENDMSG = 28 // { int sendmsg(int s, struct msghdr *msg, \ - SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, \ - SYS_ACCEPT = 30 // { int accept(int s, \ - SYS_GETPEERNAME = 31 // { int getpeername(int fdes, \ - SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, \ - SYS_ACCESS = 33 // { int access(char *path, int amode); } - SYS_CHFLAGS = 34 // { int chflags(const char *path, u_long flags); } - SYS_FCHFLAGS = 35 // { int fchflags(int fd, u_long flags); } - SYS_SYNC = 36 // { int sync(void); } - SYS_KILL = 37 // { int kill(int pid, int signum); } - SYS_GETPPID = 39 // { pid_t getppid(void); } - SYS_DUP = 41 // { int dup(u_int fd); } - SYS_PIPE = 42 // { int pipe(void); } - SYS_GETEGID = 43 // { gid_t getegid(void); } - SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \ - SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, \ - SYS_GETGID = 47 // { gid_t getgid(void); } - SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int \ - SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); } - SYS_ACCT = 51 // { int acct(char *path); } - SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, \ - SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, \ - SYS_REBOOT = 55 // { int reboot(int opt); } - SYS_REVOKE = 56 // { int revoke(char *path); } - SYS_SYMLINK = 57 // { int symlink(char *path, char *link); } - SYS_READLINK = 58 // { ssize_t readlink(char *path, char *buf, \ - SYS_EXECVE = 59 // { int execve(char *fname, char **argv, \ - SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args \ - SYS_CHROOT = 61 // { int chroot(char *path); } - SYS_MSYNC = 65 // { int msync(void *addr, size_t len, \ - SYS_VFORK = 66 // { int vfork(void); } - SYS_SBRK = 69 // { int sbrk(int incr); } - SYS_SSTK = 70 // { int sstk(int incr); } - SYS_OVADVISE = 72 // { int ovadvise(int anom); } vadvise \ - SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); } - SYS_MPROTECT = 74 // { int mprotect(const void *addr, size_t len, \ - SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, \ - SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \ - SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, \ - SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, \ - SYS_GETPGRP = 81 // { int getpgrp(void); } - SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); } - SYS_SETITIMER = 83 // { int setitimer(u_int which, struct \ - SYS_SWAPON = 85 // { int swapon(char *name); } - SYS_GETITIMER = 86 // { int getitimer(u_int which, \ - SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); } - SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); } - SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); } - SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \ - SYS_FSYNC = 95 // { int fsync(int fd); } - SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, \ - SYS_SOCKET = 97 // { int socket(int domain, int type, \ - SYS_CONNECT = 98 // { int connect(int s, caddr_t name, \ - SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); } - SYS_BIND = 104 // { int bind(int s, caddr_t name, \ - SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \ - SYS_LISTEN = 106 // { int listen(int s, int backlog); } - SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \ - SYS_GETRUSAGE = 117 // { int getrusage(int who, \ - SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \ - SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, \ - SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \ - SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \ - SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); } - SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); } - SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); } - SYS_SETREGID = 127 // { int setregid(int rgid, int egid); } - SYS_RENAME = 128 // { int rename(char *from, char *to); } - SYS_FLOCK = 131 // { int flock(int fd, int how); } - SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); } - SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \ - SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); } - SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, \ - SYS_MKDIR = 136 // { int mkdir(char *path, int mode); } - SYS_RMDIR = 137 // { int rmdir(char *path); } - SYS_UTIMES = 138 // { int utimes(char *path, \ - SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \ - SYS_SETSID = 147 // { int setsid(void); } - SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \ - SYS_LGETFH = 160 // { int lgetfh(char *fname, \ - SYS_GETFH = 161 // { int getfh(char *fname, \ - SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); } - SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \ - SYS_FREEBSD6_PREAD = 173 // { ssize_t freebsd6_pread(int fd, void *buf, \ - SYS_FREEBSD6_PWRITE = 174 // { ssize_t freebsd6_pwrite(int fd, \ - SYS_SETFIB = 175 // { int setfib(int fibnum); } - SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); } - SYS_SETGID = 181 // { int setgid(gid_t gid); } - SYS_SETEGID = 182 // { int setegid(gid_t egid); } - SYS_SETEUID = 183 // { int seteuid(uid_t euid); } - SYS_STAT = 188 // { int stat(char *path, struct stat *ub); } - SYS_FSTAT = 189 // { int fstat(int fd, struct stat *sb); } - SYS_LSTAT = 190 // { int lstat(char *path, struct stat *ub); } - SYS_PATHCONF = 191 // { int pathconf(char *path, int name); } - SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); } - SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \ - SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \ - SYS_GETDIRENTRIES = 196 // { int getdirentries(int fd, char *buf, \ - SYS_FREEBSD6_MMAP = 197 // { caddr_t freebsd6_mmap(caddr_t addr, \ - SYS_FREEBSD6_LSEEK = 199 // { off_t freebsd6_lseek(int fd, int pad, \ - SYS_FREEBSD6_TRUNCATE = 200 // { int freebsd6_truncate(char *path, int pad, \ - SYS_FREEBSD6_FTRUNCATE = 201 // { int freebsd6_ftruncate(int fd, int pad, \ - SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, \ - SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); } - SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); } - SYS_UNDELETE = 205 // { int undelete(char *path); } - SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); } - SYS_GETPGID = 207 // { int getpgid(pid_t pid); } - SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \ - SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \ - SYS_CLOCK_SETTIME = 233 // { int clock_settime( \ - SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \ - SYS_KTIMER_CREATE = 235 // { int ktimer_create(clockid_t clock_id, \ - SYS_KTIMER_DELETE = 236 // { int ktimer_delete(int timerid); } - SYS_KTIMER_SETTIME = 237 // { int ktimer_settime(int timerid, int flags, \ - SYS_KTIMER_GETTIME = 238 // { int ktimer_gettime(int timerid, struct \ - SYS_KTIMER_GETOVERRUN = 239 // { int ktimer_getoverrun(int timerid); } - SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \ - SYS_FFCLOCK_GETCOUNTER = 241 // { int ffclock_getcounter(ffcounter *ffcount); } - SYS_FFCLOCK_SETESTIMATE = 242 // { int ffclock_setestimate( \ - SYS_FFCLOCK_GETESTIMATE = 243 // { int ffclock_getestimate( \ - SYS_CLOCK_GETCPUCLOCKID2 = 247 // { int clock_getcpuclockid2(id_t id,\ - SYS_NTP_GETTIME = 248 // { int ntp_gettime(struct ntptimeval *ntvp); } - SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, \ - SYS_RFORK = 251 // { int rfork(int flags); } - SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, \ - SYS_ISSETUGID = 253 // { int issetugid(void); } - SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); } - SYS_GETDENTS = 272 // { int getdents(int fd, char *buf, \ - SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); } - SYS_LUTIMES = 276 // { int lutimes(char *path, \ - SYS_NSTAT = 278 // { int nstat(char *path, struct nstat *ub); } - SYS_NFSTAT = 279 // { int nfstat(int fd, struct nstat *sb); } - SYS_NLSTAT = 280 // { int nlstat(char *path, struct nstat *ub); } - SYS_PREADV = 289 // { ssize_t preadv(int fd, struct iovec *iovp, \ - SYS_PWRITEV = 290 // { ssize_t pwritev(int fd, struct iovec *iovp, \ - SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, \ - SYS_FHSTAT = 299 // { int fhstat(const struct fhandle *u_fhp, \ - SYS_MODNEXT = 300 // { int modnext(int modid); } - SYS_MODSTAT = 301 // { int modstat(int modid, \ - SYS_MODFNEXT = 302 // { int modfnext(int modid); } - SYS_MODFIND = 303 // { int modfind(const char *name); } - SYS_KLDLOAD = 304 // { int kldload(const char *file); } - SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); } - SYS_KLDFIND = 306 // { int kldfind(const char *file); } - SYS_KLDNEXT = 307 // { int kldnext(int fileid); } - SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct \ - SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); } - SYS_GETSID = 310 // { int getsid(pid_t pid); } - SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, \ - SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, \ - SYS_YIELD = 321 // { int yield(void); } - SYS_MLOCKALL = 324 // { int mlockall(int how); } - SYS_MUNLOCKALL = 325 // { int munlockall(void); } - SYS___GETCWD = 326 // { int __getcwd(char *buf, u_int buflen); } - SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, \ - SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct \ - SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int \ - SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); } - SYS_SCHED_YIELD = 331 // { int sched_yield (void); } - SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); } - SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); } - SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, \ - SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); } - SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, \ - SYS_JAIL = 338 // { int jail(struct jail *jail); } - SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, \ - SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); } - SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); } - SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set, \ - SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set, \ - SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \ - SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \ - SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, \ - SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, \ - SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \ - SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, \ - SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \ - SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, \ - SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \ - SYS_EXTATTR_SET_FILE = 356 // { ssize_t extattr_set_file( \ - SYS_EXTATTR_GET_FILE = 357 // { ssize_t extattr_get_file( \ - SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \ - SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, \ - SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, \ - SYS_KQUEUE = 362 // { int kqueue(void); } - SYS_KEVENT = 363 // { int kevent(int fd, \ - SYS_EXTATTR_SET_FD = 371 // { ssize_t extattr_set_fd(int fd, \ - SYS_EXTATTR_GET_FD = 372 // { ssize_t extattr_get_fd(int fd, \ - SYS_EXTATTR_DELETE_FD = 373 // { int extattr_delete_fd(int fd, \ - SYS___SETUGID = 374 // { int __setugid(int flag); } - SYS_EACCESS = 376 // { int eaccess(char *path, int amode); } - SYS_NMOUNT = 378 // { int nmount(struct iovec *iovp, \ - SYS___MAC_GET_PROC = 384 // { int __mac_get_proc(struct mac *mac_p); } - SYS___MAC_SET_PROC = 385 // { int __mac_set_proc(struct mac *mac_p); } - SYS___MAC_GET_FD = 386 // { int __mac_get_fd(int fd, \ - SYS___MAC_GET_FILE = 387 // { int __mac_get_file(const char *path_p, \ - SYS___MAC_SET_FD = 388 // { int __mac_set_fd(int fd, \ - SYS___MAC_SET_FILE = 389 // { int __mac_set_file(const char *path_p, \ - SYS_KENV = 390 // { int kenv(int what, const char *name, \ - SYS_LCHFLAGS = 391 // { int lchflags(const char *path, \ - SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, \ - SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, \ - SYS_MAC_SYSCALL = 394 // { int mac_syscall(const char *policy, \ - SYS_GETFSSTAT = 395 // { int getfsstat(struct statfs *buf, \ - SYS_STATFS = 396 // { int statfs(char *path, \ - SYS_FSTATFS = 397 // { int fstatfs(int fd, struct statfs *buf); } - SYS_FHSTATFS = 398 // { int fhstatfs(const struct fhandle *u_fhp, \ - SYS___MAC_GET_PID = 409 // { int __mac_get_pid(pid_t pid, \ - SYS___MAC_GET_LINK = 410 // { int __mac_get_link(const char *path_p, \ - SYS___MAC_SET_LINK = 411 // { int __mac_set_link(const char *path_p, \ - SYS_EXTATTR_SET_LINK = 412 // { ssize_t extattr_set_link( \ - SYS_EXTATTR_GET_LINK = 413 // { ssize_t extattr_get_link( \ - SYS_EXTATTR_DELETE_LINK = 414 // { int extattr_delete_link( \ - SYS___MAC_EXECVE = 415 // { int __mac_execve(char *fname, char **argv, \ - SYS_SIGACTION = 416 // { int sigaction(int sig, \ - SYS_SIGRETURN = 417 // { int sigreturn( \ - SYS_GETCONTEXT = 421 // { int getcontext(struct __ucontext *ucp); } - SYS_SETCONTEXT = 422 // { int setcontext( \ - SYS_SWAPCONTEXT = 423 // { int swapcontext(struct __ucontext *oucp, \ - SYS_SWAPOFF = 424 // { int swapoff(const char *name); } - SYS___ACL_GET_LINK = 425 // { int __acl_get_link(const char *path, \ - SYS___ACL_SET_LINK = 426 // { int __acl_set_link(const char *path, \ - SYS___ACL_DELETE_LINK = 427 // { int __acl_delete_link(const char *path, \ - SYS___ACL_ACLCHECK_LINK = 428 // { int __acl_aclcheck_link(const char *path, \ - SYS_SIGWAIT = 429 // { int sigwait(const sigset_t *set, \ - SYS_THR_CREATE = 430 // { int thr_create(ucontext_t *ctx, long *id, \ - SYS_THR_EXIT = 431 // { void thr_exit(long *state); } - SYS_THR_SELF = 432 // { int thr_self(long *id); } - SYS_THR_KILL = 433 // { int thr_kill(long id, int sig); } - SYS__UMTX_LOCK = 434 // { int _umtx_lock(struct umtx *umtx); } - SYS__UMTX_UNLOCK = 435 // { int _umtx_unlock(struct umtx *umtx); } - SYS_JAIL_ATTACH = 436 // { int jail_attach(int jid); } - SYS_EXTATTR_LIST_FD = 437 // { ssize_t extattr_list_fd(int fd, \ - SYS_EXTATTR_LIST_FILE = 438 // { ssize_t extattr_list_file( \ - SYS_EXTATTR_LIST_LINK = 439 // { ssize_t extattr_list_link( \ - SYS_THR_SUSPEND = 442 // { int thr_suspend( \ - SYS_THR_WAKE = 443 // { int thr_wake(long id); } - SYS_KLDUNLOADF = 444 // { int kldunloadf(int fileid, int flags); } - SYS_AUDIT = 445 // { int audit(const void *record, \ - SYS_AUDITON = 446 // { int auditon(int cmd, void *data, \ - SYS_GETAUID = 447 // { int getauid(uid_t *auid); } - SYS_SETAUID = 448 // { int setauid(uid_t *auid); } - SYS_GETAUDIT = 449 // { int getaudit(struct auditinfo *auditinfo); } - SYS_SETAUDIT = 450 // { int setaudit(struct auditinfo *auditinfo); } - SYS_GETAUDIT_ADDR = 451 // { int getaudit_addr( \ - SYS_SETAUDIT_ADDR = 452 // { int setaudit_addr( \ - SYS_AUDITCTL = 453 // { int auditctl(char *path); } - SYS__UMTX_OP = 454 // { int _umtx_op(void *obj, int op, \ - SYS_THR_NEW = 455 // { int thr_new(struct thr_param *param, \ - SYS_SIGQUEUE = 456 // { int sigqueue(pid_t pid, int signum, void *value); } - SYS_ABORT2 = 463 // { int abort2(const char *why, int nargs, void **args); } - SYS_THR_SET_NAME = 464 // { int thr_set_name(long id, const char *name); } - SYS_RTPRIO_THREAD = 466 // { int rtprio_thread(int function, \ - SYS_SCTP_PEELOFF = 471 // { int sctp_peeloff(int sd, uint32_t name); } - SYS_SCTP_GENERIC_SENDMSG = 472 // { int sctp_generic_sendmsg(int sd, caddr_t msg, int mlen, \ - SYS_SCTP_GENERIC_SENDMSG_IOV = 473 // { int sctp_generic_sendmsg_iov(int sd, struct iovec *iov, int iovlen, \ - SYS_SCTP_GENERIC_RECVMSG = 474 // { int sctp_generic_recvmsg(int sd, struct iovec *iov, int iovlen, \ - SYS_PREAD = 475 // { ssize_t pread(int fd, void *buf, \ - SYS_PWRITE = 476 // { ssize_t pwrite(int fd, const void *buf, \ - SYS_MMAP = 477 // { caddr_t mmap(caddr_t addr, size_t len, \ - SYS_LSEEK = 478 // { off_t lseek(int fd, off_t offset, \ - SYS_TRUNCATE = 479 // { int truncate(char *path, off_t length); } - SYS_FTRUNCATE = 480 // { int ftruncate(int fd, off_t length); } - SYS_THR_KILL2 = 481 // { int thr_kill2(pid_t pid, long id, int sig); } - SYS_SHM_OPEN = 482 // { int shm_open(const char *path, int flags, \ - SYS_SHM_UNLINK = 483 // { int shm_unlink(const char *path); } - SYS_CPUSET = 484 // { int cpuset(cpusetid_t *setid); } - SYS_CPUSET_SETID = 485 // { int cpuset_setid(cpuwhich_t which, id_t id, \ - SYS_CPUSET_GETID = 486 // { int cpuset_getid(cpulevel_t level, \ - SYS_CPUSET_GETAFFINITY = 487 // { int cpuset_getaffinity(cpulevel_t level, \ - SYS_CPUSET_SETAFFINITY = 488 // { int cpuset_setaffinity(cpulevel_t level, \ - SYS_FACCESSAT = 489 // { int faccessat(int fd, char *path, int amode, \ - SYS_FCHMODAT = 490 // { int fchmodat(int fd, char *path, mode_t mode, \ - SYS_FCHOWNAT = 491 // { int fchownat(int fd, char *path, uid_t uid, \ - SYS_FEXECVE = 492 // { int fexecve(int fd, char **argv, \ - SYS_FSTATAT = 493 // { int fstatat(int fd, char *path, \ - SYS_FUTIMESAT = 494 // { int futimesat(int fd, char *path, \ - SYS_LINKAT = 495 // { int linkat(int fd1, char *path1, int fd2, \ - SYS_MKDIRAT = 496 // { int mkdirat(int fd, char *path, mode_t mode); } - SYS_MKFIFOAT = 497 // { int mkfifoat(int fd, char *path, mode_t mode); } - SYS_MKNODAT = 498 // { int mknodat(int fd, char *path, mode_t mode, \ - SYS_OPENAT = 499 // { int openat(int fd, char *path, int flag, \ - SYS_READLINKAT = 500 // { int readlinkat(int fd, char *path, char *buf, \ - SYS_RENAMEAT = 501 // { int renameat(int oldfd, char *old, int newfd, \ - SYS_SYMLINKAT = 502 // { int symlinkat(char *path1, int fd, \ - SYS_UNLINKAT = 503 // { int unlinkat(int fd, char *path, int flag); } - SYS_POSIX_OPENPT = 504 // { int posix_openpt(int flags); } - SYS_JAIL_GET = 506 // { int jail_get(struct iovec *iovp, \ - SYS_JAIL_SET = 507 // { int jail_set(struct iovec *iovp, \ - SYS_JAIL_REMOVE = 508 // { int jail_remove(int jid); } - SYS_CLOSEFROM = 509 // { int closefrom(int lowfd); } - SYS_LPATHCONF = 513 // { int lpathconf(char *path, int name); } - SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); } - SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \ - SYS_CAP_ENTER = 516 // { int cap_enter(void); } - SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); } - SYS_PDFORK = 518 // { int pdfork(int *fdp, int flags); } - SYS_PDKILL = 519 // { int pdkill(int fd, int signum); } - SYS_PDGETPID = 520 // { int pdgetpid(int fd, pid_t *pidp); } - SYS_PSELECT = 522 // { int pselect(int nd, fd_set *in, \ - SYS_GETLOGINCLASS = 523 // { int getloginclass(char *namebuf, \ - SYS_SETLOGINCLASS = 524 // { int setloginclass(const char *namebuf); } - SYS_RCTL_GET_RACCT = 525 // { int rctl_get_racct(const void *inbufp, \ - SYS_RCTL_GET_RULES = 526 // { int rctl_get_rules(const void *inbufp, \ - SYS_RCTL_GET_LIMITS = 527 // { int rctl_get_limits(const void *inbufp, \ - SYS_RCTL_ADD_RULE = 528 // { int rctl_add_rule(const void *inbufp, \ - SYS_RCTL_REMOVE_RULE = 529 // { int rctl_remove_rule(const void *inbufp, \ - SYS_POSIX_FALLOCATE = 530 // { int posix_fallocate(int fd, \ - SYS_POSIX_FADVISE = 531 // { int posix_fadvise(int fd, off_t offset, \ - SYS_WAIT6 = 532 // { int wait6(idtype_t idtype, id_t id, \ - SYS_BINDAT = 538 // { int bindat(int fd, int s, caddr_t name, \ - SYS_CONNECTAT = 539 // { int connectat(int fd, int s, caddr_t name, \ - SYS_CHFLAGSAT = 540 // { int chflagsat(int fd, const char *path, \ - SYS_ACCEPT4 = 541 // { int accept4(int s, \ - SYS_PIPE2 = 542 // { int pipe2(int *fildes, int flags); } - SYS_PROCCTL = 544 // { int procctl(idtype_t idtype, id_t id, \ - SYS_PPOLL = 545 // { int ppoll(struct pollfd *fds, u_int nfds, \ + SYS_EXIT = 1 // { void sys_exit(int rval); } exit \ + SYS_FORK = 2 // { int fork(void); } + SYS_READ = 3 // { ssize_t read(int fd, void *buf, \ + SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, \ + SYS_OPEN = 5 // { int open(char *path, int flags, int mode); } + SYS_CLOSE = 6 // { int close(int fd); } + SYS_WAIT4 = 7 // { int wait4(int pid, int *status, \ + SYS_LINK = 9 // { int link(char *path, char *link); } + SYS_UNLINK = 10 // { int unlink(char *path); } + SYS_CHDIR = 12 // { int chdir(char *path); } + SYS_FCHDIR = 13 // { int fchdir(int fd); } + SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); } + SYS_CHMOD = 15 // { int chmod(char *path, int mode); } + SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); } + SYS_OBREAK = 17 // { int obreak(char *nsize); } break \ + SYS_GETPID = 20 // { pid_t getpid(void); } + SYS_MOUNT = 21 // { int mount(char *type, char *path, \ + SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); } + SYS_SETUID = 23 // { int setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t getuid(void); } + SYS_GETEUID = 25 // { uid_t geteuid(void); } + SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, \ + SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, \ + SYS_SENDMSG = 28 // { int sendmsg(int s, struct msghdr *msg, \ + SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, \ + SYS_ACCEPT = 30 // { int accept(int s, \ + SYS_GETPEERNAME = 31 // { int getpeername(int fdes, \ + SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, \ + SYS_ACCESS = 33 // { int access(char *path, int amode); } + SYS_CHFLAGS = 34 // { int chflags(const char *path, u_long flags); } + SYS_FCHFLAGS = 35 // { int fchflags(int fd, u_long flags); } + SYS_SYNC = 36 // { int sync(void); } + SYS_KILL = 37 // { int kill(int pid, int signum); } + SYS_GETPPID = 39 // { pid_t getppid(void); } + SYS_DUP = 41 // { int dup(u_int fd); } + SYS_PIPE = 42 // { int pipe(void); } + SYS_GETEGID = 43 // { gid_t getegid(void); } + SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \ + SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, \ + SYS_GETGID = 47 // { gid_t getgid(void); } + SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int \ + SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); } + SYS_ACCT = 51 // { int acct(char *path); } + SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, \ + SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, \ + SYS_REBOOT = 55 // { int reboot(int opt); } + SYS_REVOKE = 56 // { int revoke(char *path); } + SYS_SYMLINK = 57 // { int symlink(char *path, char *link); } + SYS_READLINK = 58 // { ssize_t readlink(char *path, char *buf, \ + SYS_EXECVE = 59 // { int execve(char *fname, char **argv, \ + SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args \ + SYS_CHROOT = 61 // { int chroot(char *path); } + SYS_MSYNC = 65 // { int msync(void *addr, size_t len, \ + SYS_VFORK = 66 // { int vfork(void); } + SYS_SBRK = 69 // { int sbrk(int incr); } + SYS_SSTK = 70 // { int sstk(int incr); } + SYS_OVADVISE = 72 // { int ovadvise(int anom); } vadvise \ + SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int mprotect(const void *addr, size_t len, \ + SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, \ + SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \ + SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, \ + SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, \ + SYS_GETPGRP = 81 // { int getpgrp(void); } + SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); } + SYS_SETITIMER = 83 // { int setitimer(u_int which, struct \ + SYS_SWAPON = 85 // { int swapon(char *name); } + SYS_GETITIMER = 86 // { int getitimer(u_int which, \ + SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); } + SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); } + SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); } + SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \ + SYS_FSYNC = 95 // { int fsync(int fd); } + SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, \ + SYS_SOCKET = 97 // { int socket(int domain, int type, \ + SYS_CONNECT = 98 // { int connect(int s, caddr_t name, \ + SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); } + SYS_BIND = 104 // { int bind(int s, caddr_t name, \ + SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \ + SYS_LISTEN = 106 // { int listen(int s, int backlog); } + SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \ + SYS_GETRUSAGE = 117 // { int getrusage(int who, \ + SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \ + SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, \ + SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \ + SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \ + SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); } + SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); } + SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); } + SYS_SETREGID = 127 // { int setregid(int rgid, int egid); } + SYS_RENAME = 128 // { int rename(char *from, char *to); } + SYS_FLOCK = 131 // { int flock(int fd, int how); } + SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); } + SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \ + SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, \ + SYS_MKDIR = 136 // { int mkdir(char *path, int mode); } + SYS_RMDIR = 137 // { int rmdir(char *path); } + SYS_UTIMES = 138 // { int utimes(char *path, \ + SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \ + SYS_SETSID = 147 // { int setsid(void); } + SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \ + SYS_LGETFH = 160 // { int lgetfh(char *fname, \ + SYS_GETFH = 161 // { int getfh(char *fname, \ + SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); } + SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \ + SYS_FREEBSD6_PREAD = 173 // { ssize_t freebsd6_pread(int fd, void *buf, \ + SYS_FREEBSD6_PWRITE = 174 // { ssize_t freebsd6_pwrite(int fd, \ + SYS_SETFIB = 175 // { int setfib(int fibnum); } + SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); } + SYS_SETGID = 181 // { int setgid(gid_t gid); } + SYS_SETEGID = 182 // { int setegid(gid_t egid); } + SYS_SETEUID = 183 // { int seteuid(uid_t euid); } + SYS_STAT = 188 // { int stat(char *path, struct stat *ub); } + SYS_FSTAT = 189 // { int fstat(int fd, struct stat *sb); } + SYS_LSTAT = 190 // { int lstat(char *path, struct stat *ub); } + SYS_PATHCONF = 191 // { int pathconf(char *path, int name); } + SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); } + SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \ + SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \ + SYS_GETDIRENTRIES = 196 // { int getdirentries(int fd, char *buf, \ + SYS_FREEBSD6_MMAP = 197 // { caddr_t freebsd6_mmap(caddr_t addr, \ + SYS_FREEBSD6_LSEEK = 199 // { off_t freebsd6_lseek(int fd, int pad, \ + SYS_FREEBSD6_TRUNCATE = 200 // { int freebsd6_truncate(char *path, int pad, \ + SYS_FREEBSD6_FTRUNCATE = 201 // { int freebsd6_ftruncate(int fd, int pad, \ + SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, \ + SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); } + SYS_UNDELETE = 205 // { int undelete(char *path); } + SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); } + SYS_GETPGID = 207 // { int getpgid(pid_t pid); } + SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \ + SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \ + SYS_CLOCK_SETTIME = 233 // { int clock_settime( \ + SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \ + SYS_KTIMER_CREATE = 235 // { int ktimer_create(clockid_t clock_id, \ + SYS_KTIMER_DELETE = 236 // { int ktimer_delete(int timerid); } + SYS_KTIMER_SETTIME = 237 // { int ktimer_settime(int timerid, int flags, \ + SYS_KTIMER_GETTIME = 238 // { int ktimer_gettime(int timerid, struct \ + SYS_KTIMER_GETOVERRUN = 239 // { int ktimer_getoverrun(int timerid); } + SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \ + SYS_FFCLOCK_GETCOUNTER = 241 // { int ffclock_getcounter(ffcounter *ffcount); } + SYS_FFCLOCK_SETESTIMATE = 242 // { int ffclock_setestimate( \ + SYS_FFCLOCK_GETESTIMATE = 243 // { int ffclock_getestimate( \ + SYS_CLOCK_GETCPUCLOCKID2 = 247 // { int clock_getcpuclockid2(id_t id,\ + SYS_NTP_GETTIME = 248 // { int ntp_gettime(struct ntptimeval *ntvp); } + SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, \ + SYS_RFORK = 251 // { int rfork(int flags); } + SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, \ + SYS_ISSETUGID = 253 // { int issetugid(void); } + SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); } + SYS_GETDENTS = 272 // { int getdents(int fd, char *buf, \ + SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); } + SYS_LUTIMES = 276 // { int lutimes(char *path, \ + SYS_NSTAT = 278 // { int nstat(char *path, struct nstat *ub); } + SYS_NFSTAT = 279 // { int nfstat(int fd, struct nstat *sb); } + SYS_NLSTAT = 280 // { int nlstat(char *path, struct nstat *ub); } + SYS_PREADV = 289 // { ssize_t preadv(int fd, struct iovec *iovp, \ + SYS_PWRITEV = 290 // { ssize_t pwritev(int fd, struct iovec *iovp, \ + SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, \ + SYS_FHSTAT = 299 // { int fhstat(const struct fhandle *u_fhp, \ + SYS_MODNEXT = 300 // { int modnext(int modid); } + SYS_MODSTAT = 301 // { int modstat(int modid, \ + SYS_MODFNEXT = 302 // { int modfnext(int modid); } + SYS_MODFIND = 303 // { int modfind(const char *name); } + SYS_KLDLOAD = 304 // { int kldload(const char *file); } + SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); } + SYS_KLDFIND = 306 // { int kldfind(const char *file); } + SYS_KLDNEXT = 307 // { int kldnext(int fileid); } + SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct \ + SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); } + SYS_GETSID = 310 // { int getsid(pid_t pid); } + SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, \ + SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, \ + SYS_YIELD = 321 // { int yield(void); } + SYS_MLOCKALL = 324 // { int mlockall(int how); } + SYS_MUNLOCKALL = 325 // { int munlockall(void); } + SYS___GETCWD = 326 // { int __getcwd(char *buf, u_int buflen); } + SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, \ + SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct \ + SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int \ + SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); } + SYS_SCHED_YIELD = 331 // { int sched_yield (void); } + SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); } + SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); } + SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, \ + SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); } + SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, \ + SYS_JAIL = 338 // { int jail(struct jail *jail); } + SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, \ + SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); } + SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); } + SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set, \ + SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set, \ + SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \ + SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \ + SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, \ + SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, \ + SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \ + SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, \ + SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \ + SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, \ + SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \ + SYS_EXTATTR_SET_FILE = 356 // { ssize_t extattr_set_file( \ + SYS_EXTATTR_GET_FILE = 357 // { ssize_t extattr_get_file( \ + SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \ + SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, \ + SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, \ + SYS_KQUEUE = 362 // { int kqueue(void); } + SYS_KEVENT = 363 // { int kevent(int fd, \ + SYS_EXTATTR_SET_FD = 371 // { ssize_t extattr_set_fd(int fd, \ + SYS_EXTATTR_GET_FD = 372 // { ssize_t extattr_get_fd(int fd, \ + SYS_EXTATTR_DELETE_FD = 373 // { int extattr_delete_fd(int fd, \ + SYS___SETUGID = 374 // { int __setugid(int flag); } + SYS_EACCESS = 376 // { int eaccess(char *path, int amode); } + SYS_NMOUNT = 378 // { int nmount(struct iovec *iovp, \ + SYS___MAC_GET_PROC = 384 // { int __mac_get_proc(struct mac *mac_p); } + SYS___MAC_SET_PROC = 385 // { int __mac_set_proc(struct mac *mac_p); } + SYS___MAC_GET_FD = 386 // { int __mac_get_fd(int fd, \ + SYS___MAC_GET_FILE = 387 // { int __mac_get_file(const char *path_p, \ + SYS___MAC_SET_FD = 388 // { int __mac_set_fd(int fd, \ + SYS___MAC_SET_FILE = 389 // { int __mac_set_file(const char *path_p, \ + SYS_KENV = 390 // { int kenv(int what, const char *name, \ + SYS_LCHFLAGS = 391 // { int lchflags(const char *path, \ + SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, \ + SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, \ + SYS_MAC_SYSCALL = 394 // { int mac_syscall(const char *policy, \ + SYS_GETFSSTAT = 395 // { int getfsstat(struct statfs *buf, \ + SYS_STATFS = 396 // { int statfs(char *path, \ + SYS_FSTATFS = 397 // { int fstatfs(int fd, struct statfs *buf); } + SYS_FHSTATFS = 398 // { int fhstatfs(const struct fhandle *u_fhp, \ + SYS___MAC_GET_PID = 409 // { int __mac_get_pid(pid_t pid, \ + SYS___MAC_GET_LINK = 410 // { int __mac_get_link(const char *path_p, \ + SYS___MAC_SET_LINK = 411 // { int __mac_set_link(const char *path_p, \ + SYS_EXTATTR_SET_LINK = 412 // { ssize_t extattr_set_link( \ + SYS_EXTATTR_GET_LINK = 413 // { ssize_t extattr_get_link( \ + SYS_EXTATTR_DELETE_LINK = 414 // { int extattr_delete_link( \ + SYS___MAC_EXECVE = 415 // { int __mac_execve(char *fname, char **argv, \ + SYS_SIGACTION = 416 // { int sigaction(int sig, \ + SYS_SIGRETURN = 417 // { int sigreturn( \ + SYS_GETCONTEXT = 421 // { int getcontext(struct __ucontext *ucp); } + SYS_SETCONTEXT = 422 // { int setcontext( \ + SYS_SWAPCONTEXT = 423 // { int swapcontext(struct __ucontext *oucp, \ + SYS_SWAPOFF = 424 // { int swapoff(const char *name); } + SYS___ACL_GET_LINK = 425 // { int __acl_get_link(const char *path, \ + SYS___ACL_SET_LINK = 426 // { int __acl_set_link(const char *path, \ + SYS___ACL_DELETE_LINK = 427 // { int __acl_delete_link(const char *path, \ + SYS___ACL_ACLCHECK_LINK = 428 // { int __acl_aclcheck_link(const char *path, \ + SYS_SIGWAIT = 429 // { int sigwait(const sigset_t *set, \ + SYS_THR_CREATE = 430 // { int thr_create(ucontext_t *ctx, long *id, \ + SYS_THR_EXIT = 431 // { void thr_exit(long *state); } + SYS_THR_SELF = 432 // { int thr_self(long *id); } + SYS_THR_KILL = 433 // { int thr_kill(long id, int sig); } + SYS__UMTX_LOCK = 434 // { int _umtx_lock(struct umtx *umtx); } + SYS__UMTX_UNLOCK = 435 // { int _umtx_unlock(struct umtx *umtx); } + SYS_JAIL_ATTACH = 436 // { int jail_attach(int jid); } + SYS_EXTATTR_LIST_FD = 437 // { ssize_t extattr_list_fd(int fd, \ + SYS_EXTATTR_LIST_FILE = 438 // { ssize_t extattr_list_file( \ + SYS_EXTATTR_LIST_LINK = 439 // { ssize_t extattr_list_link( \ + SYS_THR_SUSPEND = 442 // { int thr_suspend( \ + SYS_THR_WAKE = 443 // { int thr_wake(long id); } + SYS_KLDUNLOADF = 444 // { int kldunloadf(int fileid, int flags); } + SYS_AUDIT = 445 // { int audit(const void *record, \ + SYS_AUDITON = 446 // { int auditon(int cmd, void *data, \ + SYS_GETAUID = 447 // { int getauid(uid_t *auid); } + SYS_SETAUID = 448 // { int setauid(uid_t *auid); } + SYS_GETAUDIT = 449 // { int getaudit(struct auditinfo *auditinfo); } + SYS_SETAUDIT = 450 // { int setaudit(struct auditinfo *auditinfo); } + SYS_GETAUDIT_ADDR = 451 // { int getaudit_addr( \ + SYS_SETAUDIT_ADDR = 452 // { int setaudit_addr( \ + SYS_AUDITCTL = 453 // { int auditctl(char *path); } + SYS__UMTX_OP = 454 // { int _umtx_op(void *obj, int op, \ + SYS_THR_NEW = 455 // { int thr_new(struct thr_param *param, \ + SYS_SIGQUEUE = 456 // { int sigqueue(pid_t pid, int signum, void *value); } + SYS_ABORT2 = 463 // { int abort2(const char *why, int nargs, void **args); } + SYS_THR_SET_NAME = 464 // { int thr_set_name(long id, const char *name); } + SYS_RTPRIO_THREAD = 466 // { int rtprio_thread(int function, \ + SYS_PREAD = 475 // { ssize_t pread(int fd, void *buf, \ + SYS_PWRITE = 476 // { ssize_t pwrite(int fd, const void *buf, \ + SYS_MMAP = 477 // { caddr_t mmap(caddr_t addr, size_t len, \ + SYS_LSEEK = 478 // { off_t lseek(int fd, off_t offset, \ + SYS_TRUNCATE = 479 // { int truncate(char *path, off_t length); } + SYS_FTRUNCATE = 480 // { int ftruncate(int fd, off_t length); } + SYS_THR_KILL2 = 481 // { int thr_kill2(pid_t pid, long id, int sig); } + SYS_SHM_OPEN = 482 // { int shm_open(const char *path, int flags, \ + SYS_SHM_UNLINK = 483 // { int shm_unlink(const char *path); } + SYS_CPUSET = 484 // { int cpuset(cpusetid_t *setid); } + SYS_CPUSET_SETID = 485 // { int cpuset_setid(cpuwhich_t which, id_t id, \ + SYS_CPUSET_GETID = 486 // { int cpuset_getid(cpulevel_t level, \ + SYS_CPUSET_GETAFFINITY = 487 // { int cpuset_getaffinity(cpulevel_t level, \ + SYS_CPUSET_SETAFFINITY = 488 // { int cpuset_setaffinity(cpulevel_t level, \ + SYS_FACCESSAT = 489 // { int faccessat(int fd, char *path, int amode, \ + SYS_FCHMODAT = 490 // { int fchmodat(int fd, char *path, mode_t mode, \ + SYS_FCHOWNAT = 491 // { int fchownat(int fd, char *path, uid_t uid, \ + SYS_FEXECVE = 492 // { int fexecve(int fd, char **argv, \ + SYS_FSTATAT = 493 // { int fstatat(int fd, char *path, \ + SYS_FUTIMESAT = 494 // { int futimesat(int fd, char *path, \ + SYS_LINKAT = 495 // { int linkat(int fd1, char *path1, int fd2, \ + SYS_MKDIRAT = 496 // { int mkdirat(int fd, char *path, mode_t mode); } + SYS_MKFIFOAT = 497 // { int mkfifoat(int fd, char *path, mode_t mode); } + SYS_MKNODAT = 498 // { int mknodat(int fd, char *path, mode_t mode, \ + SYS_OPENAT = 499 // { int openat(int fd, char *path, int flag, \ + SYS_READLINKAT = 500 // { int readlinkat(int fd, char *path, char *buf, \ + SYS_RENAMEAT = 501 // { int renameat(int oldfd, char *old, int newfd, \ + SYS_SYMLINKAT = 502 // { int symlinkat(char *path1, int fd, \ + SYS_UNLINKAT = 503 // { int unlinkat(int fd, char *path, int flag); } + SYS_POSIX_OPENPT = 504 // { int posix_openpt(int flags); } + SYS_JAIL_GET = 506 // { int jail_get(struct iovec *iovp, \ + SYS_JAIL_SET = 507 // { int jail_set(struct iovec *iovp, \ + SYS_JAIL_REMOVE = 508 // { int jail_remove(int jid); } + SYS_CLOSEFROM = 509 // { int closefrom(int lowfd); } + SYS_LPATHCONF = 513 // { int lpathconf(char *path, int name); } + SYS___CAP_RIGHTS_GET = 515 // { int __cap_rights_get(int version, \ + SYS_CAP_ENTER = 516 // { int cap_enter(void); } + SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); } + SYS_PDFORK = 518 // { int pdfork(int *fdp, int flags); } + SYS_PDKILL = 519 // { int pdkill(int fd, int signum); } + SYS_PDGETPID = 520 // { int pdgetpid(int fd, pid_t *pidp); } + SYS_PSELECT = 522 // { int pselect(int nd, fd_set *in, \ + SYS_GETLOGINCLASS = 523 // { int getloginclass(char *namebuf, \ + SYS_SETLOGINCLASS = 524 // { int setloginclass(const char *namebuf); } + SYS_RCTL_GET_RACCT = 525 // { int rctl_get_racct(const void *inbufp, \ + SYS_RCTL_GET_RULES = 526 // { int rctl_get_rules(const void *inbufp, \ + SYS_RCTL_GET_LIMITS = 527 // { int rctl_get_limits(const void *inbufp, \ + SYS_RCTL_ADD_RULE = 528 // { int rctl_add_rule(const void *inbufp, \ + SYS_RCTL_REMOVE_RULE = 529 // { int rctl_remove_rule(const void *inbufp, \ + SYS_POSIX_FALLOCATE = 530 // { int posix_fallocate(int fd, \ + SYS_POSIX_FADVISE = 531 // { int posix_fadvise(int fd, off_t offset, \ + SYS_WAIT6 = 532 // { int wait6(idtype_t idtype, id_t id, \ + SYS_CAP_RIGHTS_LIMIT = 533 // { int cap_rights_limit(int fd, \ + SYS_CAP_IOCTLS_LIMIT = 534 // { int cap_ioctls_limit(int fd, \ + SYS_CAP_IOCTLS_GET = 535 // { ssize_t cap_ioctls_get(int fd, \ + SYS_CAP_FCNTLS_LIMIT = 536 // { int cap_fcntls_limit(int fd, \ + SYS_CAP_FCNTLS_GET = 537 // { int cap_fcntls_get(int fd, \ + SYS_BINDAT = 538 // { int bindat(int fd, int s, caddr_t name, \ + SYS_CONNECTAT = 539 // { int connectat(int fd, int s, caddr_t name, \ + SYS_CHFLAGSAT = 540 // { int chflagsat(int fd, const char *path, \ + SYS_ACCEPT4 = 541 // { int accept4(int s, \ + SYS_PIPE2 = 542 // { int pipe2(int *fildes, int flags); } + SYS_PROCCTL = 544 // { int procctl(idtype_t idtype, id_t id, \ + SYS_PPOLL = 545 // { int ppoll(struct pollfd *fds, u_int nfds, \ + SYS_FUTIMENS = 546 // { int futimens(int fd, \ + SYS_UTIMENSAT = 547 // { int utimensat(int fd, \ ) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go index f60d8f988..8afda9c45 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go @@ -134,6 +134,7 @@ const ( SYS_MINHERIT = 273 // { int|sys||minherit(void *addr, size_t len, int inherit); } SYS_LCHMOD = 274 // { int|sys||lchmod(const char *path, mode_t mode); } SYS_LCHOWN = 275 // { int|sys||lchown(const char *path, uid_t uid, gid_t gid); } + SYS_MSYNC = 277 // { int|sys|13|msync(void *addr, size_t len, int flags); } SYS___POSIX_CHOWN = 283 // { int|sys||__posix_chown(const char *path, uid_t uid, gid_t gid); } SYS___POSIX_FCHOWN = 284 // { int|sys||__posix_fchown(int fd, uid_t uid, gid_t gid); } SYS___POSIX_LCHOWN = 285 // { int|sys||__posix_lchown(const char *path, uid_t uid, gid_t gid); } diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go index 48a91d464..aea8dbec4 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go @@ -134,6 +134,7 @@ const ( SYS_MINHERIT = 273 // { int|sys||minherit(void *addr, size_t len, int inherit); } SYS_LCHMOD = 274 // { int|sys||lchmod(const char *path, mode_t mode); } SYS_LCHOWN = 275 // { int|sys||lchown(const char *path, uid_t uid, gid_t gid); } + SYS_MSYNC = 277 // { int|sys|13|msync(void *addr, size_t len, int flags); } SYS___POSIX_CHOWN = 283 // { int|sys||__posix_chown(const char *path, uid_t uid, gid_t gid); } SYS___POSIX_FCHOWN = 284 // { int|sys||__posix_fchown(int fd, uid_t uid, gid_t gid); } SYS___POSIX_LCHOWN = 285 // { int|sys||__posix_lchown(const char *path, uid_t uid, gid_t gid); } diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go index 612ba662c..c6158a7ef 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go @@ -134,6 +134,7 @@ const ( SYS_MINHERIT = 273 // { int|sys||minherit(void *addr, size_t len, int inherit); } SYS_LCHMOD = 274 // { int|sys||lchmod(const char *path, mode_t mode); } SYS_LCHOWN = 275 // { int|sys||lchown(const char *path, uid_t uid, gid_t gid); } + SYS_MSYNC = 277 // { int|sys|13|msync(void *addr, size_t len, int flags); } SYS___POSIX_CHOWN = 283 // { int|sys||__posix_chown(const char *path, uid_t uid, gid_t gid); } SYS___POSIX_FCHOWN = 284 // { int|sys||__posix_fchown(int fd, uid_t uid, gid_t gid); } SYS___POSIX_LCHOWN = 285 // { int|sys||__posix_lchown(const char *path, uid_t uid, gid_t gid); } diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go new file mode 100644 index 000000000..32653e53c --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go @@ -0,0 +1,213 @@ +// mksysnum_openbsd.pl +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build arm,openbsd + +package unix + +const ( + SYS_EXIT = 1 // { void sys_exit(int rval); } + SYS_FORK = 2 // { int sys_fork(void); } + SYS_READ = 3 // { ssize_t sys_read(int fd, void *buf, size_t nbyte); } + SYS_WRITE = 4 // { ssize_t sys_write(int fd, const void *buf, \ + SYS_OPEN = 5 // { int sys_open(const char *path, \ + SYS_CLOSE = 6 // { int sys_close(int fd); } + SYS_GETENTROPY = 7 // { int sys_getentropy(void *buf, size_t nbyte); } + SYS___TFORK = 8 // { int sys___tfork(const struct __tfork *param, \ + SYS_LINK = 9 // { int sys_link(const char *path, const char *link); } + SYS_UNLINK = 10 // { int sys_unlink(const char *path); } + SYS_WAIT4 = 11 // { pid_t sys_wait4(pid_t pid, int *status, \ + SYS_CHDIR = 12 // { int sys_chdir(const char *path); } + SYS_FCHDIR = 13 // { int sys_fchdir(int fd); } + SYS_MKNOD = 14 // { int sys_mknod(const char *path, mode_t mode, \ + SYS_CHMOD = 15 // { int sys_chmod(const char *path, mode_t mode); } + SYS_CHOWN = 16 // { int sys_chown(const char *path, uid_t uid, \ + SYS_OBREAK = 17 // { int sys_obreak(char *nsize); } break + SYS_GETDTABLECOUNT = 18 // { int sys_getdtablecount(void); } + SYS_GETRUSAGE = 19 // { int sys_getrusage(int who, \ + SYS_GETPID = 20 // { pid_t sys_getpid(void); } + SYS_MOUNT = 21 // { int sys_mount(const char *type, const char *path, \ + SYS_UNMOUNT = 22 // { int sys_unmount(const char *path, int flags); } + SYS_SETUID = 23 // { int sys_setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t sys_getuid(void); } + SYS_GETEUID = 25 // { uid_t sys_geteuid(void); } + SYS_PTRACE = 26 // { int sys_ptrace(int req, pid_t pid, caddr_t addr, \ + SYS_RECVMSG = 27 // { ssize_t sys_recvmsg(int s, struct msghdr *msg, \ + SYS_SENDMSG = 28 // { ssize_t sys_sendmsg(int s, \ + SYS_RECVFROM = 29 // { ssize_t sys_recvfrom(int s, void *buf, size_t len, \ + SYS_ACCEPT = 30 // { int sys_accept(int s, struct sockaddr *name, \ + SYS_GETPEERNAME = 31 // { int sys_getpeername(int fdes, struct sockaddr *asa, \ + SYS_GETSOCKNAME = 32 // { int sys_getsockname(int fdes, struct sockaddr *asa, \ + SYS_ACCESS = 33 // { int sys_access(const char *path, int amode); } + SYS_CHFLAGS = 34 // { int sys_chflags(const char *path, u_int flags); } + SYS_FCHFLAGS = 35 // { int sys_fchflags(int fd, u_int flags); } + SYS_SYNC = 36 // { void sys_sync(void); } + SYS_STAT = 38 // { int sys_stat(const char *path, struct stat *ub); } + SYS_GETPPID = 39 // { pid_t sys_getppid(void); } + SYS_LSTAT = 40 // { int sys_lstat(const char *path, struct stat *ub); } + SYS_DUP = 41 // { int sys_dup(int fd); } + SYS_FSTATAT = 42 // { int sys_fstatat(int fd, const char *path, \ + SYS_GETEGID = 43 // { gid_t sys_getegid(void); } + SYS_PROFIL = 44 // { int sys_profil(caddr_t samples, size_t size, \ + SYS_KTRACE = 45 // { int sys_ktrace(const char *fname, int ops, \ + SYS_SIGACTION = 46 // { int sys_sigaction(int signum, \ + SYS_GETGID = 47 // { gid_t sys_getgid(void); } + SYS_SIGPROCMASK = 48 // { int sys_sigprocmask(int how, sigset_t mask); } + SYS_GETLOGIN = 49 // { int sys_getlogin(char *namebuf, u_int namelen); } + SYS_SETLOGIN = 50 // { int sys_setlogin(const char *namebuf); } + SYS_ACCT = 51 // { int sys_acct(const char *path); } + SYS_SIGPENDING = 52 // { int sys_sigpending(void); } + SYS_FSTAT = 53 // { int sys_fstat(int fd, struct stat *sb); } + SYS_IOCTL = 54 // { int sys_ioctl(int fd, \ + SYS_REBOOT = 55 // { int sys_reboot(int opt); } + SYS_REVOKE = 56 // { int sys_revoke(const char *path); } + SYS_SYMLINK = 57 // { int sys_symlink(const char *path, \ + SYS_READLINK = 58 // { ssize_t sys_readlink(const char *path, \ + SYS_EXECVE = 59 // { int sys_execve(const char *path, \ + SYS_UMASK = 60 // { mode_t sys_umask(mode_t newmask); } + SYS_CHROOT = 61 // { int sys_chroot(const char *path); } + SYS_GETFSSTAT = 62 // { int sys_getfsstat(struct statfs *buf, size_t bufsize, \ + SYS_STATFS = 63 // { int sys_statfs(const char *path, \ + SYS_FSTATFS = 64 // { int sys_fstatfs(int fd, struct statfs *buf); } + SYS_FHSTATFS = 65 // { int sys_fhstatfs(const fhandle_t *fhp, \ + SYS_VFORK = 66 // { int sys_vfork(void); } + SYS_GETTIMEOFDAY = 67 // { int sys_gettimeofday(struct timeval *tp, \ + SYS_SETTIMEOFDAY = 68 // { int sys_settimeofday(const struct timeval *tv, \ + SYS_SETITIMER = 69 // { int sys_setitimer(int which, \ + SYS_GETITIMER = 70 // { int sys_getitimer(int which, \ + SYS_SELECT = 71 // { int sys_select(int nd, fd_set *in, fd_set *ou, \ + SYS_KEVENT = 72 // { int sys_kevent(int fd, \ + SYS_MUNMAP = 73 // { int sys_munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int sys_mprotect(void *addr, size_t len, \ + SYS_MADVISE = 75 // { int sys_madvise(void *addr, size_t len, \ + SYS_UTIMES = 76 // { int sys_utimes(const char *path, \ + SYS_FUTIMES = 77 // { int sys_futimes(int fd, \ + SYS_MINCORE = 78 // { int sys_mincore(void *addr, size_t len, \ + SYS_GETGROUPS = 79 // { int sys_getgroups(int gidsetsize, \ + SYS_SETGROUPS = 80 // { int sys_setgroups(int gidsetsize, \ + SYS_GETPGRP = 81 // { int sys_getpgrp(void); } + SYS_SETPGID = 82 // { int sys_setpgid(pid_t pid, pid_t pgid); } + SYS_SENDSYSLOG = 83 // { int sys_sendsyslog(const void *buf, size_t nbyte); } + SYS_UTIMENSAT = 84 // { int sys_utimensat(int fd, const char *path, \ + SYS_FUTIMENS = 85 // { int sys_futimens(int fd, \ + SYS_CLOCK_GETTIME = 87 // { int sys_clock_gettime(clockid_t clock_id, \ + SYS_CLOCK_SETTIME = 88 // { int sys_clock_settime(clockid_t clock_id, \ + SYS_CLOCK_GETRES = 89 // { int sys_clock_getres(clockid_t clock_id, \ + SYS_DUP2 = 90 // { int sys_dup2(int from, int to); } + SYS_NANOSLEEP = 91 // { int sys_nanosleep(const struct timespec *rqtp, \ + SYS_FCNTL = 92 // { int sys_fcntl(int fd, int cmd, ... void *arg); } + SYS_ACCEPT4 = 93 // { int sys_accept4(int s, struct sockaddr *name, \ + SYS___THRSLEEP = 94 // { int sys___thrsleep(const volatile void *ident, \ + SYS_FSYNC = 95 // { int sys_fsync(int fd); } + SYS_SETPRIORITY = 96 // { int sys_setpriority(int which, id_t who, int prio); } + SYS_SOCKET = 97 // { int sys_socket(int domain, int type, int protocol); } + SYS_CONNECT = 98 // { int sys_connect(int s, const struct sockaddr *name, \ + SYS_GETDENTS = 99 // { int sys_getdents(int fd, void *buf, size_t buflen); } + SYS_GETPRIORITY = 100 // { int sys_getpriority(int which, id_t who); } + SYS_PIPE2 = 101 // { int sys_pipe2(int *fdp, int flags); } + SYS_DUP3 = 102 // { int sys_dup3(int from, int to, int flags); } + SYS_SIGRETURN = 103 // { int sys_sigreturn(struct sigcontext *sigcntxp); } + SYS_BIND = 104 // { int sys_bind(int s, const struct sockaddr *name, \ + SYS_SETSOCKOPT = 105 // { int sys_setsockopt(int s, int level, int name, \ + SYS_LISTEN = 106 // { int sys_listen(int s, int backlog); } + SYS_CHFLAGSAT = 107 // { int sys_chflagsat(int fd, const char *path, \ + SYS_PPOLL = 109 // { int sys_ppoll(struct pollfd *fds, \ + SYS_PSELECT = 110 // { int sys_pselect(int nd, fd_set *in, fd_set *ou, \ + SYS_SIGSUSPEND = 111 // { int sys_sigsuspend(int mask); } + SYS_GETSOCKOPT = 118 // { int sys_getsockopt(int s, int level, int name, \ + SYS_READV = 120 // { ssize_t sys_readv(int fd, \ + SYS_WRITEV = 121 // { ssize_t sys_writev(int fd, \ + SYS_KILL = 122 // { int sys_kill(int pid, int signum); } + SYS_FCHOWN = 123 // { int sys_fchown(int fd, uid_t uid, gid_t gid); } + SYS_FCHMOD = 124 // { int sys_fchmod(int fd, mode_t mode); } + SYS_SETREUID = 126 // { int sys_setreuid(uid_t ruid, uid_t euid); } + SYS_SETREGID = 127 // { int sys_setregid(gid_t rgid, gid_t egid); } + SYS_RENAME = 128 // { int sys_rename(const char *from, const char *to); } + SYS_FLOCK = 131 // { int sys_flock(int fd, int how); } + SYS_MKFIFO = 132 // { int sys_mkfifo(const char *path, mode_t mode); } + SYS_SENDTO = 133 // { ssize_t sys_sendto(int s, const void *buf, \ + SYS_SHUTDOWN = 134 // { int sys_shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int sys_socketpair(int domain, int type, \ + SYS_MKDIR = 136 // { int sys_mkdir(const char *path, mode_t mode); } + SYS_RMDIR = 137 // { int sys_rmdir(const char *path); } + SYS_ADJTIME = 140 // { int sys_adjtime(const struct timeval *delta, \ + SYS_SETSID = 147 // { int sys_setsid(void); } + SYS_QUOTACTL = 148 // { int sys_quotactl(const char *path, int cmd, \ + SYS_NFSSVC = 155 // { int sys_nfssvc(int flag, void *argp); } + SYS_GETFH = 161 // { int sys_getfh(const char *fname, fhandle_t *fhp); } + SYS_SYSARCH = 165 // { int sys_sysarch(int op, void *parms); } + SYS_PREAD = 173 // { ssize_t sys_pread(int fd, void *buf, \ + SYS_PWRITE = 174 // { ssize_t sys_pwrite(int fd, const void *buf, \ + SYS_SETGID = 181 // { int sys_setgid(gid_t gid); } + SYS_SETEGID = 182 // { int sys_setegid(gid_t egid); } + SYS_SETEUID = 183 // { int sys_seteuid(uid_t euid); } + SYS_PATHCONF = 191 // { long sys_pathconf(const char *path, int name); } + SYS_FPATHCONF = 192 // { long sys_fpathconf(int fd, int name); } + SYS_SWAPCTL = 193 // { int sys_swapctl(int cmd, const void *arg, int misc); } + SYS_GETRLIMIT = 194 // { int sys_getrlimit(int which, \ + SYS_SETRLIMIT = 195 // { int sys_setrlimit(int which, \ + SYS_MMAP = 197 // { void *sys_mmap(void *addr, size_t len, int prot, \ + SYS_LSEEK = 199 // { off_t sys_lseek(int fd, int pad, off_t offset, \ + SYS_TRUNCATE = 200 // { int sys_truncate(const char *path, int pad, \ + SYS_FTRUNCATE = 201 // { int sys_ftruncate(int fd, int pad, off_t length); } + SYS___SYSCTL = 202 // { int sys___sysctl(const int *name, u_int namelen, \ + SYS_MLOCK = 203 // { int sys_mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int sys_munlock(const void *addr, size_t len); } + SYS_GETPGID = 207 // { pid_t sys_getpgid(pid_t pid); } + SYS_UTRACE = 209 // { int sys_utrace(const char *label, const void *addr, \ + SYS_SEMGET = 221 // { int sys_semget(key_t key, int nsems, int semflg); } + SYS_MSGGET = 225 // { int sys_msgget(key_t key, int msgflg); } + SYS_MSGSND = 226 // { int sys_msgsnd(int msqid, const void *msgp, size_t msgsz, \ + SYS_MSGRCV = 227 // { int sys_msgrcv(int msqid, void *msgp, size_t msgsz, \ + SYS_SHMAT = 228 // { void *sys_shmat(int shmid, const void *shmaddr, \ + SYS_SHMDT = 230 // { int sys_shmdt(const void *shmaddr); } + SYS_MINHERIT = 250 // { int sys_minherit(void *addr, size_t len, \ + SYS_POLL = 252 // { int sys_poll(struct pollfd *fds, \ + SYS_ISSETUGID = 253 // { int sys_issetugid(void); } + SYS_LCHOWN = 254 // { int sys_lchown(const char *path, uid_t uid, gid_t gid); } + SYS_GETSID = 255 // { pid_t sys_getsid(pid_t pid); } + SYS_MSYNC = 256 // { int sys_msync(void *addr, size_t len, int flags); } + SYS_PIPE = 263 // { int sys_pipe(int *fdp); } + SYS_FHOPEN = 264 // { int sys_fhopen(const fhandle_t *fhp, int flags); } + SYS_PREADV = 267 // { ssize_t sys_preadv(int fd, \ + SYS_PWRITEV = 268 // { ssize_t sys_pwritev(int fd, \ + SYS_KQUEUE = 269 // { int sys_kqueue(void); } + SYS_MLOCKALL = 271 // { int sys_mlockall(int flags); } + SYS_MUNLOCKALL = 272 // { int sys_munlockall(void); } + SYS_GETRESUID = 281 // { int sys_getresuid(uid_t *ruid, uid_t *euid, \ + SYS_SETRESUID = 282 // { int sys_setresuid(uid_t ruid, uid_t euid, \ + SYS_GETRESGID = 283 // { int sys_getresgid(gid_t *rgid, gid_t *egid, \ + SYS_SETRESGID = 284 // { int sys_setresgid(gid_t rgid, gid_t egid, \ + SYS_MQUERY = 286 // { void *sys_mquery(void *addr, size_t len, int prot, \ + SYS_CLOSEFROM = 287 // { int sys_closefrom(int fd); } + SYS_SIGALTSTACK = 288 // { int sys_sigaltstack(const struct sigaltstack *nss, \ + SYS_SHMGET = 289 // { int sys_shmget(key_t key, size_t size, int shmflg); } + SYS_SEMOP = 290 // { int sys_semop(int semid, struct sembuf *sops, \ + SYS_FHSTAT = 294 // { int sys_fhstat(const fhandle_t *fhp, \ + SYS___SEMCTL = 295 // { int sys___semctl(int semid, int semnum, int cmd, \ + SYS_SHMCTL = 296 // { int sys_shmctl(int shmid, int cmd, \ + SYS_MSGCTL = 297 // { int sys_msgctl(int msqid, int cmd, \ + SYS_SCHED_YIELD = 298 // { int sys_sched_yield(void); } + SYS_GETTHRID = 299 // { pid_t sys_getthrid(void); } + SYS___THRWAKEUP = 301 // { int sys___thrwakeup(const volatile void *ident, \ + SYS___THREXIT = 302 // { void sys___threxit(pid_t *notdead); } + SYS___THRSIGDIVERT = 303 // { int sys___thrsigdivert(sigset_t sigmask, \ + SYS___GETCWD = 304 // { int sys___getcwd(char *buf, size_t len); } + SYS_ADJFREQ = 305 // { int sys_adjfreq(const int64_t *freq, \ + SYS_SETRTABLE = 310 // { int sys_setrtable(int rtableid); } + SYS_GETRTABLE = 311 // { int sys_getrtable(void); } + SYS_FACCESSAT = 313 // { int sys_faccessat(int fd, const char *path, \ + SYS_FCHMODAT = 314 // { int sys_fchmodat(int fd, const char *path, \ + SYS_FCHOWNAT = 315 // { int sys_fchownat(int fd, const char *path, \ + SYS_LINKAT = 317 // { int sys_linkat(int fd1, const char *path1, int fd2, \ + SYS_MKDIRAT = 318 // { int sys_mkdirat(int fd, const char *path, \ + SYS_MKFIFOAT = 319 // { int sys_mkfifoat(int fd, const char *path, \ + SYS_MKNODAT = 320 // { int sys_mknodat(int fd, const char *path, \ + SYS_OPENAT = 321 // { int sys_openat(int fd, const char *path, int flags, \ + SYS_READLINKAT = 322 // { ssize_t sys_readlinkat(int fd, const char *path, \ + SYS_RENAMEAT = 323 // { int sys_renameat(int fromfd, const char *from, \ + SYS_SYMLINKAT = 324 // { int sys_symlinkat(const char *path, int fd, \ + SYS_UNLINKAT = 325 // { int sys_unlinkat(int fd, const char *path, \ + SYS___SET_TCB = 329 // { void sys___set_tcb(void *tcb); } + SYS___GET_TCB = 330 // { void *sys___get_tcb(void); } +) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go index 2de1d44e2..e61d78a54 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go @@ -1,6 +1,7 @@ +// cgo -godefs types_darwin.go | go run mkpost.go +// Code generated by the command above; see README.md. DO NOT EDIT. + // +build 386,darwin -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs types_darwin.go package unix @@ -445,3 +446,17 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + +const ( + AT_FDCWD = -0x2 + AT_REMOVEDIR = 0x80 + AT_SYMLINK_FOLLOW = 0x40 + AT_SYMLINK_NOFOLLOW = 0x20 +) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go index 044657878..2619155ff 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -1,6 +1,7 @@ +// cgo -godefs types_darwin.go | go run mkpost.go +// Code generated by the command above; see README.md. DO NOT EDIT. + // +build amd64,darwin -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs types_darwin.go package unix @@ -456,7 +457,16 @@ type Termios struct { Ospeed uint64 } +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + const ( AT_FDCWD = -0x2 + AT_REMOVEDIR = 0x80 + AT_SYMLINK_FOLLOW = 0x40 AT_SYMLINK_NOFOLLOW = 0x20 ) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go index 66df363ce..4dca0d4db 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go @@ -447,3 +447,17 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + +const ( + AT_FDCWD = -0x2 + AT_REMOVEDIR = 0x80 + AT_SYMLINK_FOLLOW = 0x40 + AT_SYMLINK_NOFOLLOW = 0x20 +) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go index 85d56eabd..f2881fd14 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -455,3 +455,17 @@ type Termios struct { Ispeed uint64 Ospeed uint64 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + +const ( + AT_FDCWD = -0x2 + AT_REMOVEDIR = 0x80 + AT_SYMLINK_FOLLOW = 0x40 + AT_SYMLINK_NOFOLLOW = 0x20 +) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go index e585c893a..67c6bf883 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go @@ -441,3 +441,8 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +const ( + AT_FDCWD = 0xfffafdcd + AT_SYMLINK_NOFOLLOW = 0x1 +) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go index 8cf30947b..5b28bcbba 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -1,6 +1,7 @@ +// cgo -godefs types_freebsd.go | go run mkpost.go +// Code generated by the command above; see README.md. DO NOT EDIT. + // +build 386,freebsd -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs types_freebsd.go package unix @@ -85,7 +86,7 @@ type Stat_t struct { Ctimespec Timespec Size int64 Blocks int64 - Blksize uint32 + Blksize int32 Flags uint32 Gen uint32 Lspare int32 @@ -288,9 +289,9 @@ type FdSet struct { } const ( - sizeofIfMsghdr = 0x64 + sizeofIfMsghdr = 0xa8 SizeofIfMsghdr = 0x60 - sizeofIfData = 0x54 + sizeofIfData = 0x98 SizeofIfData = 0x50 SizeofIfaMsghdr = 0x14 SizeofIfmaMsghdr = 0x10 @@ -322,31 +323,31 @@ type IfMsghdr struct { } type ifData struct { - Type uint8 - Physical uint8 - Addrlen uint8 - Hdrlen uint8 - Link_state uint8 - Vhid uint8 - Baudrate_pf uint8 - Datalen uint8 - Mtu uint32 - Metric uint32 - Baudrate uint32 - Ipackets uint32 - Ierrors uint32 - Opackets uint32 - Oerrors uint32 - Collisions uint32 - Ibytes uint32 - Obytes uint32 - Imcasts uint32 - Omcasts uint32 - Iqdrops uint32 - Noproto uint32 - Hwassist uint64 - Epoch int32 - Lastchange Timeval + Type uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Vhid uint8 + Datalen uint16 + Mtu uint32 + Metric uint32 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Oqdrops uint64 + Noproto uint64 + Hwassist uint64 + X__ifi_epoch [8]byte + X__ifi_lastchange [16]byte } type IfData struct { @@ -500,3 +501,21 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x800 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x200 +) + +type CapRights struct { + Rights [2]uint64 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go index e5feb207b..c65d89e49 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -1,6 +1,7 @@ +// cgo -godefs types_freebsd.go | go run mkpost.go +// Code generated by the command above; see README.md. DO NOT EDIT. + // +build amd64,freebsd -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs types_freebsd.go package unix @@ -85,7 +86,7 @@ type Stat_t struct { Ctimespec Timespec Size int64 Blocks int64 - Blksize uint32 + Blksize int32 Flags uint32 Gen uint32 Lspare int32 @@ -324,31 +325,31 @@ type IfMsghdr struct { } type ifData struct { - Type uint8 - Physical uint8 - Addrlen uint8 - Hdrlen uint8 - Link_state uint8 - Vhid uint8 - Baudrate_pf uint8 - Datalen uint8 - Mtu uint64 - Metric uint64 - Baudrate uint64 - Ipackets uint64 - Ierrors uint64 - Opackets uint64 - Oerrors uint64 - Collisions uint64 - Ibytes uint64 - Obytes uint64 - Imcasts uint64 - Omcasts uint64 - Iqdrops uint64 - Noproto uint64 - Hwassist uint64 - Epoch int64 - Lastchange Timeval + Type uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Vhid uint8 + Datalen uint16 + Mtu uint32 + Metric uint32 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Oqdrops uint64 + Noproto uint64 + Hwassist uint64 + X__ifi_epoch [8]byte + X__ifi_lastchange [16]byte } type IfData struct { @@ -503,3 +504,21 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x800 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x200 +) + +type CapRights struct { + Rights [2]uint64 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go index 5472b5428..42c0a502c 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -1,5 +1,5 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs -- -fsigned-char types_freebsd.go +// cgo -godefs -- -fsigned-char types_freebsd.go | go run mkpost.go +// Code generated by the command above; see README.md. DO NOT EDIT. // +build arm,freebsd @@ -88,7 +88,7 @@ type Stat_t struct { Ctimespec Timespec Size int64 Blocks int64 - Blksize uint32 + Blksize int32 Flags uint32 Gen uint32 Lspare int32 @@ -142,6 +142,15 @@ type Fsid struct { Val [2]int32 } +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + type RawSockaddrInet4 struct { Len uint8 Family uint8 @@ -282,9 +291,9 @@ type FdSet struct { } const ( - sizeofIfMsghdr = 0x70 + sizeofIfMsghdr = 0xa8 SizeofIfMsghdr = 0x70 - sizeofIfData = 0x60 + sizeofIfData = 0x98 SizeofIfData = 0x60 SizeofIfaMsghdr = 0x14 SizeofIfmaMsghdr = 0x10 @@ -316,31 +325,31 @@ type IfMsghdr struct { } type ifData struct { - Type uint8 - Physical uint8 - Addrlen uint8 - Hdrlen uint8 - Link_state uint8 - Vhid uint8 - Baudrate_pf uint8 - Datalen uint8 - Mtu uint32 - Metric uint32 - Baudrate uint32 - Ipackets uint32 - Ierrors uint32 - Opackets uint32 - Oerrors uint32 - Collisions uint32 - Ibytes uint32 - Obytes uint32 - Imcasts uint32 - Omcasts uint32 - Iqdrops uint32 - Noproto uint32 - Hwassist uint64 - Epoch int64 - Lastchange Timeval + Type uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Vhid uint8 + Datalen uint16 + Mtu uint32 + Metric uint32 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Oqdrops uint64 + Noproto uint64 + Hwassist uint64 + X__ifi_epoch [8]byte + X__ifi_lastchange [16]byte } type IfData struct { @@ -495,3 +504,21 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x800 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x200 +) + +type CapRights struct { + Rights [2]uint64 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index 811120659..0dcebb50b 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -285,6 +285,13 @@ type IPv6Mreq struct { Interface uint32 } +type PacketMreq struct { + Ifindex int32 + Type uint16 + Alen uint16 + Address [8]uint8 +} + type Msghdr struct { Name *byte Namelen uint32 @@ -373,9 +380,11 @@ const ( SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 SizeofLinger = 0x8 + SizeofIovec = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 + SizeofPacketMreq = 0x10 SizeofMsghdr = 0x1c SizeofCmsghdr = 0xc SizeofInet4Pktinfo = 0xc @@ -676,3 +685,10 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go index 075d9c561..d70e54348 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -287,6 +287,13 @@ type IPv6Mreq struct { Interface uint32 } +type PacketMreq struct { + Ifindex int32 + Type uint16 + Alen uint16 + Address [8]uint8 +} + type Msghdr struct { Name *byte Namelen uint32 @@ -377,9 +384,11 @@ const ( SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 + SizeofPacketMreq = 0x10 SizeofMsghdr = 0x38 SizeofCmsghdr = 0x10 SizeofInet4Pktinfo = 0xc @@ -694,3 +703,10 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index a66c1603b..497f56319 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -289,6 +289,13 @@ type IPv6Mreq struct { Interface uint32 } +type PacketMreq struct { + Ifindex int32 + Type uint16 + Alen uint16 + Address [8]uint8 +} + type Msghdr struct { Name *byte Namelen uint32 @@ -377,9 +384,11 @@ const ( SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 SizeofLinger = 0x8 + SizeofIovec = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 + SizeofPacketMreq = 0x10 SizeofMsghdr = 0x1c SizeofCmsghdr = 0xc SizeofInet4Pktinfo = 0xc @@ -665,3 +674,10 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go index b3b506a6d..f0bdaede6 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -288,6 +288,13 @@ type IPv6Mreq struct { Interface uint32 } +type PacketMreq struct { + Ifindex int32 + Type uint16 + Alen uint16 + Address [8]uint8 +} + type Msghdr struct { Name *byte Namelen uint32 @@ -378,9 +385,11 @@ const ( SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 + SizeofPacketMreq = 0x10 SizeofMsghdr = 0x38 SizeofCmsghdr = 0x10 SizeofInet4Pktinfo = 0xc @@ -673,3 +682,10 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go index 5c654f552..850a68cb2 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go @@ -288,6 +288,13 @@ type IPv6Mreq struct { Interface uint32 } +type PacketMreq struct { + Ifindex int32 + Type uint16 + Alen uint16 + Address [8]uint8 +} + type Msghdr struct { Name *byte Namelen uint32 @@ -376,9 +383,11 @@ const ( SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 SizeofLinger = 0x8 + SizeofIovec = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 + SizeofPacketMreq = 0x10 SizeofMsghdr = 0x1c SizeofCmsghdr = 0xc SizeofInet4Pktinfo = 0xc @@ -670,3 +679,10 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go index 3f11fb657..92aac5d93 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -288,6 +288,13 @@ type IPv6Mreq struct { Interface uint32 } +type PacketMreq struct { + Ifindex int32 + Type uint16 + Alen uint16 + Address [8]uint8 +} + type Msghdr struct { Name *byte Namelen uint32 @@ -378,9 +385,11 @@ const ( SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 + SizeofPacketMreq = 0x10 SizeofMsghdr = 0x38 SizeofCmsghdr = 0x10 SizeofInet4Pktinfo = 0xc @@ -675,3 +684,10 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index 1a4ad57e4..623f58127 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -288,6 +288,13 @@ type IPv6Mreq struct { Interface uint32 } +type PacketMreq struct { + Ifindex int32 + Type uint16 + Alen uint16 + Address [8]uint8 +} + type Msghdr struct { Name *byte Namelen uint32 @@ -378,9 +385,11 @@ const ( SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 + SizeofPacketMreq = 0x10 SizeofMsghdr = 0x38 SizeofCmsghdr = 0x10 SizeofInet4Pktinfo = 0xc @@ -675,3 +684,10 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go index b3f0f30fd..56598a1bf 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go @@ -288,6 +288,13 @@ type IPv6Mreq struct { Interface uint32 } +type PacketMreq struct { + Ifindex int32 + Type uint16 + Alen uint16 + Address [8]uint8 +} + type Msghdr struct { Name *byte Namelen uint32 @@ -376,9 +383,11 @@ const ( SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 SizeofLinger = 0x8 + SizeofIovec = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 + SizeofPacketMreq = 0x10 SizeofMsghdr = 0x1c SizeofCmsghdr = 0xc SizeofInet4Pktinfo = 0xc @@ -670,3 +679,10 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index aeee27e04..acc7c819d 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -289,6 +289,13 @@ type IPv6Mreq struct { Interface uint32 } +type PacketMreq struct { + Ifindex int32 + Type uint16 + Alen uint16 + Address [8]uint8 +} + type Msghdr struct { Name *byte Namelen uint32 @@ -379,9 +386,11 @@ const ( SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 + SizeofPacketMreq = 0x10 SizeofMsghdr = 0x38 SizeofCmsghdr = 0x10 SizeofInet4Pktinfo = 0xc @@ -683,3 +692,10 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go index b8cb2c3b2..b348885c8 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -289,6 +289,13 @@ type IPv6Mreq struct { Interface uint32 } +type PacketMreq struct { + Ifindex int32 + Type uint16 + Alen uint16 + Address [8]uint8 +} + type Msghdr struct { Name *byte Namelen uint32 @@ -379,9 +386,11 @@ const ( SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 + SizeofPacketMreq = 0x10 SizeofMsghdr = 0x38 SizeofCmsghdr = 0x10 SizeofInet4Pktinfo = 0xc @@ -683,3 +692,10 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go index 58883f92b..a706e2f8c 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -288,6 +288,13 @@ type IPv6Mreq struct { Interface uint32 } +type PacketMreq struct { + Ifindex int32 + Type uint16 + Alen uint16 + Address [8]uint8 +} + type Msghdr struct { Name *byte Namelen uint32 @@ -378,9 +385,11 @@ const ( SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 SizeofLinger = 0x8 + SizeofIovec = 0x10 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 + SizeofPacketMreq = 0x10 SizeofMsghdr = 0x38 SizeofCmsghdr = 0x10 SizeofInet4Pktinfo = 0xc @@ -700,3 +709,10 @@ type Termios struct { Ispeed uint32 Ospeed uint32 } + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go index caf755fb8..42f99c0a3 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go @@ -382,6 +382,11 @@ type Termios struct { Ospeed int32 } +const ( + AT_FDCWD = -0x64 + AT_SYMLINK_NOFOLLOW = 0x200 +) + type Sysctlnode struct { Flags uint32 Num int32 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go index 91b4a5305..ff290ba06 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go @@ -389,6 +389,11 @@ type Termios struct { Ospeed int32 } +const ( + AT_FDCWD = -0x64 + AT_SYMLINK_NOFOLLOW = 0x200 +) + type Sysctlnode struct { Flags uint32 Num int32 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go index c0758f9d3..66dbd7c05 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go @@ -387,6 +387,11 @@ type Termios struct { Ospeed int32 } +const ( + AT_FDCWD = -0x64 + AT_SYMLINK_NOFOLLOW = 0x200 +) + type Sysctlnode struct { Flags uint32 Num int32 diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go index 860a46979..20fc9f450 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go @@ -439,3 +439,8 @@ type Termios struct { Ispeed int32 Ospeed int32 } + +const ( + AT_FDCWD = -0x64 + AT_SYMLINK_NOFOLLOW = 0x2 +) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go index 23c52727f..46fe9490c 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go @@ -446,3 +446,8 @@ type Termios struct { Ispeed int32 Ospeed int32 } + +const ( + AT_FDCWD = -0x64 + AT_SYMLINK_NOFOLLOW = 0x2 +) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go new file mode 100644 index 000000000..62e1f7c04 --- /dev/null +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go @@ -0,0 +1,439 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_openbsd.go + +// +build arm,openbsd + +package unix + +const ( + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int32 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int32 +} + +type Timeval struct { + Sec int64 + Usec int32 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int32 + Ixrss int32 + Idrss int32 + Isrss int32 + Minflt int32 + Majflt int32 + Nswap int32 + Inblock int32 + Oublock int32 + Msgsnd int32 + Msgrcv int32 + Nsignals int32 + Nvcsw int32 + Nivcsw int32 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +const ( + S_IFMT = 0xf000 + S_IFIFO = 0x1000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFBLK = 0x6000 + S_IFREG = 0x8000 + S_IFLNK = 0xa000 + S_IFSOCK = 0xc000 + S_ISUID = 0x800 + S_ISGID = 0x400 + S_ISVTX = 0x200 + S_IRUSR = 0x100 + S_IWUSR = 0x80 + S_IXUSR = 0x40 +) + +type Stat_t struct { + Mode uint32 + Dev int32 + Ino uint64 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev int32 + Atim Timespec + Mtim Timespec + Ctim Timespec + Size int64 + Blocks int64 + Blksize int32 + Flags uint32 + Gen uint32 + X__st_birthtim Timespec +} + +type Statfs_t struct { + F_flags uint32 + F_bsize uint32 + F_iosize uint32 + F_blocks uint64 + F_bfree uint64 + F_bavail int64 + F_files uint64 + F_ffree uint64 + F_favail int64 + F_syncwrites uint64 + F_syncreads uint64 + F_asyncwrites uint64 + F_asyncreads uint64 + F_fsid Fsid + F_namemax uint32 + F_owner uint32 + F_ctime uint64 + F_fstypename [16]uint8 + F_mntonname [90]uint8 + F_mntfromname [90]uint8 + F_mntfromspec [90]uint8 + Pad_cgo_0 [2]byte + Mount_info [160]byte +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Dirent struct { + Fileno uint64 + Off int64 + Reclen uint16 + Type uint8 + Namlen uint8 + X__d_padding [4]uint8 + Name [256]uint8 +} + +type Fsid struct { + Val [2]int32 +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [24]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint32 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen uint32 + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x20 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x1c + SizeofCmsghdr = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint32 + Filter int16 + Flags uint16 + Fflags uint32 + Data int64 + Udata *byte +} + +type FdSet struct { + Bits [32]uint32 +} + +const ( + SizeofIfMsghdr = 0x98 + SizeofIfData = 0x80 + SizeofIfaMsghdr = 0x18 + SizeofIfAnnounceMsghdr = 0x1a + SizeofRtMsghdr = 0x60 + SizeofRtMetrics = 0x38 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Pad1 uint8 + Pad2 uint8 + Addrs int32 + Flags int32 + Xflags int32 + Data IfData +} + +type IfData struct { + Type uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Mtu uint32 + Metric uint32 + Pad uint32 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Noproto uint64 + Capabilities uint32 + Lastchange Timeval +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Pad1 uint8 + Pad2 uint8 + Addrs int32 + Flags int32 + Metric int32 +} + +type IfAnnounceMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + What uint16 + Name [16]uint8 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Priority uint8 + Mpls uint8 + Addrs int32 + Flags int32 + Fmask int32 + Pid int32 + Seq int32 + Errno int32 + Inits uint32 + Rmx RtMetrics +} + +type RtMetrics struct { + Pksent uint64 + Expire int64 + Locks uint32 + Mtu uint32 + Refcnt uint32 + Hopcount uint32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pad uint32 +} + +type Mclpool struct{} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfProgram = 0x8 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x14 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfProgram struct { + Len uint32 + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp BpfTimeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [2]byte +} + +type BpfTimeval struct { + Sec uint32 + Usec uint32 +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed int32 + Ospeed int32 +} + +const ( + AT_FDCWD = -0x64 + AT_SYMLINK_NOFOLLOW = 0x2 +) diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/syscall_windows.go index 518250e70..c7ff24b55 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -176,6 +176,8 @@ func NewCallbackCDecl(fn interface{}) uintptr //sys RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegQueryValueExW //sys getCurrentProcessId() (pid uint32) = kernel32.GetCurrentProcessId //sys GetConsoleMode(console Handle, mode *uint32) (err error) = kernel32.GetConsoleMode +//sys SetConsoleMode(console Handle, mode uint32) (err error) = kernel32.SetConsoleMode +//sys GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) = kernel32.GetConsoleScreenBufferInfo //sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW //sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW //sys CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot @@ -186,8 +188,12 @@ func NewCallbackCDecl(fn interface{}) uintptr //sys CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) [failretval&0xff==0] = CreateSymbolicLinkW //sys CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) [failretval&0xff==0] = CreateHardLinkW //sys GetCurrentThreadId() (id uint32) -//sys CreateEvent(eventAttrs *syscall.SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) = kernel32.CreateEventW +//sys CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) = kernel32.CreateEventW +//sys CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) = kernel32.CreateEventExW +//sys OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) = kernel32.OpenEventW //sys SetEvent(event Handle) (err error) = kernel32.SetEvent +//sys ResetEvent(event Handle) (err error) = kernel32.ResetEvent +//sys PulseEvent(event Handle) (err error) = kernel32.PulseEvent // syscall interface implementation for other packages diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/ztypes_windows.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/types_windows.go similarity index 96% rename from vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/ztypes_windows.go rename to vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/types_windows.go index c99a3fe5f..401a5f2d9 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/ztypes_windows.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/types_windows.go @@ -1233,3 +1233,50 @@ const ( IfOperStatusNotPresent = 6 IfOperStatusLowerLayerDown = 7 ) + +// Console related constants used for the mode parameter to SetConsoleMode. See +// https://docs.microsoft.com/en-us/windows/console/setconsolemode for details. + +const ( + ENABLE_PROCESSED_INPUT = 0x1 + ENABLE_LINE_INPUT = 0x2 + ENABLE_ECHO_INPUT = 0x4 + ENABLE_WINDOW_INPUT = 0x8 + ENABLE_MOUSE_INPUT = 0x10 + ENABLE_INSERT_MODE = 0x20 + ENABLE_QUICK_EDIT_MODE = 0x40 + ENABLE_EXTENDED_FLAGS = 0x80 + ENABLE_AUTO_POSITION = 0x100 + ENABLE_VIRTUAL_TERMINAL_INPUT = 0x200 + + ENABLE_PROCESSED_OUTPUT = 0x1 + ENABLE_WRAP_AT_EOL_OUTPUT = 0x2 + ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4 + DISABLE_NEWLINE_AUTO_RETURN = 0x8 + ENABLE_LVB_GRID_WORLDWIDE = 0x10 +) + +type Coord struct { + X int16 + Y int16 +} + +type SmallRect struct { + Left int16 + Top int16 + Right int16 + Bottom int16 +} + +// Used with GetConsoleScreenBuffer to retreive information about a console +// screen buffer. See +// https://docs.microsoft.com/en-us/windows/console/console-screen-buffer-info-str +// for details. + +type ConsoleScreenBufferInfo struct { + Size Coord + CursorPosition Coord + Attributes uint16 + Window SmallRect + MaximumWindowSize Coord +} diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/ztypes_windows_386.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/types_windows_386.go similarity index 100% rename from vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/ztypes_windows_386.go rename to vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/types_windows_386.go diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/ztypes_windows_amd64.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/types_windows_amd64.go similarity index 100% rename from vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/ztypes_windows_amd64.go rename to vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/types_windows_amd64.go diff --git a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/zsyscall_windows.go index d588e1d03..2f893d2ef 100644 --- a/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/github.com/docker/docker/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -161,6 +161,8 @@ var ( procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW") procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId") procGetConsoleMode = modkernel32.NewProc("GetConsoleMode") + procSetConsoleMode = modkernel32.NewProc("SetConsoleMode") + procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo") procWriteConsoleW = modkernel32.NewProc("WriteConsoleW") procReadConsoleW = modkernel32.NewProc("ReadConsoleW") procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot") @@ -171,7 +173,11 @@ var ( procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW") procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId") procCreateEventW = modkernel32.NewProc("CreateEventW") + procCreateEventExW = modkernel32.NewProc("CreateEventExW") + procOpenEventW = modkernel32.NewProc("OpenEventW") procSetEvent = modkernel32.NewProc("SetEvent") + procResetEvent = modkernel32.NewProc("ResetEvent") + procPulseEvent = modkernel32.NewProc("PulseEvent") procWSAStartup = modws2_32.NewProc("WSAStartup") procWSACleanup = modws2_32.NewProc("WSACleanup") procWSAIoctl = modws2_32.NewProc("WSAIoctl") @@ -1629,6 +1635,30 @@ func GetConsoleMode(console Handle, mode *uint32) (err error) { return } +func SetConsoleMode(console Handle, mode uint32) (err error) { + r1, _, e1 := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(console), uintptr(mode), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) { + r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) { r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0) if r1 == 0 { @@ -1732,7 +1762,7 @@ func GetCurrentThreadId() (id uint32) { return } -func CreateEvent(eventAttrs *syscall.SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) { +func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) { r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0) handle = Handle(r0) if handle == 0 { @@ -1745,6 +1775,38 @@ func CreateEvent(eventAttrs *syscall.SecurityAttributes, manualReset uint32, ini return } +func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) { + r0, _, e1 := syscall.Syscall6(procCreateEventExW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0) + handle = Handle(r0) + if handle == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) { + var _p0 uint32 + if inheritHandle { + _p0 = 1 + } else { + _p0 = 0 + } + r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name))) + handle = Handle(r0) + if handle == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + func SetEvent(event Handle) (err error) { r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0) if r1 == 0 { @@ -1757,6 +1819,30 @@ func SetEvent(event Handle) (err error) { return } +func ResetEvent(event Handle) (err error) { + r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(event), 0, 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func PulseEvent(event Handle) (err error) { + r1, _, e1 := syscall.Syscall(procPulseEvent.Addr(), 1, uintptr(event), 0, 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + func WSAStartup(verreq uint32, data *WSAData) (sockerr error) { r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0) if r0 != 0 { diff --git a/vendor/github.com/docker/docker/volume/drivers/extpoint.go b/vendor/github.com/docker/docker/volume/drivers/extpoint.go index da230dcc7..ee42f2f5e 100644 --- a/vendor/github.com/docker/docker/volume/drivers/extpoint.go +++ b/vendor/github.com/docker/docker/volume/drivers/extpoint.go @@ -10,6 +10,7 @@ import ( "github.com/docker/docker/pkg/locker" getter "github.com/docker/docker/pkg/plugingetter" "github.com/docker/docker/volume" + "github.com/pkg/errors" ) // currently created by hand. generation tool would generate this like: @@ -31,6 +32,7 @@ func NewVolumeDriver(name string, baseHostPath string, c client) volume.Driver { // volumeDriver defines the available functions that volume plugins must implement. // This interface is only defined to generate the proxy objects. // It's not intended to be public or reused. +// nolint: deadcode type volumeDriver interface { // Create a volume with the given name Create(name string, opts map[string]string) (err error) @@ -99,6 +101,14 @@ func Unregister(name string) bool { return true } +type driverNotFoundError string + +func (e driverNotFoundError) Error() string { + return "volume driver not found: " + string(e) +} + +func (driverNotFoundError) NotFound() {} + // lookup returns the driver associated with the given name. If a // driver with the given name has not been registered it checks if // there is a VolumeDriver plugin available with the given name. @@ -115,7 +125,7 @@ func lookup(name string, mode int) (volume.Driver, error) { if drivers.plugingetter != nil { p, err := drivers.plugingetter.Get(name, extName, mode) if err != nil { - return nil, fmt.Errorf("Error looking up volume plugin %s: %v", name, err) + return nil, errors.Wrap(err, "error looking up volume plugin "+name) } d := NewVolumeDriver(p.Name(), p.BasePath(), p.Client()) @@ -130,7 +140,7 @@ func lookup(name string, mode int) (volume.Driver, error) { } return d, nil } - return nil, fmt.Errorf("Error looking up volume plugin %s", name) + return nil, driverNotFoundError(name) } func validateDriver(vd volume.Driver) error { diff --git a/vendor/github.com/docker/docker/volume/lcow_parser.go b/vendor/github.com/docker/docker/volume/lcow_parser.go new file mode 100644 index 000000000..aeb81a420 --- /dev/null +++ b/vendor/github.com/docker/docker/volume/lcow_parser.go @@ -0,0 +1,35 @@ +package volume + +import ( + "errors" + "fmt" + "path" + + "github.com/docker/docker/api/types/mount" +) + +var lcowSpecificValidators mountValidator = func(m *mount.Mount) error { + if path.Clean(m.Target) == "/" { + return fmt.Errorf("invalid specification: destination can't be '/'") + } + if m.Type == mount.TypeNamedPipe { + return errors.New("Linux containers on Windows do not support named pipe mounts") + } + return nil +} + +type lcowParser struct { + windowsParser +} + +func (p *lcowParser) validateMountConfig(mnt *mount.Mount) error { + return p.validateMountConfigReg(mnt, rxLCOWDestination, lcowSpecificValidators) +} + +func (p *lcowParser) ParseMountRaw(raw, volumeDriver string) (*MountPoint, error) { + return p.parseMountRaw(raw, volumeDriver, rxLCOWDestination, false, lcowSpecificValidators) +} + +func (p *lcowParser) ParseMountSpec(cfg mount.Mount) (*MountPoint, error) { + return p.parseMountSpec(cfg, rxLCOWDestination, false, lcowSpecificValidators) +} diff --git a/vendor/github.com/docker/docker/volume/linux_parser.go b/vendor/github.com/docker/docker/volume/linux_parser.go new file mode 100644 index 000000000..1b3493ac7 --- /dev/null +++ b/vendor/github.com/docker/docker/volume/linux_parser.go @@ -0,0 +1,416 @@ +package volume + +import ( + "errors" + "fmt" + "path" + "path/filepath" + "strings" + + "github.com/docker/docker/api/types/mount" + "github.com/docker/docker/pkg/stringid" +) + +type linuxParser struct { +} + +func linuxSplitRawSpec(raw string) ([]string, error) { + if strings.Count(raw, ":") > 2 { + return nil, errInvalidSpec(raw) + } + + arr := strings.SplitN(raw, ":", 3) + if arr[0] == "" { + return nil, errInvalidSpec(raw) + } + return arr, nil +} + +func linuxValidateNotRoot(p string) error { + p = path.Clean(strings.Replace(p, `\`, `/`, -1)) + if p == "/" { + return fmt.Errorf("invalid specification: destination can't be '/'") + } + return nil +} +func linuxValidateAbsolute(p string) error { + p = strings.Replace(p, `\`, `/`, -1) + if path.IsAbs(p) { + return nil + } + return fmt.Errorf("invalid mount path: '%s' mount path must be absolute", p) +} +func (p *linuxParser) validateMountConfig(mnt *mount.Mount) error { + // there was something looking like a bug in existing codebase: + // - validateMountConfig on linux was called with options skipping bind source existance when calling ParseMountRaw + // - but not when calling ParseMountSpec directly... nor when the unit test called it directly + return p.validateMountConfigImpl(mnt, true) +} +func (p *linuxParser) validateMountConfigImpl(mnt *mount.Mount, validateBindSourceExists bool) error { + if len(mnt.Target) == 0 { + return &errMountConfig{mnt, errMissingField("Target")} + } + + if err := linuxValidateNotRoot(mnt.Target); err != nil { + return &errMountConfig{mnt, err} + } + + if err := linuxValidateAbsolute(mnt.Target); err != nil { + return &errMountConfig{mnt, err} + } + + switch mnt.Type { + case mount.TypeBind: + if len(mnt.Source) == 0 { + return &errMountConfig{mnt, errMissingField("Source")} + } + // Don't error out just because the propagation mode is not supported on the platform + if opts := mnt.BindOptions; opts != nil { + if len(opts.Propagation) > 0 && len(linuxPropagationModes) > 0 { + if _, ok := linuxPropagationModes[opts.Propagation]; !ok { + return &errMountConfig{mnt, fmt.Errorf("invalid propagation mode: %s", opts.Propagation)} + } + } + } + if mnt.VolumeOptions != nil { + return &errMountConfig{mnt, errExtraField("VolumeOptions")} + } + + if err := linuxValidateAbsolute(mnt.Source); err != nil { + return &errMountConfig{mnt, err} + } + + if validateBindSourceExists { + exists, _, _ := currentFileInfoProvider.fileInfo(mnt.Source) + if !exists { + return &errMountConfig{mnt, errBindNotExist} + } + } + + case mount.TypeVolume: + if mnt.BindOptions != nil { + return &errMountConfig{mnt, errExtraField("BindOptions")} + } + + if len(mnt.Source) == 0 && mnt.ReadOnly { + return &errMountConfig{mnt, fmt.Errorf("must not set ReadOnly mode when using anonymous volumes")} + } + case mount.TypeTmpfs: + if len(mnt.Source) != 0 { + return &errMountConfig{mnt, errExtraField("Source")} + } + if _, err := p.ConvertTmpfsOptions(mnt.TmpfsOptions, mnt.ReadOnly); err != nil { + return &errMountConfig{mnt, err} + } + default: + return &errMountConfig{mnt, errors.New("mount type unknown")} + } + return nil +} + +// read-write modes +var rwModes = map[string]bool{ + "rw": true, + "ro": true, +} + +// label modes +var linuxLabelModes = map[string]bool{ + "Z": true, + "z": true, +} + +// consistency modes +var linuxConsistencyModes = map[mount.Consistency]bool{ + mount.ConsistencyFull: true, + mount.ConsistencyCached: true, + mount.ConsistencyDelegated: true, +} +var linuxPropagationModes = map[mount.Propagation]bool{ + mount.PropagationPrivate: true, + mount.PropagationRPrivate: true, + mount.PropagationSlave: true, + mount.PropagationRSlave: true, + mount.PropagationShared: true, + mount.PropagationRShared: true, +} + +const linuxDefaultPropagationMode = mount.PropagationRPrivate + +func linuxGetPropagation(mode string) mount.Propagation { + for _, o := range strings.Split(mode, ",") { + prop := mount.Propagation(o) + if linuxPropagationModes[prop] { + return prop + } + } + return linuxDefaultPropagationMode +} + +func linuxHasPropagation(mode string) bool { + for _, o := range strings.Split(mode, ",") { + if linuxPropagationModes[mount.Propagation(o)] { + return true + } + } + return false +} + +func linuxValidMountMode(mode string) bool { + if mode == "" { + return true + } + + rwModeCount := 0 + labelModeCount := 0 + propagationModeCount := 0 + copyModeCount := 0 + consistencyModeCount := 0 + + for _, o := range strings.Split(mode, ",") { + switch { + case rwModes[o]: + rwModeCount++ + case linuxLabelModes[o]: + labelModeCount++ + case linuxPropagationModes[mount.Propagation(o)]: + propagationModeCount++ + case copyModeExists(o): + copyModeCount++ + case linuxConsistencyModes[mount.Consistency(o)]: + consistencyModeCount++ + default: + return false + } + } + + // Only one string for each mode is allowed. + if rwModeCount > 1 || labelModeCount > 1 || propagationModeCount > 1 || copyModeCount > 1 || consistencyModeCount > 1 { + return false + } + return true +} + +func (p *linuxParser) ReadWrite(mode string) bool { + if !linuxValidMountMode(mode) { + return false + } + + for _, o := range strings.Split(mode, ",") { + if o == "ro" { + return false + } + } + return true +} + +func (p *linuxParser) ParseMountRaw(raw, volumeDriver string) (*MountPoint, error) { + arr, err := linuxSplitRawSpec(raw) + if err != nil { + return nil, err + } + + var spec mount.Mount + var mode string + switch len(arr) { + case 1: + // Just a destination path in the container + spec.Target = arr[0] + case 2: + if linuxValidMountMode(arr[1]) { + // Destination + Mode is not a valid volume - volumes + // cannot include a mode. e.g. /foo:rw + return nil, errInvalidSpec(raw) + } + // Host Source Path or Name + Destination + spec.Source = arr[0] + spec.Target = arr[1] + case 3: + // HostSourcePath+DestinationPath+Mode + spec.Source = arr[0] + spec.Target = arr[1] + mode = arr[2] + default: + return nil, errInvalidSpec(raw) + } + + if !linuxValidMountMode(mode) { + return nil, errInvalidMode(mode) + } + + if path.IsAbs(spec.Source) { + spec.Type = mount.TypeBind + } else { + spec.Type = mount.TypeVolume + } + + spec.ReadOnly = !p.ReadWrite(mode) + + // cannot assume that if a volume driver is passed in that we should set it + if volumeDriver != "" && spec.Type == mount.TypeVolume { + spec.VolumeOptions = &mount.VolumeOptions{ + DriverConfig: &mount.Driver{Name: volumeDriver}, + } + } + + if copyData, isSet := getCopyMode(mode, p.DefaultCopyMode()); isSet { + if spec.VolumeOptions == nil { + spec.VolumeOptions = &mount.VolumeOptions{} + } + spec.VolumeOptions.NoCopy = !copyData + } + if linuxHasPropagation(mode) { + spec.BindOptions = &mount.BindOptions{ + Propagation: linuxGetPropagation(mode), + } + } + + mp, err := p.parseMountSpec(spec, false) + if mp != nil { + mp.Mode = mode + } + if err != nil { + err = fmt.Errorf("%v: %v", errInvalidSpec(raw), err) + } + return mp, err +} +func (p *linuxParser) ParseMountSpec(cfg mount.Mount) (*MountPoint, error) { + return p.parseMountSpec(cfg, true) +} +func (p *linuxParser) parseMountSpec(cfg mount.Mount, validateBindSourceExists bool) (*MountPoint, error) { + if err := p.validateMountConfigImpl(&cfg, validateBindSourceExists); err != nil { + return nil, err + } + mp := &MountPoint{ + RW: !cfg.ReadOnly, + Destination: path.Clean(filepath.ToSlash(cfg.Target)), + Type: cfg.Type, + Spec: cfg, + } + + switch cfg.Type { + case mount.TypeVolume: + if cfg.Source == "" { + mp.Name = stringid.GenerateNonCryptoID() + } else { + mp.Name = cfg.Source + } + mp.CopyData = p.DefaultCopyMode() + + if cfg.VolumeOptions != nil { + if cfg.VolumeOptions.DriverConfig != nil { + mp.Driver = cfg.VolumeOptions.DriverConfig.Name + } + if cfg.VolumeOptions.NoCopy { + mp.CopyData = false + } + } + case mount.TypeBind: + mp.Source = path.Clean(filepath.ToSlash(cfg.Source)) + if cfg.BindOptions != nil && len(cfg.BindOptions.Propagation) > 0 { + mp.Propagation = cfg.BindOptions.Propagation + } else { + // If user did not specify a propagation mode, get + // default propagation mode. + mp.Propagation = linuxDefaultPropagationMode + } + case mount.TypeTmpfs: + // NOP + } + return mp, nil +} + +func (p *linuxParser) ParseVolumesFrom(spec string) (string, string, error) { + if len(spec) == 0 { + return "", "", fmt.Errorf("volumes-from specification cannot be an empty string") + } + + specParts := strings.SplitN(spec, ":", 2) + id := specParts[0] + mode := "rw" + + if len(specParts) == 2 { + mode = specParts[1] + if !linuxValidMountMode(mode) { + return "", "", errInvalidMode(mode) + } + // For now don't allow propagation properties while importing + // volumes from data container. These volumes will inherit + // the same propagation property as of the original volume + // in data container. This probably can be relaxed in future. + if linuxHasPropagation(mode) { + return "", "", errInvalidMode(mode) + } + // Do not allow copy modes on volumes-from + if _, isSet := getCopyMode(mode, p.DefaultCopyMode()); isSet { + return "", "", errInvalidMode(mode) + } + } + return id, mode, nil +} + +func (p *linuxParser) DefaultPropagationMode() mount.Propagation { + return linuxDefaultPropagationMode +} + +func (p *linuxParser) ConvertTmpfsOptions(opt *mount.TmpfsOptions, readOnly bool) (string, error) { + var rawOpts []string + if readOnly { + rawOpts = append(rawOpts, "ro") + } + + if opt != nil && opt.Mode != 0 { + rawOpts = append(rawOpts, fmt.Sprintf("mode=%o", opt.Mode)) + } + + if opt != nil && opt.SizeBytes != 0 { + // calculate suffix here, making this linux specific, but that is + // okay, since API is that way anyways. + + // we do this by finding the suffix that divides evenly into the + // value, returning the value itself, with no suffix, if it fails. + // + // For the most part, we don't enforce any semantic to this values. + // The operating system will usually align this and enforce minimum + // and maximums. + var ( + size = opt.SizeBytes + suffix string + ) + for _, r := range []struct { + suffix string + divisor int64 + }{ + {"g", 1 << 30}, + {"m", 1 << 20}, + {"k", 1 << 10}, + } { + if size%r.divisor == 0 { + size = size / r.divisor + suffix = r.suffix + break + } + } + + rawOpts = append(rawOpts, fmt.Sprintf("size=%d%s", size, suffix)) + } + return strings.Join(rawOpts, ","), nil +} + +func (p *linuxParser) DefaultCopyMode() bool { + return true +} +func (p *linuxParser) ValidateVolumeName(name string) error { + return nil +} + +func (p *linuxParser) IsBackwardCompatible(m *MountPoint) bool { + return len(m.Source) > 0 || m.Driver == DefaultDriverName +} + +func (p *linuxParser) ValidateTmpfsMountDestination(dest string) error { + if err := linuxValidateNotRoot(dest); err != nil { + return err + } + return linuxValidateAbsolute(dest) +} diff --git a/vendor/github.com/docker/docker/volume/local/local.go b/vendor/github.com/docker/docker/volume/local/local.go index 329febb4d..b37c45e61 100644 --- a/vendor/github.com/docker/docker/volume/local/local.go +++ b/vendor/github.com/docker/docker/volume/local/local.go @@ -13,12 +13,11 @@ import ( "strings" "sync" - "github.com/pkg/errors" - - "github.com/docker/docker/api" + "github.com/docker/docker/daemon/names" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/mount" "github.com/docker/docker/volume" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -36,17 +35,9 @@ var ( // volumeNameRegex ensures the name assigned for the volume is valid. // This name is used to create the bind directory, so we need to avoid characters that // would make the path to escape the root directory. - volumeNameRegex = api.RestrictedNamePattern + volumeNameRegex = names.RestrictedNamePattern ) -type validationError struct { - error -} - -func (validationError) IsValidationError() bool { - return true -} - type activeMount struct { count uint64 mounted bool @@ -148,6 +139,30 @@ func (r *Root) Name() string { return volume.DefaultDriverName } +type alreadyExistsError struct { + path string +} + +func (e alreadyExistsError) Error() string { + return "local volume already exists under " + e.path +} + +func (e alreadyExistsError) Conflict() {} + +type systemError struct { + err error +} + +func (e systemError) Error() string { + return e.err.Error() +} + +func (e systemError) SystemError() {} + +func (e systemError) Cause() error { + return e.err +} + // Create creates a new volume.Volume with the provided name, creating // the underlying directory tree required for this volume in the // process. @@ -167,9 +182,9 @@ func (r *Root) Create(name string, opts map[string]string) (volume.Volume, error path := r.DataPath(name) if err := idtools.MkdirAllAndChown(path, 0755, r.rootIDs); err != nil { if os.IsExist(err) { - return nil, fmt.Errorf("volume already exists under %s", filepath.Dir(path)) + return nil, alreadyExistsError{filepath.Dir(path)} } - return nil, errors.Wrapf(err, "error while creating volume path '%s'", path) + return nil, errors.Wrapf(systemError{err}, "error while creating volume path '%s'", path) } var err error @@ -195,7 +210,7 @@ func (r *Root) Create(name string, opts map[string]string) (volume.Volume, error return nil, err } if err = ioutil.WriteFile(filepath.Join(filepath.Dir(path), "opts.json"), b, 600); err != nil { - return nil, errors.Wrap(err, "error while persisting volume options") + return nil, errors.Wrap(systemError{err}, "error while persisting volume options") } } @@ -213,11 +228,11 @@ func (r *Root) Remove(v volume.Volume) error { lv, ok := v.(*localVolume) if !ok { - return fmt.Errorf("unknown volume type %T", v) + return systemError{errors.Errorf("unknown volume type %T", v)} } if lv.active.count > 0 { - return fmt.Errorf("volume has active mounts") + return systemError{errors.Errorf("volume has active mounts")} } if err := lv.unmount(); err != nil { @@ -233,7 +248,7 @@ func (r *Root) Remove(v volume.Volume) error { } if !r.scopedPath(realPath) { - return fmt.Errorf("Unable to remove a directory of out the Docker root %s: %s", r.scope, realPath) + return systemError{errors.Errorf("Unable to remove a directory of out the Docker root %s: %s", r.scope, realPath)} } if err := removePath(realPath); err != nil { @@ -249,7 +264,7 @@ func removePath(path string) error { if os.IsNotExist(err) { return nil } - return errors.Wrapf(err, "error removing volume path '%s'", path) + return errors.Wrapf(systemError{err}, "error removing volume path '%s'", path) } return nil } @@ -270,12 +285,20 @@ func (r *Root) Scope() string { return volume.LocalScope } +type validationError string + +func (e validationError) Error() string { + return string(e) +} + +func (e validationError) InvalidParameter() {} + func (r *Root) validateName(name string) error { if len(name) == 1 { - return validationError{fmt.Errorf("volume name is too short, names should be at least two alphanumeric characters")} + return validationError("volume name is too short, names should be at least two alphanumeric characters") } if !volumeNameRegex.MatchString(name) { - return validationError{fmt.Errorf("%q includes invalid characters for a local volume name, only %q are allowed. If you intended to pass a host directory, use absolute path", name, api.RestrictedNameChars)} + return validationError(fmt.Sprintf("%q includes invalid characters for a local volume name, only %q are allowed. If you intended to pass a host directory, use absolute path", name, names.RestrictedNameChars)) } return nil } @@ -311,6 +334,11 @@ func (v *localVolume) Path() string { return v.path } +// CachedPath returns the data location +func (v *localVolume) CachedPath() string { + return v.path +} + // Mount implements the localVolume interface, returning the data location. // If there are any provided mount options, the resources will be mounted at this point func (v *localVolume) Mount(id string) (string, error) { @@ -319,7 +347,7 @@ func (v *localVolume) Mount(id string) (string, error) { if v.opts != nil { if !v.active.mounted { if err := v.mount(); err != nil { - return "", err + return "", systemError{err} } v.active.mounted = true } @@ -353,7 +381,7 @@ func (v *localVolume) unmount() error { if v.opts != nil { if err := mount.Unmount(v.path); err != nil { if mounted, mErr := mount.Mounted(v.path); mounted || mErr != nil { - return errors.Wrapf(err, "error while unmounting volume path '%s'", v.path) + return errors.Wrapf(systemError{err}, "error while unmounting volume path '%s'", v.path) } } v.active.mounted = false @@ -364,7 +392,7 @@ func (v *localVolume) unmount() error { func validateOpts(opts map[string]string) error { for opt := range opts { if !validOpts[opt] { - return validationError{fmt.Errorf("invalid option key: %q", opt)} + return validationError(fmt.Sprintf("invalid option key: %q", opt)) } } return nil diff --git a/vendor/github.com/docker/docker/volume/parser.go b/vendor/github.com/docker/docker/volume/parser.go new file mode 100644 index 000000000..1f48b60e2 --- /dev/null +++ b/vendor/github.com/docker/docker/volume/parser.go @@ -0,0 +1,43 @@ +package volume + +import ( + "runtime" + + "github.com/docker/docker/api/types/mount" +) + +const ( + // OSLinux is the same as runtime.GOOS on linux + OSLinux = "linux" + // OSWindows is the same as runtime.GOOS on windows + OSWindows = "windows" +) + +// Parser represents a platform specific parser for mount expressions +type Parser interface { + ParseMountRaw(raw, volumeDriver string) (*MountPoint, error) + ParseMountSpec(cfg mount.Mount) (*MountPoint, error) + ParseVolumesFrom(spec string) (string, string, error) + DefaultPropagationMode() mount.Propagation + ConvertTmpfsOptions(opt *mount.TmpfsOptions, readOnly bool) (string, error) + DefaultCopyMode() bool + ValidateVolumeName(name string) error + ReadWrite(mode string) bool + IsBackwardCompatible(m *MountPoint) bool + HasResource(m *MountPoint, absPath string) bool + ValidateTmpfsMountDestination(dest string) error + + validateMountConfig(mt *mount.Mount) error +} + +// NewParser creates a parser for a given container OS, depending on the current host OS (linux on a windows host will resolve to an lcowParser) +func NewParser(containerOS string) Parser { + switch containerOS { + case OSWindows: + return &windowsParser{} + } + if runtime.GOOS == OSWindows { + return &lcowParser{} + } + return &linuxParser{} +} diff --git a/vendor/github.com/docker/docker/volume/store/errors.go b/vendor/github.com/docker/docker/volume/store/errors.go index 980175f29..75e24e619 100644 --- a/vendor/github.com/docker/docker/volume/store/errors.go +++ b/vendor/github.com/docker/docker/volume/store/errors.go @@ -2,21 +2,32 @@ package store import ( "strings" - - "github.com/pkg/errors" ) -var ( +const ( // errVolumeInUse is a typed error returned when trying to remove a volume that is currently in use by a container - errVolumeInUse = errors.New("volume is in use") + errVolumeInUse conflictError = "volume is in use" // errNoSuchVolume is a typed error returned if the requested volume doesn't exist in the volume store - errNoSuchVolume = errors.New("no such volume") - // errInvalidName is a typed error returned when creating a volume with a name that is not valid on the platform - errInvalidName = errors.New("volume name is not valid on this platform") + errNoSuchVolume notFoundError = "no such volume" // errNameConflict is a typed error returned on create when a volume exists with the given name, but for a different driver - errNameConflict = errors.New("volume name must be unique") + errNameConflict conflictError = "volume name must be unique" ) +type conflictError string + +func (e conflictError) Error() string { + return string(e) +} +func (conflictError) Conflict() {} + +type notFoundError string + +func (e notFoundError) Error() string { + return string(e) +} + +func (notFoundError) NotFound() {} + // OpErr is the error type returned by functions in the store package. It describes // the operation, volume name, and error. type OpErr struct { @@ -47,6 +58,11 @@ func (e *OpErr) Error() string { return s } +// Cause returns the error the caused this error +func (e *OpErr) Cause() error { + return e.Err +} + // IsInUse returns a boolean indicating whether the error indicates that a // volume is in use func IsInUse(err error) bool { @@ -64,13 +80,16 @@ func IsNameConflict(err error) bool { return isErr(err, errNameConflict) } +type causal interface { + Cause() error +} + func isErr(err error, expected error) bool { - err = errors.Cause(err) switch pe := err.(type) { case nil: return false - case *OpErr: - err = errors.Cause(pe.Err) + case causal: + return isErr(pe.Cause(), expected) } return err == expected } diff --git a/vendor/github.com/docker/docker/volume/store/store.go b/vendor/github.com/docker/docker/volume/store/store.go index b1742061b..e47ec0e7d 100644 --- a/vendor/github.com/docker/docker/volume/store/store.go +++ b/vendor/github.com/docker/docker/volume/store/store.go @@ -4,6 +4,7 @@ import ( "net" "os" "path/filepath" + "runtime" "sync" "time" @@ -188,7 +189,7 @@ func (s *VolumeStore) List() ([]volume.Volume, []string, error) { var out []volume.Volume for _, v := range vols { - name := normaliseVolumeName(v.Name()) + name := normalizeVolumeName(v.Name()) s.locks.Lock(name) storedV, exists := s.getNamed(name) @@ -269,7 +270,7 @@ func (s *VolumeStore) list() ([]volume.Volume, []string, error) { // CreateWithRef creates a volume with the given name and driver and stores the ref // This ensures there's no race between creating a volume and then storing a reference. func (s *VolumeStore) CreateWithRef(name, driverName, ref string, opts, labels map[string]string) (volume.Volume, error) { - name = normaliseVolumeName(name) + name = normalizeVolumeName(name) s.locks.Lock(name) defer s.locks.Unlock(name) @@ -369,13 +370,14 @@ func volumeExists(v volume.Volume) (bool, error) { // It is expected that callers of this function hold any necessary locks. func (s *VolumeStore) create(name, driverName string, opts, labels map[string]string) (volume.Volume, error) { // Validate the name in a platform-specific manner - valid, err := volume.IsVolumeNameValid(name) + + // volume name validation is specific to the host os and not on container image + // windows/lcow should have an equivalent volumename validation logic so we create a parser for current host OS + parser := volume.NewParser(runtime.GOOS) + err := parser.ValidateVolumeName(name) if err != nil { return nil, err } - if !valid { - return nil, &OpErr{Err: errInvalidName, Name: name, Op: "create"} - } v, err := s.checkConflict(name, driverName) if err != nil { @@ -432,7 +434,7 @@ func (s *VolumeStore) create(name, driverName string, opts, labels map[string]st // This is just like Get(), but we store the reference while holding the lock. // This makes sure there are no races between checking for the existence of a volume and adding a reference for it func (s *VolumeStore) GetWithRef(name, driverName, ref string) (volume.Volume, error) { - name = normaliseVolumeName(name) + name = normalizeVolumeName(name) s.locks.Lock(name) defer s.locks.Unlock(name) @@ -455,7 +457,7 @@ func (s *VolumeStore) GetWithRef(name, driverName, ref string) (volume.Volume, e // Get looks if a volume with the given name exists and returns it if so func (s *VolumeStore) Get(name string) (volume.Volume, error) { - name = normaliseVolumeName(name) + name = normalizeVolumeName(name) s.locks.Lock(name) defer s.locks.Unlock(name) @@ -558,7 +560,7 @@ func lookupVolume(driverName, volumeName string) (volume.Volume, error) { // Remove removes the requested volume. A volume is not removed if it has any refs func (s *VolumeStore) Remove(v volume.Volume) error { - name := normaliseVolumeName(v.Name()) + name := normalizeVolumeName(v.Name()) s.locks.Lock(name) defer s.locks.Unlock(name) diff --git a/vendor/github.com/docker/docker/volume/store/store_unix.go b/vendor/github.com/docker/docker/volume/store/store_unix.go index 8ebc1f20c..c024abbf9 100644 --- a/vendor/github.com/docker/docker/volume/store/store_unix.go +++ b/vendor/github.com/docker/docker/volume/store/store_unix.go @@ -2,8 +2,8 @@ package store -// normaliseVolumeName is a platform specific function to normalise the name +// normalizeVolumeName is a platform specific function to normalize the name // of a volume. This is a no-op on Unix-like platforms -func normaliseVolumeName(name string) string { +func normalizeVolumeName(name string) string { return name } diff --git a/vendor/github.com/docker/docker/volume/store/store_windows.go b/vendor/github.com/docker/docker/volume/store/store_windows.go index 8601cdd5c..9e91a5f02 100644 --- a/vendor/github.com/docker/docker/volume/store/store_windows.go +++ b/vendor/github.com/docker/docker/volume/store/store_windows.go @@ -2,11 +2,11 @@ package store import "strings" -// normaliseVolumeName is a platform specific function to normalise the name +// normalizeVolumeName is a platform specific function to normalize the name // of a volume. On Windows, as NTFS is case insensitive, under // c:\ProgramData\Docker\Volumes\, the folders John and john would be synonymous. // Hence we can't allow the volume "John" and "john" to be created as separate // volumes. -func normaliseVolumeName(name string) string { +func normalizeVolumeName(name string) string { return strings.ToLower(name) } diff --git a/vendor/github.com/docker/docker/volume/validate.go b/vendor/github.com/docker/docker/volume/validate.go index 42396a0da..b3f640948 100644 --- a/vendor/github.com/docker/docker/volume/validate.go +++ b/vendor/github.com/docker/docker/volume/validate.go @@ -1,108 +1,14 @@ package volume import ( - "errors" "fmt" - "os" - "path/filepath" "github.com/docker/docker/api/types/mount" + "github.com/pkg/errors" ) var errBindNotExist = errors.New("bind source path does not exist") -type validateOpts struct { - skipBindSourceCheck bool - skipAbsolutePathCheck bool -} - -func validateMountConfig(mnt *mount.Mount, options ...func(*validateOpts)) error { - opts := validateOpts{} - for _, o := range options { - o(&opts) - } - - if len(mnt.Target) == 0 { - return &errMountConfig{mnt, errMissingField("Target")} - } - - if err := validateNotRoot(mnt.Target); err != nil { - return &errMountConfig{mnt, err} - } - - if !opts.skipAbsolutePathCheck { - if err := validateAbsolute(mnt.Target); err != nil { - return &errMountConfig{mnt, err} - } - } - - switch mnt.Type { - case mount.TypeBind: - if len(mnt.Source) == 0 { - return &errMountConfig{mnt, errMissingField("Source")} - } - // Don't error out just because the propagation mode is not supported on the platform - if opts := mnt.BindOptions; opts != nil { - if len(opts.Propagation) > 0 && len(propagationModes) > 0 { - if _, ok := propagationModes[opts.Propagation]; !ok { - return &errMountConfig{mnt, fmt.Errorf("invalid propagation mode: %s", opts.Propagation)} - } - } - } - if mnt.VolumeOptions != nil { - return &errMountConfig{mnt, errExtraField("VolumeOptions")} - } - - if err := validateAbsolute(mnt.Source); err != nil { - return &errMountConfig{mnt, err} - } - - // Do not allow binding to non-existent path - if !opts.skipBindSourceCheck { - fi, err := os.Stat(mnt.Source) - if err != nil { - if !os.IsNotExist(err) { - return &errMountConfig{mnt, err} - } - return &errMountConfig{mnt, errBindNotExist} - } - if err := validateStat(fi); err != nil { - return &errMountConfig{mnt, err} - } - } - case mount.TypeVolume: - if mnt.BindOptions != nil { - return &errMountConfig{mnt, errExtraField("BindOptions")} - } - - if len(mnt.Source) == 0 && mnt.ReadOnly { - return &errMountConfig{mnt, fmt.Errorf("must not set ReadOnly mode when using anonymous volumes")} - } - - if len(mnt.Source) != 0 { - if valid, err := IsVolumeNameValid(mnt.Source); !valid { - if err == nil { - err = errors.New("invalid volume name") - } - return &errMountConfig{mnt, err} - } - } - case mount.TypeTmpfs: - if len(mnt.Source) != 0 { - return &errMountConfig{mnt, errExtraField("Source")} - } - if err := ValidateTmpfsMountDestination(mnt.Target); err != nil { - return &errMountConfig{mnt, err} - } - if _, err := ConvertTmpfsOptions(mnt.TmpfsOptions, mnt.ReadOnly); err != nil { - return &errMountConfig{mnt, err} - } - default: - return &errMountConfig{mnt, errors.New("mount type unknown")} - } - return nil -} - type errMountConfig struct { mount *mount.Mount err error @@ -113,28 +19,8 @@ func (e *errMountConfig) Error() string { } func errExtraField(name string) error { - return fmt.Errorf("field %s must not be specified", name) + return errors.Errorf("field %s must not be specified", name) } func errMissingField(name string) error { - return fmt.Errorf("field %s must not be empty", name) -} - -func validateAbsolute(p string) error { - p = convertSlash(p) - if filepath.IsAbs(p) { - return nil - } - return fmt.Errorf("invalid mount path: '%s' mount path must be absolute", p) -} - -// ValidateTmpfsMountDestination validates the destination of tmpfs mount. -// Currently, we have only two obvious rule for validation: -// - path must not be "/" -// - path must be absolute -// We should add more rules carefully (#30166) -func ValidateTmpfsMountDestination(dest string) error { - if err := validateNotRoot(dest); err != nil { - return err - } - return validateAbsolute(dest) + return errors.Errorf("field %s must not be empty", name) } diff --git a/vendor/github.com/docker/docker/volume/validate_test.go b/vendor/github.com/docker/docker/volume/validate_test.go index 8732500fc..6a8e28682 100644 --- a/vendor/github.com/docker/docker/volume/validate_test.go +++ b/vendor/github.com/docker/docker/volume/validate_test.go @@ -4,6 +4,7 @@ import ( "errors" "io/ioutil" "os" + "runtime" "strings" "testing" @@ -27,17 +28,50 @@ func TestValidateMount(t *testing.T) { {mount.Mount{Type: mount.TypeBind}, errMissingField("Target")}, {mount.Mount{Type: mount.TypeBind, Target: testDestinationPath}, errMissingField("Source")}, {mount.Mount{Type: mount.TypeBind, Target: testDestinationPath, Source: testSourcePath, VolumeOptions: &mount.VolumeOptions{}}, errExtraField("VolumeOptions")}, - {mount.Mount{Type: mount.TypeBind, Source: testSourcePath, Target: testDestinationPath}, errBindNotExist}, + {mount.Mount{Type: mount.TypeBind, Source: testDir, Target: testDestinationPath}, nil}, {mount.Mount{Type: "invalid", Target: testDestinationPath}, errors.New("mount type unknown")}, } + if runtime.GOOS == "windows" { + cases = append(cases, struct { + input mount.Mount + expected error + }{mount.Mount{Type: mount.TypeBind, Source: testSourcePath, Target: testDestinationPath}, errBindNotExist}) // bind source existance is not checked on linux + } + lcowCases := []struct { + input mount.Mount + expected error + }{ + {mount.Mount{Type: mount.TypeVolume}, errMissingField("Target")}, + {mount.Mount{Type: mount.TypeVolume, Target: "/foo", Source: "hello"}, nil}, + {mount.Mount{Type: mount.TypeVolume, Target: "/foo"}, nil}, + {mount.Mount{Type: mount.TypeBind}, errMissingField("Target")}, + {mount.Mount{Type: mount.TypeBind, Target: "/foo"}, errMissingField("Source")}, + {mount.Mount{Type: mount.TypeBind, Target: "/foo", Source: "c:\\foo", VolumeOptions: &mount.VolumeOptions{}}, errExtraField("VolumeOptions")}, + {mount.Mount{Type: mount.TypeBind, Source: "c:\\foo", Target: "/foo"}, errBindNotExist}, + {mount.Mount{Type: mount.TypeBind, Source: testDir, Target: "/foo"}, nil}, + {mount.Mount{Type: "invalid", Target: "/foo"}, errors.New("mount type unknown")}, + } + parser := NewParser(runtime.GOOS) for i, x := range cases { - err := validateMountConfig(&x.input) + err := parser.validateMountConfig(&x.input) if err == nil && x.expected == nil { continue } if (err == nil && x.expected != nil) || (x.expected == nil && err != nil) || !strings.Contains(err.Error(), x.expected.Error()) { - t.Fatalf("expected %q, got %q, case: %d", x.expected, err, i) + t.Errorf("expected %q, got %q, case: %d", x.expected, err, i) + } + } + if runtime.GOOS == "windows" { + parser = &lcowParser{} + for i, x := range lcowCases { + err := parser.validateMountConfig(&x.input) + if err == nil && x.expected == nil { + continue + } + if (err == nil && x.expected != nil) || (x.expected == nil && err != nil) || !strings.Contains(err.Error(), x.expected.Error()) { + t.Errorf("expected %q, got %q, case: %d", x.expected, err, i) + } } } } diff --git a/vendor/github.com/docker/docker/volume/validate_test_unix.go b/vendor/github.com/docker/docker/volume/validate_unix_test.go similarity index 100% rename from vendor/github.com/docker/docker/volume/validate_test_unix.go rename to vendor/github.com/docker/docker/volume/validate_unix_test.go diff --git a/vendor/github.com/docker/docker/volume/validate_test_windows.go b/vendor/github.com/docker/docker/volume/validate_windows_test.go similarity index 100% rename from vendor/github.com/docker/docker/volume/validate_test_windows.go rename to vendor/github.com/docker/docker/volume/validate_windows_test.go diff --git a/vendor/github.com/docker/docker/volume/volume.go b/vendor/github.com/docker/docker/volume/volume.go index 8598d4cb8..4aa4de513 100644 --- a/vendor/github.com/docker/docker/volume/volume.go +++ b/vendor/github.com/docker/docker/volume/volume.go @@ -3,8 +3,6 @@ package volume import ( "fmt" "os" - "path/filepath" - "strings" "syscall" "time" @@ -217,158 +215,10 @@ func (m *MountPoint) Path() string { return m.Source } -// ParseVolumesFrom ensures that the supplied volumes-from is valid. -func ParseVolumesFrom(spec string) (string, string, error) { - if len(spec) == 0 { - return "", "", fmt.Errorf("volumes-from specification cannot be an empty string") - } - - specParts := strings.SplitN(spec, ":", 2) - id := specParts[0] - mode := "rw" - - if len(specParts) == 2 { - mode = specParts[1] - if !ValidMountMode(mode) { - return "", "", errInvalidMode(mode) - } - // For now don't allow propagation properties while importing - // volumes from data container. These volumes will inherit - // the same propagation property as of the original volume - // in data container. This probably can be relaxed in future. - if HasPropagation(mode) { - return "", "", errInvalidMode(mode) - } - // Do not allow copy modes on volumes-from - if _, isSet := getCopyMode(mode); isSet { - return "", "", errInvalidMode(mode) - } - } - return id, mode, nil -} - -// ParseMountRaw parses a raw volume spec (e.g. `-v /foo:/bar:shared`) into a -// structured spec. Once the raw spec is parsed it relies on `ParseMountSpec` to -// validate the spec and create a MountPoint -func ParseMountRaw(raw, volumeDriver string) (*MountPoint, error) { - arr, err := splitRawSpec(convertSlash(raw)) - if err != nil { - return nil, err - } - - var spec mounttypes.Mount - var mode string - switch len(arr) { - case 1: - // Just a destination path in the container - spec.Target = arr[0] - case 2: - if ValidMountMode(arr[1]) { - // Destination + Mode is not a valid volume - volumes - // cannot include a mode. e.g. /foo:rw - return nil, errInvalidSpec(raw) - } - // Host Source Path or Name + Destination - spec.Source = arr[0] - spec.Target = arr[1] - case 3: - // HostSourcePath+DestinationPath+Mode - spec.Source = arr[0] - spec.Target = arr[1] - mode = arr[2] - default: - return nil, errInvalidSpec(raw) - } - - if !ValidMountMode(mode) { - return nil, errInvalidMode(mode) - } - - if filepath.IsAbs(spec.Source) { - spec.Type = mounttypes.TypeBind - } else { - spec.Type = mounttypes.TypeVolume - } - - spec.ReadOnly = !ReadWrite(mode) - - // cannot assume that if a volume driver is passed in that we should set it - if volumeDriver != "" && spec.Type == mounttypes.TypeVolume { - spec.VolumeOptions = &mounttypes.VolumeOptions{ - DriverConfig: &mounttypes.Driver{Name: volumeDriver}, - } - } - - if copyData, isSet := getCopyMode(mode); isSet { - if spec.VolumeOptions == nil { - spec.VolumeOptions = &mounttypes.VolumeOptions{} - } - spec.VolumeOptions.NoCopy = !copyData - } - if HasPropagation(mode) { - spec.BindOptions = &mounttypes.BindOptions{ - Propagation: GetPropagation(mode), - } - } - - mp, err := ParseMountSpec(spec, platformRawValidationOpts...) - if mp != nil { - mp.Mode = mode - } - if err != nil { - err = fmt.Errorf("%v: %v", errInvalidSpec(raw), err) - } - return mp, err -} - -// ParseMountSpec reads a mount config, validates it, and configures a mountpoint from it. -func ParseMountSpec(cfg mounttypes.Mount, options ...func(*validateOpts)) (*MountPoint, error) { - if err := validateMountConfig(&cfg, options...); err != nil { - return nil, err - } - mp := &MountPoint{ - RW: !cfg.ReadOnly, - Destination: clean(convertSlash(cfg.Target)), - Type: cfg.Type, - Spec: cfg, - } - - switch cfg.Type { - case mounttypes.TypeVolume: - if cfg.Source == "" { - mp.Name = stringid.GenerateNonCryptoID() - } else { - mp.Name = cfg.Source - } - mp.CopyData = DefaultCopyMode - - if cfg.VolumeOptions != nil { - if cfg.VolumeOptions.DriverConfig != nil { - mp.Driver = cfg.VolumeOptions.DriverConfig.Name - } - if cfg.VolumeOptions.NoCopy { - mp.CopyData = false - } - } - case mounttypes.TypeBind: - mp.Source = clean(convertSlash(cfg.Source)) - if cfg.BindOptions != nil && len(cfg.BindOptions.Propagation) > 0 { - mp.Propagation = cfg.BindOptions.Propagation - } else { - // If user did not specify a propagation mode, get - // default propagation mode. - mp.Propagation = DefaultPropagationMode - } - case mounttypes.TypeTmpfs: - // NOP - } - return mp, nil -} - func errInvalidMode(mode string) error { - return fmt.Errorf("invalid mode: %v", mode) + return errors.Errorf("invalid mode: %v", mode) } func errInvalidSpec(spec string) error { - return fmt.Errorf("invalid volume specification: '%s'", spec) + return errors.Errorf("invalid volume specification: '%s'", spec) } diff --git a/vendor/github.com/docker/docker/volume/volume_copy.go b/vendor/github.com/docker/docker/volume/volume_copy.go index 77f06a0d1..37c7fa74a 100644 --- a/vendor/github.com/docker/docker/volume/volume_copy.go +++ b/vendor/github.com/docker/docker/volume/volume_copy.go @@ -13,11 +13,11 @@ func copyModeExists(mode string) bool { } // GetCopyMode gets the copy mode from the mode string for mounts -func getCopyMode(mode string) (bool, bool) { +func getCopyMode(mode string, def bool) (bool, bool) { for _, o := range strings.Split(mode, ",") { if isEnabled, exists := copyModes[o]; exists { return isEnabled, true } } - return DefaultCopyMode, false + return def, false } diff --git a/vendor/github.com/docker/docker/volume/volume_copy_unix.go b/vendor/github.com/docker/docker/volume/volume_copy_unix.go deleted file mode 100644 index ad66e1763..000000000 --- a/vendor/github.com/docker/docker/volume/volume_copy_unix.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build !windows - -package volume - -const ( - // DefaultCopyMode is the copy mode used by default for normal/named volumes - DefaultCopyMode = true -) diff --git a/vendor/github.com/docker/docker/volume/volume_copy_windows.go b/vendor/github.com/docker/docker/volume/volume_copy_windows.go deleted file mode 100644 index 798638c87..000000000 --- a/vendor/github.com/docker/docker/volume/volume_copy_windows.go +++ /dev/null @@ -1,6 +0,0 @@ -package volume - -const ( - // DefaultCopyMode is the copy mode used by default for normal/named volumes - DefaultCopyMode = false -) diff --git a/vendor/github.com/docker/docker/volume/volume_linux.go b/vendor/github.com/docker/docker/volume/volume_linux.go deleted file mode 100644 index fdf7b63e4..000000000 --- a/vendor/github.com/docker/docker/volume/volume_linux.go +++ /dev/null @@ -1,56 +0,0 @@ -// +build linux - -package volume - -import ( - "fmt" - "strings" - - mounttypes "github.com/docker/docker/api/types/mount" -) - -// ConvertTmpfsOptions converts *mounttypes.TmpfsOptions to the raw option string -// for mount(2). -func ConvertTmpfsOptions(opt *mounttypes.TmpfsOptions, readOnly bool) (string, error) { - var rawOpts []string - if readOnly { - rawOpts = append(rawOpts, "ro") - } - - if opt != nil && opt.Mode != 0 { - rawOpts = append(rawOpts, fmt.Sprintf("mode=%o", opt.Mode)) - } - - if opt != nil && opt.SizeBytes != 0 { - // calculate suffix here, making this linux specific, but that is - // okay, since API is that way anyways. - - // we do this by finding the suffix that divides evenly into the - // value, returning the value itself, with no suffix, if it fails. - // - // For the most part, we don't enforce any semantic to this values. - // The operating system will usually align this and enforce minimum - // and maximums. - var ( - size = opt.SizeBytes - suffix string - ) - for _, r := range []struct { - suffix string - divisor int64 - }{ - {"g", 1 << 30}, - {"m", 1 << 20}, - {"k", 1 << 10}, - } { - if size%r.divisor == 0 { - size = size / r.divisor - suffix = r.suffix - break - } - } - - rawOpts = append(rawOpts, fmt.Sprintf("size=%d%s", size, suffix)) - } - return strings.Join(rawOpts, ","), nil -} diff --git a/vendor/github.com/docker/docker/volume/volume_linux_test.go b/vendor/github.com/docker/docker/volume/volume_linux_test.go deleted file mode 100644 index 40ce5525a..000000000 --- a/vendor/github.com/docker/docker/volume/volume_linux_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// +build linux - -package volume - -import ( - "strings" - "testing" - - mounttypes "github.com/docker/docker/api/types/mount" -) - -func TestConvertTmpfsOptions(t *testing.T) { - type testCase struct { - opt mounttypes.TmpfsOptions - readOnly bool - expectedSubstrings []string - unexpectedSubstrings []string - } - cases := []testCase{ - { - opt: mounttypes.TmpfsOptions{SizeBytes: 1024 * 1024, Mode: 0700}, - readOnly: false, - expectedSubstrings: []string{"size=1m", "mode=700"}, - unexpectedSubstrings: []string{"ro"}, - }, - { - opt: mounttypes.TmpfsOptions{}, - readOnly: true, - expectedSubstrings: []string{"ro"}, - unexpectedSubstrings: []string{}, - }, - } - for _, c := range cases { - data, err := ConvertTmpfsOptions(&c.opt, c.readOnly) - if err != nil { - t.Fatalf("could not convert %+v (readOnly: %v) to string: %v", - c.opt, c.readOnly, err) - } - t.Logf("data=%q", data) - for _, s := range c.expectedSubstrings { - if !strings.Contains(data, s) { - t.Fatalf("expected substring: %s, got %v (case=%+v)", s, data, c) - } - } - for _, s := range c.unexpectedSubstrings { - if strings.Contains(data, s) { - t.Fatalf("unexpected substring: %s, got %v (case=%+v)", s, data, c) - } - } - } -} diff --git a/vendor/github.com/docker/docker/volume/volume_propagation_linux.go b/vendor/github.com/docker/docker/volume/volume_propagation_linux.go deleted file mode 100644 index 1de57ab52..000000000 --- a/vendor/github.com/docker/docker/volume/volume_propagation_linux.go +++ /dev/null @@ -1,47 +0,0 @@ -// +build linux - -package volume - -import ( - "strings" - - mounttypes "github.com/docker/docker/api/types/mount" -) - -// DefaultPropagationMode defines what propagation mode should be used by -// default if user has not specified one explicitly. -// propagation modes -const DefaultPropagationMode = mounttypes.PropagationRPrivate - -var propagationModes = map[mounttypes.Propagation]bool{ - mounttypes.PropagationPrivate: true, - mounttypes.PropagationRPrivate: true, - mounttypes.PropagationSlave: true, - mounttypes.PropagationRSlave: true, - mounttypes.PropagationShared: true, - mounttypes.PropagationRShared: true, -} - -// GetPropagation extracts and returns the mount propagation mode. If there -// are no specifications, then by default it is "private". -func GetPropagation(mode string) mounttypes.Propagation { - for _, o := range strings.Split(mode, ",") { - prop := mounttypes.Propagation(o) - if propagationModes[prop] { - return prop - } - } - return DefaultPropagationMode -} - -// HasPropagation checks if there is a valid propagation mode present in -// passed string. Returns true if a valid propagation mode specifier is -// present, false otherwise. -func HasPropagation(mode string) bool { - for _, o := range strings.Split(mode, ",") { - if propagationModes[mounttypes.Propagation(o)] { - return true - } - } - return false -} diff --git a/vendor/github.com/docker/docker/volume/volume_propagation_linux_test.go b/vendor/github.com/docker/docker/volume/volume_propagation_linux_test.go deleted file mode 100644 index 46d026506..000000000 --- a/vendor/github.com/docker/docker/volume/volume_propagation_linux_test.go +++ /dev/null @@ -1,65 +0,0 @@ -// +build linux - -package volume - -import ( - "strings" - "testing" -) - -func TestParseMountRawPropagation(t *testing.T) { - var ( - valid []string - invalid map[string]string - ) - - valid = []string{ - "/hostPath:/containerPath:shared", - "/hostPath:/containerPath:rshared", - "/hostPath:/containerPath:slave", - "/hostPath:/containerPath:rslave", - "/hostPath:/containerPath:private", - "/hostPath:/containerPath:rprivate", - "/hostPath:/containerPath:ro,shared", - "/hostPath:/containerPath:ro,slave", - "/hostPath:/containerPath:ro,private", - "/hostPath:/containerPath:ro,z,shared", - "/hostPath:/containerPath:ro,Z,slave", - "/hostPath:/containerPath:Z,ro,slave", - "/hostPath:/containerPath:slave,Z,ro", - "/hostPath:/containerPath:Z,slave,ro", - "/hostPath:/containerPath:slave,ro,Z", - "/hostPath:/containerPath:rslave,ro,Z", - "/hostPath:/containerPath:ro,rshared,Z", - "/hostPath:/containerPath:ro,Z,rprivate", - } - invalid = map[string]string{ - "/path:/path:ro,rshared,rslave": `invalid mode`, - "/path:/path:ro,z,rshared,rslave": `invalid mode`, - "/path:shared": "invalid volume specification", - "/path:slave": "invalid volume specification", - "/path:private": "invalid volume specification", - "name:/absolute-path:shared": "invalid volume specification", - "name:/absolute-path:rshared": "invalid volume specification", - "name:/absolute-path:slave": "invalid volume specification", - "name:/absolute-path:rslave": "invalid volume specification", - "name:/absolute-path:private": "invalid volume specification", - "name:/absolute-path:rprivate": "invalid volume specification", - } - - for _, path := range valid { - if _, err := ParseMountRaw(path, "local"); err != nil { - t.Fatalf("ParseMountRaw(`%q`) should succeed: error %q", path, err) - } - } - - for path, expectedError := range invalid { - if _, err := ParseMountRaw(path, "local"); err == nil { - t.Fatalf("ParseMountRaw(`%q`) should have failed validation. Err %v", path, err) - } else { - if !strings.Contains(err.Error(), expectedError) { - t.Fatalf("ParseMountRaw(`%q`) error should contain %q, got %v", path, expectedError, err.Error()) - } - } - } -} diff --git a/vendor/github.com/docker/docker/volume/volume_propagation_unsupported.go b/vendor/github.com/docker/docker/volume/volume_propagation_unsupported.go deleted file mode 100644 index 7311ffc2e..000000000 --- a/vendor/github.com/docker/docker/volume/volume_propagation_unsupported.go +++ /dev/null @@ -1,24 +0,0 @@ -// +build !linux - -package volume - -import mounttypes "github.com/docker/docker/api/types/mount" - -// DefaultPropagationMode is used only in linux. In other cases it returns -// empty string. -const DefaultPropagationMode mounttypes.Propagation = "" - -// propagation modes not supported on this platform. -var propagationModes = map[mounttypes.Propagation]bool{} - -// GetPropagation is not supported. Return empty string. -func GetPropagation(mode string) mounttypes.Propagation { - return DefaultPropagationMode -} - -// HasPropagation checks if there is a valid propagation mode present in -// passed string. Returns true if a valid propagation mode specifier is -// present, false otherwise. -func HasPropagation(mode string) bool { - return false -} diff --git a/vendor/github.com/docker/docker/volume/volume_test.go b/vendor/github.com/docker/docker/volume/volume_test.go index 5c3e0e381..9f2020d58 100644 --- a/vendor/github.com/docker/docker/volume/volume_test.go +++ b/vendor/github.com/docker/docker/volume/volume_test.go @@ -10,14 +10,84 @@ import ( "github.com/docker/docker/api/types/mount" ) +type parseMountRawTestSet struct { + valid []string + invalid map[string]string +} + +func TestConvertTmpfsOptions(t *testing.T) { + type testCase struct { + opt mount.TmpfsOptions + readOnly bool + expectedSubstrings []string + unexpectedSubstrings []string + } + cases := []testCase{ + { + opt: mount.TmpfsOptions{SizeBytes: 1024 * 1024, Mode: 0700}, + readOnly: false, + expectedSubstrings: []string{"size=1m", "mode=700"}, + unexpectedSubstrings: []string{"ro"}, + }, + { + opt: mount.TmpfsOptions{}, + readOnly: true, + expectedSubstrings: []string{"ro"}, + unexpectedSubstrings: []string{}, + }, + } + p := &linuxParser{} + for _, c := range cases { + data, err := p.ConvertTmpfsOptions(&c.opt, c.readOnly) + if err != nil { + t.Fatalf("could not convert %+v (readOnly: %v) to string: %v", + c.opt, c.readOnly, err) + } + t.Logf("data=%q", data) + for _, s := range c.expectedSubstrings { + if !strings.Contains(data, s) { + t.Fatalf("expected substring: %s, got %v (case=%+v)", s, data, c) + } + } + for _, s := range c.unexpectedSubstrings { + if strings.Contains(data, s) { + t.Fatalf("unexpected substring: %s, got %v (case=%+v)", s, data, c) + } + } + } +} + +type mockFiProvider struct{} + +func (mockFiProvider) fileInfo(path string) (exists, isDir bool, err error) { + dirs := map[string]struct{}{ + `c:\`: {}, + `c:\windows\`: {}, + `c:\windows`: {}, + `c:\program files`: {}, + `c:\Windows`: {}, + `c:\Program Files (x86)`: {}, + `\\?\c:\windows\`: {}, + } + files := map[string]struct{}{ + `c:\windows\system32\ntdll.dll`: {}, + } + if _, ok := dirs[path]; ok { + return true, true, nil + } + if _, ok := files[path]; ok { + return true, false, nil + } + return false, false, nil +} + func TestParseMountRaw(t *testing.T) { - var ( - valid []string - invalid map[string]string - ) - if runtime.GOOS == "windows" { - valid = []string{ + previousProvider := currentFileInfoProvider + defer func() { currentFileInfoProvider = previousProvider }() + currentFileInfoProvider = mockFiProvider{} + windowsSet := parseMountRawTestSet{ + valid: []string{ `d:\`, `d:`, `d:\path`, @@ -35,10 +105,14 @@ func TestParseMountRaw(t *testing.T) { `name:D::RO`, `c:/:d:/forward/slashes/are/good/too`, `c:/:d:/including with/spaces:ro`, - `c:\Windows`, // With capital - `c:\Program Files (x86)`, // With capitals and brackets - } - invalid = map[string]string{ + `c:\Windows`, // With capital + `c:\Program Files (x86)`, // With capitals and brackets + `\\?\c:\windows\:d:`, // Long path handling (source) + `c:\windows\:\\?\d:\`, // Long path handling (target) + `\\.\pipe\foo:\\.\pipe\foo`, // named pipe + `//./pipe/foo://./pipe/foo`, // named pipe forward slashes + }, + invalid: map[string]string{ ``: "invalid volume specification: ", `.`: "invalid volume specification: ", `..\`: "invalid volume specification: ", @@ -82,10 +156,79 @@ func TestParseMountRaw(t *testing.T) { `lpt8:d:`: `cannot be a reserved word for Windows filenames`, `lpt9:d:`: `cannot be a reserved word for Windows filenames`, `c:\windows\system32\ntdll.dll`: `Only directories can be mapped on this platform`, - } - - } else { - valid = []string{ + `\\.\pipe\foo:c:\pipe`: `'c:\pipe' is not a valid pipe path`, + }, + } + lcowSet := parseMountRawTestSet{ + valid: []string{ + `/foo`, + `/foo/`, + `/foo bar`, + `c:\:/foo`, + `c:\windows\:/foo`, + `c:\windows:/s p a c e`, + `c:\windows:/s p a c e:RW`, + `c:\program files:/s p a c e i n h o s t d i r`, + `0123456789name:/foo`, + `MiXeDcAsEnAmE:/foo`, + `name:/foo`, + `name:/foo:rW`, + `name:/foo:RW`, + `name:/foo:RO`, + `c:/:/forward/slashes/are/good/too`, + `c:/:/including with/spaces:ro`, + `/Program Files (x86)`, // With capitals and brackets + }, + invalid: map[string]string{ + ``: "invalid volume specification: ", + `.`: "invalid volume specification: ", + `c:`: "invalid volume specification: ", + `c:\`: "invalid volume specification: ", + `../`: "invalid volume specification: ", + `c:\:../`: "invalid volume specification: ", + `c:\:/foo:xyzzy`: "invalid volume specification: ", + `/`: "destination can't be '/'", + `/..`: "destination can't be '/'", + `c:\notexist:/foo`: `source path does not exist`, + `c:\windows\system32\ntdll.dll:/foo`: `source path must be a directory`, + `name<:/foo`: `invalid volume specification`, + `name>:/foo`: `invalid volume specification`, + `name::/foo`: `invalid volume specification`, + `name":/foo`: `invalid volume specification`, + `name\:/foo`: `invalid volume specification`, + `name*:/foo`: `invalid volume specification`, + `name|:/foo`: `invalid volume specification`, + `name?:/foo`: `invalid volume specification`, + `name/:/foo`: `invalid volume specification`, + `/foo:rw`: `invalid volume specification`, + `/foo:ro`: `invalid volume specification`, + `con:/foo`: `cannot be a reserved word for Windows filenames`, + `PRN:/foo`: `cannot be a reserved word for Windows filenames`, + `aUx:/foo`: `cannot be a reserved word for Windows filenames`, + `nul:/foo`: `cannot be a reserved word for Windows filenames`, + `com1:/foo`: `cannot be a reserved word for Windows filenames`, + `com2:/foo`: `cannot be a reserved word for Windows filenames`, + `com3:/foo`: `cannot be a reserved word for Windows filenames`, + `com4:/foo`: `cannot be a reserved word for Windows filenames`, + `com5:/foo`: `cannot be a reserved word for Windows filenames`, + `com6:/foo`: `cannot be a reserved word for Windows filenames`, + `com7:/foo`: `cannot be a reserved word for Windows filenames`, + `com8:/foo`: `cannot be a reserved word for Windows filenames`, + `com9:/foo`: `cannot be a reserved word for Windows filenames`, + `lpt1:/foo`: `cannot be a reserved word for Windows filenames`, + `lpt2:/foo`: `cannot be a reserved word for Windows filenames`, + `lpt3:/foo`: `cannot be a reserved word for Windows filenames`, + `lpt4:/foo`: `cannot be a reserved word for Windows filenames`, + `lpt5:/foo`: `cannot be a reserved word for Windows filenames`, + `lpt6:/foo`: `cannot be a reserved word for Windows filenames`, + `lpt7:/foo`: `cannot be a reserved word for Windows filenames`, + `lpt8:/foo`: `cannot be a reserved word for Windows filenames`, + `lpt9:/foo`: `cannot be a reserved word for Windows filenames`, + `\\.\pipe\foo:/foo`: `Linux containers on Windows do not support named pipe mounts`, + }, + } + linuxSet := parseMountRawTestSet{ + valid: []string{ "/home", "/home:/home", "/home:/something/else", @@ -95,47 +238,87 @@ func TestParseMountRaw(t *testing.T) { "hostPath:/containerPath:ro", "/hostPath:/containerPath:rw", "/rw:/ro", - } - invalid = map[string]string{ - "": "invalid volume specification", - "./": "mount path must be absolute", - "../": "mount path must be absolute", - "/:../": "mount path must be absolute", - "/:path": "mount path must be absolute", - ":": "invalid volume specification", - "/tmp:": "invalid volume specification", - ":test": "invalid volume specification", - ":/test": "invalid volume specification", - "tmp:": "invalid volume specification", - ":test:": "invalid volume specification", - "::": "invalid volume specification", - ":::": "invalid volume specification", - "/tmp:::": "invalid volume specification", - ":/tmp::": "invalid volume specification", - "/path:rw": "invalid volume specification", - "/path:ro": "invalid volume specification", - "/rw:rw": "invalid volume specification", - "path:ro": "invalid volume specification", - "/path:/path:sw": `invalid mode`, - "/path:/path:rwz": `invalid mode`, - } + "/hostPath:/containerPath:shared", + "/hostPath:/containerPath:rshared", + "/hostPath:/containerPath:slave", + "/hostPath:/containerPath:rslave", + "/hostPath:/containerPath:private", + "/hostPath:/containerPath:rprivate", + "/hostPath:/containerPath:ro,shared", + "/hostPath:/containerPath:ro,slave", + "/hostPath:/containerPath:ro,private", + "/hostPath:/containerPath:ro,z,shared", + "/hostPath:/containerPath:ro,Z,slave", + "/hostPath:/containerPath:Z,ro,slave", + "/hostPath:/containerPath:slave,Z,ro", + "/hostPath:/containerPath:Z,slave,ro", + "/hostPath:/containerPath:slave,ro,Z", + "/hostPath:/containerPath:rslave,ro,Z", + "/hostPath:/containerPath:ro,rshared,Z", + "/hostPath:/containerPath:ro,Z,rprivate", + }, + invalid: map[string]string{ + "": "invalid volume specification", + "./": "mount path must be absolute", + "../": "mount path must be absolute", + "/:../": "mount path must be absolute", + "/:path": "mount path must be absolute", + ":": "invalid volume specification", + "/tmp:": "invalid volume specification", + ":test": "invalid volume specification", + ":/test": "invalid volume specification", + "tmp:": "invalid volume specification", + ":test:": "invalid volume specification", + "::": "invalid volume specification", + ":::": "invalid volume specification", + "/tmp:::": "invalid volume specification", + ":/tmp::": "invalid volume specification", + "/path:rw": "invalid volume specification", + "/path:ro": "invalid volume specification", + "/rw:rw": "invalid volume specification", + "path:ro": "invalid volume specification", + "/path:/path:sw": `invalid mode`, + "/path:/path:rwz": `invalid mode`, + "/path:/path:ro,rshared,rslave": `invalid mode`, + "/path:/path:ro,z,rshared,rslave": `invalid mode`, + "/path:shared": "invalid volume specification", + "/path:slave": "invalid volume specification", + "/path:private": "invalid volume specification", + "name:/absolute-path:shared": "invalid volume specification", + "name:/absolute-path:rshared": "invalid volume specification", + "name:/absolute-path:slave": "invalid volume specification", + "name:/absolute-path:rslave": "invalid volume specification", + "name:/absolute-path:private": "invalid volume specification", + "name:/absolute-path:rprivate": "invalid volume specification", + }, } - for _, path := range valid { - if _, err := ParseMountRaw(path, "local"); err != nil { - t.Fatalf("ParseMountRaw(`%q`) should succeed: error %q", path, err) + linParser := &linuxParser{} + winParser := &windowsParser{} + lcowParser := &lcowParser{} + tester := func(parser Parser, set parseMountRawTestSet) { + + for _, path := range set.valid { + + if _, err := parser.ParseMountRaw(path, "local"); err != nil { + t.Errorf("ParseMountRaw(`%q`) should succeed: error %q", path, err) + } } - } - for path, expectedError := range invalid { - if mp, err := ParseMountRaw(path, "local"); err == nil { - t.Fatalf("ParseMountRaw(`%q`) should have failed validation. Err '%v' - MP: %v", path, err, mp) - } else { - if !strings.Contains(err.Error(), expectedError) { - t.Fatalf("ParseMountRaw(`%q`) error should contain %q, got %v", path, expectedError, err.Error()) + for path, expectedError := range set.invalid { + if mp, err := parser.ParseMountRaw(path, "local"); err == nil { + t.Errorf("ParseMountRaw(`%q`) should have failed validation. Err '%v' - MP: %v", path, err, mp) + } else { + if !strings.Contains(err.Error(), expectedError) { + t.Errorf("ParseMountRaw(`%q`) error should contain %q, got %v", path, expectedError, err.Error()) + } } } } + tester(linParser, linuxSet) + tester(winParser, windowsSet) + tester(lcowParser, lcowSet) + } // testParseMountRaw is a structure used by TestParseMountRawSplit for @@ -143,6 +326,7 @@ func TestParseMountRaw(t *testing.T) { type testParseMountRaw struct { bind string driver string + expType mount.Type expDest string expSource string expName string @@ -152,69 +336,96 @@ type testParseMountRaw struct { } func TestParseMountRawSplit(t *testing.T) { - var cases []testParseMountRaw - if runtime.GOOS == "windows" { - cases = []testParseMountRaw{ - {`c:\:d:`, "local", `d:`, `c:\`, ``, "", true, false}, - {`c:\:d:\`, "local", `d:\`, `c:\`, ``, "", true, false}, - {`c:\:d:\:ro`, "local", `d:\`, `c:\`, ``, "", false, false}, - {`c:\:d:\:rw`, "local", `d:\`, `c:\`, ``, "", true, false}, - {`c:\:d:\:foo`, "local", `d:\`, `c:\`, ``, "", false, true}, - {`name:d::rw`, "local", `d:`, ``, `name`, "local", true, false}, - {`name:d:`, "local", `d:`, ``, `name`, "local", true, false}, - {`name:d::ro`, "local", `d:`, ``, `name`, "local", false, false}, - {`name:c:`, "", ``, ``, ``, "", true, true}, - {`driver/name:c:`, "", ``, ``, ``, "", true, true}, - } - } else { - cases = []testParseMountRaw{ - {"/tmp:/tmp1", "", "/tmp1", "/tmp", "", "", true, false}, - {"/tmp:/tmp2:ro", "", "/tmp2", "/tmp", "", "", false, false}, - {"/tmp:/tmp3:rw", "", "/tmp3", "/tmp", "", "", true, false}, - {"/tmp:/tmp4:foo", "", "", "", "", "", false, true}, - {"name:/named1", "", "/named1", "", "name", "", true, false}, - {"name:/named2", "external", "/named2", "", "name", "external", true, false}, - {"name:/named3:ro", "local", "/named3", "", "name", "local", false, false}, - {"local/name:/tmp:rw", "", "/tmp", "", "local/name", "", true, false}, - {"/tmp:tmp", "", "", "", "", "", true, true}, - } + previousProvider := currentFileInfoProvider + defer func() { currentFileInfoProvider = previousProvider }() + currentFileInfoProvider = mockFiProvider{} + windowsCases := []testParseMountRaw{ + {`c:\:d:`, "local", mount.TypeBind, `d:`, `c:\`, ``, "", true, false}, + {`c:\:d:\`, "local", mount.TypeBind, `d:\`, `c:\`, ``, "", true, false}, + {`c:\:d:\:ro`, "local", mount.TypeBind, `d:\`, `c:\`, ``, "", false, false}, + {`c:\:d:\:rw`, "local", mount.TypeBind, `d:\`, `c:\`, ``, "", true, false}, + {`c:\:d:\:foo`, "local", mount.TypeBind, `d:\`, `c:\`, ``, "", false, true}, + {`name:d::rw`, "local", mount.TypeVolume, `d:`, ``, `name`, "local", true, false}, + {`name:d:`, "local", mount.TypeVolume, `d:`, ``, `name`, "local", true, false}, + {`name:d::ro`, "local", mount.TypeVolume, `d:`, ``, `name`, "local", false, false}, + {`name:c:`, "", mount.TypeVolume, ``, ``, ``, "", true, true}, + {`driver/name:c:`, "", mount.TypeVolume, ``, ``, ``, "", true, true}, + {`\\.\pipe\foo:\\.\pipe\bar`, "local", mount.TypeNamedPipe, `\\.\pipe\bar`, `\\.\pipe\foo`, "", "", true, false}, + {`\\.\pipe\foo:c:\foo\bar`, "local", mount.TypeNamedPipe, ``, ``, "", "", true, true}, + {`c:\foo\bar:\\.\pipe\foo`, "local", mount.TypeNamedPipe, ``, ``, "", "", true, true}, } - - for i, c := range cases { - t.Logf("case %d", i) - m, err := ParseMountRaw(c.bind, c.driver) - if c.fail { - if err == nil { - t.Fatalf("Expected error, was nil, for spec %s\n", c.bind) + lcowCases := []testParseMountRaw{ + {`c:\:/foo`, "local", mount.TypeBind, `/foo`, `c:\`, ``, "", true, false}, + {`c:\:/foo:ro`, "local", mount.TypeBind, `/foo`, `c:\`, ``, "", false, false}, + {`c:\:/foo:rw`, "local", mount.TypeBind, `/foo`, `c:\`, ``, "", true, false}, + {`c:\:/foo:foo`, "local", mount.TypeBind, `/foo`, `c:\`, ``, "", false, true}, + {`name:/foo:rw`, "local", mount.TypeVolume, `/foo`, ``, `name`, "local", true, false}, + {`name:/foo`, "local", mount.TypeVolume, `/foo`, ``, `name`, "local", true, false}, + {`name:/foo:ro`, "local", mount.TypeVolume, `/foo`, ``, `name`, "local", false, false}, + {`name:/`, "", mount.TypeVolume, ``, ``, ``, "", true, true}, + {`driver/name:/`, "", mount.TypeVolume, ``, ``, ``, "", true, true}, + {`\\.\pipe\foo:\\.\pipe\bar`, "local", mount.TypeNamedPipe, `\\.\pipe\bar`, `\\.\pipe\foo`, "", "", true, true}, + {`\\.\pipe\foo:/data`, "local", mount.TypeNamedPipe, ``, ``, "", "", true, true}, + {`c:\foo\bar:\\.\pipe\foo`, "local", mount.TypeNamedPipe, ``, ``, "", "", true, true}, + } + linuxCases := []testParseMountRaw{ + {"/tmp:/tmp1", "", mount.TypeBind, "/tmp1", "/tmp", "", "", true, false}, + {"/tmp:/tmp2:ro", "", mount.TypeBind, "/tmp2", "/tmp", "", "", false, false}, + {"/tmp:/tmp3:rw", "", mount.TypeBind, "/tmp3", "/tmp", "", "", true, false}, + {"/tmp:/tmp4:foo", "", mount.TypeBind, "", "", "", "", false, true}, + {"name:/named1", "", mount.TypeVolume, "/named1", "", "name", "", true, false}, + {"name:/named2", "external", mount.TypeVolume, "/named2", "", "name", "external", true, false}, + {"name:/named3:ro", "local", mount.TypeVolume, "/named3", "", "name", "local", false, false}, + {"local/name:/tmp:rw", "", mount.TypeVolume, "/tmp", "", "local/name", "", true, false}, + {"/tmp:tmp", "", mount.TypeBind, "", "", "", "", true, true}, + } + linParser := &linuxParser{} + winParser := &windowsParser{} + lcowParser := &lcowParser{} + tester := func(parser Parser, cases []testParseMountRaw) { + for i, c := range cases { + t.Logf("case %d", i) + m, err := parser.ParseMountRaw(c.bind, c.driver) + if c.fail { + if err == nil { + t.Errorf("Expected error, was nil, for spec %s\n", c.bind) + } + continue } - continue - } - if m == nil || err != nil { - t.Fatalf("ParseMountRaw failed for spec '%s', driver '%s', error '%v'", c.bind, c.driver, err.Error()) - continue - } + if m == nil || err != nil { + t.Errorf("ParseMountRaw failed for spec '%s', driver '%s', error '%v'", c.bind, c.driver, err.Error()) + continue + } - if m.Destination != c.expDest { - t.Fatalf("Expected destination '%s, was %s', for spec '%s'", c.expDest, m.Destination, c.bind) - } + if m.Destination != c.expDest { + t.Errorf("Expected destination '%s, was %s', for spec '%s'", c.expDest, m.Destination, c.bind) + } - if m.Source != c.expSource { - t.Fatalf("Expected source '%s', was '%s', for spec '%s'", c.expSource, m.Source, c.bind) - } + if m.Source != c.expSource { + t.Errorf("Expected source '%s', was '%s', for spec '%s'", c.expSource, m.Source, c.bind) + } - if m.Name != c.expName { - t.Fatalf("Expected name '%s', was '%s' for spec '%s'", c.expName, m.Name, c.bind) - } + if m.Name != c.expName { + t.Errorf("Expected name '%s', was '%s' for spec '%s'", c.expName, m.Name, c.bind) + } - if m.Driver != c.expDriver { - t.Fatalf("Expected driver '%s', was '%s', for spec '%s'", c.expDriver, m.Driver, c.bind) - } + if m.Driver != c.expDriver { + t.Errorf("Expected driver '%s', was '%s', for spec '%s'", c.expDriver, m.Driver, c.bind) + } - if m.RW != c.expRW { - t.Fatalf("Expected RW '%v', was '%v' for spec '%s'", c.expRW, m.RW, c.bind) + if m.RW != c.expRW { + t.Errorf("Expected RW '%v', was '%v' for spec '%s'", c.expRW, m.RW, c.bind) + } + if m.Type != c.expType { + t.Fatalf("Expected type '%s', was '%s', for spec '%s'", c.expType, m.Type, c.bind) + } } } + + tester(linParser, linuxCases) + tester(winParser, windowsCases) + tester(lcowParser, lcowCases) } func TestParseMountSpec(t *testing.T) { @@ -227,43 +438,43 @@ func TestParseMountSpec(t *testing.T) { t.Fatal(err) } defer os.RemoveAll(testDir) - + parser := NewParser(runtime.GOOS) cases := []c{ - {mount.Mount{Type: mount.TypeBind, Source: testDir, Target: testDestinationPath, ReadOnly: true}, MountPoint{Type: mount.TypeBind, Source: testDir, Destination: testDestinationPath, Propagation: DefaultPropagationMode}}, - {mount.Mount{Type: mount.TypeBind, Source: testDir, Target: testDestinationPath}, MountPoint{Type: mount.TypeBind, Source: testDir, Destination: testDestinationPath, RW: true, Propagation: DefaultPropagationMode}}, - {mount.Mount{Type: mount.TypeBind, Source: testDir + string(os.PathSeparator), Target: testDestinationPath, ReadOnly: true}, MountPoint{Type: mount.TypeBind, Source: testDir, Destination: testDestinationPath, Propagation: DefaultPropagationMode}}, - {mount.Mount{Type: mount.TypeBind, Source: testDir, Target: testDestinationPath + string(os.PathSeparator), ReadOnly: true}, MountPoint{Type: mount.TypeBind, Source: testDir, Destination: testDestinationPath, Propagation: DefaultPropagationMode}}, - {mount.Mount{Type: mount.TypeVolume, Target: testDestinationPath}, MountPoint{Type: mount.TypeVolume, Destination: testDestinationPath, RW: true, CopyData: DefaultCopyMode}}, - {mount.Mount{Type: mount.TypeVolume, Target: testDestinationPath + string(os.PathSeparator)}, MountPoint{Type: mount.TypeVolume, Destination: testDestinationPath, RW: true, CopyData: DefaultCopyMode}}, + {mount.Mount{Type: mount.TypeBind, Source: testDir, Target: testDestinationPath, ReadOnly: true}, MountPoint{Type: mount.TypeBind, Source: testDir, Destination: testDestinationPath, Propagation: parser.DefaultPropagationMode()}}, + {mount.Mount{Type: mount.TypeBind, Source: testDir, Target: testDestinationPath}, MountPoint{Type: mount.TypeBind, Source: testDir, Destination: testDestinationPath, RW: true, Propagation: parser.DefaultPropagationMode()}}, + {mount.Mount{Type: mount.TypeBind, Source: testDir + string(os.PathSeparator), Target: testDestinationPath, ReadOnly: true}, MountPoint{Type: mount.TypeBind, Source: testDir, Destination: testDestinationPath, Propagation: parser.DefaultPropagationMode()}}, + {mount.Mount{Type: mount.TypeBind, Source: testDir, Target: testDestinationPath + string(os.PathSeparator), ReadOnly: true}, MountPoint{Type: mount.TypeBind, Source: testDir, Destination: testDestinationPath, Propagation: parser.DefaultPropagationMode()}}, + {mount.Mount{Type: mount.TypeVolume, Target: testDestinationPath}, MountPoint{Type: mount.TypeVolume, Destination: testDestinationPath, RW: true, CopyData: parser.DefaultCopyMode()}}, + {mount.Mount{Type: mount.TypeVolume, Target: testDestinationPath + string(os.PathSeparator)}, MountPoint{Type: mount.TypeVolume, Destination: testDestinationPath, RW: true, CopyData: parser.DefaultCopyMode()}}, } for i, c := range cases { t.Logf("case %d", i) - mp, err := ParseMountSpec(c.input) + mp, err := parser.ParseMountSpec(c.input) if err != nil { - t.Fatal(err) + t.Error(err) } if c.expected.Type != mp.Type { - t.Fatalf("Expected mount types to match. Expected: '%s', Actual: '%s'", c.expected.Type, mp.Type) + t.Errorf("Expected mount types to match. Expected: '%s', Actual: '%s'", c.expected.Type, mp.Type) } if c.expected.Destination != mp.Destination { - t.Fatalf("Expected mount destination to match. Expected: '%s', Actual: '%s'", c.expected.Destination, mp.Destination) + t.Errorf("Expected mount destination to match. Expected: '%s', Actual: '%s'", c.expected.Destination, mp.Destination) } if c.expected.Source != mp.Source { - t.Fatalf("Expected mount source to match. Expected: '%s', Actual: '%s'", c.expected.Source, mp.Source) + t.Errorf("Expected mount source to match. Expected: '%s', Actual: '%s'", c.expected.Source, mp.Source) } if c.expected.RW != mp.RW { - t.Fatalf("Expected mount writable to match. Expected: '%v', Actual: '%v'", c.expected.RW, mp.RW) + t.Errorf("Expected mount writable to match. Expected: '%v', Actual: '%v'", c.expected.RW, mp.RW) } if c.expected.Propagation != mp.Propagation { - t.Fatalf("Expected mount propagation to match. Expected: '%v', Actual: '%s'", c.expected.Propagation, mp.Propagation) + t.Errorf("Expected mount propagation to match. Expected: '%v', Actual: '%s'", c.expected.Propagation, mp.Propagation) } if c.expected.Driver != mp.Driver { - t.Fatalf("Expected mount driver to match. Expected: '%v', Actual: '%s'", c.expected.Driver, mp.Driver) + t.Errorf("Expected mount driver to match. Expected: '%v', Actual: '%s'", c.expected.Driver, mp.Driver) } if c.expected.CopyData != mp.CopyData { - t.Fatalf("Expected mount copy data to match. Expected: '%v', Actual: '%v'", c.expected.CopyData, mp.CopyData) + t.Errorf("Expected mount copy data to match. Expected: '%v', Actual: '%v'", c.expected.CopyData, mp.CopyData) } } } diff --git a/vendor/github.com/docker/docker/volume/volume_unix.go b/vendor/github.com/docker/docker/volume/volume_unix.go index e35b70c03..0968fe37e 100644 --- a/vendor/github.com/docker/docker/volume/volume_unix.go +++ b/vendor/github.com/docker/docker/volume/volume_unix.go @@ -4,145 +4,15 @@ package volume import ( "fmt" - "os" "path/filepath" "strings" - - mounttypes "github.com/docker/docker/api/types/mount" ) -var platformRawValidationOpts = []func(o *validateOpts){ - // need to make sure to not error out if the bind source does not exist on unix - // this is supported for historical reasons, the path will be automatically - // created later. - func(o *validateOpts) { o.skipBindSourceCheck = true }, -} - -// read-write modes -var rwModes = map[string]bool{ - "rw": true, - "ro": true, -} - -// label modes -var labelModes = map[string]bool{ - "Z": true, - "z": true, -} - -// consistency modes -var consistencyModes = map[mounttypes.Consistency]bool{ - mounttypes.ConsistencyFull: true, - mounttypes.ConsistencyCached: true, - mounttypes.ConsistencyDelegated: true, -} - -// BackwardsCompatible decides whether this mount point can be -// used in old versions of Docker or not. -// Only bind mounts and local volumes can be used in old versions of Docker. -func (m *MountPoint) BackwardsCompatible() bool { - return len(m.Source) > 0 || m.Driver == DefaultDriverName -} - -// HasResource checks whether the given absolute path for a container is in -// this mount point. If the relative path starts with `../` then the resource -// is outside of this mount point, but we can't simply check for this prefix -// because it misses `..` which is also outside of the mount, so check both. -func (m *MountPoint) HasResource(absolutePath string) bool { +func (p *linuxParser) HasResource(m *MountPoint, absolutePath string) bool { relPath, err := filepath.Rel(m.Destination, absolutePath) return err == nil && relPath != ".." && !strings.HasPrefix(relPath, fmt.Sprintf("..%c", filepath.Separator)) } -// IsVolumeNameValid checks a volume name in a platform specific manner. -func IsVolumeNameValid(name string) (bool, error) { - return true, nil -} - -// ValidMountMode will make sure the mount mode is valid. -// returns if it's a valid mount mode or not. -func ValidMountMode(mode string) bool { - if mode == "" { - return true - } - - rwModeCount := 0 - labelModeCount := 0 - propagationModeCount := 0 - copyModeCount := 0 - consistencyModeCount := 0 - - for _, o := range strings.Split(mode, ",") { - switch { - case rwModes[o]: - rwModeCount++ - case labelModes[o]: - labelModeCount++ - case propagationModes[mounttypes.Propagation(o)]: - propagationModeCount++ - case copyModeExists(o): - copyModeCount++ - case consistencyModes[mounttypes.Consistency(o)]: - consistencyModeCount++ - default: - return false - } - } - - // Only one string for each mode is allowed. - if rwModeCount > 1 || labelModeCount > 1 || propagationModeCount > 1 || copyModeCount > 1 || consistencyModeCount > 1 { - return false - } - return true -} - -// ReadWrite tells you if a mode string is a valid read-write mode or not. -// If there are no specifications w.r.t read write mode, then by default -// it returns true. -func ReadWrite(mode string) bool { - if !ValidMountMode(mode) { - return false - } - - for _, o := range strings.Split(mode, ",") { - if o == "ro" { - return false - } - } - return true -} - -func validateNotRoot(p string) error { - p = filepath.Clean(convertSlash(p)) - if p == "/" { - return fmt.Errorf("invalid specification: destination can't be '/'") - } - return nil -} - -func validateCopyMode(mode bool) error { - return nil -} - -func convertSlash(p string) string { - return filepath.ToSlash(p) -} - -func splitRawSpec(raw string) ([]string, error) { - if strings.Count(raw, ":") > 2 { - return nil, errInvalidSpec(raw) - } - - arr := strings.SplitN(raw, ":", 3) - if arr[0] == "" { - return nil, errInvalidSpec(raw) - } - return arr, nil -} - -func clean(p string) string { - return filepath.Clean(p) -} - -func validateStat(fi os.FileInfo) error { - return nil +func (p *windowsParser) HasResource(m *MountPoint, absolutePath string) bool { + return false } diff --git a/vendor/github.com/docker/docker/volume/volume_unsupported.go b/vendor/github.com/docker/docker/volume/volume_unsupported.go deleted file mode 100644 index ff9d6afa2..000000000 --- a/vendor/github.com/docker/docker/volume/volume_unsupported.go +++ /dev/null @@ -1,16 +0,0 @@ -// +build !linux - -package volume - -import ( - "fmt" - "runtime" - - mounttypes "github.com/docker/docker/api/types/mount" -) - -// ConvertTmpfsOptions converts *mounttypes.TmpfsOptions to the raw option string -// for mount(2). -func ConvertTmpfsOptions(opt *mounttypes.TmpfsOptions, readOnly bool) (string, error) { - return "", fmt.Errorf("%s does not support tmpfs", runtime.GOOS) -} diff --git a/vendor/github.com/docker/docker/volume/volume_windows.go b/vendor/github.com/docker/docker/volume/volume_windows.go index 22f6fc7a1..8ec1d6c80 100644 --- a/vendor/github.com/docker/docker/volume/volume_windows.go +++ b/vendor/github.com/docker/docker/volume/volume_windows.go @@ -1,201 +1,8 @@ package volume -import ( - "fmt" - "os" - "path/filepath" - "regexp" - "strings" -) - -// read-write modes -var rwModes = map[string]bool{ - "rw": true, -} - -// read-only modes -var roModes = map[string]bool{ - "ro": true, -} - -var platformRawValidationOpts = []func(*validateOpts){ - // filepath.IsAbs is weird on Windows: - // `c:` is not considered an absolute path - // `c:\` is considered an absolute path - // In any case, the regex matching below ensures absolute paths - // TODO: consider this a bug with filepath.IsAbs (?) - func(o *validateOpts) { o.skipAbsolutePathCheck = true }, -} - -const ( - // Spec should be in the format [source:]destination[:mode] - // - // Examples: c:\foo bar:d:rw - // c:\foo:d:\bar - // myname:d: - // d:\ - // - // Explanation of this regex! Thanks @thaJeztah on IRC and gist for help. See - // https://gist.github.com/thaJeztah/6185659e4978789fb2b2. A good place to - // test is https://regex-golang.appspot.com/assets/html/index.html - // - // Useful link for referencing named capturing groups: - // http://stackoverflow.com/questions/20750843/using-named-matches-from-go-regex - // - // There are three match groups: source, destination and mode. - // - - // RXHostDir is the first option of a source - RXHostDir = `[a-z]:\\(?:[^\\/:*?"<>|\r\n]+\\?)*` - // RXName is the second option of a source - RXName = `[^\\/:*?"<>|\r\n]+` - // RXReservedNames are reserved names not possible on Windows - RXReservedNames = `(con)|(prn)|(nul)|(aux)|(com[1-9])|(lpt[1-9])` - - // RXSource is the combined possibilities for a source - RXSource = `((?P((` + RXHostDir + `)|(` + RXName + `))):)?` - - // Source. Can be either a host directory, a name, or omitted: - // HostDir: - // - Essentially using the folder solution from - // https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch08s18.html - // but adding case insensitivity. - // - Must be an absolute path such as c:\path - // - Can include spaces such as `c:\program files` - // - And then followed by a colon which is not in the capture group - // - And can be optional - // Name: - // - Must not contain invalid NTFS filename characters (https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx) - // - And then followed by a colon which is not in the capture group - // - And can be optional - - // RXDestination is the regex expression for the mount destination - RXDestination = `(?P([a-z]):((?:\\[^\\/:*?"<>\r\n]+)*\\?))` - // Destination (aka container path): - // - Variation on hostdir but can be a drive followed by colon as well - // - If a path, must be absolute. Can include spaces - // - Drive cannot be c: (explicitly checked in code, not RegEx) - - // RXMode is the regex expression for the mode of the mount - // Mode (optional): - // - Hopefully self explanatory in comparison to above regex's. - // - Colon is not in the capture group - RXMode = `(:(?P(?i)ro|rw))?` -) - -// BackwardsCompatible decides whether this mount point can be -// used in old versions of Docker or not. -// Windows volumes are never backwards compatible. -func (m *MountPoint) BackwardsCompatible() bool { +func (p *windowsParser) HasResource(m *MountPoint, absolutePath string) bool { return false } - -func splitRawSpec(raw string) ([]string, error) { - specExp := regexp.MustCompile(`^` + RXSource + RXDestination + RXMode + `$`) - match := specExp.FindStringSubmatch(strings.ToLower(raw)) - - // Must have something back - if len(match) == 0 { - return nil, errInvalidSpec(raw) - } - - var split []string - matchgroups := make(map[string]string) - // Pull out the sub expressions from the named capture groups - for i, name := range specExp.SubexpNames() { - matchgroups[name] = strings.ToLower(match[i]) - } - if source, exists := matchgroups["source"]; exists { - if source != "" { - split = append(split, source) - } - } - if destination, exists := matchgroups["destination"]; exists { - if destination != "" { - split = append(split, destination) - } - } - if mode, exists := matchgroups["mode"]; exists { - if mode != "" { - split = append(split, mode) - } - } - // Fix #26329. If the destination appears to be a file, and the source is null, - // it may be because we've fallen through the possible naming regex and hit a - // situation where the user intention was to map a file into a container through - // a local volume, but this is not supported by the platform. - if matchgroups["source"] == "" && matchgroups["destination"] != "" { - validName, err := IsVolumeNameValid(matchgroups["destination"]) - if err != nil { - return nil, err - } - if !validName { - if fi, err := os.Stat(matchgroups["destination"]); err == nil { - if !fi.IsDir() { - return nil, fmt.Errorf("file '%s' cannot be mapped. Only directories can be mapped on this platform", matchgroups["destination"]) - } - } - } - } - return split, nil -} - -// IsVolumeNameValid checks a volume name in a platform specific manner. -func IsVolumeNameValid(name string) (bool, error) { - nameExp := regexp.MustCompile(`^` + RXName + `$`) - if !nameExp.MatchString(name) { - return false, nil - } - nameExp = regexp.MustCompile(`^` + RXReservedNames + `$`) - if nameExp.MatchString(name) { - return false, fmt.Errorf("volume name %q cannot be a reserved word for Windows filenames", name) - } - return true, nil -} - -// ValidMountMode will make sure the mount mode is valid. -// returns if it's a valid mount mode or not. -func ValidMountMode(mode string) bool { - if mode == "" { - return true - } - return roModes[strings.ToLower(mode)] || rwModes[strings.ToLower(mode)] -} - -// ReadWrite tells you if a mode string is a valid read-write mode or not. -func ReadWrite(mode string) bool { - return rwModes[strings.ToLower(mode)] || mode == "" -} - -func validateNotRoot(p string) error { - p = strings.ToLower(convertSlash(p)) - if p == "c:" || p == `c:\` { - return fmt.Errorf("destination path cannot be `c:` or `c:\\`: %v", p) - } - return nil -} - -func validateCopyMode(mode bool) error { - if mode { - return fmt.Errorf("Windows does not support copying image path content") - } - return nil -} - -func convertSlash(p string) string { - return filepath.FromSlash(p) -} - -func clean(p string) string { - if match, _ := regexp.MatchString("^[a-z]:$", p); match { - return p - } - return filepath.Clean(p) -} - -func validateStat(fi os.FileInfo) error { - if !fi.IsDir() { - return fmt.Errorf("source path must be a directory") - } - return nil +func (p *linuxParser) HasResource(m *MountPoint, absolutePath string) bool { + return false } diff --git a/vendor/github.com/docker/docker/volume/windows_parser.go b/vendor/github.com/docker/docker/volume/windows_parser.go new file mode 100644 index 000000000..172610dbd --- /dev/null +++ b/vendor/github.com/docker/docker/volume/windows_parser.go @@ -0,0 +1,456 @@ +package volume + +import ( + "errors" + "fmt" + "os" + "regexp" + "runtime" + "strings" + + "github.com/docker/docker/api/types/mount" + "github.com/docker/docker/pkg/stringid" +) + +type windowsParser struct { +} + +const ( + // Spec should be in the format [source:]destination[:mode] + // + // Examples: c:\foo bar:d:rw + // c:\foo:d:\bar + // myname:d: + // d:\ + // + // Explanation of this regex! Thanks @thaJeztah on IRC and gist for help. See + // https://gist.github.com/thaJeztah/6185659e4978789fb2b2. A good place to + // test is https://regex-golang.appspot.com/assets/html/index.html + // + // Useful link for referencing named capturing groups: + // http://stackoverflow.com/questions/20750843/using-named-matches-from-go-regex + // + // There are three match groups: source, destination and mode. + // + + // rxHostDir is the first option of a source + rxHostDir = `(?:\\\\\?\\)?[a-z]:[\\/](?:[^\\/:*?"<>|\r\n]+[\\/]?)*` + // rxName is the second option of a source + rxName = `[^\\/:*?"<>|\r\n]+` + + // RXReservedNames are reserved names not possible on Windows + rxReservedNames = `(con)|(prn)|(nul)|(aux)|(com[1-9])|(lpt[1-9])` + + // rxPipe is a named path pipe (starts with `\\.\pipe\`, possibly with / instead of \) + rxPipe = `[/\\]{2}.[/\\]pipe[/\\][^:*?"<>|\r\n]+` + // rxSource is the combined possibilities for a source + rxSource = `((?P((` + rxHostDir + `)|(` + rxName + `)|(` + rxPipe + `))):)?` + + // Source. Can be either a host directory, a name, or omitted: + // HostDir: + // - Essentially using the folder solution from + // https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch08s18.html + // but adding case insensitivity. + // - Must be an absolute path such as c:\path + // - Can include spaces such as `c:\program files` + // - And then followed by a colon which is not in the capture group + // - And can be optional + // Name: + // - Must not contain invalid NTFS filename characters (https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx) + // - And then followed by a colon which is not in the capture group + // - And can be optional + + // rxDestination is the regex expression for the mount destination + rxDestination = `(?P((?:\\\\\?\\)?([a-z]):((?:[\\/][^\\/:*?"<>\r\n]+)*[\\/]?))|(` + rxPipe + `))` + + rxLCOWDestination = `(?P/(?:[^\\/:*?"<>\r\n]+[/]?)*)` + // Destination (aka container path): + // - Variation on hostdir but can be a drive followed by colon as well + // - If a path, must be absolute. Can include spaces + // - Drive cannot be c: (explicitly checked in code, not RegEx) + + // rxMode is the regex expression for the mode of the mount + // Mode (optional): + // - Hopefully self explanatory in comparison to above regex's. + // - Colon is not in the capture group + rxMode = `(:(?P(?i)ro|rw))?` +) + +type mountValidator func(mnt *mount.Mount) error + +func windowsSplitRawSpec(raw, destRegex string) ([]string, error) { + specExp := regexp.MustCompile(`^` + rxSource + destRegex + rxMode + `$`) + match := specExp.FindStringSubmatch(strings.ToLower(raw)) + + // Must have something back + if len(match) == 0 { + return nil, errInvalidSpec(raw) + } + + var split []string + matchgroups := make(map[string]string) + // Pull out the sub expressions from the named capture groups + for i, name := range specExp.SubexpNames() { + matchgroups[name] = strings.ToLower(match[i]) + } + if source, exists := matchgroups["source"]; exists { + if source != "" { + split = append(split, source) + } + } + if destination, exists := matchgroups["destination"]; exists { + if destination != "" { + split = append(split, destination) + } + } + if mode, exists := matchgroups["mode"]; exists { + if mode != "" { + split = append(split, mode) + } + } + // Fix #26329. If the destination appears to be a file, and the source is null, + // it may be because we've fallen through the possible naming regex and hit a + // situation where the user intention was to map a file into a container through + // a local volume, but this is not supported by the platform. + if matchgroups["source"] == "" && matchgroups["destination"] != "" { + volExp := regexp.MustCompile(`^` + rxName + `$`) + reservedNameExp := regexp.MustCompile(`^` + rxReservedNames + `$`) + + if volExp.MatchString(matchgroups["destination"]) { + if reservedNameExp.MatchString(matchgroups["destination"]) { + return nil, fmt.Errorf("volume name %q cannot be a reserved word for Windows filenames", matchgroups["destination"]) + } + } else { + + exists, isDir, _ := currentFileInfoProvider.fileInfo(matchgroups["destination"]) + if exists && !isDir { + return nil, fmt.Errorf("file '%s' cannot be mapped. Only directories can be mapped on this platform", matchgroups["destination"]) + + } + } + } + return split, nil +} + +func windowsValidMountMode(mode string) bool { + if mode == "" { + return true + } + return rwModes[strings.ToLower(mode)] +} +func windowsValidateNotRoot(p string) error { + p = strings.ToLower(strings.Replace(p, `/`, `\`, -1)) + if p == "c:" || p == `c:\` { + return fmt.Errorf("destination path cannot be `c:` or `c:\\`: %v", p) + } + return nil +} + +var windowsSpecificValidators mountValidator = func(mnt *mount.Mount) error { + return windowsValidateNotRoot(mnt.Target) +} + +func windowsValidateRegex(p, r string) error { + if regexp.MustCompile(`^` + r + `$`).MatchString(strings.ToLower(p)) { + return nil + } + return fmt.Errorf("invalid mount path: '%s'", p) +} +func windowsValidateAbsolute(p string) error { + if err := windowsValidateRegex(p, rxDestination); err != nil { + return fmt.Errorf("invalid mount path: '%s' mount path must be absolute", p) + } + return nil +} + +func windowsDetectMountType(p string) mount.Type { + if strings.HasPrefix(p, `\\.\pipe\`) { + return mount.TypeNamedPipe + } else if regexp.MustCompile(`^` + rxHostDir + `$`).MatchString(p) { + return mount.TypeBind + } else { + return mount.TypeVolume + } +} + +func (p *windowsParser) ReadWrite(mode string) bool { + return strings.ToLower(mode) != "ro" +} + +// IsVolumeNameValid checks a volume name in a platform specific manner. +func (p *windowsParser) ValidateVolumeName(name string) error { + nameExp := regexp.MustCompile(`^` + rxName + `$`) + if !nameExp.MatchString(name) { + return errors.New("invalid volume name") + } + nameExp = regexp.MustCompile(`^` + rxReservedNames + `$`) + if nameExp.MatchString(name) { + return fmt.Errorf("volume name %q cannot be a reserved word for Windows filenames", name) + } + return nil +} +func (p *windowsParser) validateMountConfig(mnt *mount.Mount) error { + return p.validateMountConfigReg(mnt, rxDestination, windowsSpecificValidators) +} + +type fileInfoProvider interface { + fileInfo(path string) (exist, isDir bool, err error) +} + +type defaultFileInfoProvider struct { +} + +func (defaultFileInfoProvider) fileInfo(path string) (exist, isDir bool, err error) { + fi, err := os.Stat(path) + if err != nil { + if !os.IsNotExist(err) { + return false, false, err + } + return false, false, nil + } + return true, fi.IsDir(), nil +} + +var currentFileInfoProvider fileInfoProvider = defaultFileInfoProvider{} + +func (p *windowsParser) validateMountConfigReg(mnt *mount.Mount, destRegex string, additionalValidators ...mountValidator) error { + + for _, v := range additionalValidators { + if err := v(mnt); err != nil { + return &errMountConfig{mnt, err} + } + } + if len(mnt.Target) == 0 { + return &errMountConfig{mnt, errMissingField("Target")} + } + + if err := windowsValidateRegex(mnt.Target, destRegex); err != nil { + return &errMountConfig{mnt, err} + } + + switch mnt.Type { + case mount.TypeBind: + if len(mnt.Source) == 0 { + return &errMountConfig{mnt, errMissingField("Source")} + } + // Don't error out just because the propagation mode is not supported on the platform + if opts := mnt.BindOptions; opts != nil { + if len(opts.Propagation) > 0 { + return &errMountConfig{mnt, fmt.Errorf("invalid propagation mode: %s", opts.Propagation)} + } + } + if mnt.VolumeOptions != nil { + return &errMountConfig{mnt, errExtraField("VolumeOptions")} + } + + if err := windowsValidateAbsolute(mnt.Source); err != nil { + return &errMountConfig{mnt, err} + } + + exists, isdir, err := currentFileInfoProvider.fileInfo(mnt.Source) + if err != nil { + return &errMountConfig{mnt, err} + } + if !exists { + return &errMountConfig{mnt, errBindNotExist} + } + if !isdir { + return &errMountConfig{mnt, fmt.Errorf("source path must be a directory")} + } + + case mount.TypeVolume: + if mnt.BindOptions != nil { + return &errMountConfig{mnt, errExtraField("BindOptions")} + } + + if len(mnt.Source) == 0 && mnt.ReadOnly { + return &errMountConfig{mnt, fmt.Errorf("must not set ReadOnly mode when using anonymous volumes")} + } + + if len(mnt.Source) != 0 { + if err := p.ValidateVolumeName(mnt.Source); err != nil { + return &errMountConfig{mnt, err} + } + } + case mount.TypeNamedPipe: + if len(mnt.Source) == 0 { + return &errMountConfig{mnt, errMissingField("Source")} + } + + if mnt.BindOptions != nil { + return &errMountConfig{mnt, errExtraField("BindOptions")} + } + + if mnt.ReadOnly { + return &errMountConfig{mnt, errExtraField("ReadOnly")} + } + + if windowsDetectMountType(mnt.Source) != mount.TypeNamedPipe { + return &errMountConfig{mnt, fmt.Errorf("'%s' is not a valid pipe path", mnt.Source)} + } + + if windowsDetectMountType(mnt.Target) != mount.TypeNamedPipe { + return &errMountConfig{mnt, fmt.Errorf("'%s' is not a valid pipe path", mnt.Target)} + } + default: + return &errMountConfig{mnt, errors.New("mount type unknown")} + } + return nil +} +func (p *windowsParser) ParseMountRaw(raw, volumeDriver string) (*MountPoint, error) { + return p.parseMountRaw(raw, volumeDriver, rxDestination, true, windowsSpecificValidators) +} + +func (p *windowsParser) parseMountRaw(raw, volumeDriver, destRegex string, convertTargetToBackslash bool, additionalValidators ...mountValidator) (*MountPoint, error) { + arr, err := windowsSplitRawSpec(raw, destRegex) + if err != nil { + return nil, err + } + + var spec mount.Mount + var mode string + switch len(arr) { + case 1: + // Just a destination path in the container + spec.Target = arr[0] + case 2: + if windowsValidMountMode(arr[1]) { + // Destination + Mode is not a valid volume - volumes + // cannot include a mode. e.g. /foo:rw + return nil, errInvalidSpec(raw) + } + // Host Source Path or Name + Destination + spec.Source = strings.Replace(arr[0], `/`, `\`, -1) + spec.Target = arr[1] + case 3: + // HostSourcePath+DestinationPath+Mode + spec.Source = strings.Replace(arr[0], `/`, `\`, -1) + spec.Target = arr[1] + mode = arr[2] + default: + return nil, errInvalidSpec(raw) + } + if convertTargetToBackslash { + spec.Target = strings.Replace(spec.Target, `/`, `\`, -1) + } + + if !windowsValidMountMode(mode) { + return nil, errInvalidMode(mode) + } + + spec.Type = windowsDetectMountType(spec.Source) + spec.ReadOnly = !p.ReadWrite(mode) + + // cannot assume that if a volume driver is passed in that we should set it + if volumeDriver != "" && spec.Type == mount.TypeVolume { + spec.VolumeOptions = &mount.VolumeOptions{ + DriverConfig: &mount.Driver{Name: volumeDriver}, + } + } + + if copyData, isSet := getCopyMode(mode, p.DefaultCopyMode()); isSet { + if spec.VolumeOptions == nil { + spec.VolumeOptions = &mount.VolumeOptions{} + } + spec.VolumeOptions.NoCopy = !copyData + } + + mp, err := p.parseMountSpec(spec, destRegex, convertTargetToBackslash, additionalValidators...) + if mp != nil { + mp.Mode = mode + } + if err != nil { + err = fmt.Errorf("%v: %v", errInvalidSpec(raw), err) + } + return mp, err +} + +func (p *windowsParser) ParseMountSpec(cfg mount.Mount) (*MountPoint, error) { + return p.parseMountSpec(cfg, rxDestination, true, windowsSpecificValidators) +} +func (p *windowsParser) parseMountSpec(cfg mount.Mount, destRegex string, convertTargetToBackslash bool, additionalValidators ...mountValidator) (*MountPoint, error) { + if err := p.validateMountConfigReg(&cfg, destRegex, additionalValidators...); err != nil { + return nil, err + } + mp := &MountPoint{ + RW: !cfg.ReadOnly, + Destination: cfg.Target, + Type: cfg.Type, + Spec: cfg, + } + if convertTargetToBackslash { + mp.Destination = strings.Replace(cfg.Target, `/`, `\`, -1) + } + + switch cfg.Type { + case mount.TypeVolume: + if cfg.Source == "" { + mp.Name = stringid.GenerateNonCryptoID() + } else { + mp.Name = cfg.Source + } + mp.CopyData = p.DefaultCopyMode() + + if cfg.VolumeOptions != nil { + if cfg.VolumeOptions.DriverConfig != nil { + mp.Driver = cfg.VolumeOptions.DriverConfig.Name + } + if cfg.VolumeOptions.NoCopy { + mp.CopyData = false + } + } + case mount.TypeBind: + mp.Source = strings.Replace(cfg.Source, `/`, `\`, -1) + case mount.TypeNamedPipe: + mp.Source = strings.Replace(cfg.Source, `/`, `\`, -1) + } + // cleanup trailing `\` except for paths like `c:\` + if len(mp.Source) > 3 && mp.Source[len(mp.Source)-1] == '\\' { + mp.Source = mp.Source[:len(mp.Source)-1] + } + if len(mp.Destination) > 3 && mp.Destination[len(mp.Destination)-1] == '\\' { + mp.Destination = mp.Destination[:len(mp.Destination)-1] + } + return mp, nil +} + +func (p *windowsParser) ParseVolumesFrom(spec string) (string, string, error) { + if len(spec) == 0 { + return "", "", fmt.Errorf("volumes-from specification cannot be an empty string") + } + + specParts := strings.SplitN(spec, ":", 2) + id := specParts[0] + mode := "rw" + + if len(specParts) == 2 { + mode = specParts[1] + if !windowsValidMountMode(mode) { + return "", "", errInvalidMode(mode) + } + + // Do not allow copy modes on volumes-from + if _, isSet := getCopyMode(mode, p.DefaultCopyMode()); isSet { + return "", "", errInvalidMode(mode) + } + } + return id, mode, nil +} + +func (p *windowsParser) DefaultPropagationMode() mount.Propagation { + return mount.Propagation("") +} + +func (p *windowsParser) ConvertTmpfsOptions(opt *mount.TmpfsOptions, readOnly bool) (string, error) { + return "", fmt.Errorf("%s does not support tmpfs", runtime.GOOS) +} +func (p *windowsParser) DefaultCopyMode() bool { + return false +} +func (p *windowsParser) IsBackwardCompatible(m *MountPoint) bool { + return false +} + +func (p *windowsParser) ValidateTmpfsMountDestination(dest string) error { + return errors.New("Platform does not support tmpfs") +} diff --git a/vendor/github.com/docker/libcompose/config/interpolation.go b/vendor/github.com/docker/libcompose/config/interpolation.go index 66c987a71..3010e68e3 100644 --- a/vendor/github.com/docker/libcompose/config/interpolation.go +++ b/vendor/github.com/docker/libcompose/config/interpolation.go @@ -8,10 +8,16 @@ import ( "github.com/Sirupsen/logrus" ) +var defaultValues = make(map[string]string) + func isNum(c uint8) bool { return c >= '0' && c <= '9' } +func validVariableDefault(c uint8, line string, pos int) bool { + return (c == ':' && line[pos+1] == '-') || (c == '-') +} + func validVariableNameChar(c uint8) bool { return c == '_' || c >= 'A' && c <= 'Z' || @@ -36,6 +42,30 @@ func parseVariable(line string, pos int, mapping func(string) string) (string, i return mapping(buffer.String()), pos, true } +func parseDefaultValue(line string, pos int) (string, int, bool) { + var buffer bytes.Buffer + + // only skip :, :- and - at the beginning + for ; pos < len(line); pos++ { + c := line[pos] + if c == ':' || c == '-' { + continue + } + break + } + for ; pos < len(line); pos++ { + c := line[pos] + if c == '}' { + return buffer.String(), pos - 1, true + } + err := buffer.WriteByte(c) + if err != nil { + return "", pos, false + } + } + return "", 0, false +} + func parseVariableWithBraces(line string, pos int, mapping func(string) string) (string, int, bool) { var buffer bytes.Buffer @@ -49,10 +79,13 @@ func parseVariableWithBraces(line string, pos int, mapping func(string) string) if bufferString == "" { return "", 0, false } - return mapping(buffer.String()), pos, true case validVariableNameChar(c): buffer.WriteByte(c) + case validVariableDefault(c, line, pos): + defaultValue := "" + defaultValue, pos, _ = parseDefaultValue(line, pos) + defaultValues[buffer.String()] = defaultValue default: return "", 0, false } @@ -143,10 +176,19 @@ func Interpolate(key string, data *interface{}, environmentLookup EnvironmentLoo values := environmentLookup.Lookup(s, nil) if len(values) == 0 { + if val, ok := defaultValues[s]; ok { + return val + } logrus.Warnf("The %s variable is not set. Substituting a blank string.", s) return "" } + if strings.SplitN(values[0], "=", 2)[1] == "" { + if val, ok := defaultValues[s]; ok { + return val + } + } + // Use first result if many are given value := values[0] diff --git a/vendor/github.com/docker/libcompose/config/interpolation_test.go b/vendor/github.com/docker/libcompose/config/interpolation_test.go index d5afeb68e..cffdffd13 100644 --- a/vendor/github.com/docker/libcompose/config/interpolation_test.go +++ b/vendor/github.com/docker/libcompose/config/interpolation_test.go @@ -3,6 +3,7 @@ package config import ( "fmt" "os" + "strings" "testing" "github.com/stretchr/testify/assert" @@ -25,6 +26,14 @@ func testInvalidInterpolatedLine(t *testing.T, line string) { assert.Equal(t, false, success) } +func testInterpolatedDefault(t *testing.T, line string, delim string, expectedVar string, expectedVal string) { + envVar, _ := parseLine(line, func(env string) string { return env }) + pos := strings.Index(line, delim) + envDefault, _, _ := parseDefaultValue(line, pos) + assert.Equal(t, expectedVal, envDefault) + assert.Equal(t, expectedVar, envVar) +} + func TestParseLine(t *testing.T) { variables := map[string]string{ "A": "ABC", @@ -35,11 +44,20 @@ func TestParseLine(t *testing.T) { "split_VaLue": "WORKED", "9aNumber": "WORKED", "a9Number": "WORKED", + "defTest": "WORKED", } + testInterpolatedDefault(t, "${defVar:-defVal}", ":-", "defVar", "defVal") + testInterpolatedDefault(t, "${defVar2-defVal2}", "-", "defVar2", "defVal2") + testInterpolatedDefault(t, "${defVar:-def:Val}", ":-", "defVar", "def:Val") + testInterpolatedDefault(t, "${defVar:-def-Val}", ":-", "defVar", "def-Val") + testInterpolatedLine(t, "WORKED", "$lower", variables) testInterpolatedLine(t, "WORKED", "${MiXeD}", variables) testInterpolatedLine(t, "WORKED", "${split_VaLue}", variables) + // make sure variable name is parsed correctly with default value + testInterpolatedLine(t, "WORKED", "${defTest:-sometest}", variables) + testInterpolatedLine(t, "WORKED", "${defTest-sometest}", variables) // Starting with a number isn't valid testInterpolatedLine(t, "", "$9aNumber", variables) testInterpolatedLine(t, "WORKED", "$a9Number", variables) @@ -67,6 +85,7 @@ func TestParseLine(t *testing.T) { testInterpolatedLine(t, "", "$E", variables) testInterpolatedLine(t, "", "${E}", variables) + testInvalidInterpolatedLine(t, "${df:val}") testInvalidInterpolatedLine(t, "${") testInvalidInterpolatedLine(t, "$}") testInvalidInterpolatedLine(t, "${}") @@ -198,6 +217,43 @@ func TestInterpolate(t *testing.T) { "HOST_PORT": "=", "LABEL_VALUE": "myvalue==", }) + // same as above but with default values + testInterpolatedConfig(t, + `web: + # unbracketed name + image: busybox + + # array element + ports: + - "80:8000" + + # dictionary item value + labels: + mylabel: "my-val:ue" + + # unset value + hostname: "host-" + + # escaped interpolation + command: "${ESCAPED}"`, + + `web: + # unbracketed name + image: ${IMAGE:-busybox} + + # array element + ports: + - "${HOST_PORT:-80}:8000" + + # dictionary item value + labels: + mylabel: "${LABEL_VALUE-my-val:ue}" + + # unset value + hostname: "host-${UNSET_VALUE}" + + # escaped interpolation + command: "$${ESCAPED}"`, map[string]string{}) testInvalidInterpolatedConfig(t, `web: diff --git a/vendor/github.com/docker/libcompose/config/merge.go b/vendor/github.com/docker/libcompose/config/merge.go index c5f04db0e..a375e546f 100644 --- a/vendor/github.com/docker/libcompose/config/merge.go +++ b/vendor/github.com/docker/libcompose/config/merge.go @@ -6,11 +6,12 @@ import ( "fmt" "strings" + "reflect" + "github.com/docker/docker/pkg/urlutil" "github.com/docker/libcompose/utils" composeYaml "github.com/docker/libcompose/yaml" "gopkg.in/yaml.v2" - "reflect" ) var ( @@ -229,8 +230,6 @@ func readEnvFile(resourceLookup ResourceLookup, inFile string, serviceData RawSe serviceData["environment"] = vars - delete(serviceData, "env_file") - return serviceData, nil } diff --git a/vendor/github.com/docker/libcompose/docker/builder/builder.go b/vendor/github.com/docker/libcompose/docker/builder/builder.go index 265182fea..d1d3f447a 100644 --- a/vendor/github.com/docker/libcompose/docker/builder/builder.go +++ b/vendor/github.com/docker/libcompose/docker/builder/builder.go @@ -42,6 +42,7 @@ type DaemonBuilder struct { ForceRemove bool Pull bool BuildArgs map[string]*string + CacheFrom []string LoggerFactory logger.Factory } @@ -96,6 +97,7 @@ func (d *DaemonBuilder) Build(ctx context.Context, imageName string) error { Dockerfile: d.Dockerfile, AuthConfigs: d.AuthConfigs, BuildArgs: d.BuildArgs, + CacheFrom: d.CacheFrom, }) if err != nil { return err diff --git a/vendor/github.com/docker/libcompose/docker/container/container.go b/vendor/github.com/docker/libcompose/docker/container/container.go index 8ec061ccf..d738f6ee9 100644 --- a/vendor/github.com/docker/libcompose/docker/container/container.go +++ b/vendor/github.com/docker/libcompose/docker/container/container.go @@ -180,6 +180,7 @@ func (c *Container) Run(ctx context.Context, configOverride *config.ServiceConfi errCh chan error out, stderr io.Writer in io.ReadCloser + inFd uintptr ) if configOverride.StdinOpen { @@ -202,14 +203,17 @@ func (c *Container) Run(ctx context.Context, configOverride *config.ServiceConfi return -1, err } - // set raw terminal - inFd, _ := term.GetFdInfo(in) - state, err := term.SetRawTerminal(inFd) - if err != nil { - return -1, err + if configOverride.StdinOpen { + // set raw terminal + inFd, _ = term.GetFdInfo(in) + state, err := term.SetRawTerminal(inFd) + if err != nil { + return -1, err + } + // restore raw terminal + defer term.RestoreTerminal(inFd, state) } - // restore raw terminal - defer term.RestoreTerminal(inFd, state) + // holdHijackedConnection (in goroutine) errCh = promise.Go(func() error { return holdHijackedConnection(configOverride.Tty, in, out, stderr, resp) diff --git a/vendor/github.com/docker/libcompose/docker/service/service.go b/vendor/github.com/docker/libcompose/docker/service/service.go index cc8f1326e..7df25e787 100644 --- a/vendor/github.com/docker/libcompose/docker/service/service.go +++ b/vendor/github.com/docker/libcompose/docker/service/service.go @@ -257,7 +257,7 @@ func (s *Service) Run(ctx context.Context, commandParts []string, options option return -1, err } - configOverride := &config.ServiceConfig{Command: commandParts, Tty: true, StdinOpen: true} + configOverride := &config.ServiceConfig{Command: commandParts, Tty: !options.DisableTty, StdinOpen: !options.DisableTty} c, err := s.createContainer(ctx, namer, "", configOverride, true) if err != nil { @@ -357,7 +357,7 @@ func (s *Service) connectContainerToNetworks(ctx context.Context, c *container.C } if s.serviceConfig.Networks != nil { for _, network := range s.serviceConfig.Networks.Networks { - existingNetwork, ok := connectedNetworks[network.Name] + existingNetwork, ok := connectedNetworks[network.RealName] if ok { // FIXME(vdemeester) implement alias checking (to not disconnect/reconnect for nothing) aliasPresent := false diff --git a/vendor/github.com/docker/libcompose/project/options/types.go b/vendor/github.com/docker/libcompose/project/options/types.go index 17a6df508..3d8d54a0b 100644 --- a/vendor/github.com/docker/libcompose/project/options/types.go +++ b/vendor/github.com/docker/libcompose/project/options/types.go @@ -30,7 +30,8 @@ type Create struct { // Run holds options of compose run. type Run struct { - Detached bool + Detached bool + DisableTty bool } // Up holds options of compose up. diff --git a/vendor/github.com/docker/libcompose/project/project_containers.go b/vendor/github.com/docker/libcompose/project/project_containers.go index a1768aa24..a8fed9942 100644 --- a/vendor/github.com/docker/libcompose/project/project_containers.go +++ b/vendor/github.com/docker/libcompose/project/project_containers.go @@ -2,6 +2,7 @@ package project import ( "fmt" + "sync" "golang.org/x/net/context" @@ -12,6 +13,8 @@ import ( // the Filter struct. func (p *Project) Containers(ctx context.Context, filter Filter, services ...string) ([]string, error) { containers := []string{} + var lock sync.Mutex + err := p.forEach(services, wrapperAction(func(wrapper *serviceWrapper, wrappers map[string]*serviceWrapper) { wrapper.Do(nil, events.NoEvent, events.NoEvent, func(service Service) error { serviceContainers, innerErr := service.Containers(ctx) @@ -37,7 +40,9 @@ func (p *Project) Containers(ctx context.Context, filter Filter, services ...str return fmt.Errorf("Invalid container filter: %s", filter.State) } containerID := container.ID() + lock.Lock() containers = append(containers, containerID) + lock.Unlock() } return nil }) diff --git a/vendor/github.com/dustin/go-humanize/.travis.yml b/vendor/github.com/dustin/go-humanize/.travis.yml index ffa87400a..ba95cdd15 100644 --- a/vendor/github.com/dustin/go-humanize/.travis.yml +++ b/vendor/github.com/dustin/go-humanize/.travis.yml @@ -1,13 +1,16 @@ sudo: false language: go go: - - 1.3.3 - - 1.5.4 - - 1.6.2 - - tip + - 1.3.x + - 1.5.x + - 1.6.x + - 1.7.x + - 1.8.x + - 1.9.x + - master matrix: allow_failures: - - go: tip + - go: master fast_finish: true install: - # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step). diff --git a/vendor/github.com/gin-gonic/gin/.travis.yml b/vendor/github.com/gin-gonic/gin/.travis.yml index 821ce8dfd..ec12cad6a 100644 --- a/vendor/github.com/gin-gonic/gin/.travis.yml +++ b/vendor/github.com/gin-gonic/gin/.travis.yml @@ -4,6 +4,7 @@ go: - 1.6.x - 1.7.x - 1.8.x + - 1.9.x - master git: diff --git a/vendor/github.com/gin-gonic/gin/README.md b/vendor/github.com/gin-gonic/gin/README.md index b14c2a2a0..0dc165bc2 100644 --- a/vendor/github.com/gin-gonic/gin/README.md +++ b/vendor/github.com/gin-gonic/gin/README.md @@ -40,7 +40,7 @@ $ go run example.go ## Benchmarks -Gin uses a custom version of [HttpRouter](https://github.com/julienschmidt/httprouter) +Gin uses a custom version of [HttpRouter](https://github.com/julienschmidt/httprouter) [See all benchmarks](/BENCHMARKS.md) @@ -74,10 +74,10 @@ BenchmarkTigerTonic_GithubAll | 1000 | 1439483 | 239104 BenchmarkTraffic_GithubAll | 100 | 11383067 | 2659329 | 21848 BenchmarkVulcan_GithubAll | 5000 | 394253 | 19894 | 609 -(1): Total Repetitions achieved in constant time, higher means more confident result -(2): Single Repetition Duration (ns/op), lower is better -(3): Heap Memory (B/op), lower is better -(4): Average Allocations per Repetition (allocs/op), lower is better +(1): Total Repetitions achieved in constant time, higher means more confident result +(2): Single Repetition Duration (ns/op), lower is better +(3): Heap Memory (B/op), lower is better +(4): Average Allocations per Repetition (allocs/op), lower is better ## Gin v1. stable @@ -277,14 +277,16 @@ References issue [#774](https://github.com/gin-gonic/gin/issues/774) and detail ```go func main() { router := gin.Default() + // Set a lower memory limit for multipart forms (default is 32 MiB) + // router.MaxMultipartMemory = 8 << 20 // 8 MiB router.POST("/upload", func(c *gin.Context) { // single file file, _ := c.FormFile("file") log.Println(file.Filename) - + // Upload the file to specific dst. - // c.SaveUploadedFile(file, dst) - + // c.SaveUploadedFile(file, dst) + c.String(http.StatusOK, fmt.Sprintf("'%s' uploaded!", file.Filename)) }) router.Run(":8080") @@ -306,6 +308,8 @@ See the detail [example code](examples/upload-file/multiple). ```go func main() { router := gin.Default() + // Set a lower memory limit for multipart forms (default is 32 MiB) + // router.MaxMultipartMemory = 8 << 20 // 8 MiB router.POST("/upload", func(c *gin.Context) { // Multipart form form, _ := c.MultipartForm() @@ -313,9 +317,9 @@ func main() { for _, file := range files { log.Println(file.Filename) - + // Upload the file to specific dst. - // c.SaveUploadedFile(file, dst) + // c.SaveUploadedFile(file, dst) } c.String(http.StatusOK, fmt.Sprintf("%d files uploaded!", len(files))) }) @@ -369,6 +373,7 @@ r := gin.New() instead of ```go +// Default With the Logger and Recovery middleware already attached r := gin.Default() ``` @@ -380,7 +385,11 @@ func main() { r := gin.New() // Global middleware + // Logger middleware will write the logs to gin.DefaultWriter even you set with GIN_MODE=release. + // By default gin.DefaultWriter = os.Stdout r.Use(gin.Logger()) + + // Recovery middleware recovers from any panics and writes a 500 if there was one. r.Use(gin.Recovery()) // Per route middleware, you can add as many as you desire. @@ -408,6 +417,28 @@ func main() { } ``` +### How to write log file +```go +func main() { + // Disable Console Color, you don't need console color when writing the logs to file. + gin.DisableConsoleColor() + + // Logging to a file. + f, _ := os.Create("gin.log") + gin.DefaultWriter = io.MultiWriter(f) + + // Use the following code if you need to write the logs to file and console at the same time. + // gin.DefaultWriter = io.MultiWriter(f, os.Stdout) + + router := gin.Default() + router.GET("/ping", func(c *gin.Context) { + c.String(200, "pong") + }) + + r.Run(":8080") +} +``` + ### Model binding and validation To bind a request body into a type, use model binding. We currently support binding of JSON, XML and standard form values (foo=bar&boo=baz). @@ -460,6 +491,67 @@ func main() { } ``` +### Custom Validators + +It is also possible to register custom validators. See the [example code](examples/custom-validation/server.go). + +[embedmd]:# (examples/custom-validation/server.go go) +```go +package main + +import ( + "net/http" + "reflect" + "time" + + "github.com/gin-gonic/gin" + "github.com/gin-gonic/gin/binding" + validator "gopkg.in/go-playground/validator.v8" +) + +type Booking struct { + CheckIn time.Time `form:"check_in" binding:"required,bookabledate" time_format:"2006-01-02"` + CheckOut time.Time `form:"check_out" binding:"required,gtfield=CheckIn" time_format:"2006-01-02"` +} + +func bookableDate( + v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value, + field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string, +) bool { + if date, ok := field.Interface().(time.Time); ok { + today := time.Now() + if today.Year() > date.Year() || today.YearDay() > date.YearDay() { + return false + } + } + return true +} + +func main() { + route := gin.Default() + binding.Validator.RegisterValidation("bookabledate", bookableDate) + route.GET("/bookable", getBookable) + route.Run(":8085") +} + +func getBookable(c *gin.Context) { + var b Booking + if err := c.ShouldBindWith(&b, binding.Query); err == nil { + c.JSON(http.StatusOK, gin.H{"message": "Booking dates are valid!"}) + } else { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + } +} +``` + +```console +$ curl "localhost:8085/bookable?check_in=2017-08-16&check_out=2017-08-17" +{"message":"Booking dates are valid!"} + +$ curl "localhost:8085/bookable?check_in=2017-08-15&check_out=2017-08-16" +{"error":"Key: 'Booking.CheckIn' Error:Field validation for 'CheckIn' failed on the 'bookabledate' tag"} +``` + ### Only Bind Query String `BindQuery` function only binds the query params and not the post data. See the [detail information](https://github.com/gin-gonic/gin/issues/742#issuecomment-315953017). @@ -505,10 +597,12 @@ package main import "log" import "github.com/gin-gonic/gin" +import "time" type Person struct { - Name string `form:"name"` - Address string `form:"address"` + Name string `form:"name"` + Address string `form:"address"` + Birthday time.Time `form:"birthday" time_format:"2006-01-02" time_utc:"1"` } func main() { @@ -525,12 +619,18 @@ func startPage(c *gin.Context) { if c.Bind(&person) == nil { log.Println(person.Name) log.Println(person.Address) + log.Println(person.Birthday) } c.String(200, "Success") } ``` +Test it with: +```sh +$ curl -X GET "localhost:8085/testing?name=appleboy&address=xyz&birthday=1992-03-15" +``` + ### Bind HTML checkboxes See the [detail information](https://github.com/gin-gonic/gin/issues/129#issuecomment-124260092) @@ -676,7 +776,7 @@ func main() { // Listen and serve on 0.0.0.0:8080 r.Run(":8080") } -``` +``` ### Serving static files @@ -787,7 +887,7 @@ You may use custom delims r := gin.Default() r.Delims("{[{", "}]}") r.LoadHTMLGlob("/path/to/templates")) -``` +``` #### Custom Template Funcs @@ -1124,7 +1224,7 @@ func main() { if err := srv.Shutdown(ctx); err != nil { log.Fatal("Server Shutdown:", err) } - log.Println("Server exist") + log.Println("Server exiting") } ``` diff --git a/vendor/github.com/gin-gonic/gin/auth.go b/vendor/github.com/gin-gonic/gin/auth.go index c214e2134..85d96fd38 100644 --- a/vendor/github.com/gin-gonic/gin/auth.go +++ b/vendor/github.com/gin-gonic/gin/auth.go @@ -10,10 +10,10 @@ import ( "strconv" ) -// AuthUserKey is the cookie name for user credential in basic auth +// AuthUserKey is the cookie name for user credential in basic auth. const AuthUserKey = "user" -// Accounts defines a key/value for user/pass list of authorized logins +// Accounts defines a key/value for user/pass list of authorized logins. type Accounts map[string]string type authPair struct { @@ -47,7 +47,7 @@ func BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc { pairs := processAccounts(accounts) return func(c *Context) { // Search user in the slice of allowed credentials - user, found := pairs.searchCredential(c.Request.Header.Get("Authorization")) + user, found := pairs.searchCredential(c.requestHeader("Authorization")) if !found { // Credentials doesn't match, we return 401 and abort handlers chain. c.Header("WWW-Authenticate", realm) @@ -56,7 +56,7 @@ func BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc { } // The user credentials was found, set user's id to key AuthUserKey in this context, the user's id can be read later using - // c.MustGet(gin.AuthUserKey) + // c.MustGet(gin.AuthUserKey). c.Set(AuthUserKey, user) } } @@ -90,6 +90,6 @@ func secureCompare(given, actual string) bool { if subtle.ConstantTimeEq(int32(len(given)), int32(len(actual))) == 1 { return subtle.ConstantTimeCompare([]byte(given), []byte(actual)) == 1 } - // Securely compare actual to itself to keep constant time, but always return false + // Securely compare actual to itself to keep constant time, but always return false. return subtle.ConstantTimeCompare([]byte(actual), []byte(actual)) == 1 && false } diff --git a/vendor/github.com/gin-gonic/gin/binding/binding.go b/vendor/github.com/gin-gonic/gin/binding/binding.go index 971547c21..a09cc2214 100644 --- a/vendor/github.com/gin-gonic/gin/binding/binding.go +++ b/vendor/github.com/gin-gonic/gin/binding/binding.go @@ -4,7 +4,11 @@ package binding -import "net/http" +import ( + "net/http" + + validator "gopkg.in/go-playground/validator.v8" +) const ( MIMEJSON = "application/json" @@ -31,6 +35,11 @@ type StructValidator interface { // If the struct is not valid or the validation itself fails, a descriptive error should be returned. // Otherwise nil must be returned. ValidateStruct(interface{}) error + + // RegisterValidation adds a validation Func to a Validate's map of validators denoted by the key + // NOTE: if the key already exists, the previous validation function will be replaced. + // NOTE: this method is not thread-safe it is intended that these all be registered prior to any validation + RegisterValidation(string, validator.Func) error } var Validator StructValidator = &defaultValidator{} diff --git a/vendor/github.com/gin-gonic/gin/binding/default_validator.go b/vendor/github.com/gin-gonic/gin/binding/default_validator.go index 19885f164..6336bb6e2 100644 --- a/vendor/github.com/gin-gonic/gin/binding/default_validator.go +++ b/vendor/github.com/gin-gonic/gin/binding/default_validator.go @@ -28,6 +28,11 @@ func (v *defaultValidator) ValidateStruct(obj interface{}) error { return nil } +func (v *defaultValidator) RegisterValidation(key string, fn validator.Func) error { + v.lazyinit() + return v.validate.RegisterValidation(key, fn) +} + func (v *defaultValidator) lazyinit() { v.once.Do(func() { config := &validator.Config{TagName: "binding"} diff --git a/vendor/github.com/gin-gonic/gin/binding/form.go b/vendor/github.com/gin-gonic/gin/binding/form.go index 557333e6f..0be59660b 100644 --- a/vendor/github.com/gin-gonic/gin/binding/form.go +++ b/vendor/github.com/gin-gonic/gin/binding/form.go @@ -6,6 +6,8 @@ package binding import "net/http" +const defaultMemory = 32 * 1024 * 1024 + type formBinding struct{} type formPostBinding struct{} type formMultipartBinding struct{} @@ -18,7 +20,7 @@ func (formBinding) Bind(req *http.Request, obj interface{}) error { if err := req.ParseForm(); err != nil { return err } - req.ParseMultipartForm(32 << 10) // 32 MB + req.ParseMultipartForm(defaultMemory) if err := mapForm(obj, req.Form); err != nil { return err } @@ -44,7 +46,7 @@ func (formMultipartBinding) Name() string { } func (formMultipartBinding) Bind(req *http.Request, obj interface{}) error { - if err := req.ParseMultipartForm(32 << 10); err != nil { + if err := req.ParseMultipartForm(defaultMemory); err != nil { return err } if err := mapForm(obj, req.MultipartForm.Value); err != nil { diff --git a/vendor/github.com/gin-gonic/gin/binding/validate_test.go b/vendor/github.com/gin-gonic/gin/binding/validate_test.go index cbcb389de..523e12983 100644 --- a/vendor/github.com/gin-gonic/gin/binding/validate_test.go +++ b/vendor/github.com/gin-gonic/gin/binding/validate_test.go @@ -6,9 +6,12 @@ package binding import ( "bytes" + "reflect" "testing" "time" + validator "gopkg.in/go-playground/validator.v8" + "github.com/stretchr/testify/assert" ) @@ -190,3 +193,42 @@ func TestValidatePrimitives(t *testing.T) { assert.NoError(t, validate(&str)) assert.Equal(t, str, "value") } + +// structCustomValidation is a helper struct we use to check that +// custom validation can be registered on it. +// The `notone` binding directive is for custom validation and registered later. +type structCustomValidation struct { + Integer int `binding:"notone"` +} + +// notOne is a custom validator meant to be used with `validator.v8` library. +// The method signature for `v9` is significantly different and this function +// would need to be changed for tests to pass after upgrade. +// See https://github.com/gin-gonic/gin/pull/1015. +func notOne( + v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value, + field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string, +) bool { + if val, ok := field.Interface().(int); ok { + return val != 1 + } + return false +} + +func TestRegisterValidation(t *testing.T) { + // This validates that the function `notOne` matches + // the expected function signature by `defaultValidator` + // and by extension the validator library. + err := Validator.RegisterValidation("notone", notOne) + // Check that we can register custom validation without error + assert.Nil(t, err) + + // Create an instance which will fail validation + withOne := structCustomValidation{Integer: 1} + errs := validate(withOne) + + // Check that we got back non-nil errs + assert.NotNil(t, errs) + // Check that the error matches expactation + assert.Error(t, errs, "", "", "notone") +} diff --git a/vendor/github.com/gin-gonic/gin/context.go b/vendor/github.com/gin-gonic/gin/context.go index 895ba7a15..74995e68e 100644 --- a/vendor/github.com/gin-gonic/gin/context.go +++ b/vendor/github.com/gin-gonic/gin/context.go @@ -22,7 +22,7 @@ import ( "github.com/gin-gonic/gin/render" ) -// Content-Type MIME of the most common data formats +// Content-Type MIME of the most common data formats. const ( MIMEJSON = binding.MIMEJSON MIMEHTML = binding.MIMEHTML @@ -34,8 +34,7 @@ const ( ) const ( - defaultMemory = 32 << 20 // 32 MB - abortIndex int8 = math.MaxInt8 / 2 + abortIndex int8 = math.MaxInt8 / 2 ) // Context is the most important part of gin. It allows us to pass variables between middleware, @@ -51,13 +50,13 @@ type Context struct { engine *Engine - // Keys is a key/value pair exclusively for the context of each request + // Keys is a key/value pair exclusively for the context of each request. Keys map[string]interface{} - // Errors is a list of errors attached to all the handlers/middlewares who used this context + // Errors is a list of errors attached to all the handlers/middlewares who used this context. Errors errorMsgs - // Accepted defines a list of manually accepted formats for content negotiation + // Accepted defines a list of manually accepted formats for content negotiation. Accepted []string } @@ -87,7 +86,7 @@ func (c *Context) Copy() *Context { } // HandlerName returns the main handler's name. For example if the handler is "handleGetUsers()", -// this function will return "main.handleGetUsers" +// this function will return "main.handleGetUsers". func (c *Context) HandlerName() string { return nameOfFunction(c.handlers.Last()) } @@ -407,7 +406,7 @@ func (c *Context) PostFormArray(key string) []string { func (c *Context) GetPostFormArray(key string) ([]string, bool) { req := c.Request req.ParseForm() - req.ParseMultipartForm(defaultMemory) + req.ParseMultipartForm(c.engine.MaxMultipartMemory) if values := req.PostForm[key]; len(values) > 0 { return values, true } @@ -427,7 +426,7 @@ func (c *Context) FormFile(name string) (*multipart.FileHeader, error) { // MultipartForm is the parsed multipart form, including file uploads. func (c *Context) MultipartForm() (*multipart.Form, error) { - err := c.Request.ParseMultipartForm(defaultMemory) + err := c.Request.ParseMultipartForm(c.engine.MaxMultipartMemory) return c.Request.MultipartForm, err } @@ -462,18 +461,18 @@ func (c *Context) Bind(obj interface{}) error { return c.MustBindWith(obj, b) } -// BindJSON is a shortcut for c.MustBindWith(obj, binding.JSON) +// BindJSON is a shortcut for c.MustBindWith(obj, binding.JSON). func (c *Context) BindJSON(obj interface{}) error { return c.MustBindWith(obj, binding.JSON) } -// BindQuery is a shortcut for c.MustBindWith(obj, binding.Query) +// BindQuery is a shortcut for c.MustBindWith(obj, binding.Query). func (c *Context) BindQuery(obj interface{}) error { return c.MustBindWith(obj, binding.Query) } -// MustBindWith binds the passed struct pointer using the specified binding -// engine. It will abort the request with HTTP 400 if any error ocurrs. +// MustBindWith binds the passed struct pointer using the specified binding engine. +// It will abort the request with HTTP 400 if any error ocurrs. // See the binding package. func (c *Context) MustBindWith(obj interface{}, b binding.Binding) (err error) { if err = c.ShouldBindWith(obj, b); err != nil { @@ -483,8 +482,7 @@ func (c *Context) MustBindWith(obj interface{}, b binding.Binding) (err error) { return } -// ShouldBindWith binds the passed struct pointer using the specified binding -// engine. +// ShouldBindWith binds the passed struct pointer using the specified binding engine. // See the binding package. func (c *Context) ShouldBindWith(obj interface{}, b binding.Binding) error { return b.Bind(c.Request, obj) @@ -510,7 +508,7 @@ func (c *Context) ClientIP() string { } if c.engine.AppEngine { - if addr := c.Request.Header.Get("X-Appengine-Remote-Addr"); addr != "" { + if addr := c.requestHeader("X-Appengine-Remote-Addr"); addr != "" { return addr } } @@ -538,17 +536,14 @@ func (c *Context) IsWebsocket() bool { } func (c *Context) requestHeader(key string) string { - if values, _ := c.Request.Header[key]; len(values) > 0 { - return values[0] - } - return "" + return c.Request.Header.Get(key) } /************************************/ /******** RESPONSE RENDERING ********/ /************************************/ -// bodyAllowedForStatus is a copy of http.bodyAllowedForStatus non-exported function +// bodyAllowedForStatus is a copy of http.bodyAllowedForStatus non-exported function. func bodyAllowedForStatus(status int) bool { switch { case status >= 100 && status <= 199: @@ -566,7 +561,7 @@ func (c *Context) Status(code int) { c.writermem.WriteHeader(code) } -// Header is a intelligent shortcut for c.Writer.Header().Set(key, value) +// Header is a intelligent shortcut for c.Writer.Header().Set(key, value). // It writes a header in the response. // If value == "", this method removes the header `c.Writer.Header().Del(key)` func (c *Context) Header(key, value string) { @@ -577,16 +572,19 @@ func (c *Context) Header(key, value string) { } } -// GetHeader returns value from request headers +// GetHeader returns value from request headers. func (c *Context) GetHeader(key string) string { return c.requestHeader(key) } -// GetRawData return stream data +// GetRawData return stream data. func (c *Context) GetRawData() ([]byte, error) { return ioutil.ReadAll(c.Request.Body) } +// SetCookie adds a Set-Cookie header to the ResponseWriter's headers. +// The provided cookie must have a valid Name. Invalid cookies may be +// silently dropped. func (c *Context) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool) { if path == "" { path = "/" @@ -602,6 +600,10 @@ func (c *Context) SetCookie(name, value string, maxAge int, path, domain string, }) } +// Cookie returns the named cookie provided in the request or +// ErrNoCookie if not found. And return the named cookie is unescaped. +// If multiple cookies match the given name, only one cookie will +// be returned. func (c *Context) Cookie(name string) (string, error) { cookie, err := c.Request.Cookie(name) if err != nil { diff --git a/vendor/github.com/gin-gonic/gin/deprecated.go b/vendor/github.com/gin-gonic/gin/deprecated.go index 7b50dc70e..ab4474296 100644 --- a/vendor/github.com/gin-gonic/gin/deprecated.go +++ b/vendor/github.com/gin-gonic/gin/deprecated.go @@ -15,7 +15,7 @@ import ( func (c *Context) BindWith(obj interface{}, b binding.Binding) error { log.Println(`BindWith(\"interface{}, binding.Binding\") error is going to be deprecated, please check issue #662 and either use MustBindWith() if you - want HTTP 400 to be automatically returned if any error occur, of use + want HTTP 400 to be automatically returned if any error occur, or use ShouldBindWith() if you need to manage the error.`) return c.MustBindWith(obj, b) } diff --git a/vendor/github.com/gin-gonic/gin/errors.go b/vendor/github.com/gin-gonic/gin/errors.go index 197611064..6f3c98686 100644 --- a/vendor/github.com/gin-gonic/gin/errors.go +++ b/vendor/github.com/gin-gonic/gin/errors.go @@ -65,7 +65,7 @@ func (msg *Error) JSON() interface{} { return json } -// MarshalJSON implements the json.Marshaller interface +// MarshalJSON implements the json.Marshaller interface. func (msg *Error) MarshalJSON() ([]byte, error) { return json.Marshal(msg.JSON()) } @@ -80,7 +80,7 @@ func (msg *Error) IsType(flags ErrorType) bool { } // ByType returns a readonly copy filtered the byte. -// ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic +// ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic. func (a errorMsgs) ByType(typ ErrorType) errorMsgs { if len(a) == 0 { return nil @@ -98,7 +98,7 @@ func (a errorMsgs) ByType(typ ErrorType) errorMsgs { } // Last returns the last error in the slice. It returns nil if the array is empty. -// Shortcut for errors[len(errors)-1] +// Shortcut for errors[len(errors)-1]. func (a errorMsgs) Last() *Error { if length := len(a); length > 0 { return a[length-1] diff --git a/vendor/github.com/gin-gonic/gin/examples/app-engine/hello.go b/vendor/github.com/gin-gonic/gin/examples/app-engine/hello.go index da7e4ae46..f569dadb6 100644 --- a/vendor/github.com/gin-gonic/gin/examples/app-engine/hello.go +++ b/vendor/github.com/gin-gonic/gin/examples/app-engine/hello.go @@ -13,10 +13,10 @@ func init() { // Define your handlers r.GET("/", func(c *gin.Context) { - c.String(200, "Hello World!") + c.String(http.StatusOK, "Hello World!") }) r.GET("/ping", func(c *gin.Context) { - c.String(200, "pong") + c.String(http.StatusOK, "pong") }) // Handle all requests using net/http diff --git a/vendor/github.com/gin-gonic/gin/examples/custom-validation/server.go b/vendor/github.com/gin-gonic/gin/examples/custom-validation/server.go new file mode 100644 index 000000000..0b67ce10d --- /dev/null +++ b/vendor/github.com/gin-gonic/gin/examples/custom-validation/server.go @@ -0,0 +1,45 @@ +package main + +import ( + "net/http" + "reflect" + "time" + + "github.com/gin-gonic/gin" + "github.com/gin-gonic/gin/binding" + validator "gopkg.in/go-playground/validator.v8" +) + +type Booking struct { + CheckIn time.Time `form:"check_in" binding:"required,bookabledate" time_format:"2006-01-02"` + CheckOut time.Time `form:"check_out" binding:"required,gtfield=CheckIn" time_format:"2006-01-02"` +} + +func bookableDate( + v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value, + field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string, +) bool { + if date, ok := field.Interface().(time.Time); ok { + today := time.Now() + if today.Year() > date.Year() || today.YearDay() > date.YearDay() { + return false + } + } + return true +} + +func main() { + route := gin.Default() + binding.Validator.RegisterValidation("bookabledate", bookableDate) + route.GET("/bookable", getBookable) + route.Run(":8085") +} + +func getBookable(c *gin.Context) { + var b Booking + if err := c.ShouldBindWith(&b, binding.Query); err == nil { + c.JSON(http.StatusOK, gin.H{"message": "Booking dates are valid!"}) + } else { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + } +} diff --git a/vendor/github.com/gin-gonic/gin/examples/graceful-shutdown/close/server.go b/vendor/github.com/gin-gonic/gin/examples/graceful-shutdown/close/server.go index 547783931..9c4e90fac 100644 --- a/vendor/github.com/gin-gonic/gin/examples/graceful-shutdown/close/server.go +++ b/vendor/github.com/gin-gonic/gin/examples/graceful-shutdown/close/server.go @@ -41,5 +41,5 @@ func main() { } } - log.Println("Server exist") + log.Println("Server exiting") } diff --git a/vendor/github.com/gin-gonic/gin/examples/graceful-shutdown/graceful-shutdown/server.go b/vendor/github.com/gin-gonic/gin/examples/graceful-shutdown/graceful-shutdown/server.go index 060de081c..6debe7f59 100644 --- a/vendor/github.com/gin-gonic/gin/examples/graceful-shutdown/graceful-shutdown/server.go +++ b/vendor/github.com/gin-gonic/gin/examples/graceful-shutdown/graceful-shutdown/server.go @@ -44,5 +44,5 @@ func main() { if err := srv.Shutdown(ctx); err != nil { log.Fatal("Server Shutdown:", err) } - log.Println("Server exist") + log.Println("Server exiting") } diff --git a/vendor/github.com/gin-gonic/gin/examples/upload-file/multiple/main.go b/vendor/github.com/gin-gonic/gin/examples/upload-file/multiple/main.go index 4bb4cdcb9..a55325ed5 100644 --- a/vendor/github.com/gin-gonic/gin/examples/upload-file/multiple/main.go +++ b/vendor/github.com/gin-gonic/gin/examples/upload-file/multiple/main.go @@ -9,6 +9,8 @@ import ( func main() { router := gin.Default() + // Set a lower memory limit for multipart forms (default is 32 MiB) + router.MaxMultipartMemory = 8 << 20 // 8 MiB router.Static("/", "./public") router.POST("/upload", func(c *gin.Context) { name := c.PostForm("name") diff --git a/vendor/github.com/gin-gonic/gin/examples/upload-file/single/main.go b/vendor/github.com/gin-gonic/gin/examples/upload-file/single/main.go index 372a29942..5d438651a 100644 --- a/vendor/github.com/gin-gonic/gin/examples/upload-file/single/main.go +++ b/vendor/github.com/gin-gonic/gin/examples/upload-file/single/main.go @@ -9,6 +9,8 @@ import ( func main() { router := gin.Default() + // Set a lower memory limit for multipart forms (default is 32 MiB) + router.MaxMultipartMemory = 8 << 20 // 8 MiB router.Static("/", "./public") router.POST("/upload", func(c *gin.Context) { name := c.PostForm("name") diff --git a/vendor/github.com/gin-gonic/gin/fs.go b/vendor/github.com/gin-gonic/gin/fs.go index 8570a9a9e..7a6738a68 100644 --- a/vendor/github.com/gin-gonic/gin/fs.go +++ b/vendor/github.com/gin-gonic/gin/fs.go @@ -29,7 +29,7 @@ func Dir(root string, listDirectory bool) http.FileSystem { return &onlyfilesFS{fs} } -// Open conforms to http.Filesystem +// Open conforms to http.Filesystem. func (fs onlyfilesFS) Open(name string) (http.File, error) { f, err := fs.fs.Open(name) if err != nil { @@ -38,7 +38,7 @@ func (fs onlyfilesFS) Open(name string) (http.File, error) { return neuteredReaddirFile{f}, nil } -// Readdir overrides the http.File default implementation +// Readdir overrides the http.File default implementation. func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) { // this disables directory listing return nil, nil diff --git a/vendor/github.com/gin-gonic/gin/gin.go b/vendor/github.com/gin-gonic/gin/gin.go index 8347ce22d..24c4dd8d7 100644 --- a/vendor/github.com/gin-gonic/gin/gin.go +++ b/vendor/github.com/gin-gonic/gin/gin.go @@ -14,8 +14,11 @@ import ( "github.com/gin-gonic/gin/render" ) -// Version is Framework's version -const Version = "v1.2" +// Version is Framework's version. +const ( + Version = "v1.2" + defaultMultipartMemory = 32 << 20 // 32 MB +) var default404Body = []byte("404 page not found") var default405Body = []byte("405 method not allowed") @@ -92,6 +95,10 @@ type Engine struct { // If UseRawPath is false (by default), the UnescapePathValues effectively is true, // as url.Path gonna be used, which is already unescaped. UnescapePathValues bool + + // Value of 'maxMemory' param that is given to http.Request's ParseMultipartForm + // method call. + MaxMultipartMemory int64 } var _ IRouter = &Engine{} @@ -120,6 +127,7 @@ func New() *Engine { AppEngine: defaultAppEngine, UseRawPath: false, UnescapePathValues: true, + MaxMultipartMemory: defaultMultipartMemory, trees: make(methodTrees, 0, 9), delims: render.Delims{Left: "{{", Right: "}}"}, secureJsonPrefix: "while(1);", @@ -191,7 +199,7 @@ func (engine *Engine) NoRoute(handlers ...HandlerFunc) { engine.rebuild404Handlers() } -// NoMethod sets the handlers called when... TODO +// NoMethod sets the handlers called when... TODO. func (engine *Engine) NoMethod(handlers ...HandlerFunc) { engine.noMethod = handlers engine.rebuild405Handlers() @@ -268,7 +276,7 @@ func (engine *Engine) Run(addr ...string) (err error) { // RunTLS attaches the router to a http.Server and starts listening and serving HTTPS (secure) requests. // It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router) // Note: this method will block the calling goroutine indefinitely unless an error happens. -func (engine *Engine) RunTLS(addr string, certFile string, keyFile string) (err error) { +func (engine *Engine) RunTLS(addr, certFile, keyFile string) (err error) { debugPrint("Listening and serving HTTPS on %s\n", addr) defer func() { debugPrintError(err) }() @@ -316,14 +324,11 @@ func (engine *Engine) HandleContext(c *Context) { func (engine *Engine) handleHTTPRequest(context *Context) { httpMethod := context.Request.Method - var path string - var unescape bool + path := context.Request.URL.Path + unescape := false if engine.UseRawPath && len(context.Request.URL.RawPath) > 0 { path = context.Request.URL.RawPath unescape = engine.UnescapePathValues - } else { - path = context.Request.URL.Path - unescape = false } // Find root of the tree for the given HTTP method diff --git a/vendor/github.com/gin-gonic/gin/ginS/gins.go b/vendor/github.com/gin-gonic/gin/ginS/gins.go index d40d1c3a3..ee00b3816 100644 --- a/vendor/github.com/gin-gonic/gin/ginS/gins.go +++ b/vendor/github.com/gin-gonic/gin/ginS/gins.go @@ -9,15 +9,15 @@ import ( "net/http" "sync" - . "github.com/gin-gonic/gin" + "github.com/gin-gonic/gin" ) var once sync.Once -var internalEngine *Engine +var internalEngine *gin.Engine -func engine() *Engine { +func engine() *gin.Engine { once.Do(func() { - internalEngine = Default() + internalEngine = gin.Default() }) return internalEngine } @@ -35,65 +35,65 @@ func SetHTMLTemplate(templ *template.Template) { } // NoRoute adds handlers for NoRoute. It return a 404 code by default. -func NoRoute(handlers ...HandlerFunc) { +func NoRoute(handlers ...gin.HandlerFunc) { engine().NoRoute(handlers...) } // NoMethod sets the handlers called when... TODO -func NoMethod(handlers ...HandlerFunc) { +func NoMethod(handlers ...gin.HandlerFunc) { engine().NoMethod(handlers...) } // Group creates a new router group. You should add all the routes that have common middlwares or the same path prefix. // For example, all the routes that use a common middlware for authorization could be grouped. -func Group(relativePath string, handlers ...HandlerFunc) *RouterGroup { +func Group(relativePath string, handlers ...gin.HandlerFunc) *gin.RouterGroup { return engine().Group(relativePath, handlers...) } -func Handle(httpMethod, relativePath string, handlers ...HandlerFunc) IRoutes { +func Handle(httpMethod, relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes { return engine().Handle(httpMethod, relativePath, handlers...) } // POST is a shortcut for router.Handle("POST", path, handle) -func POST(relativePath string, handlers ...HandlerFunc) IRoutes { +func POST(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes { return engine().POST(relativePath, handlers...) } // GET is a shortcut for router.Handle("GET", path, handle) -func GET(relativePath string, handlers ...HandlerFunc) IRoutes { +func GET(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes { return engine().GET(relativePath, handlers...) } // DELETE is a shortcut for router.Handle("DELETE", path, handle) -func DELETE(relativePath string, handlers ...HandlerFunc) IRoutes { +func DELETE(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes { return engine().DELETE(relativePath, handlers...) } // PATCH is a shortcut for router.Handle("PATCH", path, handle) -func PATCH(relativePath string, handlers ...HandlerFunc) IRoutes { +func PATCH(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes { return engine().PATCH(relativePath, handlers...) } // PUT is a shortcut for router.Handle("PUT", path, handle) -func PUT(relativePath string, handlers ...HandlerFunc) IRoutes { +func PUT(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes { return engine().PUT(relativePath, handlers...) } // OPTIONS is a shortcut for router.Handle("OPTIONS", path, handle) -func OPTIONS(relativePath string, handlers ...HandlerFunc) IRoutes { +func OPTIONS(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes { return engine().OPTIONS(relativePath, handlers...) } // HEAD is a shortcut for router.Handle("HEAD", path, handle) -func HEAD(relativePath string, handlers ...HandlerFunc) IRoutes { +func HEAD(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes { return engine().HEAD(relativePath, handlers...) } -func Any(relativePath string, handlers ...HandlerFunc) IRoutes { +func Any(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes { return engine().Any(relativePath, handlers...) } -func StaticFile(relativePath, filepath string) IRoutes { +func StaticFile(relativePath, filepath string) gin.IRoutes { return engine().StaticFile(relativePath, filepath) } @@ -103,18 +103,18 @@ func StaticFile(relativePath, filepath string) IRoutes { // To use the operating system's file system implementation, // use : // router.Static("/static", "/var/www") -func Static(relativePath, root string) IRoutes { +func Static(relativePath, root string) gin.IRoutes { return engine().Static(relativePath, root) } -func StaticFS(relativePath string, fs http.FileSystem) IRoutes { +func StaticFS(relativePath string, fs http.FileSystem) gin.IRoutes { return engine().StaticFS(relativePath, fs) } // Use attachs a global middleware to the router. ie. the middlewares attached though Use() will be // included in the handlers chain for every single request. Even 404, 405, static files... // For example, this is the right place for a logger or error management middleware. -func Use(middlewares ...HandlerFunc) IRoutes { +func Use(middlewares ...gin.HandlerFunc) gin.IRoutes { return engine().Use(middlewares...) } diff --git a/vendor/github.com/gin-gonic/gin/logger.go b/vendor/github.com/gin-gonic/gin/logger.go index 470e4bb64..c679c7871 100644 --- a/vendor/github.com/gin-gonic/gin/logger.go +++ b/vendor/github.com/gin-gonic/gin/logger.go @@ -25,17 +25,17 @@ var ( disableColor = false ) -// DisableConsoleColor disables color output in the console +// DisableConsoleColor disables color output in the console. func DisableConsoleColor() { disableColor = true } -// ErrorLogger returns a handlerfunc for any error type +// ErrorLogger returns a handlerfunc for any error type. func ErrorLogger() HandlerFunc { return ErrorLoggerT(ErrorTypeAny) } -// ErrorLoggerT returns a handlerfunc for a given error type +// ErrorLoggerT returns a handlerfunc for a given error type. func ErrorLoggerT(typ ErrorType) HandlerFunc { return func(c *Context) { c.Next() @@ -46,8 +46,8 @@ func ErrorLoggerT(typ ErrorType) HandlerFunc { } } -// Logger instances a Logger middleware that will write the logs to gin.DefaultWriter -// By default gin.DefaultWriter = os.Stdout +// Logger instances a Logger middleware that will write the logs to gin.DefaultWriter. +// By default gin.DefaultWriter = os.Stdout. func Logger() HandlerFunc { return LoggerWithWriter(DefaultWriter) } @@ -91,10 +91,11 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc { clientIP := c.ClientIP() method := c.Request.Method statusCode := c.Writer.Status() - var statusColor, methodColor string + var statusColor, methodColor, resetColor string if isTerm { statusColor = colorForStatus(statusCode) methodColor = colorForMethod(method) + resetColor = reset } comment := c.Errors.ByType(ErrorTypePrivate).String() @@ -102,12 +103,12 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc { path = path + "?" + raw } - fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %15s |%s %s %-7s %s\n%s", + fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %15s |%s %-7s %s %s\n%s", end.Format("2006/01/02 - 15:04:05"), - statusColor, statusCode, reset, + statusColor, statusCode, resetColor, latency, clientIP, - methodColor, method, reset, + methodColor, method, resetColor, path, comment, ) diff --git a/vendor/github.com/gin-gonic/gin/path.go b/vendor/github.com/gin-gonic/gin/path.go index e3424b139..ed63ad1aa 100644 --- a/vendor/github.com/gin-gonic/gin/path.go +++ b/vendor/github.com/gin-gonic/gin/path.go @@ -17,7 +17,7 @@ package gin // 4. Eliminate .. elements that begin a rooted path: // that is, replace "/.." by "/" at the beginning of a path. // -// If the result of this process is an empty string, "/" is returned +// If the result of this process is an empty string, "/" is returned. func cleanPath(p string) string { // Turn empty string into "/" if p == "" { @@ -109,7 +109,7 @@ func cleanPath(p string) string { return string(buf[:w]) } -// internal helper to lazily create a buffer if necessary +// internal helper to lazily create a buffer if necessary. func bufApp(buf *[]byte, s string, w int, c byte) { if *buf == nil { if s[w] == c { diff --git a/vendor/github.com/gin-gonic/gin/recovery.go b/vendor/github.com/gin-gonic/gin/recovery.go index c502f3553..89b39fecd 100644 --- a/vendor/github.com/gin-gonic/gin/recovery.go +++ b/vendor/github.com/gin-gonic/gin/recovery.go @@ -26,6 +26,7 @@ func Recovery() HandlerFunc { return RecoveryWithWriter(DefaultErrorWriter) } +// RecoveryWithWriter returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one. func RecoveryWithWriter(out io.Writer) HandlerFunc { var logger *log.Logger if out != nil { @@ -46,7 +47,7 @@ func RecoveryWithWriter(out io.Writer) HandlerFunc { } } -// stack returns a nicely formated stack frame, skipping skip frames +// stack returns a nicely formatted stack frame, skipping skip frames. func stack(skip int) []byte { buf := new(bytes.Buffer) // the returned data // As we loop, we open files and read them. These variables record the currently diff --git a/vendor/github.com/gin-gonic/gin/render/data.go b/vendor/github.com/gin-gonic/gin/render/data.go index c296042c9..331949139 100644 --- a/vendor/github.com/gin-gonic/gin/render/data.go +++ b/vendor/github.com/gin-gonic/gin/render/data.go @@ -11,7 +11,7 @@ type Data struct { Data []byte } -// Render (Data) writes data with custom ContentType +// Render (Data) writes data with custom ContentType. func (r Data) Render(w http.ResponseWriter) (err error) { r.WriteContentType(w) _, err = w.Write(r.Data) diff --git a/vendor/github.com/gin-gonic/gin/response_writer.go b/vendor/github.com/gin-gonic/gin/response_writer.go index 216165b92..232f00aac 100644 --- a/vendor/github.com/gin-gonic/gin/response_writer.go +++ b/vendor/github.com/gin-gonic/gin/response_writer.go @@ -95,7 +95,7 @@ func (w *responseWriter) Written() bool { return w.size != noWritten } -// Hijack implements the http.Hijacker interface +// Hijack implements the http.Hijacker interface. func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { if w.size < 0 { w.size = 0 @@ -103,12 +103,12 @@ func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { return w.ResponseWriter.(http.Hijacker).Hijack() } -// CloseNotify implements the http.CloseNotify interface +// CloseNotify implements the http.CloseNotify interface. func (w *responseWriter) CloseNotify() <-chan bool { return w.ResponseWriter.(http.CloseNotifier).CloseNotify() } -// Flush implements the http.Flush interface +// Flush implements the http.Flush interface. func (w *responseWriter) Flush() { w.ResponseWriter.(http.Flusher).Flush() } diff --git a/vendor/github.com/gin-gonic/gin/routergroup.go b/vendor/github.com/gin-gonic/gin/routergroup.go index 89ec89aae..5e681c1cb 100644 --- a/vendor/github.com/gin-gonic/gin/routergroup.go +++ b/vendor/github.com/gin-gonic/gin/routergroup.go @@ -35,7 +35,7 @@ type IRoutes interface { } // RouterGroup is used internally to configure router, a RouterGroup is associated with a prefix -// and an array of handlers (middleware) +// and an array of handlers (middleware). type RouterGroup struct { Handlers HandlersChain basePath string @@ -89,43 +89,43 @@ func (group *RouterGroup) Handle(httpMethod, relativePath string, handlers ...Ha return group.handle(httpMethod, relativePath, handlers) } -// POST is a shortcut for router.Handle("POST", path, handle) +// POST is a shortcut for router.Handle("POST", path, handle). func (group *RouterGroup) POST(relativePath string, handlers ...HandlerFunc) IRoutes { return group.handle("POST", relativePath, handlers) } -// GET is a shortcut for router.Handle("GET", path, handle) +// GET is a shortcut for router.Handle("GET", path, handle). func (group *RouterGroup) GET(relativePath string, handlers ...HandlerFunc) IRoutes { return group.handle("GET", relativePath, handlers) } -// DELETE is a shortcut for router.Handle("DELETE", path, handle) +// DELETE is a shortcut for router.Handle("DELETE", path, handle). func (group *RouterGroup) DELETE(relativePath string, handlers ...HandlerFunc) IRoutes { return group.handle("DELETE", relativePath, handlers) } -// PATCH is a shortcut for router.Handle("PATCH", path, handle) +// PATCH is a shortcut for router.Handle("PATCH", path, handle). func (group *RouterGroup) PATCH(relativePath string, handlers ...HandlerFunc) IRoutes { return group.handle("PATCH", relativePath, handlers) } -// PUT is a shortcut for router.Handle("PUT", path, handle) +// PUT is a shortcut for router.Handle("PUT", path, handle). func (group *RouterGroup) PUT(relativePath string, handlers ...HandlerFunc) IRoutes { return group.handle("PUT", relativePath, handlers) } -// OPTIONS is a shortcut for router.Handle("OPTIONS", path, handle) +// OPTIONS is a shortcut for router.Handle("OPTIONS", path, handle). func (group *RouterGroup) OPTIONS(relativePath string, handlers ...HandlerFunc) IRoutes { return group.handle("OPTIONS", relativePath, handlers) } -// HEAD is a shortcut for router.Handle("HEAD", path, handle) +// HEAD is a shortcut for router.Handle("HEAD", path, handle). func (group *RouterGroup) HEAD(relativePath string, handlers ...HandlerFunc) IRoutes { return group.handle("HEAD", relativePath, handlers) } // Any registers a route that matches all the HTTP methods. -// GET, POST, PUT, PATCH, HEAD, OPTIONS, DELETE, CONNECT, TRACE +// GET, POST, PUT, PATCH, HEAD, OPTIONS, DELETE, CONNECT, TRACE. func (group *RouterGroup) Any(relativePath string, handlers ...HandlerFunc) IRoutes { group.handle("GET", relativePath, handlers) group.handle("POST", relativePath, handlers) diff --git a/vendor/github.com/gin-gonic/gin/routes_test.go b/vendor/github.com/gin-gonic/gin/routes_test.go index 41693eed0..b44b6431e 100644 --- a/vendor/github.com/gin-gonic/gin/routes_test.go +++ b/vendor/github.com/gin-gonic/gin/routes_test.go @@ -356,25 +356,25 @@ func TestRouterNotFound(t *testing.T) { router.GET("/", func(c *Context) {}) testRoutes := []struct { - route string - code int - header string + route string + code int + location string }{ - {"/path/", 301, "map[Location:[/path]]"}, // TSR -/ - {"/dir", 301, "map[Location:[/dir/]]"}, // TSR +/ - {"", 301, "map[Location:[/]]"}, // TSR +/ - {"/PATH", 301, "map[Location:[/path]]"}, // Fixed Case - {"/DIR/", 301, "map[Location:[/dir/]]"}, // Fixed Case - {"/PATH/", 301, "map[Location:[/path]]"}, // Fixed Case -/ - {"/DIR", 301, "map[Location:[/dir/]]"}, // Fixed Case +/ - {"/../path", 301, "map[Location:[/path]]"}, // CleanPath - {"/nope", 404, ""}, // NotFound + {"/path/", 301, "/path"}, // TSR -/ + {"/dir", 301, "/dir/"}, // TSR +/ + {"", 301, "/"}, // TSR +/ + {"/PATH", 301, "/path"}, // Fixed Case + {"/DIR/", 301, "/dir/"}, // Fixed Case + {"/PATH/", 301, "/path"}, // Fixed Case -/ + {"/DIR", 301, "/dir/"}, // Fixed Case +/ + {"/../path", 301, "/path"}, // CleanPath + {"/nope", 404, ""}, // NotFound } for _, tr := range testRoutes { w := performRequest(router, "GET", tr.route) assert.Equal(t, w.Code, tr.code) if w.Code != 404 { - assert.Equal(t, fmt.Sprint(w.Header()), tr.header) + assert.Equal(t, fmt.Sprint(w.Header().Get("Location")), tr.location) } } diff --git a/vendor/github.com/gin-gonic/gin/tree.go b/vendor/github.com/gin-gonic/gin/tree.go index 750ffae89..f67edd5dc 100644 --- a/vendor/github.com/gin-gonic/gin/tree.go +++ b/vendor/github.com/gin-gonic/gin/tree.go @@ -96,7 +96,7 @@ type node struct { priority uint32 } -// increments priority of the given child and reorders if necessary +// increments priority of the given child and reorders if necessary. func (n *node) incrementChildPrio(pos int) int { n.children[pos].priority++ prio := n.children[pos].priority diff --git a/vendor/github.com/gin-gonic/gin/utils.go b/vendor/github.com/gin-gonic/gin/utils.go index 968570c7e..ab06a759d 100644 --- a/vendor/github.com/gin-gonic/gin/utils.go +++ b/vendor/github.com/gin-gonic/gin/utils.go @@ -47,7 +47,7 @@ func WrapH(h http.Handler) HandlerFunc { type H map[string]interface{} -// MarshalXML allows type H to be used with xml.Marshal +// MarshalXML allows type H to be used with xml.Marshal. func (h H) MarshalXML(e *xml.Encoder, start xml.StartElement) error { start.Name = xml.Name{ Space: "", diff --git a/vendor/github.com/gin-gonic/gin/vendor/vendor.json b/vendor/github.com/gin-gonic/gin/vendor/vendor.json index e8690a2c0..bcefee103 100644 --- a/vendor/github.com/gin-gonic/gin/vendor/vendor.json +++ b/vendor/github.com/gin-gonic/gin/vendor/vendor.json @@ -34,10 +34,10 @@ "revisionTime": "2017-06-01T23:02:30Z" }, { - "checksumSHA1": "0e59uuETpidkmpaRwipQ8auqwhM=", + "checksumSHA1": "Ajh8TemnItg4nn+jKmVcsMRALBc=", "path": "github.com/json-iterator/go", - "revision": "6b6938829d6156d7b9825f83eec757f0f571c981", - "revisionTime": "2017-07-18T14:19:52Z" + "revision": "36b14963da70d11297d313183d7e6388c8510e1e", + "revisionTime": "2017-08-29T15:58:51Z" }, { "checksumSHA1": "9if9IBLsxkarJ804NPWAzgskIAk=", diff --git a/vendor/github.com/golang/protobuf/.gitignore b/vendor/github.com/golang/protobuf/.gitignore index 8f5b596b1..0bf694c97 100644 --- a/vendor/github.com/golang/protobuf/.gitignore +++ b/vendor/github.com/golang/protobuf/.gitignore @@ -1,5 +1,6 @@ .DS_Store *.[568ao] +*.pb.go *.ao *.so *.pyc @@ -12,5 +13,5 @@ core _obj _test _testmain.go -protoc-gen-go/testdata/multi/*.pb.go -_conformance/_conformance +compiler/protoc-gen-go +compiler/testdata/extension_test diff --git a/vendor/github.com/golang/protobuf/Makefile b/vendor/github.com/golang/protobuf/Makefile index a1421d8b7..d24239e47 100644 --- a/vendor/github.com/golang/protobuf/Makefile +++ b/vendor/github.com/golang/protobuf/Makefile @@ -33,11 +33,13 @@ all: install install: - go install ./proto ./jsonpb ./ptypes + go install ./proto + go install ./jsonpb go install ./protoc-gen-go test: - go test ./proto ./jsonpb ./ptypes + go test ./proto + go test ./jsonpb make -C protoc-gen-go/testdata test clean: @@ -52,4 +54,3 @@ regenerate: make -C protoc-gen-go/testdata regenerate make -C proto/testdata regenerate make -C jsonpb/jsonpb_test_proto regenerate - make -C _conformance regenerate diff --git a/vendor/github.com/golang/protobuf/README.md b/vendor/github.com/golang/protobuf/README.md index 037fc7c8e..12b39c3e0 100644 --- a/vendor/github.com/golang/protobuf/README.md +++ b/vendor/github.com/golang/protobuf/README.md @@ -140,7 +140,6 @@ To create and play with a Test object from the example package, test := &example.Test { Label: proto.String("hello"), Type: proto.Int32(17), - Reps: []int64{1, 2, 3}, Optionalgroup: &example.Test_OptionalGroup { RequiredField: proto.String("good bye"), }, @@ -191,51 +190,3 @@ the `plugins` parameter to protoc-gen-go; the usual way is to insert it into the --go_out argument to protoc: protoc --go_out=plugins=grpc:. *.proto - -## Compatibility ## - -The library and the generated code are expected to be stable over time. -However, we reserve the right to make breaking changes without notice for the -following reasons: - -- Security. A security issue in the specification or implementation may come to - light whose resolution requires breaking compatibility. We reserve the right - to address such security issues. -- Unspecified behavior. There are some aspects of the Protocol Buffers - specification that are undefined. Programs that depend on such unspecified - behavior may break in future releases. -- Specification errors or changes. If it becomes necessary to address an - inconsistency, incompleteness, or change in the Protocol Buffers - specification, resolving the issue could affect the meaning or legality of - existing programs. We reserve the right to address such issues, including - updating the implementations. -- Bugs. If the library has a bug that violates the specification, a program - that depends on the buggy behavior may break if the bug is fixed. We reserve - the right to fix such bugs. -- Adding methods or fields to generated structs. These may conflict with field - names that already exist in a schema, causing applications to break. When the - code generator encounters a field in the schema that would collide with a - generated field or method name, the code generator will append an underscore - to the generated field or method name. -- Adding, removing, or changing methods or fields in generated structs that - start with `XXX`. These parts of the generated code are exported out of - necessity, but should not be considered part of the public API. -- Adding, removing, or changing unexported symbols in generated code. - -Any breaking changes outside of these will be announced 6 months in advance to -protobuf@googlegroups.com. - -You should, whenever possible, use generated code created by the `protoc-gen-go` -tool built at the same commit as the `proto` package. The `proto` package -declares package-level constants in the form `ProtoPackageIsVersionX`. -Application code and generated code may depend on one of these constants to -ensure that compilation will fail if the available version of the proto library -is too old. Whenever we make a change to the generated code that requires newer -library support, in the same commit we will increment the version number of the -generated code and declare a new package-level constant whose name incorporates -the latest version number. Removing a compatibility constant is considered a -breaking change and would be subject to the announcement policy stated above. - -The `protoc-gen-go/generator` package exposes a plugin interface, -which is used by the gRPC code generation. This interface is not -supported and is subject to incompatible changes without notice. diff --git a/vendor/github.com/golang/protobuf/_conformance/Makefile b/vendor/github.com/golang/protobuf/_conformance/Makefile deleted file mode 100644 index 89800e2d9..000000000 --- a/vendor/github.com/golang/protobuf/_conformance/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# Go support for Protocol Buffers - Google's data interchange format -# -# Copyright 2016 The Go Authors. All rights reserved. -# https://github.com/golang/protobuf -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -regenerate: - protoc --go_out=Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any,Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration,Mgoogle/protobuf/struct.proto=github.com/golang/protobuf/ptypes/struct,Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp,Mgoogle/protobuf/wrappers.proto=github.com/golang/protobuf/ptypes/wrappers,Mgoogle/protobuf/field_mask.proto=google.golang.org/genproto/protobuf:. conformance_proto/conformance.proto diff --git a/vendor/github.com/golang/protobuf/_conformance/conformance.go b/vendor/github.com/golang/protobuf/_conformance/conformance.go deleted file mode 100644 index c54212c80..000000000 --- a/vendor/github.com/golang/protobuf/_conformance/conformance.go +++ /dev/null @@ -1,161 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2016 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// conformance implements the conformance test subprocess protocol as -// documented in conformance.proto. -package main - -import ( - "encoding/binary" - "fmt" - "io" - "os" - - pb "github.com/golang/protobuf/_conformance/conformance_proto" - "github.com/golang/protobuf/jsonpb" - "github.com/golang/protobuf/proto" -) - -func main() { - var sizeBuf [4]byte - inbuf := make([]byte, 0, 4096) - outbuf := proto.NewBuffer(nil) - for { - if _, err := io.ReadFull(os.Stdin, sizeBuf[:]); err == io.EOF { - break - } else if err != nil { - fmt.Fprintln(os.Stderr, "go conformance: read request:", err) - os.Exit(1) - } - size := binary.LittleEndian.Uint32(sizeBuf[:]) - if int(size) > cap(inbuf) { - inbuf = make([]byte, size) - } - inbuf = inbuf[:size] - if _, err := io.ReadFull(os.Stdin, inbuf); err != nil { - fmt.Fprintln(os.Stderr, "go conformance: read request:", err) - os.Exit(1) - } - - req := new(pb.ConformanceRequest) - if err := proto.Unmarshal(inbuf, req); err != nil { - fmt.Fprintln(os.Stderr, "go conformance: parse request:", err) - os.Exit(1) - } - res := handle(req) - - if err := outbuf.Marshal(res); err != nil { - fmt.Fprintln(os.Stderr, "go conformance: marshal response:", err) - os.Exit(1) - } - binary.LittleEndian.PutUint32(sizeBuf[:], uint32(len(outbuf.Bytes()))) - if _, err := os.Stdout.Write(sizeBuf[:]); err != nil { - fmt.Fprintln(os.Stderr, "go conformance: write response:", err) - os.Exit(1) - } - if _, err := os.Stdout.Write(outbuf.Bytes()); err != nil { - fmt.Fprintln(os.Stderr, "go conformance: write response:", err) - os.Exit(1) - } - outbuf.Reset() - } -} - -var jsonMarshaler = jsonpb.Marshaler{ - OrigName: true, -} - -func handle(req *pb.ConformanceRequest) *pb.ConformanceResponse { - var err error - var msg pb.TestAllTypes - switch p := req.Payload.(type) { - case *pb.ConformanceRequest_ProtobufPayload: - err = proto.Unmarshal(p.ProtobufPayload, &msg) - case *pb.ConformanceRequest_JsonPayload: - err = jsonpb.UnmarshalString(p.JsonPayload, &msg) - if err != nil && err.Error() == "unmarshaling Any not supported yet" { - return &pb.ConformanceResponse{ - Result: &pb.ConformanceResponse_Skipped{ - Skipped: err.Error(), - }, - } - } - default: - return &pb.ConformanceResponse{ - Result: &pb.ConformanceResponse_RuntimeError{ - RuntimeError: "unknown request payload type", - }, - } - } - if err != nil { - return &pb.ConformanceResponse{ - Result: &pb.ConformanceResponse_ParseError{ - ParseError: err.Error(), - }, - } - } - switch req.RequestedOutputFormat { - case pb.WireFormat_PROTOBUF: - p, err := proto.Marshal(&msg) - if err != nil { - return &pb.ConformanceResponse{ - Result: &pb.ConformanceResponse_SerializeError{ - SerializeError: err.Error(), - }, - } - } - return &pb.ConformanceResponse{ - Result: &pb.ConformanceResponse_ProtobufPayload{ - ProtobufPayload: p, - }, - } - case pb.WireFormat_JSON: - p, err := jsonMarshaler.MarshalToString(&msg) - if err != nil { - return &pb.ConformanceResponse{ - Result: &pb.ConformanceResponse_SerializeError{ - SerializeError: err.Error(), - }, - } - } - return &pb.ConformanceResponse{ - Result: &pb.ConformanceResponse_JsonPayload{ - JsonPayload: p, - }, - } - default: - return &pb.ConformanceResponse{ - Result: &pb.ConformanceResponse_RuntimeError{ - RuntimeError: "unknown output format", - }, - } - } -} diff --git a/vendor/github.com/golang/protobuf/_conformance/conformance_proto/conformance.pb.go b/vendor/github.com/golang/protobuf/_conformance/conformance_proto/conformance.pb.go deleted file mode 100644 index 5e01f9b9c..000000000 --- a/vendor/github.com/golang/protobuf/_conformance/conformance_proto/conformance.pb.go +++ /dev/null @@ -1,1886 +0,0 @@ -// Code generated by protoc-gen-go. -// source: conformance_proto/conformance.proto -// DO NOT EDIT! - -/* -Package conformance is a generated protocol buffer package. - -It is generated from these files: - conformance_proto/conformance.proto - -It has these top-level messages: - ConformanceRequest - ConformanceResponse - TestAllTypes - ForeignMessage -*/ -package conformance - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" -import google_protobuf "github.com/golang/protobuf/ptypes/any" -import google_protobuf1 "github.com/golang/protobuf/ptypes/duration" -import google_protobuf2 "google.golang.org/genproto/protobuf" -import google_protobuf3 "github.com/golang/protobuf/ptypes/struct" -import google_protobuf4 "github.com/golang/protobuf/ptypes/timestamp" -import google_protobuf5 "github.com/golang/protobuf/ptypes/wrappers" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type WireFormat int32 - -const ( - WireFormat_UNSPECIFIED WireFormat = 0 - WireFormat_PROTOBUF WireFormat = 1 - WireFormat_JSON WireFormat = 2 -) - -var WireFormat_name = map[int32]string{ - 0: "UNSPECIFIED", - 1: "PROTOBUF", - 2: "JSON", -} -var WireFormat_value = map[string]int32{ - "UNSPECIFIED": 0, - "PROTOBUF": 1, - "JSON": 2, -} - -func (x WireFormat) String() string { - return proto.EnumName(WireFormat_name, int32(x)) -} -func (WireFormat) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -type ForeignEnum int32 - -const ( - ForeignEnum_FOREIGN_FOO ForeignEnum = 0 - ForeignEnum_FOREIGN_BAR ForeignEnum = 1 - ForeignEnum_FOREIGN_BAZ ForeignEnum = 2 -) - -var ForeignEnum_name = map[int32]string{ - 0: "FOREIGN_FOO", - 1: "FOREIGN_BAR", - 2: "FOREIGN_BAZ", -} -var ForeignEnum_value = map[string]int32{ - "FOREIGN_FOO": 0, - "FOREIGN_BAR": 1, - "FOREIGN_BAZ": 2, -} - -func (x ForeignEnum) String() string { - return proto.EnumName(ForeignEnum_name, int32(x)) -} -func (ForeignEnum) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } - -type TestAllTypes_NestedEnum int32 - -const ( - TestAllTypes_FOO TestAllTypes_NestedEnum = 0 - TestAllTypes_BAR TestAllTypes_NestedEnum = 1 - TestAllTypes_BAZ TestAllTypes_NestedEnum = 2 - TestAllTypes_NEG TestAllTypes_NestedEnum = -1 -) - -var TestAllTypes_NestedEnum_name = map[int32]string{ - 0: "FOO", - 1: "BAR", - 2: "BAZ", - -1: "NEG", -} -var TestAllTypes_NestedEnum_value = map[string]int32{ - "FOO": 0, - "BAR": 1, - "BAZ": 2, - "NEG": -1, -} - -func (x TestAllTypes_NestedEnum) String() string { - return proto.EnumName(TestAllTypes_NestedEnum_name, int32(x)) -} -func (TestAllTypes_NestedEnum) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{2, 0} } - -// Represents a single test case's input. The testee should: -// -// 1. parse this proto (which should always succeed) -// 2. parse the protobuf or JSON payload in "payload" (which may fail) -// 3. if the parse succeeded, serialize the message in the requested format. -type ConformanceRequest struct { - // The payload (whether protobuf of JSON) is always for a TestAllTypes proto - // (see below). - // - // Types that are valid to be assigned to Payload: - // *ConformanceRequest_ProtobufPayload - // *ConformanceRequest_JsonPayload - Payload isConformanceRequest_Payload `protobuf_oneof:"payload"` - // Which format should the testee serialize its message to? - RequestedOutputFormat WireFormat `protobuf:"varint,3,opt,name=requested_output_format,json=requestedOutputFormat,enum=conformance.WireFormat" json:"requested_output_format,omitempty"` -} - -func (m *ConformanceRequest) Reset() { *m = ConformanceRequest{} } -func (m *ConformanceRequest) String() string { return proto.CompactTextString(m) } -func (*ConformanceRequest) ProtoMessage() {} -func (*ConformanceRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -type isConformanceRequest_Payload interface { - isConformanceRequest_Payload() -} - -type ConformanceRequest_ProtobufPayload struct { - ProtobufPayload []byte `protobuf:"bytes,1,opt,name=protobuf_payload,json=protobufPayload,proto3,oneof"` -} -type ConformanceRequest_JsonPayload struct { - JsonPayload string `protobuf:"bytes,2,opt,name=json_payload,json=jsonPayload,oneof"` -} - -func (*ConformanceRequest_ProtobufPayload) isConformanceRequest_Payload() {} -func (*ConformanceRequest_JsonPayload) isConformanceRequest_Payload() {} - -func (m *ConformanceRequest) GetPayload() isConformanceRequest_Payload { - if m != nil { - return m.Payload - } - return nil -} - -func (m *ConformanceRequest) GetProtobufPayload() []byte { - if x, ok := m.GetPayload().(*ConformanceRequest_ProtobufPayload); ok { - return x.ProtobufPayload - } - return nil -} - -func (m *ConformanceRequest) GetJsonPayload() string { - if x, ok := m.GetPayload().(*ConformanceRequest_JsonPayload); ok { - return x.JsonPayload - } - return "" -} - -func (m *ConformanceRequest) GetRequestedOutputFormat() WireFormat { - if m != nil { - return m.RequestedOutputFormat - } - return WireFormat_UNSPECIFIED -} - -// XXX_OneofFuncs is for the internal use of the proto package. -func (*ConformanceRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _ConformanceRequest_OneofMarshaler, _ConformanceRequest_OneofUnmarshaler, _ConformanceRequest_OneofSizer, []interface{}{ - (*ConformanceRequest_ProtobufPayload)(nil), - (*ConformanceRequest_JsonPayload)(nil), - } -} - -func _ConformanceRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*ConformanceRequest) - // payload - switch x := m.Payload.(type) { - case *ConformanceRequest_ProtobufPayload: - b.EncodeVarint(1<<3 | proto.WireBytes) - b.EncodeRawBytes(x.ProtobufPayload) - case *ConformanceRequest_JsonPayload: - b.EncodeVarint(2<<3 | proto.WireBytes) - b.EncodeStringBytes(x.JsonPayload) - case nil: - default: - return fmt.Errorf("ConformanceRequest.Payload has unexpected type %T", x) - } - return nil -} - -func _ConformanceRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*ConformanceRequest) - switch tag { - case 1: // payload.protobuf_payload - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.Payload = &ConformanceRequest_ProtobufPayload{x} - return true, err - case 2: // payload.json_payload - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Payload = &ConformanceRequest_JsonPayload{x} - return true, err - default: - return false, nil - } -} - -func _ConformanceRequest_OneofSizer(msg proto.Message) (n int) { - m := msg.(*ConformanceRequest) - // payload - switch x := m.Payload.(type) { - case *ConformanceRequest_ProtobufPayload: - n += proto.SizeVarint(1<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.ProtobufPayload))) - n += len(x.ProtobufPayload) - case *ConformanceRequest_JsonPayload: - n += proto.SizeVarint(2<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.JsonPayload))) - n += len(x.JsonPayload) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - -// Represents a single test case's output. -type ConformanceResponse struct { - // Types that are valid to be assigned to Result: - // *ConformanceResponse_ParseError - // *ConformanceResponse_SerializeError - // *ConformanceResponse_RuntimeError - // *ConformanceResponse_ProtobufPayload - // *ConformanceResponse_JsonPayload - // *ConformanceResponse_Skipped - Result isConformanceResponse_Result `protobuf_oneof:"result"` -} - -func (m *ConformanceResponse) Reset() { *m = ConformanceResponse{} } -func (m *ConformanceResponse) String() string { return proto.CompactTextString(m) } -func (*ConformanceResponse) ProtoMessage() {} -func (*ConformanceResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } - -type isConformanceResponse_Result interface { - isConformanceResponse_Result() -} - -type ConformanceResponse_ParseError struct { - ParseError string `protobuf:"bytes,1,opt,name=parse_error,json=parseError,oneof"` -} -type ConformanceResponse_SerializeError struct { - SerializeError string `protobuf:"bytes,6,opt,name=serialize_error,json=serializeError,oneof"` -} -type ConformanceResponse_RuntimeError struct { - RuntimeError string `protobuf:"bytes,2,opt,name=runtime_error,json=runtimeError,oneof"` -} -type ConformanceResponse_ProtobufPayload struct { - ProtobufPayload []byte `protobuf:"bytes,3,opt,name=protobuf_payload,json=protobufPayload,proto3,oneof"` -} -type ConformanceResponse_JsonPayload struct { - JsonPayload string `protobuf:"bytes,4,opt,name=json_payload,json=jsonPayload,oneof"` -} -type ConformanceResponse_Skipped struct { - Skipped string `protobuf:"bytes,5,opt,name=skipped,oneof"` -} - -func (*ConformanceResponse_ParseError) isConformanceResponse_Result() {} -func (*ConformanceResponse_SerializeError) isConformanceResponse_Result() {} -func (*ConformanceResponse_RuntimeError) isConformanceResponse_Result() {} -func (*ConformanceResponse_ProtobufPayload) isConformanceResponse_Result() {} -func (*ConformanceResponse_JsonPayload) isConformanceResponse_Result() {} -func (*ConformanceResponse_Skipped) isConformanceResponse_Result() {} - -func (m *ConformanceResponse) GetResult() isConformanceResponse_Result { - if m != nil { - return m.Result - } - return nil -} - -func (m *ConformanceResponse) GetParseError() string { - if x, ok := m.GetResult().(*ConformanceResponse_ParseError); ok { - return x.ParseError - } - return "" -} - -func (m *ConformanceResponse) GetSerializeError() string { - if x, ok := m.GetResult().(*ConformanceResponse_SerializeError); ok { - return x.SerializeError - } - return "" -} - -func (m *ConformanceResponse) GetRuntimeError() string { - if x, ok := m.GetResult().(*ConformanceResponse_RuntimeError); ok { - return x.RuntimeError - } - return "" -} - -func (m *ConformanceResponse) GetProtobufPayload() []byte { - if x, ok := m.GetResult().(*ConformanceResponse_ProtobufPayload); ok { - return x.ProtobufPayload - } - return nil -} - -func (m *ConformanceResponse) GetJsonPayload() string { - if x, ok := m.GetResult().(*ConformanceResponse_JsonPayload); ok { - return x.JsonPayload - } - return "" -} - -func (m *ConformanceResponse) GetSkipped() string { - if x, ok := m.GetResult().(*ConformanceResponse_Skipped); ok { - return x.Skipped - } - return "" -} - -// XXX_OneofFuncs is for the internal use of the proto package. -func (*ConformanceResponse) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _ConformanceResponse_OneofMarshaler, _ConformanceResponse_OneofUnmarshaler, _ConformanceResponse_OneofSizer, []interface{}{ - (*ConformanceResponse_ParseError)(nil), - (*ConformanceResponse_SerializeError)(nil), - (*ConformanceResponse_RuntimeError)(nil), - (*ConformanceResponse_ProtobufPayload)(nil), - (*ConformanceResponse_JsonPayload)(nil), - (*ConformanceResponse_Skipped)(nil), - } -} - -func _ConformanceResponse_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*ConformanceResponse) - // result - switch x := m.Result.(type) { - case *ConformanceResponse_ParseError: - b.EncodeVarint(1<<3 | proto.WireBytes) - b.EncodeStringBytes(x.ParseError) - case *ConformanceResponse_SerializeError: - b.EncodeVarint(6<<3 | proto.WireBytes) - b.EncodeStringBytes(x.SerializeError) - case *ConformanceResponse_RuntimeError: - b.EncodeVarint(2<<3 | proto.WireBytes) - b.EncodeStringBytes(x.RuntimeError) - case *ConformanceResponse_ProtobufPayload: - b.EncodeVarint(3<<3 | proto.WireBytes) - b.EncodeRawBytes(x.ProtobufPayload) - case *ConformanceResponse_JsonPayload: - b.EncodeVarint(4<<3 | proto.WireBytes) - b.EncodeStringBytes(x.JsonPayload) - case *ConformanceResponse_Skipped: - b.EncodeVarint(5<<3 | proto.WireBytes) - b.EncodeStringBytes(x.Skipped) - case nil: - default: - return fmt.Errorf("ConformanceResponse.Result has unexpected type %T", x) - } - return nil -} - -func _ConformanceResponse_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*ConformanceResponse) - switch tag { - case 1: // result.parse_error - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Result = &ConformanceResponse_ParseError{x} - return true, err - case 6: // result.serialize_error - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Result = &ConformanceResponse_SerializeError{x} - return true, err - case 2: // result.runtime_error - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Result = &ConformanceResponse_RuntimeError{x} - return true, err - case 3: // result.protobuf_payload - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.Result = &ConformanceResponse_ProtobufPayload{x} - return true, err - case 4: // result.json_payload - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Result = &ConformanceResponse_JsonPayload{x} - return true, err - case 5: // result.skipped - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Result = &ConformanceResponse_Skipped{x} - return true, err - default: - return false, nil - } -} - -func _ConformanceResponse_OneofSizer(msg proto.Message) (n int) { - m := msg.(*ConformanceResponse) - // result - switch x := m.Result.(type) { - case *ConformanceResponse_ParseError: - n += proto.SizeVarint(1<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.ParseError))) - n += len(x.ParseError) - case *ConformanceResponse_SerializeError: - n += proto.SizeVarint(6<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.SerializeError))) - n += len(x.SerializeError) - case *ConformanceResponse_RuntimeError: - n += proto.SizeVarint(2<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.RuntimeError))) - n += len(x.RuntimeError) - case *ConformanceResponse_ProtobufPayload: - n += proto.SizeVarint(3<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.ProtobufPayload))) - n += len(x.ProtobufPayload) - case *ConformanceResponse_JsonPayload: - n += proto.SizeVarint(4<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.JsonPayload))) - n += len(x.JsonPayload) - case *ConformanceResponse_Skipped: - n += proto.SizeVarint(5<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.Skipped))) - n += len(x.Skipped) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - -// This proto includes every type of field in both singular and repeated -// forms. -type TestAllTypes struct { - // Singular - OptionalInt32 int32 `protobuf:"varint,1,opt,name=optional_int32,json=optionalInt32" json:"optional_int32,omitempty"` - OptionalInt64 int64 `protobuf:"varint,2,opt,name=optional_int64,json=optionalInt64" json:"optional_int64,omitempty"` - OptionalUint32 uint32 `protobuf:"varint,3,opt,name=optional_uint32,json=optionalUint32" json:"optional_uint32,omitempty"` - OptionalUint64 uint64 `protobuf:"varint,4,opt,name=optional_uint64,json=optionalUint64" json:"optional_uint64,omitempty"` - OptionalSint32 int32 `protobuf:"zigzag32,5,opt,name=optional_sint32,json=optionalSint32" json:"optional_sint32,omitempty"` - OptionalSint64 int64 `protobuf:"zigzag64,6,opt,name=optional_sint64,json=optionalSint64" json:"optional_sint64,omitempty"` - OptionalFixed32 uint32 `protobuf:"fixed32,7,opt,name=optional_fixed32,json=optionalFixed32" json:"optional_fixed32,omitempty"` - OptionalFixed64 uint64 `protobuf:"fixed64,8,opt,name=optional_fixed64,json=optionalFixed64" json:"optional_fixed64,omitempty"` - OptionalSfixed32 int32 `protobuf:"fixed32,9,opt,name=optional_sfixed32,json=optionalSfixed32" json:"optional_sfixed32,omitempty"` - OptionalSfixed64 int64 `protobuf:"fixed64,10,opt,name=optional_sfixed64,json=optionalSfixed64" json:"optional_sfixed64,omitempty"` - OptionalFloat float32 `protobuf:"fixed32,11,opt,name=optional_float,json=optionalFloat" json:"optional_float,omitempty"` - OptionalDouble float64 `protobuf:"fixed64,12,opt,name=optional_double,json=optionalDouble" json:"optional_double,omitempty"` - OptionalBool bool `protobuf:"varint,13,opt,name=optional_bool,json=optionalBool" json:"optional_bool,omitempty"` - OptionalString string `protobuf:"bytes,14,opt,name=optional_string,json=optionalString" json:"optional_string,omitempty"` - OptionalBytes []byte `protobuf:"bytes,15,opt,name=optional_bytes,json=optionalBytes,proto3" json:"optional_bytes,omitempty"` - OptionalNestedMessage *TestAllTypes_NestedMessage `protobuf:"bytes,18,opt,name=optional_nested_message,json=optionalNestedMessage" json:"optional_nested_message,omitempty"` - OptionalForeignMessage *ForeignMessage `protobuf:"bytes,19,opt,name=optional_foreign_message,json=optionalForeignMessage" json:"optional_foreign_message,omitempty"` - OptionalNestedEnum TestAllTypes_NestedEnum `protobuf:"varint,21,opt,name=optional_nested_enum,json=optionalNestedEnum,enum=conformance.TestAllTypes_NestedEnum" json:"optional_nested_enum,omitempty"` - OptionalForeignEnum ForeignEnum `protobuf:"varint,22,opt,name=optional_foreign_enum,json=optionalForeignEnum,enum=conformance.ForeignEnum" json:"optional_foreign_enum,omitempty"` - OptionalStringPiece string `protobuf:"bytes,24,opt,name=optional_string_piece,json=optionalStringPiece" json:"optional_string_piece,omitempty"` - OptionalCord string `protobuf:"bytes,25,opt,name=optional_cord,json=optionalCord" json:"optional_cord,omitempty"` - RecursiveMessage *TestAllTypes `protobuf:"bytes,27,opt,name=recursive_message,json=recursiveMessage" json:"recursive_message,omitempty"` - // Repeated - RepeatedInt32 []int32 `protobuf:"varint,31,rep,packed,name=repeated_int32,json=repeatedInt32" json:"repeated_int32,omitempty"` - RepeatedInt64 []int64 `protobuf:"varint,32,rep,packed,name=repeated_int64,json=repeatedInt64" json:"repeated_int64,omitempty"` - RepeatedUint32 []uint32 `protobuf:"varint,33,rep,packed,name=repeated_uint32,json=repeatedUint32" json:"repeated_uint32,omitempty"` - RepeatedUint64 []uint64 `protobuf:"varint,34,rep,packed,name=repeated_uint64,json=repeatedUint64" json:"repeated_uint64,omitempty"` - RepeatedSint32 []int32 `protobuf:"zigzag32,35,rep,packed,name=repeated_sint32,json=repeatedSint32" json:"repeated_sint32,omitempty"` - RepeatedSint64 []int64 `protobuf:"zigzag64,36,rep,packed,name=repeated_sint64,json=repeatedSint64" json:"repeated_sint64,omitempty"` - RepeatedFixed32 []uint32 `protobuf:"fixed32,37,rep,packed,name=repeated_fixed32,json=repeatedFixed32" json:"repeated_fixed32,omitempty"` - RepeatedFixed64 []uint64 `protobuf:"fixed64,38,rep,packed,name=repeated_fixed64,json=repeatedFixed64" json:"repeated_fixed64,omitempty"` - RepeatedSfixed32 []int32 `protobuf:"fixed32,39,rep,packed,name=repeated_sfixed32,json=repeatedSfixed32" json:"repeated_sfixed32,omitempty"` - RepeatedSfixed64 []int64 `protobuf:"fixed64,40,rep,packed,name=repeated_sfixed64,json=repeatedSfixed64" json:"repeated_sfixed64,omitempty"` - RepeatedFloat []float32 `protobuf:"fixed32,41,rep,packed,name=repeated_float,json=repeatedFloat" json:"repeated_float,omitempty"` - RepeatedDouble []float64 `protobuf:"fixed64,42,rep,packed,name=repeated_double,json=repeatedDouble" json:"repeated_double,omitempty"` - RepeatedBool []bool `protobuf:"varint,43,rep,packed,name=repeated_bool,json=repeatedBool" json:"repeated_bool,omitempty"` - RepeatedString []string `protobuf:"bytes,44,rep,name=repeated_string,json=repeatedString" json:"repeated_string,omitempty"` - RepeatedBytes [][]byte `protobuf:"bytes,45,rep,name=repeated_bytes,json=repeatedBytes,proto3" json:"repeated_bytes,omitempty"` - RepeatedNestedMessage []*TestAllTypes_NestedMessage `protobuf:"bytes,48,rep,name=repeated_nested_message,json=repeatedNestedMessage" json:"repeated_nested_message,omitempty"` - RepeatedForeignMessage []*ForeignMessage `protobuf:"bytes,49,rep,name=repeated_foreign_message,json=repeatedForeignMessage" json:"repeated_foreign_message,omitempty"` - RepeatedNestedEnum []TestAllTypes_NestedEnum `protobuf:"varint,51,rep,packed,name=repeated_nested_enum,json=repeatedNestedEnum,enum=conformance.TestAllTypes_NestedEnum" json:"repeated_nested_enum,omitempty"` - RepeatedForeignEnum []ForeignEnum `protobuf:"varint,52,rep,packed,name=repeated_foreign_enum,json=repeatedForeignEnum,enum=conformance.ForeignEnum" json:"repeated_foreign_enum,omitempty"` - RepeatedStringPiece []string `protobuf:"bytes,54,rep,name=repeated_string_piece,json=repeatedStringPiece" json:"repeated_string_piece,omitempty"` - RepeatedCord []string `protobuf:"bytes,55,rep,name=repeated_cord,json=repeatedCord" json:"repeated_cord,omitempty"` - // Map - MapInt32Int32 map[int32]int32 `protobuf:"bytes,56,rep,name=map_int32_int32,json=mapInt32Int32" json:"map_int32_int32,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` - MapInt64Int64 map[int64]int64 `protobuf:"bytes,57,rep,name=map_int64_int64,json=mapInt64Int64" json:"map_int64_int64,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` - MapUint32Uint32 map[uint32]uint32 `protobuf:"bytes,58,rep,name=map_uint32_uint32,json=mapUint32Uint32" json:"map_uint32_uint32,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` - MapUint64Uint64 map[uint64]uint64 `protobuf:"bytes,59,rep,name=map_uint64_uint64,json=mapUint64Uint64" json:"map_uint64_uint64,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` - MapSint32Sint32 map[int32]int32 `protobuf:"bytes,60,rep,name=map_sint32_sint32,json=mapSint32Sint32" json:"map_sint32_sint32,omitempty" protobuf_key:"zigzag32,1,opt,name=key" protobuf_val:"zigzag32,2,opt,name=value"` - MapSint64Sint64 map[int64]int64 `protobuf:"bytes,61,rep,name=map_sint64_sint64,json=mapSint64Sint64" json:"map_sint64_sint64,omitempty" protobuf_key:"zigzag64,1,opt,name=key" protobuf_val:"zigzag64,2,opt,name=value"` - MapFixed32Fixed32 map[uint32]uint32 `protobuf:"bytes,62,rep,name=map_fixed32_fixed32,json=mapFixed32Fixed32" json:"map_fixed32_fixed32,omitempty" protobuf_key:"fixed32,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"` - MapFixed64Fixed64 map[uint64]uint64 `protobuf:"bytes,63,rep,name=map_fixed64_fixed64,json=mapFixed64Fixed64" json:"map_fixed64_fixed64,omitempty" protobuf_key:"fixed64,1,opt,name=key" protobuf_val:"fixed64,2,opt,name=value"` - MapSfixed32Sfixed32 map[int32]int32 `protobuf:"bytes,64,rep,name=map_sfixed32_sfixed32,json=mapSfixed32Sfixed32" json:"map_sfixed32_sfixed32,omitempty" protobuf_key:"fixed32,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"` - MapSfixed64Sfixed64 map[int64]int64 `protobuf:"bytes,65,rep,name=map_sfixed64_sfixed64,json=mapSfixed64Sfixed64" json:"map_sfixed64_sfixed64,omitempty" protobuf_key:"fixed64,1,opt,name=key" protobuf_val:"fixed64,2,opt,name=value"` - MapInt32Float map[int32]float32 `protobuf:"bytes,66,rep,name=map_int32_float,json=mapInt32Float" json:"map_int32_float,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"` - MapInt32Double map[int32]float64 `protobuf:"bytes,67,rep,name=map_int32_double,json=mapInt32Double" json:"map_int32_double,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"fixed64,2,opt,name=value"` - MapBoolBool map[bool]bool `protobuf:"bytes,68,rep,name=map_bool_bool,json=mapBoolBool" json:"map_bool_bool,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` - MapStringString map[string]string `protobuf:"bytes,69,rep,name=map_string_string,json=mapStringString" json:"map_string_string,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - MapStringBytes map[string][]byte `protobuf:"bytes,70,rep,name=map_string_bytes,json=mapStringBytes" json:"map_string_bytes,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value,proto3"` - MapStringNestedMessage map[string]*TestAllTypes_NestedMessage `protobuf:"bytes,71,rep,name=map_string_nested_message,json=mapStringNestedMessage" json:"map_string_nested_message,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - MapStringForeignMessage map[string]*ForeignMessage `protobuf:"bytes,72,rep,name=map_string_foreign_message,json=mapStringForeignMessage" json:"map_string_foreign_message,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - MapStringNestedEnum map[string]TestAllTypes_NestedEnum `protobuf:"bytes,73,rep,name=map_string_nested_enum,json=mapStringNestedEnum" json:"map_string_nested_enum,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=conformance.TestAllTypes_NestedEnum"` - MapStringForeignEnum map[string]ForeignEnum `protobuf:"bytes,74,rep,name=map_string_foreign_enum,json=mapStringForeignEnum" json:"map_string_foreign_enum,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=conformance.ForeignEnum"` - // Types that are valid to be assigned to OneofField: - // *TestAllTypes_OneofUint32 - // *TestAllTypes_OneofNestedMessage - // *TestAllTypes_OneofString - // *TestAllTypes_OneofBytes - // *TestAllTypes_OneofBool - // *TestAllTypes_OneofUint64 - // *TestAllTypes_OneofFloat - // *TestAllTypes_OneofDouble - // *TestAllTypes_OneofEnum - OneofField isTestAllTypes_OneofField `protobuf_oneof:"oneof_field"` - // Well-known types - OptionalBoolWrapper *google_protobuf5.BoolValue `protobuf:"bytes,201,opt,name=optional_bool_wrapper,json=optionalBoolWrapper" json:"optional_bool_wrapper,omitempty"` - OptionalInt32Wrapper *google_protobuf5.Int32Value `protobuf:"bytes,202,opt,name=optional_int32_wrapper,json=optionalInt32Wrapper" json:"optional_int32_wrapper,omitempty"` - OptionalInt64Wrapper *google_protobuf5.Int64Value `protobuf:"bytes,203,opt,name=optional_int64_wrapper,json=optionalInt64Wrapper" json:"optional_int64_wrapper,omitempty"` - OptionalUint32Wrapper *google_protobuf5.UInt32Value `protobuf:"bytes,204,opt,name=optional_uint32_wrapper,json=optionalUint32Wrapper" json:"optional_uint32_wrapper,omitempty"` - OptionalUint64Wrapper *google_protobuf5.UInt64Value `protobuf:"bytes,205,opt,name=optional_uint64_wrapper,json=optionalUint64Wrapper" json:"optional_uint64_wrapper,omitempty"` - OptionalFloatWrapper *google_protobuf5.FloatValue `protobuf:"bytes,206,opt,name=optional_float_wrapper,json=optionalFloatWrapper" json:"optional_float_wrapper,omitempty"` - OptionalDoubleWrapper *google_protobuf5.DoubleValue `protobuf:"bytes,207,opt,name=optional_double_wrapper,json=optionalDoubleWrapper" json:"optional_double_wrapper,omitempty"` - OptionalStringWrapper *google_protobuf5.StringValue `protobuf:"bytes,208,opt,name=optional_string_wrapper,json=optionalStringWrapper" json:"optional_string_wrapper,omitempty"` - OptionalBytesWrapper *google_protobuf5.BytesValue `protobuf:"bytes,209,opt,name=optional_bytes_wrapper,json=optionalBytesWrapper" json:"optional_bytes_wrapper,omitempty"` - RepeatedBoolWrapper []*google_protobuf5.BoolValue `protobuf:"bytes,211,rep,name=repeated_bool_wrapper,json=repeatedBoolWrapper" json:"repeated_bool_wrapper,omitempty"` - RepeatedInt32Wrapper []*google_protobuf5.Int32Value `protobuf:"bytes,212,rep,name=repeated_int32_wrapper,json=repeatedInt32Wrapper" json:"repeated_int32_wrapper,omitempty"` - RepeatedInt64Wrapper []*google_protobuf5.Int64Value `protobuf:"bytes,213,rep,name=repeated_int64_wrapper,json=repeatedInt64Wrapper" json:"repeated_int64_wrapper,omitempty"` - RepeatedUint32Wrapper []*google_protobuf5.UInt32Value `protobuf:"bytes,214,rep,name=repeated_uint32_wrapper,json=repeatedUint32Wrapper" json:"repeated_uint32_wrapper,omitempty"` - RepeatedUint64Wrapper []*google_protobuf5.UInt64Value `protobuf:"bytes,215,rep,name=repeated_uint64_wrapper,json=repeatedUint64Wrapper" json:"repeated_uint64_wrapper,omitempty"` - RepeatedFloatWrapper []*google_protobuf5.FloatValue `protobuf:"bytes,216,rep,name=repeated_float_wrapper,json=repeatedFloatWrapper" json:"repeated_float_wrapper,omitempty"` - RepeatedDoubleWrapper []*google_protobuf5.DoubleValue `protobuf:"bytes,217,rep,name=repeated_double_wrapper,json=repeatedDoubleWrapper" json:"repeated_double_wrapper,omitempty"` - RepeatedStringWrapper []*google_protobuf5.StringValue `protobuf:"bytes,218,rep,name=repeated_string_wrapper,json=repeatedStringWrapper" json:"repeated_string_wrapper,omitempty"` - RepeatedBytesWrapper []*google_protobuf5.BytesValue `protobuf:"bytes,219,rep,name=repeated_bytes_wrapper,json=repeatedBytesWrapper" json:"repeated_bytes_wrapper,omitempty"` - OptionalDuration *google_protobuf1.Duration `protobuf:"bytes,301,opt,name=optional_duration,json=optionalDuration" json:"optional_duration,omitempty"` - OptionalTimestamp *google_protobuf4.Timestamp `protobuf:"bytes,302,opt,name=optional_timestamp,json=optionalTimestamp" json:"optional_timestamp,omitempty"` - OptionalFieldMask *google_protobuf2.FieldMask `protobuf:"bytes,303,opt,name=optional_field_mask,json=optionalFieldMask" json:"optional_field_mask,omitempty"` - OptionalStruct *google_protobuf3.Struct `protobuf:"bytes,304,opt,name=optional_struct,json=optionalStruct" json:"optional_struct,omitempty"` - OptionalAny *google_protobuf.Any `protobuf:"bytes,305,opt,name=optional_any,json=optionalAny" json:"optional_any,omitempty"` - OptionalValue *google_protobuf3.Value `protobuf:"bytes,306,opt,name=optional_value,json=optionalValue" json:"optional_value,omitempty"` - RepeatedDuration []*google_protobuf1.Duration `protobuf:"bytes,311,rep,name=repeated_duration,json=repeatedDuration" json:"repeated_duration,omitempty"` - RepeatedTimestamp []*google_protobuf4.Timestamp `protobuf:"bytes,312,rep,name=repeated_timestamp,json=repeatedTimestamp" json:"repeated_timestamp,omitempty"` - RepeatedFieldmask []*google_protobuf2.FieldMask `protobuf:"bytes,313,rep,name=repeated_fieldmask,json=repeatedFieldmask" json:"repeated_fieldmask,omitempty"` - RepeatedStruct []*google_protobuf3.Struct `protobuf:"bytes,324,rep,name=repeated_struct,json=repeatedStruct" json:"repeated_struct,omitempty"` - RepeatedAny []*google_protobuf.Any `protobuf:"bytes,315,rep,name=repeated_any,json=repeatedAny" json:"repeated_any,omitempty"` - RepeatedValue []*google_protobuf3.Value `protobuf:"bytes,316,rep,name=repeated_value,json=repeatedValue" json:"repeated_value,omitempty"` - // Test field-name-to-JSON-name convention. - // (protobuf says names can be any valid C/C++ identifier.) - Fieldname1 int32 `protobuf:"varint,401,opt,name=fieldname1" json:"fieldname1,omitempty"` - FieldName2 int32 `protobuf:"varint,402,opt,name=field_name2,json=fieldName2" json:"field_name2,omitempty"` - XFieldName3 int32 `protobuf:"varint,403,opt,name=_field_name3,json=FieldName3" json:"_field_name3,omitempty"` - Field_Name4_ int32 `protobuf:"varint,404,opt,name=field__name4_,json=fieldName4" json:"field__name4_,omitempty"` - Field0Name5 int32 `protobuf:"varint,405,opt,name=field0name5" json:"field0name5,omitempty"` - Field_0Name6 int32 `protobuf:"varint,406,opt,name=field_0_name6,json=field0Name6" json:"field_0_name6,omitempty"` - FieldName7 int32 `protobuf:"varint,407,opt,name=fieldName7" json:"fieldName7,omitempty"` - FieldName8 int32 `protobuf:"varint,408,opt,name=FieldName8" json:"FieldName8,omitempty"` - Field_Name9 int32 `protobuf:"varint,409,opt,name=field_Name9,json=fieldName9" json:"field_Name9,omitempty"` - Field_Name10 int32 `protobuf:"varint,410,opt,name=Field_Name10,json=FieldName10" json:"Field_Name10,omitempty"` - FIELD_NAME11 int32 `protobuf:"varint,411,opt,name=FIELD_NAME11,json=FIELDNAME11" json:"FIELD_NAME11,omitempty"` - FIELDName12 int32 `protobuf:"varint,412,opt,name=FIELD_name12,json=FIELDName12" json:"FIELD_name12,omitempty"` - XFieldName13 int32 `protobuf:"varint,413,opt,name=__field_name13,json=FieldName13" json:"__field_name13,omitempty"` - X_FieldName14 int32 `protobuf:"varint,414,opt,name=__Field_name14,json=FieldName14" json:"__Field_name14,omitempty"` - Field_Name15 int32 `protobuf:"varint,415,opt,name=field__name15,json=fieldName15" json:"field__name15,omitempty"` - Field__Name16 int32 `protobuf:"varint,416,opt,name=field__Name16,json=fieldName16" json:"field__Name16,omitempty"` - FieldName17__ int32 `protobuf:"varint,417,opt,name=field_name17__,json=fieldName17" json:"field_name17__,omitempty"` - FieldName18__ int32 `protobuf:"varint,418,opt,name=Field_name18__,json=FieldName18" json:"Field_name18__,omitempty"` -} - -func (m *TestAllTypes) Reset() { *m = TestAllTypes{} } -func (m *TestAllTypes) String() string { return proto.CompactTextString(m) } -func (*TestAllTypes) ProtoMessage() {} -func (*TestAllTypes) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } - -type isTestAllTypes_OneofField interface { - isTestAllTypes_OneofField() -} - -type TestAllTypes_OneofUint32 struct { - OneofUint32 uint32 `protobuf:"varint,111,opt,name=oneof_uint32,json=oneofUint32,oneof"` -} -type TestAllTypes_OneofNestedMessage struct { - OneofNestedMessage *TestAllTypes_NestedMessage `protobuf:"bytes,112,opt,name=oneof_nested_message,json=oneofNestedMessage,oneof"` -} -type TestAllTypes_OneofString struct { - OneofString string `protobuf:"bytes,113,opt,name=oneof_string,json=oneofString,oneof"` -} -type TestAllTypes_OneofBytes struct { - OneofBytes []byte `protobuf:"bytes,114,opt,name=oneof_bytes,json=oneofBytes,proto3,oneof"` -} -type TestAllTypes_OneofBool struct { - OneofBool bool `protobuf:"varint,115,opt,name=oneof_bool,json=oneofBool,oneof"` -} -type TestAllTypes_OneofUint64 struct { - OneofUint64 uint64 `protobuf:"varint,116,opt,name=oneof_uint64,json=oneofUint64,oneof"` -} -type TestAllTypes_OneofFloat struct { - OneofFloat float32 `protobuf:"fixed32,117,opt,name=oneof_float,json=oneofFloat,oneof"` -} -type TestAllTypes_OneofDouble struct { - OneofDouble float64 `protobuf:"fixed64,118,opt,name=oneof_double,json=oneofDouble,oneof"` -} -type TestAllTypes_OneofEnum struct { - OneofEnum TestAllTypes_NestedEnum `protobuf:"varint,119,opt,name=oneof_enum,json=oneofEnum,enum=conformance.TestAllTypes_NestedEnum,oneof"` -} - -func (*TestAllTypes_OneofUint32) isTestAllTypes_OneofField() {} -func (*TestAllTypes_OneofNestedMessage) isTestAllTypes_OneofField() {} -func (*TestAllTypes_OneofString) isTestAllTypes_OneofField() {} -func (*TestAllTypes_OneofBytes) isTestAllTypes_OneofField() {} -func (*TestAllTypes_OneofBool) isTestAllTypes_OneofField() {} -func (*TestAllTypes_OneofUint64) isTestAllTypes_OneofField() {} -func (*TestAllTypes_OneofFloat) isTestAllTypes_OneofField() {} -func (*TestAllTypes_OneofDouble) isTestAllTypes_OneofField() {} -func (*TestAllTypes_OneofEnum) isTestAllTypes_OneofField() {} - -func (m *TestAllTypes) GetOneofField() isTestAllTypes_OneofField { - if m != nil { - return m.OneofField - } - return nil -} - -func (m *TestAllTypes) GetOptionalInt32() int32 { - if m != nil { - return m.OptionalInt32 - } - return 0 -} - -func (m *TestAllTypes) GetOptionalInt64() int64 { - if m != nil { - return m.OptionalInt64 - } - return 0 -} - -func (m *TestAllTypes) GetOptionalUint32() uint32 { - if m != nil { - return m.OptionalUint32 - } - return 0 -} - -func (m *TestAllTypes) GetOptionalUint64() uint64 { - if m != nil { - return m.OptionalUint64 - } - return 0 -} - -func (m *TestAllTypes) GetOptionalSint32() int32 { - if m != nil { - return m.OptionalSint32 - } - return 0 -} - -func (m *TestAllTypes) GetOptionalSint64() int64 { - if m != nil { - return m.OptionalSint64 - } - return 0 -} - -func (m *TestAllTypes) GetOptionalFixed32() uint32 { - if m != nil { - return m.OptionalFixed32 - } - return 0 -} - -func (m *TestAllTypes) GetOptionalFixed64() uint64 { - if m != nil { - return m.OptionalFixed64 - } - return 0 -} - -func (m *TestAllTypes) GetOptionalSfixed32() int32 { - if m != nil { - return m.OptionalSfixed32 - } - return 0 -} - -func (m *TestAllTypes) GetOptionalSfixed64() int64 { - if m != nil { - return m.OptionalSfixed64 - } - return 0 -} - -func (m *TestAllTypes) GetOptionalFloat() float32 { - if m != nil { - return m.OptionalFloat - } - return 0 -} - -func (m *TestAllTypes) GetOptionalDouble() float64 { - if m != nil { - return m.OptionalDouble - } - return 0 -} - -func (m *TestAllTypes) GetOptionalBool() bool { - if m != nil { - return m.OptionalBool - } - return false -} - -func (m *TestAllTypes) GetOptionalString() string { - if m != nil { - return m.OptionalString - } - return "" -} - -func (m *TestAllTypes) GetOptionalBytes() []byte { - if m != nil { - return m.OptionalBytes - } - return nil -} - -func (m *TestAllTypes) GetOptionalNestedMessage() *TestAllTypes_NestedMessage { - if m != nil { - return m.OptionalNestedMessage - } - return nil -} - -func (m *TestAllTypes) GetOptionalForeignMessage() *ForeignMessage { - if m != nil { - return m.OptionalForeignMessage - } - return nil -} - -func (m *TestAllTypes) GetOptionalNestedEnum() TestAllTypes_NestedEnum { - if m != nil { - return m.OptionalNestedEnum - } - return TestAllTypes_FOO -} - -func (m *TestAllTypes) GetOptionalForeignEnum() ForeignEnum { - if m != nil { - return m.OptionalForeignEnum - } - return ForeignEnum_FOREIGN_FOO -} - -func (m *TestAllTypes) GetOptionalStringPiece() string { - if m != nil { - return m.OptionalStringPiece - } - return "" -} - -func (m *TestAllTypes) GetOptionalCord() string { - if m != nil { - return m.OptionalCord - } - return "" -} - -func (m *TestAllTypes) GetRecursiveMessage() *TestAllTypes { - if m != nil { - return m.RecursiveMessage - } - return nil -} - -func (m *TestAllTypes) GetRepeatedInt32() []int32 { - if m != nil { - return m.RepeatedInt32 - } - return nil -} - -func (m *TestAllTypes) GetRepeatedInt64() []int64 { - if m != nil { - return m.RepeatedInt64 - } - return nil -} - -func (m *TestAllTypes) GetRepeatedUint32() []uint32 { - if m != nil { - return m.RepeatedUint32 - } - return nil -} - -func (m *TestAllTypes) GetRepeatedUint64() []uint64 { - if m != nil { - return m.RepeatedUint64 - } - return nil -} - -func (m *TestAllTypes) GetRepeatedSint32() []int32 { - if m != nil { - return m.RepeatedSint32 - } - return nil -} - -func (m *TestAllTypes) GetRepeatedSint64() []int64 { - if m != nil { - return m.RepeatedSint64 - } - return nil -} - -func (m *TestAllTypes) GetRepeatedFixed32() []uint32 { - if m != nil { - return m.RepeatedFixed32 - } - return nil -} - -func (m *TestAllTypes) GetRepeatedFixed64() []uint64 { - if m != nil { - return m.RepeatedFixed64 - } - return nil -} - -func (m *TestAllTypes) GetRepeatedSfixed32() []int32 { - if m != nil { - return m.RepeatedSfixed32 - } - return nil -} - -func (m *TestAllTypes) GetRepeatedSfixed64() []int64 { - if m != nil { - return m.RepeatedSfixed64 - } - return nil -} - -func (m *TestAllTypes) GetRepeatedFloat() []float32 { - if m != nil { - return m.RepeatedFloat - } - return nil -} - -func (m *TestAllTypes) GetRepeatedDouble() []float64 { - if m != nil { - return m.RepeatedDouble - } - return nil -} - -func (m *TestAllTypes) GetRepeatedBool() []bool { - if m != nil { - return m.RepeatedBool - } - return nil -} - -func (m *TestAllTypes) GetRepeatedString() []string { - if m != nil { - return m.RepeatedString - } - return nil -} - -func (m *TestAllTypes) GetRepeatedBytes() [][]byte { - if m != nil { - return m.RepeatedBytes - } - return nil -} - -func (m *TestAllTypes) GetRepeatedNestedMessage() []*TestAllTypes_NestedMessage { - if m != nil { - return m.RepeatedNestedMessage - } - return nil -} - -func (m *TestAllTypes) GetRepeatedForeignMessage() []*ForeignMessage { - if m != nil { - return m.RepeatedForeignMessage - } - return nil -} - -func (m *TestAllTypes) GetRepeatedNestedEnum() []TestAllTypes_NestedEnum { - if m != nil { - return m.RepeatedNestedEnum - } - return nil -} - -func (m *TestAllTypes) GetRepeatedForeignEnum() []ForeignEnum { - if m != nil { - return m.RepeatedForeignEnum - } - return nil -} - -func (m *TestAllTypes) GetRepeatedStringPiece() []string { - if m != nil { - return m.RepeatedStringPiece - } - return nil -} - -func (m *TestAllTypes) GetRepeatedCord() []string { - if m != nil { - return m.RepeatedCord - } - return nil -} - -func (m *TestAllTypes) GetMapInt32Int32() map[int32]int32 { - if m != nil { - return m.MapInt32Int32 - } - return nil -} - -func (m *TestAllTypes) GetMapInt64Int64() map[int64]int64 { - if m != nil { - return m.MapInt64Int64 - } - return nil -} - -func (m *TestAllTypes) GetMapUint32Uint32() map[uint32]uint32 { - if m != nil { - return m.MapUint32Uint32 - } - return nil -} - -func (m *TestAllTypes) GetMapUint64Uint64() map[uint64]uint64 { - if m != nil { - return m.MapUint64Uint64 - } - return nil -} - -func (m *TestAllTypes) GetMapSint32Sint32() map[int32]int32 { - if m != nil { - return m.MapSint32Sint32 - } - return nil -} - -func (m *TestAllTypes) GetMapSint64Sint64() map[int64]int64 { - if m != nil { - return m.MapSint64Sint64 - } - return nil -} - -func (m *TestAllTypes) GetMapFixed32Fixed32() map[uint32]uint32 { - if m != nil { - return m.MapFixed32Fixed32 - } - return nil -} - -func (m *TestAllTypes) GetMapFixed64Fixed64() map[uint64]uint64 { - if m != nil { - return m.MapFixed64Fixed64 - } - return nil -} - -func (m *TestAllTypes) GetMapSfixed32Sfixed32() map[int32]int32 { - if m != nil { - return m.MapSfixed32Sfixed32 - } - return nil -} - -func (m *TestAllTypes) GetMapSfixed64Sfixed64() map[int64]int64 { - if m != nil { - return m.MapSfixed64Sfixed64 - } - return nil -} - -func (m *TestAllTypes) GetMapInt32Float() map[int32]float32 { - if m != nil { - return m.MapInt32Float - } - return nil -} - -func (m *TestAllTypes) GetMapInt32Double() map[int32]float64 { - if m != nil { - return m.MapInt32Double - } - return nil -} - -func (m *TestAllTypes) GetMapBoolBool() map[bool]bool { - if m != nil { - return m.MapBoolBool - } - return nil -} - -func (m *TestAllTypes) GetMapStringString() map[string]string { - if m != nil { - return m.MapStringString - } - return nil -} - -func (m *TestAllTypes) GetMapStringBytes() map[string][]byte { - if m != nil { - return m.MapStringBytes - } - return nil -} - -func (m *TestAllTypes) GetMapStringNestedMessage() map[string]*TestAllTypes_NestedMessage { - if m != nil { - return m.MapStringNestedMessage - } - return nil -} - -func (m *TestAllTypes) GetMapStringForeignMessage() map[string]*ForeignMessage { - if m != nil { - return m.MapStringForeignMessage - } - return nil -} - -func (m *TestAllTypes) GetMapStringNestedEnum() map[string]TestAllTypes_NestedEnum { - if m != nil { - return m.MapStringNestedEnum - } - return nil -} - -func (m *TestAllTypes) GetMapStringForeignEnum() map[string]ForeignEnum { - if m != nil { - return m.MapStringForeignEnum - } - return nil -} - -func (m *TestAllTypes) GetOneofUint32() uint32 { - if x, ok := m.GetOneofField().(*TestAllTypes_OneofUint32); ok { - return x.OneofUint32 - } - return 0 -} - -func (m *TestAllTypes) GetOneofNestedMessage() *TestAllTypes_NestedMessage { - if x, ok := m.GetOneofField().(*TestAllTypes_OneofNestedMessage); ok { - return x.OneofNestedMessage - } - return nil -} - -func (m *TestAllTypes) GetOneofString() string { - if x, ok := m.GetOneofField().(*TestAllTypes_OneofString); ok { - return x.OneofString - } - return "" -} - -func (m *TestAllTypes) GetOneofBytes() []byte { - if x, ok := m.GetOneofField().(*TestAllTypes_OneofBytes); ok { - return x.OneofBytes - } - return nil -} - -func (m *TestAllTypes) GetOneofBool() bool { - if x, ok := m.GetOneofField().(*TestAllTypes_OneofBool); ok { - return x.OneofBool - } - return false -} - -func (m *TestAllTypes) GetOneofUint64() uint64 { - if x, ok := m.GetOneofField().(*TestAllTypes_OneofUint64); ok { - return x.OneofUint64 - } - return 0 -} - -func (m *TestAllTypes) GetOneofFloat() float32 { - if x, ok := m.GetOneofField().(*TestAllTypes_OneofFloat); ok { - return x.OneofFloat - } - return 0 -} - -func (m *TestAllTypes) GetOneofDouble() float64 { - if x, ok := m.GetOneofField().(*TestAllTypes_OneofDouble); ok { - return x.OneofDouble - } - return 0 -} - -func (m *TestAllTypes) GetOneofEnum() TestAllTypes_NestedEnum { - if x, ok := m.GetOneofField().(*TestAllTypes_OneofEnum); ok { - return x.OneofEnum - } - return TestAllTypes_FOO -} - -func (m *TestAllTypes) GetOptionalBoolWrapper() *google_protobuf5.BoolValue { - if m != nil { - return m.OptionalBoolWrapper - } - return nil -} - -func (m *TestAllTypes) GetOptionalInt32Wrapper() *google_protobuf5.Int32Value { - if m != nil { - return m.OptionalInt32Wrapper - } - return nil -} - -func (m *TestAllTypes) GetOptionalInt64Wrapper() *google_protobuf5.Int64Value { - if m != nil { - return m.OptionalInt64Wrapper - } - return nil -} - -func (m *TestAllTypes) GetOptionalUint32Wrapper() *google_protobuf5.UInt32Value { - if m != nil { - return m.OptionalUint32Wrapper - } - return nil -} - -func (m *TestAllTypes) GetOptionalUint64Wrapper() *google_protobuf5.UInt64Value { - if m != nil { - return m.OptionalUint64Wrapper - } - return nil -} - -func (m *TestAllTypes) GetOptionalFloatWrapper() *google_protobuf5.FloatValue { - if m != nil { - return m.OptionalFloatWrapper - } - return nil -} - -func (m *TestAllTypes) GetOptionalDoubleWrapper() *google_protobuf5.DoubleValue { - if m != nil { - return m.OptionalDoubleWrapper - } - return nil -} - -func (m *TestAllTypes) GetOptionalStringWrapper() *google_protobuf5.StringValue { - if m != nil { - return m.OptionalStringWrapper - } - return nil -} - -func (m *TestAllTypes) GetOptionalBytesWrapper() *google_protobuf5.BytesValue { - if m != nil { - return m.OptionalBytesWrapper - } - return nil -} - -func (m *TestAllTypes) GetRepeatedBoolWrapper() []*google_protobuf5.BoolValue { - if m != nil { - return m.RepeatedBoolWrapper - } - return nil -} - -func (m *TestAllTypes) GetRepeatedInt32Wrapper() []*google_protobuf5.Int32Value { - if m != nil { - return m.RepeatedInt32Wrapper - } - return nil -} - -func (m *TestAllTypes) GetRepeatedInt64Wrapper() []*google_protobuf5.Int64Value { - if m != nil { - return m.RepeatedInt64Wrapper - } - return nil -} - -func (m *TestAllTypes) GetRepeatedUint32Wrapper() []*google_protobuf5.UInt32Value { - if m != nil { - return m.RepeatedUint32Wrapper - } - return nil -} - -func (m *TestAllTypes) GetRepeatedUint64Wrapper() []*google_protobuf5.UInt64Value { - if m != nil { - return m.RepeatedUint64Wrapper - } - return nil -} - -func (m *TestAllTypes) GetRepeatedFloatWrapper() []*google_protobuf5.FloatValue { - if m != nil { - return m.RepeatedFloatWrapper - } - return nil -} - -func (m *TestAllTypes) GetRepeatedDoubleWrapper() []*google_protobuf5.DoubleValue { - if m != nil { - return m.RepeatedDoubleWrapper - } - return nil -} - -func (m *TestAllTypes) GetRepeatedStringWrapper() []*google_protobuf5.StringValue { - if m != nil { - return m.RepeatedStringWrapper - } - return nil -} - -func (m *TestAllTypes) GetRepeatedBytesWrapper() []*google_protobuf5.BytesValue { - if m != nil { - return m.RepeatedBytesWrapper - } - return nil -} - -func (m *TestAllTypes) GetOptionalDuration() *google_protobuf1.Duration { - if m != nil { - return m.OptionalDuration - } - return nil -} - -func (m *TestAllTypes) GetOptionalTimestamp() *google_protobuf4.Timestamp { - if m != nil { - return m.OptionalTimestamp - } - return nil -} - -func (m *TestAllTypes) GetOptionalFieldMask() *google_protobuf2.FieldMask { - if m != nil { - return m.OptionalFieldMask - } - return nil -} - -func (m *TestAllTypes) GetOptionalStruct() *google_protobuf3.Struct { - if m != nil { - return m.OptionalStruct - } - return nil -} - -func (m *TestAllTypes) GetOptionalAny() *google_protobuf.Any { - if m != nil { - return m.OptionalAny - } - return nil -} - -func (m *TestAllTypes) GetOptionalValue() *google_protobuf3.Value { - if m != nil { - return m.OptionalValue - } - return nil -} - -func (m *TestAllTypes) GetRepeatedDuration() []*google_protobuf1.Duration { - if m != nil { - return m.RepeatedDuration - } - return nil -} - -func (m *TestAllTypes) GetRepeatedTimestamp() []*google_protobuf4.Timestamp { - if m != nil { - return m.RepeatedTimestamp - } - return nil -} - -func (m *TestAllTypes) GetRepeatedFieldmask() []*google_protobuf2.FieldMask { - if m != nil { - return m.RepeatedFieldmask - } - return nil -} - -func (m *TestAllTypes) GetRepeatedStruct() []*google_protobuf3.Struct { - if m != nil { - return m.RepeatedStruct - } - return nil -} - -func (m *TestAllTypes) GetRepeatedAny() []*google_protobuf.Any { - if m != nil { - return m.RepeatedAny - } - return nil -} - -func (m *TestAllTypes) GetRepeatedValue() []*google_protobuf3.Value { - if m != nil { - return m.RepeatedValue - } - return nil -} - -func (m *TestAllTypes) GetFieldname1() int32 { - if m != nil { - return m.Fieldname1 - } - return 0 -} - -func (m *TestAllTypes) GetFieldName2() int32 { - if m != nil { - return m.FieldName2 - } - return 0 -} - -func (m *TestAllTypes) GetXFieldName3() int32 { - if m != nil { - return m.XFieldName3 - } - return 0 -} - -func (m *TestAllTypes) GetField_Name4_() int32 { - if m != nil { - return m.Field_Name4_ - } - return 0 -} - -func (m *TestAllTypes) GetField0Name5() int32 { - if m != nil { - return m.Field0Name5 - } - return 0 -} - -func (m *TestAllTypes) GetField_0Name6() int32 { - if m != nil { - return m.Field_0Name6 - } - return 0 -} - -func (m *TestAllTypes) GetFieldName7() int32 { - if m != nil { - return m.FieldName7 - } - return 0 -} - -func (m *TestAllTypes) GetFieldName8() int32 { - if m != nil { - return m.FieldName8 - } - return 0 -} - -func (m *TestAllTypes) GetField_Name9() int32 { - if m != nil { - return m.Field_Name9 - } - return 0 -} - -func (m *TestAllTypes) GetField_Name10() int32 { - if m != nil { - return m.Field_Name10 - } - return 0 -} - -func (m *TestAllTypes) GetFIELD_NAME11() int32 { - if m != nil { - return m.FIELD_NAME11 - } - return 0 -} - -func (m *TestAllTypes) GetFIELDName12() int32 { - if m != nil { - return m.FIELDName12 - } - return 0 -} - -func (m *TestAllTypes) GetXFieldName13() int32 { - if m != nil { - return m.XFieldName13 - } - return 0 -} - -func (m *TestAllTypes) GetX_FieldName14() int32 { - if m != nil { - return m.X_FieldName14 - } - return 0 -} - -func (m *TestAllTypes) GetField_Name15() int32 { - if m != nil { - return m.Field_Name15 - } - return 0 -} - -func (m *TestAllTypes) GetField__Name16() int32 { - if m != nil { - return m.Field__Name16 - } - return 0 -} - -func (m *TestAllTypes) GetFieldName17__() int32 { - if m != nil { - return m.FieldName17__ - } - return 0 -} - -func (m *TestAllTypes) GetFieldName18__() int32 { - if m != nil { - return m.FieldName18__ - } - return 0 -} - -// XXX_OneofFuncs is for the internal use of the proto package. -func (*TestAllTypes) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _TestAllTypes_OneofMarshaler, _TestAllTypes_OneofUnmarshaler, _TestAllTypes_OneofSizer, []interface{}{ - (*TestAllTypes_OneofUint32)(nil), - (*TestAllTypes_OneofNestedMessage)(nil), - (*TestAllTypes_OneofString)(nil), - (*TestAllTypes_OneofBytes)(nil), - (*TestAllTypes_OneofBool)(nil), - (*TestAllTypes_OneofUint64)(nil), - (*TestAllTypes_OneofFloat)(nil), - (*TestAllTypes_OneofDouble)(nil), - (*TestAllTypes_OneofEnum)(nil), - } -} - -func _TestAllTypes_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*TestAllTypes) - // oneof_field - switch x := m.OneofField.(type) { - case *TestAllTypes_OneofUint32: - b.EncodeVarint(111<<3 | proto.WireVarint) - b.EncodeVarint(uint64(x.OneofUint32)) - case *TestAllTypes_OneofNestedMessage: - b.EncodeVarint(112<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.OneofNestedMessage); err != nil { - return err - } - case *TestAllTypes_OneofString: - b.EncodeVarint(113<<3 | proto.WireBytes) - b.EncodeStringBytes(x.OneofString) - case *TestAllTypes_OneofBytes: - b.EncodeVarint(114<<3 | proto.WireBytes) - b.EncodeRawBytes(x.OneofBytes) - case *TestAllTypes_OneofBool: - t := uint64(0) - if x.OneofBool { - t = 1 - } - b.EncodeVarint(115<<3 | proto.WireVarint) - b.EncodeVarint(t) - case *TestAllTypes_OneofUint64: - b.EncodeVarint(116<<3 | proto.WireVarint) - b.EncodeVarint(uint64(x.OneofUint64)) - case *TestAllTypes_OneofFloat: - b.EncodeVarint(117<<3 | proto.WireFixed32) - b.EncodeFixed32(uint64(math.Float32bits(x.OneofFloat))) - case *TestAllTypes_OneofDouble: - b.EncodeVarint(118<<3 | proto.WireFixed64) - b.EncodeFixed64(math.Float64bits(x.OneofDouble)) - case *TestAllTypes_OneofEnum: - b.EncodeVarint(119<<3 | proto.WireVarint) - b.EncodeVarint(uint64(x.OneofEnum)) - case nil: - default: - return fmt.Errorf("TestAllTypes.OneofField has unexpected type %T", x) - } - return nil -} - -func _TestAllTypes_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*TestAllTypes) - switch tag { - case 111: // oneof_field.oneof_uint32 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.OneofField = &TestAllTypes_OneofUint32{uint32(x)} - return true, err - case 112: // oneof_field.oneof_nested_message - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(TestAllTypes_NestedMessage) - err := b.DecodeMessage(msg) - m.OneofField = &TestAllTypes_OneofNestedMessage{msg} - return true, err - case 113: // oneof_field.oneof_string - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.OneofField = &TestAllTypes_OneofString{x} - return true, err - case 114: // oneof_field.oneof_bytes - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeRawBytes(true) - m.OneofField = &TestAllTypes_OneofBytes{x} - return true, err - case 115: // oneof_field.oneof_bool - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.OneofField = &TestAllTypes_OneofBool{x != 0} - return true, err - case 116: // oneof_field.oneof_uint64 - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.OneofField = &TestAllTypes_OneofUint64{x} - return true, err - case 117: // oneof_field.oneof_float - if wire != proto.WireFixed32 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed32() - m.OneofField = &TestAllTypes_OneofFloat{math.Float32frombits(uint32(x))} - return true, err - case 118: // oneof_field.oneof_double - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.OneofField = &TestAllTypes_OneofDouble{math.Float64frombits(x)} - return true, err - case 119: // oneof_field.oneof_enum - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.OneofField = &TestAllTypes_OneofEnum{TestAllTypes_NestedEnum(x)} - return true, err - default: - return false, nil - } -} - -func _TestAllTypes_OneofSizer(msg proto.Message) (n int) { - m := msg.(*TestAllTypes) - // oneof_field - switch x := m.OneofField.(type) { - case *TestAllTypes_OneofUint32: - n += proto.SizeVarint(111<<3 | proto.WireVarint) - n += proto.SizeVarint(uint64(x.OneofUint32)) - case *TestAllTypes_OneofNestedMessage: - s := proto.Size(x.OneofNestedMessage) - n += proto.SizeVarint(112<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(s)) - n += s - case *TestAllTypes_OneofString: - n += proto.SizeVarint(113<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.OneofString))) - n += len(x.OneofString) - case *TestAllTypes_OneofBytes: - n += proto.SizeVarint(114<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.OneofBytes))) - n += len(x.OneofBytes) - case *TestAllTypes_OneofBool: - n += proto.SizeVarint(115<<3 | proto.WireVarint) - n += 1 - case *TestAllTypes_OneofUint64: - n += proto.SizeVarint(116<<3 | proto.WireVarint) - n += proto.SizeVarint(uint64(x.OneofUint64)) - case *TestAllTypes_OneofFloat: - n += proto.SizeVarint(117<<3 | proto.WireFixed32) - n += 4 - case *TestAllTypes_OneofDouble: - n += proto.SizeVarint(118<<3 | proto.WireFixed64) - n += 8 - case *TestAllTypes_OneofEnum: - n += proto.SizeVarint(119<<3 | proto.WireVarint) - n += proto.SizeVarint(uint64(x.OneofEnum)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - -type TestAllTypes_NestedMessage struct { - A int32 `protobuf:"varint,1,opt,name=a" json:"a,omitempty"` - Corecursive *TestAllTypes `protobuf:"bytes,2,opt,name=corecursive" json:"corecursive,omitempty"` -} - -func (m *TestAllTypes_NestedMessage) Reset() { *m = TestAllTypes_NestedMessage{} } -func (m *TestAllTypes_NestedMessage) String() string { return proto.CompactTextString(m) } -func (*TestAllTypes_NestedMessage) ProtoMessage() {} -func (*TestAllTypes_NestedMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2, 0} } - -func (m *TestAllTypes_NestedMessage) GetA() int32 { - if m != nil { - return m.A - } - return 0 -} - -func (m *TestAllTypes_NestedMessage) GetCorecursive() *TestAllTypes { - if m != nil { - return m.Corecursive - } - return nil -} - -type ForeignMessage struct { - C int32 `protobuf:"varint,1,opt,name=c" json:"c,omitempty"` -} - -func (m *ForeignMessage) Reset() { *m = ForeignMessage{} } -func (m *ForeignMessage) String() string { return proto.CompactTextString(m) } -func (*ForeignMessage) ProtoMessage() {} -func (*ForeignMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } - -func (m *ForeignMessage) GetC() int32 { - if m != nil { - return m.C - } - return 0 -} - -func init() { - proto.RegisterType((*ConformanceRequest)(nil), "conformance.ConformanceRequest") - proto.RegisterType((*ConformanceResponse)(nil), "conformance.ConformanceResponse") - proto.RegisterType((*TestAllTypes)(nil), "conformance.TestAllTypes") - proto.RegisterType((*TestAllTypes_NestedMessage)(nil), "conformance.TestAllTypes.NestedMessage") - proto.RegisterType((*ForeignMessage)(nil), "conformance.ForeignMessage") - proto.RegisterEnum("conformance.WireFormat", WireFormat_name, WireFormat_value) - proto.RegisterEnum("conformance.ForeignEnum", ForeignEnum_name, ForeignEnum_value) - proto.RegisterEnum("conformance.TestAllTypes_NestedEnum", TestAllTypes_NestedEnum_name, TestAllTypes_NestedEnum_value) -} - -func init() { proto.RegisterFile("conformance_proto/conformance.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 2737 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x5a, 0xd9, 0x72, 0xdb, 0xc8, - 0xd5, 0x16, 0x08, 0x59, 0x4b, 0x93, 0x92, 0xa8, 0xd6, 0xd6, 0x96, 0x5d, 0x63, 0x58, 0xb2, 0x7f, - 0xd3, 0xf6, 0x8c, 0xac, 0x05, 0x86, 0x65, 0xcf, 0x3f, 0x8e, 0x45, 0x9b, 0xb4, 0xe4, 0x8c, 0x25, - 0x17, 0x64, 0x8d, 0xab, 0x9c, 0x0b, 0x06, 0xa6, 0x20, 0x15, 0xc7, 0x24, 0xc1, 0x01, 0x48, 0x4f, - 0x94, 0xcb, 0xbc, 0x41, 0xf6, 0x7d, 0xbd, 0xcf, 0x7a, 0x93, 0xa4, 0x92, 0xab, 0x54, 0x6e, 0xb2, - 0x27, 0x95, 0x3d, 0x79, 0x85, 0xbc, 0x43, 0x52, 0xbd, 0xa2, 0xbb, 0x01, 0x50, 0xf4, 0x54, 0x0d, - 0x25, 0x1e, 0x7c, 0xfd, 0x9d, 0xd3, 0xe7, 0x1c, 0x7c, 0x2d, 0x1c, 0x18, 0x2c, 0xd7, 0x83, 0xf6, - 0x51, 0x10, 0xb6, 0xbc, 0x76, 0xdd, 0xaf, 0x75, 0xc2, 0xa0, 0x1b, 0xdc, 0x90, 0x2c, 0x2b, 0xc4, - 0x02, 0xf3, 0x92, 0x69, 0xf1, 0xec, 0x71, 0x10, 0x1c, 0x37, 0xfd, 0x1b, 0xe4, 0xd2, 0x8b, 0xde, - 0xd1, 0x0d, 0xaf, 0x7d, 0x42, 0x71, 0x8b, 0x6f, 0xe8, 0x97, 0x0e, 0x7b, 0xa1, 0xd7, 0x6d, 0x04, - 0x6d, 0x76, 0xdd, 0xd2, 0xaf, 0x1f, 0x35, 0xfc, 0xe6, 0x61, 0xad, 0xe5, 0x45, 0x2f, 0x19, 0xe2, - 0xbc, 0x8e, 0x88, 0xba, 0x61, 0xaf, 0xde, 0x65, 0x57, 0x2f, 0xe8, 0x57, 0xbb, 0x8d, 0x96, 0x1f, - 0x75, 0xbd, 0x56, 0x27, 0x2b, 0x80, 0x0f, 0x43, 0xaf, 0xd3, 0xf1, 0xc3, 0x88, 0x5e, 0x5f, 0xfa, - 0x85, 0x01, 0xe0, 0xfd, 0x78, 0x2f, 0xae, 0xff, 0x41, 0xcf, 0x8f, 0xba, 0xf0, 0x3a, 0x28, 0xf2, - 0x15, 0xb5, 0x8e, 0x77, 0xd2, 0x0c, 0xbc, 0x43, 0x64, 0x58, 0x46, 0xa9, 0xb0, 0x3d, 0xe4, 0x4e, - 0xf1, 0x2b, 0x4f, 0xe8, 0x05, 0xb8, 0x0c, 0x0a, 0xef, 0x47, 0x41, 0x5b, 0x00, 0x73, 0x96, 0x51, - 0x1a, 0xdf, 0x1e, 0x72, 0xf3, 0xd8, 0xca, 0x41, 0x7b, 0x60, 0x21, 0xa4, 0xe4, 0xfe, 0x61, 0x2d, - 0xe8, 0x75, 0x3b, 0xbd, 0x6e, 0x8d, 0x78, 0xed, 0x22, 0xd3, 0x32, 0x4a, 0x93, 0xeb, 0x0b, 0x2b, - 0x72, 0x9a, 0x9f, 0x35, 0x42, 0xbf, 0x4a, 0x2e, 0xbb, 0x73, 0x62, 0xdd, 0x1e, 0x59, 0x46, 0xcd, - 0xe5, 0x71, 0x30, 0xca, 0x1c, 0x2e, 0x7d, 0x2a, 0x07, 0x66, 0x94, 0x4d, 0x44, 0x9d, 0xa0, 0x1d, - 0xf9, 0xf0, 0x22, 0xc8, 0x77, 0xbc, 0x30, 0xf2, 0x6b, 0x7e, 0x18, 0x06, 0x21, 0xd9, 0x00, 0x8e, - 0x0b, 0x10, 0x63, 0x05, 0xdb, 0xe0, 0x55, 0x30, 0x15, 0xf9, 0x61, 0xc3, 0x6b, 0x36, 0x3e, 0xc9, - 0x61, 0x23, 0x0c, 0x36, 0x29, 0x2e, 0x50, 0xe8, 0x65, 0x30, 0x11, 0xf6, 0xda, 0x38, 0xc1, 0x0c, - 0xc8, 0xf7, 0x59, 0x60, 0x66, 0x0a, 0x4b, 0x4b, 0x9d, 0x39, 0x68, 0xea, 0x86, 0xd3, 0x52, 0xb7, - 0x08, 0x46, 0xa3, 0x97, 0x8d, 0x4e, 0xc7, 0x3f, 0x44, 0x67, 0xd8, 0x75, 0x6e, 0x28, 0x8f, 0x81, - 0x91, 0xd0, 0x8f, 0x7a, 0xcd, 0xee, 0xd2, 0x7f, 0xaa, 0xa0, 0xf0, 0xd4, 0x8f, 0xba, 0x5b, 0xcd, - 0xe6, 0xd3, 0x93, 0x8e, 0x1f, 0xc1, 0xcb, 0x60, 0x32, 0xe8, 0xe0, 0x5e, 0xf3, 0x9a, 0xb5, 0x46, - 0xbb, 0xbb, 0xb1, 0x4e, 0x12, 0x70, 0xc6, 0x9d, 0xe0, 0xd6, 0x1d, 0x6c, 0xd4, 0x61, 0x8e, 0x4d, - 0xf6, 0x65, 0x2a, 0x30, 0xc7, 0x86, 0x57, 0xc0, 0x94, 0x80, 0xf5, 0x28, 0x1d, 0xde, 0xd5, 0x84, - 0x2b, 0x56, 0x1f, 0x10, 0x6b, 0x02, 0xe8, 0xd8, 0x64, 0x57, 0xc3, 0x2a, 0x50, 0x63, 0x8c, 0x28, - 0x23, 0xde, 0xde, 0x74, 0x0c, 0xdc, 0x4f, 0x32, 0x46, 0x94, 0x11, 0xd7, 0x08, 0xaa, 0x40, 0xc7, - 0x86, 0x57, 0x41, 0x51, 0x00, 0x8f, 0x1a, 0x9f, 0xf0, 0x0f, 0x37, 0xd6, 0xd1, 0xa8, 0x65, 0x94, - 0x46, 0x5d, 0x41, 0x50, 0xa5, 0xe6, 0x24, 0xd4, 0xb1, 0xd1, 0x98, 0x65, 0x94, 0x46, 0x34, 0xa8, - 0x63, 0xc3, 0xeb, 0x60, 0x3a, 0x76, 0xcf, 0x69, 0xc7, 0x2d, 0xa3, 0x34, 0xe5, 0x0a, 0x8e, 0x7d, - 0x66, 0x4f, 0x01, 0x3b, 0x36, 0x02, 0x96, 0x51, 0x2a, 0xea, 0x60, 0xc7, 0x56, 0x52, 0x7f, 0xd4, - 0x0c, 0xbc, 0x2e, 0xca, 0x5b, 0x46, 0x29, 0x17, 0xa7, 0xbe, 0x8a, 0x8d, 0xca, 0xfe, 0x0f, 0x83, - 0xde, 0x8b, 0xa6, 0x8f, 0x0a, 0x96, 0x51, 0x32, 0xe2, 0xfd, 0x3f, 0x20, 0x56, 0xb8, 0x0c, 0xc4, - 0xca, 0xda, 0x8b, 0x20, 0x68, 0xa2, 0x09, 0xcb, 0x28, 0x8d, 0xb9, 0x05, 0x6e, 0x2c, 0x07, 0x41, - 0x53, 0xcd, 0x66, 0x37, 0x6c, 0xb4, 0x8f, 0xd1, 0x24, 0xee, 0x2a, 0x29, 0x9b, 0xc4, 0xaa, 0x44, - 0xf7, 0xe2, 0xa4, 0xeb, 0x47, 0x68, 0x0a, 0xb7, 0x71, 0x1c, 0x5d, 0x19, 0x1b, 0x61, 0x0d, 0x2c, - 0x08, 0x58, 0x9b, 0xde, 0xde, 0x2d, 0x3f, 0x8a, 0xbc, 0x63, 0x1f, 0x41, 0xcb, 0x28, 0xe5, 0xd7, - 0xaf, 0x28, 0x37, 0xb6, 0xdc, 0xa2, 0x2b, 0xbb, 0x04, 0xff, 0x98, 0xc2, 0xdd, 0x39, 0xce, 0xa3, - 0x98, 0xe1, 0x01, 0x40, 0x71, 0x96, 0x82, 0xd0, 0x6f, 0x1c, 0xb7, 0x85, 0x87, 0x19, 0xe2, 0xe1, - 0x9c, 0xe2, 0xa1, 0x4a, 0x31, 0x9c, 0x75, 0x5e, 0x24, 0x53, 0xb1, 0xc3, 0xf7, 0xc0, 0xac, 0x1e, - 0xb7, 0xdf, 0xee, 0xb5, 0xd0, 0x1c, 0x51, 0xa3, 0x4b, 0xa7, 0x05, 0x5d, 0x69, 0xf7, 0x5a, 0x2e, - 0x54, 0x23, 0xc6, 0x36, 0xf8, 0x2e, 0x98, 0x4b, 0x84, 0x4b, 0x88, 0xe7, 0x09, 0x31, 0x4a, 0x8b, - 0x95, 0x90, 0xcd, 0x68, 0x81, 0x12, 0x36, 0x47, 0x62, 0xa3, 0xd5, 0xaa, 0x75, 0x1a, 0x7e, 0xdd, - 0x47, 0x08, 0xd7, 0xac, 0x9c, 0x1b, 0xcb, 0xc5, 0xeb, 0x68, 0xdd, 0x9e, 0xe0, 0xcb, 0xf0, 0x8a, - 0xd4, 0x0a, 0xf5, 0x20, 0x3c, 0x44, 0x67, 0x19, 0xde, 0x88, 0xdb, 0xe1, 0x7e, 0x10, 0x1e, 0xc2, - 0x2a, 0x98, 0x0e, 0xfd, 0x7a, 0x2f, 0x8c, 0x1a, 0xaf, 0x7c, 0x91, 0xd6, 0x73, 0x24, 0xad, 0x67, - 0x33, 0x73, 0xe0, 0x16, 0xc5, 0x1a, 0x9e, 0xce, 0xcb, 0x60, 0x32, 0xf4, 0x3b, 0xbe, 0x87, 0xf3, - 0x48, 0x6f, 0xe6, 0x0b, 0x96, 0x89, 0xd5, 0x86, 0x5b, 0x85, 0xda, 0xc8, 0x30, 0xc7, 0x46, 0x96, - 0x65, 0x62, 0xb5, 0x91, 0x60, 0x54, 0x1b, 0x04, 0x8c, 0xa9, 0xcd, 0x45, 0xcb, 0xc4, 0x6a, 0xc3, - 0xcd, 0xb1, 0xda, 0x28, 0x40, 0xc7, 0x46, 0x4b, 0x96, 0x89, 0xd5, 0x46, 0x06, 0x6a, 0x8c, 0x4c, - 0x6d, 0x96, 0x2d, 0x13, 0xab, 0x0d, 0x37, 0xef, 0x27, 0x19, 0x99, 0xda, 0x5c, 0xb2, 0x4c, 0xac, - 0x36, 0x32, 0x90, 0xaa, 0x8d, 0x00, 0x72, 0x59, 0xb8, 0x6c, 0x99, 0x58, 0x6d, 0xb8, 0x5d, 0x52, - 0x1b, 0x15, 0xea, 0xd8, 0xe8, 0xff, 0x2c, 0x13, 0xab, 0x8d, 0x02, 0xa5, 0x6a, 0x13, 0xbb, 0xe7, - 0xb4, 0x57, 0x2c, 0x13, 0xab, 0x8d, 0x08, 0x40, 0x52, 0x1b, 0x0d, 0xec, 0xd8, 0xa8, 0x64, 0x99, - 0x58, 0x6d, 0x54, 0x30, 0x55, 0x9b, 0x38, 0x08, 0xa2, 0x36, 0x57, 0x2d, 0x13, 0xab, 0x8d, 0x08, - 0x81, 0xab, 0x8d, 0x80, 0x31, 0xb5, 0xb9, 0x66, 0x99, 0x58, 0x6d, 0xb8, 0x39, 0x56, 0x1b, 0x01, - 0x24, 0x6a, 0x73, 0xdd, 0x32, 0xb1, 0xda, 0x70, 0x23, 0x57, 0x9b, 0x38, 0x42, 0xaa, 0x36, 0x6f, - 0x5a, 0x26, 0x56, 0x1b, 0x11, 0x9f, 0x50, 0x9b, 0x98, 0x8d, 0xa8, 0xcd, 0x5b, 0x96, 0x89, 0xd5, - 0x46, 0xd0, 0x71, 0xb5, 0x11, 0x30, 0x4d, 0x6d, 0x56, 0x2d, 0xf3, 0xb5, 0xd4, 0x86, 0xf3, 0x24, - 0xd4, 0x26, 0xce, 0x92, 0xa6, 0x36, 0x6b, 0xc4, 0x43, 0x7f, 0xb5, 0x11, 0xc9, 0x4c, 0xa8, 0x8d, - 0x1e, 0x37, 0x11, 0x85, 0x0d, 0xcb, 0x1c, 0x5c, 0x6d, 0xd4, 0x88, 0xb9, 0xda, 0x24, 0xc2, 0x25, - 0xc4, 0x36, 0x21, 0xee, 0xa3, 0x36, 0x5a, 0xa0, 0x5c, 0x6d, 0xb4, 0x6a, 0x31, 0xb5, 0x71, 0x70, - 0xcd, 0xa8, 0xda, 0xa8, 0x75, 0x13, 0x6a, 0x23, 0xd6, 0x11, 0xb5, 0xb9, 0xc5, 0xf0, 0x46, 0xdc, - 0x0e, 0x44, 0x6d, 0x9e, 0x82, 0xa9, 0x96, 0xd7, 0xa1, 0x02, 0xc1, 0x64, 0x62, 0x93, 0x24, 0xf5, - 0xcd, 0xec, 0x0c, 0x3c, 0xf6, 0x3a, 0x44, 0x3b, 0xc8, 0x47, 0xa5, 0xdd, 0x0d, 0x4f, 0xdc, 0x89, - 0x96, 0x6c, 0x93, 0x58, 0x1d, 0x9b, 0xa9, 0xca, 0xed, 0xc1, 0x58, 0x1d, 0x9b, 0x7c, 0x28, 0xac, - 0xcc, 0x06, 0x9f, 0x83, 0x69, 0xcc, 0x4a, 0xe5, 0x87, 0xab, 0xd0, 0x1d, 0xc2, 0xbb, 0xd2, 0x97, - 0x97, 0x4a, 0x13, 0xfd, 0xa4, 0xcc, 0x38, 0x3c, 0xd9, 0x2a, 0x73, 0x3b, 0x36, 0x17, 0xae, 0xb7, - 0x07, 0xe4, 0x76, 0x6c, 0xfa, 0xa9, 0x72, 0x73, 0x2b, 0xe7, 0xa6, 0x22, 0xc7, 0xb5, 0xee, 0xff, - 0x07, 0xe0, 0xa6, 0x02, 0xb8, 0xaf, 0xc5, 0x2d, 0x5b, 0x65, 0x6e, 0xc7, 0xe6, 0xf2, 0xf8, 0xce, - 0x80, 0xdc, 0x8e, 0xbd, 0xaf, 0xc5, 0x2d, 0x5b, 0xe1, 0xc7, 0xc1, 0x0c, 0xe6, 0x66, 0xda, 0x26, - 0x24, 0xf5, 0x2e, 0x61, 0x5f, 0xed, 0xcb, 0xce, 0x74, 0x96, 0xfd, 0xa0, 0xfc, 0x38, 0x50, 0xd5, - 0xae, 0x78, 0x70, 0x6c, 0xa1, 0xc4, 0x1f, 0x19, 0xd4, 0x83, 0x63, 0xb3, 0x1f, 0x9a, 0x07, 0x61, - 0x87, 0x47, 0x60, 0x8e, 0xe4, 0x87, 0x6f, 0x42, 0x28, 0xf8, 0x3d, 0xe2, 0x63, 0xbd, 0x7f, 0x8e, - 0x18, 0x98, 0xff, 0xa4, 0x5e, 0x70, 0xc8, 0xfa, 0x15, 0xd5, 0x0f, 0xae, 0x04, 0xdf, 0xcb, 0xd6, - 0xc0, 0x7e, 0x1c, 0x9b, 0xff, 0xd4, 0xfd, 0xc4, 0x57, 0xd4, 0xfb, 0x95, 0x1e, 0x1a, 0xe5, 0x41, - 0xef, 0x57, 0x72, 0x9c, 0x68, 0xf7, 0x2b, 0x3d, 0x62, 0x9e, 0x81, 0x62, 0xcc, 0xca, 0xce, 0x98, - 0xfb, 0x84, 0xf6, 0xad, 0xd3, 0x69, 0xe9, 0xe9, 0x43, 0x79, 0x27, 0x5b, 0x8a, 0x11, 0xee, 0x02, - 0xec, 0x89, 0x9c, 0x46, 0xf4, 0x48, 0x7a, 0x40, 0x58, 0xaf, 0xf5, 0x65, 0xc5, 0xe7, 0x14, 0xfe, - 0x9f, 0x52, 0xe6, 0x5b, 0xb1, 0x45, 0xb4, 0x3b, 0x95, 0x42, 0x76, 0x7e, 0x55, 0x06, 0x69, 0x77, - 0x02, 0xa5, 0x9f, 0x52, 0xbb, 0x4b, 0x56, 0x9e, 0x04, 0xc6, 0x4d, 0x8f, 0xbc, 0xea, 0x00, 0x49, - 0xa0, 0xcb, 0xc9, 0x69, 0x18, 0x27, 0x41, 0x32, 0xc2, 0x0e, 0x38, 0x2b, 0x11, 0x6b, 0x87, 0xe4, - 0x43, 0xe2, 0xe1, 0xe6, 0x00, 0x1e, 0x94, 0x63, 0x91, 0x7a, 0x9a, 0x6f, 0xa5, 0x5e, 0x84, 0x11, - 0x58, 0x94, 0x3c, 0xea, 0xa7, 0xe6, 0x36, 0x71, 0xe9, 0x0c, 0xe0, 0x52, 0x3d, 0x33, 0xa9, 0xcf, - 0x85, 0x56, 0xfa, 0x55, 0x78, 0x0c, 0xe6, 0x93, 0xdb, 0x24, 0x47, 0xdf, 0xce, 0x20, 0xf7, 0x80, - 0xb4, 0x0d, 0x7c, 0xf4, 0x49, 0xf7, 0x80, 0x76, 0x05, 0xbe, 0x0f, 0x16, 0x52, 0x76, 0x47, 0x3c, - 0x3d, 0x22, 0x9e, 0x36, 0x06, 0xdf, 0x5a, 0xec, 0x6a, 0xb6, 0x95, 0x72, 0x09, 0x2e, 0x83, 0x42, - 0xd0, 0xf6, 0x83, 0x23, 0x7e, 0xdc, 0x04, 0xf8, 0x11, 0x7b, 0x7b, 0xc8, 0xcd, 0x13, 0x2b, 0x3b, - 0x3c, 0x3e, 0x06, 0x66, 0x29, 0x48, 0xab, 0x6d, 0xe7, 0xb5, 0x1e, 0xb7, 0xb6, 0x87, 0x5c, 0x48, - 0x68, 0xd4, 0x5a, 0x8a, 0x08, 0x58, 0xb7, 0x7f, 0xc0, 0x27, 0x12, 0xc4, 0xca, 0x7a, 0xf7, 0x22, - 0xa0, 0x5f, 0x59, 0xdb, 0x86, 0x6c, 0xbc, 0x01, 0x88, 0x91, 0x76, 0xe1, 0x05, 0x00, 0x18, 0x04, - 0xdf, 0x87, 0x11, 0x7e, 0x10, 0xdd, 0x1e, 0x72, 0xc7, 0x29, 0x02, 0xdf, 0x5b, 0xca, 0x56, 0x1d, - 0x1b, 0x75, 0x2d, 0xa3, 0x34, 0xac, 0x6c, 0xd5, 0xb1, 0x63, 0x47, 0x54, 0x7b, 0x7a, 0xf8, 0xf1, - 0x58, 0x38, 0xa2, 0x62, 0x22, 0x78, 0x98, 0x90, 0xbc, 0xc2, 0x8f, 0xc6, 0x82, 0x87, 0x09, 0x43, - 0x85, 0x47, 0x43, 0xca, 0xf6, 0xe1, 0xe0, 0x8f, 0x78, 0x22, 0x66, 0x52, 0x9e, 0x3d, 0xe9, 0x69, - 0x8c, 0x88, 0x0c, 0x9b, 0xa6, 0xa1, 0x5f, 0x19, 0x24, 0xf7, 0x8b, 0x2b, 0x74, 0xdc, 0xb6, 0xc2, - 0xe7, 0x3c, 0x2b, 0x78, 0xab, 0xef, 0x79, 0xcd, 0x9e, 0x1f, 0x3f, 0xa6, 0x61, 0xd3, 0x33, 0xba, - 0x0e, 0xba, 0x60, 0x5e, 0x9d, 0xd1, 0x08, 0xc6, 0x5f, 0x1b, 0xec, 0xd1, 0x56, 0x67, 0x24, 0x7a, - 0x47, 0x29, 0x67, 0x95, 0x49, 0x4e, 0x06, 0xa7, 0x63, 0x0b, 0xce, 0xdf, 0xf4, 0xe1, 0x74, 0xec, - 0x24, 0xa7, 0x63, 0x73, 0xce, 0x03, 0xe9, 0x21, 0xbf, 0xa7, 0x06, 0xfa, 0x5b, 0x4a, 0x7a, 0x3e, - 0x41, 0x7a, 0x20, 0x45, 0x3a, 0xa7, 0x0e, 0x89, 0xb2, 0x68, 0xa5, 0x58, 0x7f, 0xd7, 0x8f, 0x96, - 0x07, 0x3b, 0xa7, 0x8e, 0x94, 0xd2, 0x32, 0x40, 0x1a, 0x47, 0xb0, 0xfe, 0x3e, 0x2b, 0x03, 0xa4, - 0x97, 0xb4, 0x0c, 0x10, 0x5b, 0x5a, 0xa8, 0xb4, 0xd3, 0x04, 0xe9, 0x1f, 0xb2, 0x42, 0xa5, 0xcd, - 0xa7, 0x85, 0x4a, 0x8d, 0x69, 0xb4, 0x4c, 0x61, 0x38, 0xed, 0x1f, 0xb3, 0x68, 0xe9, 0x4d, 0xa8, - 0xd1, 0x52, 0x63, 0x5a, 0x06, 0xc8, 0x3d, 0x2a, 0x58, 0xff, 0x94, 0x95, 0x01, 0x72, 0xdb, 0x6a, - 0x19, 0x20, 0x36, 0xce, 0xb9, 0x27, 0x3d, 0x1c, 0x28, 0xcd, 0xff, 0x67, 0x83, 0xc8, 0x60, 0xdf, - 0xe6, 0x97, 0x1f, 0x0a, 0xa5, 0x20, 0xd5, 0x91, 0x81, 0x60, 0xfc, 0x8b, 0xc1, 0x9e, 0xb4, 0xfa, - 0x35, 0xbf, 0x32, 0x58, 0xc8, 0xe0, 0x94, 0x1a, 0xea, 0xaf, 0x7d, 0x38, 0x45, 0xf3, 0x2b, 0x53, - 0x08, 0xa9, 0x46, 0xda, 0x30, 0x42, 0x90, 0xfe, 0x8d, 0x92, 0x9e, 0xd2, 0xfc, 0xea, 0xcc, 0x22, - 0x8b, 0x56, 0x8a, 0xf5, 0xef, 0xfd, 0x68, 0x45, 0xf3, 0xab, 0x13, 0x8e, 0xb4, 0x0c, 0xa8, 0xcd, - 0xff, 0x8f, 0xac, 0x0c, 0xc8, 0xcd, 0xaf, 0x0c, 0x03, 0xd2, 0x42, 0xd5, 0x9a, 0xff, 0x9f, 0x59, - 0xa1, 0x2a, 0xcd, 0xaf, 0x8e, 0x0e, 0xd2, 0x68, 0xb5, 0xe6, 0xff, 0x57, 0x16, 0xad, 0xd2, 0xfc, - 0xea, 0xb3, 0x68, 0x5a, 0x06, 0xd4, 0xe6, 0xff, 0x77, 0x56, 0x06, 0xe4, 0xe6, 0x57, 0x06, 0x0e, - 0x9c, 0xf3, 0xa1, 0x34, 0xd7, 0xe5, 0xef, 0x70, 0xd0, 0x77, 0x73, 0x6c, 0x4e, 0x96, 0xd8, 0x3b, - 0x43, 0xc4, 0x33, 0x5f, 0x6e, 0x81, 0x8f, 0x80, 0x18, 0x1a, 0xd6, 0xc4, 0xcb, 0x1a, 0xf4, 0xbd, - 0x5c, 0xc6, 0xf9, 0xf1, 0x94, 0x43, 0x5c, 0xe1, 0x5f, 0x98, 0xe0, 0x47, 0xc1, 0x8c, 0x34, 0xc4, - 0xe6, 0x2f, 0x8e, 0xd0, 0xf7, 0xb3, 0xc8, 0xaa, 0x18, 0xf3, 0xd8, 0x8b, 0x5e, 0xc6, 0x64, 0xc2, - 0x04, 0xb7, 0xd4, 0xb9, 0x70, 0xaf, 0xde, 0x45, 0x3f, 0xa0, 0x44, 0x0b, 0x69, 0x45, 0xe8, 0xd5, - 0xbb, 0xca, 0xc4, 0xb8, 0x57, 0xef, 0xc2, 0x4d, 0x20, 0x66, 0x8b, 0x35, 0xaf, 0x7d, 0x82, 0x7e, - 0x48, 0xd7, 0xcf, 0x26, 0xd6, 0x6f, 0xb5, 0x4f, 0xdc, 0x3c, 0x87, 0x6e, 0xb5, 0x4f, 0xe0, 0x5d, - 0x69, 0xd6, 0xfc, 0x0a, 0x97, 0x01, 0xfd, 0x88, 0xae, 0x9d, 0x4f, 0xac, 0xa5, 0x55, 0x12, 0xd3, - 0x4d, 0xf2, 0x15, 0x97, 0x27, 0x6e, 0x50, 0x5e, 0x9e, 0x1f, 0xe7, 0x48, 0xb5, 0xfb, 0x95, 0x47, - 0xf4, 0xa5, 0x54, 0x1e, 0x41, 0x14, 0x97, 0xe7, 0x27, 0xb9, 0x0c, 0x85, 0x93, 0xca, 0xc3, 0x97, - 0xc5, 0xe5, 0x91, 0xb9, 0x48, 0x79, 0x48, 0x75, 0x7e, 0x9a, 0xc5, 0x25, 0x55, 0x27, 0x1e, 0x0a, - 0xb2, 0x55, 0xb8, 0x3a, 0xf2, 0xad, 0x82, 0xab, 0xf3, 0x4b, 0x4a, 0x94, 0x5d, 0x1d, 0xe9, 0xee, - 0x60, 0xd5, 0x11, 0x14, 0xb8, 0x3a, 0x3f, 0xa3, 0xeb, 0x33, 0xaa, 0xc3, 0xa1, 0xac, 0x3a, 0x62, - 0x25, 0xad, 0xce, 0xcf, 0xe9, 0xda, 0xcc, 0xea, 0x70, 0x38, 0xad, 0xce, 0x05, 0x00, 0xc8, 0xfe, - 0xdb, 0x5e, 0xcb, 0x5f, 0x43, 0x9f, 0x36, 0xc9, 0x6b, 0x28, 0xc9, 0x04, 0x2d, 0x90, 0xa7, 0xfd, - 0x8b, 0xbf, 0xae, 0xa3, 0xcf, 0xc8, 0x88, 0x5d, 0x6c, 0x82, 0x17, 0x41, 0xa1, 0x16, 0x43, 0x36, - 0xd0, 0x67, 0x19, 0xa4, 0xca, 0x21, 0x1b, 0x70, 0x09, 0x4c, 0x50, 0x04, 0x81, 0xd8, 0x35, 0xf4, - 0x39, 0x9d, 0x86, 0xfc, 0x3d, 0x49, 0xbe, 0xad, 0x62, 0xc8, 0x4d, 0xf4, 0x79, 0x8a, 0x90, 0x6d, - 0x70, 0x99, 0xd3, 0xac, 0x12, 0x1e, 0x07, 0x7d, 0x41, 0x01, 0x61, 0x1e, 0x47, 0xec, 0x08, 0x7f, - 0xbb, 0x85, 0xbe, 0xa8, 0x3b, 0xba, 0x85, 0x01, 0x22, 0xb4, 0x4d, 0xf4, 0x25, 0x3d, 0xda, 0xcd, - 0x78, 0xcb, 0xf8, 0xeb, 0x6d, 0xf4, 0x65, 0x9d, 0xe2, 0x36, 0x5c, 0x02, 0x85, 0xaa, 0x40, 0xac, - 0xad, 0xa2, 0xaf, 0xb0, 0x38, 0x04, 0xc9, 0xda, 0x2a, 0xc1, 0xec, 0x54, 0xde, 0x7d, 0x50, 0xdb, - 0xdd, 0x7a, 0x5c, 0x59, 0x5b, 0x43, 0x5f, 0xe5, 0x18, 0x6c, 0xa4, 0xb6, 0x18, 0x43, 0x72, 0xbd, - 0x8e, 0xbe, 0xa6, 0x60, 0x88, 0x0d, 0x5e, 0x02, 0x93, 0x35, 0x29, 0xbf, 0x6b, 0x1b, 0xe8, 0xeb, - 0x09, 0x6f, 0x1b, 0x14, 0x55, 0x8d, 0x51, 0x36, 0xfa, 0x46, 0x02, 0x65, 0xc7, 0x09, 0xa4, 0xa0, - 0x9b, 0xe8, 0x9b, 0x72, 0x02, 0x09, 0x48, 0xca, 0x32, 0xdd, 0x9d, 0x83, 0xbe, 0x95, 0x00, 0x39, - 0xd8, 0x9f, 0x14, 0xd3, 0xad, 0x5a, 0x0d, 0x7d, 0x3b, 0x81, 0xba, 0x85, 0x51, 0x52, 0x4c, 0x9b, - 0xb5, 0x1a, 0xfa, 0x4e, 0x22, 0xaa, 0xcd, 0xc5, 0xe7, 0x60, 0x42, 0x7d, 0xd0, 0x29, 0x00, 0xc3, - 0x63, 0x6f, 0x44, 0x0d, 0x0f, 0xbe, 0x0d, 0xf2, 0xf5, 0x40, 0xbc, 0xd4, 0x40, 0xb9, 0xd3, 0x5e, - 0x80, 0xc8, 0xe8, 0xc5, 0x7b, 0x00, 0x26, 0x87, 0x94, 0xb0, 0x08, 0xcc, 0x97, 0xfe, 0x09, 0x73, - 0x81, 0x7f, 0x85, 0xb3, 0xe0, 0x0c, 0xbd, 0x7d, 0x72, 0xc4, 0x46, 0xbf, 0xdc, 0xc9, 0x6d, 0x1a, - 0x31, 0x83, 0x3c, 0x90, 0x94, 0x19, 0xcc, 0x14, 0x06, 0x53, 0x66, 0x28, 0x83, 0xd9, 0xb4, 0xd1, - 0xa3, 0xcc, 0x31, 0x91, 0xc2, 0x31, 0x91, 0xce, 0xa1, 0x8c, 0x18, 0x65, 0x8e, 0xe1, 0x14, 0x8e, - 0xe1, 0x24, 0x47, 0x62, 0x94, 0x28, 0x73, 0x4c, 0xa7, 0x70, 0x4c, 0xa7, 0x73, 0x28, 0x23, 0x43, - 0x99, 0x03, 0xa6, 0x70, 0x40, 0x99, 0xe3, 0x01, 0x98, 0x4f, 0x1f, 0x0c, 0xca, 0x2c, 0xa3, 0x29, - 0x2c, 0xa3, 0x19, 0x2c, 0xea, 0xf0, 0x4f, 0x66, 0x19, 0x49, 0x61, 0x19, 0x91, 0x59, 0xaa, 0x00, - 0x65, 0x8d, 0xf7, 0x64, 0x9e, 0xa9, 0x14, 0x9e, 0xa9, 0x2c, 0x1e, 0x6d, 0x7c, 0x27, 0xf3, 0x14, - 0x53, 0x78, 0x8a, 0xa9, 0xdd, 0x26, 0x0f, 0xe9, 0x4e, 0xeb, 0xd7, 0x9c, 0xcc, 0xb0, 0x05, 0x66, - 0x52, 0xe6, 0x71, 0xa7, 0x51, 0x18, 0x32, 0xc5, 0x5d, 0x50, 0xd4, 0x87, 0x6f, 0xf2, 0xfa, 0xb1, - 0x94, 0xf5, 0x63, 0x29, 0x4d, 0xa2, 0x0f, 0xda, 0x64, 0x8e, 0xf1, 0x14, 0x8e, 0xf1, 0xe4, 0x36, - 0xf4, 0x89, 0xda, 0x69, 0x14, 0x05, 0x99, 0x22, 0x04, 0xe7, 0xfa, 0x8c, 0xcc, 0x52, 0xa8, 0xde, - 0x91, 0xa9, 0x5e, 0xe3, 0x7d, 0x95, 0xe4, 0xf3, 0x18, 0x9c, 0xef, 0x37, 0x33, 0x4b, 0x71, 0xba, - 0xa6, 0x3a, 0xed, 0xfb, 0x0a, 0x4b, 0x72, 0xd4, 0xa4, 0x0d, 0x97, 0x36, 0x2b, 0x4b, 0x71, 0x72, - 0x47, 0x76, 0x32, 0xe8, 0x4b, 0x2d, 0xc9, 0x9b, 0x07, 0xce, 0x66, 0xce, 0xcb, 0x52, 0xdc, 0xad, - 0xa8, 0xee, 0xb2, 0x5f, 0x75, 0xc5, 0x2e, 0x96, 0x6e, 0x03, 0x20, 0x4d, 0xf6, 0x46, 0x81, 0x59, - 0xdd, 0xdb, 0x2b, 0x0e, 0xe1, 0x5f, 0xca, 0x5b, 0x6e, 0xd1, 0xa0, 0xbf, 0x3c, 0x2f, 0xe6, 0xb0, - 0xbb, 0xdd, 0xca, 0xc3, 0xe2, 0x7f, 0xf9, 0x7f, 0x46, 0x79, 0x42, 0x8c, 0xa2, 0xf0, 0xa9, 0xb2, - 0xf4, 0x06, 0x98, 0xd4, 0x06, 0x92, 0x05, 0x60, 0xd4, 0xf9, 0x81, 0x52, 0xbf, 0x76, 0x13, 0x80, - 0xf8, 0xdf, 0x30, 0xc1, 0x29, 0x90, 0x3f, 0xd8, 0xdd, 0x7f, 0x52, 0xb9, 0xbf, 0x53, 0xdd, 0xa9, - 0x3c, 0x28, 0x0e, 0xc1, 0x02, 0x18, 0x7b, 0xe2, 0xee, 0x3d, 0xdd, 0x2b, 0x1f, 0x54, 0x8b, 0x06, - 0x1c, 0x03, 0xc3, 0x8f, 0xf6, 0xf7, 0x76, 0x8b, 0xb9, 0x6b, 0xf7, 0x40, 0x5e, 0x9e, 0x07, 0x4e, - 0x81, 0x7c, 0x75, 0xcf, 0xad, 0xec, 0x3c, 0xdc, 0xad, 0xd1, 0x48, 0x25, 0x03, 0x8d, 0x58, 0x31, - 0x3c, 0x2f, 0xe6, 0xca, 0x17, 0xc1, 0x85, 0x7a, 0xd0, 0x4a, 0xfc, 0x61, 0x26, 0x25, 0xe7, 0xc5, - 0x08, 0xb1, 0x6e, 0xfc, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x33, 0xc2, 0x0c, 0xb6, 0xeb, 0x26, 0x00, - 0x00, -} diff --git a/vendor/github.com/golang/protobuf/_conformance/conformance_proto/conformance.proto b/vendor/github.com/golang/protobuf/_conformance/conformance_proto/conformance.proto deleted file mode 100644 index 95a8fd135..000000000 --- a/vendor/github.com/golang/protobuf/_conformance/conformance_proto/conformance.proto +++ /dev/null @@ -1,285 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; -package conformance; -option java_package = "com.google.protobuf.conformance"; - -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -// This defines the conformance testing protocol. This protocol exists between -// the conformance test suite itself and the code being tested. For each test, -// the suite will send a ConformanceRequest message and expect a -// ConformanceResponse message. -// -// You can either run the tests in two different ways: -// -// 1. in-process (using the interface in conformance_test.h). -// -// 2. as a sub-process communicating over a pipe. Information about how to -// do this is in conformance_test_runner.cc. -// -// Pros/cons of the two approaches: -// -// - running as a sub-process is much simpler for languages other than C/C++. -// -// - running as a sub-process may be more tricky in unusual environments like -// iOS apps, where fork/stdin/stdout are not available. - -enum WireFormat { - UNSPECIFIED = 0; - PROTOBUF = 1; - JSON = 2; -} - -// Represents a single test case's input. The testee should: -// -// 1. parse this proto (which should always succeed) -// 2. parse the protobuf or JSON payload in "payload" (which may fail) -// 3. if the parse succeeded, serialize the message in the requested format. -message ConformanceRequest { - // The payload (whether protobuf of JSON) is always for a TestAllTypes proto - // (see below). - oneof payload { - bytes protobuf_payload = 1; - string json_payload = 2; - } - - // Which format should the testee serialize its message to? - WireFormat requested_output_format = 3; -} - -// Represents a single test case's output. -message ConformanceResponse { - oneof result { - // This string should be set to indicate parsing failed. The string can - // provide more information about the parse error if it is available. - // - // Setting this string does not necessarily mean the testee failed the - // test. Some of the test cases are intentionally invalid input. - string parse_error = 1; - - // If the input was successfully parsed but errors occurred when - // serializing it to the requested output format, set the error message in - // this field. - string serialize_error = 6; - - // This should be set if some other error occurred. This will always - // indicate that the test failed. The string can provide more information - // about the failure. - string runtime_error = 2; - - // If the input was successfully parsed and the requested output was - // protobuf, serialize it to protobuf and set it in this field. - bytes protobuf_payload = 3; - - // If the input was successfully parsed and the requested output was JSON, - // serialize to JSON and set it in this field. - string json_payload = 4; - - // For when the testee skipped the test, likely because a certain feature - // wasn't supported, like JSON input/output. - string skipped = 5; - } -} - -// This proto includes every type of field in both singular and repeated -// forms. -message TestAllTypes { - message NestedMessage { - int32 a = 1; - TestAllTypes corecursive = 2; - } - - enum NestedEnum { - FOO = 0; - BAR = 1; - BAZ = 2; - NEG = -1; // Intentionally negative. - } - - // Singular - int32 optional_int32 = 1; - int64 optional_int64 = 2; - uint32 optional_uint32 = 3; - uint64 optional_uint64 = 4; - sint32 optional_sint32 = 5; - sint64 optional_sint64 = 6; - fixed32 optional_fixed32 = 7; - fixed64 optional_fixed64 = 8; - sfixed32 optional_sfixed32 = 9; - sfixed64 optional_sfixed64 = 10; - float optional_float = 11; - double optional_double = 12; - bool optional_bool = 13; - string optional_string = 14; - bytes optional_bytes = 15; - - NestedMessage optional_nested_message = 18; - ForeignMessage optional_foreign_message = 19; - - NestedEnum optional_nested_enum = 21; - ForeignEnum optional_foreign_enum = 22; - - string optional_string_piece = 24 [ctype=STRING_PIECE]; - string optional_cord = 25 [ctype=CORD]; - - TestAllTypes recursive_message = 27; - - // Repeated - repeated int32 repeated_int32 = 31; - repeated int64 repeated_int64 = 32; - repeated uint32 repeated_uint32 = 33; - repeated uint64 repeated_uint64 = 34; - repeated sint32 repeated_sint32 = 35; - repeated sint64 repeated_sint64 = 36; - repeated fixed32 repeated_fixed32 = 37; - repeated fixed64 repeated_fixed64 = 38; - repeated sfixed32 repeated_sfixed32 = 39; - repeated sfixed64 repeated_sfixed64 = 40; - repeated float repeated_float = 41; - repeated double repeated_double = 42; - repeated bool repeated_bool = 43; - repeated string repeated_string = 44; - repeated bytes repeated_bytes = 45; - - repeated NestedMessage repeated_nested_message = 48; - repeated ForeignMessage repeated_foreign_message = 49; - - repeated NestedEnum repeated_nested_enum = 51; - repeated ForeignEnum repeated_foreign_enum = 52; - - repeated string repeated_string_piece = 54 [ctype=STRING_PIECE]; - repeated string repeated_cord = 55 [ctype=CORD]; - - // Map - map < int32, int32> map_int32_int32 = 56; - map < int64, int64> map_int64_int64 = 57; - map < uint32, uint32> map_uint32_uint32 = 58; - map < uint64, uint64> map_uint64_uint64 = 59; - map < sint32, sint32> map_sint32_sint32 = 60; - map < sint64, sint64> map_sint64_sint64 = 61; - map < fixed32, fixed32> map_fixed32_fixed32 = 62; - map < fixed64, fixed64> map_fixed64_fixed64 = 63; - map map_sfixed32_sfixed32 = 64; - map map_sfixed64_sfixed64 = 65; - map < int32, float> map_int32_float = 66; - map < int32, double> map_int32_double = 67; - map < bool, bool> map_bool_bool = 68; - map < string, string> map_string_string = 69; - map < string, bytes> map_string_bytes = 70; - map < string, NestedMessage> map_string_nested_message = 71; - map < string, ForeignMessage> map_string_foreign_message = 72; - map < string, NestedEnum> map_string_nested_enum = 73; - map < string, ForeignEnum> map_string_foreign_enum = 74; - - oneof oneof_field { - uint32 oneof_uint32 = 111; - NestedMessage oneof_nested_message = 112; - string oneof_string = 113; - bytes oneof_bytes = 114; - bool oneof_bool = 115; - uint64 oneof_uint64 = 116; - float oneof_float = 117; - double oneof_double = 118; - NestedEnum oneof_enum = 119; - } - - // Well-known types - google.protobuf.BoolValue optional_bool_wrapper = 201; - google.protobuf.Int32Value optional_int32_wrapper = 202; - google.protobuf.Int64Value optional_int64_wrapper = 203; - google.protobuf.UInt32Value optional_uint32_wrapper = 204; - google.protobuf.UInt64Value optional_uint64_wrapper = 205; - google.protobuf.FloatValue optional_float_wrapper = 206; - google.protobuf.DoubleValue optional_double_wrapper = 207; - google.protobuf.StringValue optional_string_wrapper = 208; - google.protobuf.BytesValue optional_bytes_wrapper = 209; - - repeated google.protobuf.BoolValue repeated_bool_wrapper = 211; - repeated google.protobuf.Int32Value repeated_int32_wrapper = 212; - repeated google.protobuf.Int64Value repeated_int64_wrapper = 213; - repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214; - repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215; - repeated google.protobuf.FloatValue repeated_float_wrapper = 216; - repeated google.protobuf.DoubleValue repeated_double_wrapper = 217; - repeated google.protobuf.StringValue repeated_string_wrapper = 218; - repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219; - - google.protobuf.Duration optional_duration = 301; - google.protobuf.Timestamp optional_timestamp = 302; - google.protobuf.FieldMask optional_field_mask = 303; - google.protobuf.Struct optional_struct = 304; - google.protobuf.Any optional_any = 305; - google.protobuf.Value optional_value = 306; - - repeated google.protobuf.Duration repeated_duration = 311; - repeated google.protobuf.Timestamp repeated_timestamp = 312; - repeated google.protobuf.FieldMask repeated_fieldmask = 313; - repeated google.protobuf.Struct repeated_struct = 324; - repeated google.protobuf.Any repeated_any = 315; - repeated google.protobuf.Value repeated_value = 316; - - // Test field-name-to-JSON-name convention. - // (protobuf says names can be any valid C/C++ identifier.) - int32 fieldname1 = 401; - int32 field_name2 = 402; - int32 _field_name3 = 403; - int32 field__name4_ = 404; - int32 field0name5 = 405; - int32 field_0_name6 = 406; - int32 fieldName7 = 407; - int32 FieldName8 = 408; - int32 field_Name9 = 409; - int32 Field_Name10 = 410; - int32 FIELD_NAME11 = 411; - int32 FIELD_name12 = 412; - int32 __field_name13 = 413; - int32 __Field_name14 = 414; - int32 field__name15 = 415; - int32 field__Name16 = 416; - int32 field_name17__ = 417; - int32 Field_name18__ = 418; -} - -message ForeignMessage { - int32 c = 1; -} - -enum ForeignEnum { - FOREIGN_FOO = 0; - FOREIGN_BAR = 1; - FOREIGN_BAZ = 2; -} diff --git a/vendor/github.com/golang/protobuf/descriptor/descriptor.go b/vendor/github.com/golang/protobuf/descriptor/descriptor.go deleted file mode 100644 index 83607ff6c..000000000 --- a/vendor/github.com/golang/protobuf/descriptor/descriptor.go +++ /dev/null @@ -1,93 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2016 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Package descriptor provides functions for obtaining protocol buffer -// descriptors for generated Go types. -// -// These functions cannot go in package proto because they depend on the -// generated protobuf descriptor messages, which themselves depend on proto. -package descriptor - -import ( - "bytes" - "compress/gzip" - "fmt" - "io/ioutil" - - "github.com/golang/protobuf/proto" - protobuf "google.golang.org/genproto/protobuf" -) - -// extractFile extracts a FileDescriptorProto from a gzip'd buffer. -func extractFile(gz []byte) (*protobuf.FileDescriptorProto, error) { - r, err := gzip.NewReader(bytes.NewReader(gz)) - if err != nil { - return nil, fmt.Errorf("failed to open gzip reader: %v", err) - } - defer r.Close() - - b, err := ioutil.ReadAll(r) - if err != nil { - return nil, fmt.Errorf("failed to uncompress descriptor: %v", err) - } - - fd := new(protobuf.FileDescriptorProto) - if err := proto.Unmarshal(b, fd); err != nil { - return nil, fmt.Errorf("malformed FileDescriptorProto: %v", err) - } - - return fd, nil -} - -// Message is a proto.Message with a method to return its descriptor. -// -// Message types generated by the protocol compiler always satisfy -// the Message interface. -type Message interface { - proto.Message - Descriptor() ([]byte, []int) -} - -// ForMessage returns a FileDescriptorProto and a DescriptorProto from within it -// describing the given message. -func ForMessage(msg Message) (fd *protobuf.FileDescriptorProto, md *protobuf.DescriptorProto) { - gz, path := msg.Descriptor() - fd, err := extractFile(gz) - if err != nil { - panic(fmt.Sprintf("invalid FileDescriptorProto for %T: %v", msg, err)) - } - - md = fd.MessageType[path[0]] - for _, i := range path[1:] { - md = md.NestedType[i] - } - return fd, md -} diff --git a/vendor/github.com/golang/protobuf/descriptor/descriptor_test.go b/vendor/github.com/golang/protobuf/descriptor/descriptor_test.go deleted file mode 100644 index 282a1e3a7..000000000 --- a/vendor/github.com/golang/protobuf/descriptor/descriptor_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package descriptor_test - -import ( - "fmt" - "testing" - - "github.com/golang/protobuf/descriptor" - tpb "github.com/golang/protobuf/proto/testdata" - protobuf "google.golang.org/genproto/protobuf" -) - -func TestMessage(t *testing.T) { - var msg *protobuf.DescriptorProto - fd, md := descriptor.ForMessage(msg) - if pkg, want := fd.GetPackage(), "google.protobuf"; pkg != want { - t.Errorf("descriptor.ForMessage(%T).GetPackage() = %q; want %q", msg, pkg, want) - } - if name, want := md.GetName(), "DescriptorProto"; name != want { - t.Fatalf("descriptor.ForMessage(%T).GetName() = %q; want %q", msg, name, want) - } -} - -func Example_Options() { - var msg *tpb.MyMessageSet - _, md := descriptor.ForMessage(msg) - if md.GetOptions().GetMessageSetWireFormat() { - fmt.Printf("%v uses option message_set_wire_format.\n", md.GetName()) - } - - // Output: - // MyMessageSet uses option message_set_wire_format. -} diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb.go b/vendor/github.com/golang/protobuf/jsonpb/jsonpb.go index 82c61624e..57b58fd33 100644 --- a/vendor/github.com/golang/protobuf/jsonpb/jsonpb.go +++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb.go @@ -30,52 +30,49 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* -Package jsonpb provides marshaling and unmarshaling between protocol buffers and JSON. -It follows the specification at https://developers.google.com/protocol-buffers/docs/proto3#json. +Package jsonpb provides marshaling/unmarshaling functionality between +protocol buffer and JSON objects. -This package produces a different output than the standard "encoding/json" package, -which does not operate correctly on protocol buffers. +Compared to encoding/json, this library: + - encodes int64, uint64 as strings + - optionally encodes enums as integers */ package jsonpb import ( "bytes" "encoding/json" - "errors" "fmt" "io" "reflect" "sort" "strconv" "strings" - "time" "github.com/golang/protobuf/proto" ) +var ( + byteArrayType = reflect.TypeOf([]byte{}) +) + // Marshaler is a configurable object for converting between -// protocol buffer objects and a JSON representation for them. +// protocol buffer objects and a JSON representation for them type Marshaler struct { // Whether to render enum values as integers, as opposed to string values. EnumsAsInts bool - // Whether to render fields with zero values. - EmitDefaults bool - // A string to indent each level by. The presence of this field will // also cause a space to appear between the field separator and // value, and for newlines to be appear between fields and array // elements. Indent string - - // Whether to use the original (.proto) name for fields. - OrigName bool } // Marshal marshals a protocol buffer into JSON. func (m *Marshaler) Marshal(out io.Writer, pb proto.Message) error { writer := &errWriter{writer: out} - return m.marshalObject(writer, pb, "", "") + return m.marshalObject(writer, pb, "") } // MarshalToString converts a protocol buffer object to JSON string. @@ -94,83 +91,15 @@ func (s int32Slice) Len() int { return len(s) } func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] } func (s int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } -type wkt interface { - XXX_WellKnownType() string -} - // marshalObject writes a struct to the Writer. -func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeURL string) error { - s := reflect.ValueOf(v).Elem() - - // Handle well-known types. - if wkt, ok := v.(wkt); ok { - switch wkt.XXX_WellKnownType() { - case "DoubleValue", "FloatValue", "Int64Value", "UInt64Value", - "Int32Value", "UInt32Value", "BoolValue", "StringValue", "BytesValue": - // "Wrappers use the same representation in JSON - // as the wrapped primitive type, ..." - sprop := proto.GetProperties(s.Type()) - return m.marshalValue(out, sprop.Prop[0], s.Field(0), indent) - case "Any": - // Any is a bit more involved. - return m.marshalAny(out, v, indent) - case "Duration": - // "Generated output always contains 3, 6, or 9 fractional digits, - // depending on required precision." - s, ns := s.Field(0).Int(), s.Field(1).Int() - d := time.Duration(s)*time.Second + time.Duration(ns)*time.Nanosecond - x := fmt.Sprintf("%.9f", d.Seconds()) - x = strings.TrimSuffix(x, "000") - x = strings.TrimSuffix(x, "000") - out.write(`"`) - out.write(x) - out.write(`s"`) - return out.err - case "Struct": - // Let marshalValue handle the `fields` map. - // TODO: pass the correct Properties if needed. - return m.marshalValue(out, &proto.Properties{}, s.Field(0), indent) - case "Timestamp": - // "RFC 3339, where generated output will always be Z-normalized - // and uses 3, 6 or 9 fractional digits." - s, ns := s.Field(0).Int(), s.Field(1).Int() - t := time.Unix(s, ns).UTC() - // time.RFC3339Nano isn't exactly right (we need to get 3/6/9 fractional digits). - x := t.Format("2006-01-02T15:04:05.000000000") - x = strings.TrimSuffix(x, "000") - x = strings.TrimSuffix(x, "000") - out.write(`"`) - out.write(x) - out.write(`Z"`) - return out.err - case "Value": - // Value has a single oneof. - kind := s.Field(0) - if kind.IsNil() { - // "absence of any variant indicates an error" - return errors.New("nil Value") - } - // oneof -> *T -> T -> T.F - x := kind.Elem().Elem().Field(0) - // TODO: pass the correct Properties if needed. - return m.marshalValue(out, &proto.Properties{}, x, indent) - } - } - +func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent string) error { out.write("{") if m.Indent != "" { out.write("\n") } + s := reflect.ValueOf(v).Elem() firstField := true - - if typeURL != "" { - if err := m.marshalTypeURL(out, indent, typeURL); err != nil { - return err - } - firstField = false - } - for i := 0; i < s.NumField(); i++ { value := s.Field(i) valueField := s.Type().Field(i) @@ -178,6 +107,8 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU continue } + // TODO: proto3 objects should have default values omitted. + // IsNil will panic on most value kinds. switch value.Kind() { case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: @@ -186,31 +117,6 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU } } - if !m.EmitDefaults { - switch value.Kind() { - case reflect.Bool: - if !value.Bool() { - continue - } - case reflect.Int32, reflect.Int64: - if value.Int() == 0 { - continue - } - case reflect.Uint32, reflect.Uint64: - if value.Uint() == 0 { - continue - } - case reflect.Float32, reflect.Float64: - if value.Float() == 0 { - continue - } - case reflect.String: - if value.Len() == 0 { - continue - } - } - } - // Oneof fields need special handling. if valueField.Tag.Get("protobuf_oneof") != "" { // value is an interface containing &T{real_value}. @@ -218,7 +124,7 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU value = sv.Field(0) valueField = sv.Type().Field(0) } - prop := jsonProperties(valueField, m.OrigName) + prop := jsonProperties(valueField) if !firstField { m.writeSep(out) } @@ -229,14 +135,12 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU } // Handle proto2 extensions. - if ep, ok := v.(proto.Message); ok { + if ep, ok := v.(extendableProto); ok { extensions := proto.RegisteredExtensions(v) + extensionMap := ep.ExtensionMap() // Sort extensions for stable output. - ids := make([]int32, 0, len(extensions)) - for id, desc := range extensions { - if !proto.HasExtension(ep, desc) { - continue - } + ids := make([]int32, 0, len(extensionMap)) + for id := range extensionMap { ids = append(ids, id) } sort.Sort(int32Slice(ids)) @@ -253,7 +157,7 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU value := reflect.ValueOf(ext) var prop proto.Properties prop.Parse(desc.Tag) - prop.JSONName = fmt.Sprintf("[%s]", desc.Name) + prop.OrigName = fmt.Sprintf("[%s]", desc.Name) if !firstField { m.writeSep(out) } @@ -281,76 +185,6 @@ func (m *Marshaler) writeSep(out *errWriter) { } } -func (m *Marshaler) marshalAny(out *errWriter, any proto.Message, indent string) error { - // "If the Any contains a value that has a special JSON mapping, - // it will be converted as follows: {"@type": xxx, "value": yyy}. - // Otherwise, the value will be converted into a JSON object, - // and the "@type" field will be inserted to indicate the actual data type." - v := reflect.ValueOf(any).Elem() - turl := v.Field(0).String() - val := v.Field(1).Bytes() - - // Only the part of type_url after the last slash is relevant. - mname := turl - if slash := strings.LastIndex(mname, "/"); slash >= 0 { - mname = mname[slash+1:] - } - mt := proto.MessageType(mname) - if mt == nil { - return fmt.Errorf("unknown message type %q", mname) - } - msg := reflect.New(mt.Elem()).Interface().(proto.Message) - if err := proto.Unmarshal(val, msg); err != nil { - return err - } - - if _, ok := msg.(wkt); ok { - out.write("{") - if m.Indent != "" { - out.write("\n") - } - if err := m.marshalTypeURL(out, indent, turl); err != nil { - return err - } - m.writeSep(out) - if m.Indent != "" { - out.write(indent) - out.write(m.Indent) - out.write(`"value": `) - } else { - out.write(`"value":`) - } - if err := m.marshalObject(out, msg, indent+m.Indent, ""); err != nil { - return err - } - if m.Indent != "" { - out.write("\n") - out.write(indent) - } - out.write("}") - return out.err - } - - return m.marshalObject(out, msg, indent, turl) -} - -func (m *Marshaler) marshalTypeURL(out *errWriter, indent, typeURL string) error { - if m.Indent != "" { - out.write(indent) - out.write(m.Indent) - } - out.write(`"@type":`) - if m.Indent != "" { - out.write(" ") - } - b, err := json.Marshal(typeURL) - if err != nil { - return err - } - out.write(string(b)) - return out.err -} - // marshalField writes field description and value to the Writer. func (m *Marshaler) marshalField(out *errWriter, prop *proto.Properties, v reflect.Value, indent string) error { if m.Indent != "" { @@ -358,7 +192,7 @@ func (m *Marshaler) marshalField(out *errWriter, prop *proto.Properties, v refle out.write(m.Indent) } out.write(`"`) - out.write(prop.JSONName) + out.write(prop.OrigName) out.write(`":`) if m.Indent != "" { out.write(" ") @@ -376,7 +210,7 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle v = reflect.Indirect(v) // Handle repeated elements. - if v.Kind() == reflect.Slice && v.Type().Elem().Kind() != reflect.Uint8 { + if v.Type() != byteArrayType && v.Kind() == reflect.Slice { out.write("[") comma := "" for i := 0; i < v.Len(); i++ { @@ -388,9 +222,7 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle out.write(m.Indent) out.write(m.Indent) } - if err := m.marshalValue(out, prop, sliceVal, indent+m.Indent); err != nil { - return err - } + m.marshalValue(out, prop, sliceVal, indent+m.Indent) comma = "," } if m.Indent != "" { @@ -402,19 +234,6 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle return out.err } - // Handle well-known types. - // Most are handled up in marshalObject (because 99% are messages). - type wkt interface { - XXX_WellKnownType() string - } - if wkt, ok := v.Interface().(wkt); ok { - switch wkt.XXX_WellKnownType() { - case "NullValue": - out.write("null") - return out.err - } - } - // Handle enumerations. if !m.EnumsAsInts && prop.Enum != "" { // Unknown enum values will are stringified by the proto library as their @@ -440,7 +259,7 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle // Handle nested messages. if v.Kind() == reflect.Struct { - return m.marshalObject(out, v.Addr().Interface().(proto.Message), indent+m.Indent, "") + return m.marshalObject(out, v.Addr().Interface().(proto.Message), indent+m.Indent) } // Handle maps. @@ -510,143 +329,32 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle return out.err } -// Unmarshaler is a configurable object for converting from a JSON -// representation to a protocol buffer object. -type Unmarshaler struct { - // Whether to allow messages to contain unknown fields, as opposed to - // failing to unmarshal. - AllowUnknownFields bool -} - -// UnmarshalNext unmarshals the next protocol buffer from a JSON object stream. -// This function is lenient and will decode any options permutations of the -// related Marshaler. -func (u *Unmarshaler) UnmarshalNext(dec *json.Decoder, pb proto.Message) error { - inputValue := json.RawMessage{} - if err := dec.Decode(&inputValue); err != nil { - return err - } - return u.unmarshalValue(reflect.ValueOf(pb).Elem(), inputValue, nil) -} - -// Unmarshal unmarshals a JSON object stream into a protocol -// buffer. This function is lenient and will decode any options -// permutations of the related Marshaler. -func (u *Unmarshaler) Unmarshal(r io.Reader, pb proto.Message) error { - dec := json.NewDecoder(r) - return u.UnmarshalNext(dec, pb) -} - -// UnmarshalNext unmarshals the next protocol buffer from a JSON object stream. -// This function is lenient and will decode any options permutations of the -// related Marshaler. -func UnmarshalNext(dec *json.Decoder, pb proto.Message) error { - return new(Unmarshaler).UnmarshalNext(dec, pb) -} - // Unmarshal unmarshals a JSON object stream into a protocol // buffer. This function is lenient and will decode any options // permutations of the related Marshaler. func Unmarshal(r io.Reader, pb proto.Message) error { - return new(Unmarshaler).Unmarshal(r, pb) + inputValue := json.RawMessage{} + if err := json.NewDecoder(r).Decode(&inputValue); err != nil { + return err + } + return unmarshalValue(reflect.ValueOf(pb).Elem(), inputValue) } // UnmarshalString will populate the fields of a protocol buffer based // on a JSON string. This function is lenient and will decode any options // permutations of the related Marshaler. func UnmarshalString(str string, pb proto.Message) error { - return new(Unmarshaler).Unmarshal(strings.NewReader(str), pb) + return Unmarshal(strings.NewReader(str), pb) } // unmarshalValue converts/copies a value into the target. -// prop may be nil. -func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMessage, prop *proto.Properties) error { +func unmarshalValue(target reflect.Value, inputValue json.RawMessage) error { targetType := target.Type() // Allocate memory for pointer fields. if targetType.Kind() == reflect.Ptr { target.Set(reflect.New(targetType.Elem())) - return u.unmarshalValue(target.Elem(), inputValue, prop) - } - - // Handle well-known types. - type wkt interface { - XXX_WellKnownType() string - } - if wkt, ok := target.Addr().Interface().(wkt); ok { - switch wkt.XXX_WellKnownType() { - case "DoubleValue", "FloatValue", "Int64Value", "UInt64Value", - "Int32Value", "UInt32Value", "BoolValue", "StringValue", "BytesValue": - // "Wrappers use the same representation in JSON - // as the wrapped primitive type, except that null is allowed." - // encoding/json will turn JSON `null` into Go `nil`, - // so we don't have to do any extra work. - return u.unmarshalValue(target.Field(0), inputValue, prop) - case "Any": - return fmt.Errorf("unmarshaling Any not supported yet") - case "Duration": - ivStr := string(inputValue) - if ivStr == "null" { - target.Field(0).SetInt(0) - target.Field(1).SetInt(0) - return nil - } - - unq, err := strconv.Unquote(ivStr) - if err != nil { - return err - } - d, err := time.ParseDuration(unq) - if err != nil { - return fmt.Errorf("bad Duration: %v", err) - } - ns := d.Nanoseconds() - s := ns / 1e9 - ns %= 1e9 - target.Field(0).SetInt(s) - target.Field(1).SetInt(ns) - return nil - case "Timestamp": - ivStr := string(inputValue) - if ivStr == "null" { - target.Field(0).SetInt(0) - target.Field(1).SetInt(0) - return nil - } - - unq, err := strconv.Unquote(ivStr) - if err != nil { - return err - } - t, err := time.Parse(time.RFC3339Nano, unq) - if err != nil { - return fmt.Errorf("bad Timestamp: %v", err) - } - target.Field(0).SetInt(int64(t.Unix())) - target.Field(1).SetInt(int64(t.Nanosecond())) - return nil - } - } - - // Handle enums, which have an underlying type of int32, - // and may appear as strings. - // The case of an enum appearing as a number is handled - // at the bottom of this function. - if inputValue[0] == '"' && prop != nil && prop.Enum != "" { - vmap := proto.EnumValueMap(prop.Enum) - // Don't need to do unquoting; valid enum names - // are from a limited character set. - s := inputValue[1 : len(inputValue)-1] - n, ok := vmap[string(s)] - if !ok { - return fmt.Errorf("unknown value %q for enum %s", s, prop.Enum) - } - if target.Kind() == reflect.Ptr { // proto2 - target.Set(reflect.New(targetType.Elem())) - target = target.Elem() - } - target.SetInt(int64(n)) - return nil + return unmarshalValue(target.Elem(), inputValue) } // Handle nested messages. @@ -656,59 +364,59 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe return err } - consumeField := func(prop *proto.Properties) (json.RawMessage, bool) { - // Be liberal in what names we accept; both orig_name and camelName are okay. - fieldNames := acceptedJSONFieldNames(prop) - - vOrig, okOrig := jsonFields[fieldNames.orig] - vCamel, okCamel := jsonFields[fieldNames.camel] - if !okOrig && !okCamel { - return nil, false - } - // If, for some reason, both are present in the data, favour the camelName. - var raw json.RawMessage - if okOrig { - raw = vOrig - delete(jsonFields, fieldNames.orig) - } - if okCamel { - raw = vCamel - delete(jsonFields, fieldNames.camel) - } - return raw, true - } - sprops := proto.GetProperties(targetType) for i := 0; i < target.NumField(); i++ { ft := target.Type().Field(i) if strings.HasPrefix(ft.Name, "XXX_") { continue } + fieldName := jsonProperties(ft).OrigName - valueForField, ok := consumeField(sprops.Prop[i]) + valueForField, ok := jsonFields[fieldName] if !ok { continue } + delete(jsonFields, fieldName) + + // Handle enums, which have an underlying type of int32, + // and may appear as strings. We do this while handling + // the struct so we have access to the enum info. + // The case of an enum appearing as a number is handled + // by the recursive call to unmarshalValue. + if enum := sprops.Prop[i].Enum; valueForField[0] == '"' && enum != "" { + vmap := proto.EnumValueMap(enum) + // Don't need to do unquoting; valid enum names + // are from a limited character set. + s := valueForField[1 : len(valueForField)-1] + n, ok := vmap[string(s)] + if !ok { + return fmt.Errorf("unknown value %q for enum %s", s, enum) + } + f := target.Field(i) + if f.Kind() == reflect.Ptr { // proto2 + f.Set(reflect.New(f.Type().Elem())) + f = f.Elem() + } + f.SetInt(int64(n)) + continue + } - if err := u.unmarshalValue(target.Field(i), valueForField, sprops.Prop[i]); err != nil { + if err := unmarshalValue(target.Field(i), valueForField); err != nil { return err } } // Check for any oneof fields. - if len(jsonFields) > 0 { - for _, oop := range sprops.OneofTypes { - raw, ok := consumeField(oop.Prop) - if !ok { - continue - } + for fname, raw := range jsonFields { + if oop, ok := sprops.OneofTypes[fname]; ok { nv := reflect.New(oop.Type.Elem()) target.Field(oop.Field).Set(nv) - if err := u.unmarshalValue(nv.Elem().Field(0), raw, oop.Prop); err != nil { + if err := unmarshalValue(nv.Elem().Field(0), raw); err != nil { return err } + delete(jsonFields, fname) } } - if !u.AllowUnknownFields && len(jsonFields) > 0 { + if len(jsonFields) > 0 { // Pick any field to be the scapegoat. var f string for fname := range jsonFields { @@ -721,7 +429,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe } // Handle arrays (which aren't encoded bytes) - if targetType.Kind() == reflect.Slice && targetType.Elem().Kind() != reflect.Uint8 { + if targetType != byteArrayType && targetType.Kind() == reflect.Slice { var slc []json.RawMessage if err := json.Unmarshal(inputValue, &slc); err != nil { return err @@ -729,7 +437,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe len := len(slc) target.Set(reflect.MakeSlice(targetType, len, len)) for i := 0; i < len; i++ { - if err := u.unmarshalValue(target.Index(i), slc[i], prop); err != nil { + if err := unmarshalValue(target.Index(i), slc[i]); err != nil { return err } } @@ -743,13 +451,6 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe return err } target.Set(reflect.MakeMap(targetType)) - var keyprop, valprop *proto.Properties - if prop != nil { - // These could still be nil if the protobuf metadata is broken somehow. - // TODO: This won't work because the fields are unexported. - // We should probably just reparse them. - //keyprop, valprop = prop.mkeyprop, prop.mvalprop - } for ks, raw := range mp { // Unmarshal map key. The core json library already decoded the key into a // string, so we handle that specially. Other types were quoted post-serialization. @@ -758,14 +459,14 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe k = reflect.ValueOf(ks) } else { k = reflect.New(targetType.Key()).Elem() - if err := u.unmarshalValue(k, json.RawMessage(ks), keyprop); err != nil { + if err := unmarshalValue(k, json.RawMessage(ks)); err != nil { return err } } // Unmarshal map value. v := reflect.New(targetType.Elem()).Elem() - if err := u.unmarshalValue(v, raw, valprop); err != nil { + if err := unmarshalValue(v, raw); err != nil { return err } target.SetMapIndex(k, v) @@ -784,26 +485,18 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe return json.Unmarshal(inputValue, target.Addr().Interface()) } -// jsonProperties returns parsed proto.Properties for the field and corrects JSONName attribute. -func jsonProperties(f reflect.StructField, origName bool) *proto.Properties { +// jsonProperties returns parsed proto.Properties for the field. +func jsonProperties(f reflect.StructField) *proto.Properties { var prop proto.Properties prop.Init(f.Type, f.Name, f.Tag.Get("protobuf"), &f) - if origName || prop.JSONName == "" { - prop.JSONName = prop.OrigName - } return &prop } -type fieldNames struct { - orig, camel string -} - -func acceptedJSONFieldNames(prop *proto.Properties) fieldNames { - opts := fieldNames{orig: prop.OrigName, camel: prop.OrigName} - if prop.JSONName != "" { - opts.camel = prop.JSONName - } - return opts +// extendableProto is an interface implemented by any protocol buffer that may be extended. +type extendableProto interface { + proto.Message + ExtensionRangeArray() []proto.ExtensionRange + ExtensionMap() map[int32]proto.Extension } // Writer wrapper inspired by https://blog.golang.org/errors-are-values @@ -823,21 +516,10 @@ func (w *errWriter) write(str string) { // The easiest way to sort them in some deterministic order is to use fmt. // If this turns out to be inefficient we can always consider other options, // such as doing a Schwartzian transform. -// -// Numeric keys are sorted in numeric order per -// https://developers.google.com/protocol-buffers/docs/proto#maps. type mapKeys []reflect.Value func (s mapKeys) Len() int { return len(s) } func (s mapKeys) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s mapKeys) Less(i, j int) bool { - if k := s[i].Kind(); k == s[j].Kind() { - switch k { - case reflect.Int32, reflect.Int64: - return s[i].Int() < s[j].Int() - case reflect.Uint32, reflect.Uint64: - return s[i].Uint() < s[j].Uint() - } - } return fmt.Sprint(s[i].Interface()) < fmt.Sprint(s[j].Interface()) } diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test.go b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test.go index e237df55c..0a5b4ec0e 100644 --- a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test.go +++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test.go @@ -32,22 +32,12 @@ package jsonpb import ( - "bytes" - "encoding/json" - "io" "reflect" - "strings" "testing" - "github.com/golang/protobuf/proto" - pb "github.com/golang/protobuf/jsonpb/jsonpb_test_proto" + "github.com/golang/protobuf/proto" proto3pb "github.com/golang/protobuf/proto/proto3_proto" - anypb "github.com/golang/protobuf/ptypes/any" - durpb "github.com/golang/protobuf/ptypes/duration" - stpb "github.com/golang/protobuf/ptypes/struct" - tspb "github.com/golang/protobuf/ptypes/timestamp" - wpb "github.com/golang/protobuf/ptypes/wrappers" ) var ( @@ -72,31 +62,31 @@ var ( } simpleObjectJSON = `{` + - `"oBool":true,` + - `"oInt32":-32,` + - `"oInt64":"-6400000000",` + - `"oUint32":32,` + - `"oUint64":"6400000000",` + - `"oSint32":-13,` + - `"oSint64":"-2600000000",` + - `"oFloat":3.14,` + - `"oDouble":6.02214179e+23,` + - `"oString":"hello \"there\"",` + - `"oBytes":"YmVlcCBib29w"` + + `"o_bool":true,` + + `"o_int32":-32,` + + `"o_int64":"-6400000000",` + + `"o_uint32":32,` + + `"o_uint64":"6400000000",` + + `"o_sint32":-13,` + + `"o_sint64":"-2600000000",` + + `"o_float":3.14,` + + `"o_double":6.02214179e+23,` + + `"o_string":"hello \"there\"",` + + `"o_bytes":"YmVlcCBib29w"` + `}` simpleObjectPrettyJSON = `{ - "oBool": true, - "oInt32": -32, - "oInt64": "-6400000000", - "oUint32": 32, - "oUint64": "6400000000", - "oSint32": -13, - "oSint64": "-2600000000", - "oFloat": 3.14, - "oDouble": 6.02214179e+23, - "oString": "hello \"there\"", - "oBytes": "YmVlcCBib29w" + "o_bool": true, + "o_int32": -32, + "o_int64": "-6400000000", + "o_uint32": 32, + "o_uint64": "6400000000", + "o_sint32": -13, + "o_sint64": "-2600000000", + "o_float": 3.14, + "o_double": 6.02214179e+23, + "o_string": "hello \"there\"", + "o_bytes": "YmVlcCBib29w" }` repeatsObject = &pb.Repeats{ @@ -108,71 +98,71 @@ var ( RSint32: []int32{-1, -2, -3}, RSint64: []int64{-6789012345, -3456789012}, RFloat: []float32{3.14, 6.28}, - RDouble: []float64{299792458 * 1e20, 6.62606957e-34}, + RDouble: []float64{299792458, 6.62606957e-34}, RString: []string{"happy", "days"}, RBytes: [][]byte{[]byte("skittles"), []byte("m&m's")}, } repeatsObjectJSON = `{` + - `"rBool":[true,false,true],` + - `"rInt32":[-3,-4,-5],` + - `"rInt64":["-123456789","-987654321"],` + - `"rUint32":[1,2,3],` + - `"rUint64":["6789012345","3456789012"],` + - `"rSint32":[-1,-2,-3],` + - `"rSint64":["-6789012345","-3456789012"],` + - `"rFloat":[3.14,6.28],` + - `"rDouble":[2.99792458e+28,6.62606957e-34],` + - `"rString":["happy","days"],` + - `"rBytes":["c2tpdHRsZXM=","bSZtJ3M="]` + + `"r_bool":[true,false,true],` + + `"r_int32":[-3,-4,-5],` + + `"r_int64":["-123456789","-987654321"],` + + `"r_uint32":[1,2,3],` + + `"r_uint64":["6789012345","3456789012"],` + + `"r_sint32":[-1,-2,-3],` + + `"r_sint64":["-6789012345","-3456789012"],` + + `"r_float":[3.14,6.28],` + + `"r_double":[2.99792458e+08,6.62606957e-34],` + + `"r_string":["happy","days"],` + + `"r_bytes":["c2tpdHRsZXM=","bSZtJ3M="]` + `}` repeatsObjectPrettyJSON = `{ - "rBool": [ + "r_bool": [ true, false, true ], - "rInt32": [ + "r_int32": [ -3, -4, -5 ], - "rInt64": [ + "r_int64": [ "-123456789", "-987654321" ], - "rUint32": [ + "r_uint32": [ 1, 2, 3 ], - "rUint64": [ + "r_uint64": [ "6789012345", "3456789012" ], - "rSint32": [ + "r_sint32": [ -1, -2, -3 ], - "rSint64": [ + "r_sint64": [ "-6789012345", "-3456789012" ], - "rFloat": [ + "r_float": [ 3.14, 6.28 ], - "rDouble": [ - 2.99792458e+28, + "r_double": [ + 2.99792458e+08, 6.62606957e-34 ], - "rString": [ + "r_string": [ "happy", "days" ], - "rBytes": [ + "r_bytes": [ "c2tpdHRsZXM=", "bSZtJ3M=" ] @@ -192,46 +182,46 @@ var ( } complexObjectJSON = `{"color":"GREEN",` + - `"rColor":["RED","GREEN","BLUE"],` + - `"simple":{"oInt32":-32},` + - `"rSimple":[{"oInt32":-32},{"oInt64":"25"}],` + - `"repeats":{"rString":["roses","red"]},` + - `"rRepeats":[{"rString":["roses","red"]},{"rString":["violets","blue"]}]` + + `"r_color":["RED","GREEN","BLUE"],` + + `"simple":{"o_int32":-32},` + + `"r_simple":[{"o_int32":-32},{"o_int64":"25"}],` + + `"repeats":{"r_string":["roses","red"]},` + + `"r_repeats":[{"r_string":["roses","red"]},{"r_string":["violets","blue"]}]` + `}` complexObjectPrettyJSON = `{ "color": "GREEN", - "rColor": [ + "r_color": [ "RED", "GREEN", "BLUE" ], "simple": { - "oInt32": -32 + "o_int32": -32 }, - "rSimple": [ + "r_simple": [ { - "oInt32": -32 + "o_int32": -32 }, { - "oInt64": "25" + "o_int64": "25" } ], "repeats": { - "rString": [ + "r_string": [ "roses", "red" ] }, - "rRepeats": [ + "r_repeats": [ { - "rString": [ + "r_string": [ "roses", "red" ] }, { - "rString": [ + "r_string": [ "violets", "blue" ] @@ -245,7 +235,7 @@ var ( colorListPrettyJSON = `{ "color": 1000, - "rColor": [ + "r_color": [ "RED" ] }` @@ -272,41 +262,6 @@ var ( `"[jsonpb.Complex.real_extension]":{"imaginary":0.5772156649},` + `"[jsonpb.name]":"Pi"` + `}` - - anySimple = &pb.KnownTypes{ - An: &anypb.Any{ - TypeUrl: "something.example.com/jsonpb.Simple", - Value: []byte{ - // &pb.Simple{OBool:true} - 1 << 3, 1, - }, - }, - } - anySimpleJSON = `{"an":{"@type":"something.example.com/jsonpb.Simple","oBool":true}}` - anySimplePrettyJSON = `{ - "an": { - "@type": "something.example.com/jsonpb.Simple", - "oBool": true - } -}` - - anyWellKnown = &pb.KnownTypes{ - An: &anypb.Any{ - TypeUrl: "type.googleapis.com/google.protobuf.Duration", - Value: []byte{ - // &durpb.Duration{Seconds: 1, Nanos: 212000000 } - 1 << 3, 1, // seconds - 2 << 3, 0x80, 0xba, 0x8b, 0x65, // nanos - }, - }, - } - anyWellKnownJSON = `{"an":{"@type":"type.googleapis.com/google.protobuf.Duration","value":"1.212s"}}` - anyWellKnownPrettyJSON = `{ - "an": { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } -}` ) func init() { @@ -336,20 +291,7 @@ var marshalingTests = []struct { &pb.Widget{Color: pb.Widget_BLUE.Enum()}, colorPrettyJSON}, {"unknown enum value object", marshalerAllOptions, &pb.Widget{Color: pb.Widget_Color(1000).Enum(), RColor: []pb.Widget_Color{pb.Widget_RED}}, colorListPrettyJSON}, - {"repeated proto3 enum", Marshaler{}, - &proto3pb.Message{RFunny: []proto3pb.Message_Humour{ - proto3pb.Message_PUNS, - proto3pb.Message_SLAPSTICK, - }}, - `{"rFunny":["PUNS","SLAPSTICK"]}`}, - {"repeated proto3 enum as int", Marshaler{EnumsAsInts: true}, - &proto3pb.Message{RFunny: []proto3pb.Message_Humour{ - proto3pb.Message_PUNS, - proto3pb.Message_SLAPSTICK, - }}, - `{"rFunny":[1,2]}`}, - {"empty value", marshaler, &pb.Simple3{}, `{}`}, - {"empty value emitted", Marshaler{EmitDefaults: true}, &pb.Simple3{}, `{"dub":0}`}, + {"proto3 object with empty value", marshaler, &pb.Simple3{}, `{"dub":0}`}, {"map", marshaler, &pb.Mappy{Nummy: map[int64]int32{1: 2, 3: 4}}, `{"nummy":{"1":2,"3":4}}`}, {"map", marshalerAllOptions, &pb.Mappy{Nummy: map[int64]int32{1: 2, 3: 4}}, nummyPrettyJSON}, {"map", marshaler, @@ -362,45 +304,14 @@ var marshalingTests = []struct { {"map", marshaler, &pb.Mappy{Buggy: map[int64]string{1234: "yup"}}, `{"buggy":{"1234":"yup"}}`}, {"map", marshaler, &pb.Mappy{Booly: map[bool]bool{false: true}}, `{"booly":{"false":true}}`}, - // TODO: This is broken. - //{"map", marshaler, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}, `{"enumy":{"XIV":"ROMAN"}`}, - {"map", Marshaler{EnumsAsInts: true}, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}, `{"enumy":{"XIV":2}}`}, - {"map", marshaler, &pb.Mappy{S32Booly: map[int32]bool{1: true, 3: false, 10: true, 12: false}}, `{"s32booly":{"1":true,"3":false,"10":true,"12":false}}`}, - {"map", marshaler, &pb.Mappy{S64Booly: map[int64]bool{1: true, 3: false, 10: true, 12: false}}, `{"s64booly":{"1":true,"3":false,"10":true,"12":false}}`}, - {"map", marshaler, &pb.Mappy{U32Booly: map[uint32]bool{1: true, 3: false, 10: true, 12: false}}, `{"u32booly":{"1":true,"3":false,"10":true,"12":false}}`}, - {"map", marshaler, &pb.Mappy{U64Booly: map[uint64]bool{1: true, 3: false, 10: true, 12: false}}, `{"u64booly":{"1":true,"3":false,"10":true,"12":false}}`}, {"proto2 map", marshaler, &pb.Maps{MInt64Str: map[int64]string{213: "cat"}}, - `{"mInt64Str":{"213":"cat"}}`}, + `{"m_int64_str":{"213":"cat"}}`}, {"proto2 map", marshaler, &pb.Maps{MBoolSimple: map[bool]*pb.Simple{true: &pb.Simple{OInt32: proto.Int32(1)}}}, - `{"mBoolSimple":{"true":{"oInt32":1}}}`}, + `{"m_bool_simple":{"true":{"o_int32":1}}}`}, {"oneof, not set", marshaler, &pb.MsgWithOneof{}, `{}`}, {"oneof, set", marshaler, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_Title{"Grand Poobah"}}, `{"title":"Grand Poobah"}`}, - {"force orig_name", Marshaler{OrigName: true}, &pb.Simple{OInt32: proto.Int32(4)}, - `{"o_int32":4}`}, {"proto2 extension", marshaler, realNumber, realNumberJSON}, - {"Any with message", marshaler, anySimple, anySimpleJSON}, - {"Any with message and indent", marshalerAllOptions, anySimple, anySimplePrettyJSON}, - {"Any with WKT", marshaler, anyWellKnown, anyWellKnownJSON}, - {"Any with WKT and indent", marshalerAllOptions, anyWellKnown, anyWellKnownPrettyJSON}, - {"Duration", marshaler, &pb.KnownTypes{Dur: &durpb.Duration{Seconds: 3}}, `{"dur":"3.000s"}`}, - {"Struct", marshaler, &pb.KnownTypes{St: &stpb.Struct{ - Fields: map[string]*stpb.Value{ - "one": &stpb.Value{Kind: &stpb.Value_StringValue{"loneliest number"}}, - "two": &stpb.Value{Kind: &stpb.Value_NullValue{stpb.NullValue_NULL_VALUE}}, - }, - }}, `{"st":{"one":"loneliest number","two":null}}`}, - {"Timestamp", marshaler, &pb.KnownTypes{Ts: &tspb.Timestamp{Seconds: 14e8, Nanos: 21e6}}, `{"ts":"2014-05-13T16:53:20.021Z"}`}, - - {"DoubleValue", marshaler, &pb.KnownTypes{Dbl: &wpb.DoubleValue{Value: 1.2}}, `{"dbl":1.2}`}, - {"FloatValue", marshaler, &pb.KnownTypes{Flt: &wpb.FloatValue{Value: 1.2}}, `{"flt":1.2}`}, - {"Int64Value", marshaler, &pb.KnownTypes{I64: &wpb.Int64Value{Value: -3}}, `{"i64":"-3"}`}, - {"UInt64Value", marshaler, &pb.KnownTypes{U64: &wpb.UInt64Value{Value: 3}}, `{"u64":"3"}`}, - {"Int32Value", marshaler, &pb.KnownTypes{I32: &wpb.Int32Value{Value: -4}}, `{"i32":-4}`}, - {"UInt32Value", marshaler, &pb.KnownTypes{U32: &wpb.UInt32Value{Value: 4}}, `{"u32":4}`}, - {"BoolValue", marshaler, &pb.KnownTypes{Bool: &wpb.BoolValue{Value: true}}, `{"bool":true}`}, - {"StringValue", marshaler, &pb.KnownTypes{Str: &wpb.StringValue{Value: "plush"}}, `{"str":"plush"}`}, - {"BytesValue", marshaler, &pb.KnownTypes{Bytes: &wpb.BytesValue{Value: []byte("wow")}}, `{"bytes":"d293"}`}, } func TestMarshaling(t *testing.T) { @@ -415,75 +326,29 @@ func TestMarshaling(t *testing.T) { } var unmarshalingTests = []struct { - desc string - unmarshaler Unmarshaler - json string - pb proto.Message + desc string + json string + pb proto.Message }{ - {"simple flat object", Unmarshaler{}, simpleObjectJSON, simpleObject}, - {"simple pretty object", Unmarshaler{}, simpleObjectPrettyJSON, simpleObject}, - {"repeated fields flat object", Unmarshaler{}, repeatsObjectJSON, repeatsObject}, - {"repeated fields pretty object", Unmarshaler{}, repeatsObjectPrettyJSON, repeatsObject}, - {"nested message/enum flat object", Unmarshaler{}, complexObjectJSON, complexObject}, - {"nested message/enum pretty object", Unmarshaler{}, complexObjectPrettyJSON, complexObject}, - {"enum-string object", Unmarshaler{}, `{"color":"BLUE"}`, &pb.Widget{Color: pb.Widget_BLUE.Enum()}}, - {"enum-value object", Unmarshaler{}, "{\n \"color\": 2\n}", &pb.Widget{Color: pb.Widget_BLUE.Enum()}}, - {"unknown field with allowed option", Unmarshaler{AllowUnknownFields: true}, `{"unknown": "foo"}`, new(pb.Simple)}, - {"proto3 enum string", Unmarshaler{}, `{"hilarity":"PUNS"}`, &proto3pb.Message{Hilarity: proto3pb.Message_PUNS}}, - {"proto3 enum value", Unmarshaler{}, `{"hilarity":1}`, &proto3pb.Message{Hilarity: proto3pb.Message_PUNS}}, + {"simple flat object", simpleObjectJSON, simpleObject}, + {"simple pretty object", simpleObjectPrettyJSON, simpleObject}, + {"repeated fields flat object", repeatsObjectJSON, repeatsObject}, + {"repeated fields pretty object", repeatsObjectPrettyJSON, repeatsObject}, + {"nested message/enum flat object", complexObjectJSON, complexObject}, + {"nested message/enum pretty object", complexObjectPrettyJSON, complexObject}, + {"enum-string object", `{"color":"BLUE"}`, &pb.Widget{Color: pb.Widget_BLUE.Enum()}}, + {"enum-value object", "{\n \"color\": 2\n}", &pb.Widget{Color: pb.Widget_BLUE.Enum()}}, + {"proto3 enum string", `{"hilarity":"PUNS"}`, &proto3pb.Message{Hilarity: proto3pb.Message_PUNS}}, + {"proto3 enum value", `{"hilarity":1}`, &proto3pb.Message{Hilarity: proto3pb.Message_PUNS}}, {"unknown enum value object", - Unmarshaler{}, "{\n \"color\": 1000,\n \"r_color\": [\n \"RED\"\n ]\n}", &pb.Widget{Color: pb.Widget_Color(1000).Enum(), RColor: []pb.Widget_Color{pb.Widget_RED}}}, - {"repeated proto3 enum", Unmarshaler{}, `{"rFunny":["PUNS","SLAPSTICK"]}`, - &proto3pb.Message{RFunny: []proto3pb.Message_Humour{ - proto3pb.Message_PUNS, - proto3pb.Message_SLAPSTICK, - }}}, - {"repeated proto3 enum as int", Unmarshaler{}, `{"rFunny":[1,2]}`, - &proto3pb.Message{RFunny: []proto3pb.Message_Humour{ - proto3pb.Message_PUNS, - proto3pb.Message_SLAPSTICK, - }}}, - {"repeated proto3 enum as mix of strings and ints", Unmarshaler{}, `{"rFunny":["PUNS",2]}`, - &proto3pb.Message{RFunny: []proto3pb.Message_Humour{ - proto3pb.Message_PUNS, - proto3pb.Message_SLAPSTICK, - }}}, - {"unquoted int64 object", Unmarshaler{}, `{"oInt64":-314}`, &pb.Simple{OInt64: proto.Int64(-314)}}, - {"unquoted uint64 object", Unmarshaler{}, `{"oUint64":123}`, &pb.Simple{OUint64: proto.Uint64(123)}}, - {"map", Unmarshaler{}, `{"nummy":{"1":2,"3":4}}`, &pb.Mappy{Nummy: map[int64]int32{1: 2, 3: 4}}}, - {"map", Unmarshaler{}, `{"strry":{"\"one\"":"two","three":"four"}}`, &pb.Mappy{Strry: map[string]string{`"one"`: "two", "three": "four"}}}, - {"map", Unmarshaler{}, `{"objjy":{"1":{"dub":1}}}`, &pb.Mappy{Objjy: map[int32]*pb.Simple3{1: &pb.Simple3{Dub: 1}}}}, - // TODO: This is broken. - //{"map", Unmarshaler{}, `{"enumy":{"XIV":"ROMAN"}`, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}}, - {"map", Unmarshaler{}, `{"enumy":{"XIV":2}}`, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}}, - {"oneof", Unmarshaler{}, `{"salary":31000}`, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_Salary{31000}}}, - {"oneof spec name", Unmarshaler{}, `{"Country":"Australia"}`, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_Country{"Australia"}}}, - {"oneof orig_name", Unmarshaler{}, `{"Country":"Australia"}`, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_Country{"Australia"}}}, - {"oneof spec name2", Unmarshaler{}, `{"homeAddress":"Australia"}`, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_HomeAddress{"Australia"}}}, - {"oneof orig_name2", Unmarshaler{}, `{"home_address":"Australia"}`, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_HomeAddress{"Australia"}}}, - {"orig_name input", Unmarshaler{}, `{"o_bool":true}`, &pb.Simple{OBool: proto.Bool(true)}}, - {"camelName input", Unmarshaler{}, `{"oBool":true}`, &pb.Simple{OBool: proto.Bool(true)}}, - - {"Duration", Unmarshaler{}, `{"dur":"3.000s"}`, &pb.KnownTypes{Dur: &durpb.Duration{Seconds: 3}}}, - {"null Duration", Unmarshaler{}, `{"dur":null}`, &pb.KnownTypes{Dur: &durpb.Duration{Seconds: 0}}}, - {"Timestamp", Unmarshaler{}, `{"ts":"2014-05-13T16:53:20.021Z"}`, &pb.KnownTypes{Ts: &tspb.Timestamp{Seconds: 14e8, Nanos: 21e6}}}, - {"PreEpochTimestamp", Unmarshaler{}, `{"ts":"1969-12-31T23:59:58.999999995Z"}`, &pb.KnownTypes{Ts: &tspb.Timestamp{Seconds: -2, Nanos: 999999995}}}, - {"ZeroTimeTimestamp", Unmarshaler{}, `{"ts":"0001-01-01T00:00:00Z"}`, &pb.KnownTypes{Ts: &tspb.Timestamp{Seconds: -62135596800, Nanos: 0}}}, - {"null Timestamp", Unmarshaler{}, `{"ts":null}`, &pb.KnownTypes{Ts: &tspb.Timestamp{Seconds: 0, Nanos: 0}}}, - - {"DoubleValue", Unmarshaler{}, `{"dbl":1.2}`, &pb.KnownTypes{Dbl: &wpb.DoubleValue{Value: 1.2}}}, - {"FloatValue", Unmarshaler{}, `{"flt":1.2}`, &pb.KnownTypes{Flt: &wpb.FloatValue{Value: 1.2}}}, - {"Int64Value", Unmarshaler{}, `{"i64":"-3"}`, &pb.KnownTypes{I64: &wpb.Int64Value{Value: -3}}}, - {"UInt64Value", Unmarshaler{}, `{"u64":"3"}`, &pb.KnownTypes{U64: &wpb.UInt64Value{Value: 3}}}, - {"Int32Value", Unmarshaler{}, `{"i32":-4}`, &pb.KnownTypes{I32: &wpb.Int32Value{Value: -4}}}, - {"UInt32Value", Unmarshaler{}, `{"u32":4}`, &pb.KnownTypes{U32: &wpb.UInt32Value{Value: 4}}}, - {"BoolValue", Unmarshaler{}, `{"bool":true}`, &pb.KnownTypes{Bool: &wpb.BoolValue{Value: true}}}, - {"StringValue", Unmarshaler{}, `{"str":"plush"}`, &pb.KnownTypes{Str: &wpb.StringValue{Value: "plush"}}}, - {"BytesValue", Unmarshaler{}, `{"bytes":"d293"}`, &pb.KnownTypes{Bytes: &wpb.BytesValue{Value: []byte("wow")}}}, - // `null` is also a permissible value. Let's just test one. - {"null DoubleValue", Unmarshaler{}, `{"dbl":null}`, &pb.KnownTypes{Dbl: &wpb.DoubleValue{}}}, + {"unquoted int64 object", `{"o_int64":-314}`, &pb.Simple{OInt64: proto.Int64(-314)}}, + {"unquoted uint64 object", `{"o_uint64":123}`, &pb.Simple{OUint64: proto.Uint64(123)}}, + {"map", `{"nummy":{"1":2,"3":4}}`, &pb.Mappy{Nummy: map[int64]int32{1: 2, 3: 4}}}, + {"map", `{"strry":{"\"one\"":"two","three":"four"}}`, &pb.Mappy{Strry: map[string]string{`"one"`: "two", "three": "four"}}}, + {"map", `{"objjy":{"1":{"dub":1}}}`, &pb.Mappy{Objjy: map[int32]*pb.Simple3{1: &pb.Simple3{Dub: 1}}}}, + {"oneof", `{"salary":31000}`, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_Salary{31000}}}, } func TestUnmarshaling(t *testing.T) { @@ -491,9 +356,9 @@ func TestUnmarshaling(t *testing.T) { // Make a new instance of the type of our expected object. p := reflect.New(reflect.TypeOf(tt.pb).Elem()).Interface().(proto.Message) - err := tt.unmarshaler.Unmarshal(strings.NewReader(tt.json), p) + err := UnmarshalString(tt.json, p) if err != nil { - t.Errorf("%s: %v", tt.desc, err) + t.Error(err) continue } @@ -506,42 +371,6 @@ func TestUnmarshaling(t *testing.T) { } } -func TestUnmarshalNext(t *testing.T) { - // We only need to check against a few, not all of them. - tests := unmarshalingTests[:5] - - // Create a buffer with many concatenated JSON objects. - var b bytes.Buffer - for _, tt := range tests { - b.WriteString(tt.json) - } - - dec := json.NewDecoder(&b) - for _, tt := range tests { - // Make a new instance of the type of our expected object. - p := reflect.New(reflect.TypeOf(tt.pb).Elem()).Interface().(proto.Message) - - err := tt.unmarshaler.UnmarshalNext(dec, p) - if err != nil { - t.Errorf("%s: %v", tt.desc, err) - continue - } - - // For easier diffs, compare text strings of the protos. - exp := proto.MarshalTextString(tt.pb) - act := proto.MarshalTextString(p) - if string(exp) != string(act) { - t.Errorf("%s: got [%s] want [%s]", tt.desc, act, exp) - } - } - - p := &pb.Simple{} - err := new(Unmarshaler).UnmarshalNext(dec, p) - if err != io.EOF { - t.Errorf("eof: got %v, expected io.EOF", err) - } -} - var unmarshalingShouldError = []struct { desc string in string @@ -549,7 +378,6 @@ var unmarshalingShouldError = []struct { }{ {"a value", "666", new(pb.Simple)}, {"gibberish", "{adskja123;l23=-=", new(pb.Simple)}, - {"unknown field", `{"unknown": "foo"}`, new(pb.Simple)}, {"unknown enum name", `{"hilarity":"DAVE"}`, new(proto3pb.Message)}, } diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/Makefile b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/Makefile index eeda8ae53..e53e6a690 100644 --- a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/Makefile +++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/Makefile @@ -30,4 +30,4 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. regenerate: - protoc --go_out=Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any,Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration,Mgoogle/protobuf/struct.proto=github.com/golang/protobuf/ptypes/struct,Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp,Mgoogle/protobuf/wrappers.proto=github.com/golang/protobuf/ptypes/wrappers:. *.proto + protoc --go_out=. *.proto diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.pb.go b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.pb.go index d6ff6413f..5548ae4ca 100644 --- a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.pb.go +++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.pb.go @@ -19,7 +19,6 @@ It has these top-level messages: MsgWithOneof Real Complex - KnownTypes */ package jsonpb @@ -34,33 +33,7 @@ var _ = math.Inf // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type Numeral int32 - -const ( - Numeral_UNKNOWN Numeral = 0 - Numeral_ARABIC Numeral = 1 - Numeral_ROMAN Numeral = 2 -) - -var Numeral_name = map[int32]string{ - 0: "UNKNOWN", - 1: "ARABIC", - 2: "ROMAN", -} -var Numeral_value = map[string]int32{ - "UNKNOWN": 0, - "ARABIC": 1, - "ROMAN": 2, -} - -func (x Numeral) String() string { - return proto.EnumName(Numeral_name, int32(x)) -} -func (Numeral) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +const _ = proto.ProtoPackageIsVersion1 type Simple3 struct { Dub float64 `protobuf:"fixed64,1,opt,name=dub" json:"dub,omitempty"` @@ -71,24 +44,12 @@ func (m *Simple3) String() string { return proto.CompactTextString(m) func (*Simple3) ProtoMessage() {} func (*Simple3) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (m *Simple3) GetDub() float64 { - if m != nil { - return m.Dub - } - return 0 -} - type Mappy struct { - Nummy map[int64]int32 `protobuf:"bytes,1,rep,name=nummy" json:"nummy,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` - Strry map[string]string `protobuf:"bytes,2,rep,name=strry" json:"strry,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - Objjy map[int32]*Simple3 `protobuf:"bytes,3,rep,name=objjy" json:"objjy,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - Buggy map[int64]string `protobuf:"bytes,4,rep,name=buggy" json:"buggy,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - Booly map[bool]bool `protobuf:"bytes,5,rep,name=booly" json:"booly,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` - Enumy map[string]Numeral `protobuf:"bytes,6,rep,name=enumy" json:"enumy,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=jsonpb.Numeral"` - S32Booly map[int32]bool `protobuf:"bytes,7,rep,name=s32booly" json:"s32booly,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` - S64Booly map[int64]bool `protobuf:"bytes,8,rep,name=s64booly" json:"s64booly,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` - U32Booly map[uint32]bool `protobuf:"bytes,9,rep,name=u32booly" json:"u32booly,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` - U64Booly map[uint64]bool `protobuf:"bytes,10,rep,name=u64booly" json:"u64booly,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` + Nummy map[int64]int32 `protobuf:"bytes,1,rep,name=nummy" json:"nummy,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` + Strry map[string]string `protobuf:"bytes,2,rep,name=strry" json:"strry,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Objjy map[int32]*Simple3 `protobuf:"bytes,3,rep,name=objjy" json:"objjy,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Buggy map[int64]string `protobuf:"bytes,4,rep,name=buggy" json:"buggy,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Booly map[bool]bool `protobuf:"bytes,5,rep,name=booly" json:"booly,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` } func (m *Mappy) Reset() { *m = Mappy{} } @@ -131,77 +92,28 @@ func (m *Mappy) GetBooly() map[bool]bool { return nil } -func (m *Mappy) GetEnumy() map[string]Numeral { - if m != nil { - return m.Enumy - } - return nil -} - -func (m *Mappy) GetS32Booly() map[int32]bool { - if m != nil { - return m.S32Booly - } - return nil -} - -func (m *Mappy) GetS64Booly() map[int64]bool { - if m != nil { - return m.S64Booly - } - return nil -} - -func (m *Mappy) GetU32Booly() map[uint32]bool { - if m != nil { - return m.U32Booly - } - return nil -} - -func (m *Mappy) GetU64Booly() map[uint64]bool { - if m != nil { - return m.U64Booly - } - return nil -} - func init() { proto.RegisterType((*Simple3)(nil), "jsonpb.Simple3") proto.RegisterType((*Mappy)(nil), "jsonpb.Mappy") - proto.RegisterEnum("jsonpb.Numeral", Numeral_name, Numeral_value) } -func init() { proto.RegisterFile("more_test_objects.proto", fileDescriptor0) } - var fileDescriptor0 = []byte{ - // 444 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x94, 0xc1, 0x6b, 0xdb, 0x30, - 0x14, 0x87, 0xe7, 0xa4, 0x4e, 0xec, 0x17, 0xba, 0x19, 0x31, 0x98, 0x58, 0x2f, 0xa1, 0x30, 0x08, - 0x83, 0xf9, 0x90, 0x8c, 0xad, 0x6c, 0xa7, 0x74, 0xf4, 0x50, 0x46, 0x1d, 0x70, 0x09, 0x3b, 0x96, - 0x78, 0x13, 0x65, 0x9e, 0x6d, 0x19, 0xdb, 0x1a, 0xe8, 0x8f, 0x1f, 0x8c, 0x27, 0xcb, 0xb5, 0x6c, - 0x14, 0xd2, 0x9b, 0xcc, 0xef, 0xfb, 0xf2, 0x9e, 0xf4, 0x1e, 0x81, 0x37, 0x39, 0xaf, 0xd8, 0x43, - 0xc3, 0xea, 0xe6, 0x81, 0x27, 0x29, 0xfb, 0xd9, 0xd4, 0x61, 0x59, 0xf1, 0x86, 0x93, 0x59, 0x5a, - 0xf3, 0xa2, 0x4c, 0x2e, 0x2f, 0x60, 0x7e, 0xff, 0x3b, 0x2f, 0x33, 0xb6, 0x21, 0x01, 0x4c, 0x7f, - 0x89, 0x84, 0x3a, 0x4b, 0x67, 0xe5, 0xc4, 0x78, 0xbc, 0xfc, 0xe7, 0x81, 0x7b, 0x77, 0x28, 0x4b, - 0x49, 0x42, 0x70, 0x0b, 0x91, 0xe7, 0x92, 0x3a, 0xcb, 0xe9, 0x6a, 0xb1, 0xa6, 0x61, 0xab, 0x87, - 0x2a, 0x0d, 0x23, 0x8c, 0x6e, 0x8a, 0xa6, 0x92, 0x71, 0x8b, 0x21, 0x5f, 0x37, 0x55, 0x25, 0xe9, - 0xc4, 0xc6, 0xdf, 0x63, 0xa4, 0x79, 0x85, 0x21, 0xcf, 0x93, 0x34, 0x95, 0x74, 0x6a, 0xe3, 0x77, - 0x18, 0x69, 0x5e, 0x61, 0xc8, 0x27, 0xe2, 0xf1, 0x51, 0xd2, 0x33, 0x1b, 0x7f, 0x8d, 0x91, 0xe6, - 0x15, 0xa6, 0x78, 0xce, 0x33, 0x49, 0x5d, 0x2b, 0x8f, 0x51, 0xc7, 0xe3, 0x19, 0x79, 0x56, 0x88, - 0x5c, 0xd2, 0x99, 0x8d, 0xbf, 0xc1, 0x48, 0xf3, 0x0a, 0x23, 0x9f, 0xc1, 0xab, 0x37, 0xeb, 0xb6, - 0xc4, 0x5c, 0x29, 0x17, 0xa3, 0x2b, 0xeb, 0xb4, 0xb5, 0x9e, 0x60, 0x25, 0x7e, 0xfa, 0xd8, 0x8a, - 0x9e, 0x55, 0xd4, 0x69, 0x27, 0xea, 0x4f, 0x14, 0x45, 0x57, 0xd1, 0xb7, 0x89, 0xfb, 0x61, 0x45, - 0x61, 0x54, 0x14, 0x5d, 0x45, 0xb0, 0x8a, 0xc3, 0x8a, 0x1d, 0xfc, 0xf6, 0x0a, 0xa0, 0x1f, 0x34, - 0x6e, 0xcb, 0x1f, 0x26, 0xd5, 0xb6, 0x4c, 0x63, 0x3c, 0x92, 0xd7, 0xe0, 0xfe, 0x3d, 0x64, 0x82, - 0xd1, 0xc9, 0xd2, 0x59, 0xb9, 0x71, 0xfb, 0xf1, 0x65, 0x72, 0xe5, 0xa0, 0xd9, 0x8f, 0xdc, 0x34, - 0x7d, 0x8b, 0xe9, 0x9b, 0xe6, 0x2d, 0x40, 0x3f, 0x7c, 0xd3, 0x74, 0x5b, 0xf3, 0x9d, 0x69, 0x2e, - 0xd6, 0xaf, 0xba, 0x9b, 0xe8, 0x9d, 0x1e, 0x35, 0xd1, 0xef, 0xc5, 0xa9, 0xf6, 0xfd, 0xb1, 0xf9, - 0xf4, 0x20, 0xa6, 0xe9, 0x59, 0x4c, 0x6f, 0xd4, 0x7e, 0xbf, 0x2b, 0x96, 0x8b, 0x0f, 0xda, 0x7f, - 0xd9, 0xb7, 0x1f, 0x89, 0x9c, 0x55, 0x87, 0xcc, 0xfc, 0xa9, 0xaf, 0x70, 0x3e, 0xd8, 0x21, 0xcb, - 0x63, 0x1c, 0xef, 0x03, 0x65, 0x73, 0xaa, 0xa7, 0xae, 0x3f, 0x96, 0xf7, 0xc7, 0x2a, 0x9f, 0x3f, - 0x47, 0x3e, 0x56, 0xf9, 0xec, 0x84, 0xfc, 0xfe, 0x03, 0xcc, 0xf5, 0x4b, 0x90, 0x05, 0xcc, 0xf7, - 0xd1, 0xf7, 0x68, 0xf7, 0x23, 0x0a, 0x5e, 0x10, 0x80, 0xd9, 0x36, 0xde, 0x5e, 0xdf, 0x7e, 0x0b, - 0x1c, 0xe2, 0x83, 0x1b, 0xef, 0xee, 0xb6, 0x51, 0x30, 0x49, 0x66, 0xea, 0xaf, 0x6d, 0xf3, 0x3f, - 0x00, 0x00, 0xff, 0xff, 0xa2, 0x4b, 0xe1, 0x77, 0xf5, 0x04, 0x00, 0x00, + // 261 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0xd1, 0xc1, 0x4a, 0xc3, 0x30, + 0x1c, 0x06, 0x70, 0xb2, 0x98, 0xb9, 0xfe, 0x8b, 0x08, 0x39, 0x68, 0xf0, 0x20, 0xb2, 0x8b, 0x3d, + 0x48, 0x0f, 0xdb, 0x45, 0x04, 0x2f, 0x82, 0x47, 0xf5, 0xb0, 0x07, 0x18, 0x8b, 0x86, 0x61, 0x6d, + 0x9b, 0x90, 0xa6, 0x42, 0x9e, 0xd1, 0x97, 0xb2, 0x89, 0xae, 0xfe, 0x0b, 0xf1, 0xfc, 0xfd, 0x42, + 0xbe, 0x2f, 0x81, 0xf3, 0x46, 0x5b, 0xb5, 0x75, 0xaa, 0x73, 0x5b, 0x2d, 0x2b, 0xf5, 0xea, 0xba, + 0xd2, 0x58, 0xed, 0x34, 0x9f, 0x57, 0x9d, 0x6e, 0x8d, 0x5c, 0x9e, 0xc1, 0xf1, 0xe6, 0xbd, 0x31, + 0xb5, 0x5a, 0xf3, 0x1c, 0xe8, 0x5b, 0x2f, 0x05, 0xb9, 0x22, 0x05, 0x59, 0x7e, 0x51, 0x60, 0x4f, + 0x3b, 0x63, 0x3c, 0xbf, 0x06, 0xd6, 0xf6, 0x4d, 0xe3, 0x87, 0x80, 0x16, 0xf9, 0x4a, 0x94, 0x3f, + 0x27, 0xcb, 0x98, 0x96, 0xcf, 0x21, 0x7a, 0x6c, 0x9d, 0x8d, 0xb0, 0x73, 0xd6, 0x7a, 0x31, 0x4b, + 0xc1, 0x4d, 0x88, 0x46, 0x38, 0x94, 0xa9, 0xbc, 0xa0, 0x29, 0xf8, 0x12, 0xa2, 0x11, 0xca, 0x7e, + 0xbf, 0xf7, 0xe2, 0x28, 0x05, 0x1f, 0x42, 0xf4, 0x07, 0xb5, 0xae, 0xbd, 0x60, 0x49, 0x18, 0xa2, + 0x08, 0x2f, 0x6e, 0x00, 0x50, 0xe3, 0x61, 0xf1, 0x87, 0xf2, 0x71, 0x31, 0xe5, 0x27, 0xc0, 0x3e, + 0x77, 0x75, 0xaf, 0x86, 0xfa, 0xa4, 0x60, 0x77, 0xb3, 0x5b, 0x12, 0x34, 0xaa, 0x8d, 0x74, 0x36, + 0xd5, 0x59, 0xd4, 0xf7, 0x00, 0xa8, 0x3b, 0xd2, 0x8c, 0x5f, 0x62, 0x9d, 0xaf, 0x4e, 0x0f, 0xfd, + 0x7e, 0x9f, 0xfe, 0x70, 0x19, 0x5a, 0xf4, 0x7f, 0xb5, 0x6c, 0xd4, 0xe3, 0x2c, 0xac, 0x17, 0x53, + 0xbd, 0x08, 0x5a, 0xce, 0xe3, 0xa7, 0xaf, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xd5, 0x3b, 0xe8, + 0xea, 0x0f, 0x02, 0x00, 0x00, } diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto index 43b440e2d..653579163 100644 --- a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto +++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto @@ -37,21 +37,10 @@ message Simple3 { double dub = 1; } -enum Numeral { - UNKNOWN = 0; - ARABIC = 1; - ROMAN = 2; -} - message Mappy { map nummy = 1; map strry = 2; map objjy = 3; map buggy = 4; map booly = 5; - map enumy = 6; - map s32booly = 7; - map s64booly = 8; - map u32booly = 9; - map u64booly = 10; } diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.pb.go b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.pb.go index a5dfcd269..a9f50c37e 100644 --- a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.pb.go +++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.pb.go @@ -7,11 +7,6 @@ package jsonpb import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -import google_protobuf "github.com/golang/protobuf/ptypes/any" -import google_protobuf1 "github.com/golang/protobuf/ptypes/duration" -import google_protobuf2 "github.com/golang/protobuf/ptypes/struct" -import google_protobuf3 "github.com/golang/protobuf/ptypes/timestamp" -import google_protobuf4 "github.com/golang/protobuf/ptypes/wrappers" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -57,17 +52,17 @@ func (Widget_Color) EnumDescriptor() ([]byte, []int) { return fileDescriptor1, [ // Test message for holding primitive types. type Simple struct { - OBool *bool `protobuf:"varint,1,opt,name=o_bool,json=oBool" json:"o_bool,omitempty"` - OInt32 *int32 `protobuf:"varint,2,opt,name=o_int32,json=oInt32" json:"o_int32,omitempty"` - OInt64 *int64 `protobuf:"varint,3,opt,name=o_int64,json=oInt64" json:"o_int64,omitempty"` - OUint32 *uint32 `protobuf:"varint,4,opt,name=o_uint32,json=oUint32" json:"o_uint32,omitempty"` - OUint64 *uint64 `protobuf:"varint,5,opt,name=o_uint64,json=oUint64" json:"o_uint64,omitempty"` - OSint32 *int32 `protobuf:"zigzag32,6,opt,name=o_sint32,json=oSint32" json:"o_sint32,omitempty"` - OSint64 *int64 `protobuf:"zigzag64,7,opt,name=o_sint64,json=oSint64" json:"o_sint64,omitempty"` - OFloat *float32 `protobuf:"fixed32,8,opt,name=o_float,json=oFloat" json:"o_float,omitempty"` - ODouble *float64 `protobuf:"fixed64,9,opt,name=o_double,json=oDouble" json:"o_double,omitempty"` - OString *string `protobuf:"bytes,10,opt,name=o_string,json=oString" json:"o_string,omitempty"` - OBytes []byte `protobuf:"bytes,11,opt,name=o_bytes,json=oBytes" json:"o_bytes,omitempty"` + OBool *bool `protobuf:"varint,1,opt,name=o_bool" json:"o_bool,omitempty"` + OInt32 *int32 `protobuf:"varint,2,opt,name=o_int32" json:"o_int32,omitempty"` + OInt64 *int64 `protobuf:"varint,3,opt,name=o_int64" json:"o_int64,omitempty"` + OUint32 *uint32 `protobuf:"varint,4,opt,name=o_uint32" json:"o_uint32,omitempty"` + OUint64 *uint64 `protobuf:"varint,5,opt,name=o_uint64" json:"o_uint64,omitempty"` + OSint32 *int32 `protobuf:"zigzag32,6,opt,name=o_sint32" json:"o_sint32,omitempty"` + OSint64 *int64 `protobuf:"zigzag64,7,opt,name=o_sint64" json:"o_sint64,omitempty"` + OFloat *float32 `protobuf:"fixed32,8,opt,name=o_float" json:"o_float,omitempty"` + ODouble *float64 `protobuf:"fixed64,9,opt,name=o_double" json:"o_double,omitempty"` + OString *string `protobuf:"bytes,10,opt,name=o_string" json:"o_string,omitempty"` + OBytes []byte `protobuf:"bytes,11,opt,name=o_bytes" json:"o_bytes,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -155,17 +150,17 @@ func (m *Simple) GetOBytes() []byte { // Test message for holding repeated primitives. type Repeats struct { - RBool []bool `protobuf:"varint,1,rep,name=r_bool,json=rBool" json:"r_bool,omitempty"` - RInt32 []int32 `protobuf:"varint,2,rep,name=r_int32,json=rInt32" json:"r_int32,omitempty"` - RInt64 []int64 `protobuf:"varint,3,rep,name=r_int64,json=rInt64" json:"r_int64,omitempty"` - RUint32 []uint32 `protobuf:"varint,4,rep,name=r_uint32,json=rUint32" json:"r_uint32,omitempty"` - RUint64 []uint64 `protobuf:"varint,5,rep,name=r_uint64,json=rUint64" json:"r_uint64,omitempty"` - RSint32 []int32 `protobuf:"zigzag32,6,rep,name=r_sint32,json=rSint32" json:"r_sint32,omitempty"` - RSint64 []int64 `protobuf:"zigzag64,7,rep,name=r_sint64,json=rSint64" json:"r_sint64,omitempty"` - RFloat []float32 `protobuf:"fixed32,8,rep,name=r_float,json=rFloat" json:"r_float,omitempty"` - RDouble []float64 `protobuf:"fixed64,9,rep,name=r_double,json=rDouble" json:"r_double,omitempty"` - RString []string `protobuf:"bytes,10,rep,name=r_string,json=rString" json:"r_string,omitempty"` - RBytes [][]byte `protobuf:"bytes,11,rep,name=r_bytes,json=rBytes" json:"r_bytes,omitempty"` + RBool []bool `protobuf:"varint,1,rep,name=r_bool" json:"r_bool,omitempty"` + RInt32 []int32 `protobuf:"varint,2,rep,name=r_int32" json:"r_int32,omitempty"` + RInt64 []int64 `protobuf:"varint,3,rep,name=r_int64" json:"r_int64,omitempty"` + RUint32 []uint32 `protobuf:"varint,4,rep,name=r_uint32" json:"r_uint32,omitempty"` + RUint64 []uint64 `protobuf:"varint,5,rep,name=r_uint64" json:"r_uint64,omitempty"` + RSint32 []int32 `protobuf:"zigzag32,6,rep,name=r_sint32" json:"r_sint32,omitempty"` + RSint64 []int64 `protobuf:"zigzag64,7,rep,name=r_sint64" json:"r_sint64,omitempty"` + RFloat []float32 `protobuf:"fixed32,8,rep,name=r_float" json:"r_float,omitempty"` + RDouble []float64 `protobuf:"fixed64,9,rep,name=r_double" json:"r_double,omitempty"` + RString []string `protobuf:"bytes,10,rep,name=r_string" json:"r_string,omitempty"` + RBytes [][]byte `protobuf:"bytes,11,rep,name=r_bytes" json:"r_bytes,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -254,11 +249,11 @@ func (m *Repeats) GetRBytes() [][]byte { // Test message for holding enums and nested messages. type Widget struct { Color *Widget_Color `protobuf:"varint,1,opt,name=color,enum=jsonpb.Widget_Color" json:"color,omitempty"` - RColor []Widget_Color `protobuf:"varint,2,rep,name=r_color,json=rColor,enum=jsonpb.Widget_Color" json:"r_color,omitempty"` + RColor []Widget_Color `protobuf:"varint,2,rep,name=r_color,enum=jsonpb.Widget_Color" json:"r_color,omitempty"` Simple *Simple `protobuf:"bytes,10,opt,name=simple" json:"simple,omitempty"` - RSimple []*Simple `protobuf:"bytes,11,rep,name=r_simple,json=rSimple" json:"r_simple,omitempty"` + RSimple []*Simple `protobuf:"bytes,11,rep,name=r_simple" json:"r_simple,omitempty"` Repeats *Repeats `protobuf:"bytes,20,opt,name=repeats" json:"repeats,omitempty"` - RRepeats []*Repeats `protobuf:"bytes,21,rep,name=r_repeats,json=rRepeats" json:"r_repeats,omitempty"` + RRepeats []*Repeats `protobuf:"bytes,21,rep,name=r_repeats" json:"r_repeats,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -310,8 +305,8 @@ func (m *Widget) GetRRepeats() []*Repeats { } type Maps struct { - MInt64Str map[int64]string `protobuf:"bytes,1,rep,name=m_int64_str,json=mInt64Str" json:"m_int64_str,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - MBoolSimple map[bool]*Simple `protobuf:"bytes,2,rep,name=m_bool_simple,json=mBoolSimple" json:"m_bool_simple,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + MInt64Str map[int64]string `protobuf:"bytes,1,rep,name=m_int64_str" json:"m_int64_str,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + MBoolSimple map[bool]*Simple `protobuf:"bytes,2,rep,name=m_bool_simple" json:"m_bool_simple,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` XXX_unrecognized []byte `json:"-"` } @@ -338,8 +333,6 @@ type MsgWithOneof struct { // Types that are valid to be assigned to Union: // *MsgWithOneof_Title // *MsgWithOneof_Salary - // *MsgWithOneof_Country - // *MsgWithOneof_HomeAddress Union isMsgWithOneof_Union `protobuf_oneof:"union"` XXX_unrecognized []byte `json:"-"` } @@ -359,17 +352,9 @@ type MsgWithOneof_Title struct { type MsgWithOneof_Salary struct { Salary int64 `protobuf:"varint,2,opt,name=salary,oneof"` } -type MsgWithOneof_Country struct { - Country string `protobuf:"bytes,3,opt,name=Country,oneof"` -} -type MsgWithOneof_HomeAddress struct { - HomeAddress string `protobuf:"bytes,4,opt,name=home_address,json=homeAddress,oneof"` -} -func (*MsgWithOneof_Title) isMsgWithOneof_Union() {} -func (*MsgWithOneof_Salary) isMsgWithOneof_Union() {} -func (*MsgWithOneof_Country) isMsgWithOneof_Union() {} -func (*MsgWithOneof_HomeAddress) isMsgWithOneof_Union() {} +func (*MsgWithOneof_Title) isMsgWithOneof_Union() {} +func (*MsgWithOneof_Salary) isMsgWithOneof_Union() {} func (m *MsgWithOneof) GetUnion() isMsgWithOneof_Union { if m != nil { @@ -392,27 +377,11 @@ func (m *MsgWithOneof) GetSalary() int64 { return 0 } -func (m *MsgWithOneof) GetCountry() string { - if x, ok := m.GetUnion().(*MsgWithOneof_Country); ok { - return x.Country - } - return "" -} - -func (m *MsgWithOneof) GetHomeAddress() string { - if x, ok := m.GetUnion().(*MsgWithOneof_HomeAddress); ok { - return x.HomeAddress - } - return "" -} - // XXX_OneofFuncs is for the internal use of the proto package. func (*MsgWithOneof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { return _MsgWithOneof_OneofMarshaler, _MsgWithOneof_OneofUnmarshaler, _MsgWithOneof_OneofSizer, []interface{}{ (*MsgWithOneof_Title)(nil), (*MsgWithOneof_Salary)(nil), - (*MsgWithOneof_Country)(nil), - (*MsgWithOneof_HomeAddress)(nil), } } @@ -426,12 +395,6 @@ func _MsgWithOneof_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { case *MsgWithOneof_Salary: b.EncodeVarint(2<<3 | proto.WireVarint) b.EncodeVarint(uint64(x.Salary)) - case *MsgWithOneof_Country: - b.EncodeVarint(3<<3 | proto.WireBytes) - b.EncodeStringBytes(x.Country) - case *MsgWithOneof_HomeAddress: - b.EncodeVarint(4<<3 | proto.WireBytes) - b.EncodeStringBytes(x.HomeAddress) case nil: default: return fmt.Errorf("MsgWithOneof.Union has unexpected type %T", x) @@ -456,20 +419,6 @@ func _MsgWithOneof_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.B x, err := b.DecodeVarint() m.Union = &MsgWithOneof_Salary{int64(x)} return true, err - case 3: // union.Country - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Union = &MsgWithOneof_Country{x} - return true, err - case 4: // union.home_address - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Union = &MsgWithOneof_HomeAddress{x} - return true, err default: return false, nil } @@ -486,14 +435,6 @@ func _MsgWithOneof_OneofSizer(msg proto.Message) (n int) { case *MsgWithOneof_Salary: n += proto.SizeVarint(2<<3 | proto.WireVarint) n += proto.SizeVarint(uint64(x.Salary)) - case *MsgWithOneof_Country: - n += proto.SizeVarint(3<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.Country))) - n += len(x.Country) - case *MsgWithOneof_HomeAddress: - n += proto.SizeVarint(4<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.HomeAddress))) - n += len(x.HomeAddress) case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) @@ -502,9 +443,9 @@ func _MsgWithOneof_OneofSizer(msg proto.Message) (n int) { } type Real struct { - Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *Real) Reset() { *m = Real{} } @@ -519,6 +460,12 @@ var extRange_Real = []proto.ExtensionRange{ func (*Real) ExtensionRangeArray() []proto.ExtensionRange { return extRange_Real } +func (m *Real) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} func (m *Real) GetValue() float64 { if m != nil && m.Value != nil { @@ -528,9 +475,9 @@ func (m *Real) GetValue() float64 { } type Complex struct { - Imaginary *float64 `protobuf:"fixed64,1,opt,name=imaginary" json:"imaginary,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + Imaginary *float64 `protobuf:"fixed64,1,opt,name=imaginary" json:"imaginary,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *Complex) Reset() { *m = Complex{} } @@ -545,6 +492,12 @@ var extRange_Complex = []proto.ExtensionRange{ func (*Complex) ExtensionRangeArray() []proto.ExtensionRange { return extRange_Complex } +func (m *Complex) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} func (m *Complex) GetImaginary() float64 { if m != nil && m.Imaginary != nil { @@ -558,121 +511,7 @@ var E_Complex_RealExtension = &proto.ExtensionDesc{ ExtensionType: (*Complex)(nil), Field: 123, Name: "jsonpb.Complex.real_extension", - Tag: "bytes,123,opt,name=real_extension,json=realExtension", - Filename: "test_objects.proto", -} - -type KnownTypes struct { - An *google_protobuf.Any `protobuf:"bytes,14,opt,name=an" json:"an,omitempty"` - Dur *google_protobuf1.Duration `protobuf:"bytes,1,opt,name=dur" json:"dur,omitempty"` - St *google_protobuf2.Struct `protobuf:"bytes,12,opt,name=st" json:"st,omitempty"` - Ts *google_protobuf3.Timestamp `protobuf:"bytes,2,opt,name=ts" json:"ts,omitempty"` - Dbl *google_protobuf4.DoubleValue `protobuf:"bytes,3,opt,name=dbl" json:"dbl,omitempty"` - Flt *google_protobuf4.FloatValue `protobuf:"bytes,4,opt,name=flt" json:"flt,omitempty"` - I64 *google_protobuf4.Int64Value `protobuf:"bytes,5,opt,name=i64" json:"i64,omitempty"` - U64 *google_protobuf4.UInt64Value `protobuf:"bytes,6,opt,name=u64" json:"u64,omitempty"` - I32 *google_protobuf4.Int32Value `protobuf:"bytes,7,opt,name=i32" json:"i32,omitempty"` - U32 *google_protobuf4.UInt32Value `protobuf:"bytes,8,opt,name=u32" json:"u32,omitempty"` - Bool *google_protobuf4.BoolValue `protobuf:"bytes,9,opt,name=bool" json:"bool,omitempty"` - Str *google_protobuf4.StringValue `protobuf:"bytes,10,opt,name=str" json:"str,omitempty"` - Bytes *google_protobuf4.BytesValue `protobuf:"bytes,11,opt,name=bytes" json:"bytes,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *KnownTypes) Reset() { *m = KnownTypes{} } -func (m *KnownTypes) String() string { return proto.CompactTextString(m) } -func (*KnownTypes) ProtoMessage() {} -func (*KnownTypes) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{7} } - -func (m *KnownTypes) GetAn() *google_protobuf.Any { - if m != nil { - return m.An - } - return nil -} - -func (m *KnownTypes) GetDur() *google_protobuf1.Duration { - if m != nil { - return m.Dur - } - return nil -} - -func (m *KnownTypes) GetSt() *google_protobuf2.Struct { - if m != nil { - return m.St - } - return nil -} - -func (m *KnownTypes) GetTs() *google_protobuf3.Timestamp { - if m != nil { - return m.Ts - } - return nil -} - -func (m *KnownTypes) GetDbl() *google_protobuf4.DoubleValue { - if m != nil { - return m.Dbl - } - return nil -} - -func (m *KnownTypes) GetFlt() *google_protobuf4.FloatValue { - if m != nil { - return m.Flt - } - return nil -} - -func (m *KnownTypes) GetI64() *google_protobuf4.Int64Value { - if m != nil { - return m.I64 - } - return nil -} - -func (m *KnownTypes) GetU64() *google_protobuf4.UInt64Value { - if m != nil { - return m.U64 - } - return nil -} - -func (m *KnownTypes) GetI32() *google_protobuf4.Int32Value { - if m != nil { - return m.I32 - } - return nil -} - -func (m *KnownTypes) GetU32() *google_protobuf4.UInt32Value { - if m != nil { - return m.U32 - } - return nil -} - -func (m *KnownTypes) GetBool() *google_protobuf4.BoolValue { - if m != nil { - return m.Bool - } - return nil -} - -func (m *KnownTypes) GetStr() *google_protobuf4.StringValue { - if m != nil { - return m.Str - } - return nil -} - -func (m *KnownTypes) GetBytes() *google_protobuf4.BytesValue { - if m != nil { - return m.Bytes - } - return nil + Tag: "bytes,123,opt,name=real_extension", } var E_Name = &proto.ExtensionDesc{ @@ -681,7 +520,6 @@ var E_Name = &proto.ExtensionDesc{ Field: 124, Name: "jsonpb.name", Tag: "bytes,124,opt,name=name", - Filename: "test_objects.proto", } func init() { @@ -692,80 +530,49 @@ func init() { proto.RegisterType((*MsgWithOneof)(nil), "jsonpb.MsgWithOneof") proto.RegisterType((*Real)(nil), "jsonpb.Real") proto.RegisterType((*Complex)(nil), "jsonpb.Complex") - proto.RegisterType((*KnownTypes)(nil), "jsonpb.KnownTypes") proto.RegisterEnum("jsonpb.Widget_Color", Widget_Color_name, Widget_Color_value) proto.RegisterExtension(E_Complex_RealExtension) proto.RegisterExtension(E_Name) } -func init() { proto.RegisterFile("test_objects.proto", fileDescriptor1) } - var fileDescriptor1 = []byte{ - // 1054 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x95, 0xdf, 0x72, 0xdb, 0x44, - 0x14, 0xc6, 0x23, 0xc9, 0x96, 0xed, 0x75, 0x12, 0xcc, 0x4e, 0x4a, 0x15, 0x13, 0x40, 0x63, 0x4a, - 0x11, 0x85, 0xba, 0x83, 0xe2, 0xf1, 0x30, 0x85, 0x9b, 0xa4, 0x31, 0x94, 0x81, 0x94, 0x99, 0x4d, - 0x43, 0x2f, 0x3d, 0x72, 0xbc, 0x71, 0x55, 0x64, 0xad, 0x67, 0x77, 0x45, 0xea, 0x81, 0x8b, 0x5c, - 0x73, 0xcd, 0x2b, 0xc0, 0x23, 0xf0, 0x44, 0x3c, 0x48, 0xe7, 0x9c, 0xd5, 0x9f, 0xc4, 0x8e, 0xaf, - 0xe2, 0xb3, 0xe7, 0x3b, 0x5f, 0x56, 0xbf, 0x3d, 0xbb, 0x87, 0x50, 0xcd, 0x95, 0x1e, 0x8b, 0xc9, - 0x1b, 0x7e, 0xa1, 0x55, 0x7f, 0x21, 0x85, 0x16, 0xd4, 0x7d, 0xa3, 0x44, 0xba, 0x98, 0x74, 0xf7, - 0x67, 0x42, 0xcc, 0x12, 0xfe, 0x04, 0x57, 0x27, 0xd9, 0xe5, 0x93, 0x28, 0x5d, 0x1a, 0x49, 0xf7, - 0xe3, 0xd5, 0xd4, 0x34, 0x93, 0x91, 0x8e, 0x45, 0x9a, 0xe7, 0x0f, 0x56, 0xf3, 0x4a, 0xcb, 0xec, - 0x42, 0xe7, 0xd9, 0x4f, 0x56, 0xb3, 0x3a, 0x9e, 0x73, 0xa5, 0xa3, 0xf9, 0x62, 0x93, 0xfd, 0x95, - 0x8c, 0x16, 0x0b, 0x2e, 0xf3, 0x1d, 0xf6, 0xfe, 0xb1, 0x89, 0x7b, 0x16, 0xcf, 0x17, 0x09, 0xa7, - 0xf7, 0x88, 0x2b, 0xc6, 0x13, 0x21, 0x12, 0xcf, 0xf2, 0xad, 0xa0, 0xc9, 0xea, 0xe2, 0x58, 0x88, - 0x84, 0xde, 0x27, 0x0d, 0x31, 0x8e, 0x53, 0x7d, 0x18, 0x7a, 0xb6, 0x6f, 0x05, 0x75, 0xe6, 0x8a, - 0x1f, 0x21, 0x2a, 0x13, 0xc3, 0x81, 0xe7, 0xf8, 0x56, 0xe0, 0x98, 0xc4, 0x70, 0x40, 0xf7, 0x49, - 0x53, 0x8c, 0x33, 0x53, 0x52, 0xf3, 0xad, 0x60, 0x87, 0x35, 0xc4, 0x39, 0x86, 0x55, 0x6a, 0x38, - 0xf0, 0xea, 0xbe, 0x15, 0xd4, 0xf2, 0x54, 0x51, 0xa5, 0x4c, 0x95, 0xeb, 0x5b, 0xc1, 0xfb, 0xac, - 0x21, 0xce, 0x6e, 0x54, 0x29, 0x53, 0xd5, 0xf0, 0xad, 0x80, 0xe6, 0xa9, 0xe1, 0xc0, 0x6c, 0xe2, - 0x32, 0x11, 0x91, 0xf6, 0x9a, 0xbe, 0x15, 0xd8, 0xcc, 0x15, 0xdf, 0x43, 0x64, 0x6a, 0xa6, 0x22, - 0x9b, 0x24, 0xdc, 0x6b, 0xf9, 0x56, 0x60, 0xb1, 0x86, 0x38, 0xc1, 0x30, 0xb7, 0xd3, 0x32, 0x4e, - 0x67, 0x1e, 0xf1, 0xad, 0xa0, 0x05, 0x76, 0x18, 0x1a, 0xbb, 0xc9, 0x52, 0x73, 0xe5, 0xb5, 0x7d, - 0x2b, 0xd8, 0x66, 0xae, 0x38, 0x86, 0xa8, 0xf7, 0xaf, 0x4d, 0x1a, 0x8c, 0x2f, 0x78, 0xa4, 0x15, - 0x80, 0x92, 0x05, 0x28, 0x07, 0x40, 0xc9, 0x02, 0x94, 0x2c, 0x41, 0x39, 0x00, 0x4a, 0x96, 0xa0, - 0x64, 0x09, 0xca, 0x01, 0x50, 0xb2, 0x04, 0x25, 0x2b, 0x50, 0x0e, 0x80, 0x92, 0x15, 0x28, 0x59, - 0x81, 0x72, 0x00, 0x94, 0xac, 0x40, 0xc9, 0x0a, 0x94, 0x03, 0xa0, 0xe4, 0xd9, 0x8d, 0xaa, 0x12, - 0x94, 0x03, 0xa0, 0x64, 0x05, 0x4a, 0x96, 0xa0, 0x1c, 0x00, 0x25, 0x4b, 0x50, 0xb2, 0x02, 0xe5, - 0x00, 0x28, 0x59, 0x81, 0x92, 0x15, 0x28, 0x07, 0x40, 0xc9, 0x0a, 0x94, 0x2c, 0x41, 0x39, 0x00, - 0x4a, 0x1a, 0x50, 0xff, 0xd9, 0xc4, 0x7d, 0x15, 0x4f, 0x67, 0x5c, 0xd3, 0x47, 0xa4, 0x7e, 0x21, - 0x12, 0x21, 0xb1, 0x9f, 0x76, 0xc3, 0xbd, 0xbe, 0xb9, 0x0d, 0x7d, 0x93, 0xee, 0x3f, 0x83, 0x1c, - 0x33, 0x12, 0xfa, 0x18, 0xfc, 0x8c, 0x1a, 0xe0, 0x6d, 0x52, 0xbb, 0x12, 0xff, 0xd2, 0x87, 0xc4, - 0x55, 0xd8, 0xb5, 0x78, 0x80, 0xed, 0x70, 0xb7, 0x50, 0x9b, 0x5e, 0x66, 0x79, 0x96, 0x7e, 0x61, - 0x80, 0xa0, 0x12, 0xf6, 0xb9, 0xae, 0x04, 0x40, 0xb9, 0xb4, 0x21, 0xcd, 0x01, 0x7b, 0x7b, 0xe8, - 0xf9, 0x5e, 0xa1, 0xcc, 0xcf, 0x9d, 0x15, 0x79, 0xfa, 0x15, 0x69, 0xc9, 0x71, 0x21, 0xbe, 0x87, - 0xb6, 0x6b, 0xe2, 0xa6, 0xcc, 0x7f, 0xf5, 0x3e, 0x23, 0x75, 0xb3, 0xe9, 0x06, 0x71, 0xd8, 0xe8, - 0xa4, 0xb3, 0x45, 0x5b, 0xa4, 0xfe, 0x03, 0x1b, 0x8d, 0x5e, 0x74, 0x2c, 0xda, 0x24, 0xb5, 0xe3, - 0x9f, 0xcf, 0x47, 0x1d, 0xbb, 0xf7, 0xb7, 0x4d, 0x6a, 0xa7, 0xd1, 0x42, 0xd1, 0x6f, 0x49, 0x7b, - 0x6e, 0xda, 0x05, 0xd8, 0x63, 0x8f, 0xb5, 0xc3, 0x0f, 0x0b, 0x7f, 0x90, 0xf4, 0x4f, 0xb1, 0x7f, - 0xce, 0xb4, 0x1c, 0xa5, 0x5a, 0x2e, 0x59, 0x6b, 0x5e, 0xc4, 0xf4, 0x88, 0xec, 0xcc, 0xb1, 0x37, - 0x8b, 0xaf, 0xb6, 0xb1, 0xfc, 0xa3, 0xdb, 0xe5, 0xd0, 0xaf, 0xe6, 0xb3, 0x8d, 0x41, 0x7b, 0x5e, - 0xad, 0x74, 0xbf, 0x23, 0xbb, 0xb7, 0xfd, 0x69, 0x87, 0x38, 0xbf, 0xf1, 0x25, 0x1e, 0xa3, 0xc3, - 0xe0, 0x27, 0xdd, 0x23, 0xf5, 0xdf, 0xa3, 0x24, 0xe3, 0xf8, 0x24, 0xb4, 0x98, 0x09, 0x9e, 0xda, - 0xdf, 0x58, 0xdd, 0x17, 0xa4, 0xb3, 0x6a, 0x7f, 0xb3, 0xbe, 0x69, 0xea, 0x1f, 0xdc, 0xac, 0x5f, - 0x3f, 0x94, 0xca, 0xaf, 0xf7, 0x97, 0x45, 0xb6, 0x4f, 0xd5, 0xec, 0x55, 0xac, 0x5f, 0xff, 0x92, - 0x72, 0x71, 0x49, 0x3f, 0x20, 0x75, 0x1d, 0xeb, 0x84, 0xa3, 0x5d, 0xeb, 0xf9, 0x16, 0x33, 0x21, - 0xf5, 0x88, 0xab, 0xa2, 0x24, 0x92, 0x4b, 0xf4, 0x74, 0x9e, 0x6f, 0xb1, 0x3c, 0xa6, 0x5d, 0xd2, - 0x78, 0x26, 0x32, 0xd8, 0x09, 0x3e, 0x54, 0x50, 0x53, 0x2c, 0xd0, 0x4f, 0xc9, 0xf6, 0x6b, 0x31, - 0xe7, 0xe3, 0x68, 0x3a, 0x95, 0x5c, 0x29, 0x7c, 0xaf, 0x40, 0xd0, 0x86, 0xd5, 0x23, 0xb3, 0x78, - 0xdc, 0x20, 0xf5, 0x2c, 0x8d, 0x45, 0xda, 0x7b, 0x48, 0x6a, 0x8c, 0x47, 0x49, 0xf5, 0xf9, 0x16, - 0xbe, 0x2c, 0x26, 0x78, 0xd4, 0x6c, 0x4e, 0x3b, 0xd7, 0xd7, 0xd7, 0xd7, 0x76, 0xef, 0x0a, 0xfe, - 0x23, 0x7c, 0xc9, 0x5b, 0x7a, 0x40, 0x5a, 0xf1, 0x3c, 0x9a, 0xc5, 0x29, 0xec, 0xcc, 0xc8, 0xab, - 0x85, 0xaa, 0x24, 0x3c, 0x21, 0xbb, 0x92, 0x47, 0xc9, 0x98, 0xbf, 0xd5, 0x3c, 0x55, 0xb1, 0x48, - 0xe9, 0x76, 0xd5, 0x52, 0x51, 0xe2, 0xfd, 0x71, 0xbb, 0x27, 0x73, 0x7b, 0xb6, 0x03, 0x45, 0xa3, - 0xa2, 0xa6, 0xf7, 0x7f, 0x8d, 0x90, 0x9f, 0x52, 0x71, 0x95, 0xbe, 0x5c, 0x2e, 0xb8, 0xa2, 0x0f, - 0x88, 0x1d, 0xa5, 0xde, 0x2e, 0x96, 0xee, 0xf5, 0xcd, 0x28, 0xe8, 0x17, 0xa3, 0xa0, 0x7f, 0x94, - 0x2e, 0x99, 0x1d, 0xa5, 0xf4, 0x4b, 0xe2, 0x4c, 0x33, 0x73, 0x4b, 0xdb, 0xe1, 0xfe, 0x9a, 0xec, - 0x24, 0x1f, 0x48, 0x0c, 0x54, 0xf4, 0x73, 0x62, 0x2b, 0xed, 0x6d, 0xa3, 0xf6, 0xfe, 0x9a, 0xf6, - 0x0c, 0x87, 0x13, 0xb3, 0x15, 0xdc, 0x7e, 0x5b, 0xab, 0xfc, 0x7c, 0xbb, 0x6b, 0xc2, 0x97, 0xc5, - 0x9c, 0x62, 0xb6, 0x56, 0xb4, 0x4f, 0x9c, 0xe9, 0x24, 0xc1, 0xd3, 0x69, 0x87, 0x07, 0xeb, 0x3b, - 0xc0, 0xe7, 0xe8, 0x57, 0x80, 0xcc, 0x40, 0x48, 0x1f, 0x13, 0xe7, 0x32, 0xd1, 0x78, 0x58, 0x70, - 0x35, 0x56, 0xf5, 0xf8, 0xb0, 0xe5, 0xf2, 0xcb, 0x44, 0x83, 0x3c, 0xce, 0x07, 0xce, 0x5d, 0x72, - 0x6c, 0xf6, 0x5c, 0x1e, 0x0f, 0x07, 0xb0, 0x9b, 0x6c, 0x38, 0xc0, 0x21, 0x74, 0xd7, 0x6e, 0xce, - 0x6f, 0xea, 0xb3, 0xe1, 0x00, 0xed, 0x0f, 0x43, 0x9c, 0x4c, 0x1b, 0xec, 0x0f, 0xc3, 0xc2, 0xfe, - 0x30, 0x44, 0xfb, 0xc3, 0x10, 0xc7, 0xd5, 0x26, 0xfb, 0x52, 0x9f, 0xa1, 0xbe, 0x86, 0xc3, 0xa6, - 0xb5, 0x01, 0x25, 0xdc, 0x36, 0x23, 0x47, 0x1d, 0xf8, 0xc3, 0xbb, 0x41, 0x36, 0xf8, 0x9b, 0x07, - 0x3c, 0xf7, 0x57, 0x5a, 0xd2, 0xaf, 0x49, 0xbd, 0x9a, 0x78, 0x77, 0x7d, 0x00, 0x3e, 0xec, 0xa6, - 0xc0, 0x28, 0x9f, 0xfa, 0xa4, 0x96, 0x46, 0x73, 0xbe, 0xd2, 0xa2, 0x7f, 0xe2, 0x5b, 0x80, 0x99, - 0x77, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7e, 0xe7, 0x47, 0x52, 0x0e, 0x09, 0x00, 0x00, + // 598 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x93, 0x5f, 0x6b, 0x13, 0x4d, + 0x14, 0xc6, 0xbb, 0x3b, 0xfb, 0xf7, 0xa4, 0x4d, 0xb7, 0x43, 0x5f, 0x58, 0xfa, 0x52, 0x2d, 0x2b, + 0x05, 0xf1, 0x22, 0x94, 0x58, 0x45, 0x72, 0x99, 0x1a, 0xac, 0x60, 0x14, 0x52, 0xa4, 0x57, 0xb2, + 0x6c, 0x9a, 0x69, 0xdc, 0xba, 0xd9, 0x09, 0xb3, 0x13, 0x69, 0xd0, 0x0b, 0xc1, 0x2f, 0xa7, 0xdf, + 0xc3, 0x0f, 0xe2, 0xcc, 0x9c, 0x6c, 0xb6, 0x8d, 0x9a, 0xcb, 0x67, 0x9e, 0xf3, 0xe4, 0xfc, 0xce, + 0x39, 0x0b, 0x54, 0xb2, 0x4a, 0xa6, 0x7c, 0x7c, 0xc3, 0xae, 0x64, 0xd5, 0x99, 0x0b, 0x2e, 0x39, + 0xf5, 0x6e, 0x2a, 0x5e, 0xce, 0xc7, 0xc9, 0x0f, 0x0b, 0xbc, 0x8b, 0x7c, 0x36, 0x2f, 0x18, 0x6d, + 0x83, 0xc7, 0xd3, 0x31, 0xe7, 0x45, 0x6c, 0x1d, 0x59, 0x8f, 0x03, 0xba, 0x0b, 0x3e, 0x4f, 0xf3, + 0x52, 0x3e, 0xed, 0xc6, 0xb6, 0x12, 0xdc, 0xb5, 0xf0, 0xfc, 0x34, 0x26, 0x4a, 0x20, 0x34, 0x82, + 0x80, 0xa7, 0x0b, 0xb4, 0x38, 0x4a, 0xd9, 0x69, 0x14, 0xe5, 0x71, 0x95, 0xe2, 0xa0, 0x52, 0xa1, + 0xc7, 0x53, 0xca, 0x5e, 0xa3, 0x28, 0x8f, 0xaf, 0x14, 0x8a, 0xc1, 0xd7, 0x05, 0xcf, 0x64, 0x1c, + 0x28, 0xc1, 0x46, 0xcb, 0x84, 0x2f, 0xc6, 0x05, 0x8b, 0x43, 0xa5, 0x58, 0xab, 0x22, 0x29, 0xf2, + 0x72, 0x1a, 0x83, 0x52, 0x42, 0x2c, 0x1a, 0x2f, 0x15, 0x5b, 0xdc, 0x52, 0xc2, 0x76, 0xf2, 0xd3, + 0x02, 0x7f, 0xc4, 0xe6, 0x2c, 0x93, 0x95, 0x66, 0x11, 0x35, 0x0b, 0x41, 0x16, 0xb1, 0x66, 0x21, + 0xc8, 0x22, 0xd6, 0x2c, 0x04, 0x59, 0x44, 0xc3, 0x42, 0x90, 0x45, 0x34, 0x2c, 0x04, 0x59, 0x44, + 0xc3, 0x42, 0x90, 0x45, 0x34, 0x2c, 0x04, 0x59, 0xc4, 0x9a, 0x85, 0x20, 0x8b, 0x68, 0x58, 0x08, + 0xb2, 0x88, 0x86, 0x85, 0x20, 0x8b, 0x58, 0xb3, 0x10, 0xc5, 0xf2, 0xdd, 0x06, 0xef, 0x32, 0x9f, + 0x4c, 0x99, 0xa4, 0x8f, 0xc0, 0xbd, 0xe2, 0x05, 0x17, 0x66, 0x2b, 0xed, 0xee, 0x7e, 0x07, 0x37, + 0xd7, 0xc1, 0xe7, 0xce, 0x99, 0x7e, 0xa3, 0xc7, 0x3a, 0x00, 0x6d, 0x9a, 0xef, 0x5f, 0xb6, 0x07, + 0xe0, 0x55, 0x66, 0xd9, 0x66, 0x86, 0xad, 0x6e, 0xbb, 0x76, 0xad, 0x4e, 0xe0, 0x08, 0x71, 0x8c, + 0x43, 0x37, 0xf2, 0x37, 0x87, 0x2f, 0x70, 0xc6, 0xf1, 0xbe, 0x89, 0xd8, 0xad, 0x0d, 0xf5, 0xe8, + 0x13, 0x08, 0x45, 0x5a, 0x7b, 0xfe, 0x33, 0x21, 0x9b, 0x9e, 0xe4, 0x18, 0x5c, 0x6c, 0xc8, 0x07, + 0x32, 0x1a, 0xbc, 0x8c, 0xb6, 0x68, 0x08, 0xee, 0xab, 0xd1, 0x60, 0xf0, 0x36, 0xb2, 0x68, 0x00, + 0x4e, 0xff, 0xcd, 0xfb, 0x41, 0x64, 0x27, 0xbf, 0x2c, 0x70, 0x86, 0xd9, 0xbc, 0xa2, 0x27, 0xd0, + 0x9a, 0xe1, 0xb6, 0xf4, 0xdc, 0xcc, 0x4e, 0x5b, 0xdd, 0xff, 0xeb, 0x54, 0x6d, 0xe9, 0x0c, 0x5f, + 0xeb, 0xe7, 0x0b, 0x29, 0x06, 0xa5, 0x14, 0x4b, 0x7a, 0x0a, 0x3b, 0x33, 0x73, 0x00, 0x35, 0x8e, + 0x6d, 0x6a, 0x0e, 0xef, 0xd7, 0xf4, 0x95, 0x01, 0xc1, 0x4c, 0xd5, 0xc1, 0x09, 0xb4, 0x37, 0x72, + 0x5a, 0x40, 0x3e, 0xb1, 0xa5, 0x99, 0x3d, 0xa1, 0x3b, 0xe0, 0x7e, 0xce, 0x8a, 0x05, 0x33, 0xdf, + 0x43, 0xd8, 0xb3, 0x5f, 0x58, 0x07, 0x7d, 0x88, 0x36, 0x53, 0xee, 0xd6, 0x04, 0xf4, 0xf0, 0x6e, + 0xcd, 0x1f, 0xf3, 0xd4, 0x19, 0x49, 0x0f, 0xb6, 0x87, 0xd5, 0xf4, 0x32, 0x97, 0x1f, 0xdf, 0x95, + 0x8c, 0x5f, 0xab, 0x6b, 0x70, 0x65, 0x2e, 0x55, 0xcf, 0x3a, 0x21, 0x3c, 0xdf, 0x52, 0x07, 0xe3, + 0x55, 0x59, 0x91, 0x89, 0xa5, 0x09, 0x21, 0xe7, 0x5b, 0x7d, 0x1f, 0xdc, 0x45, 0x99, 0xf3, 0x32, + 0x79, 0x08, 0xce, 0x88, 0x65, 0x45, 0xd3, 0x9a, 0xae, 0xb1, 0x9e, 0x04, 0xc1, 0x24, 0xfa, 0xa6, + 0x7e, 0x76, 0xf2, 0x01, 0xfc, 0x33, 0xae, 0xff, 0xea, 0x96, 0xee, 0x41, 0x98, 0xcf, 0xb2, 0x69, + 0x5e, 0xea, 0xa4, 0x0d, 0x5f, 0xf7, 0x19, 0xb4, 0x85, 0x0a, 0x4a, 0xd9, 0xad, 0x64, 0x65, 0xa5, + 0xa2, 0xe9, 0x76, 0xb3, 0xb5, 0xac, 0x88, 0xbf, 0xdc, 0xdf, 0xf6, 0x2a, 0xb3, 0x77, 0x00, 0x4e, + 0x99, 0xcd, 0xd8, 0x86, 0xf9, 0xab, 0x6e, 0xfc, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfb, 0xc2, + 0xb2, 0xf6, 0x78, 0x04, 0x00, 0x00, } diff --git a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto index d1934a074..77f7fba9e 100644 --- a/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto +++ b/vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto @@ -31,12 +31,6 @@ syntax = "proto2"; -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - package jsonpb; // Test message for holding primitive types. @@ -95,8 +89,6 @@ message MsgWithOneof { oneof union { string title = 1; int64 salary = 2; - string Country = 3; - string home_address = 4; } } @@ -116,20 +108,3 @@ message Complex { optional double imaginary = 1; extensions 100 to max; } - -message KnownTypes { - optional google.protobuf.Any an = 14; - optional google.protobuf.Duration dur = 1; - optional google.protobuf.Struct st = 12; - optional google.protobuf.Timestamp ts = 2; - - optional google.protobuf.DoubleValue dbl = 3; - optional google.protobuf.FloatValue flt = 4; - optional google.protobuf.Int64Value i64 = 5; - optional google.protobuf.UInt64Value u64 = 6; - optional google.protobuf.Int32Value i32 = 7; - optional google.protobuf.UInt32Value u32 = 8; - optional google.protobuf.BoolValue bool = 9; - optional google.protobuf.StringValue str = 10; - optional google.protobuf.BytesValue bytes = 11; -} diff --git a/vendor/github.com/golang/protobuf/proto/Makefile b/vendor/github.com/golang/protobuf/proto/Makefile index e2e0651a9..f1f06564a 100644 --- a/vendor/github.com/golang/protobuf/proto/Makefile +++ b/vendor/github.com/golang/protobuf/proto/Makefile @@ -39,5 +39,5 @@ test: install generate-test-pbs generate-test-pbs: make install make -C testdata - protoc --go_out=Mtestdata/test.proto=github.com/golang/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any:. proto3_proto/proto3.proto + protoc --go_out=Mtestdata/test.proto=github.com/golang/protobuf/proto/testdata:. proto3_proto/proto3.proto make diff --git a/vendor/github.com/golang/protobuf/proto/all_test.go b/vendor/github.com/golang/protobuf/proto/all_test.go index 41451a407..f68f913df 100644 --- a/vendor/github.com/golang/protobuf/proto/all_test.go +++ b/vendor/github.com/golang/protobuf/proto/all_test.go @@ -420,7 +420,7 @@ func TestMarshalerEncoding(t *testing.T) { name string m Message want []byte - errType reflect.Type + wantErr error }{ { name: "Marshaler that fails", @@ -428,11 +428,9 @@ func TestMarshalerEncoding(t *testing.T) { err: errors.New("some marshal err"), b: []byte{5, 6, 7}, }, - // Since the Marshal method returned bytes, they should be written to the - // buffer. (For efficiency, we assume that Marshal implementations are - // always correct w.r.t. RequiredNotSetError and output.) - want: []byte{5, 6, 7}, - errType: reflect.TypeOf(errors.New("some marshal err")), + // Since there's an error, nothing should be written to buffer. + want: nil, + wantErr: errors.New("some marshal err"), }, { name: "Marshaler that fails with RequiredNotSetError", @@ -448,37 +446,30 @@ func TestMarshalerEncoding(t *testing.T) { 10, 3, // for &msgWithFakeMarshaler 5, 6, 7, // for &fakeMarshaler }, - errType: reflect.TypeOf(&RequiredNotSetError{}), + wantErr: &RequiredNotSetError{}, }, { name: "Marshaler that succeeds", m: &fakeMarshaler{ b: []byte{0, 1, 2, 3, 4, 127, 255}, }, - want: []byte{0, 1, 2, 3, 4, 127, 255}, + want: []byte{0, 1, 2, 3, 4, 127, 255}, + wantErr: nil, }, } for _, test := range tests { b := NewBuffer(nil) err := b.Marshal(test.m) - if reflect.TypeOf(err) != test.errType { - t.Errorf("%s: got err %T(%v) wanted %T", test.name, err, err, test.errType) + if _, ok := err.(*RequiredNotSetError); ok { + // We're not in package proto, so we can only assert the type in this case. + err = &RequiredNotSetError{} + } + if !reflect.DeepEqual(test.wantErr, err) { + t.Errorf("%s: got err %v wanted %v", test.name, err, test.wantErr) } if !reflect.DeepEqual(test.want, b.Bytes()) { t.Errorf("%s: got bytes %v wanted %v", test.name, b.Bytes(), test.want) } - if size := Size(test.m); size != len(b.Bytes()) { - t.Errorf("%s: Size(_) = %v, but marshaled to %v bytes", test.name, size, len(b.Bytes())) - } - - m, mErr := Marshal(test.m) - if !bytes.Equal(b.Bytes(), m) { - t.Errorf("%s: Marshal returned %v, but (*Buffer).Marshal wrote %v", test.name, m, b.Bytes()) - } - if !reflect.DeepEqual(err, mErr) { - t.Errorf("%s: Marshal err = %q, but (*Buffer).Marshal returned %q", - test.name, fmt.Sprint(mErr), fmt.Sprint(err)) - } } } @@ -1311,7 +1302,7 @@ func TestEnum(t *testing.T) { // We don't care what the value actually is, just as long as it doesn't crash. func TestPrintingNilEnumFields(t *testing.T) { pb := new(GoEnum) - _ = fmt.Sprintf("%+v", pb) + fmt.Sprintf("%+v", pb) } // Verify that absent required fields cause Marshal/Unmarshal to return errors. @@ -1320,7 +1311,7 @@ func TestRequiredFieldEnforcement(t *testing.T) { _, err := Marshal(pb) if err == nil { t.Error("marshal: expected error, got nil") - } else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Label") { + } else if strings.Index(err.Error(), "Label") < 0 { t.Errorf("marshal: bad error type: %v", err) } @@ -1331,42 +1322,16 @@ func TestRequiredFieldEnforcement(t *testing.T) { err = Unmarshal(buf, pb) if err == nil { t.Error("unmarshal: expected error, got nil") - } else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "{Unknown}") { - t.Errorf("unmarshal: bad error type: %v", err) - } -} - -// Verify that absent required fields in groups cause Marshal/Unmarshal to return errors. -func TestRequiredFieldEnforcementGroups(t *testing.T) { - pb := &GoTestRequiredGroupField{Group: &GoTestRequiredGroupField_Group{}} - if _, err := Marshal(pb); err == nil { - t.Error("marshal: expected error, got nil") - } else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Group.Field") { - t.Errorf("marshal: bad error type: %v", err) - } - - buf := []byte{11, 12} - if err := Unmarshal(buf, pb); err == nil { - t.Error("unmarshal: expected error, got nil") - } else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Group.{Unknown}") { + } else if strings.Index(err.Error(), "{Unknown}") < 0 { t.Errorf("unmarshal: bad error type: %v", err) } } func TestTypedNilMarshal(t *testing.T) { // A typed nil should return ErrNil and not crash. - { - var m *GoEnum - if _, err := Marshal(m); err != ErrNil { - t.Errorf("Marshal(%#v): got %v, want ErrNil", m, err) - } - } - - { - m := &Communique{Union: &Communique_Msg{nil}} - if _, err := Marshal(m); err == nil || err == ErrNil { - t.Errorf("Marshal(%#v): got %v, want errOneofHasNil", m, err) - } + _, err := Marshal((*GoEnum)(nil)) + if err != ErrNil { + t.Errorf("Marshal: got err %v, want ErrNil", err) } } @@ -1982,88 +1947,14 @@ func TestMapFieldRoundTrips(t *testing.T) { } func TestMapFieldWithNil(t *testing.T) { - m1 := &MessageWithMap{ + m := &MessageWithMap{ MsgMapping: map[int64]*FloatingPoint{ 1: nil, }, } - b, err := Marshal(m1) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - m2 := new(MessageWithMap) - if err := Unmarshal(b, m2); err != nil { - t.Fatalf("Unmarshal: %v, got these bytes: %v", err, b) - } - if v, ok := m2.MsgMapping[1]; !ok { - t.Error("msg_mapping[1] not present") - } else if v != nil { - t.Errorf("msg_mapping[1] not nil: %v", v) - } -} - -func TestMapFieldWithNilBytes(t *testing.T) { - m1 := &MessageWithMap{ - ByteMapping: map[bool][]byte{ - false: []byte{}, - true: nil, - }, - } - n := Size(m1) - b, err := Marshal(m1) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - if n != len(b) { - t.Errorf("Size(m1) = %d; want len(Marshal(m1)) = %d", n, len(b)) - } - m2 := new(MessageWithMap) - if err := Unmarshal(b, m2); err != nil { - t.Fatalf("Unmarshal: %v, got these bytes: %v", err, b) - } - if v, ok := m2.ByteMapping[false]; !ok { - t.Error("byte_mapping[false] not present") - } else if len(v) != 0 { - t.Errorf("byte_mapping[false] not empty: %#v", v) - } - if v, ok := m2.ByteMapping[true]; !ok { - t.Error("byte_mapping[true] not present") - } else if len(v) != 0 { - t.Errorf("byte_mapping[true] not empty: %#v", v) - } -} - -func TestDecodeMapFieldMissingKey(t *testing.T) { - b := []byte{ - 0x0A, 0x03, // message, tag 1 (name_mapping), of length 3 bytes - // no key - 0x12, 0x01, 0x6D, // string value of length 1 byte, value "m" - } - got := &MessageWithMap{} - err := Unmarshal(b, got) - if err != nil { - t.Fatalf("failed to marshal map with missing key: %v", err) - } - want := &MessageWithMap{NameMapping: map[int32]string{0: "m"}} - if !Equal(got, want) { - t.Errorf("Unmarshaled map with no key was not as expected. got: %v, want %v", got, want) - } -} - -func TestDecodeMapFieldMissingValue(t *testing.T) { - b := []byte{ - 0x0A, 0x02, // message, tag 1 (name_mapping), of length 2 bytes - 0x08, 0x01, // varint key, value 1 - // no value - } - got := &MessageWithMap{} - err := Unmarshal(b, got) - if err != nil { - t.Fatalf("failed to marshal map with missing value: %v", err) - } - want := &MessageWithMap{NameMapping: map[int32]string{1: ""}} - if !Equal(got, want) { - t.Errorf("Unmarshaled map with no value was not as expected. got: %v, want %v", got, want) + b, err := Marshal(m) + if err == nil { + t.Fatalf("Marshal of bad map should have failed, got these bytes: %v", b) } } diff --git a/vendor/github.com/golang/protobuf/proto/any_test.go b/vendor/github.com/golang/protobuf/proto/any_test.go deleted file mode 100644 index 1a3c22ed4..000000000 --- a/vendor/github.com/golang/protobuf/proto/any_test.go +++ /dev/null @@ -1,300 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2016 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package proto_test - -import ( - "strings" - "testing" - - "github.com/golang/protobuf/proto" - - pb "github.com/golang/protobuf/proto/proto3_proto" - testpb "github.com/golang/protobuf/proto/testdata" - anypb "github.com/golang/protobuf/ptypes/any" -) - -var ( - expandedMarshaler = proto.TextMarshaler{ExpandAny: true} - expandedCompactMarshaler = proto.TextMarshaler{Compact: true, ExpandAny: true} -) - -// anyEqual reports whether two messages which may be google.protobuf.Any or may -// contain google.protobuf.Any fields are equal. We can't use proto.Equal for -// comparison, because semantically equivalent messages may be marshaled to -// binary in different tag order. Instead, trust that TextMarshaler with -// ExpandAny option works and compare the text marshaling results. -func anyEqual(got, want proto.Message) bool { - // if messages are proto.Equal, no need to marshal. - if proto.Equal(got, want) { - return true - } - g := expandedMarshaler.Text(got) - w := expandedMarshaler.Text(want) - return g == w -} - -type golden struct { - m proto.Message - t, c string -} - -var goldenMessages = makeGolden() - -func makeGolden() []golden { - nested := &pb.Nested{Bunny: "Monty"} - nb, err := proto.Marshal(nested) - if err != nil { - panic(err) - } - m1 := &pb.Message{ - Name: "David", - ResultCount: 47, - Anything: &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(nested), Value: nb}, - } - m2 := &pb.Message{ - Name: "David", - ResultCount: 47, - Anything: &anypb.Any{TypeUrl: "http://[::1]/type.googleapis.com/" + proto.MessageName(nested), Value: nb}, - } - m3 := &pb.Message{ - Name: "David", - ResultCount: 47, - Anything: &anypb.Any{TypeUrl: `type.googleapis.com/"/` + proto.MessageName(nested), Value: nb}, - } - m4 := &pb.Message{ - Name: "David", - ResultCount: 47, - Anything: &anypb.Any{TypeUrl: "type.googleapis.com/a/path/" + proto.MessageName(nested), Value: nb}, - } - m5 := &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(nested), Value: nb} - - any1 := &testpb.MyMessage{Count: proto.Int32(47), Name: proto.String("David")} - proto.SetExtension(any1, testpb.E_Ext_More, &testpb.Ext{Data: proto.String("foo")}) - proto.SetExtension(any1, testpb.E_Ext_Text, proto.String("bar")) - any1b, err := proto.Marshal(any1) - if err != nil { - panic(err) - } - any2 := &testpb.MyMessage{Count: proto.Int32(42), Bikeshed: testpb.MyMessage_GREEN.Enum(), RepBytes: [][]byte{[]byte("roboto")}} - proto.SetExtension(any2, testpb.E_Ext_More, &testpb.Ext{Data: proto.String("baz")}) - any2b, err := proto.Marshal(any2) - if err != nil { - panic(err) - } - m6 := &pb.Message{ - Name: "David", - ResultCount: 47, - Anything: &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(any1), Value: any1b}, - ManyThings: []*anypb.Any{ - &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(any2), Value: any2b}, - &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(any1), Value: any1b}, - }, - } - - const ( - m1Golden = ` -name: "David" -result_count: 47 -anything: < - [type.googleapis.com/proto3_proto.Nested]: < - bunny: "Monty" - > -> -` - m2Golden = ` -name: "David" -result_count: 47 -anything: < - ["http://[::1]/type.googleapis.com/proto3_proto.Nested"]: < - bunny: "Monty" - > -> -` - m3Golden = ` -name: "David" -result_count: 47 -anything: < - ["type.googleapis.com/\"/proto3_proto.Nested"]: < - bunny: "Monty" - > -> -` - m4Golden = ` -name: "David" -result_count: 47 -anything: < - [type.googleapis.com/a/path/proto3_proto.Nested]: < - bunny: "Monty" - > -> -` - m5Golden = ` -[type.googleapis.com/proto3_proto.Nested]: < - bunny: "Monty" -> -` - m6Golden = ` -name: "David" -result_count: 47 -anything: < - [type.googleapis.com/testdata.MyMessage]: < - count: 47 - name: "David" - [testdata.Ext.more]: < - data: "foo" - > - [testdata.Ext.text]: "bar" - > -> -many_things: < - [type.googleapis.com/testdata.MyMessage]: < - count: 42 - bikeshed: GREEN - rep_bytes: "roboto" - [testdata.Ext.more]: < - data: "baz" - > - > -> -many_things: < - [type.googleapis.com/testdata.MyMessage]: < - count: 47 - name: "David" - [testdata.Ext.more]: < - data: "foo" - > - [testdata.Ext.text]: "bar" - > -> -` - ) - return []golden{ - {m1, strings.TrimSpace(m1Golden) + "\n", strings.TrimSpace(compact(m1Golden)) + " "}, - {m2, strings.TrimSpace(m2Golden) + "\n", strings.TrimSpace(compact(m2Golden)) + " "}, - {m3, strings.TrimSpace(m3Golden) + "\n", strings.TrimSpace(compact(m3Golden)) + " "}, - {m4, strings.TrimSpace(m4Golden) + "\n", strings.TrimSpace(compact(m4Golden)) + " "}, - {m5, strings.TrimSpace(m5Golden) + "\n", strings.TrimSpace(compact(m5Golden)) + " "}, - {m6, strings.TrimSpace(m6Golden) + "\n", strings.TrimSpace(compact(m6Golden)) + " "}, - } -} - -func TestMarshalGolden(t *testing.T) { - for _, tt := range goldenMessages { - if got, want := expandedMarshaler.Text(tt.m), tt.t; got != want { - t.Errorf("message %v: got:\n%s\nwant:\n%s", tt.m, got, want) - } - if got, want := expandedCompactMarshaler.Text(tt.m), tt.c; got != want { - t.Errorf("message %v: got:\n`%s`\nwant:\n`%s`", tt.m, got, want) - } - } -} - -func TestUnmarshalGolden(t *testing.T) { - for _, tt := range goldenMessages { - want := tt.m - got := proto.Clone(tt.m) - got.Reset() - if err := proto.UnmarshalText(tt.t, got); err != nil { - t.Errorf("failed to unmarshal\n%s\nerror: %v", tt.t, err) - } - if !anyEqual(got, want) { - t.Errorf("message:\n%s\ngot:\n%s\nwant:\n%s", tt.t, got, want) - } - got.Reset() - if err := proto.UnmarshalText(tt.c, got); err != nil { - t.Errorf("failed to unmarshal\n%s\nerror: %v", tt.c, err) - } - if !anyEqual(got, want) { - t.Errorf("message:\n%s\ngot:\n%s\nwant:\n%s", tt.c, got, want) - } - } -} - -func TestMarshalUnknownAny(t *testing.T) { - m := &pb.Message{ - Anything: &anypb.Any{ - TypeUrl: "foo", - Value: []byte("bar"), - }, - } - want := `anything: < - type_url: "foo" - value: "bar" -> -` - got := expandedMarshaler.Text(m) - if got != want { - t.Errorf("got\n`%s`\nwant\n`%s`", got, want) - } -} - -func TestAmbiguousAny(t *testing.T) { - pb := &anypb.Any{} - err := proto.UnmarshalText(` - type_url: "ttt/proto3_proto.Nested" - value: "\n\x05Monty" - `, pb) - t.Logf("result: %v (error: %v)", expandedMarshaler.Text(pb), err) - if err != nil { - t.Errorf("failed to parse ambiguous Any message: %v", err) - } -} - -func TestUnmarshalOverwriteAny(t *testing.T) { - pb := &anypb.Any{} - err := proto.UnmarshalText(` - [type.googleapis.com/a/path/proto3_proto.Nested]: < - bunny: "Monty" - > - [type.googleapis.com/a/path/proto3_proto.Nested]: < - bunny: "Rabbit of Caerbannog" - > - `, pb) - want := `line 7: Any message unpacked multiple times, or "type_url" already set` - if err.Error() != want { - t.Errorf("incorrect error.\nHave: %v\nWant: %v", err.Error(), want) - } -} - -func TestUnmarshalAnyMixAndMatch(t *testing.T) { - pb := &anypb.Any{} - err := proto.UnmarshalText(` - value: "\n\x05Monty" - [type.googleapis.com/a/path/proto3_proto.Nested]: < - bunny: "Rabbit of Caerbannog" - > - `, pb) - want := `line 5: Any message unpacked multiple times, or "value" already set` - if err.Error() != want { - t.Errorf("incorrect error.\nHave: %v\nWant: %v", err.Error(), want) - } -} diff --git a/vendor/github.com/golang/protobuf/proto/clone.go b/vendor/github.com/golang/protobuf/proto/clone.go index e392575b3..e98ddec98 100644 --- a/vendor/github.com/golang/protobuf/proto/clone.go +++ b/vendor/github.com/golang/protobuf/proto/clone.go @@ -84,15 +84,9 @@ func mergeStruct(out, in reflect.Value) { mergeAny(out.Field(i), in.Field(i), false, sprop.Prop[i]) } - if emIn, ok := extendable(in.Addr().Interface()); ok { - emOut, _ := extendable(out.Addr().Interface()) - mIn, muIn := emIn.extensionsRead() - if mIn != nil { - mOut := emOut.extensionsWrite() - muIn.Lock() - mergeExtension(mOut, mIn) - muIn.Unlock() - } + if emIn, ok := in.Addr().Interface().(extendableProto); ok { + emOut := out.Addr().Interface().(extendableProto) + mergeExtension(emOut.ExtensionMap(), emIn.ExtensionMap()) } uf := in.FieldByName("XXX_unrecognized") diff --git a/vendor/github.com/golang/protobuf/proto/clone_test.go b/vendor/github.com/golang/protobuf/proto/clone_test.go index f607ff49e..76720f18b 100644 --- a/vendor/github.com/golang/protobuf/proto/clone_test.go +++ b/vendor/github.com/golang/protobuf/proto/clone_test.go @@ -195,9 +195,6 @@ var mergeTests = []struct { NameMapping: map[int32]string{6: "Nigel"}, MsgMapping: map[int64]*pb.FloatingPoint{ 0x4001: &pb.FloatingPoint{F: proto.Float64(2.0)}, - 0x4002: &pb.FloatingPoint{ - F: proto.Float64(2.0), - }, }, ByteMapping: map[bool][]byte{true: []byte("wowsa")}, }, @@ -206,12 +203,6 @@ var mergeTests = []struct { 6: "Bruce", // should be overwritten 7: "Andrew", }, - MsgMapping: map[int64]*pb.FloatingPoint{ - 0x4002: &pb.FloatingPoint{ - F: proto.Float64(3.0), - Exact: proto.Bool(true), - }, // the entire message should be overwritten - }, }, want: &pb.MessageWithMap{ NameMapping: map[int32]string{ @@ -220,9 +211,6 @@ var mergeTests = []struct { }, MsgMapping: map[int64]*pb.FloatingPoint{ 0x4001: &pb.FloatingPoint{F: proto.Float64(2.0)}, - 0x4002: &pb.FloatingPoint{ - F: proto.Float64(2.0), - }, }, ByteMapping: map[bool][]byte{true: []byte("wowsa")}, }, @@ -266,27 +254,6 @@ var mergeTests = []struct { Union: &pb.Communique_Name{"Bobby Tables"}, }, }, - { - src: &proto3pb.Message{ - Terrain: map[string]*proto3pb.Nested{ - "kay_a": &proto3pb.Nested{Cute: true}, // replace - "kay_b": &proto3pb.Nested{Bunny: "rabbit"}, // insert - }, - }, - dst: &proto3pb.Message{ - Terrain: map[string]*proto3pb.Nested{ - "kay_a": &proto3pb.Nested{Bunny: "lost"}, // replaced - "kay_c": &proto3pb.Nested{Bunny: "bunny"}, // keep - }, - }, - want: &proto3pb.Message{ - Terrain: map[string]*proto3pb.Nested{ - "kay_a": &proto3pb.Nested{Cute: true}, - "kay_b": &proto3pb.Nested{Bunny: "rabbit"}, - "kay_c": &proto3pb.Nested{Bunny: "bunny"}, - }, - }, - }, } func TestMerge(t *testing.T) { diff --git a/vendor/github.com/golang/protobuf/proto/decode.go b/vendor/github.com/golang/protobuf/proto/decode.go index aa207298f..5810782fd 100644 --- a/vendor/github.com/golang/protobuf/proto/decode.go +++ b/vendor/github.com/golang/protobuf/proto/decode.go @@ -61,6 +61,7 @@ var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for // int32, int64, uint32, uint64, bool, and enum // protocol buffer types. func DecodeVarint(buf []byte) (x uint64, n int) { + // x, n already 0 for shift := uint(0); shift < 64; shift += 7 { if n >= len(buf) { return 0, 0 @@ -77,7 +78,13 @@ func DecodeVarint(buf []byte) (x uint64, n int) { return 0, 0 } -func (p *Buffer) decodeVarintSlow() (x uint64, err error) { +// DecodeVarint reads a varint-encoded integer from the Buffer. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func (p *Buffer) DecodeVarint() (x uint64, err error) { + // x, err already 0 + i := p.index l := len(p.buf) @@ -100,107 +107,6 @@ func (p *Buffer) decodeVarintSlow() (x uint64, err error) { return } -// DecodeVarint reads a varint-encoded integer from the Buffer. -// This is the format for the -// int32, int64, uint32, uint64, bool, and enum -// protocol buffer types. -func (p *Buffer) DecodeVarint() (x uint64, err error) { - i := p.index - buf := p.buf - - if i >= len(buf) { - return 0, io.ErrUnexpectedEOF - } else if buf[i] < 0x80 { - p.index++ - return uint64(buf[i]), nil - } else if len(buf)-i < 10 { - return p.decodeVarintSlow() - } - - var b uint64 - // we already checked the first byte - x = uint64(buf[i]) - 0x80 - i++ - - b = uint64(buf[i]) - i++ - x += b << 7 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 7 - - b = uint64(buf[i]) - i++ - x += b << 14 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 14 - - b = uint64(buf[i]) - i++ - x += b << 21 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 21 - - b = uint64(buf[i]) - i++ - x += b << 28 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 28 - - b = uint64(buf[i]) - i++ - x += b << 35 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 35 - - b = uint64(buf[i]) - i++ - x += b << 42 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 42 - - b = uint64(buf[i]) - i++ - x += b << 49 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 49 - - b = uint64(buf[i]) - i++ - x += b << 56 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 56 - - b = uint64(buf[i]) - i++ - x += b << 63 - if b&0x80 == 0 { - goto done - } - // x -= 0x80 << 63 // Always zero. - - return 0, errOverflow - -done: - p.index = i - return x, nil -} - // DecodeFixed64 reads a 64-bit integer from the Buffer. // This is the format for the // fixed64, sfixed64, and double protocol buffer types. @@ -434,8 +340,6 @@ func (p *Buffer) DecodeGroup(pb Message) error { // Buffer and places the decoded result in pb. If the struct // underlying pb does not match the data in the buffer, the results can be // unpredictable. -// -// Unlike proto.Unmarshal, this does not reset pb before starting to unmarshal. func (p *Buffer) Unmarshal(pb Message) error { // If the object can unmarshal itself, let it. if u, ok := pb.(Unmarshaler); ok { @@ -474,11 +378,6 @@ func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group wire := int(u & 0x7) if wire == WireEndGroup { if is_group { - if required > 0 { - // Not enough information to determine the exact field. - // (See below.) - return &RequiredNotSetError{"{Unknown}"} - } return nil // input is satisfied } return fmt.Errorf("proto: %s: wiretype end group for non-group", st) @@ -491,12 +390,11 @@ func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group if !ok { // Maybe it's an extension? if prop.extendable { - if e, _ := extendable(structPointer_Interface(base, st)); isExtensionField(e, int32(tag)) { + if e := structPointer_Interface(base, st).(extendableProto); isExtensionField(e, int32(tag)) { if err = o.skip(st, tag, wire); err == nil { - extmap := e.extensionsWrite() - ext := extmap[int32(tag)] // may be missing + ext := e.ExtensionMap()[int32(tag)] // may be missing ext.enc = append(ext.enc, o.buf[oi:o.index]...) - extmap[int32(tag)] = ext + e.ExtensionMap()[int32(tag)] = ext } continue } @@ -870,11 +768,10 @@ func (o *Buffer) dec_new_map(p *Properties, base structPointer) error { } } keyelem, valelem := keyptr.Elem(), valptr.Elem() - if !keyelem.IsValid() { - keyelem = reflect.Zero(p.mtype.Key()) - } - if !valelem.IsValid() { - valelem = reflect.Zero(p.mtype.Elem()) + if !keyelem.IsValid() || !valelem.IsValid() { + // We did not decode the key or the value in the map entry. + // Either way, it's an invalid map entry. + return fmt.Errorf("proto: bad map data: missing key/val") } v.SetMapIndex(keyelem, valelem) diff --git a/vendor/github.com/golang/protobuf/proto/decode_test.go b/vendor/github.com/golang/protobuf/proto/decode_test.go deleted file mode 100644 index b1f130449..000000000 --- a/vendor/github.com/golang/protobuf/proto/decode_test.go +++ /dev/null @@ -1,256 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2010 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package proto_test - -import ( - "fmt" - "testing" - - "github.com/golang/protobuf/proto" - tpb "github.com/golang/protobuf/proto/proto3_proto" -) - -var ( - bytesBlackhole []byte - msgBlackhole = new(tpb.Message) -) - -// BenchmarkVarint32ArraySmall shows the performance on an array of small int32 fields (1 and -// 2 bytes long). -func BenchmarkVarint32ArraySmall(b *testing.B) { - for i := uint(1); i <= 10; i++ { - dist := genInt32Dist([7]int{0, 3, 1}, 1<2GB. - ErrTooLarge = errors.New("proto: message encodes to over 2 GB") ) // The fundamental encoders that put bytes on the wire. @@ -82,10 +74,6 @@ var ( const maxVarintBytes = 10 // maximum length of a varint -// maxMarshalSize is the largest allowed size of an encoded protobuf, -// since C++ and Java use signed int32s for the size. -const maxMarshalSize = 1<<31 - 1 - // EncodeVarint returns the varint encoding of x. // This is the format for the // int32, int64, uint32, uint64, bool, and enum @@ -234,6 +222,10 @@ func Marshal(pb Message) ([]byte, error) { } p := NewBuffer(nil) err := p.Marshal(pb) + var state errorState + if err != nil && !state.shouldContinue(err, nil) { + return nil, err + } if p.buf == nil && err == nil { // Return a non-nil slice on success. return []byte{}, nil @@ -262,8 +254,11 @@ func (p *Buffer) Marshal(pb Message) error { // Can the object marshal itself? if m, ok := pb.(Marshaler); ok { data, err := m.Marshal() + if err != nil { + return err + } p.buf = append(p.buf, data...) - return err + return nil } t, base, err := getbase(pb) @@ -275,12 +270,9 @@ func (p *Buffer) Marshal(pb Message) error { } if collectStats { - (stats).Encode++ // Parens are to work around a goimports bug. + stats.Encode++ } - if len(p.buf) > maxMarshalSize { - return ErrTooLarge - } return err } @@ -302,7 +294,7 @@ func Size(pb Message) (n int) { } if collectStats { - (stats).Size++ // Parens are to work around a goimports bug. + stats.Size++ } return @@ -1007,6 +999,7 @@ func size_slice_struct_message(p *Properties, base structPointer) (n int) { if p.isMarshaler { m := structPointer_Interface(structp, p.stype).(Marshaler) data, _ := m.Marshal() + n += len(p.tagcode) n += sizeRawBytes(data) continue } @@ -1065,32 +1058,10 @@ func size_slice_struct_group(p *Properties, base structPointer) (n int) { // Encode an extension map. func (o *Buffer) enc_map(p *Properties, base structPointer) error { - exts := structPointer_ExtMap(base, p.field) - if err := encodeExtensionsMap(*exts); err != nil { - return err - } - - return o.enc_map_body(*exts) -} - -func (o *Buffer) enc_exts(p *Properties, base structPointer) error { - exts := structPointer_Extensions(base, p.field) - - v, mu := exts.extensionsRead() - if v == nil { - return nil - } - - mu.Lock() - defer mu.Unlock() - if err := encodeExtensionsMap(v); err != nil { + v := *structPointer_ExtMap(base, p.field) + if err := encodeExtensionMap(v); err != nil { return err } - - return o.enc_map_body(v) -} - -func (o *Buffer) enc_map_body(v map[int32]Extension) error { // Fast-path for common cases: zero or one extensions. if len(v) <= 1 { for _, e := range v { @@ -1113,13 +1084,8 @@ func (o *Buffer) enc_map_body(v map[int32]Extension) error { } func size_map(p *Properties, base structPointer) int { - v := structPointer_ExtMap(base, p.field) - return extensionsMapSize(*v) -} - -func size_exts(p *Properties, base structPointer) int { - v := structPointer_Extensions(base, p.field) - return extensionsSize(v) + v := *structPointer_ExtMap(base, p.field) + return sizeExtensionMap(v) } // Encode a map field. @@ -1148,7 +1114,7 @@ func (o *Buffer) enc_new_map(p *Properties, base structPointer) error { if err := p.mkeyprop.enc(o, p.mkeyprop, keybase); err != nil { return err } - if err := p.mvalprop.enc(o, p.mvalprop, valbase); err != nil && err != ErrNil { + if err := p.mvalprop.enc(o, p.mvalprop, valbase); err != nil { return err } return nil @@ -1158,6 +1124,11 @@ func (o *Buffer) enc_new_map(p *Properties, base structPointer) error { for _, key := range v.MapKeys() { val := v.MapIndex(key) + // The only illegal map entry values are nil message pointers. + if val.Kind() == reflect.Ptr && val.IsNil() { + return errors.New("proto: map has nil element") + } + keycopy.Set(key) valcopy.Set(val) @@ -1245,18 +1216,13 @@ func (o *Buffer) enc_struct(prop *StructProperties, base structPointer) error { return err } } - if len(o.buf) > maxMarshalSize { - return ErrTooLarge - } } } // Do oneof fields. if prop.oneofMarshaler != nil { m := structPointer_Interface(base, prop.stype).(Message) - if err := prop.oneofMarshaler(m, o); err == ErrNil { - return errOneofHasNil - } else if err != nil { + if err := prop.oneofMarshaler(m, o); err != nil { return err } } @@ -1264,9 +1230,6 @@ func (o *Buffer) enc_struct(prop *StructProperties, base structPointer) error { // Add unrecognized fields at the end. if prop.unrecField.IsValid() { v := *structPointer_Bytes(base, prop.unrecField) - if len(o.buf)+len(v) > maxMarshalSize { - return ErrTooLarge - } if len(v) > 0 { o.buf = append(o.buf, v...) } diff --git a/vendor/github.com/golang/protobuf/proto/encode_test.go b/vendor/github.com/golang/protobuf/proto/encode_test.go deleted file mode 100644 index 0b36a0e9f..000000000 --- a/vendor/github.com/golang/protobuf/proto/encode_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2010 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package proto_test - -import ( - "strconv" - "testing" - - "github.com/golang/protobuf/proto" - tpb "github.com/golang/protobuf/proto/proto3_proto" - "github.com/golang/protobuf/ptypes" -) - -var ( - blackhole []byte -) - -// BenchmarkAny creates increasingly large arbitrary Any messages. The type is always the -// same. -func BenchmarkAny(b *testing.B) { - data := make([]byte, 1<<20) - quantum := 1 << 10 - for i := uint(0); i <= 10; i++ { - b.Run(strconv.Itoa(quantum< 0; n-- { - g.Go(func() error { - _, err := proto.Marshal(m) - return err - }) - } - if err := g.Wait(); err != nil { - t.Fatal(err) - } -} diff --git a/vendor/github.com/golang/protobuf/proto/lib.go b/vendor/github.com/golang/protobuf/proto/lib.go index ac4ddbc07..42a58c6fd 100644 --- a/vendor/github.com/golang/protobuf/proto/lib.go +++ b/vendor/github.com/golang/protobuf/proto/lib.go @@ -235,7 +235,6 @@ To create and play with a Test object: test := &pb.Test{ Label: proto.String("hello"), Type: proto.Int32(17), - Reps: []int64{1, 2, 3}, Optionalgroup: &pb.Test_OptionalGroup{ RequiredField: proto.String("good bye"), }, @@ -308,7 +307,7 @@ func GetStats() Stats { return stats } // temporary Buffer and are fine for most applications. type Buffer struct { buf []byte // encode/decode byte stream - index int // read point + index int // write point // pools of basic types to amortize allocation. bools []bool @@ -889,10 +888,6 @@ func isProto3Zero(v reflect.Value) bool { return false } -// ProtoPackageIsVersion2 is referenced from generated protocol buffer files -// to assert that that code is compatible with this version of the proto package. -const ProtoPackageIsVersion2 = true - // ProtoPackageIsVersion1 is referenced from generated protocol buffer files // to assert that that code is compatible with this version of the proto package. const ProtoPackageIsVersion1 = true diff --git a/vendor/github.com/golang/protobuf/proto/map_test.go b/vendor/github.com/golang/protobuf/proto/map_test.go deleted file mode 100644 index 313e87924..000000000 --- a/vendor/github.com/golang/protobuf/proto/map_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package proto_test - -import ( - "fmt" - "testing" - - "github.com/golang/protobuf/proto" - ppb "github.com/golang/protobuf/proto/proto3_proto" -) - -func marshalled() []byte { - m := &ppb.IntMaps{} - for i := 0; i < 1000; i++ { - m.Maps = append(m.Maps, &ppb.IntMap{ - Rtt: map[int32]int32{1: 2}, - }) - } - b, err := proto.Marshal(m) - if err != nil { - panic(fmt.Sprintf("Can't marshal %+v: %v", m, err)) - } - return b -} - -func BenchmarkConcurrentMapUnmarshal(b *testing.B) { - in := marshalled() - b.RunParallel(func(pb *testing.PB) { - for pb.Next() { - var out ppb.IntMaps - if err := proto.Unmarshal(in, &out); err != nil { - b.Errorf("Can't unmarshal ppb.IntMaps: %v", err) - } - } - }) -} - -func BenchmarkSequentialMapUnmarshal(b *testing.B) { - in := marshalled() - b.ResetTimer() - for i := 0; i < b.N; i++ { - var out ppb.IntMaps - if err := proto.Unmarshal(in, &out); err != nil { - b.Errorf("Can't unmarshal ppb.IntMaps: %v", err) - } - } -} diff --git a/vendor/github.com/golang/protobuf/proto/message_set.go b/vendor/github.com/golang/protobuf/proto/message_set.go index fd982decd..e25e01e63 100644 --- a/vendor/github.com/golang/protobuf/proto/message_set.go +++ b/vendor/github.com/golang/protobuf/proto/message_set.go @@ -149,21 +149,9 @@ func skipVarint(buf []byte) []byte { // MarshalMessageSet encodes the extension map represented by m in the message set wire format. // It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option. -func MarshalMessageSet(exts interface{}) ([]byte, error) { - var m map[int32]Extension - switch exts := exts.(type) { - case *XXX_InternalExtensions: - if err := encodeExtensions(exts); err != nil { - return nil, err - } - m, _ = exts.extensionsRead() - case map[int32]Extension: - if err := encodeExtensionsMap(exts); err != nil { - return nil, err - } - m = exts - default: - return nil, errors.New("proto: not an extension map") +func MarshalMessageSet(m map[int32]Extension) ([]byte, error) { + if err := encodeExtensionMap(m); err != nil { + return nil, err } // Sort extension IDs to provide a deterministic encoding. @@ -190,17 +178,7 @@ func MarshalMessageSet(exts interface{}) ([]byte, error) { // UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. // It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option. -func UnmarshalMessageSet(buf []byte, exts interface{}) error { - var m map[int32]Extension - switch exts := exts.(type) { - case *XXX_InternalExtensions: - m = exts.extensionsWrite() - case map[int32]Extension: - m = exts - default: - return errors.New("proto: not an extension map") - } - +func UnmarshalMessageSet(buf []byte, m map[int32]Extension) error { ms := new(messageSet) if err := Unmarshal(buf, ms); err != nil { return err @@ -231,16 +209,7 @@ func UnmarshalMessageSet(buf []byte, exts interface{}) error { // MarshalMessageSetJSON encodes the extension map represented by m in JSON format. // It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option. -func MarshalMessageSetJSON(exts interface{}) ([]byte, error) { - var m map[int32]Extension - switch exts := exts.(type) { - case *XXX_InternalExtensions: - m, _ = exts.extensionsRead() - case map[int32]Extension: - m = exts - default: - return nil, errors.New("proto: not an extension map") - } +func MarshalMessageSetJSON(m map[int32]Extension) ([]byte, error) { var b bytes.Buffer b.WriteByte('{') @@ -283,7 +252,7 @@ func MarshalMessageSetJSON(exts interface{}) ([]byte, error) { // UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format. // It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option. -func UnmarshalMessageSetJSON(buf []byte, exts interface{}) error { +func UnmarshalMessageSetJSON(buf []byte, m map[int32]Extension) error { // Common-case fast path. if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) { return nil diff --git a/vendor/github.com/golang/protobuf/proto/message_set_test.go b/vendor/github.com/golang/protobuf/proto/message_set_test.go index 353a3ea76..ab8ac2f0e 100644 --- a/vendor/github.com/golang/protobuf/proto/message_set_test.go +++ b/vendor/github.com/golang/protobuf/proto/message_set_test.go @@ -50,13 +50,13 @@ func TestUnmarshalMessageSetWithDuplicate(t *testing.T) { } t.Logf("Marshaled bytes: %q", b) - var extensions XXX_InternalExtensions - if err := UnmarshalMessageSet(b, &extensions); err != nil { + m := make(map[int32]Extension) + if err := UnmarshalMessageSet(b, m); err != nil { t.Fatalf("UnmarshalMessageSet: %v", err) } - ext, ok := extensions.p.extensionMap[12345] + ext, ok := m[12345] if !ok { - t.Fatalf("Didn't retrieve extension 12345; map is %v", extensions.p.extensionMap) + t.Fatalf("Didn't retrieve extension 12345; map is %v", m) } // Skip wire type/field number and length varints. got := skipVarint(skipVarint(ext.enc)) diff --git a/vendor/github.com/golang/protobuf/proto/pointer_reflect.go b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go index fb512e2e1..749919d25 100644 --- a/vendor/github.com/golang/protobuf/proto/pointer_reflect.go +++ b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go @@ -29,7 +29,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +build appengine js +// +build appengine // This file contains an implementation of proto field accesses using package reflect. // It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can @@ -139,11 +139,6 @@ func structPointer_StringSlice(p structPointer, f field) *[]string { return structPointer_ifield(p, f).(*[]string) } -// Extensions returns the address of an extension map field in the struct. -func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions { - return structPointer_ifield(p, f).(*XXX_InternalExtensions) -} - // ExtMap returns the address of an extension map field in the struct. func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { return structPointer_ifield(p, f).(*map[int32]Extension) diff --git a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go index 6b5567d47..e9be0fe92 100644 --- a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go +++ b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go @@ -29,7 +29,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +build !appengine,!js +// +build !appengine // This file contains the implementation of the proto field accesses using package unsafe. @@ -126,10 +126,6 @@ func structPointer_StringSlice(p structPointer, f field) *[]string { } // ExtMap returns the address of an extension map field in the struct. -func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions { - return (*XXX_InternalExtensions)(unsafe.Pointer(uintptr(p) + uintptr(f))) -} - func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f))) } diff --git a/vendor/github.com/golang/protobuf/proto/properties.go b/vendor/github.com/golang/protobuf/proto/properties.go index ec2289c00..d4531c056 100644 --- a/vendor/github.com/golang/protobuf/proto/properties.go +++ b/vendor/github.com/golang/protobuf/proto/properties.go @@ -173,7 +173,6 @@ func (sp *StructProperties) Swap(i, j int) { sp.order[i], sp.order[j] = sp.order type Properties struct { Name string // name of the field, for error messages OrigName string // original name before protocol compiler (always set) - JSONName string // name to use for JSON; determined by protoc Wire string WireType int Tag int @@ -230,9 +229,8 @@ func (p *Properties) String() string { if p.Packed { s += ",packed" } - s += ",name=" + p.OrigName - if p.JSONName != p.OrigName { - s += ",json=" + p.JSONName + if p.OrigName != p.Name { + s += ",name=" + p.OrigName } if p.proto3 { s += ",proto3" @@ -312,8 +310,6 @@ func (p *Properties) Parse(s string) { p.Packed = true case strings.HasPrefix(f, "name="): p.OrigName = f[5:] - case strings.HasPrefix(f, "json="): - p.JSONName = f[5:] case strings.HasPrefix(f, "enum="): p.Enum = f[5:] case f == "proto3": @@ -473,13 +469,17 @@ func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lock p.dec = (*Buffer).dec_slice_int64 p.packedDec = (*Buffer).dec_slice_packed_int64 case reflect.Uint8: + p.enc = (*Buffer).enc_slice_byte p.dec = (*Buffer).dec_slice_byte - if p.proto3 { + p.size = size_slice_byte + // This is a []byte, which is either a bytes field, + // or the value of a map field. In the latter case, + // we always encode an empty []byte, so we should not + // use the proto3 enc/size funcs. + // f == nil iff this is the key/value of a map field. + if p.proto3 && f != nil { p.enc = (*Buffer).enc_proto3_slice_byte p.size = size_proto3_slice_byte - } else { - p.enc = (*Buffer).enc_slice_byte - p.size = size_slice_byte } case reflect.Float32, reflect.Float64: switch t2.Bits() { @@ -678,8 +678,7 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { propertiesMap[t] = prop // build properties - prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) || - reflect.PtrTo(t).Implements(extendableProtoV1Type) + prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) prop.unrecField = invalidField prop.Prop = make([]*Properties, t.NumField()) prop.order = make([]int, t.NumField()) @@ -690,22 +689,15 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { name := f.Name p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false) - if f.Name == "XXX_InternalExtensions" { // special case - p.enc = (*Buffer).enc_exts - p.dec = nil // not needed - p.size = size_exts - } else if f.Name == "XXX_extensions" { // special case + if f.Name == "XXX_extensions" { // special case p.enc = (*Buffer).enc_map p.dec = nil // not needed p.size = size_map - } else if f.Name == "XXX_unrecognized" { // special case - prop.unrecField = toField(&f) } - oneof := f.Tag.Get("protobuf_oneof") // special case - if oneof != "" { - // Oneof fields don't use the traditional protobuf tag. - p.OrigName = oneof + if f.Name == "XXX_unrecognized" { // special case + prop.unrecField = toField(&f) } + oneof := f.Tag.Get("protobuf_oneof") != "" // special case prop.Prop[i] = p prop.order[i] = i if debug { @@ -715,7 +707,7 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { } print("\n") } - if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && oneof == "" { + if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && !oneof { fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]") } } @@ -844,29 +836,7 @@ func RegisterType(x Message, name string) { } // MessageName returns the fully-qualified proto name for the given message type. -func MessageName(x Message) string { - type xname interface { - XXX_MessageName() string - } - if m, ok := x.(xname); ok { - return m.XXX_MessageName() - } - return revProtoTypes[reflect.TypeOf(x)] -} +func MessageName(x Message) string { return revProtoTypes[reflect.TypeOf(x)] } // MessageType returns the message type (pointer to struct) for a named message. func MessageType(name string) reflect.Type { return protoTypes[name] } - -// A registry of all linked proto files. -var ( - protoFiles = make(map[string][]byte) // file name => fileDescriptor -) - -// RegisterFile is called from generated code and maps from the -// full file name of a .proto file to its compressed FileDescriptorProto. -func RegisterFile(filename string, fileDescriptor []byte) { - protoFiles[filename] = fileDescriptor -} - -// FileDescriptor returns the compressed FileDescriptorProto for a .proto file. -func FileDescriptor(filename string) []byte { return protoFiles[filename] } diff --git a/vendor/github.com/golang/protobuf/proto/proto3_proto/proto3.pb.go b/vendor/github.com/golang/protobuf/proto/proto3_proto/proto3.pb.go index cc4d0489f..37c778209 100644 --- a/vendor/github.com/golang/protobuf/proto/proto3_proto/proto3.pb.go +++ b/vendor/github.com/golang/protobuf/proto/proto3_proto/proto3.pb.go @@ -12,27 +12,14 @@ It has these top-level messages: Message Nested MessageWithMap - IntMap - IntMaps */ package proto3_proto import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" -import google_protobuf "github.com/golang/protobuf/ptypes/any" import testdata "github.com/golang/protobuf/proto/testdata" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type Message_Humour int32 @@ -59,96 +46,25 @@ var Message_Humour_value = map[string]int32{ func (x Message_Humour) String() string { return proto.EnumName(Message_Humour_name, int32(x)) } -func (Message_Humour) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0, 0} } type Message struct { Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` Hilarity Message_Humour `protobuf:"varint,2,opt,name=hilarity,enum=proto3_proto.Message_Humour" json:"hilarity,omitempty"` - HeightInCm uint32 `protobuf:"varint,3,opt,name=height_in_cm,json=heightInCm" json:"height_in_cm,omitempty"` + HeightInCm uint32 `protobuf:"varint,3,opt,name=height_in_cm" json:"height_in_cm,omitempty"` Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` - ResultCount int64 `protobuf:"varint,7,opt,name=result_count,json=resultCount" json:"result_count,omitempty"` - TrueScotsman bool `protobuf:"varint,8,opt,name=true_scotsman,json=trueScotsman" json:"true_scotsman,omitempty"` + ResultCount int64 `protobuf:"varint,7,opt,name=result_count" json:"result_count,omitempty"` + TrueScotsman bool `protobuf:"varint,8,opt,name=true_scotsman" json:"true_scotsman,omitempty"` Score float32 `protobuf:"fixed32,9,opt,name=score" json:"score,omitempty"` - Key []uint64 `protobuf:"varint,5,rep,packed,name=key" json:"key,omitempty"` - ShortKey []int32 `protobuf:"varint,19,rep,packed,name=short_key,json=shortKey" json:"short_key,omitempty"` + Key []uint64 `protobuf:"varint,5,rep,name=key" json:"key,omitempty"` Nested *Nested `protobuf:"bytes,6,opt,name=nested" json:"nested,omitempty"` - RFunny []Message_Humour `protobuf:"varint,16,rep,packed,name=r_funny,json=rFunny,enum=proto3_proto.Message_Humour" json:"r_funny,omitempty"` Terrain map[string]*Nested `protobuf:"bytes,10,rep,name=terrain" json:"terrain,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - Proto2Field *testdata.SubDefaults `protobuf:"bytes,11,opt,name=proto2_field,json=proto2Field" json:"proto2_field,omitempty"` - Proto2Value map[string]*testdata.SubDefaults `protobuf:"bytes,13,rep,name=proto2_value,json=proto2Value" json:"proto2_value,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - Anything *google_protobuf.Any `protobuf:"bytes,14,opt,name=anything" json:"anything,omitempty"` - ManyThings []*google_protobuf.Any `protobuf:"bytes,15,rep,name=many_things,json=manyThings" json:"many_things,omitempty"` - Submessage *Message `protobuf:"bytes,17,opt,name=submessage" json:"submessage,omitempty"` - Children []*Message `protobuf:"bytes,18,rep,name=children" json:"children,omitempty"` -} - -func (m *Message) Reset() { *m = Message{} } -func (m *Message) String() string { return proto.CompactTextString(m) } -func (*Message) ProtoMessage() {} -func (*Message) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *Message) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Message) GetHilarity() Message_Humour { - if m != nil { - return m.Hilarity - } - return Message_UNKNOWN -} - -func (m *Message) GetHeightInCm() uint32 { - if m != nil { - return m.HeightInCm - } - return 0 -} - -func (m *Message) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -func (m *Message) GetResultCount() int64 { - if m != nil { - return m.ResultCount - } - return 0 + Proto2Field *testdata.SubDefaults `protobuf:"bytes,11,opt,name=proto2_field" json:"proto2_field,omitempty"` + Proto2Value map[string]*testdata.SubDefaults `protobuf:"bytes,13,rep,name=proto2_value" json:"proto2_value,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` } -func (m *Message) GetTrueScotsman() bool { - if m != nil { - return m.TrueScotsman - } - return false -} - -func (m *Message) GetScore() float32 { - if m != nil { - return m.Score - } - return 0 -} - -func (m *Message) GetKey() []uint64 { - if m != nil { - return m.Key - } - return nil -} - -func (m *Message) GetShortKey() []int32 { - if m != nil { - return m.ShortKey - } - return nil -} +func (m *Message) Reset() { *m = Message{} } +func (m *Message) String() string { return proto.CompactTextString(m) } +func (*Message) ProtoMessage() {} func (m *Message) GetNested() *Nested { if m != nil { @@ -157,13 +73,6 @@ func (m *Message) GetNested() *Nested { return nil } -func (m *Message) GetRFunny() []Message_Humour { - if m != nil { - return m.RFunny - } - return nil -} - func (m *Message) GetTerrain() map[string]*Nested { if m != nil { return m.Terrain @@ -185,66 +94,21 @@ func (m *Message) GetProto2Value() map[string]*testdata.SubDefaults { return nil } -func (m *Message) GetAnything() *google_protobuf.Any { - if m != nil { - return m.Anything - } - return nil -} - -func (m *Message) GetManyThings() []*google_protobuf.Any { - if m != nil { - return m.ManyThings - } - return nil -} - -func (m *Message) GetSubmessage() *Message { - if m != nil { - return m.Submessage - } - return nil -} - -func (m *Message) GetChildren() []*Message { - if m != nil { - return m.Children - } - return nil -} - type Nested struct { Bunny string `protobuf:"bytes,1,opt,name=bunny" json:"bunny,omitempty"` - Cute bool `protobuf:"varint,2,opt,name=cute" json:"cute,omitempty"` -} - -func (m *Nested) Reset() { *m = Nested{} } -func (m *Nested) String() string { return proto.CompactTextString(m) } -func (*Nested) ProtoMessage() {} -func (*Nested) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } - -func (m *Nested) GetBunny() string { - if m != nil { - return m.Bunny - } - return "" } -func (m *Nested) GetCute() bool { - if m != nil { - return m.Cute - } - return false -} +func (m *Nested) Reset() { *m = Nested{} } +func (m *Nested) String() string { return proto.CompactTextString(m) } +func (*Nested) ProtoMessage() {} type MessageWithMap struct { - ByteMapping map[bool][]byte `protobuf:"bytes,1,rep,name=byte_mapping,json=byteMapping" json:"byte_mapping,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value,proto3"` + ByteMapping map[bool][]byte `protobuf:"bytes,1,rep,name=byte_mapping" json:"byte_mapping,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value,proto3"` } -func (m *MessageWithMap) Reset() { *m = MessageWithMap{} } -func (m *MessageWithMap) String() string { return proto.CompactTextString(m) } -func (*MessageWithMap) ProtoMessage() {} -func (*MessageWithMap) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } +func (m *MessageWithMap) Reset() { *m = MessageWithMap{} } +func (m *MessageWithMap) String() string { return proto.CompactTextString(m) } +func (*MessageWithMap) ProtoMessage() {} func (m *MessageWithMap) GetByteMapping() map[bool][]byte { if m != nil { @@ -253,95 +117,6 @@ func (m *MessageWithMap) GetByteMapping() map[bool][]byte { return nil } -type IntMap struct { - Rtt map[int32]int32 `protobuf:"bytes,1,rep,name=rtt" json:"rtt,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` -} - -func (m *IntMap) Reset() { *m = IntMap{} } -func (m *IntMap) String() string { return proto.CompactTextString(m) } -func (*IntMap) ProtoMessage() {} -func (*IntMap) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } - -func (m *IntMap) GetRtt() map[int32]int32 { - if m != nil { - return m.Rtt - } - return nil -} - -type IntMaps struct { - Maps []*IntMap `protobuf:"bytes,1,rep,name=maps" json:"maps,omitempty"` -} - -func (m *IntMaps) Reset() { *m = IntMaps{} } -func (m *IntMaps) String() string { return proto.CompactTextString(m) } -func (*IntMaps) ProtoMessage() {} -func (*IntMaps) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } - -func (m *IntMaps) GetMaps() []*IntMap { - if m != nil { - return m.Maps - } - return nil -} - func init() { - proto.RegisterType((*Message)(nil), "proto3_proto.Message") - proto.RegisterType((*Nested)(nil), "proto3_proto.Nested") - proto.RegisterType((*MessageWithMap)(nil), "proto3_proto.MessageWithMap") - proto.RegisterType((*IntMap)(nil), "proto3_proto.IntMap") - proto.RegisterType((*IntMaps)(nil), "proto3_proto.IntMaps") proto.RegisterEnum("proto3_proto.Message_Humour", Message_Humour_name, Message_Humour_value) } - -func init() { proto.RegisterFile("proto3_proto/proto3.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 733 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x53, 0x6d, 0x6f, 0xf3, 0x34, - 0x14, 0x25, 0x4d, 0x5f, 0xd2, 0x9b, 0x74, 0x0b, 0x5e, 0x91, 0xbc, 0x02, 0x52, 0x28, 0x12, 0x8a, - 0x78, 0x49, 0xa1, 0xd3, 0xd0, 0x84, 0x10, 0x68, 0x1b, 0x9b, 0xa8, 0xd6, 0x95, 0xca, 0xdd, 0x98, - 0xf8, 0x14, 0xa5, 0xad, 0xdb, 0x46, 0x34, 0x4e, 0x49, 0x1c, 0xa4, 0xfc, 0x1d, 0xfe, 0x28, 0x8f, - 0x6c, 0xa7, 0x5d, 0x36, 0x65, 0xcf, 0xf3, 0x29, 0xf6, 0xf1, 0xb9, 0xf7, 0x9c, 0x1c, 0x5f, 0xc3, - 0xe9, 0x2e, 0x89, 0x79, 0x7c, 0xe6, 0xcb, 0xcf, 0x40, 0x6d, 0x3c, 0xf9, 0x41, 0x56, 0xf9, 0xa8, - 0x77, 0xba, 0x8e, 0xe3, 0xf5, 0x96, 0x2a, 0xca, 0x3c, 0x5b, 0x0d, 0x02, 0x96, 0x2b, 0x62, 0xef, - 0x84, 0xd3, 0x94, 0x2f, 0x03, 0x1e, 0x0c, 0xc4, 0x42, 0x81, 0xfd, 0xff, 0x5b, 0xd0, 0xba, 0xa7, - 0x69, 0x1a, 0xac, 0x29, 0x42, 0x50, 0x67, 0x41, 0x44, 0xb1, 0xe6, 0x68, 0x6e, 0x9b, 0xc8, 0x35, - 0xba, 0x00, 0x63, 0x13, 0x6e, 0x83, 0x24, 0xe4, 0x39, 0xae, 0x39, 0x9a, 0x7b, 0x34, 0xfc, 0xcc, - 0x2b, 0x0b, 0x7a, 0x45, 0xb1, 0xf7, 0x7b, 0x16, 0xc5, 0x59, 0x42, 0x0e, 0x6c, 0xe4, 0x80, 0xb5, - 0xa1, 0xe1, 0x7a, 0xc3, 0xfd, 0x90, 0xf9, 0x8b, 0x08, 0xeb, 0x8e, 0xe6, 0x76, 0x08, 0x28, 0x6c, - 0xc4, 0xae, 0x23, 0xa1, 0x27, 0xec, 0xe0, 0xba, 0xa3, 0xb9, 0x16, 0x91, 0x6b, 0xf4, 0x05, 0x58, - 0x09, 0x4d, 0xb3, 0x2d, 0xf7, 0x17, 0x71, 0xc6, 0x38, 0x6e, 0x39, 0x9a, 0xab, 0x13, 0x53, 0x61, - 0xd7, 0x02, 0x42, 0x5f, 0x42, 0x87, 0x27, 0x19, 0xf5, 0xd3, 0x45, 0xcc, 0xd3, 0x28, 0x60, 0xd8, - 0x70, 0x34, 0xd7, 0x20, 0x96, 0x00, 0x67, 0x05, 0x86, 0xba, 0xd0, 0x48, 0x17, 0x71, 0x42, 0x71, - 0xdb, 0xd1, 0xdc, 0x1a, 0x51, 0x1b, 0x64, 0x83, 0xfe, 0x37, 0xcd, 0x71, 0xc3, 0xd1, 0xdd, 0x3a, - 0x11, 0x4b, 0xf4, 0x29, 0xb4, 0xd3, 0x4d, 0x9c, 0x70, 0x5f, 0xe0, 0x27, 0x8e, 0xee, 0x36, 0x88, - 0x21, 0x81, 0x3b, 0x9a, 0xa3, 0x6f, 0xa1, 0xc9, 0x68, 0xca, 0xe9, 0x12, 0x37, 0x1d, 0xcd, 0x35, - 0x87, 0xdd, 0x97, 0xbf, 0x3e, 0x91, 0x67, 0xa4, 0xe0, 0xa0, 0x73, 0x68, 0x25, 0xfe, 0x2a, 0x63, - 0x2c, 0xc7, 0xb6, 0xa3, 0x7f, 0x30, 0xa9, 0x66, 0x72, 0x2b, 0xb8, 0xe8, 0x67, 0x68, 0x71, 0x9a, - 0x24, 0x41, 0xc8, 0x30, 0x38, 0xba, 0x6b, 0x0e, 0xfb, 0xd5, 0x65, 0x0f, 0x8a, 0x74, 0xc3, 0x78, - 0x92, 0x93, 0x7d, 0x09, 0xba, 0x00, 0x75, 0xff, 0x43, 0x7f, 0x15, 0xd2, 0xed, 0x12, 0x9b, 0xd2, - 0xe8, 0x27, 0xde, 0xfe, 0xae, 0xbd, 0x59, 0x36, 0xff, 0x8d, 0xae, 0x82, 0x6c, 0xcb, 0x53, 0x62, - 0x2a, 0xea, 0xad, 0x60, 0xa2, 0xd1, 0xa1, 0xf2, 0xdf, 0x60, 0x9b, 0x51, 0xdc, 0x91, 0xe2, 0x5f, - 0x55, 0x8b, 0x4f, 0x25, 0xf3, 0x4f, 0x41, 0x54, 0x06, 0x8a, 0x56, 0x12, 0x41, 0xdf, 0x83, 0x11, - 0xb0, 0x9c, 0x6f, 0x42, 0xb6, 0xc6, 0x47, 0x45, 0x52, 0x6a, 0x0e, 0xbd, 0xfd, 0x1c, 0x7a, 0x97, - 0x2c, 0x27, 0x07, 0x16, 0x3a, 0x07, 0x33, 0x0a, 0x58, 0xee, 0xcb, 0x5d, 0x8a, 0x8f, 0xa5, 0x76, - 0x75, 0x11, 0x08, 0xe2, 0x83, 0xe4, 0xa1, 0x73, 0x80, 0x34, 0x9b, 0x47, 0xca, 0x14, 0xfe, 0xb8, - 0xf8, 0xd7, 0x2a, 0xc7, 0xa4, 0x44, 0x44, 0x3f, 0x80, 0xb1, 0xd8, 0x84, 0xdb, 0x65, 0x42, 0x19, - 0x46, 0x52, 0xea, 0x8d, 0xa2, 0x03, 0xad, 0x37, 0x05, 0xab, 0x1c, 0xf8, 0x7e, 0x72, 0xd4, 0xd3, - 0x90, 0x93, 0xf3, 0x35, 0x34, 0x54, 0x70, 0xb5, 0xf7, 0xcc, 0x86, 0xa2, 0xfc, 0x54, 0xbb, 0xd0, - 0x7a, 0x8f, 0x60, 0xbf, 0x4e, 0xb1, 0xa2, 0xeb, 0x37, 0x2f, 0xbb, 0xbe, 0x71, 0x91, 0xcf, 0x6d, - 0xfb, 0xbf, 0x42, 0x53, 0x0d, 0x14, 0x32, 0xa1, 0xf5, 0x38, 0xb9, 0x9b, 0xfc, 0xf1, 0x34, 0xb1, - 0x3f, 0x42, 0x06, 0xd4, 0xa7, 0x8f, 0x93, 0x99, 0xad, 0xa1, 0x0e, 0xb4, 0x67, 0xe3, 0xcb, 0xe9, - 0xec, 0x61, 0x74, 0x7d, 0x67, 0xd7, 0xd0, 0x31, 0x98, 0x57, 0xa3, 0xf1, 0xd8, 0xbf, 0xba, 0x1c, - 0x8d, 0x6f, 0xfe, 0xb2, 0xf5, 0xfe, 0x10, 0x9a, 0xca, 0xac, 0x78, 0x33, 0x73, 0x39, 0xbe, 0xca, - 0x8f, 0xda, 0x88, 0x57, 0xba, 0xc8, 0xb8, 0x32, 0x64, 0x10, 0xb9, 0xee, 0xff, 0xa7, 0xc1, 0x51, - 0x91, 0xd9, 0x53, 0xc8, 0x37, 0xf7, 0xc1, 0x0e, 0x4d, 0xc1, 0x9a, 0xe7, 0x9c, 0xfa, 0x51, 0xb0, - 0xdb, 0x89, 0x39, 0xd0, 0x64, 0xce, 0xdf, 0x55, 0xe6, 0x5c, 0xd4, 0x78, 0x57, 0x39, 0xa7, 0xf7, - 0x8a, 0x5f, 0x4c, 0xd5, 0xfc, 0x19, 0xe9, 0xfd, 0x02, 0xf6, 0x6b, 0x42, 0x39, 0x30, 0x43, 0x05, - 0xd6, 0x2d, 0x07, 0x66, 0x95, 0x93, 0xf9, 0x07, 0x9a, 0x23, 0xc6, 0x85, 0xb7, 0x01, 0xe8, 0x09, - 0xe7, 0x85, 0xa5, 0xcf, 0x5f, 0x5a, 0x52, 0x14, 0x8f, 0x70, 0xae, 0x2c, 0x08, 0x66, 0xef, 0x47, - 0x30, 0xf6, 0x40, 0x59, 0xb2, 0x51, 0x21, 0xd9, 0x28, 0x4b, 0x9e, 0x41, 0x4b, 0xf5, 0x4b, 0x91, - 0x0b, 0xf5, 0x28, 0xd8, 0xa5, 0x85, 0x68, 0xb7, 0x4a, 0x94, 0x48, 0xc6, 0xbc, 0xa9, 0x8e, 0xde, - 0x05, 0x00, 0x00, 0xff, 0xff, 0x75, 0x38, 0xad, 0x84, 0xe4, 0x05, 0x00, 0x00, -} diff --git a/vendor/github.com/golang/protobuf/proto/proto3_proto/proto3.proto b/vendor/github.com/golang/protobuf/proto/proto3_proto/proto3.proto index 204865571..e2311d929 100644 --- a/vendor/github.com/golang/protobuf/proto/proto3_proto/proto3.proto +++ b/vendor/github.com/golang/protobuf/proto/proto3_proto/proto3.proto @@ -31,7 +31,6 @@ syntax = "proto3"; -import "google/protobuf/any.proto"; import "testdata/test.proto"; package proto3_proto; @@ -53,35 +52,17 @@ message Message { float score = 9; repeated uint64 key = 5; - repeated int32 short_key = 19; Nested nested = 6; - repeated Humour r_funny = 16; map terrain = 10; testdata.SubDefaults proto2_field = 11; map proto2_value = 13; - - google.protobuf.Any anything = 14; - repeated google.protobuf.Any many_things = 15; - - Message submessage = 17; - repeated Message children = 18; } message Nested { string bunny = 1; - bool cute = 2; } message MessageWithMap { map byte_mapping = 1; } - - -message IntMap { - map rtt = 1; -} - -message IntMaps { - repeated IntMap maps = 1; -} diff --git a/vendor/github.com/golang/protobuf/proto/proto3_test.go b/vendor/github.com/golang/protobuf/proto/proto3_test.go index 735837f2d..462f8055c 100644 --- a/vendor/github.com/golang/protobuf/proto/proto3_test.go +++ b/vendor/github.com/golang/protobuf/proto/proto3_test.go @@ -93,16 +93,6 @@ func TestRoundTripProto3(t *testing.T) { } } -func TestGettersForBasicTypesExist(t *testing.T) { - var m pb.Message - if got := m.GetNested().GetBunny(); got != "" { - t.Errorf("m.GetNested().GetBunny() = %q, want empty string", got) - } - if got := m.GetNested().GetCute(); got { - t.Errorf("m.GetNested().GetCute() = %t, want false", got) - } -} - func TestProto3SetDefaults(t *testing.T) { in := &pb.Message{ Terrain: map[string]*pb.Nested{ diff --git a/vendor/github.com/golang/protobuf/proto/testdata/test.pb.go b/vendor/github.com/golang/protobuf/proto/testdata/test.pb.go index 25ffd7a08..e3c83fc1a 100644 --- a/vendor/github.com/golang/protobuf/proto/testdata/test.pb.go +++ b/vendor/github.com/golang/protobuf/proto/testdata/test.pb.go @@ -12,7 +12,6 @@ It has these top-level messages: GoEnum GoTestField GoTest - GoTestRequiredGroupField GoSkipTest NonPackedTest PackedTest @@ -21,7 +20,6 @@ It has these top-level messages: NewMessage InnerMessage OtherMessage - RequiredInnerMessage MyMessage Ext ComplexExtension @@ -54,9 +52,7 @@ var _ = math.Inf // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion1 type FOO int32 @@ -196,7 +192,7 @@ func (x *MyMessage_Color) UnmarshalJSON(data []byte) error { *x = MyMessage_Color(value) return nil } -func (MyMessage_Color) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{13, 0} } +func (MyMessage_Color) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{11, 0} } type DefaultsMessage_DefaultsEnum int32 @@ -234,7 +230,7 @@ func (x *DefaultsMessage_DefaultsEnum) UnmarshalJSON(data []byte) error { return nil } func (DefaultsMessage_DefaultsEnum) EnumDescriptor() ([]byte, []int) { - return fileDescriptor0, []int{16, 0} + return fileDescriptor0, []int{14, 0} } type Defaults_Color int32 @@ -272,7 +268,7 @@ func (x *Defaults_Color) UnmarshalJSON(data []byte) error { *x = Defaults_Color(value) return nil } -func (Defaults_Color) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{21, 0} } +func (Defaults_Color) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{19, 0} } type RepeatedEnum_Color int32 @@ -303,7 +299,7 @@ func (x *RepeatedEnum_Color) UnmarshalJSON(data []byte) error { *x = RepeatedEnum_Color(value) return nil } -func (RepeatedEnum_Color) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{23, 0} } +func (RepeatedEnum_Color) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{21, 0} } type GoEnum struct { Foo *FOO `protobuf:"varint,1,req,name=foo,enum=testdata.FOO" json:"foo,omitempty"` @@ -357,76 +353,76 @@ type GoTest struct { RepeatedField []*GoTestField `protobuf:"bytes,5,rep,name=RepeatedField" json:"RepeatedField,omitempty"` OptionalField *GoTestField `protobuf:"bytes,6,opt,name=OptionalField" json:"OptionalField,omitempty"` // Required fields of all basic types - F_BoolRequired *bool `protobuf:"varint,10,req,name=F_Bool_required,json=FBoolRequired" json:"F_Bool_required,omitempty"` - F_Int32Required *int32 `protobuf:"varint,11,req,name=F_Int32_required,json=FInt32Required" json:"F_Int32_required,omitempty"` - F_Int64Required *int64 `protobuf:"varint,12,req,name=F_Int64_required,json=FInt64Required" json:"F_Int64_required,omitempty"` - F_Fixed32Required *uint32 `protobuf:"fixed32,13,req,name=F_Fixed32_required,json=FFixed32Required" json:"F_Fixed32_required,omitempty"` - F_Fixed64Required *uint64 `protobuf:"fixed64,14,req,name=F_Fixed64_required,json=FFixed64Required" json:"F_Fixed64_required,omitempty"` - F_Uint32Required *uint32 `protobuf:"varint,15,req,name=F_Uint32_required,json=FUint32Required" json:"F_Uint32_required,omitempty"` - F_Uint64Required *uint64 `protobuf:"varint,16,req,name=F_Uint64_required,json=FUint64Required" json:"F_Uint64_required,omitempty"` - F_FloatRequired *float32 `protobuf:"fixed32,17,req,name=F_Float_required,json=FFloatRequired" json:"F_Float_required,omitempty"` - F_DoubleRequired *float64 `protobuf:"fixed64,18,req,name=F_Double_required,json=FDoubleRequired" json:"F_Double_required,omitempty"` - F_StringRequired *string `protobuf:"bytes,19,req,name=F_String_required,json=FStringRequired" json:"F_String_required,omitempty"` - F_BytesRequired []byte `protobuf:"bytes,101,req,name=F_Bytes_required,json=FBytesRequired" json:"F_Bytes_required,omitempty"` - F_Sint32Required *int32 `protobuf:"zigzag32,102,req,name=F_Sint32_required,json=FSint32Required" json:"F_Sint32_required,omitempty"` - F_Sint64Required *int64 `protobuf:"zigzag64,103,req,name=F_Sint64_required,json=FSint64Required" json:"F_Sint64_required,omitempty"` + F_BoolRequired *bool `protobuf:"varint,10,req,name=F_Bool_required" json:"F_Bool_required,omitempty"` + F_Int32Required *int32 `protobuf:"varint,11,req,name=F_Int32_required" json:"F_Int32_required,omitempty"` + F_Int64Required *int64 `protobuf:"varint,12,req,name=F_Int64_required" json:"F_Int64_required,omitempty"` + F_Fixed32Required *uint32 `protobuf:"fixed32,13,req,name=F_Fixed32_required" json:"F_Fixed32_required,omitempty"` + F_Fixed64Required *uint64 `protobuf:"fixed64,14,req,name=F_Fixed64_required" json:"F_Fixed64_required,omitempty"` + F_Uint32Required *uint32 `protobuf:"varint,15,req,name=F_Uint32_required" json:"F_Uint32_required,omitempty"` + F_Uint64Required *uint64 `protobuf:"varint,16,req,name=F_Uint64_required" json:"F_Uint64_required,omitempty"` + F_FloatRequired *float32 `protobuf:"fixed32,17,req,name=F_Float_required" json:"F_Float_required,omitempty"` + F_DoubleRequired *float64 `protobuf:"fixed64,18,req,name=F_Double_required" json:"F_Double_required,omitempty"` + F_StringRequired *string `protobuf:"bytes,19,req,name=F_String_required" json:"F_String_required,omitempty"` + F_BytesRequired []byte `protobuf:"bytes,101,req,name=F_Bytes_required" json:"F_Bytes_required,omitempty"` + F_Sint32Required *int32 `protobuf:"zigzag32,102,req,name=F_Sint32_required" json:"F_Sint32_required,omitempty"` + F_Sint64Required *int64 `protobuf:"zigzag64,103,req,name=F_Sint64_required" json:"F_Sint64_required,omitempty"` // Repeated fields of all basic types - F_BoolRepeated []bool `protobuf:"varint,20,rep,name=F_Bool_repeated,json=FBoolRepeated" json:"F_Bool_repeated,omitempty"` - F_Int32Repeated []int32 `protobuf:"varint,21,rep,name=F_Int32_repeated,json=FInt32Repeated" json:"F_Int32_repeated,omitempty"` - F_Int64Repeated []int64 `protobuf:"varint,22,rep,name=F_Int64_repeated,json=FInt64Repeated" json:"F_Int64_repeated,omitempty"` - F_Fixed32Repeated []uint32 `protobuf:"fixed32,23,rep,name=F_Fixed32_repeated,json=FFixed32Repeated" json:"F_Fixed32_repeated,omitempty"` - F_Fixed64Repeated []uint64 `protobuf:"fixed64,24,rep,name=F_Fixed64_repeated,json=FFixed64Repeated" json:"F_Fixed64_repeated,omitempty"` - F_Uint32Repeated []uint32 `protobuf:"varint,25,rep,name=F_Uint32_repeated,json=FUint32Repeated" json:"F_Uint32_repeated,omitempty"` - F_Uint64Repeated []uint64 `protobuf:"varint,26,rep,name=F_Uint64_repeated,json=FUint64Repeated" json:"F_Uint64_repeated,omitempty"` - F_FloatRepeated []float32 `protobuf:"fixed32,27,rep,name=F_Float_repeated,json=FFloatRepeated" json:"F_Float_repeated,omitempty"` - F_DoubleRepeated []float64 `protobuf:"fixed64,28,rep,name=F_Double_repeated,json=FDoubleRepeated" json:"F_Double_repeated,omitempty"` - F_StringRepeated []string `protobuf:"bytes,29,rep,name=F_String_repeated,json=FStringRepeated" json:"F_String_repeated,omitempty"` - F_BytesRepeated [][]byte `protobuf:"bytes,201,rep,name=F_Bytes_repeated,json=FBytesRepeated" json:"F_Bytes_repeated,omitempty"` - F_Sint32Repeated []int32 `protobuf:"zigzag32,202,rep,name=F_Sint32_repeated,json=FSint32Repeated" json:"F_Sint32_repeated,omitempty"` - F_Sint64Repeated []int64 `protobuf:"zigzag64,203,rep,name=F_Sint64_repeated,json=FSint64Repeated" json:"F_Sint64_repeated,omitempty"` + F_BoolRepeated []bool `protobuf:"varint,20,rep,name=F_Bool_repeated" json:"F_Bool_repeated,omitempty"` + F_Int32Repeated []int32 `protobuf:"varint,21,rep,name=F_Int32_repeated" json:"F_Int32_repeated,omitempty"` + F_Int64Repeated []int64 `protobuf:"varint,22,rep,name=F_Int64_repeated" json:"F_Int64_repeated,omitempty"` + F_Fixed32Repeated []uint32 `protobuf:"fixed32,23,rep,name=F_Fixed32_repeated" json:"F_Fixed32_repeated,omitempty"` + F_Fixed64Repeated []uint64 `protobuf:"fixed64,24,rep,name=F_Fixed64_repeated" json:"F_Fixed64_repeated,omitempty"` + F_Uint32Repeated []uint32 `protobuf:"varint,25,rep,name=F_Uint32_repeated" json:"F_Uint32_repeated,omitempty"` + F_Uint64Repeated []uint64 `protobuf:"varint,26,rep,name=F_Uint64_repeated" json:"F_Uint64_repeated,omitempty"` + F_FloatRepeated []float32 `protobuf:"fixed32,27,rep,name=F_Float_repeated" json:"F_Float_repeated,omitempty"` + F_DoubleRepeated []float64 `protobuf:"fixed64,28,rep,name=F_Double_repeated" json:"F_Double_repeated,omitempty"` + F_StringRepeated []string `protobuf:"bytes,29,rep,name=F_String_repeated" json:"F_String_repeated,omitempty"` + F_BytesRepeated [][]byte `protobuf:"bytes,201,rep,name=F_Bytes_repeated" json:"F_Bytes_repeated,omitempty"` + F_Sint32Repeated []int32 `protobuf:"zigzag32,202,rep,name=F_Sint32_repeated" json:"F_Sint32_repeated,omitempty"` + F_Sint64Repeated []int64 `protobuf:"zigzag64,203,rep,name=F_Sint64_repeated" json:"F_Sint64_repeated,omitempty"` // Optional fields of all basic types - F_BoolOptional *bool `protobuf:"varint,30,opt,name=F_Bool_optional,json=FBoolOptional" json:"F_Bool_optional,omitempty"` - F_Int32Optional *int32 `protobuf:"varint,31,opt,name=F_Int32_optional,json=FInt32Optional" json:"F_Int32_optional,omitempty"` - F_Int64Optional *int64 `protobuf:"varint,32,opt,name=F_Int64_optional,json=FInt64Optional" json:"F_Int64_optional,omitempty"` - F_Fixed32Optional *uint32 `protobuf:"fixed32,33,opt,name=F_Fixed32_optional,json=FFixed32Optional" json:"F_Fixed32_optional,omitempty"` - F_Fixed64Optional *uint64 `protobuf:"fixed64,34,opt,name=F_Fixed64_optional,json=FFixed64Optional" json:"F_Fixed64_optional,omitempty"` - F_Uint32Optional *uint32 `protobuf:"varint,35,opt,name=F_Uint32_optional,json=FUint32Optional" json:"F_Uint32_optional,omitempty"` - F_Uint64Optional *uint64 `protobuf:"varint,36,opt,name=F_Uint64_optional,json=FUint64Optional" json:"F_Uint64_optional,omitempty"` - F_FloatOptional *float32 `protobuf:"fixed32,37,opt,name=F_Float_optional,json=FFloatOptional" json:"F_Float_optional,omitempty"` - F_DoubleOptional *float64 `protobuf:"fixed64,38,opt,name=F_Double_optional,json=FDoubleOptional" json:"F_Double_optional,omitempty"` - F_StringOptional *string `protobuf:"bytes,39,opt,name=F_String_optional,json=FStringOptional" json:"F_String_optional,omitempty"` - F_BytesOptional []byte `protobuf:"bytes,301,opt,name=F_Bytes_optional,json=FBytesOptional" json:"F_Bytes_optional,omitempty"` - F_Sint32Optional *int32 `protobuf:"zigzag32,302,opt,name=F_Sint32_optional,json=FSint32Optional" json:"F_Sint32_optional,omitempty"` - F_Sint64Optional *int64 `protobuf:"zigzag64,303,opt,name=F_Sint64_optional,json=FSint64Optional" json:"F_Sint64_optional,omitempty"` + F_BoolOptional *bool `protobuf:"varint,30,opt,name=F_Bool_optional" json:"F_Bool_optional,omitempty"` + F_Int32Optional *int32 `protobuf:"varint,31,opt,name=F_Int32_optional" json:"F_Int32_optional,omitempty"` + F_Int64Optional *int64 `protobuf:"varint,32,opt,name=F_Int64_optional" json:"F_Int64_optional,omitempty"` + F_Fixed32Optional *uint32 `protobuf:"fixed32,33,opt,name=F_Fixed32_optional" json:"F_Fixed32_optional,omitempty"` + F_Fixed64Optional *uint64 `protobuf:"fixed64,34,opt,name=F_Fixed64_optional" json:"F_Fixed64_optional,omitempty"` + F_Uint32Optional *uint32 `protobuf:"varint,35,opt,name=F_Uint32_optional" json:"F_Uint32_optional,omitempty"` + F_Uint64Optional *uint64 `protobuf:"varint,36,opt,name=F_Uint64_optional" json:"F_Uint64_optional,omitempty"` + F_FloatOptional *float32 `protobuf:"fixed32,37,opt,name=F_Float_optional" json:"F_Float_optional,omitempty"` + F_DoubleOptional *float64 `protobuf:"fixed64,38,opt,name=F_Double_optional" json:"F_Double_optional,omitempty"` + F_StringOptional *string `protobuf:"bytes,39,opt,name=F_String_optional" json:"F_String_optional,omitempty"` + F_BytesOptional []byte `protobuf:"bytes,301,opt,name=F_Bytes_optional" json:"F_Bytes_optional,omitempty"` + F_Sint32Optional *int32 `protobuf:"zigzag32,302,opt,name=F_Sint32_optional" json:"F_Sint32_optional,omitempty"` + F_Sint64Optional *int64 `protobuf:"zigzag64,303,opt,name=F_Sint64_optional" json:"F_Sint64_optional,omitempty"` // Default-valued fields of all basic types - F_BoolDefaulted *bool `protobuf:"varint,40,opt,name=F_Bool_defaulted,json=FBoolDefaulted,def=1" json:"F_Bool_defaulted,omitempty"` - F_Int32Defaulted *int32 `protobuf:"varint,41,opt,name=F_Int32_defaulted,json=FInt32Defaulted,def=32" json:"F_Int32_defaulted,omitempty"` - F_Int64Defaulted *int64 `protobuf:"varint,42,opt,name=F_Int64_defaulted,json=FInt64Defaulted,def=64" json:"F_Int64_defaulted,omitempty"` - F_Fixed32Defaulted *uint32 `protobuf:"fixed32,43,opt,name=F_Fixed32_defaulted,json=FFixed32Defaulted,def=320" json:"F_Fixed32_defaulted,omitempty"` - F_Fixed64Defaulted *uint64 `protobuf:"fixed64,44,opt,name=F_Fixed64_defaulted,json=FFixed64Defaulted,def=640" json:"F_Fixed64_defaulted,omitempty"` - F_Uint32Defaulted *uint32 `protobuf:"varint,45,opt,name=F_Uint32_defaulted,json=FUint32Defaulted,def=3200" json:"F_Uint32_defaulted,omitempty"` - F_Uint64Defaulted *uint64 `protobuf:"varint,46,opt,name=F_Uint64_defaulted,json=FUint64Defaulted,def=6400" json:"F_Uint64_defaulted,omitempty"` - F_FloatDefaulted *float32 `protobuf:"fixed32,47,opt,name=F_Float_defaulted,json=FFloatDefaulted,def=314159" json:"F_Float_defaulted,omitempty"` - F_DoubleDefaulted *float64 `protobuf:"fixed64,48,opt,name=F_Double_defaulted,json=FDoubleDefaulted,def=271828" json:"F_Double_defaulted,omitempty"` - F_StringDefaulted *string `protobuf:"bytes,49,opt,name=F_String_defaulted,json=FStringDefaulted,def=hello, \"world!\"\n" json:"F_String_defaulted,omitempty"` - F_BytesDefaulted []byte `protobuf:"bytes,401,opt,name=F_Bytes_defaulted,json=FBytesDefaulted,def=Bignose" json:"F_Bytes_defaulted,omitempty"` - F_Sint32Defaulted *int32 `protobuf:"zigzag32,402,opt,name=F_Sint32_defaulted,json=FSint32Defaulted,def=-32" json:"F_Sint32_defaulted,omitempty"` - F_Sint64Defaulted *int64 `protobuf:"zigzag64,403,opt,name=F_Sint64_defaulted,json=FSint64Defaulted,def=-64" json:"F_Sint64_defaulted,omitempty"` + F_BoolDefaulted *bool `protobuf:"varint,40,opt,name=F_Bool_defaulted,def=1" json:"F_Bool_defaulted,omitempty"` + F_Int32Defaulted *int32 `protobuf:"varint,41,opt,name=F_Int32_defaulted,def=32" json:"F_Int32_defaulted,omitempty"` + F_Int64Defaulted *int64 `protobuf:"varint,42,opt,name=F_Int64_defaulted,def=64" json:"F_Int64_defaulted,omitempty"` + F_Fixed32Defaulted *uint32 `protobuf:"fixed32,43,opt,name=F_Fixed32_defaulted,def=320" json:"F_Fixed32_defaulted,omitempty"` + F_Fixed64Defaulted *uint64 `protobuf:"fixed64,44,opt,name=F_Fixed64_defaulted,def=640" json:"F_Fixed64_defaulted,omitempty"` + F_Uint32Defaulted *uint32 `protobuf:"varint,45,opt,name=F_Uint32_defaulted,def=3200" json:"F_Uint32_defaulted,omitempty"` + F_Uint64Defaulted *uint64 `protobuf:"varint,46,opt,name=F_Uint64_defaulted,def=6400" json:"F_Uint64_defaulted,omitempty"` + F_FloatDefaulted *float32 `protobuf:"fixed32,47,opt,name=F_Float_defaulted,def=314159" json:"F_Float_defaulted,omitempty"` + F_DoubleDefaulted *float64 `protobuf:"fixed64,48,opt,name=F_Double_defaulted,def=271828" json:"F_Double_defaulted,omitempty"` + F_StringDefaulted *string `protobuf:"bytes,49,opt,name=F_String_defaulted,def=hello, \"world!\"\n" json:"F_String_defaulted,omitempty"` + F_BytesDefaulted []byte `protobuf:"bytes,401,opt,name=F_Bytes_defaulted,def=Bignose" json:"F_Bytes_defaulted,omitempty"` + F_Sint32Defaulted *int32 `protobuf:"zigzag32,402,opt,name=F_Sint32_defaulted,def=-32" json:"F_Sint32_defaulted,omitempty"` + F_Sint64Defaulted *int64 `protobuf:"zigzag64,403,opt,name=F_Sint64_defaulted,def=-64" json:"F_Sint64_defaulted,omitempty"` // Packed repeated fields (no string or bytes). - F_BoolRepeatedPacked []bool `protobuf:"varint,50,rep,packed,name=F_Bool_repeated_packed,json=FBoolRepeatedPacked" json:"F_Bool_repeated_packed,omitempty"` - F_Int32RepeatedPacked []int32 `protobuf:"varint,51,rep,packed,name=F_Int32_repeated_packed,json=FInt32RepeatedPacked" json:"F_Int32_repeated_packed,omitempty"` - F_Int64RepeatedPacked []int64 `protobuf:"varint,52,rep,packed,name=F_Int64_repeated_packed,json=FInt64RepeatedPacked" json:"F_Int64_repeated_packed,omitempty"` - F_Fixed32RepeatedPacked []uint32 `protobuf:"fixed32,53,rep,packed,name=F_Fixed32_repeated_packed,json=FFixed32RepeatedPacked" json:"F_Fixed32_repeated_packed,omitempty"` - F_Fixed64RepeatedPacked []uint64 `protobuf:"fixed64,54,rep,packed,name=F_Fixed64_repeated_packed,json=FFixed64RepeatedPacked" json:"F_Fixed64_repeated_packed,omitempty"` - F_Uint32RepeatedPacked []uint32 `protobuf:"varint,55,rep,packed,name=F_Uint32_repeated_packed,json=FUint32RepeatedPacked" json:"F_Uint32_repeated_packed,omitempty"` - F_Uint64RepeatedPacked []uint64 `protobuf:"varint,56,rep,packed,name=F_Uint64_repeated_packed,json=FUint64RepeatedPacked" json:"F_Uint64_repeated_packed,omitempty"` - F_FloatRepeatedPacked []float32 `protobuf:"fixed32,57,rep,packed,name=F_Float_repeated_packed,json=FFloatRepeatedPacked" json:"F_Float_repeated_packed,omitempty"` - F_DoubleRepeatedPacked []float64 `protobuf:"fixed64,58,rep,packed,name=F_Double_repeated_packed,json=FDoubleRepeatedPacked" json:"F_Double_repeated_packed,omitempty"` - F_Sint32RepeatedPacked []int32 `protobuf:"zigzag32,502,rep,packed,name=F_Sint32_repeated_packed,json=FSint32RepeatedPacked" json:"F_Sint32_repeated_packed,omitempty"` - F_Sint64RepeatedPacked []int64 `protobuf:"zigzag64,503,rep,packed,name=F_Sint64_repeated_packed,json=FSint64RepeatedPacked" json:"F_Sint64_repeated_packed,omitempty"` - Requiredgroup *GoTest_RequiredGroup `protobuf:"group,70,req,name=RequiredGroup,json=requiredgroup" json:"requiredgroup,omitempty"` - Repeatedgroup []*GoTest_RepeatedGroup `protobuf:"group,80,rep,name=RepeatedGroup,json=repeatedgroup" json:"repeatedgroup,omitempty"` - Optionalgroup *GoTest_OptionalGroup `protobuf:"group,90,opt,name=OptionalGroup,json=optionalgroup" json:"optionalgroup,omitempty"` + F_BoolRepeatedPacked []bool `protobuf:"varint,50,rep,packed,name=F_Bool_repeated_packed" json:"F_Bool_repeated_packed,omitempty"` + F_Int32RepeatedPacked []int32 `protobuf:"varint,51,rep,packed,name=F_Int32_repeated_packed" json:"F_Int32_repeated_packed,omitempty"` + F_Int64RepeatedPacked []int64 `protobuf:"varint,52,rep,packed,name=F_Int64_repeated_packed" json:"F_Int64_repeated_packed,omitempty"` + F_Fixed32RepeatedPacked []uint32 `protobuf:"fixed32,53,rep,packed,name=F_Fixed32_repeated_packed" json:"F_Fixed32_repeated_packed,omitempty"` + F_Fixed64RepeatedPacked []uint64 `protobuf:"fixed64,54,rep,packed,name=F_Fixed64_repeated_packed" json:"F_Fixed64_repeated_packed,omitempty"` + F_Uint32RepeatedPacked []uint32 `protobuf:"varint,55,rep,packed,name=F_Uint32_repeated_packed" json:"F_Uint32_repeated_packed,omitempty"` + F_Uint64RepeatedPacked []uint64 `protobuf:"varint,56,rep,packed,name=F_Uint64_repeated_packed" json:"F_Uint64_repeated_packed,omitempty"` + F_FloatRepeatedPacked []float32 `protobuf:"fixed32,57,rep,packed,name=F_Float_repeated_packed" json:"F_Float_repeated_packed,omitempty"` + F_DoubleRepeatedPacked []float64 `protobuf:"fixed64,58,rep,packed,name=F_Double_repeated_packed" json:"F_Double_repeated_packed,omitempty"` + F_Sint32RepeatedPacked []int32 `protobuf:"zigzag32,502,rep,packed,name=F_Sint32_repeated_packed" json:"F_Sint32_repeated_packed,omitempty"` + F_Sint64RepeatedPacked []int64 `protobuf:"zigzag64,503,rep,packed,name=F_Sint64_repeated_packed" json:"F_Sint64_repeated_packed,omitempty"` + Requiredgroup *GoTest_RequiredGroup `protobuf:"group,70,req,name=RequiredGroup" json:"requiredgroup,omitempty"` + Repeatedgroup []*GoTest_RepeatedGroup `protobuf:"group,80,rep,name=RepeatedGroup" json:"repeatedgroup,omitempty"` + Optionalgroup *GoTest_OptionalGroup `protobuf:"group,90,opt,name=OptionalGroup" json:"optionalgroup,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -961,10 +957,9 @@ type GoTest_RequiredGroup struct { XXX_unrecognized []byte `json:"-"` } -func (m *GoTest_RequiredGroup) Reset() { *m = GoTest_RequiredGroup{} } -func (m *GoTest_RequiredGroup) String() string { return proto.CompactTextString(m) } -func (*GoTest_RequiredGroup) ProtoMessage() {} -func (*GoTest_RequiredGroup) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2, 0} } +func (m *GoTest_RequiredGroup) Reset() { *m = GoTest_RequiredGroup{} } +func (m *GoTest_RequiredGroup) String() string { return proto.CompactTextString(m) } +func (*GoTest_RequiredGroup) ProtoMessage() {} func (m *GoTest_RequiredGroup) GetRequiredField() string { if m != nil && m.RequiredField != nil { @@ -978,10 +973,9 @@ type GoTest_RepeatedGroup struct { XXX_unrecognized []byte `json:"-"` } -func (m *GoTest_RepeatedGroup) Reset() { *m = GoTest_RepeatedGroup{} } -func (m *GoTest_RepeatedGroup) String() string { return proto.CompactTextString(m) } -func (*GoTest_RepeatedGroup) ProtoMessage() {} -func (*GoTest_RepeatedGroup) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2, 1} } +func (m *GoTest_RepeatedGroup) Reset() { *m = GoTest_RepeatedGroup{} } +func (m *GoTest_RepeatedGroup) String() string { return proto.CompactTextString(m) } +func (*GoTest_RepeatedGroup) ProtoMessage() {} func (m *GoTest_RepeatedGroup) GetRequiredField() string { if m != nil && m.RequiredField != nil { @@ -995,10 +989,9 @@ type GoTest_OptionalGroup struct { XXX_unrecognized []byte `json:"-"` } -func (m *GoTest_OptionalGroup) Reset() { *m = GoTest_OptionalGroup{} } -func (m *GoTest_OptionalGroup) String() string { return proto.CompactTextString(m) } -func (*GoTest_OptionalGroup) ProtoMessage() {} -func (*GoTest_OptionalGroup) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2, 2} } +func (m *GoTest_OptionalGroup) Reset() { *m = GoTest_OptionalGroup{} } +func (m *GoTest_OptionalGroup) String() string { return proto.CompactTextString(m) } +func (*GoTest_OptionalGroup) ProtoMessage() {} func (m *GoTest_OptionalGroup) GetRequiredField() string { if m != nil && m.RequiredField != nil { @@ -1007,59 +1000,22 @@ func (m *GoTest_OptionalGroup) GetRequiredField() string { return "" } -// For testing a group containing a required field. -type GoTestRequiredGroupField struct { - Group *GoTestRequiredGroupField_Group `protobuf:"group,1,req,name=Group,json=group" json:"group,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *GoTestRequiredGroupField) Reset() { *m = GoTestRequiredGroupField{} } -func (m *GoTestRequiredGroupField) String() string { return proto.CompactTextString(m) } -func (*GoTestRequiredGroupField) ProtoMessage() {} -func (*GoTestRequiredGroupField) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } - -func (m *GoTestRequiredGroupField) GetGroup() *GoTestRequiredGroupField_Group { - if m != nil { - return m.Group - } - return nil -} - -type GoTestRequiredGroupField_Group struct { - Field *int32 `protobuf:"varint,2,req,name=Field" json:"Field,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *GoTestRequiredGroupField_Group) Reset() { *m = GoTestRequiredGroupField_Group{} } -func (m *GoTestRequiredGroupField_Group) String() string { return proto.CompactTextString(m) } -func (*GoTestRequiredGroupField_Group) ProtoMessage() {} -func (*GoTestRequiredGroupField_Group) Descriptor() ([]byte, []int) { - return fileDescriptor0, []int{3, 0} -} - -func (m *GoTestRequiredGroupField_Group) GetField() int32 { - if m != nil && m.Field != nil { - return *m.Field - } - return 0 -} - // For testing skipping of unrecognized fields. // Numbers are all big, larger than tag numbers in GoTestField, // the message used in the corresponding test. type GoSkipTest struct { - SkipInt32 *int32 `protobuf:"varint,11,req,name=skip_int32,json=skipInt32" json:"skip_int32,omitempty"` - SkipFixed32 *uint32 `protobuf:"fixed32,12,req,name=skip_fixed32,json=skipFixed32" json:"skip_fixed32,omitempty"` - SkipFixed64 *uint64 `protobuf:"fixed64,13,req,name=skip_fixed64,json=skipFixed64" json:"skip_fixed64,omitempty"` - SkipString *string `protobuf:"bytes,14,req,name=skip_string,json=skipString" json:"skip_string,omitempty"` - Skipgroup *GoSkipTest_SkipGroup `protobuf:"group,15,req,name=SkipGroup,json=skipgroup" json:"skipgroup,omitempty"` + SkipInt32 *int32 `protobuf:"varint,11,req,name=skip_int32" json:"skip_int32,omitempty"` + SkipFixed32 *uint32 `protobuf:"fixed32,12,req,name=skip_fixed32" json:"skip_fixed32,omitempty"` + SkipFixed64 *uint64 `protobuf:"fixed64,13,req,name=skip_fixed64" json:"skip_fixed64,omitempty"` + SkipString *string `protobuf:"bytes,14,req,name=skip_string" json:"skip_string,omitempty"` + Skipgroup *GoSkipTest_SkipGroup `protobuf:"group,15,req,name=SkipGroup" json:"skipgroup,omitempty"` XXX_unrecognized []byte `json:"-"` } func (m *GoSkipTest) Reset() { *m = GoSkipTest{} } func (m *GoSkipTest) String() string { return proto.CompactTextString(m) } func (*GoSkipTest) ProtoMessage() {} -func (*GoSkipTest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } +func (*GoSkipTest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } func (m *GoSkipTest) GetSkipInt32() int32 { if m != nil && m.SkipInt32 != nil { @@ -1097,15 +1053,14 @@ func (m *GoSkipTest) GetSkipgroup() *GoSkipTest_SkipGroup { } type GoSkipTest_SkipGroup struct { - GroupInt32 *int32 `protobuf:"varint,16,req,name=group_int32,json=groupInt32" json:"group_int32,omitempty"` - GroupString *string `protobuf:"bytes,17,req,name=group_string,json=groupString" json:"group_string,omitempty"` + GroupInt32 *int32 `protobuf:"varint,16,req,name=group_int32" json:"group_int32,omitempty"` + GroupString *string `protobuf:"bytes,17,req,name=group_string" json:"group_string,omitempty"` XXX_unrecognized []byte `json:"-"` } -func (m *GoSkipTest_SkipGroup) Reset() { *m = GoSkipTest_SkipGroup{} } -func (m *GoSkipTest_SkipGroup) String() string { return proto.CompactTextString(m) } -func (*GoSkipTest_SkipGroup) ProtoMessage() {} -func (*GoSkipTest_SkipGroup) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4, 0} } +func (m *GoSkipTest_SkipGroup) Reset() { *m = GoSkipTest_SkipGroup{} } +func (m *GoSkipTest_SkipGroup) String() string { return proto.CompactTextString(m) } +func (*GoSkipTest_SkipGroup) ProtoMessage() {} func (m *GoSkipTest_SkipGroup) GetGroupInt32() int32 { if m != nil && m.GroupInt32 != nil { @@ -1131,7 +1086,7 @@ type NonPackedTest struct { func (m *NonPackedTest) Reset() { *m = NonPackedTest{} } func (m *NonPackedTest) String() string { return proto.CompactTextString(m) } func (*NonPackedTest) ProtoMessage() {} -func (*NonPackedTest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } +func (*NonPackedTest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } func (m *NonPackedTest) GetA() []int32 { if m != nil { @@ -1148,7 +1103,7 @@ type PackedTest struct { func (m *PackedTest) Reset() { *m = PackedTest{} } func (m *PackedTest) String() string { return proto.CompactTextString(m) } func (*PackedTest) ProtoMessage() {} -func (*PackedTest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } +func (*PackedTest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } func (m *PackedTest) GetB() []int32 { if m != nil { @@ -1159,14 +1114,14 @@ func (m *PackedTest) GetB() []int32 { type MaxTag struct { // Maximum possible tag number. - LastField *string `protobuf:"bytes,536870911,opt,name=last_field,json=lastField" json:"last_field,omitempty"` + LastField *string `protobuf:"bytes,536870911,opt,name=last_field" json:"last_field,omitempty"` XXX_unrecognized []byte `json:"-"` } func (m *MaxTag) Reset() { *m = MaxTag{} } func (m *MaxTag) String() string { return proto.CompactTextString(m) } func (*MaxTag) ProtoMessage() {} -func (*MaxTag) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } +func (*MaxTag) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } func (m *MaxTag) GetLastField() string { if m != nil && m.LastField != nil { @@ -1184,7 +1139,7 @@ type OldMessage struct { func (m *OldMessage) Reset() { *m = OldMessage{} } func (m *OldMessage) String() string { return proto.CompactTextString(m) } func (*OldMessage) ProtoMessage() {} -func (*OldMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } +func (*OldMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } func (m *OldMessage) GetNested() *OldMessage_Nested { if m != nil { @@ -1208,7 +1163,7 @@ type OldMessage_Nested struct { func (m *OldMessage_Nested) Reset() { *m = OldMessage_Nested{} } func (m *OldMessage_Nested) String() string { return proto.CompactTextString(m) } func (*OldMessage_Nested) ProtoMessage() {} -func (*OldMessage_Nested) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8, 0} } +func (*OldMessage_Nested) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7, 0} } func (m *OldMessage_Nested) GetName() string { if m != nil && m.Name != nil { @@ -1229,7 +1184,7 @@ type NewMessage struct { func (m *NewMessage) Reset() { *m = NewMessage{} } func (m *NewMessage) String() string { return proto.CompactTextString(m) } func (*NewMessage) ProtoMessage() {} -func (*NewMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} } +func (*NewMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } func (m *NewMessage) GetNested() *NewMessage_Nested { if m != nil { @@ -1247,14 +1202,14 @@ func (m *NewMessage) GetNum() int64 { type NewMessage_Nested struct { Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - FoodGroup *string `protobuf:"bytes,2,opt,name=food_group,json=foodGroup" json:"food_group,omitempty"` + FoodGroup *string `protobuf:"bytes,2,opt,name=food_group" json:"food_group,omitempty"` XXX_unrecognized []byte `json:"-"` } func (m *NewMessage_Nested) Reset() { *m = NewMessage_Nested{} } func (m *NewMessage_Nested) String() string { return proto.CompactTextString(m) } func (*NewMessage_Nested) ProtoMessage() {} -func (*NewMessage_Nested) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9, 0} } +func (*NewMessage_Nested) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8, 0} } func (m *NewMessage_Nested) GetName() string { if m != nil && m.Name != nil { @@ -1280,7 +1235,7 @@ type InnerMessage struct { func (m *InnerMessage) Reset() { *m = InnerMessage{} } func (m *InnerMessage) String() string { return proto.CompactTextString(m) } func (*InnerMessage) ProtoMessage() {} -func (*InnerMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } +func (*InnerMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} } const Default_InnerMessage_Port int32 = 4000 @@ -1306,18 +1261,18 @@ func (m *InnerMessage) GetConnected() bool { } type OtherMessage struct { - Key *int64 `protobuf:"varint,1,opt,name=key" json:"key,omitempty"` - Value []byte `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` - Weight *float32 `protobuf:"fixed32,3,opt,name=weight" json:"weight,omitempty"` - Inner *InnerMessage `protobuf:"bytes,4,opt,name=inner" json:"inner,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + Key *int64 `protobuf:"varint,1,opt,name=key" json:"key,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` + Weight *float32 `protobuf:"fixed32,3,opt,name=weight" json:"weight,omitempty"` + Inner *InnerMessage `protobuf:"bytes,4,opt,name=inner" json:"inner,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *OtherMessage) Reset() { *m = OtherMessage{} } func (m *OtherMessage) String() string { return proto.CompactTextString(m) } func (*OtherMessage) ProtoMessage() {} -func (*OtherMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } +func (*OtherMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } var extRange_OtherMessage = []proto.ExtensionRange{ {100, 536870911}, @@ -1326,6 +1281,12 @@ var extRange_OtherMessage = []proto.ExtensionRange{ func (*OtherMessage) ExtensionRangeArray() []proto.ExtensionRange { return extRange_OtherMessage } +func (m *OtherMessage) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} func (m *OtherMessage) GetKey() int64 { if m != nil && m.Key != nil { @@ -1355,45 +1316,27 @@ func (m *OtherMessage) GetInner() *InnerMessage { return nil } -type RequiredInnerMessage struct { - LeoFinallyWonAnOscar *InnerMessage `protobuf:"bytes,1,req,name=leo_finally_won_an_oscar,json=leoFinallyWonAnOscar" json:"leo_finally_won_an_oscar,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *RequiredInnerMessage) Reset() { *m = RequiredInnerMessage{} } -func (m *RequiredInnerMessage) String() string { return proto.CompactTextString(m) } -func (*RequiredInnerMessage) ProtoMessage() {} -func (*RequiredInnerMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } - -func (m *RequiredInnerMessage) GetLeoFinallyWonAnOscar() *InnerMessage { - if m != nil { - return m.LeoFinallyWonAnOscar - } - return nil -} - type MyMessage struct { - Count *int32 `protobuf:"varint,1,req,name=count" json:"count,omitempty"` - Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` - Quote *string `protobuf:"bytes,3,opt,name=quote" json:"quote,omitempty"` - Pet []string `protobuf:"bytes,4,rep,name=pet" json:"pet,omitempty"` - Inner *InnerMessage `protobuf:"bytes,5,opt,name=inner" json:"inner,omitempty"` - Others []*OtherMessage `protobuf:"bytes,6,rep,name=others" json:"others,omitempty"` - WeMustGoDeeper *RequiredInnerMessage `protobuf:"bytes,13,opt,name=we_must_go_deeper,json=weMustGoDeeper" json:"we_must_go_deeper,omitempty"` - RepInner []*InnerMessage `protobuf:"bytes,12,rep,name=rep_inner,json=repInner" json:"rep_inner,omitempty"` - Bikeshed *MyMessage_Color `protobuf:"varint,7,opt,name=bikeshed,enum=testdata.MyMessage_Color" json:"bikeshed,omitempty"` - Somegroup *MyMessage_SomeGroup `protobuf:"group,8,opt,name=SomeGroup,json=somegroup" json:"somegroup,omitempty"` + Count *int32 `protobuf:"varint,1,req,name=count" json:"count,omitempty"` + Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` + Quote *string `protobuf:"bytes,3,opt,name=quote" json:"quote,omitempty"` + Pet []string `protobuf:"bytes,4,rep,name=pet" json:"pet,omitempty"` + Inner *InnerMessage `protobuf:"bytes,5,opt,name=inner" json:"inner,omitempty"` + Others []*OtherMessage `protobuf:"bytes,6,rep,name=others" json:"others,omitempty"` + RepInner []*InnerMessage `protobuf:"bytes,12,rep,name=rep_inner" json:"rep_inner,omitempty"` + Bikeshed *MyMessage_Color `protobuf:"varint,7,opt,name=bikeshed,enum=testdata.MyMessage_Color" json:"bikeshed,omitempty"` + Somegroup *MyMessage_SomeGroup `protobuf:"group,8,opt,name=SomeGroup" json:"somegroup,omitempty"` // This field becomes [][]byte in the generated code. - RepBytes [][]byte `protobuf:"bytes,10,rep,name=rep_bytes,json=repBytes" json:"rep_bytes,omitempty"` - Bigfloat *float64 `protobuf:"fixed64,11,opt,name=bigfloat" json:"bigfloat,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + RepBytes [][]byte `protobuf:"bytes,10,rep,name=rep_bytes" json:"rep_bytes,omitempty"` + Bigfloat *float64 `protobuf:"fixed64,11,opt,name=bigfloat" json:"bigfloat,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *MyMessage) Reset() { *m = MyMessage{} } func (m *MyMessage) String() string { return proto.CompactTextString(m) } func (*MyMessage) ProtoMessage() {} -func (*MyMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } +func (*MyMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } var extRange_MyMessage = []proto.ExtensionRange{ {100, 536870911}, @@ -1402,6 +1345,12 @@ var extRange_MyMessage = []proto.ExtensionRange{ func (*MyMessage) ExtensionRangeArray() []proto.ExtensionRange { return extRange_MyMessage } +func (m *MyMessage) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} func (m *MyMessage) GetCount() int32 { if m != nil && m.Count != nil { @@ -1445,13 +1394,6 @@ func (m *MyMessage) GetOthers() []*OtherMessage { return nil } -func (m *MyMessage) GetWeMustGoDeeper() *RequiredInnerMessage { - if m != nil { - return m.WeMustGoDeeper - } - return nil -} - func (m *MyMessage) GetRepInner() []*InnerMessage { if m != nil { return m.RepInner @@ -1488,14 +1430,13 @@ func (m *MyMessage) GetBigfloat() float64 { } type MyMessage_SomeGroup struct { - GroupField *int32 `protobuf:"varint,9,opt,name=group_field,json=groupField" json:"group_field,omitempty"` + GroupField *int32 `protobuf:"varint,9,opt,name=group_field" json:"group_field,omitempty"` XXX_unrecognized []byte `json:"-"` } -func (m *MyMessage_SomeGroup) Reset() { *m = MyMessage_SomeGroup{} } -func (m *MyMessage_SomeGroup) String() string { return proto.CompactTextString(m) } -func (*MyMessage_SomeGroup) ProtoMessage() {} -func (*MyMessage_SomeGroup) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13, 0} } +func (m *MyMessage_SomeGroup) Reset() { *m = MyMessage_SomeGroup{} } +func (m *MyMessage_SomeGroup) String() string { return proto.CompactTextString(m) } +func (*MyMessage_SomeGroup) ProtoMessage() {} func (m *MyMessage_SomeGroup) GetGroupField() int32 { if m != nil && m.GroupField != nil { @@ -1512,7 +1453,7 @@ type Ext struct { func (m *Ext) Reset() { *m = Ext{} } func (m *Ext) String() string { return proto.CompactTextString(m) } func (*Ext) ProtoMessage() {} -func (*Ext) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} } +func (*Ext) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } func (m *Ext) GetData() string { if m != nil && m.Data != nil { @@ -1527,7 +1468,6 @@ var E_Ext_More = &proto.ExtensionDesc{ Field: 103, Name: "testdata.Ext.more", Tag: "bytes,103,opt,name=more", - Filename: "test.proto", } var E_Ext_Text = &proto.ExtensionDesc{ @@ -1536,7 +1476,6 @@ var E_Ext_Text = &proto.ExtensionDesc{ Field: 104, Name: "testdata.Ext.text", Tag: "bytes,104,opt,name=text", - Filename: "test.proto", } var E_Ext_Number = &proto.ExtensionDesc{ @@ -1545,7 +1484,6 @@ var E_Ext_Number = &proto.ExtensionDesc{ Field: 105, Name: "testdata.Ext.number", Tag: "varint,105,opt,name=number", - Filename: "test.proto", } type ComplexExtension struct { @@ -1558,7 +1496,7 @@ type ComplexExtension struct { func (m *ComplexExtension) Reset() { *m = ComplexExtension{} } func (m *ComplexExtension) String() string { return proto.CompactTextString(m) } func (*ComplexExtension) ProtoMessage() {} -func (*ComplexExtension) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} } +func (*ComplexExtension) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } func (m *ComplexExtension) GetFirst() int32 { if m != nil && m.First != nil { @@ -1582,14 +1520,14 @@ func (m *ComplexExtension) GetThird() []int32 { } type DefaultsMessage struct { - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *DefaultsMessage) Reset() { *m = DefaultsMessage{} } func (m *DefaultsMessage) String() string { return proto.CompactTextString(m) } func (*DefaultsMessage) ProtoMessage() {} -func (*DefaultsMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} } +func (*DefaultsMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} } var extRange_DefaultsMessage = []proto.ExtensionRange{ {100, 536870911}, @@ -1598,28 +1536,34 @@ var extRange_DefaultsMessage = []proto.ExtensionRange{ func (*DefaultsMessage) ExtensionRangeArray() []proto.ExtensionRange { return extRange_DefaultsMessage } +func (m *DefaultsMessage) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} type MyMessageSet struct { - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *MyMessageSet) Reset() { *m = MyMessageSet{} } func (m *MyMessageSet) String() string { return proto.CompactTextString(m) } func (*MyMessageSet) ProtoMessage() {} -func (*MyMessageSet) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} } +func (*MyMessageSet) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} } func (m *MyMessageSet) Marshal() ([]byte, error) { - return proto.MarshalMessageSet(&m.XXX_InternalExtensions) + return proto.MarshalMessageSet(m.ExtensionMap()) } func (m *MyMessageSet) Unmarshal(buf []byte) error { - return proto.UnmarshalMessageSet(buf, &m.XXX_InternalExtensions) + return proto.UnmarshalMessageSet(buf, m.ExtensionMap()) } func (m *MyMessageSet) MarshalJSON() ([]byte, error) { - return proto.MarshalMessageSetJSON(&m.XXX_InternalExtensions) + return proto.MarshalMessageSetJSON(m.XXX_extensions) } func (m *MyMessageSet) UnmarshalJSON(buf []byte) error { - return proto.UnmarshalMessageSetJSON(buf, &m.XXX_InternalExtensions) + return proto.UnmarshalMessageSetJSON(buf, m.XXX_extensions) } // ensure MyMessageSet satisfies proto.Marshaler and proto.Unmarshaler @@ -1633,6 +1577,12 @@ var extRange_MyMessageSet = []proto.ExtensionRange{ func (*MyMessageSet) ExtensionRangeArray() []proto.ExtensionRange { return extRange_MyMessageSet } +func (m *MyMessageSet) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} type Empty struct { XXX_unrecognized []byte `json:"-"` @@ -1641,17 +1591,17 @@ type Empty struct { func (m *Empty) Reset() { *m = Empty{} } func (m *Empty) String() string { return proto.CompactTextString(m) } func (*Empty) ProtoMessage() {} -func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} } +func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} } type MessageList struct { - Message []*MessageList_Message `protobuf:"group,1,rep,name=Message,json=message" json:"message,omitempty"` + Message []*MessageList_Message `protobuf:"group,1,rep,name=Message" json:"message,omitempty"` XXX_unrecognized []byte `json:"-"` } func (m *MessageList) Reset() { *m = MessageList{} } func (m *MessageList) String() string { return proto.CompactTextString(m) } func (*MessageList) ProtoMessage() {} -func (*MessageList) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{19} } +func (*MessageList) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} } func (m *MessageList) GetMessage() []*MessageList_Message { if m != nil { @@ -1666,10 +1616,9 @@ type MessageList_Message struct { XXX_unrecognized []byte `json:"-"` } -func (m *MessageList_Message) Reset() { *m = MessageList_Message{} } -func (m *MessageList_Message) String() string { return proto.CompactTextString(m) } -func (*MessageList_Message) ProtoMessage() {} -func (*MessageList_Message) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{19, 0} } +func (m *MessageList_Message) Reset() { *m = MessageList_Message{} } +func (m *MessageList_Message) String() string { return proto.CompactTextString(m) } +func (*MessageList_Message) ProtoMessage() {} func (m *MessageList_Message) GetName() string { if m != nil && m.Name != nil { @@ -1686,15 +1635,15 @@ func (m *MessageList_Message) GetCount() int32 { } type Strings struct { - StringField *string `protobuf:"bytes,1,opt,name=string_field,json=stringField" json:"string_field,omitempty"` - BytesField []byte `protobuf:"bytes,2,opt,name=bytes_field,json=bytesField" json:"bytes_field,omitempty"` + StringField *string `protobuf:"bytes,1,opt,name=string_field" json:"string_field,omitempty"` + BytesField []byte `protobuf:"bytes,2,opt,name=bytes_field" json:"bytes_field,omitempty"` XXX_unrecognized []byte `json:"-"` } func (m *Strings) Reset() { *m = Strings{} } func (m *Strings) String() string { return proto.CompactTextString(m) } func (*Strings) ProtoMessage() {} -func (*Strings) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{20} } +func (*Strings) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} } func (m *Strings) GetStringField() string { if m != nil && m.StringField != nil { @@ -1713,35 +1662,35 @@ func (m *Strings) GetBytesField() []byte { type Defaults struct { // Default-valued fields of all basic types. // Same as GoTest, but copied here to make testing easier. - F_Bool *bool `protobuf:"varint,1,opt,name=F_Bool,json=FBool,def=1" json:"F_Bool,omitempty"` - F_Int32 *int32 `protobuf:"varint,2,opt,name=F_Int32,json=FInt32,def=32" json:"F_Int32,omitempty"` - F_Int64 *int64 `protobuf:"varint,3,opt,name=F_Int64,json=FInt64,def=64" json:"F_Int64,omitempty"` - F_Fixed32 *uint32 `protobuf:"fixed32,4,opt,name=F_Fixed32,json=FFixed32,def=320" json:"F_Fixed32,omitempty"` - F_Fixed64 *uint64 `protobuf:"fixed64,5,opt,name=F_Fixed64,json=FFixed64,def=640" json:"F_Fixed64,omitempty"` - F_Uint32 *uint32 `protobuf:"varint,6,opt,name=F_Uint32,json=FUint32,def=3200" json:"F_Uint32,omitempty"` - F_Uint64 *uint64 `protobuf:"varint,7,opt,name=F_Uint64,json=FUint64,def=6400" json:"F_Uint64,omitempty"` - F_Float *float32 `protobuf:"fixed32,8,opt,name=F_Float,json=FFloat,def=314159" json:"F_Float,omitempty"` - F_Double *float64 `protobuf:"fixed64,9,opt,name=F_Double,json=FDouble,def=271828" json:"F_Double,omitempty"` - F_String *string `protobuf:"bytes,10,opt,name=F_String,json=FString,def=hello, \"world!\"\n" json:"F_String,omitempty"` - F_Bytes []byte `protobuf:"bytes,11,opt,name=F_Bytes,json=FBytes,def=Bignose" json:"F_Bytes,omitempty"` - F_Sint32 *int32 `protobuf:"zigzag32,12,opt,name=F_Sint32,json=FSint32,def=-32" json:"F_Sint32,omitempty"` - F_Sint64 *int64 `protobuf:"zigzag64,13,opt,name=F_Sint64,json=FSint64,def=-64" json:"F_Sint64,omitempty"` - F_Enum *Defaults_Color `protobuf:"varint,14,opt,name=F_Enum,json=FEnum,enum=testdata.Defaults_Color,def=1" json:"F_Enum,omitempty"` + F_Bool *bool `protobuf:"varint,1,opt,name=F_Bool,def=1" json:"F_Bool,omitempty"` + F_Int32 *int32 `protobuf:"varint,2,opt,name=F_Int32,def=32" json:"F_Int32,omitempty"` + F_Int64 *int64 `protobuf:"varint,3,opt,name=F_Int64,def=64" json:"F_Int64,omitempty"` + F_Fixed32 *uint32 `protobuf:"fixed32,4,opt,name=F_Fixed32,def=320" json:"F_Fixed32,omitempty"` + F_Fixed64 *uint64 `protobuf:"fixed64,5,opt,name=F_Fixed64,def=640" json:"F_Fixed64,omitempty"` + F_Uint32 *uint32 `protobuf:"varint,6,opt,name=F_Uint32,def=3200" json:"F_Uint32,omitempty"` + F_Uint64 *uint64 `protobuf:"varint,7,opt,name=F_Uint64,def=6400" json:"F_Uint64,omitempty"` + F_Float *float32 `protobuf:"fixed32,8,opt,name=F_Float,def=314159" json:"F_Float,omitempty"` + F_Double *float64 `protobuf:"fixed64,9,opt,name=F_Double,def=271828" json:"F_Double,omitempty"` + F_String *string `protobuf:"bytes,10,opt,name=F_String,def=hello, \"world!\"\n" json:"F_String,omitempty"` + F_Bytes []byte `protobuf:"bytes,11,opt,name=F_Bytes,def=Bignose" json:"F_Bytes,omitempty"` + F_Sint32 *int32 `protobuf:"zigzag32,12,opt,name=F_Sint32,def=-32" json:"F_Sint32,omitempty"` + F_Sint64 *int64 `protobuf:"zigzag64,13,opt,name=F_Sint64,def=-64" json:"F_Sint64,omitempty"` + F_Enum *Defaults_Color `protobuf:"varint,14,opt,name=F_Enum,enum=testdata.Defaults_Color,def=1" json:"F_Enum,omitempty"` // More fields with crazy defaults. - F_Pinf *float32 `protobuf:"fixed32,15,opt,name=F_Pinf,json=FPinf,def=inf" json:"F_Pinf,omitempty"` - F_Ninf *float32 `protobuf:"fixed32,16,opt,name=F_Ninf,json=FNinf,def=-inf" json:"F_Ninf,omitempty"` - F_Nan *float32 `protobuf:"fixed32,17,opt,name=F_Nan,json=FNan,def=nan" json:"F_Nan,omitempty"` + F_Pinf *float32 `protobuf:"fixed32,15,opt,name=F_Pinf,def=inf" json:"F_Pinf,omitempty"` + F_Ninf *float32 `protobuf:"fixed32,16,opt,name=F_Ninf,def=-inf" json:"F_Ninf,omitempty"` + F_Nan *float32 `protobuf:"fixed32,17,opt,name=F_Nan,def=nan" json:"F_Nan,omitempty"` // Sub-message. Sub *SubDefaults `protobuf:"bytes,18,opt,name=sub" json:"sub,omitempty"` // Redundant but explicit defaults. - StrZero *string `protobuf:"bytes,19,opt,name=str_zero,json=strZero,def=" json:"str_zero,omitempty"` + StrZero *string `protobuf:"bytes,19,opt,name=str_zero,def=" json:"str_zero,omitempty"` XXX_unrecognized []byte `json:"-"` } func (m *Defaults) Reset() { *m = Defaults{} } func (m *Defaults) String() string { return proto.CompactTextString(m) } func (*Defaults) ProtoMessage() {} -func (*Defaults) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{21} } +func (*Defaults) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{19} } const Default_Defaults_F_Bool bool = true const Default_Defaults_F_Int32 int32 = 32 @@ -1905,7 +1854,7 @@ type SubDefaults struct { func (m *SubDefaults) Reset() { *m = SubDefaults{} } func (m *SubDefaults) String() string { return proto.CompactTextString(m) } func (*SubDefaults) ProtoMessage() {} -func (*SubDefaults) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{22} } +func (*SubDefaults) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{20} } const Default_SubDefaults_N int64 = 7 @@ -1924,7 +1873,7 @@ type RepeatedEnum struct { func (m *RepeatedEnum) Reset() { *m = RepeatedEnum{} } func (m *RepeatedEnum) String() string { return proto.CompactTextString(m) } func (*RepeatedEnum) ProtoMessage() {} -func (*RepeatedEnum) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{23} } +func (*RepeatedEnum) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{21} } func (m *RepeatedEnum) GetColor() []RepeatedEnum_Color { if m != nil { @@ -1935,10 +1884,10 @@ func (m *RepeatedEnum) GetColor() []RepeatedEnum_Color { type MoreRepeated struct { Bools []bool `protobuf:"varint,1,rep,name=bools" json:"bools,omitempty"` - BoolsPacked []bool `protobuf:"varint,2,rep,packed,name=bools_packed,json=boolsPacked" json:"bools_packed,omitempty"` + BoolsPacked []bool `protobuf:"varint,2,rep,packed,name=bools_packed" json:"bools_packed,omitempty"` Ints []int32 `protobuf:"varint,3,rep,name=ints" json:"ints,omitempty"` - IntsPacked []int32 `protobuf:"varint,4,rep,packed,name=ints_packed,json=intsPacked" json:"ints_packed,omitempty"` - Int64SPacked []int64 `protobuf:"varint,7,rep,packed,name=int64s_packed,json=int64sPacked" json:"int64s_packed,omitempty"` + IntsPacked []int32 `protobuf:"varint,4,rep,packed,name=ints_packed" json:"ints_packed,omitempty"` + Int64SPacked []int64 `protobuf:"varint,7,rep,packed,name=int64s_packed" json:"int64s_packed,omitempty"` Strings []string `protobuf:"bytes,5,rep,name=strings" json:"strings,omitempty"` Fixeds []uint32 `protobuf:"fixed32,6,rep,name=fixeds" json:"fixeds,omitempty"` XXX_unrecognized []byte `json:"-"` @@ -1947,7 +1896,7 @@ type MoreRepeated struct { func (m *MoreRepeated) Reset() { *m = MoreRepeated{} } func (m *MoreRepeated) String() string { return proto.CompactTextString(m) } func (*MoreRepeated) ProtoMessage() {} -func (*MoreRepeated) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{24} } +func (*MoreRepeated) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{22} } func (m *MoreRepeated) GetBools() []bool { if m != nil { @@ -1999,14 +1948,14 @@ func (m *MoreRepeated) GetFixeds() []uint32 { } type GroupOld struct { - G *GroupOld_G `protobuf:"group,101,opt,name=G,json=g" json:"g,omitempty"` + G *GroupOld_G `protobuf:"group,101,opt,name=G" json:"g,omitempty"` XXX_unrecognized []byte `json:"-"` } func (m *GroupOld) Reset() { *m = GroupOld{} } func (m *GroupOld) String() string { return proto.CompactTextString(m) } func (*GroupOld) ProtoMessage() {} -func (*GroupOld) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{25} } +func (*GroupOld) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{23} } func (m *GroupOld) GetG() *GroupOld_G { if m != nil { @@ -2020,10 +1969,9 @@ type GroupOld_G struct { XXX_unrecognized []byte `json:"-"` } -func (m *GroupOld_G) Reset() { *m = GroupOld_G{} } -func (m *GroupOld_G) String() string { return proto.CompactTextString(m) } -func (*GroupOld_G) ProtoMessage() {} -func (*GroupOld_G) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{25, 0} } +func (m *GroupOld_G) Reset() { *m = GroupOld_G{} } +func (m *GroupOld_G) String() string { return proto.CompactTextString(m) } +func (*GroupOld_G) ProtoMessage() {} func (m *GroupOld_G) GetX() int32 { if m != nil && m.X != nil { @@ -2033,14 +1981,14 @@ func (m *GroupOld_G) GetX() int32 { } type GroupNew struct { - G *GroupNew_G `protobuf:"group,101,opt,name=G,json=g" json:"g,omitempty"` + G *GroupNew_G `protobuf:"group,101,opt,name=G" json:"g,omitempty"` XXX_unrecognized []byte `json:"-"` } func (m *GroupNew) Reset() { *m = GroupNew{} } func (m *GroupNew) String() string { return proto.CompactTextString(m) } func (*GroupNew) ProtoMessage() {} -func (*GroupNew) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{26} } +func (*GroupNew) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{24} } func (m *GroupNew) GetG() *GroupNew_G { if m != nil { @@ -2055,10 +2003,9 @@ type GroupNew_G struct { XXX_unrecognized []byte `json:"-"` } -func (m *GroupNew_G) Reset() { *m = GroupNew_G{} } -func (m *GroupNew_G) String() string { return proto.CompactTextString(m) } -func (*GroupNew_G) ProtoMessage() {} -func (*GroupNew_G) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{26, 0} } +func (m *GroupNew_G) Reset() { *m = GroupNew_G{} } +func (m *GroupNew_G) String() string { return proto.CompactTextString(m) } +func (*GroupNew_G) ProtoMessage() {} func (m *GroupNew_G) GetX() int32 { if m != nil && m.X != nil { @@ -2076,14 +2023,13 @@ func (m *GroupNew_G) GetY() int32 { type FloatingPoint struct { F *float64 `protobuf:"fixed64,1,req,name=f" json:"f,omitempty"` - Exact *bool `protobuf:"varint,2,opt,name=exact" json:"exact,omitempty"` XXX_unrecognized []byte `json:"-"` } func (m *FloatingPoint) Reset() { *m = FloatingPoint{} } func (m *FloatingPoint) String() string { return proto.CompactTextString(m) } func (*FloatingPoint) ProtoMessage() {} -func (*FloatingPoint) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{27} } +func (*FloatingPoint) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{25} } func (m *FloatingPoint) GetF() float64 { if m != nil && m.F != nil { @@ -2092,25 +2038,18 @@ func (m *FloatingPoint) GetF() float64 { return 0 } -func (m *FloatingPoint) GetExact() bool { - if m != nil && m.Exact != nil { - return *m.Exact - } - return false -} - type MessageWithMap struct { - NameMapping map[int32]string `protobuf:"bytes,1,rep,name=name_mapping,json=nameMapping" json:"name_mapping,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - MsgMapping map[int64]*FloatingPoint `protobuf:"bytes,2,rep,name=msg_mapping,json=msgMapping" json:"msg_mapping,omitempty" protobuf_key:"zigzag64,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - ByteMapping map[bool][]byte `protobuf:"bytes,3,rep,name=byte_mapping,json=byteMapping" json:"byte_mapping,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - StrToStr map[string]string `protobuf:"bytes,4,rep,name=str_to_str,json=strToStr" json:"str_to_str,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + NameMapping map[int32]string `protobuf:"bytes,1,rep,name=name_mapping" json:"name_mapping,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + MsgMapping map[int64]*FloatingPoint `protobuf:"bytes,2,rep,name=msg_mapping" json:"msg_mapping,omitempty" protobuf_key:"zigzag64,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + ByteMapping map[bool][]byte `protobuf:"bytes,3,rep,name=byte_mapping" json:"byte_mapping,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + StrToStr map[string]string `protobuf:"bytes,4,rep,name=str_to_str" json:"str_to_str,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` XXX_unrecognized []byte `json:"-"` } func (m *MessageWithMap) Reset() { *m = MessageWithMap{} } func (m *MessageWithMap) String() string { return proto.CompactTextString(m) } func (*MessageWithMap) ProtoMessage() {} -func (*MessageWithMap) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{28} } +func (*MessageWithMap) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{26} } func (m *MessageWithMap) GetNameMapping() map[int32]string { if m != nil { @@ -2169,7 +2108,7 @@ type Oneof struct { func (m *Oneof) Reset() { *m = Oneof{} } func (m *Oneof) String() string { return proto.CompactTextString(m) } func (*Oneof) ProtoMessage() {} -func (*Oneof) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{29} } +func (*Oneof) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{27} } type isOneof_Union interface { isOneof_Union() @@ -2179,55 +2118,55 @@ type isOneof_Tormato interface { } type Oneof_F_Bool struct { - F_Bool bool `protobuf:"varint,1,opt,name=F_Bool,json=FBool,oneof"` + F_Bool bool `protobuf:"varint,1,opt,name=F_Bool,oneof"` } type Oneof_F_Int32 struct { - F_Int32 int32 `protobuf:"varint,2,opt,name=F_Int32,json=FInt32,oneof"` + F_Int32 int32 `protobuf:"varint,2,opt,name=F_Int32,oneof"` } type Oneof_F_Int64 struct { - F_Int64 int64 `protobuf:"varint,3,opt,name=F_Int64,json=FInt64,oneof"` + F_Int64 int64 `protobuf:"varint,3,opt,name=F_Int64,oneof"` } type Oneof_F_Fixed32 struct { - F_Fixed32 uint32 `protobuf:"fixed32,4,opt,name=F_Fixed32,json=FFixed32,oneof"` + F_Fixed32 uint32 `protobuf:"fixed32,4,opt,name=F_Fixed32,oneof"` } type Oneof_F_Fixed64 struct { - F_Fixed64 uint64 `protobuf:"fixed64,5,opt,name=F_Fixed64,json=FFixed64,oneof"` + F_Fixed64 uint64 `protobuf:"fixed64,5,opt,name=F_Fixed64,oneof"` } type Oneof_F_Uint32 struct { - F_Uint32 uint32 `protobuf:"varint,6,opt,name=F_Uint32,json=FUint32,oneof"` + F_Uint32 uint32 `protobuf:"varint,6,opt,name=F_Uint32,oneof"` } type Oneof_F_Uint64 struct { - F_Uint64 uint64 `protobuf:"varint,7,opt,name=F_Uint64,json=FUint64,oneof"` + F_Uint64 uint64 `protobuf:"varint,7,opt,name=F_Uint64,oneof"` } type Oneof_F_Float struct { - F_Float float32 `protobuf:"fixed32,8,opt,name=F_Float,json=FFloat,oneof"` + F_Float float32 `protobuf:"fixed32,8,opt,name=F_Float,oneof"` } type Oneof_F_Double struct { - F_Double float64 `protobuf:"fixed64,9,opt,name=F_Double,json=FDouble,oneof"` + F_Double float64 `protobuf:"fixed64,9,opt,name=F_Double,oneof"` } type Oneof_F_String struct { - F_String string `protobuf:"bytes,10,opt,name=F_String,json=FString,oneof"` + F_String string `protobuf:"bytes,10,opt,name=F_String,oneof"` } type Oneof_F_Bytes struct { - F_Bytes []byte `protobuf:"bytes,11,opt,name=F_Bytes,json=FBytes,oneof"` + F_Bytes []byte `protobuf:"bytes,11,opt,name=F_Bytes,oneof"` } type Oneof_F_Sint32 struct { - F_Sint32 int32 `protobuf:"zigzag32,12,opt,name=F_Sint32,json=FSint32,oneof"` + F_Sint32 int32 `protobuf:"zigzag32,12,opt,name=F_Sint32,oneof"` } type Oneof_F_Sint64 struct { - F_Sint64 int64 `protobuf:"zigzag64,13,opt,name=F_Sint64,json=FSint64,oneof"` + F_Sint64 int64 `protobuf:"zigzag64,13,opt,name=F_Sint64,oneof"` } type Oneof_F_Enum struct { - F_Enum MyMessage_Color `protobuf:"varint,14,opt,name=F_Enum,json=FEnum,enum=testdata.MyMessage_Color,oneof"` + F_Enum MyMessage_Color `protobuf:"varint,14,opt,name=F_Enum,enum=testdata.MyMessage_Color,oneof"` } type Oneof_F_Message struct { - F_Message *GoTestField `protobuf:"bytes,15,opt,name=F_Message,json=FMessage,oneof"` + F_Message *GoTestField `protobuf:"bytes,15,opt,name=F_Message,oneof"` } type Oneof_FGroup struct { - FGroup *Oneof_F_Group `protobuf:"group,16,opt,name=F_Group,json=fGroup,oneof"` + FGroup *Oneof_F_Group `protobuf:"group,16,opt,name=F_Group,oneof"` } type Oneof_F_Largest_Tag struct { - F_Largest_Tag int32 `protobuf:"varint,536870911,opt,name=F_Largest_Tag,json=FLargestTag,oneof"` + F_Largest_Tag int32 `protobuf:"varint,536870911,opt,name=F_Largest_Tag,oneof"` } type Oneof_Value struct { Value int32 `protobuf:"varint,100,opt,name=value,oneof"` @@ -2712,10 +2651,9 @@ type Oneof_F_Group struct { XXX_unrecognized []byte `json:"-"` } -func (m *Oneof_F_Group) Reset() { *m = Oneof_F_Group{} } -func (m *Oneof_F_Group) String() string { return proto.CompactTextString(m) } -func (*Oneof_F_Group) ProtoMessage() {} -func (*Oneof_F_Group) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{29, 0} } +func (m *Oneof_F_Group) Reset() { *m = Oneof_F_Group{} } +func (m *Oneof_F_Group) String() string { return proto.CompactTextString(m) } +func (*Oneof_F_Group) ProtoMessage() {} func (m *Oneof_F_Group) GetX() int32 { if m != nil && m.X != nil { @@ -2725,7 +2663,7 @@ func (m *Oneof_F_Group) GetX() int32 { } type Communique struct { - MakeMeCry *bool `protobuf:"varint,1,opt,name=make_me_cry,json=makeMeCry" json:"make_me_cry,omitempty"` + MakeMeCry *bool `protobuf:"varint,1,opt,name=make_me_cry" json:"make_me_cry,omitempty"` // This is a oneof, called "union". // // Types that are valid to be assigned to Union: @@ -2742,7 +2680,7 @@ type Communique struct { func (m *Communique) Reset() { *m = Communique{} } func (m *Communique) String() string { return proto.CompactTextString(m) } func (*Communique) ProtoMessage() {} -func (*Communique) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{30} } +func (*Communique) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{28} } type isCommunique_Union interface { isCommunique_Union() @@ -2758,7 +2696,7 @@ type Communique_Data struct { Data []byte `protobuf:"bytes,7,opt,name=data,oneof"` } type Communique_TempC struct { - TempC float64 `protobuf:"fixed64,8,opt,name=temp_c,json=tempC,oneof"` + TempC float64 `protobuf:"fixed64,8,opt,name=temp_c,oneof"` } type Communique_Col struct { Col MyMessage_Color `protobuf:"varint,9,opt,name=col,enum=testdata.MyMessage_Color,oneof"` @@ -2963,7 +2901,6 @@ var E_Greeting = &proto.ExtensionDesc{ Field: 106, Name: "testdata.greeting", Tag: "bytes,106,rep,name=greeting", - Filename: "test.proto", } var E_Complex = &proto.ExtensionDesc{ @@ -2972,7 +2909,6 @@ var E_Complex = &proto.ExtensionDesc{ Field: 200, Name: "testdata.complex", Tag: "bytes,200,opt,name=complex", - Filename: "test.proto", } var E_RComplex = &proto.ExtensionDesc{ @@ -2980,8 +2916,7 @@ var E_RComplex = &proto.ExtensionDesc{ ExtensionType: ([]*ComplexExtension)(nil), Field: 201, Name: "testdata.r_complex", - Tag: "bytes,201,rep,name=r_complex,json=rComplex", - Filename: "test.proto", + Tag: "bytes,201,rep,name=r_complex", } var E_NoDefaultDouble = &proto.ExtensionDesc{ @@ -2989,8 +2924,7 @@ var E_NoDefaultDouble = &proto.ExtensionDesc{ ExtensionType: (*float64)(nil), Field: 101, Name: "testdata.no_default_double", - Tag: "fixed64,101,opt,name=no_default_double,json=noDefaultDouble", - Filename: "test.proto", + Tag: "fixed64,101,opt,name=no_default_double", } var E_NoDefaultFloat = &proto.ExtensionDesc{ @@ -2998,8 +2932,7 @@ var E_NoDefaultFloat = &proto.ExtensionDesc{ ExtensionType: (*float32)(nil), Field: 102, Name: "testdata.no_default_float", - Tag: "fixed32,102,opt,name=no_default_float,json=noDefaultFloat", - Filename: "test.proto", + Tag: "fixed32,102,opt,name=no_default_float", } var E_NoDefaultInt32 = &proto.ExtensionDesc{ @@ -3007,8 +2940,7 @@ var E_NoDefaultInt32 = &proto.ExtensionDesc{ ExtensionType: (*int32)(nil), Field: 103, Name: "testdata.no_default_int32", - Tag: "varint,103,opt,name=no_default_int32,json=noDefaultInt32", - Filename: "test.proto", + Tag: "varint,103,opt,name=no_default_int32", } var E_NoDefaultInt64 = &proto.ExtensionDesc{ @@ -3016,8 +2948,7 @@ var E_NoDefaultInt64 = &proto.ExtensionDesc{ ExtensionType: (*int64)(nil), Field: 104, Name: "testdata.no_default_int64", - Tag: "varint,104,opt,name=no_default_int64,json=noDefaultInt64", - Filename: "test.proto", + Tag: "varint,104,opt,name=no_default_int64", } var E_NoDefaultUint32 = &proto.ExtensionDesc{ @@ -3025,8 +2956,7 @@ var E_NoDefaultUint32 = &proto.ExtensionDesc{ ExtensionType: (*uint32)(nil), Field: 105, Name: "testdata.no_default_uint32", - Tag: "varint,105,opt,name=no_default_uint32,json=noDefaultUint32", - Filename: "test.proto", + Tag: "varint,105,opt,name=no_default_uint32", } var E_NoDefaultUint64 = &proto.ExtensionDesc{ @@ -3034,8 +2964,7 @@ var E_NoDefaultUint64 = &proto.ExtensionDesc{ ExtensionType: (*uint64)(nil), Field: 106, Name: "testdata.no_default_uint64", - Tag: "varint,106,opt,name=no_default_uint64,json=noDefaultUint64", - Filename: "test.proto", + Tag: "varint,106,opt,name=no_default_uint64", } var E_NoDefaultSint32 = &proto.ExtensionDesc{ @@ -3043,8 +2972,7 @@ var E_NoDefaultSint32 = &proto.ExtensionDesc{ ExtensionType: (*int32)(nil), Field: 107, Name: "testdata.no_default_sint32", - Tag: "zigzag32,107,opt,name=no_default_sint32,json=noDefaultSint32", - Filename: "test.proto", + Tag: "zigzag32,107,opt,name=no_default_sint32", } var E_NoDefaultSint64 = &proto.ExtensionDesc{ @@ -3052,8 +2980,7 @@ var E_NoDefaultSint64 = &proto.ExtensionDesc{ ExtensionType: (*int64)(nil), Field: 108, Name: "testdata.no_default_sint64", - Tag: "zigzag64,108,opt,name=no_default_sint64,json=noDefaultSint64", - Filename: "test.proto", + Tag: "zigzag64,108,opt,name=no_default_sint64", } var E_NoDefaultFixed32 = &proto.ExtensionDesc{ @@ -3061,8 +2988,7 @@ var E_NoDefaultFixed32 = &proto.ExtensionDesc{ ExtensionType: (*uint32)(nil), Field: 109, Name: "testdata.no_default_fixed32", - Tag: "fixed32,109,opt,name=no_default_fixed32,json=noDefaultFixed32", - Filename: "test.proto", + Tag: "fixed32,109,opt,name=no_default_fixed32", } var E_NoDefaultFixed64 = &proto.ExtensionDesc{ @@ -3070,8 +2996,7 @@ var E_NoDefaultFixed64 = &proto.ExtensionDesc{ ExtensionType: (*uint64)(nil), Field: 110, Name: "testdata.no_default_fixed64", - Tag: "fixed64,110,opt,name=no_default_fixed64,json=noDefaultFixed64", - Filename: "test.proto", + Tag: "fixed64,110,opt,name=no_default_fixed64", } var E_NoDefaultSfixed32 = &proto.ExtensionDesc{ @@ -3079,8 +3004,7 @@ var E_NoDefaultSfixed32 = &proto.ExtensionDesc{ ExtensionType: (*int32)(nil), Field: 111, Name: "testdata.no_default_sfixed32", - Tag: "fixed32,111,opt,name=no_default_sfixed32,json=noDefaultSfixed32", - Filename: "test.proto", + Tag: "fixed32,111,opt,name=no_default_sfixed32", } var E_NoDefaultSfixed64 = &proto.ExtensionDesc{ @@ -3088,8 +3012,7 @@ var E_NoDefaultSfixed64 = &proto.ExtensionDesc{ ExtensionType: (*int64)(nil), Field: 112, Name: "testdata.no_default_sfixed64", - Tag: "fixed64,112,opt,name=no_default_sfixed64,json=noDefaultSfixed64", - Filename: "test.proto", + Tag: "fixed64,112,opt,name=no_default_sfixed64", } var E_NoDefaultBool = &proto.ExtensionDesc{ @@ -3097,8 +3020,7 @@ var E_NoDefaultBool = &proto.ExtensionDesc{ ExtensionType: (*bool)(nil), Field: 113, Name: "testdata.no_default_bool", - Tag: "varint,113,opt,name=no_default_bool,json=noDefaultBool", - Filename: "test.proto", + Tag: "varint,113,opt,name=no_default_bool", } var E_NoDefaultString = &proto.ExtensionDesc{ @@ -3106,8 +3028,7 @@ var E_NoDefaultString = &proto.ExtensionDesc{ ExtensionType: (*string)(nil), Field: 114, Name: "testdata.no_default_string", - Tag: "bytes,114,opt,name=no_default_string,json=noDefaultString", - Filename: "test.proto", + Tag: "bytes,114,opt,name=no_default_string", } var E_NoDefaultBytes = &proto.ExtensionDesc{ @@ -3115,8 +3036,7 @@ var E_NoDefaultBytes = &proto.ExtensionDesc{ ExtensionType: ([]byte)(nil), Field: 115, Name: "testdata.no_default_bytes", - Tag: "bytes,115,opt,name=no_default_bytes,json=noDefaultBytes", - Filename: "test.proto", + Tag: "bytes,115,opt,name=no_default_bytes", } var E_NoDefaultEnum = &proto.ExtensionDesc{ @@ -3124,8 +3044,7 @@ var E_NoDefaultEnum = &proto.ExtensionDesc{ ExtensionType: (*DefaultsMessage_DefaultsEnum)(nil), Field: 116, Name: "testdata.no_default_enum", - Tag: "varint,116,opt,name=no_default_enum,json=noDefaultEnum,enum=testdata.DefaultsMessage_DefaultsEnum", - Filename: "test.proto", + Tag: "varint,116,opt,name=no_default_enum,enum=testdata.DefaultsMessage_DefaultsEnum", } var E_DefaultDouble = &proto.ExtensionDesc{ @@ -3133,8 +3052,7 @@ var E_DefaultDouble = &proto.ExtensionDesc{ ExtensionType: (*float64)(nil), Field: 201, Name: "testdata.default_double", - Tag: "fixed64,201,opt,name=default_double,json=defaultDouble,def=3.1415", - Filename: "test.proto", + Tag: "fixed64,201,opt,name=default_double,def=3.1415", } var E_DefaultFloat = &proto.ExtensionDesc{ @@ -3142,8 +3060,7 @@ var E_DefaultFloat = &proto.ExtensionDesc{ ExtensionType: (*float32)(nil), Field: 202, Name: "testdata.default_float", - Tag: "fixed32,202,opt,name=default_float,json=defaultFloat,def=3.14", - Filename: "test.proto", + Tag: "fixed32,202,opt,name=default_float,def=3.14", } var E_DefaultInt32 = &proto.ExtensionDesc{ @@ -3151,8 +3068,7 @@ var E_DefaultInt32 = &proto.ExtensionDesc{ ExtensionType: (*int32)(nil), Field: 203, Name: "testdata.default_int32", - Tag: "varint,203,opt,name=default_int32,json=defaultInt32,def=42", - Filename: "test.proto", + Tag: "varint,203,opt,name=default_int32,def=42", } var E_DefaultInt64 = &proto.ExtensionDesc{ @@ -3160,8 +3076,7 @@ var E_DefaultInt64 = &proto.ExtensionDesc{ ExtensionType: (*int64)(nil), Field: 204, Name: "testdata.default_int64", - Tag: "varint,204,opt,name=default_int64,json=defaultInt64,def=43", - Filename: "test.proto", + Tag: "varint,204,opt,name=default_int64,def=43", } var E_DefaultUint32 = &proto.ExtensionDesc{ @@ -3169,8 +3084,7 @@ var E_DefaultUint32 = &proto.ExtensionDesc{ ExtensionType: (*uint32)(nil), Field: 205, Name: "testdata.default_uint32", - Tag: "varint,205,opt,name=default_uint32,json=defaultUint32,def=44", - Filename: "test.proto", + Tag: "varint,205,opt,name=default_uint32,def=44", } var E_DefaultUint64 = &proto.ExtensionDesc{ @@ -3178,8 +3092,7 @@ var E_DefaultUint64 = &proto.ExtensionDesc{ ExtensionType: (*uint64)(nil), Field: 206, Name: "testdata.default_uint64", - Tag: "varint,206,opt,name=default_uint64,json=defaultUint64,def=45", - Filename: "test.proto", + Tag: "varint,206,opt,name=default_uint64,def=45", } var E_DefaultSint32 = &proto.ExtensionDesc{ @@ -3187,8 +3100,7 @@ var E_DefaultSint32 = &proto.ExtensionDesc{ ExtensionType: (*int32)(nil), Field: 207, Name: "testdata.default_sint32", - Tag: "zigzag32,207,opt,name=default_sint32,json=defaultSint32,def=46", - Filename: "test.proto", + Tag: "zigzag32,207,opt,name=default_sint32,def=46", } var E_DefaultSint64 = &proto.ExtensionDesc{ @@ -3196,8 +3108,7 @@ var E_DefaultSint64 = &proto.ExtensionDesc{ ExtensionType: (*int64)(nil), Field: 208, Name: "testdata.default_sint64", - Tag: "zigzag64,208,opt,name=default_sint64,json=defaultSint64,def=47", - Filename: "test.proto", + Tag: "zigzag64,208,opt,name=default_sint64,def=47", } var E_DefaultFixed32 = &proto.ExtensionDesc{ @@ -3205,8 +3116,7 @@ var E_DefaultFixed32 = &proto.ExtensionDesc{ ExtensionType: (*uint32)(nil), Field: 209, Name: "testdata.default_fixed32", - Tag: "fixed32,209,opt,name=default_fixed32,json=defaultFixed32,def=48", - Filename: "test.proto", + Tag: "fixed32,209,opt,name=default_fixed32,def=48", } var E_DefaultFixed64 = &proto.ExtensionDesc{ @@ -3214,8 +3124,7 @@ var E_DefaultFixed64 = &proto.ExtensionDesc{ ExtensionType: (*uint64)(nil), Field: 210, Name: "testdata.default_fixed64", - Tag: "fixed64,210,opt,name=default_fixed64,json=defaultFixed64,def=49", - Filename: "test.proto", + Tag: "fixed64,210,opt,name=default_fixed64,def=49", } var E_DefaultSfixed32 = &proto.ExtensionDesc{ @@ -3223,8 +3132,7 @@ var E_DefaultSfixed32 = &proto.ExtensionDesc{ ExtensionType: (*int32)(nil), Field: 211, Name: "testdata.default_sfixed32", - Tag: "fixed32,211,opt,name=default_sfixed32,json=defaultSfixed32,def=50", - Filename: "test.proto", + Tag: "fixed32,211,opt,name=default_sfixed32,def=50", } var E_DefaultSfixed64 = &proto.ExtensionDesc{ @@ -3232,8 +3140,7 @@ var E_DefaultSfixed64 = &proto.ExtensionDesc{ ExtensionType: (*int64)(nil), Field: 212, Name: "testdata.default_sfixed64", - Tag: "fixed64,212,opt,name=default_sfixed64,json=defaultSfixed64,def=51", - Filename: "test.proto", + Tag: "fixed64,212,opt,name=default_sfixed64,def=51", } var E_DefaultBool = &proto.ExtensionDesc{ @@ -3241,8 +3148,7 @@ var E_DefaultBool = &proto.ExtensionDesc{ ExtensionType: (*bool)(nil), Field: 213, Name: "testdata.default_bool", - Tag: "varint,213,opt,name=default_bool,json=defaultBool,def=1", - Filename: "test.proto", + Tag: "varint,213,opt,name=default_bool,def=1", } var E_DefaultString = &proto.ExtensionDesc{ @@ -3250,8 +3156,7 @@ var E_DefaultString = &proto.ExtensionDesc{ ExtensionType: (*string)(nil), Field: 214, Name: "testdata.default_string", - Tag: "bytes,214,opt,name=default_string,json=defaultString,def=Hello, string", - Filename: "test.proto", + Tag: "bytes,214,opt,name=default_string,def=Hello, string", } var E_DefaultBytes = &proto.ExtensionDesc{ @@ -3259,8 +3164,7 @@ var E_DefaultBytes = &proto.ExtensionDesc{ ExtensionType: ([]byte)(nil), Field: 215, Name: "testdata.default_bytes", - Tag: "bytes,215,opt,name=default_bytes,json=defaultBytes,def=Hello, bytes", - Filename: "test.proto", + Tag: "bytes,215,opt,name=default_bytes,def=Hello, bytes", } var E_DefaultEnum = &proto.ExtensionDesc{ @@ -3268,8 +3172,7 @@ var E_DefaultEnum = &proto.ExtensionDesc{ ExtensionType: (*DefaultsMessage_DefaultsEnum)(nil), Field: 216, Name: "testdata.default_enum", - Tag: "varint,216,opt,name=default_enum,json=defaultEnum,enum=testdata.DefaultsMessage_DefaultsEnum,def=1", - Filename: "test.proto", + Tag: "varint,216,opt,name=default_enum,enum=testdata.DefaultsMessage_DefaultsEnum,def=1", } var E_X201 = &proto.ExtensionDesc{ @@ -3278,7 +3181,6 @@ var E_X201 = &proto.ExtensionDesc{ Field: 201, Name: "testdata.x201", Tag: "bytes,201,opt,name=x201", - Filename: "test.proto", } var E_X202 = &proto.ExtensionDesc{ @@ -3287,7 +3189,6 @@ var E_X202 = &proto.ExtensionDesc{ Field: 202, Name: "testdata.x202", Tag: "bytes,202,opt,name=x202", - Filename: "test.proto", } var E_X203 = &proto.ExtensionDesc{ @@ -3296,7 +3197,6 @@ var E_X203 = &proto.ExtensionDesc{ Field: 203, Name: "testdata.x203", Tag: "bytes,203,opt,name=x203", - Filename: "test.proto", } var E_X204 = &proto.ExtensionDesc{ @@ -3305,7 +3205,6 @@ var E_X204 = &proto.ExtensionDesc{ Field: 204, Name: "testdata.x204", Tag: "bytes,204,opt,name=x204", - Filename: "test.proto", } var E_X205 = &proto.ExtensionDesc{ @@ -3314,7 +3213,6 @@ var E_X205 = &proto.ExtensionDesc{ Field: 205, Name: "testdata.x205", Tag: "bytes,205,opt,name=x205", - Filename: "test.proto", } var E_X206 = &proto.ExtensionDesc{ @@ -3323,7 +3221,6 @@ var E_X206 = &proto.ExtensionDesc{ Field: 206, Name: "testdata.x206", Tag: "bytes,206,opt,name=x206", - Filename: "test.proto", } var E_X207 = &proto.ExtensionDesc{ @@ -3332,7 +3229,6 @@ var E_X207 = &proto.ExtensionDesc{ Field: 207, Name: "testdata.x207", Tag: "bytes,207,opt,name=x207", - Filename: "test.proto", } var E_X208 = &proto.ExtensionDesc{ @@ -3341,7 +3237,6 @@ var E_X208 = &proto.ExtensionDesc{ Field: 208, Name: "testdata.x208", Tag: "bytes,208,opt,name=x208", - Filename: "test.proto", } var E_X209 = &proto.ExtensionDesc{ @@ -3350,7 +3245,6 @@ var E_X209 = &proto.ExtensionDesc{ Field: 209, Name: "testdata.x209", Tag: "bytes,209,opt,name=x209", - Filename: "test.proto", } var E_X210 = &proto.ExtensionDesc{ @@ -3359,7 +3253,6 @@ var E_X210 = &proto.ExtensionDesc{ Field: 210, Name: "testdata.x210", Tag: "bytes,210,opt,name=x210", - Filename: "test.proto", } var E_X211 = &proto.ExtensionDesc{ @@ -3368,7 +3261,6 @@ var E_X211 = &proto.ExtensionDesc{ Field: 211, Name: "testdata.x211", Tag: "bytes,211,opt,name=x211", - Filename: "test.proto", } var E_X212 = &proto.ExtensionDesc{ @@ -3377,7 +3269,6 @@ var E_X212 = &proto.ExtensionDesc{ Field: 212, Name: "testdata.x212", Tag: "bytes,212,opt,name=x212", - Filename: "test.proto", } var E_X213 = &proto.ExtensionDesc{ @@ -3386,7 +3277,6 @@ var E_X213 = &proto.ExtensionDesc{ Field: 213, Name: "testdata.x213", Tag: "bytes,213,opt,name=x213", - Filename: "test.proto", } var E_X214 = &proto.ExtensionDesc{ @@ -3395,7 +3285,6 @@ var E_X214 = &proto.ExtensionDesc{ Field: 214, Name: "testdata.x214", Tag: "bytes,214,opt,name=x214", - Filename: "test.proto", } var E_X215 = &proto.ExtensionDesc{ @@ -3404,7 +3293,6 @@ var E_X215 = &proto.ExtensionDesc{ Field: 215, Name: "testdata.x215", Tag: "bytes,215,opt,name=x215", - Filename: "test.proto", } var E_X216 = &proto.ExtensionDesc{ @@ -3413,7 +3301,6 @@ var E_X216 = &proto.ExtensionDesc{ Field: 216, Name: "testdata.x216", Tag: "bytes,216,opt,name=x216", - Filename: "test.proto", } var E_X217 = &proto.ExtensionDesc{ @@ -3422,7 +3309,6 @@ var E_X217 = &proto.ExtensionDesc{ Field: 217, Name: "testdata.x217", Tag: "bytes,217,opt,name=x217", - Filename: "test.proto", } var E_X218 = &proto.ExtensionDesc{ @@ -3431,7 +3317,6 @@ var E_X218 = &proto.ExtensionDesc{ Field: 218, Name: "testdata.x218", Tag: "bytes,218,opt,name=x218", - Filename: "test.proto", } var E_X219 = &proto.ExtensionDesc{ @@ -3440,7 +3325,6 @@ var E_X219 = &proto.ExtensionDesc{ Field: 219, Name: "testdata.x219", Tag: "bytes,219,opt,name=x219", - Filename: "test.proto", } var E_X220 = &proto.ExtensionDesc{ @@ -3449,7 +3333,6 @@ var E_X220 = &proto.ExtensionDesc{ Field: 220, Name: "testdata.x220", Tag: "bytes,220,opt,name=x220", - Filename: "test.proto", } var E_X221 = &proto.ExtensionDesc{ @@ -3458,7 +3341,6 @@ var E_X221 = &proto.ExtensionDesc{ Field: 221, Name: "testdata.x221", Tag: "bytes,221,opt,name=x221", - Filename: "test.proto", } var E_X222 = &proto.ExtensionDesc{ @@ -3467,7 +3349,6 @@ var E_X222 = &proto.ExtensionDesc{ Field: 222, Name: "testdata.x222", Tag: "bytes,222,opt,name=x222", - Filename: "test.proto", } var E_X223 = &proto.ExtensionDesc{ @@ -3476,7 +3357,6 @@ var E_X223 = &proto.ExtensionDesc{ Field: 223, Name: "testdata.x223", Tag: "bytes,223,opt,name=x223", - Filename: "test.proto", } var E_X224 = &proto.ExtensionDesc{ @@ -3485,7 +3365,6 @@ var E_X224 = &proto.ExtensionDesc{ Field: 224, Name: "testdata.x224", Tag: "bytes,224,opt,name=x224", - Filename: "test.proto", } var E_X225 = &proto.ExtensionDesc{ @@ -3494,7 +3373,6 @@ var E_X225 = &proto.ExtensionDesc{ Field: 225, Name: "testdata.x225", Tag: "bytes,225,opt,name=x225", - Filename: "test.proto", } var E_X226 = &proto.ExtensionDesc{ @@ -3503,7 +3381,6 @@ var E_X226 = &proto.ExtensionDesc{ Field: 226, Name: "testdata.x226", Tag: "bytes,226,opt,name=x226", - Filename: "test.proto", } var E_X227 = &proto.ExtensionDesc{ @@ -3512,7 +3389,6 @@ var E_X227 = &proto.ExtensionDesc{ Field: 227, Name: "testdata.x227", Tag: "bytes,227,opt,name=x227", - Filename: "test.proto", } var E_X228 = &proto.ExtensionDesc{ @@ -3521,7 +3397,6 @@ var E_X228 = &proto.ExtensionDesc{ Field: 228, Name: "testdata.x228", Tag: "bytes,228,opt,name=x228", - Filename: "test.proto", } var E_X229 = &proto.ExtensionDesc{ @@ -3530,7 +3405,6 @@ var E_X229 = &proto.ExtensionDesc{ Field: 229, Name: "testdata.x229", Tag: "bytes,229,opt,name=x229", - Filename: "test.proto", } var E_X230 = &proto.ExtensionDesc{ @@ -3539,7 +3413,6 @@ var E_X230 = &proto.ExtensionDesc{ Field: 230, Name: "testdata.x230", Tag: "bytes,230,opt,name=x230", - Filename: "test.proto", } var E_X231 = &proto.ExtensionDesc{ @@ -3548,7 +3421,6 @@ var E_X231 = &proto.ExtensionDesc{ Field: 231, Name: "testdata.x231", Tag: "bytes,231,opt,name=x231", - Filename: "test.proto", } var E_X232 = &proto.ExtensionDesc{ @@ -3557,7 +3429,6 @@ var E_X232 = &proto.ExtensionDesc{ Field: 232, Name: "testdata.x232", Tag: "bytes,232,opt,name=x232", - Filename: "test.proto", } var E_X233 = &proto.ExtensionDesc{ @@ -3566,7 +3437,6 @@ var E_X233 = &proto.ExtensionDesc{ Field: 233, Name: "testdata.x233", Tag: "bytes,233,opt,name=x233", - Filename: "test.proto", } var E_X234 = &proto.ExtensionDesc{ @@ -3575,7 +3445,6 @@ var E_X234 = &proto.ExtensionDesc{ Field: 234, Name: "testdata.x234", Tag: "bytes,234,opt,name=x234", - Filename: "test.proto", } var E_X235 = &proto.ExtensionDesc{ @@ -3584,7 +3453,6 @@ var E_X235 = &proto.ExtensionDesc{ Field: 235, Name: "testdata.x235", Tag: "bytes,235,opt,name=x235", - Filename: "test.proto", } var E_X236 = &proto.ExtensionDesc{ @@ -3593,7 +3461,6 @@ var E_X236 = &proto.ExtensionDesc{ Field: 236, Name: "testdata.x236", Tag: "bytes,236,opt,name=x236", - Filename: "test.proto", } var E_X237 = &proto.ExtensionDesc{ @@ -3602,7 +3469,6 @@ var E_X237 = &proto.ExtensionDesc{ Field: 237, Name: "testdata.x237", Tag: "bytes,237,opt,name=x237", - Filename: "test.proto", } var E_X238 = &proto.ExtensionDesc{ @@ -3611,7 +3477,6 @@ var E_X238 = &proto.ExtensionDesc{ Field: 238, Name: "testdata.x238", Tag: "bytes,238,opt,name=x238", - Filename: "test.proto", } var E_X239 = &proto.ExtensionDesc{ @@ -3620,7 +3485,6 @@ var E_X239 = &proto.ExtensionDesc{ Field: 239, Name: "testdata.x239", Tag: "bytes,239,opt,name=x239", - Filename: "test.proto", } var E_X240 = &proto.ExtensionDesc{ @@ -3629,7 +3493,6 @@ var E_X240 = &proto.ExtensionDesc{ Field: 240, Name: "testdata.x240", Tag: "bytes,240,opt,name=x240", - Filename: "test.proto", } var E_X241 = &proto.ExtensionDesc{ @@ -3638,7 +3501,6 @@ var E_X241 = &proto.ExtensionDesc{ Field: 241, Name: "testdata.x241", Tag: "bytes,241,opt,name=x241", - Filename: "test.proto", } var E_X242 = &proto.ExtensionDesc{ @@ -3647,7 +3509,6 @@ var E_X242 = &proto.ExtensionDesc{ Field: 242, Name: "testdata.x242", Tag: "bytes,242,opt,name=x242", - Filename: "test.proto", } var E_X243 = &proto.ExtensionDesc{ @@ -3656,7 +3517,6 @@ var E_X243 = &proto.ExtensionDesc{ Field: 243, Name: "testdata.x243", Tag: "bytes,243,opt,name=x243", - Filename: "test.proto", } var E_X244 = &proto.ExtensionDesc{ @@ -3665,7 +3525,6 @@ var E_X244 = &proto.ExtensionDesc{ Field: 244, Name: "testdata.x244", Tag: "bytes,244,opt,name=x244", - Filename: "test.proto", } var E_X245 = &proto.ExtensionDesc{ @@ -3674,7 +3533,6 @@ var E_X245 = &proto.ExtensionDesc{ Field: 245, Name: "testdata.x245", Tag: "bytes,245,opt,name=x245", - Filename: "test.proto", } var E_X246 = &proto.ExtensionDesc{ @@ -3683,7 +3541,6 @@ var E_X246 = &proto.ExtensionDesc{ Field: 246, Name: "testdata.x246", Tag: "bytes,246,opt,name=x246", - Filename: "test.proto", } var E_X247 = &proto.ExtensionDesc{ @@ -3692,7 +3549,6 @@ var E_X247 = &proto.ExtensionDesc{ Field: 247, Name: "testdata.x247", Tag: "bytes,247,opt,name=x247", - Filename: "test.proto", } var E_X248 = &proto.ExtensionDesc{ @@ -3701,7 +3557,6 @@ var E_X248 = &proto.ExtensionDesc{ Field: 248, Name: "testdata.x248", Tag: "bytes,248,opt,name=x248", - Filename: "test.proto", } var E_X249 = &proto.ExtensionDesc{ @@ -3710,7 +3565,6 @@ var E_X249 = &proto.ExtensionDesc{ Field: 249, Name: "testdata.x249", Tag: "bytes,249,opt,name=x249", - Filename: "test.proto", } var E_X250 = &proto.ExtensionDesc{ @@ -3719,7 +3573,6 @@ var E_X250 = &proto.ExtensionDesc{ Field: 250, Name: "testdata.x250", Tag: "bytes,250,opt,name=x250", - Filename: "test.proto", } func init() { @@ -3729,8 +3582,6 @@ func init() { proto.RegisterType((*GoTest_RequiredGroup)(nil), "testdata.GoTest.RequiredGroup") proto.RegisterType((*GoTest_RepeatedGroup)(nil), "testdata.GoTest.RepeatedGroup") proto.RegisterType((*GoTest_OptionalGroup)(nil), "testdata.GoTest.OptionalGroup") - proto.RegisterType((*GoTestRequiredGroupField)(nil), "testdata.GoTestRequiredGroupField") - proto.RegisterType((*GoTestRequiredGroupField_Group)(nil), "testdata.GoTestRequiredGroupField.Group") proto.RegisterType((*GoSkipTest)(nil), "testdata.GoSkipTest") proto.RegisterType((*GoSkipTest_SkipGroup)(nil), "testdata.GoSkipTest.SkipGroup") proto.RegisterType((*NonPackedTest)(nil), "testdata.NonPackedTest") @@ -3742,7 +3593,6 @@ func init() { proto.RegisterType((*NewMessage_Nested)(nil), "testdata.NewMessage.Nested") proto.RegisterType((*InnerMessage)(nil), "testdata.InnerMessage") proto.RegisterType((*OtherMessage)(nil), "testdata.OtherMessage") - proto.RegisterType((*RequiredInnerMessage)(nil), "testdata.RequiredInnerMessage") proto.RegisterType((*MyMessage)(nil), "testdata.MyMessage") proto.RegisterType((*MyMessage_SomeGroup)(nil), "testdata.MyMessage.SomeGroup") proto.RegisterType((*Ext)(nil), "testdata.Ext") @@ -3862,287 +3712,215 @@ func init() { proto.RegisterExtension(E_X250) } -func init() { proto.RegisterFile("test.proto", fileDescriptor0) } - var fileDescriptor0 = []byte{ - // 4453 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x5a, 0xc9, 0x77, 0xdb, 0x48, - 0x7a, 0x37, 0xc0, 0xfd, 0x23, 0x25, 0x42, 0x65, 0xb5, 0x9b, 0x96, 0xbc, 0xc0, 0x9c, 0xe9, 0x6e, - 0x7a, 0xd3, 0x48, 0x20, 0x44, 0xdb, 0x74, 0xa7, 0xdf, 0xf3, 0x42, 0xca, 0x7a, 0x63, 0x89, 0x0a, - 0xa4, 0xee, 0x7e, 0xd3, 0x39, 0xf0, 0x51, 0x22, 0x44, 0xb3, 0x4d, 0x02, 0x34, 0x09, 0xc5, 0x52, - 0x72, 0xe9, 0x4b, 0x72, 0xcd, 0x76, 0xc9, 0x35, 0xa7, 0x9c, 0x92, 0xbc, 0x97, 0x7f, 0x22, 0xe9, - 0xee, 0x59, 0x7b, 0xd6, 0xac, 0x93, 0x7d, 0x99, 0xec, 0xdb, 0x4c, 0x92, 0x4b, 0xcf, 0xab, 0xaf, - 0x0a, 0x40, 0x01, 0x24, 0x20, 0xf9, 0x24, 0x56, 0xd5, 0xef, 0xf7, 0xd5, 0xf6, 0xab, 0xef, 0xab, - 0xaf, 0x20, 0x00, 0xc7, 0x9c, 0x38, 0x2b, 0xa3, 0xb1, 0xed, 0xd8, 0x24, 0x4b, 0x7f, 0x77, 0x3b, - 0x4e, 0xa7, 0x7c, 0x1d, 0xd2, 0x1b, 0x76, 0xc3, 0x3a, 0x1a, 0x92, 0xab, 0x90, 0x38, 0xb4, 0xed, - 0x92, 0xa4, 0xca, 0x95, 0x79, 0x6d, 0x6e, 0xc5, 0x45, 0xac, 0x34, 0x5b, 0x2d, 0x83, 0xb6, 0x94, - 0xef, 0x40, 0x7e, 0xc3, 0xde, 0x33, 0x27, 0x4e, 0xb3, 0x6f, 0x0e, 0xba, 0x64, 0x11, 0x52, 0x4f, - 0x3b, 0xfb, 0xe6, 0x00, 0x19, 0x39, 0x83, 0x15, 0x08, 0x81, 0xe4, 0xde, 0xc9, 0xc8, 0x2c, 0xc9, - 0x58, 0x89, 0xbf, 0xcb, 0xbf, 0x72, 0x85, 0x76, 0x42, 0x99, 0xe4, 0x3a, 0x24, 0xbf, 0xdc, 0xb7, - 0xba, 0xbc, 0x97, 0xd7, 0xfc, 0x5e, 0x58, 0xfb, 0xca, 0x97, 0x37, 0xb7, 0x1f, 0x1b, 0x08, 0xa1, - 0xf6, 0xf7, 0x3a, 0xfb, 0x03, 0x6a, 0x4a, 0xa2, 0xf6, 0xb1, 0x40, 0x6b, 0x77, 0x3a, 0xe3, 0xce, - 0xb0, 0x94, 0x50, 0xa5, 0x4a, 0xca, 0x60, 0x05, 0x72, 0x1f, 0xe6, 0x0c, 0xf3, 0xc5, 0x51, 0x7f, - 0x6c, 0x76, 0x71, 0x70, 0xa5, 0xa4, 0x2a, 0x57, 0xf2, 0xd3, 0xf6, 0xb1, 0xd1, 0x08, 0x62, 0x19, - 0x79, 0x64, 0x76, 0x1c, 0x97, 0x9c, 0x52, 0x13, 0xb1, 0x64, 0x01, 0x4b, 0xc9, 0xad, 0x91, 0xd3, - 0xb7, 0xad, 0xce, 0x80, 0x91, 0xd3, 0xaa, 0x14, 0x43, 0x0e, 0x60, 0xc9, 0x9b, 0x50, 0x6c, 0xb6, - 0x1f, 0xda, 0xf6, 0xa0, 0x3d, 0xe6, 0x23, 0x2a, 0x81, 0x2a, 0x57, 0xb2, 0xc6, 0x5c, 0x93, 0xd6, - 0xba, 0xc3, 0x24, 0x15, 0x50, 0x9a, 0xed, 0x4d, 0xcb, 0xa9, 0x6a, 0x3e, 0x30, 0xaf, 0xca, 0x95, - 0x94, 0x31, 0xdf, 0xc4, 0xea, 0x29, 0x64, 0x4d, 0xf7, 0x91, 0x05, 0x55, 0xae, 0x24, 0x18, 0xb2, - 0xa6, 0x7b, 0xc8, 0x5b, 0x40, 0x9a, 0xed, 0x66, 0xff, 0xd8, 0xec, 0x8a, 0x56, 0xe7, 0x54, 0xb9, - 0x92, 0x31, 0x94, 0x26, 0x6f, 0x98, 0x81, 0x16, 0x2d, 0xcf, 0xab, 0x72, 0x25, 0xed, 0xa2, 0x05, - 0xdb, 0x37, 0x60, 0xa1, 0xd9, 0x7e, 0xb7, 0x1f, 0x1c, 0x70, 0x51, 0x95, 0x2b, 0x73, 0x46, 0xb1, - 0xc9, 0xea, 0xa7, 0xb1, 0xa2, 0x61, 0x45, 0x95, 0x2b, 0x49, 0x8e, 0x15, 0xec, 0xe2, 0xec, 0x9a, - 0x03, 0xbb, 0xe3, 0xf8, 0xd0, 0x05, 0x55, 0xae, 0xc8, 0xc6, 0x7c, 0x13, 0xab, 0x83, 0x56, 0x1f, - 0xdb, 0x47, 0xfb, 0x03, 0xd3, 0x87, 0x12, 0x55, 0xae, 0x48, 0x46, 0xb1, 0xc9, 0xea, 0x83, 0xd8, - 0x5d, 0x67, 0xdc, 0xb7, 0x7a, 0x3e, 0xf6, 0x3c, 0xea, 0xb7, 0xd8, 0x64, 0xf5, 0xc1, 0x11, 0x3c, - 0x3c, 0x71, 0xcc, 0x89, 0x0f, 0x35, 0x55, 0xb9, 0x52, 0x30, 0xe6, 0x9b, 0x58, 0x1d, 0xb2, 0x1a, - 0x5a, 0x83, 0x43, 0x55, 0xae, 0x2c, 0x50, 0xab, 0x33, 0xd6, 0x60, 0x37, 0xb4, 0x06, 0x3d, 0x55, - 0xae, 0x10, 0x8e, 0x15, 0xd6, 0x40, 0xd4, 0x0c, 0x13, 0x62, 0x69, 0x51, 0x4d, 0x08, 0x9a, 0x61, - 0x95, 0x41, 0xcd, 0x70, 0xe0, 0x6b, 0x6a, 0x42, 0xd4, 0x4c, 0x08, 0x89, 0x9d, 0x73, 0xe4, 0x05, - 0x35, 0x21, 0x6a, 0x86, 0x23, 0x43, 0x9a, 0xe1, 0xd8, 0xd7, 0xd5, 0x44, 0x50, 0x33, 0x53, 0x68, - 0xd1, 0x72, 0x49, 0x4d, 0x04, 0x35, 0xc3, 0xd1, 0x41, 0xcd, 0x70, 0xf0, 0x45, 0x35, 0x11, 0xd0, - 0x4c, 0x18, 0x2b, 0x1a, 0x5e, 0x52, 0x13, 0x01, 0xcd, 0x88, 0xb3, 0x73, 0x35, 0xc3, 0xa1, 0xcb, - 0x6a, 0x42, 0xd4, 0x8c, 0x68, 0xd5, 0xd3, 0x0c, 0x87, 0x5e, 0x52, 0x13, 0x01, 0xcd, 0x88, 0x58, - 0x4f, 0x33, 0x1c, 0x7b, 0x59, 0x4d, 0x04, 0x34, 0xc3, 0xb1, 0xd7, 0x45, 0xcd, 0x70, 0xe8, 0xc7, - 0x92, 0x9a, 0x10, 0x45, 0xc3, 0xa1, 0x37, 0x03, 0xa2, 0xe1, 0xd8, 0x4f, 0x28, 0x56, 0x54, 0x4d, - 0x18, 0x2c, 0xae, 0xc2, 0xa7, 0x14, 0x2c, 0xca, 0x86, 0x83, 0x7d, 0xd9, 0xd8, 0xdc, 0x05, 0x95, - 0xae, 0xa8, 0x92, 0x27, 0x1b, 0xd7, 0x2f, 0x89, 0xb2, 0xf1, 0x80, 0x57, 0xd1, 0xd5, 0x72, 0xd9, - 0x4c, 0x21, 0x6b, 0xba, 0x8f, 0x54, 0x55, 0xc9, 0x97, 0x8d, 0x87, 0x0c, 0xc8, 0xc6, 0xc3, 0x5e, - 0x53, 0x25, 0x51, 0x36, 0x33, 0xd0, 0xa2, 0xe5, 0xb2, 0x2a, 0x89, 0xb2, 0xf1, 0xd0, 0xa2, 0x6c, - 0x3c, 0xf0, 0x17, 0x54, 0x49, 0x90, 0xcd, 0x34, 0x56, 0x34, 0xfc, 0x45, 0x55, 0x12, 0x64, 0x13, - 0x9c, 0x1d, 0x93, 0x8d, 0x07, 0x7d, 0x43, 0x95, 0x7c, 0xd9, 0x04, 0xad, 0x72, 0xd9, 0x78, 0xd0, - 0x37, 0x55, 0x49, 0x90, 0x4d, 0x10, 0xcb, 0x65, 0xe3, 0x61, 0xdf, 0xc2, 0xf8, 0xe6, 0xca, 0xc6, - 0xc3, 0x0a, 0xb2, 0xf1, 0xa0, 0xbf, 0x43, 0x63, 0xa1, 0x27, 0x1b, 0x0f, 0x2a, 0xca, 0xc6, 0xc3, - 0xfe, 0x2e, 0xc5, 0xfa, 0xb2, 0x99, 0x06, 0x8b, 0xab, 0xf0, 0x7b, 0x14, 0xec, 0xcb, 0xc6, 0x03, - 0xaf, 0xe0, 0x20, 0xa8, 0x6c, 0xba, 0xe6, 0x61, 0xe7, 0x68, 0x40, 0x25, 0x56, 0xa1, 0xba, 0xa9, - 0x27, 0x9d, 0xf1, 0x91, 0x49, 0x47, 0x62, 0xdb, 0x83, 0xc7, 0x6e, 0x1b, 0x59, 0xa1, 0xc6, 0x99, - 0x7c, 0x7c, 0xc2, 0x75, 0xaa, 0x9f, 0xba, 0x5c, 0xd5, 0x8c, 0x22, 0xd3, 0xd0, 0x34, 0xbe, 0xa6, - 0x0b, 0xf8, 0x1b, 0x54, 0x45, 0x75, 0xb9, 0xa6, 0x33, 0x7c, 0x4d, 0xf7, 0xf1, 0x55, 0x38, 0xef, - 0x4b, 0xc9, 0x67, 0xdc, 0xa4, 0x5a, 0xaa, 0x27, 0xaa, 0xda, 0xaa, 0xb1, 0xe0, 0x0a, 0x6a, 0x16, - 0x29, 0xd0, 0xcd, 0x2d, 0x2a, 0xa9, 0x7a, 0xa2, 0xa6, 0x7b, 0x24, 0xb1, 0x27, 0x8d, 0xca, 0x90, - 0x0b, 0xcb, 0xe7, 0xdc, 0xa6, 0xca, 0xaa, 0x27, 0xab, 0xda, 0xea, 0xaa, 0xa1, 0x70, 0x7d, 0xcd, - 0xe0, 0x04, 0xfa, 0x59, 0xa1, 0x0a, 0xab, 0x27, 0x6b, 0xba, 0xc7, 0x09, 0xf6, 0xb3, 0xe0, 0x0a, - 0xcd, 0xa7, 0x7c, 0x89, 0x2a, 0xad, 0x9e, 0xae, 0xae, 0xe9, 0x6b, 0xeb, 0xf7, 0x8c, 0x22, 0x53, - 0x9c, 0xcf, 0xd1, 0x69, 0x3f, 0x5c, 0x72, 0x3e, 0x69, 0x95, 0x6a, 0xae, 0x9e, 0xd6, 0xee, 0xac, - 0xdd, 0xd5, 0xee, 0x1a, 0x0a, 0xd7, 0x9e, 0xcf, 0x7a, 0x87, 0xb2, 0xb8, 0xf8, 0x7c, 0xd6, 0x1a, - 0x55, 0x5f, 0x5d, 0x79, 0x66, 0x0e, 0x06, 0xf6, 0x2d, 0xb5, 0xfc, 0xd2, 0x1e, 0x0f, 0xba, 0xd7, - 0xca, 0x60, 0x28, 0x5c, 0x8f, 0x62, 0xaf, 0x0b, 0xae, 0x20, 0x7d, 0xfa, 0xaf, 0xd1, 0x7b, 0x58, - 0xa1, 0x9e, 0x79, 0xd8, 0xef, 0x59, 0xf6, 0xc4, 0x34, 0x8a, 0x4c, 0x9a, 0xa1, 0x35, 0xd9, 0x0d, - 0xaf, 0xe3, 0xaf, 0x53, 0xda, 0x42, 0x3d, 0x71, 0xbb, 0xaa, 0xd1, 0x9e, 0x66, 0xad, 0xe3, 0x6e, - 0x78, 0x1d, 0x7f, 0x83, 0x72, 0x48, 0x3d, 0x71, 0xbb, 0xa6, 0x73, 0x8e, 0xb8, 0x8e, 0x77, 0xe0, - 0x42, 0x28, 0x2e, 0xb6, 0x47, 0x9d, 0x83, 0xe7, 0x66, 0xb7, 0xa4, 0xd1, 0xf0, 0xf8, 0x50, 0x56, - 0x24, 0xe3, 0x7c, 0x20, 0x44, 0xee, 0x60, 0x33, 0xb9, 0x07, 0xaf, 0x87, 0x03, 0xa5, 0xcb, 0xac, - 0xd2, 0x78, 0x89, 0xcc, 0xc5, 0x60, 0xcc, 0x0c, 0x51, 0x05, 0x07, 0xec, 0x52, 0x75, 0x1a, 0x40, - 0x7d, 0xaa, 0xef, 0x89, 0x39, 0xf5, 0x67, 0xe0, 0xe2, 0x74, 0x28, 0x75, 0xc9, 0xeb, 0x34, 0xa2, - 0x22, 0xf9, 0x42, 0x38, 0xaa, 0x4e, 0xd1, 0x67, 0xf4, 0x5d, 0xa3, 0x21, 0x56, 0xa4, 0x4f, 0xf5, - 0x7e, 0x1f, 0x4a, 0x53, 0xc1, 0xd6, 0x65, 0xdf, 0xa1, 0x31, 0x17, 0xd9, 0xaf, 0x85, 0xe2, 0x6e, - 0x98, 0x3c, 0xa3, 0xeb, 0xbb, 0x34, 0x08, 0x0b, 0xe4, 0xa9, 0x9e, 0x71, 0xc9, 0x82, 0xe1, 0xd8, - 0xe5, 0xde, 0xa3, 0x51, 0x99, 0x2f, 0x59, 0x20, 0x32, 0x8b, 0xfd, 0x86, 0xe2, 0xb3, 0xcb, 0xad, - 0xd3, 0x30, 0xcd, 0xfb, 0x0d, 0x86, 0x6a, 0x4e, 0x7e, 0x9b, 0x92, 0x77, 0x67, 0xcf, 0xf8, 0xc7, - 0x09, 0x1a, 0x60, 0x39, 0x7b, 0x77, 0xd6, 0x94, 0x3d, 0xf6, 0x8c, 0x29, 0xff, 0x84, 0xb2, 0x89, - 0xc0, 0x9e, 0x9a, 0xf3, 0x63, 0x98, 0x73, 0x6f, 0x75, 0xbd, 0xb1, 0x7d, 0x34, 0x2a, 0x35, 0x55, - 0xb9, 0x02, 0xda, 0x95, 0xa9, 0xec, 0xc7, 0xbd, 0xe4, 0x6d, 0x50, 0x94, 0x11, 0x24, 0x31, 0x2b, - 0xcc, 0x2e, 0xb3, 0xb2, 0xa3, 0x26, 0x22, 0xac, 0x30, 0x94, 0x67, 0x45, 0x20, 0x51, 0x2b, 0xae, - 0xd3, 0x67, 0x56, 0x3e, 0x50, 0xa5, 0x99, 0x56, 0xdc, 0x10, 0xc0, 0xad, 0x04, 0x48, 0x4b, 0xeb, - 0x7e, 0xbe, 0x85, 0xed, 0xe4, 0x8b, 0xe1, 0x04, 0x6c, 0x03, 0xef, 0xcf, 0xc1, 0x4a, 0x46, 0x13, - 0x06, 0x37, 0x4d, 0xfb, 0xd9, 0x08, 0x5a, 0x60, 0x34, 0xd3, 0xb4, 0x9f, 0x9b, 0x41, 0x2b, 0xff, - 0xa6, 0x04, 0x49, 0x9a, 0x4f, 0x92, 0x2c, 0x24, 0xdf, 0x6b, 0x6d, 0x3e, 0x56, 0xce, 0xd1, 0x5f, - 0x0f, 0x5b, 0xad, 0xa7, 0x8a, 0x44, 0x72, 0x90, 0x7a, 0xf8, 0x95, 0xbd, 0xc6, 0xae, 0x22, 0x93, - 0x22, 0xe4, 0x9b, 0x9b, 0xdb, 0x1b, 0x0d, 0x63, 0xc7, 0xd8, 0xdc, 0xde, 0x53, 0x12, 0xb4, 0xad, - 0xf9, 0xb4, 0xf5, 0x60, 0x4f, 0x49, 0x92, 0x0c, 0x24, 0x68, 0x5d, 0x8a, 0x00, 0xa4, 0x77, 0xf7, - 0x8c, 0xcd, 0xed, 0x0d, 0x25, 0x4d, 0xad, 0xec, 0x6d, 0x6e, 0x35, 0x94, 0x0c, 0x45, 0xee, 0xbd, - 0xbb, 0xf3, 0xb4, 0xa1, 0x64, 0xe9, 0xcf, 0x07, 0x86, 0xf1, 0xe0, 0x2b, 0x4a, 0x8e, 0x92, 0xb6, - 0x1e, 0xec, 0x28, 0x80, 0xcd, 0x0f, 0x1e, 0x3e, 0x6d, 0x28, 0x79, 0x52, 0x80, 0x6c, 0xf3, 0xdd, - 0xed, 0x47, 0x7b, 0x9b, 0xad, 0x6d, 0xa5, 0x50, 0x3e, 0x81, 0x12, 0x5b, 0xe6, 0xc0, 0x2a, 0xb2, - 0xa4, 0xf0, 0x1d, 0x48, 0xb1, 0x9d, 0x91, 0x50, 0x25, 0x95, 0xf0, 0xce, 0x4c, 0x53, 0x56, 0xd8, - 0x1e, 0x31, 0xda, 0xd2, 0x65, 0x48, 0xb1, 0x55, 0x5a, 0x84, 0x14, 0x5b, 0x1d, 0x19, 0x53, 0x45, - 0x56, 0x28, 0xff, 0x96, 0x0c, 0xb0, 0x61, 0xef, 0x3e, 0xef, 0x8f, 0x30, 0x21, 0xbf, 0x0c, 0x30, - 0x79, 0xde, 0x1f, 0xb5, 0x51, 0xf5, 0x3c, 0xa9, 0xcc, 0xd1, 0x1a, 0xf4, 0x77, 0xe4, 0x1a, 0x14, - 0xb0, 0xf9, 0x90, 0x79, 0x21, 0xcc, 0x25, 0x33, 0x46, 0x9e, 0xd6, 0x71, 0xc7, 0x14, 0x84, 0xd4, - 0x74, 0x4c, 0x21, 0xd3, 0x02, 0xa4, 0xa6, 0x93, 0xab, 0x80, 0xc5, 0xf6, 0x04, 0x23, 0x0a, 0xa6, - 0x8d, 0x39, 0x03, 0xfb, 0x65, 0x31, 0x86, 0xbc, 0x0d, 0xd8, 0x27, 0x9b, 0x77, 0x71, 0xfa, 0x74, - 0xb8, 0xc3, 0x5d, 0xa1, 0x3f, 0xd8, 0x6c, 0x7d, 0xc2, 0x52, 0x0b, 0x72, 0x5e, 0x3d, 0xed, 0x0b, - 0x6b, 0xf9, 0x8c, 0x14, 0x9c, 0x11, 0x60, 0x95, 0x37, 0x25, 0x06, 0xe0, 0xa3, 0x59, 0xc0, 0xd1, - 0x30, 0x12, 0x1b, 0x4e, 0xf9, 0x32, 0xcc, 0x6d, 0xdb, 0x16, 0x3b, 0xbd, 0xb8, 0x4a, 0x05, 0x90, - 0x3a, 0x25, 0x09, 0xb3, 0x27, 0xa9, 0x53, 0xbe, 0x02, 0x20, 0xb4, 0x29, 0x20, 0xed, 0xb3, 0x36, - 0xf4, 0x01, 0xd2, 0x7e, 0xf9, 0x26, 0xa4, 0xb7, 0x3a, 0xc7, 0x7b, 0x9d, 0x1e, 0xb9, 0x06, 0x30, - 0xe8, 0x4c, 0x9c, 0xf6, 0x21, 0xee, 0xc3, 0xe7, 0x9f, 0x7f, 0xfe, 0xb9, 0x84, 0x97, 0xbd, 0x1c, - 0xad, 0x65, 0xfb, 0xf1, 0x02, 0xa0, 0x35, 0xe8, 0x6e, 0x99, 0x93, 0x49, 0xa7, 0x67, 0x92, 0x2a, - 0xa4, 0x2d, 0x73, 0x42, 0xa3, 0x9d, 0x84, 0xef, 0x08, 0xcb, 0xfe, 0x2a, 0xf8, 0xa8, 0x95, 0x6d, - 0x84, 0x18, 0x1c, 0x4a, 0x14, 0x48, 0x58, 0x47, 0x43, 0x7c, 0x27, 0x49, 0x19, 0xf4, 0xe7, 0xd2, - 0x25, 0x48, 0x33, 0x0c, 0x21, 0x90, 0xb4, 0x3a, 0x43, 0xb3, 0xc4, 0xfa, 0xc5, 0xdf, 0xe5, 0x5f, - 0x95, 0x00, 0xb6, 0xcd, 0x97, 0x67, 0xe8, 0xd3, 0x47, 0xc5, 0xf4, 0x99, 0x60, 0x7d, 0xde, 0x8f, - 0xeb, 0x93, 0xea, 0xec, 0xd0, 0xb6, 0xbb, 0x6d, 0xb6, 0xc5, 0xec, 0x49, 0x27, 0x47, 0x6b, 0x70, - 0xd7, 0xca, 0x1f, 0x40, 0x61, 0xd3, 0xb2, 0xcc, 0xb1, 0x3b, 0x26, 0x02, 0xc9, 0x67, 0xf6, 0xc4, - 0xe1, 0x6f, 0x4b, 0xf8, 0x9b, 0x94, 0x20, 0x39, 0xb2, 0xc7, 0x0e, 0x9b, 0x67, 0x3d, 0xa9, 0xaf, - 0xae, 0xae, 0x1a, 0x58, 0x43, 0x2e, 0x41, 0xee, 0xc0, 0xb6, 0x2c, 0xf3, 0x80, 0x4e, 0x22, 0x81, - 0x69, 0x8d, 0x5f, 0x51, 0xfe, 0x65, 0x09, 0x0a, 0x2d, 0xe7, 0x99, 0x6f, 0x5c, 0x81, 0xc4, 0x73, - 0xf3, 0x04, 0x87, 0x97, 0x30, 0xe8, 0x4f, 0x7a, 0x54, 0x7e, 0xbe, 0x33, 0x38, 0x62, 0x6f, 0x4d, - 0x05, 0x83, 0x15, 0xc8, 0x05, 0x48, 0xbf, 0x34, 0xfb, 0xbd, 0x67, 0x0e, 0xda, 0x94, 0x0d, 0x5e, - 0x22, 0xb7, 0x20, 0xd5, 0xa7, 0x83, 0x2d, 0x25, 0x71, 0xbd, 0x2e, 0xf8, 0xeb, 0x25, 0xce, 0xc1, - 0x60, 0xa0, 0x1b, 0xd9, 0x6c, 0x57, 0xf9, 0xe8, 0xa3, 0x8f, 0x3e, 0x92, 0xcb, 0x87, 0xb0, 0xe8, - 0x1e, 0xde, 0xc0, 0x64, 0xb7, 0xa1, 0x34, 0x30, 0xed, 0xf6, 0x61, 0xdf, 0xea, 0x0c, 0x06, 0x27, - 0xed, 0x97, 0xb6, 0xd5, 0xee, 0x58, 0x6d, 0x7b, 0x72, 0xd0, 0x19, 0xe3, 0x02, 0x44, 0x77, 0xb1, - 0x38, 0x30, 0xed, 0x26, 0xa3, 0xbd, 0x6f, 0x5b, 0x0f, 0xac, 0x16, 0xe5, 0x94, 0xff, 0x20, 0x09, - 0xb9, 0xad, 0x13, 0xd7, 0xfa, 0x22, 0xa4, 0x0e, 0xec, 0x23, 0x8b, 0xad, 0x65, 0xca, 0x60, 0x05, - 0x6f, 0x8f, 0x64, 0x61, 0x8f, 0x16, 0x21, 0xf5, 0xe2, 0xc8, 0x76, 0x4c, 0x9c, 0x6e, 0xce, 0x60, - 0x05, 0xba, 0x5a, 0x23, 0xd3, 0x29, 0x25, 0x31, 0xb9, 0xa5, 0x3f, 0xfd, 0xf9, 0xa7, 0xce, 0x30, - 0x7f, 0xb2, 0x02, 0x69, 0x9b, 0xae, 0xfe, 0xa4, 0x94, 0xc6, 0x77, 0x35, 0x01, 0x2e, 0xee, 0x8a, - 0xc1, 0x51, 0x64, 0x13, 0x16, 0x5e, 0x9a, 0xed, 0xe1, 0xd1, 0xc4, 0x69, 0xf7, 0xec, 0x76, 0xd7, - 0x34, 0x47, 0xe6, 0xb8, 0x34, 0x87, 0x3d, 0x09, 0x3e, 0x61, 0xd6, 0x42, 0x1a, 0xf3, 0x2f, 0xcd, - 0xad, 0xa3, 0x89, 0xb3, 0x61, 0x3f, 0x46, 0x16, 0xa9, 0x42, 0x6e, 0x6c, 0x52, 0x4f, 0x40, 0x07, - 0x5b, 0x08, 0xf7, 0x1e, 0xa0, 0x66, 0xc7, 0xe6, 0x08, 0x2b, 0xc8, 0x3a, 0x64, 0xf7, 0xfb, 0xcf, - 0xcd, 0xc9, 0x33, 0xb3, 0x5b, 0xca, 0xa8, 0x52, 0x65, 0x5e, 0xbb, 0xe8, 0x73, 0xbc, 0x65, 0x5d, - 0x79, 0x64, 0x0f, 0xec, 0xb1, 0xe1, 0x41, 0xc9, 0x7d, 0xc8, 0x4d, 0xec, 0xa1, 0xc9, 0xf4, 0x9d, - 0xc5, 0xa0, 0x7a, 0x79, 0x16, 0x6f, 0xd7, 0x1e, 0x9a, 0xae, 0x07, 0x73, 0xf1, 0x64, 0x99, 0x0d, - 0x74, 0x9f, 0x5e, 0x9d, 0x4b, 0x80, 0x4f, 0x03, 0x74, 0x40, 0x78, 0x95, 0x26, 0x4b, 0x74, 0x40, - 0xbd, 0x43, 0x7a, 0x23, 0x2a, 0xe5, 0x31, 0xaf, 0xf4, 0xca, 0x4b, 0xb7, 0x20, 0xe7, 0x19, 0xf4, - 0x5d, 0x1f, 0x73, 0x37, 0x39, 0xf4, 0x07, 0xcc, 0xf5, 0x31, 0x5f, 0xf3, 0x06, 0xa4, 0x70, 0xd8, - 0x34, 0x42, 0x19, 0x0d, 0x1a, 0x10, 0x73, 0x90, 0xda, 0x30, 0x1a, 0x8d, 0x6d, 0x45, 0xc2, 0xd8, - 0xf8, 0xf4, 0xdd, 0x86, 0x22, 0x0b, 0x8a, 0xfd, 0x6d, 0x09, 0x12, 0x8d, 0x63, 0x54, 0x0b, 0x9d, - 0x86, 0x7b, 0xa2, 0xe9, 0x6f, 0xad, 0x06, 0xc9, 0xa1, 0x3d, 0x36, 0xc9, 0xf9, 0x19, 0xb3, 0x2c, - 0xf5, 0x70, 0xbf, 0x84, 0x57, 0xe4, 0xc6, 0xb1, 0x63, 0x20, 0x5e, 0x7b, 0x0b, 0x92, 0x8e, 0x79, - 0xec, 0xcc, 0xe6, 0x3d, 0x63, 0x1d, 0x50, 0x80, 0x76, 0x13, 0xd2, 0xd6, 0xd1, 0x70, 0xdf, 0x1c, - 0xcf, 0x86, 0xf6, 0x71, 0x7a, 0x1c, 0x52, 0x7e, 0x0f, 0x94, 0x47, 0xf6, 0x70, 0x34, 0x30, 0x8f, - 0x1b, 0xc7, 0x8e, 0x69, 0x4d, 0xfa, 0xb6, 0x45, 0xf5, 0x7c, 0xd8, 0x1f, 0xa3, 0x17, 0xc1, 0xb7, - 0x62, 0x2c, 0xd0, 0x53, 0x3d, 0x31, 0x0f, 0x6c, 0xab, 0xcb, 0x1d, 0x26, 0x2f, 0x51, 0xb4, 0xf3, - 0xac, 0x3f, 0xa6, 0x0e, 0x84, 0xfa, 0x79, 0x56, 0x28, 0x6f, 0x40, 0x91, 0xe7, 0x18, 0x13, 0xde, - 0x71, 0xf9, 0x06, 0x14, 0xdc, 0x2a, 0x7c, 0x38, 0xcf, 0x42, 0xf2, 0x83, 0x86, 0xd1, 0x52, 0xce, - 0xd1, 0x65, 0x6d, 0x6d, 0x37, 0x14, 0x89, 0xfe, 0xd8, 0x7b, 0xbf, 0x15, 0x58, 0xca, 0x4b, 0x50, - 0xf0, 0xc6, 0xbe, 0x6b, 0x3a, 0xd8, 0x42, 0x03, 0x42, 0xa6, 0x2e, 0x67, 0xa5, 0x72, 0x06, 0x52, - 0x8d, 0xe1, 0xc8, 0x39, 0x29, 0xff, 0x22, 0xe4, 0x39, 0xe8, 0x69, 0x7f, 0xe2, 0x90, 0x3b, 0x90, - 0x19, 0xf2, 0xf9, 0x4a, 0x78, 0xdd, 0x13, 0x35, 0xe5, 0xe3, 0xdc, 0xdf, 0x86, 0x8b, 0x5e, 0xaa, - 0x42, 0x46, 0xf0, 0xa5, 0xfc, 0xa8, 0xcb, 0xe2, 0x51, 0x67, 0x4e, 0x21, 0x21, 0x38, 0x85, 0xf2, - 0x16, 0x64, 0x58, 0x04, 0x9c, 0x60, 0x54, 0x67, 0xa9, 0x22, 0x13, 0x13, 0xdb, 0xf9, 0x3c, 0xab, - 0x63, 0x17, 0x95, 0xab, 0x90, 0x47, 0xc1, 0x72, 0x04, 0x73, 0x9d, 0x80, 0x55, 0x4c, 0x6e, 0xbf, - 0x9f, 0x82, 0xac, 0xbb, 0x52, 0x64, 0x19, 0xd2, 0x2c, 0x3f, 0x43, 0x53, 0xee, 0xfb, 0x41, 0x0a, - 0x33, 0x32, 0xb2, 0x0c, 0x19, 0x9e, 0x83, 0x71, 0xef, 0x2e, 0x57, 0x35, 0x23, 0xcd, 0x72, 0x2e, - 0xaf, 0xb1, 0xa6, 0xa3, 0x63, 0x62, 0x2f, 0x03, 0x69, 0x96, 0x55, 0x11, 0x15, 0x72, 0x5e, 0x1e, - 0x85, 0xfe, 0x98, 0x3f, 0x03, 0x64, 0xdd, 0xc4, 0x49, 0x40, 0xd4, 0x74, 0xf4, 0x58, 0x3c, 0xe7, - 0xcf, 0x36, 0xfd, 0xeb, 0x49, 0xd6, 0xcd, 0x86, 0xf0, 0xf9, 0xde, 0x4d, 0xf0, 0x33, 0x3c, 0xff, - 0xf1, 0x01, 0x35, 0x1d, 0x5d, 0x82, 0x9b, 0xcd, 0x67, 0x78, 0x8e, 0x43, 0xae, 0xd2, 0x21, 0x62, - 0xce, 0x82, 0x47, 0xdf, 0x4f, 0xdd, 0xd3, 0x2c, 0x93, 0x21, 0xd7, 0xa8, 0x05, 0x96, 0x98, 0xe0, - 0xb9, 0xf4, 0xf3, 0xf4, 0x0c, 0xcf, 0x57, 0xc8, 0x4d, 0x0a, 0x61, 0xcb, 0x5f, 0x82, 0x88, 0xa4, - 0x3c, 0xc3, 0x93, 0x72, 0xa2, 0xd2, 0x0e, 0xd1, 0x3d, 0xa0, 0x4b, 0x10, 0x12, 0xf0, 0x34, 0x4b, - 0xc0, 0xc9, 0x15, 0x34, 0xc7, 0x26, 0x55, 0xf0, 0x93, 0xed, 0x0c, 0x4f, 0x70, 0xfc, 0x76, 0xbc, - 0xb2, 0x79, 0x89, 0x75, 0x86, 0xa7, 0x30, 0xa4, 0x46, 0xf7, 0x8b, 0xea, 0xbb, 0x34, 0x8f, 0x4e, - 0xb0, 0xe4, 0x0b, 0xcf, 0xdd, 0x53, 0xe6, 0x03, 0xeb, 0xcc, 0x83, 0x18, 0xa9, 0x26, 0x9e, 0x86, - 0x25, 0xca, 0xdb, 0xe9, 0x5b, 0x87, 0xa5, 0x22, 0xae, 0x44, 0xa2, 0x6f, 0x1d, 0x1a, 0xa9, 0x26, - 0xad, 0x61, 0x1a, 0xd8, 0xa6, 0x6d, 0x0a, 0xb6, 0x25, 0x6f, 0xb3, 0x46, 0x5a, 0x45, 0x4a, 0x90, - 0x6a, 0xb6, 0xb7, 0x3b, 0x56, 0x69, 0x81, 0xf1, 0xac, 0x8e, 0x65, 0x24, 0x9b, 0xdb, 0x1d, 0x8b, - 0xbc, 0x05, 0x89, 0xc9, 0xd1, 0x7e, 0x89, 0x84, 0xbf, 0xac, 0xec, 0x1e, 0xed, 0xbb, 0x43, 0x31, - 0x28, 0x82, 0x2c, 0x43, 0x76, 0xe2, 0x8c, 0xdb, 0xbf, 0x60, 0x8e, 0xed, 0xd2, 0x79, 0x5c, 0xc2, - 0x73, 0x46, 0x66, 0xe2, 0x8c, 0x3f, 0x30, 0xc7, 0xf6, 0x19, 0x9d, 0x5f, 0xf9, 0x0a, 0xe4, 0x05, - 0xbb, 0xa4, 0x08, 0x92, 0xc5, 0x6e, 0x0a, 0x75, 0xe9, 0x8e, 0x21, 0x59, 0xe5, 0x3d, 0x28, 0xb8, - 0x39, 0x0c, 0xce, 0x57, 0xa3, 0x27, 0x69, 0x60, 0x8f, 0xf1, 0x7c, 0xce, 0x6b, 0x97, 0xc4, 0x10, - 0xe5, 0xc3, 0x78, 0xb8, 0x60, 0xd0, 0xb2, 0x12, 0x1a, 0x8a, 0x54, 0xfe, 0xa1, 0x04, 0x85, 0x2d, - 0x7b, 0xec, 0x3f, 0x30, 0x2f, 0x42, 0x6a, 0xdf, 0xb6, 0x07, 0x13, 0x34, 0x9b, 0x35, 0x58, 0x81, - 0xbc, 0x01, 0x05, 0xfc, 0xe1, 0xe6, 0x9e, 0xb2, 0xf7, 0xb4, 0x91, 0xc7, 0x7a, 0x9e, 0x70, 0x12, - 0x48, 0xf6, 0x2d, 0x67, 0xc2, 0x3d, 0x19, 0xfe, 0x26, 0x5f, 0x80, 0x3c, 0xfd, 0xeb, 0x32, 0x93, - 0xde, 0x85, 0x15, 0x68, 0x35, 0x27, 0xbe, 0x05, 0x73, 0xb8, 0xfb, 0x1e, 0x2c, 0xe3, 0x3d, 0x63, - 0x14, 0x58, 0x03, 0x07, 0x96, 0x20, 0xc3, 0x5c, 0xc1, 0x04, 0xbf, 0x96, 0xe5, 0x0c, 0xb7, 0x48, - 0xdd, 0x2b, 0x66, 0x02, 0x2c, 0xdc, 0x67, 0x0c, 0x5e, 0x2a, 0x3f, 0x80, 0x2c, 0x46, 0xa9, 0xd6, - 0xa0, 0x4b, 0xca, 0x20, 0xf5, 0x4a, 0x26, 0xc6, 0xc8, 0x45, 0xe1, 0x9a, 0xcf, 0x9b, 0x57, 0x36, - 0x0c, 0xa9, 0xb7, 0xb4, 0x00, 0xd2, 0x06, 0xbd, 0x77, 0x1f, 0x73, 0x37, 0x2d, 0x1d, 0x97, 0x5b, - 0xdc, 0xc4, 0xb6, 0xf9, 0x32, 0xce, 0xc4, 0xb6, 0xf9, 0x92, 0x99, 0xb8, 0x3a, 0x65, 0x82, 0x96, - 0x4e, 0xf8, 0xa7, 0x43, 0xe9, 0xa4, 0x5c, 0x85, 0x39, 0x3c, 0x9e, 0x7d, 0xab, 0xb7, 0x63, 0xf7, - 0x2d, 0xbc, 0xe7, 0x1f, 0xe2, 0x3d, 0x49, 0x32, 0xa4, 0x43, 0xba, 0x07, 0xe6, 0x71, 0xe7, 0x80, - 0xdd, 0x38, 0xb3, 0x06, 0x2b, 0x94, 0x3f, 0x4b, 0xc2, 0x3c, 0x77, 0xad, 0xef, 0xf7, 0x9d, 0x67, - 0x5b, 0x9d, 0x11, 0x79, 0x0a, 0x05, 0xea, 0x55, 0xdb, 0xc3, 0xce, 0x68, 0x44, 0x8f, 0xaf, 0x84, - 0x57, 0x8d, 0xeb, 0x53, 0xae, 0x9a, 0xe3, 0x57, 0xb6, 0x3b, 0x43, 0x73, 0x8b, 0x61, 0x1b, 0x96, - 0x33, 0x3e, 0x31, 0xf2, 0x96, 0x5f, 0x43, 0x36, 0x21, 0x3f, 0x9c, 0xf4, 0x3c, 0x63, 0x32, 0x1a, - 0xab, 0x44, 0x1a, 0xdb, 0x9a, 0xf4, 0x02, 0xb6, 0x60, 0xe8, 0x55, 0xd0, 0x81, 0x51, 0x7f, 0xec, - 0xd9, 0x4a, 0x9c, 0x32, 0x30, 0xea, 0x3a, 0x82, 0x03, 0xdb, 0xf7, 0x6b, 0xc8, 0x63, 0x00, 0x7a, - 0xbc, 0x1c, 0x9b, 0xa6, 0x4e, 0xa8, 0xa0, 0xbc, 0xf6, 0x66, 0xa4, 0xad, 0x5d, 0x67, 0xbc, 0x67, - 0xef, 0x3a, 0x63, 0x66, 0x88, 0x1e, 0x4c, 0x2c, 0x2e, 0xbd, 0x03, 0x4a, 0x78, 0xfe, 0xe2, 0x8d, - 0x3c, 0x35, 0xe3, 0x46, 0x9e, 0xe3, 0x37, 0xf2, 0xba, 0x7c, 0x57, 0x5a, 0x7a, 0x0f, 0x8a, 0xa1, - 0x29, 0x8b, 0x74, 0xc2, 0xe8, 0xb7, 0x45, 0x7a, 0x5e, 0x7b, 0x5d, 0xf8, 0x9c, 0x2d, 0x6e, 0xb8, - 0x68, 0xf7, 0x1d, 0x50, 0xc2, 0xd3, 0x17, 0x0d, 0x67, 0x63, 0x32, 0x05, 0xe4, 0xdf, 0x87, 0xb9, - 0xc0, 0x94, 0x45, 0x72, 0xee, 0x94, 0x49, 0x95, 0x7f, 0x29, 0x05, 0xa9, 0x96, 0x65, 0xda, 0x87, - 0xe4, 0xf5, 0x60, 0x9c, 0x7c, 0x72, 0xce, 0x8d, 0x91, 0x17, 0x43, 0x31, 0xf2, 0xc9, 0x39, 0x2f, - 0x42, 0x5e, 0x0c, 0x45, 0x48, 0xb7, 0xa9, 0xa6, 0x93, 0xcb, 0x53, 0xf1, 0xf1, 0xc9, 0x39, 0x21, - 0x38, 0x5e, 0x9e, 0x0a, 0x8e, 0x7e, 0x73, 0x4d, 0xa7, 0x0e, 0x35, 0x18, 0x19, 0x9f, 0x9c, 0xf3, - 0xa3, 0xe2, 0x72, 0x38, 0x2a, 0x7a, 0x8d, 0x35, 0x9d, 0x0d, 0x49, 0x88, 0x88, 0x38, 0x24, 0x16, - 0x0b, 0x97, 0xc3, 0xb1, 0x10, 0x79, 0x3c, 0x0a, 0x2e, 0x87, 0xa3, 0x20, 0x36, 0xf2, 0xa8, 0x77, - 0x31, 0x14, 0xf5, 0xd0, 0x28, 0x0b, 0x77, 0xcb, 0xe1, 0x70, 0xc7, 0x78, 0xc2, 0x48, 0xc5, 0x58, - 0xe7, 0x35, 0xd6, 0x74, 0xa2, 0x85, 0x02, 0x5d, 0xf4, 0x6d, 0x1f, 0xf7, 0x02, 0x9d, 0xbe, 0x4e, - 0x97, 0xcd, 0xbd, 0x88, 0x16, 0x63, 0xbe, 0xf8, 0xe3, 0x6a, 0xba, 0x17, 0x31, 0x0d, 0x32, 0x87, - 0x3c, 0x01, 0x56, 0xd0, 0x73, 0x09, 0xb2, 0xc4, 0xcd, 0x5f, 0x69, 0xb6, 0xd1, 0x83, 0xd1, 0x79, - 0x1d, 0xb2, 0x3b, 0x7d, 0x05, 0xe6, 0x9a, 0xed, 0xa7, 0x9d, 0x71, 0xcf, 0x9c, 0x38, 0xed, 0xbd, - 0x4e, 0xcf, 0x7b, 0x44, 0xa0, 0xfb, 0x9f, 0x6f, 0xf2, 0x96, 0xbd, 0x4e, 0x8f, 0x5c, 0x70, 0xc5, - 0xd5, 0xc5, 0x56, 0x89, 0xcb, 0x6b, 0xe9, 0x75, 0xba, 0x68, 0xcc, 0x18, 0xfa, 0xc2, 0x05, 0xee, - 0x0b, 0x1f, 0x66, 0x20, 0x75, 0x64, 0xf5, 0x6d, 0xeb, 0x61, 0x0e, 0x32, 0x8e, 0x3d, 0x1e, 0x76, - 0x1c, 0xbb, 0xfc, 0x23, 0x09, 0xe0, 0x91, 0x3d, 0x1c, 0x1e, 0x59, 0xfd, 0x17, 0x47, 0x26, 0xb9, - 0x02, 0xf9, 0x61, 0xe7, 0xb9, 0xd9, 0x1e, 0x9a, 0xed, 0x83, 0xb1, 0x7b, 0x0e, 0x72, 0xb4, 0x6a, - 0xcb, 0x7c, 0x34, 0x3e, 0x21, 0x25, 0xf7, 0x8a, 0x8e, 0xda, 0x41, 0x49, 0xf2, 0x2b, 0xfb, 0x22, - 0xbf, 0x74, 0xa6, 0xf9, 0x1e, 0xba, 0xd7, 0x4e, 0x96, 0x47, 0x64, 0xf8, 0xee, 0x61, 0x89, 0x4a, - 0xde, 0x31, 0x87, 0xa3, 0xf6, 0x01, 0x4a, 0x85, 0xca, 0x21, 0x45, 0xcb, 0x8f, 0xc8, 0x6d, 0x48, - 0x1c, 0xd8, 0x03, 0x14, 0xc9, 0x29, 0xfb, 0x42, 0x71, 0xe4, 0x0d, 0x48, 0x0c, 0x27, 0x4c, 0x36, - 0x79, 0x6d, 0x41, 0xb8, 0x27, 0xb0, 0xd0, 0x44, 0x61, 0xc3, 0x49, 0xcf, 0x9b, 0xf7, 0x8d, 0x22, - 0x24, 0x9a, 0xad, 0x16, 0x8d, 0xfd, 0xcd, 0x56, 0x6b, 0x4d, 0x91, 0xea, 0x5f, 0x82, 0x6c, 0x6f, - 0x6c, 0x9a, 0xd4, 0x3d, 0xcc, 0xce, 0x39, 0x3e, 0xc4, 0x58, 0xe7, 0x81, 0xea, 0x5b, 0x90, 0x39, - 0x60, 0x59, 0x07, 0x89, 0x48, 0x6b, 0x4b, 0x7f, 0xc8, 0x1e, 0x55, 0x96, 0xfc, 0xe6, 0x70, 0x9e, - 0x62, 0xb8, 0x36, 0xea, 0x3b, 0x90, 0x1b, 0xb7, 0x4f, 0x33, 0xf8, 0x31, 0x8b, 0x2e, 0x71, 0x06, - 0xb3, 0x63, 0x5e, 0x55, 0x6f, 0xc0, 0x82, 0x65, 0xbb, 0xdf, 0x50, 0xda, 0x5d, 0x76, 0xc6, 0x2e, - 0x4e, 0x5f, 0xe5, 0x5c, 0xe3, 0x26, 0xfb, 0x6e, 0x69, 0xd9, 0xbc, 0x81, 0x9d, 0xca, 0xfa, 0x23, - 0x50, 0x04, 0x33, 0x98, 0x7a, 0xc6, 0x59, 0x39, 0x64, 0x1f, 0x4a, 0x3d, 0x2b, 0x78, 0xee, 0x43, - 0x46, 0xd8, 0xc9, 0x8c, 0x31, 0xd2, 0x63, 0x5f, 0x9d, 0x3d, 0x23, 0xe8, 0xea, 0xa6, 0x8d, 0x50, - 0x5f, 0x13, 0x6d, 0xe4, 0x19, 0xfb, 0x20, 0x2d, 0x1a, 0xa9, 0xe9, 0xa1, 0x55, 0x39, 0x3a, 0x75, - 0x28, 0x7d, 0xf6, 0x3d, 0xd9, 0xb3, 0xc2, 0x1c, 0xe0, 0x0c, 0x33, 0xf1, 0x83, 0xf9, 0x90, 0x7d, - 0x6a, 0x0e, 0x98, 0x99, 0x1a, 0xcd, 0xe4, 0xd4, 0xd1, 0x3c, 0x67, 0xdf, 0x75, 0x3d, 0x33, 0xbb, - 0xb3, 0x46, 0x33, 0x39, 0x75, 0x34, 0x03, 0xf6, 0xc5, 0x37, 0x60, 0xa6, 0xa6, 0xd7, 0x37, 0x80, - 0x88, 0x5b, 0xcd, 0xe3, 0x44, 0x8c, 0x9d, 0x21, 0xfb, 0x8e, 0xef, 0x6f, 0x36, 0xa3, 0xcc, 0x32, - 0x14, 0x3f, 0x20, 0x8b, 0x7d, 0xe2, 0x0f, 0x1a, 0xaa, 0xe9, 0xf5, 0x4d, 0x38, 0x2f, 0x4e, 0xec, - 0x0c, 0x43, 0xb2, 0x55, 0xa9, 0x52, 0x34, 0x16, 0xfc, 0xa9, 0x71, 0xce, 0x4c, 0x53, 0xf1, 0x83, - 0x1a, 0xa9, 0x52, 0x45, 0x99, 0x32, 0x55, 0xd3, 0xeb, 0x0f, 0xa0, 0x28, 0x98, 0xda, 0xc7, 0x08, - 0x1d, 0x6d, 0xe6, 0x05, 0xfb, 0x5f, 0x0b, 0xcf, 0x0c, 0x8d, 0xe8, 0xe1, 0x1d, 0xe3, 0x31, 0x2e, - 0xda, 0xc8, 0x98, 0xfd, 0xa3, 0x80, 0x3f, 0x16, 0x64, 0x84, 0x8e, 0x04, 0xe6, 0xdf, 0x71, 0x56, - 0x26, 0xec, 0x5f, 0x08, 0xfc, 0xa1, 0x50, 0x42, 0xbd, 0x1f, 0x98, 0x8e, 0x49, 0x83, 0x5c, 0x8c, - 0x0d, 0x07, 0x3d, 0xf2, 0x9b, 0x91, 0x80, 0x15, 0xf1, 0x81, 0x44, 0x98, 0x36, 0x2d, 0xd6, 0x37, - 0x61, 0xfe, 0xec, 0x0e, 0xe9, 0x63, 0x89, 0x65, 0xcb, 0xd5, 0x15, 0x9a, 0x50, 0x1b, 0x73, 0xdd, - 0x80, 0x5f, 0x6a, 0xc0, 0xdc, 0x99, 0x9d, 0xd2, 0x27, 0x12, 0xcb, 0x39, 0xa9, 0x25, 0xa3, 0xd0, - 0x0d, 0x7a, 0xa6, 0xb9, 0x33, 0xbb, 0xa5, 0x4f, 0x25, 0xf6, 0x40, 0xa1, 0x6b, 0x9e, 0x11, 0xd7, - 0x33, 0xcd, 0x9d, 0xd9, 0x2d, 0x7d, 0x95, 0x65, 0x94, 0xb2, 0x5e, 0x15, 0x8d, 0xa0, 0x2f, 0x98, - 0x3f, 0xbb, 0x5b, 0xfa, 0x9a, 0x84, 0x8f, 0x15, 0xb2, 0xae, 0x7b, 0xeb, 0xe2, 0x79, 0xa6, 0xf9, - 0xb3, 0xbb, 0xa5, 0xaf, 0x4b, 0xf8, 0xa4, 0x21, 0xeb, 0xeb, 0x01, 0x33, 0xc1, 0xd1, 0x9c, 0xee, - 0x96, 0xbe, 0x21, 0xe1, 0x2b, 0x83, 0xac, 0xd7, 0x3c, 0x33, 0xbb, 0x53, 0xa3, 0x39, 0xdd, 0x2d, - 0x7d, 0x13, 0x6f, 0xf1, 0x75, 0x59, 0xbf, 0x13, 0x30, 0x83, 0x9e, 0xa9, 0xf8, 0x0a, 0x6e, 0xe9, - 0x5b, 0x12, 0x3e, 0x06, 0xc9, 0xfa, 0x5d, 0xc3, 0xed, 0xdd, 0xf7, 0x4c, 0xc5, 0x57, 0x70, 0x4b, - 0x9f, 0x49, 0xf8, 0x66, 0x24, 0xeb, 0xf7, 0x82, 0x86, 0xd0, 0x33, 0x29, 0xaf, 0xe2, 0x96, 0xbe, - 0x4d, 0x2d, 0x15, 0xeb, 0xf2, 0xfa, 0xaa, 0xe1, 0x0e, 0x40, 0xf0, 0x4c, 0xca, 0xab, 0xb8, 0xa5, - 0xef, 0x50, 0x53, 0x4a, 0x5d, 0x5e, 0x5f, 0x0b, 0x99, 0xaa, 0xe9, 0xf5, 0x47, 0x50, 0x38, 0xab, - 0x5b, 0xfa, 0xae, 0xf8, 0x16, 0x97, 0xef, 0x0a, 0xbe, 0x69, 0x47, 0xd8, 0xb3, 0x53, 0x1d, 0xd3, - 0xf7, 0x30, 0xc7, 0xa9, 0xcf, 0x3d, 0x61, 0xef, 0x55, 0x8c, 0xe0, 0x6f, 0x1f, 0x73, 0x53, 0x5b, - 0xfe, 0xf9, 0x38, 0xd5, 0x47, 0x7d, 0x5f, 0xc2, 0x47, 0xad, 0x02, 0x37, 0x88, 0x78, 0xef, 0xa4, - 0x30, 0x87, 0xf5, 0xa1, 0x3f, 0xcb, 0xd3, 0xbc, 0xd5, 0x0f, 0xa4, 0x57, 0x71, 0x57, 0xf5, 0x44, - 0x6b, 0xbb, 0xe1, 0x2d, 0x06, 0xd6, 0xbc, 0x0d, 0xc9, 0x63, 0x6d, 0x75, 0x4d, 0xbc, 0x92, 0x89, - 0x6f, 0xb9, 0xcc, 0x49, 0xe5, 0xb5, 0xa2, 0xf0, 0xdc, 0x3d, 0x1c, 0x39, 0x27, 0x06, 0xb2, 0x38, - 0x5b, 0x8b, 0x64, 0x7f, 0x12, 0xc3, 0xd6, 0x38, 0xbb, 0x1a, 0xc9, 0xfe, 0x34, 0x86, 0x5d, 0xe5, - 0x6c, 0x3d, 0x92, 0xfd, 0xd5, 0x18, 0xb6, 0xce, 0xd9, 0xeb, 0x91, 0xec, 0xaf, 0xc5, 0xb0, 0xd7, - 0x39, 0xbb, 0x16, 0xc9, 0xfe, 0x7a, 0x0c, 0xbb, 0xc6, 0xd9, 0x77, 0x22, 0xd9, 0xdf, 0x88, 0x61, - 0xdf, 0xe1, 0xec, 0xbb, 0x91, 0xec, 0x6f, 0xc6, 0xb0, 0xef, 0x72, 0xf6, 0xbd, 0x48, 0xf6, 0xb7, - 0x62, 0xd8, 0xf7, 0x18, 0x7b, 0x6d, 0x35, 0x92, 0xfd, 0x59, 0x34, 0x7b, 0x6d, 0x95, 0xb3, 0xa3, - 0xb5, 0xf6, 0xed, 0x18, 0x36, 0xd7, 0xda, 0x5a, 0xb4, 0xd6, 0xbe, 0x13, 0xc3, 0xe6, 0x5a, 0x5b, - 0x8b, 0xd6, 0xda, 0x77, 0x63, 0xd8, 0x5c, 0x6b, 0x6b, 0xd1, 0x5a, 0xfb, 0x5e, 0x0c, 0x9b, 0x6b, - 0x6d, 0x2d, 0x5a, 0x6b, 0xdf, 0x8f, 0x61, 0x73, 0xad, 0xad, 0x45, 0x6b, 0xed, 0x07, 0x31, 0x6c, - 0xae, 0xb5, 0xb5, 0x68, 0xad, 0xfd, 0x51, 0x0c, 0x9b, 0x6b, 0x6d, 0x2d, 0x5a, 0x6b, 0x7f, 0x1c, - 0xc3, 0xe6, 0x5a, 0x5b, 0x8b, 0xd6, 0xda, 0x9f, 0xc4, 0xb0, 0xb9, 0xd6, 0xb4, 0x68, 0xad, 0xfd, - 0x69, 0x34, 0x5b, 0xe3, 0x5a, 0xd3, 0xa2, 0xb5, 0xf6, 0x67, 0x31, 0x6c, 0xae, 0x35, 0x2d, 0x5a, - 0x6b, 0x7f, 0x1e, 0xc3, 0xe6, 0x5a, 0xd3, 0xa2, 0xb5, 0xf6, 0xc3, 0x18, 0x36, 0xd7, 0x9a, 0x16, - 0xad, 0xb5, 0xbf, 0x88, 0x61, 0x73, 0xad, 0x69, 0xd1, 0x5a, 0xfb, 0xcb, 0x18, 0x36, 0xd7, 0x9a, - 0x16, 0xad, 0xb5, 0xbf, 0x8a, 0x61, 0x73, 0xad, 0x69, 0xd1, 0x5a, 0xfb, 0xeb, 0x18, 0x36, 0xd7, - 0x9a, 0x16, 0xad, 0xb5, 0xbf, 0x89, 0x61, 0x73, 0xad, 0x69, 0xd1, 0x5a, 0xfb, 0xdb, 0x18, 0x36, - 0xd7, 0x5a, 0x35, 0x5a, 0x6b, 0x7f, 0x17, 0xcd, 0xae, 0x72, 0xad, 0x55, 0xa3, 0xb5, 0xf6, 0xf7, - 0x31, 0x6c, 0xae, 0xb5, 0x6a, 0xb4, 0xd6, 0xfe, 0x21, 0x86, 0xcd, 0xb5, 0x56, 0x8d, 0xd6, 0xda, - 0x3f, 0xc6, 0xb0, 0xb9, 0xd6, 0xaa, 0xd1, 0x5a, 0xfb, 0x51, 0x0c, 0x9b, 0x6b, 0xad, 0x1a, 0xad, - 0xb5, 0x7f, 0x8a, 0x61, 0x73, 0xad, 0x55, 0xa3, 0xb5, 0xf6, 0xcf, 0x31, 0x6c, 0xae, 0xb5, 0x6a, - 0xb4, 0xd6, 0xfe, 0x25, 0x86, 0xcd, 0xb5, 0x56, 0x8d, 0xd6, 0xda, 0xbf, 0xc6, 0xb0, 0xb9, 0xd6, - 0xaa, 0xd1, 0x5a, 0xfb, 0xb7, 0x18, 0x36, 0xd7, 0x9a, 0x1e, 0xad, 0xb5, 0x7f, 0x8f, 0x66, 0xeb, - 0x5c, 0x6b, 0x7a, 0xb4, 0xd6, 0xfe, 0x23, 0x86, 0xcd, 0xb5, 0xa6, 0x47, 0x6b, 0xed, 0x3f, 0x63, - 0xd8, 0x5c, 0x6b, 0x7a, 0xb4, 0xd6, 0xfe, 0x2b, 0x86, 0xcd, 0xb5, 0xa6, 0x47, 0x6b, 0xed, 0xbf, - 0x63, 0xd8, 0x5c, 0x6b, 0x7a, 0xb4, 0xd6, 0xfe, 0x27, 0x86, 0xcd, 0xb5, 0xa6, 0x47, 0x6b, 0xed, - 0xc7, 0x31, 0x6c, 0xae, 0x35, 0x3d, 0x5a, 0x6b, 0x3f, 0x89, 0x61, 0x73, 0xad, 0xe9, 0xd1, 0x5a, - 0xfb, 0xdf, 0x18, 0x36, 0xd7, 0x9a, 0x1e, 0xad, 0xb5, 0xff, 0x8b, 0x61, 0x73, 0xad, 0xad, 0x47, - 0x6b, 0xed, 0xff, 0xa3, 0xd9, 0xeb, 0xab, 0x3f, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xaa, 0x00, 0xcd, - 0x32, 0x57, 0x39, 0x00, 0x00, + // 3329 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x58, 0xd9, 0x73, 0x1b, 0xc7, + 0xf1, 0xd6, 0xe2, 0xc6, 0x00, 0x24, 0x96, 0x4b, 0x1d, 0x10, 0xe5, 0x83, 0x5a, 0xd9, 0xfa, 0xc9, + 0x92, 0x0d, 0x93, 0x20, 0x48, 0x49, 0xfb, 0xab, 0x94, 0x23, 0x4a, 0x00, 0xcd, 0x98, 0x24, 0x18, + 0x92, 0x8a, 0xcb, 0x4e, 0x25, 0x28, 0x90, 0x5c, 0x82, 0x30, 0x01, 0x2c, 0x04, 0x2c, 0x62, 0x31, + 0x4f, 0x79, 0xcd, 0x43, 0x1e, 0x92, 0x54, 0xaa, 0x5c, 0xf9, 0x1f, 0x92, 0xbc, 0xe7, 0x2f, 0x88, + 0xef, 0xfb, 0xc8, 0x7d, 0x39, 0xf7, 0xed, 0x24, 0x76, 0x92, 0x97, 0xa4, 0xbb, 0x67, 0x6f, 0x60, + 0x87, 0xb4, 0x1e, 0x6c, 0x70, 0xbe, 0xfe, 0x7a, 0x66, 0x7a, 0xba, 0x7b, 0xbe, 0x59, 0xc6, 0x4c, + 0xbd, 0x6f, 0x16, 0xba, 0x3d, 0xc3, 0x34, 0x94, 0x14, 0xfe, 0xde, 0xad, 0x9b, 0x75, 0xf5, 0x01, + 0x96, 0x58, 0x32, 0xca, 0x9d, 0x41, 0x5b, 0x99, 0x62, 0xd1, 0x3d, 0xc3, 0xc8, 0x4b, 0xd3, 0x91, + 0x4b, 0xe3, 0xc5, 0xb1, 0x82, 0x6d, 0x51, 0xa8, 0x54, 0xab, 0xea, 0x65, 0x96, 0x59, 0x32, 0xb6, + 0x60, 0xa4, 0xd2, 0xd4, 0x5b, 0xbb, 0xca, 0x18, 0x8b, 0xaf, 0xd4, 0xb7, 0xf5, 0x16, 0x19, 0xa7, + 0x95, 0x2c, 0x8b, 0x6d, 0x1d, 0x76, 0xf5, 0x7c, 0x04, 0xff, 0x52, 0xbf, 0x7c, 0x12, 0x5d, 0xa2, + 0xb1, 0x72, 0x81, 0xc5, 0x9e, 0x68, 0x76, 0x76, 0x2d, 0x9f, 0xa7, 0x5c, 0x9f, 0x1c, 0x2f, 0x3c, + 0xb1, 0xbc, 0x76, 0x0b, 0x9d, 0x6d, 0xd5, 0xb7, 0x5b, 0x48, 0x97, 0xc0, 0x19, 0xfc, 0xb9, 0x5e, + 0xef, 0xd5, 0xdb, 0xf9, 0x28, 0xfc, 0x19, 0x57, 0x1e, 0x66, 0x63, 0x1b, 0xfa, 0x9d, 0x41, 0xb3, + 0xa7, 0xef, 0xd2, 0xdc, 0xf9, 0x18, 0xf8, 0xca, 0x0c, 0xfb, 0xe2, 0x0b, 0x23, 0xeb, 0xae, 0x5e, + 0x37, 0x6d, 0xeb, 0xf8, 0x74, 0x54, 0x68, 0x5d, 0xed, 0x9a, 0x4d, 0xa3, 0x53, 0x6f, 0x71, 0xeb, + 0x04, 0x4c, 0x19, 0x6a, 0x7d, 0x86, 0xe5, 0x2a, 0xb5, 0x45, 0xc3, 0x68, 0xd5, 0x7a, 0xd6, 0x82, + 0xf2, 0x0c, 0xd6, 0x92, 0x52, 0xf2, 0x4c, 0xae, 0xd4, 0x96, 0x3b, 0xe6, 0x5c, 0xd1, 0x45, 0x32, + 0x80, 0xc4, 0x1d, 0x64, 0xa1, 0xe4, 0x22, 0x59, 0x40, 0xa2, 0x10, 0x6c, 0xa5, 0x52, 0xab, 0x34, + 0xef, 0xea, 0xbb, 0x5e, 0xd6, 0x18, 0x60, 0x49, 0x0f, 0xe6, 0xe5, 0x8d, 0x03, 0x96, 0x50, 0xce, + 0xb2, 0x89, 0x4a, 0xed, 0x76, 0xd3, 0x3f, 0x59, 0x0e, 0xa0, 0x31, 0x17, 0xf2, 0xb2, 0x64, 0x80, + 0x62, 0x7c, 0x1d, 0x95, 0x96, 0x51, 0x37, 0x5d, 0x64, 0x02, 0x90, 0x08, 0x27, 0xdd, 0x32, 0x06, + 0x10, 0x7f, 0x17, 0x52, 0x00, 0x92, 0x38, 0xb4, 0x69, 0xf6, 0x9a, 0x9d, 0x86, 0x0b, 0x4d, 0xd2, + 0x81, 0x93, 0xbf, 0xc5, 0x43, 0x08, 0x93, 0x8b, 0xe8, 0x80, 0x64, 0x2d, 0x52, 0x60, 0x7d, 0x7b, + 0x00, 0x4d, 0xb8, 0x90, 0x77, 0x7d, 0x0d, 0x80, 0x14, 0x5f, 0x68, 0xf9, 0xe9, 0xe5, 0x4f, 0xc2, + 0xc1, 0x05, 0x42, 0x6b, 0x21, 0xa7, 0x00, 0x09, 0x84, 0xd6, 0x42, 0x4e, 0x03, 0x32, 0x14, 0x5a, + 0x0b, 0x3b, 0x03, 0xd8, 0x50, 0x68, 0x2d, 0x2c, 0x0f, 0x58, 0x30, 0xb4, 0x16, 0x74, 0x16, 0xa0, + 0x60, 0x68, 0x2d, 0x68, 0x0a, 0xa0, 0x40, 0x68, 0x2d, 0xe4, 0x1c, 0x20, 0xc1, 0xd0, 0x5a, 0xd0, + 0x3d, 0x00, 0x05, 0x43, 0x6b, 0x41, 0xf7, 0x02, 0x94, 0x06, 0xc8, 0x13, 0x5a, 0x0b, 0x79, 0x5e, + 0x02, 0x28, 0x0b, 0x8b, 0xf7, 0xc6, 0xd6, 0xc2, 0x5e, 0x40, 0x6c, 0xc2, 0xc5, 0xbc, 0x2b, 0x7c, + 0x11, 0x31, 0x6f, 0x74, 0x0d, 0x2b, 0xdb, 0xf3, 0xf7, 0x41, 0xa2, 0xfb, 0xa2, 0xeb, 0x20, 0xf7, + 0x53, 0xd5, 0x79, 0xa2, 0xeb, 0x20, 0xd3, 0x80, 0x04, 0xa2, 0xeb, 0x60, 0xe7, 0x01, 0x0b, 0x44, + 0xd7, 0xc1, 0x54, 0xc0, 0xfc, 0xd1, 0x75, 0xa0, 0x0b, 0x00, 0xf9, 0xa3, 0xeb, 0x40, 0x0f, 0x00, + 0xe4, 0x8b, 0xae, 0x83, 0x3c, 0x08, 0x88, 0x3f, 0xba, 0x0e, 0x74, 0x11, 0x20, 0x7f, 0x74, 0x1d, + 0xe8, 0xff, 0xa8, 0xb9, 0x78, 0xa2, 0xeb, 0x20, 0xdf, 0xc2, 0xbe, 0xe3, 0x8f, 0xae, 0x83, 0x7d, + 0x1b, 0x31, 0x7f, 0x74, 0x1d, 0xec, 0x3b, 0x88, 0x29, 0xca, 0x7d, 0xe4, 0x12, 0xa3, 0xbb, 0xab, + 0xef, 0xd5, 0x07, 0x2d, 0x0c, 0xfc, 0x25, 0x0c, 0xaf, 0x16, 0x33, 0x7b, 0x03, 0x5d, 0xb9, 0x17, + 0xb9, 0x3c, 0xc8, 0xae, 0xc1, 0x43, 0x18, 0x65, 0x2d, 0x32, 0x57, 0x74, 0x60, 0xf0, 0xec, 0xc2, + 0x97, 0x31, 0xd4, 0x5a, 0x64, 0xa1, 0xa4, 0x4c, 0xb3, 0x49, 0x37, 0xdc, 0xae, 0xc1, 0x15, 0x8c, + 0xb7, 0x16, 0x9d, 0x2b, 0xce, 0x78, 0x2c, 0x7c, 0x2e, 0x1e, 0xc6, 0xa8, 0x6b, 0xd1, 0x85, 0x12, + 0x5a, 0x28, 0x4e, 0xe8, 0x5d, 0x83, 0x47, 0x30, 0xf6, 0x5a, 0x0c, 0x5c, 0x78, 0x2c, 0x7c, 0x2e, + 0x0a, 0x78, 0x04, 0x5a, 0x0c, 0x5c, 0xcc, 0x28, 0xe7, 0x71, 0x99, 0xfc, 0x20, 0x5c, 0x83, 0x47, + 0xf1, 0x24, 0xb4, 0xc4, 0xdc, 0x6c, 0x69, 0x76, 0xfe, 0xba, 0xa2, 0xa2, 0x13, 0xeb, 0x44, 0x5c, + 0x9b, 0x19, 0x3c, 0x12, 0x2d, 0x51, 0xbc, 0x3a, 0x7b, 0xad, 0x78, 0x0d, 0x3a, 0xae, 0xe2, 0x1c, + 0x8d, 0x6b, 0x33, 0x8b, 0x67, 0xa3, 0xc9, 0xfb, 0x7a, 0xab, 0x65, 0x3c, 0x3c, 0xad, 0x3e, 0x6b, + 0xf4, 0x5a, 0xbb, 0xe7, 0xc1, 0xdd, 0x05, 0x9c, 0x94, 0x9f, 0x96, 0x6b, 0xfc, 0x55, 0xbc, 0x17, + 0xb2, 0x5a, 0x72, 0xb1, 0xd9, 0xe8, 0x18, 0x7d, 0x9d, 0xaf, 0x7d, 0x33, 0xb8, 0xbb, 0xaf, 0xa1, + 0xd5, 0x84, 0x16, 0x7d, 0x04, 0x42, 0xec, 0x58, 0xf8, 0x76, 0xf7, 0x75, 0xb4, 0x50, 0xc0, 0x02, + 0xa2, 0xac, 0xb2, 0xd3, 0x81, 0xfe, 0x53, 0xeb, 0xd6, 0x77, 0x0e, 0xc0, 0xaa, 0x88, 0x6d, 0x68, + 0x31, 0x22, 0x4b, 0xb0, 0x98, 0x33, 0xc1, 0x56, 0x64, 0x1b, 0xcd, 0x61, 0x47, 0xf2, 0x19, 0x79, + 0xaa, 0xd0, 0x36, 0x2a, 0x61, 0x73, 0x22, 0xa3, 0x07, 0xd9, 0xd9, 0xe1, 0x06, 0x65, 0x9b, 0xcd, + 0x63, 0x9f, 0x0a, 0x98, 0x8d, 0xf0, 0xb6, 0x80, 0x2d, 0x8b, 0xcc, 0x1e, 0x60, 0xf9, 0xa1, 0xb6, + 0x65, 0x5b, 0x5d, 0xc5, 0xee, 0xe5, 0xb7, 0x1a, 0xe1, 0xeb, 0x1a, 0x36, 0x32, 0x77, 0xf9, 0xfe, + 0x66, 0x66, 0x1b, 0x5d, 0xc7, 0x9e, 0xe6, 0xba, 0x0a, 0xf4, 0x35, 0xdb, 0x4a, 0xc3, 0xf6, 0x66, + 0xad, 0x3e, 0x3f, 0xd4, 0xac, 0x6c, 0xab, 0x0f, 0xa3, 0xd8, 0xb3, 0xfc, 0x66, 0x23, 0xd6, 0xf5, + 0x11, 0x9a, 0x29, 0x64, 0x36, 0xcf, 0xc6, 0xec, 0x2b, 0xa3, 0xd1, 0x33, 0x06, 0xdd, 0x7c, 0x05, + 0xee, 0x0d, 0x56, 0xbc, 0x6f, 0x48, 0x51, 0xd8, 0x5a, 0x61, 0x09, 0xad, 0x38, 0x8d, 0x3b, 0xe5, + 0xb4, 0x75, 0xf0, 0x38, 0x9a, 0xc6, 0xad, 0x1c, 0x9a, 0x5d, 0xe5, 0x9c, 0xf6, 0x34, 0xa4, 0xca, + 0x28, 0x9a, 0xad, 0x1e, 0x88, 0x36, 0x75, 0xd1, 0x95, 0x2a, 0xdc, 0xcf, 0xa9, 0xa0, 0x76, 0x59, + 0xc2, 0xdb, 0x93, 0xdb, 0x79, 0xe7, 0x1b, 0xb2, 0xfb, 0xb4, 0x6d, 0xe7, 0x9b, 0x60, 0xd8, 0xee, + 0xb3, 0x24, 0xb8, 0x9e, 0x93, 0x40, 0x66, 0xa1, 0x92, 0x4a, 0xb1, 0xd8, 0x67, 0xaa, 0xcb, 0xb7, + 0xe4, 0x13, 0xf8, 0x6b, 0xb1, 0x5a, 0x5d, 0x81, 0xc8, 0xa5, 0x59, 0x7c, 0xf1, 0xa9, 0xad, 0xf2, + 0xa6, 0x1c, 0x51, 0x72, 0x2c, 0x53, 0x59, 0x5e, 0x5b, 0x2a, 0x6f, 0xac, 0x6f, 0x2c, 0xaf, 0x6d, + 0xc9, 0x51, 0xc4, 0x2a, 0x2b, 0xd5, 0x1b, 0x5b, 0x72, 0x4c, 0x49, 0xb2, 0x28, 0x8e, 0xc5, 0x15, + 0xc6, 0x12, 0x9b, 0x5b, 0x80, 0x2f, 0xc9, 0x09, 0xf4, 0xb2, 0xb5, 0xbc, 0x5a, 0x96, 0x93, 0x68, + 0xb9, 0x75, 0x7b, 0x7d, 0xa5, 0x2c, 0xa7, 0xf0, 0xe7, 0x8d, 0x8d, 0x8d, 0x1b, 0x4f, 0xc9, 0x69, + 0x24, 0xad, 0xde, 0x58, 0x97, 0x19, 0xc1, 0x37, 0x16, 0x01, 0xce, 0x80, 0x16, 0x4c, 0x55, 0x6e, + 0xaf, 0xdd, 0xdc, 0x5a, 0xae, 0xae, 0xc9, 0x59, 0xf5, 0x25, 0x89, 0xb1, 0x25, 0x63, 0xf3, 0xa0, + 0xd9, 0x25, 0x3d, 0x08, 0xde, 0xfb, 0xf0, 0xbb, 0x46, 0x69, 0x61, 0x69, 0xa4, 0x93, 0x2c, 0x4b, + 0x63, 0x7b, 0xbc, 0x20, 0x48, 0x1f, 0x25, 0xfd, 0xa3, 0x0b, 0x25, 0x52, 0x46, 0x09, 0x65, 0x92, + 0x65, 0x68, 0xb4, 0x4f, 0x1d, 0x84, 0x24, 0x51, 0x5a, 0x99, 0x65, 0x69, 0x1c, 0xe4, 0x27, 0x95, + 0x1b, 0xce, 0x0b, 0x7b, 0xf6, 0x02, 0xfe, 0xe0, 0x27, 0xb5, 0xc0, 0xd2, 0xce, 0x1f, 0xe8, 0x94, + 0xb8, 0xd6, 0xaa, 0x64, 0x7b, 0x55, 0x7c, 0xd0, 0x9a, 0x6a, 0x82, 0x22, 0x3d, 0xc5, 0xc6, 0xd6, + 0x8c, 0xce, 0x3a, 0xa5, 0x27, 0x6d, 0x28, 0xcd, 0xa4, 0x7a, 0x1e, 0x6f, 0xd9, 0xb8, 0x7a, 0x8e, + 0x31, 0x0f, 0x30, 0xc6, 0xa4, 0x6d, 0x0e, 0x60, 0xfe, 0xaa, 0xd3, 0x2c, 0xb1, 0x5a, 0xbf, 0xbb, + 0x55, 0x6f, 0x28, 0xa7, 0x19, 0x6b, 0xd5, 0xfb, 0x26, 0x6c, 0x0c, 0x0f, 0xf0, 0xbf, 0xf0, 0x4f, + 0xc2, 0xee, 0xa7, 0x7e, 0x9e, 0xb1, 0x6a, 0x6b, 0x77, 0x55, 0xef, 0xf7, 0xeb, 0x0d, 0x5d, 0xb9, + 0xc2, 0x12, 0x1d, 0x70, 0xa3, 0xa3, 0x74, 0x46, 0x49, 0x7a, 0xce, 0xdd, 0x90, 0x6b, 0x55, 0x58, + 0x23, 0x13, 0x25, 0xc3, 0xa2, 0xa0, 0xdf, 0x49, 0x3e, 0xc7, 0xa7, 0x4e, 0xb3, 0x84, 0x35, 0x0c, + 0xaa, 0xbc, 0x53, 0x6f, 0xeb, 0x79, 0xee, 0xbf, 0xc7, 0xd8, 0x9a, 0xfe, 0xec, 0x31, 0xfc, 0xbb, + 0x56, 0x23, 0xfc, 0x47, 0xa7, 0x2e, 0x8f, 0xf6, 0x8f, 0x47, 0x0b, 0xaf, 0x87, 0xdd, 0x1a, 0x3f, + 0x06, 0x92, 0xf2, 0xea, 0x4d, 0x96, 0x5d, 0xee, 0x74, 0xf4, 0x9e, 0x3d, 0x2b, 0x30, 0xf6, 0x8d, + 0xbe, 0x69, 0xbd, 0x1a, 0x14, 0x16, 0xeb, 0x1a, 0x3d, 0x93, 0xaf, 0x5b, 0x8b, 0xc1, 0x2d, 0x33, + 0xa3, 0x4c, 0xb0, 0xf4, 0x8e, 0x01, 0x94, 0x1d, 0x5c, 0x1a, 0x36, 0xe8, 0x94, 0x7a, 0xc0, 0xb2, + 0x55, 0x73, 0xdf, 0x75, 0x02, 0xab, 0x39, 0xd0, 0x0f, 0x69, 0xd6, 0x28, 0x3e, 0x16, 0xbe, 0x50, + 0x6f, 0x0d, 0xf8, 0xdb, 0x21, 0xab, 0x8c, 0xb3, 0xc4, 0xb3, 0x7a, 0xb3, 0xb1, 0x6f, 0x12, 0x37, + 0x02, 0xdd, 0x25, 0xde, 0xc4, 0x05, 0xc0, 0xa3, 0x01, 0x77, 0x79, 0xda, 0xdd, 0xa5, 0x77, 0x5d, + 0x97, 0x53, 0xa9, 0x5d, 0xf9, 0x4b, 0xf0, 0x2f, 0xa2, 0x7e, 0x23, 0xca, 0xd2, 0xab, 0x87, 0xf6, + 0x54, 0xe0, 0x7d, 0xc7, 0x18, 0x74, 0xf8, 0x82, 0xe3, 0xce, 0x86, 0x9d, 0x77, 0xca, 0x9d, 0x81, + 0x61, 0xea, 0x34, 0x55, 0x1a, 0x97, 0xd5, 0xd5, 0x4d, 0x98, 0x08, 0x45, 0x9c, 0x33, 0x6f, 0x5c, + 0x34, 0xaf, 0x72, 0x91, 0x25, 0x0c, 0xdc, 0x5a, 0x1f, 0x1e, 0x1e, 0x51, 0xbf, 0x9d, 0x6f, 0xcb, + 0x0f, 0xb1, 0x34, 0xb4, 0xb1, 0x1a, 0x77, 0x99, 0x0d, 0x9a, 0xfa, 0x5c, 0x5e, 0x61, 0xa9, 0xed, + 0xe6, 0x81, 0xde, 0xdf, 0x87, 0xf8, 0x25, 0x61, 0xf2, 0xf1, 0xe2, 0x59, 0xd7, 0xd2, 0xd9, 0x59, + 0xe1, 0xa6, 0xd1, 0x32, 0x7a, 0xca, 0x0c, 0x54, 0x8e, 0xd1, 0xd6, 0xf9, 0x91, 0xa5, 0xa8, 0xc7, + 0xdd, 0x3b, 0xca, 0x7a, 0x13, 0x8c, 0x78, 0xad, 0x4c, 0xf0, 0x95, 0x6c, 0xe3, 0x9d, 0x0c, 0xaf, + 0x1f, 0x54, 0xa5, 0x32, 0xce, 0xd8, 0xd8, 0xc3, 0x4b, 0x03, 0x2a, 0x1a, 0x2e, 0xfb, 0xa9, 0x69, + 0xa8, 0x2e, 0x87, 0xe1, 0x54, 0x17, 0x4f, 0xf8, 0x34, 0x1e, 0xb6, 0x0a, 0xf1, 0xe1, 0x2b, 0x80, + 0x0e, 0xb2, 0x51, 0xc6, 0x86, 0x05, 0x1d, 0x64, 0x69, 0xa3, 0x5c, 0x5e, 0x83, 0x8e, 0x85, 0xbd, + 0x6b, 0xe5, 0x76, 0x59, 0x8e, 0x78, 0xce, 0xe5, 0x2b, 0x12, 0x8b, 0x96, 0xef, 0x9a, 0x78, 0x04, + 0xb8, 0x36, 0x9e, 0x73, 0xc5, 0x19, 0x16, 0x6b, 0x1b, 0x3d, 0x5d, 0x99, 0x1c, 0xb1, 0x68, 0x78, + 0x59, 0x60, 0xe8, 0x3d, 0xef, 0x58, 0xe0, 0x17, 0xcf, 0xb3, 0x98, 0xa9, 0x83, 0x9f, 0x91, 0x8c, + 0x7d, 0x72, 0x7a, 0x01, 0x4a, 0x63, 0xd0, 0xde, 0xd6, 0x7b, 0xa3, 0x8d, 0x9a, 0xb4, 0x81, 0x4f, + 0x32, 0xf9, 0xa6, 0xd1, 0xee, 0xb6, 0xf4, 0xbb, 0xe0, 0x55, 0xef, 0xf4, 0xa1, 0x49, 0x63, 0x42, + 0xec, 0x35, 0x7b, 0x94, 0xde, 0x28, 0xa1, 0x21, 0x17, 0xfb, 0x3a, 0x24, 0xf3, 0x2e, 0x4f, 0x70, + 0x84, 0xcd, 0xfd, 0x66, 0x0f, 0xd3, 0x1a, 0xdb, 0xc5, 0x12, 0xcb, 0xdd, 0xe2, 0x5a, 0xa4, 0x6f, + 0xb9, 0x86, 0x47, 0x76, 0xd6, 0x1e, 0xa2, 0x07, 0x39, 0x04, 0xe2, 0xe9, 0xf2, 0x46, 0x15, 0xa2, + 0x03, 0x61, 0xaa, 0xae, 0x95, 0x21, 0x36, 0xf0, 0x63, 0xeb, 0xc9, 0xaa, 0x2f, 0x34, 0xf7, 0xb0, + 0xac, 0xb3, 0xba, 0x4d, 0xdd, 0x24, 0x04, 0xdb, 0x4a, 0x52, 0x8b, 0xa4, 0x24, 0x35, 0xc9, 0xe2, + 0xe5, 0x76, 0xd7, 0x3c, 0x54, 0x75, 0x96, 0xb1, 0x8c, 0x56, 0x9a, 0xd0, 0x9f, 0x0a, 0x2c, 0xd9, + 0xb6, 0x76, 0x24, 0xd1, 0x9d, 0xe8, 0x3d, 0x78, 0xd7, 0xce, 0xfe, 0x0d, 0x77, 0x51, 0xd2, 0x53, + 0xc5, 0x56, 0x19, 0x44, 0x78, 0x19, 0xf0, 0x1a, 0x89, 0x62, 0x8d, 0xa8, 0x25, 0x96, 0xe4, 0xf2, + 0xae, 0x4f, 0x2d, 0x9c, 0x2b, 0x3d, 0x7e, 0xf4, 0xbc, 0x4f, 0x40, 0x3e, 0x50, 0xf6, 0x58, 0x83, + 0x54, 0xb7, 0xea, 0x73, 0x31, 0x96, 0xb2, 0xb7, 0x0e, 0xbc, 0x04, 0x17, 0x63, 0xc4, 0xb0, 0x65, + 0xf4, 0x24, 0x4b, 0x5a, 0xf2, 0xcb, 0x6a, 0x18, 0x28, 0x9e, 0xed, 0x41, 0xb8, 0x20, 0xa2, 0x8e, + 0x64, 0x3e, 0xcd, 0xd2, 0x8e, 0xbc, 0xa2, 0xc2, 0xb7, 0x84, 0xb2, 0x3b, 0x0e, 0xe6, 0x71, 0x57, + 0x1e, 0x9f, 0x86, 0x1b, 0xcb, 0x12, 0x50, 0xf4, 0x01, 0xc0, 0x16, 0xc5, 0xce, 0x38, 0x98, 0x27, + 0x3d, 0x52, 0xf8, 0x0c, 0x4e, 0x4a, 0x22, 0x89, 0x6a, 0xc6, 0x15, 0xc0, 0x79, 0x24, 0x70, 0x61, + 0x44, 0x79, 0xee, 0xca, 0x5e, 0x15, 0x11, 0x1e, 0x17, 0xa8, 0x9a, 0xd1, 0x62, 0x37, 0x8f, 0x6e, + 0x49, 0xec, 0x52, 0x19, 0x79, 0x14, 0xee, 0x29, 0x62, 0xf3, 0x05, 0x66, 0x5d, 0x59, 0xeb, 0x0c, + 0xd3, 0xf5, 0xe8, 0x68, 0xd9, 0x47, 0x31, 0x7c, 0x98, 0x3f, 0x70, 0x3d, 0x62, 0xfd, 0xe7, 0xdd, + 0x83, 0xb5, 0x43, 0xcc, 0xcb, 0x5f, 0xe3, 0x15, 0x07, 0x41, 0x04, 0xc2, 0x7a, 0xb3, 0xb3, 0x07, + 0x97, 0x27, 0x6e, 0x27, 0x0a, 0x3f, 0xf9, 0x21, 0xac, 0xe1, 0xa0, 0x4c, 0x83, 0xb1, 0x47, 0x70, + 0x54, 0x01, 0xc1, 0x50, 0x5b, 0xab, 0x77, 0xe0, 0x3a, 0x24, 0xcb, 0x4e, 0xbd, 0x03, 0x7b, 0x8b, + 0xf6, 0x07, 0xdb, 0x79, 0x25, 0xf8, 0xe9, 0x64, 0x73, 0xb0, 0xed, 0x1c, 0xa9, 0xc2, 0x52, 0x90, + 0x0a, 0xb5, 0x2f, 0xea, 0x3d, 0x23, 0x3f, 0x49, 0xfb, 0x3f, 0x71, 0xcc, 0x1e, 0x00, 0xd7, 0x6a, + 0xc6, 0xeb, 0x29, 0xcb, 0xa4, 0x0e, 0xef, 0xfd, 0x9a, 0x74, 0x55, 0x5d, 0x65, 0x59, 0x5b, 0x49, + 0x51, 0xc5, 0x5c, 0xc1, 0x64, 0x04, 0x9f, 0x94, 0xd3, 0xe3, 0xc5, 0x7b, 0xdc, 0xd5, 0x78, 0xcd, + 0xf8, 0xf6, 0x55, 0x39, 0xb0, 0x00, 0x49, 0xfd, 0xa6, 0x04, 0xb5, 0x04, 0x0d, 0xc5, 0x36, 0xc6, + 0xe4, 0xde, 0x86, 0x44, 0xec, 0x93, 0x3f, 0x7c, 0x2f, 0x67, 0xe9, 0x4f, 0x5b, 0xa0, 0x46, 0x9c, + 0xc7, 0x01, 0xd4, 0x04, 0x1c, 0x44, 0x9f, 0xd7, 0x36, 0x64, 0x48, 0x06, 0xff, 0xb2, 0xcd, 0x62, + 0xce, 0xf3, 0xe0, 0x2c, 0x1b, 0xa3, 0xf3, 0x72, 0xa0, 0xa4, 0xf3, 0x28, 0xc8, 0xb1, 0x24, 0xaf, + 0x96, 0x3e, 0x7d, 0xb3, 0x4a, 0x63, 0xff, 0x20, 0xf1, 0xc3, 0x2f, 0x87, 0xa4, 0xfa, 0xff, 0x2c, + 0x45, 0x1d, 0x15, 0xee, 0x7f, 0xe5, 0x7e, 0x26, 0x35, 0xf2, 0x3a, 0x35, 0xec, 0x93, 0x1e, 0xa9, + 0x63, 0xc1, 0x85, 0xa5, 0xa9, 0x71, 0x26, 0x2d, 0xa1, 0x38, 0xb9, 0xcb, 0x8b, 0x45, 0xad, 0x58, + 0x64, 0xb8, 0xdc, 0x45, 0x64, 0x80, 0x81, 0x7c, 0xd6, 0x4f, 0xc6, 0x9f, 0x87, 0xfc, 0x6b, 0x1c, + 0x0a, 0x20, 0xca, 0x7c, 0x58, 0xe7, 0xba, 0x01, 0x5b, 0x41, 0x6c, 0x8f, 0xae, 0x47, 0x49, 0xfd, + 0x20, 0xca, 0xc6, 0xad, 0x1e, 0xf1, 0x64, 0xd3, 0xdc, 0x5f, 0xad, 0x77, 0x95, 0xc7, 0x58, 0x16, + 0x5b, 0x45, 0xad, 0x5d, 0xef, 0x76, 0x31, 0xf7, 0x25, 0xba, 0xbb, 0x1e, 0x1a, 0x6a, 0x35, 0x96, + 0x7d, 0x61, 0x0d, 0x8c, 0x57, 0xb9, 0x6d, 0xb9, 0x63, 0xf6, 0x0e, 0x95, 0x4f, 0xb0, 0x4c, 0xbb, + 0xdf, 0x70, 0xf8, 0x11, 0xe2, 0x5f, 0x0a, 0xe5, 0xaf, 0xf6, 0x1b, 0x3e, 0x3a, 0xcc, 0x8f, 0xcd, + 0xc6, 0xe1, 0x47, 0x8f, 0x98, 0x1f, 0xcb, 0xcf, 0xe7, 0x40, 0x03, 0xc1, 0x0a, 0x89, 0x6b, 0x1a, + 0xa8, 0x03, 0xe9, 0x20, 0x33, 0xc5, 0x8b, 0xa1, 0x74, 0xa8, 0xf0, 0x2d, 0x03, 0xfe, 0x43, 0xdc, + 0xa9, 0x22, 0x93, 0x87, 0xf6, 0xe3, 0x11, 0x2f, 0x71, 0xbf, 0x78, 0x49, 0x6b, 0x91, 0x6b, 0xd2, + 0xd4, 0xa7, 0x58, 0x2e, 0xb8, 0x07, 0x0f, 0x45, 0x01, 0xc5, 0xe0, 0xa1, 0x64, 0x8a, 0x67, 0x3c, + 0x5f, 0x69, 0xbd, 0xc7, 0x42, 0xbe, 0x60, 0xfe, 0xa1, 0xfd, 0x78, 0x9c, 0xa5, 0x02, 0xe2, 0x89, + 0x38, 0x8f, 0xb2, 0x31, 0xdf, 0x26, 0xbc, 0x84, 0xf4, 0x88, 0x05, 0xab, 0xef, 0x47, 0x59, 0xbc, + 0xda, 0xd1, 0x8d, 0x3d, 0xd0, 0x01, 0xbe, 0xb6, 0xfd, 0xf8, 0x09, 0x10, 0x0b, 0xfe, 0x96, 0xed, + 0x19, 0xb2, 0x1b, 0x36, 0x0c, 0x4d, 0x0e, 0xb5, 0x6b, 0xdf, 0xa0, 0xdd, 0xab, 0x61, 0x50, 0x09, + 0x36, 0x6a, 0xef, 0x98, 0xdd, 0xa4, 0xed, 0x49, 0x3c, 0x0d, 0xda, 0x36, 0xf3, 0xb6, 0x66, 0x7b, + 0xcc, 0xdb, 0x94, 0x6d, 0xaa, 0xa7, 0x09, 0x3b, 0x66, 0x9e, 0xee, 0xeb, 0x1d, 0xb3, 0x5b, 0x2f, + 0x8c, 0x5d, 0x09, 0xf4, 0xdd, 0x70, 0xdd, 0x05, 0xc6, 0x97, 0x71, 0x7f, 0xb6, 0xa4, 0xc8, 0x09, + 0xbe, 0x3a, 0x93, 0x6d, 0x72, 0xcf, 0x92, 0xd5, 0x32, 0x55, 0xad, 0xe7, 0xd4, 0x29, 0xf4, 0x85, + 0x4a, 0x8d, 0xaa, 0x17, 0x6c, 0xcf, 0x41, 0x7d, 0xd6, 0x56, 0xea, 0xbd, 0x06, 0x18, 0xd4, 0xe0, + 0xb9, 0xe1, 0x3c, 0x30, 0x30, 0xf8, 0x39, 0xfb, 0xf8, 0x76, 0x69, 0x40, 0x9a, 0x3a, 0x89, 0xbb, + 0xe5, 0x32, 0x8d, 0xca, 0x1d, 0xbb, 0x7a, 0x7c, 0x11, 0x24, 0xc3, 0xa0, 0x03, 0x82, 0x66, 0x31, + 0xcd, 0x92, 0xa6, 0xd1, 0x6b, 0xd7, 0x4d, 0x43, 0xfd, 0x2e, 0xbc, 0xe3, 0x40, 0xf0, 0xb4, 0x01, + 0xb8, 0x43, 0x97, 0x71, 0xa6, 0x5d, 0x3f, 0x80, 0xba, 0xd2, 0x6b, 0x3b, 0x3d, 0x3b, 0x9d, 0x64, + 0x5b, 0x38, 0xd1, 0x81, 0xe1, 0x84, 0xe3, 0x96, 0x52, 0x48, 0x58, 0xd1, 0x1d, 0xb7, 0xd4, 0x5b, + 0xd2, 0x0a, 0x2d, 0x30, 0x4c, 0xbd, 0xdd, 0xad, 0xed, 0xd0, 0x39, 0xe1, 0x99, 0x5c, 0x62, 0x51, + 0x68, 0xe0, 0x74, 0x44, 0x47, 0x44, 0x70, 0x9a, 0x45, 0xa1, 0x33, 0xd0, 0xc1, 0x65, 0x8a, 0x13, + 0x9e, 0x6b, 0x87, 0x37, 0xd1, 0xc7, 0x4f, 0x38, 0xfb, 0xb8, 0x9c, 0x63, 0xd1, 0x4a, 0xb5, 0x8a, + 0x77, 0x0a, 0xfc, 0x6f, 0x56, 0x96, 0xb4, 0x07, 0x59, 0xaa, 0xd1, 0xd3, 0x75, 0x2c, 0x97, 0xd1, + 0x22, 0xef, 0x19, 0xec, 0xc0, 0xda, 0x2d, 0x96, 0xdc, 0xe1, 0x22, 0x4f, 0x09, 0x51, 0xe6, 0xf9, + 0xef, 0xf1, 0xe7, 0xd3, 0x94, 0x0b, 0x07, 0x65, 0xa1, 0x56, 0x01, 0xc9, 0x5c, 0x3b, 0xca, 0xcf, + 0xf3, 0xbc, 0x33, 0x8a, 0xfc, 0x94, 0xd8, 0x44, 0xc7, 0xb0, 0xbf, 0x5f, 0xd5, 0x76, 0x29, 0x97, + 0x95, 0xb3, 0xc3, 0x97, 0xbb, 0xed, 0x52, 0x27, 0x05, 0x32, 0xc7, 0x64, 0x0f, 0x8b, 0x54, 0xba, + 0x88, 0xb4, 0x47, 0xf7, 0xba, 0x9f, 0x44, 0xa9, 0x2f, 0x22, 0x35, 0x48, 0x8f, 0x0d, 0x91, 0x40, + 0x8b, 0x08, 0x48, 0xfb, 0x74, 0x87, 0xfb, 0x37, 0x35, 0x38, 0x72, 0xaa, 0x26, 0xe9, 0xb3, 0x61, + 0x96, 0x78, 0xae, 0x67, 0x48, 0xbd, 0xf9, 0x59, 0xfd, 0x23, 0xe7, 0x3a, 0x20, 0xa9, 0x35, 0xcc, + 0x12, 0xcf, 0xd5, 0x22, 0x25, 0x36, 0xcf, 0x14, 0x6f, 0xd8, 0x79, 0x77, 0x13, 0xd1, 0xda, 0xa4, + 0x53, 0x47, 0xd0, 0xc4, 0xb3, 0x75, 0x48, 0xc6, 0x2e, 0xb0, 0x49, 0xef, 0x1a, 0x8f, 0x31, 0x9d, + 0x01, 0xbc, 0xdc, 0x48, 0x9e, 0x78, 0xbe, 0x2e, 0xf0, 0x64, 0xad, 0xc8, 0x72, 0x1e, 0x1e, 0x4a, + 0x22, 0x11, 0xe7, 0x0e, 0xa9, 0xf8, 0x40, 0x1c, 0xa9, 0x4a, 0x45, 0xac, 0x1e, 0x5d, 0x31, 0xfe, + 0xa4, 0xa2, 0x87, 0x83, 0x88, 0xd4, 0xa7, 0x8b, 0xec, 0x69, 0xdf, 0xf2, 0x74, 0x14, 0x86, 0x02, + 0x8e, 0x49, 0xbd, 0xe6, 0x62, 0xa8, 0x41, 0xc1, 0xfb, 0x26, 0xd3, 0x34, 0x36, 0x7e, 0xfc, 0x12, + 0x7c, 0x5e, 0xe2, 0xaf, 0x80, 0xb9, 0x02, 0x3e, 0x10, 0xb4, 0xab, 0x6c, 0xec, 0xd8, 0x85, 0xf8, + 0x82, 0xc4, 0x65, 0x37, 0x52, 0x21, 0x2d, 0xc6, 0x8e, 0x5d, 0x8c, 0x2f, 0x4a, 0xfc, 0x75, 0x54, + 0x2a, 0x06, 0x68, 0xe2, 0x83, 0x7d, 0x89, 0x6b, 0xea, 0x48, 0x69, 0x0e, 0xb2, 0x62, 0xfc, 0xf8, + 0x05, 0xf9, 0xb2, 0x44, 0x15, 0x19, 0x29, 0x95, 0x82, 0x3c, 0xf1, 0x7c, 0xaf, 0x48, 0x54, 0x93, + 0x91, 0xd2, 0xbc, 0x97, 0x77, 0x74, 0x51, 0xbe, 0x2a, 0x51, 0x55, 0x46, 0x4a, 0x0b, 0x41, 0x9e, + 0x78, 0xbe, 0xd7, 0x48, 0x3f, 0x01, 0xef, 0x2a, 0x1c, 0x43, 0xee, 0x63, 0x14, 0xe6, 0xeb, 0x12, + 0x55, 0x66, 0xa4, 0x74, 0x6d, 0x88, 0x28, 0x9e, 0xf1, 0x0d, 0x89, 0x6a, 0x33, 0x52, 0xba, 0xae, + 0x5d, 0x63, 0xf2, 0xc7, 0x29, 0xce, 0x37, 0x25, 0xaa, 0xce, 0xc8, 0xfc, 0xcc, 0x30, 0x53, 0x3c, + 0xe7, 0x5b, 0x12, 0xd5, 0x67, 0x64, 0x7e, 0x16, 0xa2, 0x93, 0x3d, 0x6e, 0x81, 0xbe, 0xed, 0x79, + 0x67, 0x6b, 0x37, 0x3c, 0x51, 0x3d, 0xb2, 0x48, 0xdf, 0x21, 0x5d, 0xa8, 0x8d, 0x3d, 0xce, 0x1f, + 0xb3, 0x9c, 0xa0, 0x3d, 0xe6, 0xe6, 0xdd, 0x91, 0x15, 0xfb, 0xae, 0x44, 0x25, 0x9b, 0xb5, 0x3c, + 0x90, 0xbd, 0xf6, 0x39, 0x77, 0xed, 0x47, 0x55, 0xef, 0x7b, 0xd2, 0xc7, 0x2a, 0x5f, 0xfc, 0x8c, + 0x02, 0xa1, 0x89, 0xdd, 0x2d, 0xce, 0xcc, 0x7a, 0x2f, 0x63, 0xef, 0x17, 0x14, 0x5e, 0xb6, 0x99, + 0x62, 0xce, 0xf3, 0xe9, 0x08, 0x3f, 0xa1, 0x58, 0xbc, 0x62, 0x28, 0xef, 0x05, 0x21, 0x6f, 0x2e, + 0x94, 0xf7, 0xa2, 0x90, 0x57, 0x0a, 0xe5, 0xbd, 0x24, 0xe4, 0xcd, 0x87, 0xf2, 0x5e, 0x16, 0xf2, + 0x16, 0x42, 0x79, 0xaf, 0x08, 0x79, 0x57, 0x43, 0x79, 0xaf, 0x0a, 0x79, 0xd7, 0x42, 0x79, 0xaf, + 0x09, 0x79, 0xd7, 0x43, 0x79, 0xaf, 0x8b, 0x78, 0xb3, 0x33, 0xa1, 0xbc, 0x37, 0x84, 0xbc, 0xf0, + 0x7c, 0x79, 0x53, 0xc8, 0x0b, 0xcf, 0x97, 0xb7, 0x84, 0xbc, 0xf0, 0x7c, 0x79, 0x5b, 0xc8, 0x0b, + 0xcf, 0x97, 0x77, 0x84, 0xbc, 0xf0, 0x7c, 0x79, 0x57, 0xc8, 0x0b, 0xcf, 0x97, 0xf7, 0x84, 0xbc, + 0xf0, 0x7c, 0xf9, 0xbe, 0x90, 0x17, 0x9e, 0x2f, 0x3f, 0x10, 0xf2, 0xc2, 0xf3, 0xe5, 0x87, 0x22, + 0x5e, 0x31, 0x3c, 0x5f, 0x7e, 0x24, 0xe4, 0x85, 0xe7, 0xcb, 0x8f, 0x85, 0xbc, 0xf0, 0x7c, 0xf9, + 0x89, 0x90, 0x17, 0x9e, 0x2f, 0x3f, 0x15, 0xf2, 0xc2, 0xf3, 0xe5, 0x67, 0x42, 0x5e, 0x78, 0xbe, + 0xfc, 0x5c, 0xc8, 0x0b, 0xcf, 0x97, 0x5f, 0x08, 0x79, 0xe1, 0xf9, 0xf2, 0x4b, 0x21, 0x2f, 0x3c, + 0x5f, 0xde, 0x17, 0xf2, 0xc2, 0xf3, 0xe5, 0x57, 0x22, 0xde, 0x5c, 0x78, 0xbe, 0xfc, 0x5a, 0xc8, + 0x0b, 0xcf, 0x97, 0xdf, 0x08, 0x79, 0xe1, 0xf9, 0xf2, 0x5b, 0x21, 0x2f, 0x3c, 0x5f, 0x7e, 0x27, + 0xe4, 0x85, 0xe7, 0xcb, 0xef, 0x85, 0xbc, 0xf0, 0x7c, 0xf9, 0x83, 0x90, 0x17, 0x9e, 0x2f, 0x7f, + 0x14, 0xf2, 0xc2, 0xf3, 0xe5, 0x4f, 0x42, 0x5e, 0x78, 0xbe, 0xfc, 0x59, 0xc8, 0x0b, 0xcf, 0x97, + 0xbf, 0x88, 0x78, 0xa5, 0xf0, 0x7c, 0xf9, 0xab, 0x90, 0x17, 0x9e, 0x2f, 0x7f, 0x13, 0xf2, 0xc2, + 0xf3, 0xe5, 0x03, 0x21, 0x2f, 0x3c, 0x5f, 0xfe, 0x2e, 0xe4, 0x85, 0xe7, 0xcb, 0x3f, 0x84, 0xbc, + 0xf0, 0x7c, 0xf9, 0xa7, 0x90, 0x17, 0x9e, 0x2f, 0x1f, 0x0a, 0x79, 0xe1, 0xf9, 0xf2, 0x91, 0x90, + 0x17, 0x9e, 0x2f, 0xff, 0x12, 0xf2, 0xc2, 0xf3, 0xe5, 0xdf, 0x22, 0xde, 0x7c, 0x78, 0xbe, 0xfc, + 0x67, 0x34, 0xef, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x8e, 0xa4, 0xcf, 0x8d, 0xf9, 0x2b, 0x00, + 0x00, } diff --git a/vendor/github.com/golang/protobuf/proto/testdata/test.proto b/vendor/github.com/golang/protobuf/proto/testdata/test.proto index 70e3cfcda..698c8ce24 100644 --- a/vendor/github.com/golang/protobuf/proto/testdata/test.proto +++ b/vendor/github.com/golang/protobuf/proto/testdata/test.proto @@ -169,13 +169,6 @@ message GoTest { }; } -// For testing a group containing a required field. -message GoTestRequiredGroupField { - required group Group = 1 { - required int32 Field = 2; - }; -} - // For testing skipping of unrecognized fields. // Numbers are all big, larger than tag numbers in GoTestField, // the message used in the corresponding test. @@ -244,10 +237,6 @@ message OtherMessage { extensions 100 to max; } -message RequiredInnerMessage { - required InnerMessage leo_finally_won_an_oscar = 1; -} - message MyMessage { required int32 count = 1; optional string name = 2; @@ -255,7 +244,6 @@ message MyMessage { repeated string pet = 4; optional InnerMessage inner = 5; repeated OtherMessage others = 6; - optional RequiredInnerMessage we_must_go_deeper = 13; repeated InnerMessage rep_inner = 12; enum Color { @@ -495,7 +483,6 @@ message GroupNew { message FloatingPoint { required double f = 1; - optional bool exact = 2; } message MessageWithMap { diff --git a/vendor/github.com/golang/protobuf/proto/text.go b/vendor/github.com/golang/protobuf/proto/text.go index 965876bf0..2336b144c 100644 --- a/vendor/github.com/golang/protobuf/proto/text.go +++ b/vendor/github.com/golang/protobuf/proto/text.go @@ -154,7 +154,7 @@ func (w *textWriter) indent() { w.ind++ } func (w *textWriter) unindent() { if w.ind == 0 { - log.Print("proto: textWriter unindented too far") + log.Printf("proto: textWriter unindented too far") return } w.ind-- @@ -175,93 +175,7 @@ type raw interface { Bytes() []byte } -func requiresQuotes(u string) bool { - // When type URL contains any characters except [0-9A-Za-z./\-]*, it must be quoted. - for _, ch := range u { - switch { - case ch == '.' || ch == '/' || ch == '_': - continue - case '0' <= ch && ch <= '9': - continue - case 'A' <= ch && ch <= 'Z': - continue - case 'a' <= ch && ch <= 'z': - continue - default: - return true - } - } - return false -} - -// isAny reports whether sv is a google.protobuf.Any message -func isAny(sv reflect.Value) bool { - type wkt interface { - XXX_WellKnownType() string - } - t, ok := sv.Addr().Interface().(wkt) - return ok && t.XXX_WellKnownType() == "Any" -} - -// writeProto3Any writes an expanded google.protobuf.Any message. -// -// It returns (false, nil) if sv value can't be unmarshaled (e.g. because -// required messages are not linked in). -// -// It returns (true, error) when sv was written in expanded format or an error -// was encountered. -func (tm *TextMarshaler) writeProto3Any(w *textWriter, sv reflect.Value) (bool, error) { - turl := sv.FieldByName("TypeUrl") - val := sv.FieldByName("Value") - if !turl.IsValid() || !val.IsValid() { - return true, errors.New("proto: invalid google.protobuf.Any message") - } - - b, ok := val.Interface().([]byte) - if !ok { - return true, errors.New("proto: invalid google.protobuf.Any message") - } - - parts := strings.Split(turl.String(), "/") - mt := MessageType(parts[len(parts)-1]) - if mt == nil { - return false, nil - } - m := reflect.New(mt.Elem()) - if err := Unmarshal(b, m.Interface().(Message)); err != nil { - return false, nil - } - w.Write([]byte("[")) - u := turl.String() - if requiresQuotes(u) { - writeString(w, u) - } else { - w.Write([]byte(u)) - } - if w.compact { - w.Write([]byte("]:<")) - } else { - w.Write([]byte("]: <\n")) - w.ind++ - } - if err := tm.writeStruct(w, m.Elem()); err != nil { - return true, err - } - if w.compact { - w.Write([]byte("> ")) - } else { - w.ind-- - w.Write([]byte(">\n")) - } - return true, nil -} - -func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { - if tm.ExpandAny && isAny(sv) { - if canExpand, err := tm.writeProto3Any(w, sv); canExpand { - return err - } - } +func writeStruct(w *textWriter, sv reflect.Value) error { st := sv.Type() sprops := GetProperties(st) for i := 0; i < sv.NumField(); i++ { @@ -313,7 +227,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { } continue } - if err := tm.writeAny(w, v, props); err != nil { + if err := writeAny(w, v, props); err != nil { return err } if err := w.WriteByte('\n'); err != nil { @@ -355,7 +269,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { return err } } - if err := tm.writeAny(w, key, props.mkeyprop); err != nil { + if err := writeAny(w, key, props.mkeyprop); err != nil { return err } if err := w.WriteByte('\n'); err != nil { @@ -372,7 +286,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { return err } } - if err := tm.writeAny(w, val, props.mvalprop); err != nil { + if err := writeAny(w, val, props.mvalprop); err != nil { return err } if err := w.WriteByte('\n'); err != nil { @@ -444,7 +358,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { } // Enums have a String method, so writeAny will work fine. - if err := tm.writeAny(w, fv, props); err != nil { + if err := writeAny(w, fv, props); err != nil { return err } @@ -455,8 +369,8 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { // Extensions (the XXX_extensions field). pv := sv.Addr() - if _, ok := extendable(pv.Interface()); ok { - if err := tm.writeExtensions(w, pv); err != nil { + if pv.Type().Implements(extendableProtoType) { + if err := writeExtensions(w, pv); err != nil { return err } } @@ -486,7 +400,7 @@ func writeRaw(w *textWriter, b []byte) error { } // writeAny writes an arbitrary field. -func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error { +func writeAny(w *textWriter, v reflect.Value, props *Properties) error { v = reflect.Indirect(v) // Floats have special cases. @@ -513,7 +427,7 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert switch v.Kind() { case reflect.Slice: // Should only be a []byte; repeated fields are handled in writeStruct. - if err := writeString(w, string(v.Bytes())); err != nil { + if err := writeString(w, string(v.Interface().([]byte))); err != nil { return err } case reflect.String: @@ -535,15 +449,15 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert } } w.indent() - if etm, ok := v.Interface().(encoding.TextMarshaler); ok { - text, err := etm.MarshalText() + if tm, ok := v.Interface().(encoding.TextMarshaler); ok { + text, err := tm.MarshalText() if err != nil { return err } if _, err = w.Write(text); err != nil { return err } - } else if err := tm.writeStruct(w, v); err != nil { + } else if err := writeStruct(w, v); err != nil { return err } w.unindent() @@ -687,24 +601,19 @@ func (s int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } // writeExtensions writes all the extensions in pv. // pv is assumed to be a pointer to a protocol message struct that is extendable. -func (tm *TextMarshaler) writeExtensions(w *textWriter, pv reflect.Value) error { +func writeExtensions(w *textWriter, pv reflect.Value) error { emap := extensionMaps[pv.Type().Elem()] - ep, _ := extendable(pv.Interface()) + ep := pv.Interface().(extendableProto) // Order the extensions by ID. // This isn't strictly necessary, but it will give us // canonical output, which will also make testing easier. - m, mu := ep.extensionsRead() - if m == nil { - return nil - } - mu.Lock() + m := ep.ExtensionMap() ids := make([]int32, 0, len(m)) for id := range m { ids = append(ids, id) } sort.Sort(int32Slice(ids)) - mu.Unlock() for _, extNum := range ids { ext := m[extNum] @@ -727,13 +636,13 @@ func (tm *TextMarshaler) writeExtensions(w *textWriter, pv reflect.Value) error // Repeated extensions will appear as a slice. if !desc.repeated() { - if err := tm.writeExtension(w, desc.Name, pb); err != nil { + if err := writeExtension(w, desc.Name, pb); err != nil { return err } } else { v := reflect.ValueOf(pb) for i := 0; i < v.Len(); i++ { - if err := tm.writeExtension(w, desc.Name, v.Index(i).Interface()); err != nil { + if err := writeExtension(w, desc.Name, v.Index(i).Interface()); err != nil { return err } } @@ -742,7 +651,7 @@ func (tm *TextMarshaler) writeExtensions(w *textWriter, pv reflect.Value) error return nil } -func (tm *TextMarshaler) writeExtension(w *textWriter, name string, pb interface{}) error { +func writeExtension(w *textWriter, name string, pb interface{}) error { if _, err := fmt.Fprintf(w, "[%s]:", name); err != nil { return err } @@ -751,7 +660,7 @@ func (tm *TextMarshaler) writeExtension(w *textWriter, name string, pb interface return err } } - if err := tm.writeAny(w, reflect.ValueOf(pb), nil); err != nil { + if err := writeAny(w, reflect.ValueOf(pb), nil); err != nil { return err } if err := w.WriteByte('\n'); err != nil { @@ -776,15 +685,7 @@ func (w *textWriter) writeIndent() { w.complete = false } -// TextMarshaler is a configurable text format marshaler. -type TextMarshaler struct { - Compact bool // use compact text format (one line). - ExpandAny bool // expand google.protobuf.Any messages of known types -} - -// Marshal writes a given protocol buffer in text format. -// The only errors returned are from w. -func (tm *TextMarshaler) Marshal(w io.Writer, pb Message) error { +func marshalText(w io.Writer, pb Message, compact bool) error { val := reflect.ValueOf(pb) if pb == nil || val.IsNil() { w.Write([]byte("")) @@ -799,11 +700,11 @@ func (tm *TextMarshaler) Marshal(w io.Writer, pb Message) error { aw := &textWriter{ w: ww, complete: true, - compact: tm.Compact, + compact: compact, } - if etm, ok := pb.(encoding.TextMarshaler); ok { - text, err := etm.MarshalText() + if tm, ok := pb.(encoding.TextMarshaler); ok { + text, err := tm.MarshalText() if err != nil { return err } @@ -817,7 +718,7 @@ func (tm *TextMarshaler) Marshal(w io.Writer, pb Message) error { } // Dereference the received pointer so we don't have outer < and >. v := reflect.Indirect(val) - if err := tm.writeStruct(aw, v); err != nil { + if err := writeStruct(aw, v); err != nil { return err } if bw != nil { @@ -826,29 +727,25 @@ func (tm *TextMarshaler) Marshal(w io.Writer, pb Message) error { return nil } -// Text is the same as Marshal, but returns the string directly. -func (tm *TextMarshaler) Text(pb Message) string { - var buf bytes.Buffer - tm.Marshal(&buf, pb) - return buf.String() -} - -var ( - defaultTextMarshaler = TextMarshaler{} - compactTextMarshaler = TextMarshaler{Compact: true} -) - -// TODO: consider removing some of the Marshal functions below. - // MarshalText writes a given protocol buffer in text format. // The only errors returned are from w. -func MarshalText(w io.Writer, pb Message) error { return defaultTextMarshaler.Marshal(w, pb) } +func MarshalText(w io.Writer, pb Message) error { + return marshalText(w, pb, false) +} // MarshalTextString is the same as MarshalText, but returns the string directly. -func MarshalTextString(pb Message) string { return defaultTextMarshaler.Text(pb) } +func MarshalTextString(pb Message) string { + var buf bytes.Buffer + marshalText(&buf, pb, false) + return buf.String() +} // CompactText writes a given protocol buffer in compact text format (one line). -func CompactText(w io.Writer, pb Message) error { return compactTextMarshaler.Marshal(w, pb) } +func CompactText(w io.Writer, pb Message) error { return marshalText(w, pb, true) } // CompactTextString is the same as CompactText, but returns the string directly. -func CompactTextString(pb Message) string { return compactTextMarshaler.Text(pb) } +func CompactTextString(pb Message) string { + var buf bytes.Buffer + marshalText(&buf, pb, true) + return buf.String() +} diff --git a/vendor/github.com/golang/protobuf/proto/text_parser.go b/vendor/github.com/golang/protobuf/proto/text_parser.go index 61f83c1e1..6d0cf2589 100644 --- a/vendor/github.com/golang/protobuf/proto/text_parser.go +++ b/vendor/github.com/golang/protobuf/proto/text_parser.go @@ -44,9 +44,6 @@ import ( "unicode/utf8" ) -// Error string emitted when deserializing Any and fields are already set -const anyRepeatedlyUnpacked = "Any message unpacked multiple times, or %q already set" - type ParseError struct { Message string Line int // 1-based line number @@ -122,14 +119,6 @@ func isWhitespace(c byte) bool { return false } -func isQuote(c byte) bool { - switch c { - case '"', '\'': - return true - } - return false -} - func (p *textParser) skipWhitespace() { i := 0 for i < len(p.s) && (isWhitespace(p.s[i]) || p.s[i] == '#') { @@ -166,7 +155,7 @@ func (p *textParser) advance() { p.cur.offset, p.cur.line = p.offset, p.line p.cur.unquoted = "" switch p.s[0] { - case '<', '>', '{', '}', ':', '[', ']', ';', ',', '/': + case '<', '>', '{', '}', ':', '[', ']', ';', ',': // Single symbol p.cur.value, p.s = p.s[0:1], p.s[1:len(p.s)] case '"', '\'': @@ -344,13 +333,13 @@ func (p *textParser) next() *token { p.advance() if p.done { p.cur.value = "" - } else if len(p.cur.value) > 0 && isQuote(p.cur.value[0]) { + } else if len(p.cur.value) > 0 && p.cur.value[0] == '"' { // Look for multiple quoted strings separated by whitespace, // and concatenate them. cat := p.cur for { p.skipWhitespace() - if p.done || !isQuote(p.s[0]) { + if p.done || p.s[0] != '"' { break } p.advance() @@ -454,10 +443,7 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { fieldSet := make(map[string]bool) // A struct is a sequence of "name: value", terminated by one of // '>' or '}', or the end of the input. A name may also be - // "[extension]" or "[type/url]". - // - // The whole struct can also be an expanded Any message, like: - // [type/url] < ... struct contents ... > + // "[extension]". for { tok := p.next() if tok.err != nil { @@ -467,74 +453,33 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { break } if tok.value == "[" { - // Looks like an extension or an Any. + // Looks like an extension. // // TODO: Check whether we need to handle // namespace rooted names (e.g. ".something.Foo"). - extName, err := p.consumeExtName() - if err != nil { - return err + tok = p.next() + if tok.err != nil { + return tok.err } - - if s := strings.LastIndex(extName, "/"); s >= 0 { - // If it contains a slash, it's an Any type URL. - messageName := extName[s+1:] - mt := MessageType(messageName) - if mt == nil { - return p.errorf("unrecognized message %q in google.protobuf.Any", messageName) - } - tok = p.next() - if tok.err != nil { - return tok.err - } - // consume an optional colon - if tok.value == ":" { - tok = p.next() - if tok.err != nil { - return tok.err - } - } - var terminator string - switch tok.value { - case "<": - terminator = ">" - case "{": - terminator = "}" - default: - return p.errorf("expected '{' or '<', found %q", tok.value) - } - v := reflect.New(mt.Elem()) - if pe := p.readStruct(v.Elem(), terminator); pe != nil { - return pe - } - b, err := Marshal(v.Interface().(Message)) - if err != nil { - return p.errorf("failed to marshal message of type %q: %v", messageName, err) - } - if fieldSet["type_url"] { - return p.errorf(anyRepeatedlyUnpacked, "type_url") - } - if fieldSet["value"] { - return p.errorf(anyRepeatedlyUnpacked, "value") - } - sv.FieldByName("TypeUrl").SetString(extName) - sv.FieldByName("Value").SetBytes(b) - fieldSet["type_url"] = true - fieldSet["value"] = true - continue - } - var desc *ExtensionDesc // This could be faster, but it's functional. // TODO: Do something smarter than a linear scan. for _, d := range RegisteredExtensions(reflect.New(st).Interface().(Message)) { - if d.Name == extName { + if d.Name == tok.value { desc = d break } } if desc == nil { - return p.errorf("unrecognized extension %q", extName) + return p.errorf("unrecognized extension %q", tok.value) + } + // Check the extension terminator. + tok = p.next() + if tok.err != nil { + return tok.err + } + if tok.value != "]" { + return p.errorf("unrecognized extension terminator %q", tok.value) } props := &Properties{} @@ -561,7 +506,7 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { } reqFieldErr = err } - ep := sv.Addr().Interface().(Message) + ep := sv.Addr().Interface().(extendableProto) if !rep { SetExtension(ep, desc, ext.Interface()) } else { @@ -592,11 +537,7 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { props = oop.Prop nv := reflect.New(oop.Type.Elem()) dst = nv.Elem().Field(0) - field := sv.Field(oop.Field) - if !field.IsNil() { - return p.errorf("field '%s' would overwrite already parsed oneof '%s'", name, sv.Type().Field(oop.Field).Name) - } - field.Set(nv) + sv.Field(oop.Field).Set(nv) } if !dst.IsValid() { return p.errorf("unknown field name %q in %v", name, st) @@ -617,9 +558,8 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { // The map entry should be this sequence of tokens: // < key : KEY value : VALUE > - // However, implementations may omit key or value, and technically - // we should support them in any order. See b/28924776 for a time - // this went wrong. + // Technically the "key" and "value" could come in any order, + // but in practice they won't. tok := p.next() var terminator string @@ -631,39 +571,32 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { default: return p.errorf("expected '{' or '<', found %q", tok.value) } - for { - tok := p.next() - if tok.err != nil { - return tok.err - } - if tok.value == terminator { - break - } - switch tok.value { - case "key": - if err := p.consumeToken(":"); err != nil { - return err - } - if err := p.readAny(key, props.mkeyprop); err != nil { - return err - } - if err := p.consumeOptionalSeparator(); err != nil { - return err - } - case "value": - if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil { - return err - } - if err := p.readAny(val, props.mvalprop); err != nil { - return err - } - if err := p.consumeOptionalSeparator(); err != nil { - return err - } - default: - p.back() - return p.errorf(`expected "key", "value", or %q, found %q`, terminator, tok.value) - } + if err := p.consumeToken("key"); err != nil { + return err + } + if err := p.consumeToken(":"); err != nil { + return err + } + if err := p.readAny(key, props.mkeyprop); err != nil { + return err + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + if err := p.consumeToken("value"); err != nil { + return err + } + if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil { + return err + } + if err := p.readAny(val, props.mvalprop); err != nil { + return err + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + if err := p.consumeToken(terminator); err != nil { + return err } dst.SetMapIndex(key, val) @@ -686,8 +619,7 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { return err } reqFieldErr = err - } - if props.Required { + } else if props.Required { reqCount-- } @@ -703,35 +635,6 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { return reqFieldErr } -// consumeExtName consumes extension name or expanded Any type URL and the -// following ']'. It returns the name or URL consumed. -func (p *textParser) consumeExtName() (string, error) { - tok := p.next() - if tok.err != nil { - return "", tok.err - } - - // If extension name or type url is quoted, it's a single token. - if len(tok.value) > 2 && isQuote(tok.value[0]) && tok.value[len(tok.value)-1] == tok.value[0] { - name, err := unquoteC(tok.value[1:len(tok.value)-1], rune(tok.value[0])) - if err != nil { - return "", err - } - return name, p.consumeToken("]") - } - - // Consume everything up to "]" - var parts []string - for tok.value != "]" { - parts = append(parts, tok.value) - tok = p.next() - if tok.err != nil { - return "", p.errorf("unrecognized type_url or extension name: %s", tok.err) - } - } - return strings.Join(parts, ""), nil -} - // consumeOptionalSeparator consumes an optional semicolon or comma. // It is used in readStruct to provide backward compatibility. func (p *textParser) consumeOptionalSeparator() error { @@ -796,12 +699,12 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error { fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) return p.readAny(fv.Index(fv.Len()-1), props) case reflect.Bool: - // true/1/t/True or false/f/0/False. + // Either "true", "false", 1 or 0. switch tok.value { - case "true", "1", "t", "True": + case "true", "1": fv.SetBool(true) return nil - case "false", "0", "f", "False": + case "false", "0": fv.SetBool(false) return nil } diff --git a/vendor/github.com/golang/protobuf/proto/text_parser_test.go b/vendor/github.com/golang/protobuf/proto/text_parser_test.go index 8f7cb4d27..d02c61d1f 100644 --- a/vendor/github.com/golang/protobuf/proto/text_parser_test.go +++ b/vendor/github.com/golang/protobuf/proto/text_parser_test.go @@ -95,7 +95,7 @@ var unMarshalTextTests = []UnmarshalTextTest{ }, }, - // Quoted string concatenation with double quotes + // Quoted string concatenation { in: `count:42 name: "My name is "` + "\n" + `"elsewhere"`, out: &MyMessage{ @@ -104,31 +104,6 @@ var unMarshalTextTests = []UnmarshalTextTest{ }, }, - // Quoted string concatenation with single quotes - { - in: "count:42 name: 'My name is '\n'elsewhere'", - out: &MyMessage{ - Count: Int32(42), - Name: String("My name is elsewhere"), - }, - }, - - // Quoted string concatenations with mixed quotes - { - in: "count:42 name: 'My name is '\n\"elsewhere\"", - out: &MyMessage{ - Count: Int32(42), - Name: String("My name is elsewhere"), - }, - }, - { - in: "count:42 name: \"My name is \"\n'elsewhere'", - out: &MyMessage{ - Count: Int32(42), - Name: String("My name is elsewhere"), - }, - }, - // Quoted string with escaped apostrophe { in: `count:42 name: "HOLIDAY - New Year\'s Day"`, @@ -336,16 +311,6 @@ var unMarshalTextTests = []UnmarshalTextTest{ }, }, - // Missing required field in a required submessage - { - in: `count: 42 we_must_go_deeper < leo_finally_won_an_oscar <> >`, - err: `proto: required field "testdata.InnerMessage.host" not set`, - out: &MyMessage{ - Count: Int32(42), - WeMustGoDeeper: &RequiredInnerMessage{LeoFinallyWonAnOscar: &InnerMessage{}}, - }, - }, - // Repeated non-repeated field { in: `name: "Rob" name: "Russ"`, @@ -380,95 +345,6 @@ var unMarshalTextTests = []UnmarshalTextTest{ }, }, - // Boolean false - { - in: `count:42 inner { host: "example.com" connected: false }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(false), - }, - }, - }, - // Boolean true - { - in: `count:42 inner { host: "example.com" connected: true }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(true), - }, - }, - }, - // Boolean 0 - { - in: `count:42 inner { host: "example.com" connected: 0 }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(false), - }, - }, - }, - // Boolean 1 - { - in: `count:42 inner { host: "example.com" connected: 1 }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(true), - }, - }, - }, - // Boolean f - { - in: `count:42 inner { host: "example.com" connected: f }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(false), - }, - }, - }, - // Boolean t - { - in: `count:42 inner { host: "example.com" connected: t }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(true), - }, - }, - }, - // Boolean False - { - in: `count:42 inner { host: "example.com" connected: False }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(false), - }, - }, - }, - // Boolean True - { - in: `count:42 inner { host: "example.com" connected: True }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(true), - }, - }, - }, - // Extension buildExtStructTest(`count: 42 [testdata.Ext.more]:`), buildExtStructTest(`count: 42 [testdata.Ext.more] {data:"Hello, world!"}`), @@ -597,10 +473,7 @@ func TestMapParsing(t *testing.T) { const in = `name_mapping: name_mapping:` + `msg_mapping:,>` + // separating commas are okay `msg_mapping>` + // no colon after "value" - `msg_mapping:>` + // omitted key - `msg_mapping:` + // omitted value - `byte_mapping:` + - `byte_mapping:<>` // omitted key and value + `byte_mapping:` want := &MessageWithMap{ NameMapping: map[int32]string{ 1: "Beatles", @@ -609,12 +482,9 @@ func TestMapParsing(t *testing.T) { MsgMapping: map[int64]*FloatingPoint{ -4: {F: Float64(2.0)}, -2: {F: Float64(4.0)}, - 0: {F: Float64(5.0)}, - 1: nil, }, ByteMapping: map[bool][]byte{ - false: nil, - true: []byte("so be it"), + true: []byte("so be it"), }, } if err := UnmarshalText(in, m); err != nil { @@ -635,17 +505,6 @@ func TestOneofParsing(t *testing.T) { if !Equal(m, want) { t.Errorf("\n got %v\nwant %v", m, want) } - - const inOverwrite = `name:"Shrek" number:42` - m = new(Communique) - testErr := "line 1.13: field 'number' would overwrite already parsed oneof 'Union'" - if err := UnmarshalText(inOverwrite, m); err == nil { - t.Errorf("TestOneofParsing: Didn't get expected error: %v", testErr) - } else if err.Error() != testErr { - t.Errorf("TestOneofParsing: Incorrect error.\nHave: %v\nWant: %v", - err.Error(), testErr) - } - } var benchInput string diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go b/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go index a1d8a764f..6a3be28eb 100644 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go @@ -3,7 +3,7 @@ // DO NOT EDIT! /* -Package descriptor is a generated protocol buffer package. +Package google_protobuf is a generated protocol buffer package. It is generated from these files: google/protobuf/descriptor.proto @@ -21,14 +21,12 @@ It has these top-level messages: FileOptions MessageOptions FieldOptions - OneofOptions EnumOptions EnumValueOptions ServiceOptions MethodOptions UninterpretedOption SourceCodeInfo - GeneratedCodeInfo */ package descriptor @@ -43,9 +41,7 @@ var _ = math.Inf // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion1 type FieldDescriptorProto_Type int32 @@ -253,46 +249,6 @@ func (x *FieldOptions_CType) UnmarshalJSON(data []byte) error { } func (FieldOptions_CType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{11, 0} } -type FieldOptions_JSType int32 - -const ( - // Use the default type. - FieldOptions_JS_NORMAL FieldOptions_JSType = 0 - // Use JavaScript strings. - FieldOptions_JS_STRING FieldOptions_JSType = 1 - // Use JavaScript numbers. - FieldOptions_JS_NUMBER FieldOptions_JSType = 2 -) - -var FieldOptions_JSType_name = map[int32]string{ - 0: "JS_NORMAL", - 1: "JS_STRING", - 2: "JS_NUMBER", -} -var FieldOptions_JSType_value = map[string]int32{ - "JS_NORMAL": 0, - "JS_STRING": 1, - "JS_NUMBER": 2, -} - -func (x FieldOptions_JSType) Enum() *FieldOptions_JSType { - p := new(FieldOptions_JSType) - *p = x - return p -} -func (x FieldOptions_JSType) String() string { - return proto.EnumName(FieldOptions_JSType_name, int32(x)) -} -func (x *FieldOptions_JSType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(FieldOptions_JSType_value, data, "FieldOptions_JSType") - if err != nil { - return err - } - *x = FieldOptions_JSType(value) - return nil -} -func (FieldOptions_JSType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{11, 1} } - // The protocol compiler can output a FileDescriptorSet containing the .proto // files it parses. type FileDescriptorSet struct { @@ -319,13 +275,13 @@ type FileDescriptorProto struct { // Names of files imported by this file. Dependency []string `protobuf:"bytes,3,rep,name=dependency" json:"dependency,omitempty"` // Indexes of the public imported files in the dependency list above. - PublicDependency []int32 `protobuf:"varint,10,rep,name=public_dependency,json=publicDependency" json:"public_dependency,omitempty"` + PublicDependency []int32 `protobuf:"varint,10,rep,name=public_dependency" json:"public_dependency,omitempty"` // Indexes of the weak imported files in the dependency list. // For Google-internal migration only. Do not use. - WeakDependency []int32 `protobuf:"varint,11,rep,name=weak_dependency,json=weakDependency" json:"weak_dependency,omitempty"` + WeakDependency []int32 `protobuf:"varint,11,rep,name=weak_dependency" json:"weak_dependency,omitempty"` // All top-level definitions in this file. - MessageType []*DescriptorProto `protobuf:"bytes,4,rep,name=message_type,json=messageType" json:"message_type,omitempty"` - EnumType []*EnumDescriptorProto `protobuf:"bytes,5,rep,name=enum_type,json=enumType" json:"enum_type,omitempty"` + MessageType []*DescriptorProto `protobuf:"bytes,4,rep,name=message_type" json:"message_type,omitempty"` + EnumType []*EnumDescriptorProto `protobuf:"bytes,5,rep,name=enum_type" json:"enum_type,omitempty"` Service []*ServiceDescriptorProto `protobuf:"bytes,6,rep,name=service" json:"service,omitempty"` Extension []*FieldDescriptorProto `protobuf:"bytes,7,rep,name=extension" json:"extension,omitempty"` Options *FileOptions `protobuf:"bytes,8,opt,name=options" json:"options,omitempty"` @@ -333,7 +289,7 @@ type FileDescriptorProto struct { // You may safely remove this entire field without harming runtime // functionality of the descriptors -- the information is needed only by // development tools. - SourceCodeInfo *SourceCodeInfo `protobuf:"bytes,9,opt,name=source_code_info,json=sourceCodeInfo" json:"source_code_info,omitempty"` + SourceCodeInfo *SourceCodeInfo `protobuf:"bytes,9,opt,name=source_code_info" json:"source_code_info,omitempty"` // The syntax of the proto file. // The supported values are "proto2" and "proto3". Syntax *string `protobuf:"bytes,12,opt,name=syntax" json:"syntax,omitempty"` @@ -431,19 +387,15 @@ func (m *FileDescriptorProto) GetSyntax() string { // Describes a message type. type DescriptorProto struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Field []*FieldDescriptorProto `protobuf:"bytes,2,rep,name=field" json:"field,omitempty"` - Extension []*FieldDescriptorProto `protobuf:"bytes,6,rep,name=extension" json:"extension,omitempty"` - NestedType []*DescriptorProto `protobuf:"bytes,3,rep,name=nested_type,json=nestedType" json:"nested_type,omitempty"` - EnumType []*EnumDescriptorProto `protobuf:"bytes,4,rep,name=enum_type,json=enumType" json:"enum_type,omitempty"` - ExtensionRange []*DescriptorProto_ExtensionRange `protobuf:"bytes,5,rep,name=extension_range,json=extensionRange" json:"extension_range,omitempty"` - OneofDecl []*OneofDescriptorProto `protobuf:"bytes,8,rep,name=oneof_decl,json=oneofDecl" json:"oneof_decl,omitempty"` - Options *MessageOptions `protobuf:"bytes,7,opt,name=options" json:"options,omitempty"` - ReservedRange []*DescriptorProto_ReservedRange `protobuf:"bytes,9,rep,name=reserved_range,json=reservedRange" json:"reserved_range,omitempty"` - // Reserved field names, which may not be used by fields in the same message. - // A given name may only be reserved once. - ReservedName []string `protobuf:"bytes,10,rep,name=reserved_name,json=reservedName" json:"reserved_name,omitempty"` - XXX_unrecognized []byte `json:"-"` + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Field []*FieldDescriptorProto `protobuf:"bytes,2,rep,name=field" json:"field,omitempty"` + Extension []*FieldDescriptorProto `protobuf:"bytes,6,rep,name=extension" json:"extension,omitempty"` + NestedType []*DescriptorProto `protobuf:"bytes,3,rep,name=nested_type" json:"nested_type,omitempty"` + EnumType []*EnumDescriptorProto `protobuf:"bytes,4,rep,name=enum_type" json:"enum_type,omitempty"` + ExtensionRange []*DescriptorProto_ExtensionRange `protobuf:"bytes,5,rep,name=extension_range" json:"extension_range,omitempty"` + OneofDecl []*OneofDescriptorProto `protobuf:"bytes,8,rep,name=oneof_decl" json:"oneof_decl,omitempty"` + Options *MessageOptions `protobuf:"bytes,7,opt,name=options" json:"options,omitempty"` + XXX_unrecognized []byte `json:"-"` } func (m *DescriptorProto) Reset() { *m = DescriptorProto{} } @@ -507,20 +459,6 @@ func (m *DescriptorProto) GetOptions() *MessageOptions { return nil } -func (m *DescriptorProto) GetReservedRange() []*DescriptorProto_ReservedRange { - if m != nil { - return m.ReservedRange - } - return nil -} - -func (m *DescriptorProto) GetReservedName() []string { - if m != nil { - return m.ReservedName - } - return nil -} - type DescriptorProto_ExtensionRange struct { Start *int32 `protobuf:"varint,1,opt,name=start" json:"start,omitempty"` End *int32 `protobuf:"varint,2,opt,name=end" json:"end,omitempty"` @@ -548,36 +486,6 @@ func (m *DescriptorProto_ExtensionRange) GetEnd() int32 { return 0 } -// Range of reserved tag numbers. Reserved tag numbers may not be used by -// fields or extension ranges in the same message. Reserved ranges may -// not overlap. -type DescriptorProto_ReservedRange struct { - Start *int32 `protobuf:"varint,1,opt,name=start" json:"start,omitempty"` - End *int32 `protobuf:"varint,2,opt,name=end" json:"end,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *DescriptorProto_ReservedRange) Reset() { *m = DescriptorProto_ReservedRange{} } -func (m *DescriptorProto_ReservedRange) String() string { return proto.CompactTextString(m) } -func (*DescriptorProto_ReservedRange) ProtoMessage() {} -func (*DescriptorProto_ReservedRange) Descriptor() ([]byte, []int) { - return fileDescriptor0, []int{2, 1} -} - -func (m *DescriptorProto_ReservedRange) GetStart() int32 { - if m != nil && m.Start != nil { - return *m.Start - } - return 0 -} - -func (m *DescriptorProto_ReservedRange) GetEnd() int32 { - if m != nil && m.End != nil { - return *m.End - } - return 0 -} - // Describes a field within a message. type FieldDescriptorProto struct { Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` @@ -591,7 +499,7 @@ type FieldDescriptorProto struct { // rules are used to find the type (i.e. first the nested types within this // message are searched, then within the parent, on up to the root // namespace). - TypeName *string `protobuf:"bytes,6,opt,name=type_name,json=typeName" json:"type_name,omitempty"` + TypeName *string `protobuf:"bytes,6,opt,name=type_name" json:"type_name,omitempty"` // For extensions, this is the name of the type being extended. It is // resolved in the same manner as type_name. Extendee *string `protobuf:"bytes,2,opt,name=extendee" json:"extendee,omitempty"` @@ -600,15 +508,17 @@ type FieldDescriptorProto struct { // For strings, contains the default text contents (not escaped in any way). // For bytes, contains the C escaped value. All bytes >= 128 are escaped. // TODO(kenton): Base-64 encode? - DefaultValue *string `protobuf:"bytes,7,opt,name=default_value,json=defaultValue" json:"default_value,omitempty"` + DefaultValue *string `protobuf:"bytes,7,opt,name=default_value" json:"default_value,omitempty"` // If set, gives the index of a oneof in the containing type's oneof_decl - // list. This field is a member of that oneof. - OneofIndex *int32 `protobuf:"varint,9,opt,name=oneof_index,json=oneofIndex" json:"oneof_index,omitempty"` + // list. This field is a member of that oneof. Extensions of a oneof should + // not set this since the oneof to which they belong will be inferred based + // on the extension range containing the extension's field number. + OneofIndex *int32 `protobuf:"varint,9,opt,name=oneof_index" json:"oneof_index,omitempty"` // JSON name of this field. The value is set by protocol compiler. If the // user has set a "json_name" option on this field, that option's value // will be used. Otherwise, it's deduced from the field's name by converting // it to camelCase. - JsonName *string `protobuf:"bytes,10,opt,name=json_name,json=jsonName" json:"json_name,omitempty"` + JsonName *string `protobuf:"bytes,10,opt,name=json_name" json:"json_name,omitempty"` Options *FieldOptions `protobuf:"bytes,8,opt,name=options" json:"options,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -690,9 +600,8 @@ func (m *FieldDescriptorProto) GetOptions() *FieldOptions { // Describes a oneof. type OneofDescriptorProto struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Options *OneofOptions `protobuf:"bytes,2,opt,name=options" json:"options,omitempty"` - XXX_unrecognized []byte `json:"-"` + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + XXX_unrecognized []byte `json:"-"` } func (m *OneofDescriptorProto) Reset() { *m = OneofDescriptorProto{} } @@ -707,13 +616,6 @@ func (m *OneofDescriptorProto) GetName() string { return "" } -func (m *OneofDescriptorProto) GetOptions() *OneofOptions { - if m != nil { - return m.Options - } - return nil -} - // Describes an enum type. type EnumDescriptorProto struct { Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` @@ -821,13 +723,13 @@ type MethodDescriptorProto struct { Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` // Input and output type names. These are resolved in the same way as // FieldDescriptorProto.type_name, but must refer to a message type. - InputType *string `protobuf:"bytes,2,opt,name=input_type,json=inputType" json:"input_type,omitempty"` - OutputType *string `protobuf:"bytes,3,opt,name=output_type,json=outputType" json:"output_type,omitempty"` + InputType *string `protobuf:"bytes,2,opt,name=input_type" json:"input_type,omitempty"` + OutputType *string `protobuf:"bytes,3,opt,name=output_type" json:"output_type,omitempty"` Options *MethodOptions `protobuf:"bytes,4,opt,name=options" json:"options,omitempty"` // Identifies if client streams multiple client messages - ClientStreaming *bool `protobuf:"varint,5,opt,name=client_streaming,json=clientStreaming,def=0" json:"client_streaming,omitempty"` + ClientStreaming *bool `protobuf:"varint,5,opt,name=client_streaming,def=0" json:"client_streaming,omitempty"` // Identifies if server streams multiple server messages - ServerStreaming *bool `protobuf:"varint,6,opt,name=server_streaming,json=serverStreaming,def=0" json:"server_streaming,omitempty"` + ServerStreaming *bool `protobuf:"varint,6,opt,name=server_streaming,def=0" json:"server_streaming,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -886,36 +788,45 @@ type FileOptions struct { // placed. By default, the proto package is used, but this is often // inappropriate because proto packages do not normally start with backwards // domain names. - JavaPackage *string `protobuf:"bytes,1,opt,name=java_package,json=javaPackage" json:"java_package,omitempty"` + JavaPackage *string `protobuf:"bytes,1,opt,name=java_package" json:"java_package,omitempty"` // If set, all the classes from the .proto file are wrapped in a single // outer class with the given name. This applies to both Proto1 // (equivalent to the old "--one_java_file" option) and Proto2 (where // a .proto always translates to a single class, but you may want to // explicitly choose the class name). - JavaOuterClassname *string `protobuf:"bytes,8,opt,name=java_outer_classname,json=javaOuterClassname" json:"java_outer_classname,omitempty"` + JavaOuterClassname *string `protobuf:"bytes,8,opt,name=java_outer_classname" json:"java_outer_classname,omitempty"` // If set true, then the Java code generator will generate a separate .java // file for each top-level message, enum, and service defined in the .proto // file. Thus, these types will *not* be nested inside the outer class // named by java_outer_classname. However, the outer class will still be // generated to contain the file's getDescriptor() method as well as any // top-level extensions defined in the file. - JavaMultipleFiles *bool `protobuf:"varint,10,opt,name=java_multiple_files,json=javaMultipleFiles,def=0" json:"java_multiple_files,omitempty"` - // This option does nothing. - JavaGenerateEqualsAndHash *bool `protobuf:"varint,20,opt,name=java_generate_equals_and_hash,json=javaGenerateEqualsAndHash" json:"java_generate_equals_and_hash,omitempty"` + JavaMultipleFiles *bool `protobuf:"varint,10,opt,name=java_multiple_files,def=0" json:"java_multiple_files,omitempty"` + // If set true, then the Java code generator will generate equals() and + // hashCode() methods for all messages defined in the .proto file. + // - In the full runtime, this is purely a speed optimization, as the + // AbstractMessage base class includes reflection-based implementations of + // these methods. + // - In the lite runtime, setting this option changes the semantics of + // equals() and hashCode() to more closely match those of the full runtime; + // the generated methods compute their results based on field values rather + // than object identity. (Implementations should not assume that hashcodes + // will be consistent across runtimes or versions of the protocol compiler.) + JavaGenerateEqualsAndHash *bool `protobuf:"varint,20,opt,name=java_generate_equals_and_hash,def=0" json:"java_generate_equals_and_hash,omitempty"` // If set true, then the Java2 code generator will generate code that // throws an exception whenever an attempt is made to assign a non-UTF-8 // byte sequence to a string field. // Message reflection will do the same. // However, an extension field still accepts non-UTF-8 byte sequences. // This option has no effect on when used with the lite runtime. - JavaStringCheckUtf8 *bool `protobuf:"varint,27,opt,name=java_string_check_utf8,json=javaStringCheckUtf8,def=0" json:"java_string_check_utf8,omitempty"` - OptimizeFor *FileOptions_OptimizeMode `protobuf:"varint,9,opt,name=optimize_for,json=optimizeFor,enum=google.protobuf.FileOptions_OptimizeMode,def=1" json:"optimize_for,omitempty"` + JavaStringCheckUtf8 *bool `protobuf:"varint,27,opt,name=java_string_check_utf8,def=0" json:"java_string_check_utf8,omitempty"` + OptimizeFor *FileOptions_OptimizeMode `protobuf:"varint,9,opt,name=optimize_for,enum=google.protobuf.FileOptions_OptimizeMode,def=1" json:"optimize_for,omitempty"` // Sets the Go package where structs generated from this .proto will be // placed. If omitted, the Go package will be derived from the following: // - The basename of the package import path, if provided. // - Otherwise, the package statement in the .proto file, if present. // - Otherwise, the basename of the .proto file, without extension. - GoPackage *string `protobuf:"bytes,11,opt,name=go_package,json=goPackage" json:"go_package,omitempty"` + GoPackage *string `protobuf:"bytes,11,opt,name=go_package" json:"go_package,omitempty"` // Should generic services be generated in each language? "Generic" services // are not specific to any particular RPC system. They are generated by the // main code generators in each language (without additional plugins). @@ -926,9 +837,9 @@ type FileOptions struct { // that generate code specific to your particular RPC system. Therefore, // these default to false. Old code which depends on generic services should // explicitly set them to true. - CcGenericServices *bool `protobuf:"varint,16,opt,name=cc_generic_services,json=ccGenericServices,def=0" json:"cc_generic_services,omitempty"` - JavaGenericServices *bool `protobuf:"varint,17,opt,name=java_generic_services,json=javaGenericServices,def=0" json:"java_generic_services,omitempty"` - PyGenericServices *bool `protobuf:"varint,18,opt,name=py_generic_services,json=pyGenericServices,def=0" json:"py_generic_services,omitempty"` + CcGenericServices *bool `protobuf:"varint,16,opt,name=cc_generic_services,def=0" json:"cc_generic_services,omitempty"` + JavaGenericServices *bool `protobuf:"varint,17,opt,name=java_generic_services,def=0" json:"java_generic_services,omitempty"` + PyGenericServices *bool `protobuf:"varint,18,opt,name=py_generic_services,def=0" json:"py_generic_services,omitempty"` // Is this file deprecated? // Depending on the target platform, this can emit Deprecated annotations // for everything in the file, or it will be completely ignored; in the very @@ -936,16 +847,11 @@ type FileOptions struct { Deprecated *bool `protobuf:"varint,23,opt,name=deprecated,def=0" json:"deprecated,omitempty"` // Enables the use of arenas for the proto messages in this file. This applies // only to generated classes for C++. - CcEnableArenas *bool `protobuf:"varint,31,opt,name=cc_enable_arenas,json=ccEnableArenas,def=0" json:"cc_enable_arenas,omitempty"` - // Sets the objective c class prefix which is prepended to all objective c - // generated classes from this .proto. There is no default. - ObjcClassPrefix *string `protobuf:"bytes,36,opt,name=objc_class_prefix,json=objcClassPrefix" json:"objc_class_prefix,omitempty"` - // Namespace for generated classes; defaults to the package. - CsharpNamespace *string `protobuf:"bytes,37,opt,name=csharp_namespace,json=csharpNamespace" json:"csharp_namespace,omitempty"` + CcEnableArenas *bool `protobuf:"varint,31,opt,name=cc_enable_arenas,def=0" json:"cc_enable_arenas,omitempty"` // The parser stores options it doesn't recognize here. See above. - UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *FileOptions) Reset() { *m = FileOptions{} } @@ -960,8 +866,15 @@ var extRange_FileOptions = []proto.ExtensionRange{ func (*FileOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_FileOptions } +func (m *FileOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} const Default_FileOptions_JavaMultipleFiles bool = false +const Default_FileOptions_JavaGenerateEqualsAndHash bool = false const Default_FileOptions_JavaStringCheckUtf8 bool = false const Default_FileOptions_OptimizeFor FileOptions_OptimizeMode = FileOptions_SPEED const Default_FileOptions_CcGenericServices bool = false @@ -995,7 +908,7 @@ func (m *FileOptions) GetJavaGenerateEqualsAndHash() bool { if m != nil && m.JavaGenerateEqualsAndHash != nil { return *m.JavaGenerateEqualsAndHash } - return false + return Default_FileOptions_JavaGenerateEqualsAndHash } func (m *FileOptions) GetJavaStringCheckUtf8() bool { @@ -1054,20 +967,6 @@ func (m *FileOptions) GetCcEnableArenas() bool { return Default_FileOptions_CcEnableArenas } -func (m *FileOptions) GetObjcClassPrefix() string { - if m != nil && m.ObjcClassPrefix != nil { - return *m.ObjcClassPrefix - } - return "" -} - -func (m *FileOptions) GetCsharpNamespace() string { - if m != nil && m.CsharpNamespace != nil { - return *m.CsharpNamespace - } - return "" -} - func (m *FileOptions) GetUninterpretedOption() []*UninterpretedOption { if m != nil { return m.UninterpretedOption @@ -1094,11 +993,11 @@ type MessageOptions struct { // // Because this is an option, the above two restrictions are not enforced by // the protocol compiler. - MessageSetWireFormat *bool `protobuf:"varint,1,opt,name=message_set_wire_format,json=messageSetWireFormat,def=0" json:"message_set_wire_format,omitempty"` + MessageSetWireFormat *bool `protobuf:"varint,1,opt,name=message_set_wire_format,def=0" json:"message_set_wire_format,omitempty"` // Disables the generation of the standard "descriptor()" accessor, which can // conflict with a field of the same name. This is meant to make migration // from proto1 easier; new code should avoid fields named "descriptor". - NoStandardDescriptorAccessor *bool `protobuf:"varint,2,opt,name=no_standard_descriptor_accessor,json=noStandardDescriptorAccessor,def=0" json:"no_standard_descriptor_accessor,omitempty"` + NoStandardDescriptorAccessor *bool `protobuf:"varint,2,opt,name=no_standard_descriptor_accessor,def=0" json:"no_standard_descriptor_accessor,omitempty"` // Is this message deprecated? // Depending on the target platform, this can emit Deprecated annotations // for the message, or it will be completely ignored; in the very least, @@ -1125,11 +1024,11 @@ type MessageOptions struct { // NOTE: Do not set the option in .proto files. Always use the maps syntax // instead. The option should only be implicitly set by the proto compiler // parser. - MapEntry *bool `protobuf:"varint,7,opt,name=map_entry,json=mapEntry" json:"map_entry,omitempty"` + MapEntry *bool `protobuf:"varint,7,opt,name=map_entry" json:"map_entry,omitempty"` // The parser stores options it doesn't recognize here. See above. - UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *MessageOptions) Reset() { *m = MessageOptions{} } @@ -1144,6 +1043,12 @@ var extRange_MessageOptions = []proto.ExtensionRange{ func (*MessageOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_MessageOptions } +func (m *MessageOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} const Default_MessageOptions_MessageSetWireFormat bool = false const Default_MessageOptions_NoStandardDescriptorAccessor bool = false @@ -1193,19 +1098,8 @@ type FieldOptions struct { // The packed option can be enabled for repeated primitive fields to enable // a more efficient representation on the wire. Rather than repeatedly // writing the tag and type for each element, the entire array is encoded as - // a single length-delimited blob. In proto3, only explicit setting it to - // false will avoid using packed encoding. + // a single length-delimited blob. Packed *bool `protobuf:"varint,2,opt,name=packed" json:"packed,omitempty"` - // The jstype option determines the JavaScript type used for values of the - // field. The option is permitted only for 64 bit integral and fixed types - // (int64, uint64, sint64, fixed64, sfixed64). By default these types are - // represented as JavaScript strings. This avoids loss of precision that can - // happen when a large value is converted to a floating point JavaScript - // numbers. Specifying JS_NUMBER for the jstype causes the generated - // JavaScript code to use the JavaScript "number" type instead of strings. - // This option is an enum to permit additional types to be added, - // e.g. goog.math.Integer. - Jstype *FieldOptions_JSType `protobuf:"varint,6,opt,name=jstype,enum=google.protobuf.FieldOptions_JSType,def=0" json:"jstype,omitempty"` // Should this field be parsed lazily? Lazy applies only to message-type // fields. It means that when the outer message is initially parsed, the // inner message's contents will not be parsed but instead stored in encoded @@ -1225,7 +1119,7 @@ type FieldOptions struct { // // // Note that implementations may choose not to check required fields within - // a lazy sub-message. That is, calling IsInitialized() on the outer message + // a lazy sub-message. That is, calling IsInitialized() on the outher message // may return true even if the inner message has missing required fields. // This is necessary because otherwise the inner message would have to be // parsed in order to perform the check, defeating the purpose of lazy @@ -1243,9 +1137,9 @@ type FieldOptions struct { // For Google-internal migration only. Do not use. Weak *bool `protobuf:"varint,10,opt,name=weak,def=0" json:"weak,omitempty"` // The parser stores options it doesn't recognize here. See above. - UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *FieldOptions) Reset() { *m = FieldOptions{} } @@ -1260,9 +1154,14 @@ var extRange_FieldOptions = []proto.ExtensionRange{ func (*FieldOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_FieldOptions } +func (m *FieldOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} const Default_FieldOptions_Ctype FieldOptions_CType = FieldOptions_STRING -const Default_FieldOptions_Jstype FieldOptions_JSType = FieldOptions_JS_NORMAL const Default_FieldOptions_Lazy bool = false const Default_FieldOptions_Deprecated bool = false const Default_FieldOptions_Weak bool = false @@ -1281,13 +1180,6 @@ func (m *FieldOptions) GetPacked() bool { return false } -func (m *FieldOptions) GetJstype() FieldOptions_JSType { - if m != nil && m.Jstype != nil { - return *m.Jstype - } - return Default_FieldOptions_Jstype -} - func (m *FieldOptions) GetLazy() bool { if m != nil && m.Lazy != nil { return *m.Lazy @@ -1316,52 +1208,25 @@ func (m *FieldOptions) GetUninterpretedOption() []*UninterpretedOption { return nil } -type OneofOptions struct { - // The parser stores options it doesn't recognize here. See above. - UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *OneofOptions) Reset() { *m = OneofOptions{} } -func (m *OneofOptions) String() string { return proto.CompactTextString(m) } -func (*OneofOptions) ProtoMessage() {} -func (*OneofOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } - -var extRange_OneofOptions = []proto.ExtensionRange{ - {1000, 536870911}, -} - -func (*OneofOptions) ExtensionRangeArray() []proto.ExtensionRange { - return extRange_OneofOptions -} - -func (m *OneofOptions) GetUninterpretedOption() []*UninterpretedOption { - if m != nil { - return m.UninterpretedOption - } - return nil -} - type EnumOptions struct { // Set this option to true to allow mapping different tag names to the same // value. - AllowAlias *bool `protobuf:"varint,2,opt,name=allow_alias,json=allowAlias" json:"allow_alias,omitempty"` + AllowAlias *bool `protobuf:"varint,2,opt,name=allow_alias" json:"allow_alias,omitempty"` // Is this enum deprecated? // Depending on the target platform, this can emit Deprecated annotations // for the enum, or it will be completely ignored; in the very least, this // is a formalization for deprecating enums. Deprecated *bool `protobuf:"varint,3,opt,name=deprecated,def=0" json:"deprecated,omitempty"` // The parser stores options it doesn't recognize here. See above. - UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *EnumOptions) Reset() { *m = EnumOptions{} } func (m *EnumOptions) String() string { return proto.CompactTextString(m) } func (*EnumOptions) ProtoMessage() {} -func (*EnumOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } +func (*EnumOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } var extRange_EnumOptions = []proto.ExtensionRange{ {1000, 536870911}, @@ -1370,6 +1235,12 @@ var extRange_EnumOptions = []proto.ExtensionRange{ func (*EnumOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_EnumOptions } +func (m *EnumOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} const Default_EnumOptions_Deprecated bool = false @@ -1401,15 +1272,15 @@ type EnumValueOptions struct { // this is a formalization for deprecating enum values. Deprecated *bool `protobuf:"varint,1,opt,name=deprecated,def=0" json:"deprecated,omitempty"` // The parser stores options it doesn't recognize here. See above. - UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *EnumValueOptions) Reset() { *m = EnumValueOptions{} } func (m *EnumValueOptions) String() string { return proto.CompactTextString(m) } func (*EnumValueOptions) ProtoMessage() {} -func (*EnumValueOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} } +func (*EnumValueOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } var extRange_EnumValueOptions = []proto.ExtensionRange{ {1000, 536870911}, @@ -1418,6 +1289,12 @@ var extRange_EnumValueOptions = []proto.ExtensionRange{ func (*EnumValueOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_EnumValueOptions } +func (m *EnumValueOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} const Default_EnumValueOptions_Deprecated bool = false @@ -1442,15 +1319,15 @@ type ServiceOptions struct { // this is a formalization for deprecating services. Deprecated *bool `protobuf:"varint,33,opt,name=deprecated,def=0" json:"deprecated,omitempty"` // The parser stores options it doesn't recognize here. See above. - UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *ServiceOptions) Reset() { *m = ServiceOptions{} } func (m *ServiceOptions) String() string { return proto.CompactTextString(m) } func (*ServiceOptions) ProtoMessage() {} -func (*ServiceOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} } +func (*ServiceOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} } var extRange_ServiceOptions = []proto.ExtensionRange{ {1000, 536870911}, @@ -1459,6 +1336,12 @@ var extRange_ServiceOptions = []proto.ExtensionRange{ func (*ServiceOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_ServiceOptions } +func (m *ServiceOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} const Default_ServiceOptions_Deprecated bool = false @@ -1483,15 +1366,15 @@ type MethodOptions struct { // this is a formalization for deprecating methods. Deprecated *bool `protobuf:"varint,33,opt,name=deprecated,def=0" json:"deprecated,omitempty"` // The parser stores options it doesn't recognize here. See above. - UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *MethodOptions) Reset() { *m = MethodOptions{} } func (m *MethodOptions) String() string { return proto.CompactTextString(m) } func (*MethodOptions) ProtoMessage() {} -func (*MethodOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} } +func (*MethodOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} } var extRange_MethodOptions = []proto.ExtensionRange{ {1000, 536870911}, @@ -1500,6 +1383,12 @@ var extRange_MethodOptions = []proto.ExtensionRange{ func (*MethodOptions) ExtensionRangeArray() []proto.ExtensionRange { return extRange_MethodOptions } +func (m *MethodOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} const Default_MethodOptions_Deprecated bool = false @@ -1527,19 +1416,19 @@ type UninterpretedOption struct { Name []*UninterpretedOption_NamePart `protobuf:"bytes,2,rep,name=name" json:"name,omitempty"` // The value of the uninterpreted option, in whatever type the tokenizer // identified it as during parsing. Exactly one of these should be set. - IdentifierValue *string `protobuf:"bytes,3,opt,name=identifier_value,json=identifierValue" json:"identifier_value,omitempty"` - PositiveIntValue *uint64 `protobuf:"varint,4,opt,name=positive_int_value,json=positiveIntValue" json:"positive_int_value,omitempty"` - NegativeIntValue *int64 `protobuf:"varint,5,opt,name=negative_int_value,json=negativeIntValue" json:"negative_int_value,omitempty"` - DoubleValue *float64 `protobuf:"fixed64,6,opt,name=double_value,json=doubleValue" json:"double_value,omitempty"` - StringValue []byte `protobuf:"bytes,7,opt,name=string_value,json=stringValue" json:"string_value,omitempty"` - AggregateValue *string `protobuf:"bytes,8,opt,name=aggregate_value,json=aggregateValue" json:"aggregate_value,omitempty"` + IdentifierValue *string `protobuf:"bytes,3,opt,name=identifier_value" json:"identifier_value,omitempty"` + PositiveIntValue *uint64 `protobuf:"varint,4,opt,name=positive_int_value" json:"positive_int_value,omitempty"` + NegativeIntValue *int64 `protobuf:"varint,5,opt,name=negative_int_value" json:"negative_int_value,omitempty"` + DoubleValue *float64 `protobuf:"fixed64,6,opt,name=double_value" json:"double_value,omitempty"` + StringValue []byte `protobuf:"bytes,7,opt,name=string_value" json:"string_value,omitempty"` + AggregateValue *string `protobuf:"bytes,8,opt,name=aggregate_value" json:"aggregate_value,omitempty"` XXX_unrecognized []byte `json:"-"` } func (m *UninterpretedOption) Reset() { *m = UninterpretedOption{} } func (m *UninterpretedOption) String() string { return proto.CompactTextString(m) } func (*UninterpretedOption) ProtoMessage() {} -func (*UninterpretedOption) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} } +func (*UninterpretedOption) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} } func (m *UninterpretedOption) GetName() []*UninterpretedOption_NamePart { if m != nil { @@ -1596,8 +1485,8 @@ func (m *UninterpretedOption) GetAggregateValue() string { // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents // "foo.(bar.baz).qux". type UninterpretedOption_NamePart struct { - NamePart *string `protobuf:"bytes,1,req,name=name_part,json=namePart" json:"name_part,omitempty"` - IsExtension *bool `protobuf:"varint,2,req,name=is_extension,json=isExtension" json:"is_extension,omitempty"` + NamePart *string `protobuf:"bytes,1,req,name=name_part" json:"name_part,omitempty"` + IsExtension *bool `protobuf:"varint,2,req,name=is_extension" json:"is_extension,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -1605,7 +1494,7 @@ func (m *UninterpretedOption_NamePart) Reset() { *m = UninterpretedOptio func (m *UninterpretedOption_NamePart) String() string { return proto.CompactTextString(m) } func (*UninterpretedOption_NamePart) ProtoMessage() {} func (*UninterpretedOption_NamePart) Descriptor() ([]byte, []int) { - return fileDescriptor0, []int{17, 0} + return fileDescriptor0, []int{16, 0} } func (m *UninterpretedOption_NamePart) GetNamePart() string { @@ -1675,7 +1564,7 @@ type SourceCodeInfo struct { func (m *SourceCodeInfo) Reset() { *m = SourceCodeInfo{} } func (m *SourceCodeInfo) String() string { return proto.CompactTextString(m) } func (*SourceCodeInfo) ProtoMessage() {} -func (*SourceCodeInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} } +func (*SourceCodeInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} } func (m *SourceCodeInfo) GetLocation() []*SourceCodeInfo_Location { if m != nil { @@ -1722,11 +1611,6 @@ type SourceCodeInfo_Location struct { // A series of line comments appearing on consecutive lines, with no other // tokens appearing on those lines, will be treated as a single comment. // - // leading_detached_comments will keep paragraphs of comments that appear - // before (but not connected to) the current element. Each paragraph, - // separated by empty lines, will be one comment element in the repeated - // field. - // // Only the comment content is provided; comment markers (e.g. //) are // stripped out. For block comments, leading whitespace and an asterisk // will be stripped from the beginning of each line other than the first. @@ -1747,12 +1631,6 @@ type SourceCodeInfo_Location struct { // // Another line attached to qux. // optional double qux = 4; // - // // Detached comment for corge. This is not leading or trailing comments - // // to qux or corge because there are blank lines separating it from - // // both. - // - // // Detached comment for corge paragraph 2. - // // optional string corge = 5; // /* Block comment attached // * to corge. Leading asterisks @@ -1760,18 +1638,15 @@ type SourceCodeInfo_Location struct { // /* Block comment attached to // * grault. */ // optional int32 grault = 6; - // - // // ignored detached comments. - LeadingComments *string `protobuf:"bytes,3,opt,name=leading_comments,json=leadingComments" json:"leading_comments,omitempty"` - TrailingComments *string `protobuf:"bytes,4,opt,name=trailing_comments,json=trailingComments" json:"trailing_comments,omitempty"` - LeadingDetachedComments []string `protobuf:"bytes,6,rep,name=leading_detached_comments,json=leadingDetachedComments" json:"leading_detached_comments,omitempty"` - XXX_unrecognized []byte `json:"-"` + LeadingComments *string `protobuf:"bytes,3,opt,name=leading_comments" json:"leading_comments,omitempty"` + TrailingComments *string `protobuf:"bytes,4,opt,name=trailing_comments" json:"trailing_comments,omitempty"` + XXX_unrecognized []byte `json:"-"` } func (m *SourceCodeInfo_Location) Reset() { *m = SourceCodeInfo_Location{} } func (m *SourceCodeInfo_Location) String() string { return proto.CompactTextString(m) } func (*SourceCodeInfo_Location) ProtoMessage() {} -func (*SourceCodeInfo_Location) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18, 0} } +func (*SourceCodeInfo_Location) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17, 0} } func (m *SourceCodeInfo_Location) GetPath() []int32 { if m != nil { @@ -1801,92 +1676,11 @@ func (m *SourceCodeInfo_Location) GetTrailingComments() string { return "" } -func (m *SourceCodeInfo_Location) GetLeadingDetachedComments() []string { - if m != nil { - return m.LeadingDetachedComments - } - return nil -} - -// Describes the relationship between generated code and its original source -// file. A GeneratedCodeInfo message is associated with only one generated -// source file, but may contain references to different source .proto files. -type GeneratedCodeInfo struct { - // An Annotation connects some span of text in generated code to an element - // of its generating .proto file. - Annotation []*GeneratedCodeInfo_Annotation `protobuf:"bytes,1,rep,name=annotation" json:"annotation,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *GeneratedCodeInfo) Reset() { *m = GeneratedCodeInfo{} } -func (m *GeneratedCodeInfo) String() string { return proto.CompactTextString(m) } -func (*GeneratedCodeInfo) ProtoMessage() {} -func (*GeneratedCodeInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{19} } - -func (m *GeneratedCodeInfo) GetAnnotation() []*GeneratedCodeInfo_Annotation { - if m != nil { - return m.Annotation - } - return nil -} - -type GeneratedCodeInfo_Annotation struct { - // Identifies the element in the original source .proto file. This field - // is formatted the same as SourceCodeInfo.Location.path. - Path []int32 `protobuf:"varint,1,rep,packed,name=path" json:"path,omitempty"` - // Identifies the filesystem path to the original source .proto. - SourceFile *string `protobuf:"bytes,2,opt,name=source_file,json=sourceFile" json:"source_file,omitempty"` - // Identifies the starting offset in bytes in the generated code - // that relates to the identified object. - Begin *int32 `protobuf:"varint,3,opt,name=begin" json:"begin,omitempty"` - // Identifies the ending offset in bytes in the generated code that - // relates to the identified offset. The end offset should be one past - // the last relevant byte (so the length of the text = end - begin). - End *int32 `protobuf:"varint,4,opt,name=end" json:"end,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *GeneratedCodeInfo_Annotation) Reset() { *m = GeneratedCodeInfo_Annotation{} } -func (m *GeneratedCodeInfo_Annotation) String() string { return proto.CompactTextString(m) } -func (*GeneratedCodeInfo_Annotation) ProtoMessage() {} -func (*GeneratedCodeInfo_Annotation) Descriptor() ([]byte, []int) { - return fileDescriptor0, []int{19, 0} -} - -func (m *GeneratedCodeInfo_Annotation) GetPath() []int32 { - if m != nil { - return m.Path - } - return nil -} - -func (m *GeneratedCodeInfo_Annotation) GetSourceFile() string { - if m != nil && m.SourceFile != nil { - return *m.SourceFile - } - return "" -} - -func (m *GeneratedCodeInfo_Annotation) GetBegin() int32 { - if m != nil && m.Begin != nil { - return *m.Begin - } - return 0 -} - -func (m *GeneratedCodeInfo_Annotation) GetEnd() int32 { - if m != nil && m.End != nil { - return *m.End - } - return 0 -} - func init() { proto.RegisterType((*FileDescriptorSet)(nil), "google.protobuf.FileDescriptorSet") proto.RegisterType((*FileDescriptorProto)(nil), "google.protobuf.FileDescriptorProto") proto.RegisterType((*DescriptorProto)(nil), "google.protobuf.DescriptorProto") proto.RegisterType((*DescriptorProto_ExtensionRange)(nil), "google.protobuf.DescriptorProto.ExtensionRange") - proto.RegisterType((*DescriptorProto_ReservedRange)(nil), "google.protobuf.DescriptorProto.ReservedRange") proto.RegisterType((*FieldDescriptorProto)(nil), "google.protobuf.FieldDescriptorProto") proto.RegisterType((*OneofDescriptorProto)(nil), "google.protobuf.OneofDescriptorProto") proto.RegisterType((*EnumDescriptorProto)(nil), "google.protobuf.EnumDescriptorProto") @@ -1896,7 +1690,6 @@ func init() { proto.RegisterType((*FileOptions)(nil), "google.protobuf.FileOptions") proto.RegisterType((*MessageOptions)(nil), "google.protobuf.MessageOptions") proto.RegisterType((*FieldOptions)(nil), "google.protobuf.FieldOptions") - proto.RegisterType((*OneofOptions)(nil), "google.protobuf.OneofOptions") proto.RegisterType((*EnumOptions)(nil), "google.protobuf.EnumOptions") proto.RegisterType((*EnumValueOptions)(nil), "google.protobuf.EnumValueOptions") proto.RegisterType((*ServiceOptions)(nil), "google.protobuf.ServiceOptions") @@ -1905,161 +1698,115 @@ func init() { proto.RegisterType((*UninterpretedOption_NamePart)(nil), "google.protobuf.UninterpretedOption.NamePart") proto.RegisterType((*SourceCodeInfo)(nil), "google.protobuf.SourceCodeInfo") proto.RegisterType((*SourceCodeInfo_Location)(nil), "google.protobuf.SourceCodeInfo.Location") - proto.RegisterType((*GeneratedCodeInfo)(nil), "google.protobuf.GeneratedCodeInfo") - proto.RegisterType((*GeneratedCodeInfo_Annotation)(nil), "google.protobuf.GeneratedCodeInfo.Annotation") proto.RegisterEnum("google.protobuf.FieldDescriptorProto_Type", FieldDescriptorProto_Type_name, FieldDescriptorProto_Type_value) proto.RegisterEnum("google.protobuf.FieldDescriptorProto_Label", FieldDescriptorProto_Label_name, FieldDescriptorProto_Label_value) proto.RegisterEnum("google.protobuf.FileOptions_OptimizeMode", FileOptions_OptimizeMode_name, FileOptions_OptimizeMode_value) proto.RegisterEnum("google.protobuf.FieldOptions_CType", FieldOptions_CType_name, FieldOptions_CType_value) - proto.RegisterEnum("google.protobuf.FieldOptions_JSType", FieldOptions_JSType_name, FieldOptions_JSType_value) } -func init() { proto.RegisterFile("google/protobuf/descriptor.proto", fileDescriptor0) } - var fileDescriptor0 = []byte{ - // 2295 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xcc, 0x59, 0x4f, 0x6f, 0x1b, 0xc7, - 0x15, 0xcf, 0xf2, 0x9f, 0xc8, 0x47, 0x8a, 0x1a, 0x8d, 0x14, 0x67, 0xad, 0xfc, 0xb1, 0xcc, 0xd8, - 0xb1, 0x6c, 0xb7, 0x74, 0x20, 0xff, 0x89, 0xa3, 0x14, 0x29, 0x28, 0x71, 0xad, 0xd0, 0x90, 0x44, - 0x76, 0x29, 0xb5, 0x4e, 0x2e, 0x8b, 0xd1, 0xee, 0x90, 0x5a, 0x7b, 0x39, 0xbb, 0xdd, 0x5d, 0xda, - 0x56, 0x4e, 0x06, 0x7a, 0xea, 0xa5, 0xe7, 0xa2, 0x2d, 0x7a, 0xc8, 0x25, 0x40, 0x3f, 0x40, 0x0f, - 0xfd, 0x0a, 0x05, 0x0a, 0xf4, 0x2b, 0x14, 0x05, 0xda, 0x6f, 0xd0, 0x6b, 0x31, 0x33, 0xbb, 0xcb, - 0x5d, 0xfe, 0x89, 0xd5, 0x00, 0x49, 0x7a, 0x12, 0xe7, 0xf7, 0x7e, 0xef, 0xcd, 0x9b, 0x37, 0x6f, - 0xde, 0xbc, 0x1d, 0xc1, 0xe6, 0xd0, 0x75, 0x87, 0x0e, 0xbd, 0xe3, 0xf9, 0x6e, 0xe8, 0x9e, 0x8e, - 0x07, 0x77, 0x2c, 0x1a, 0x98, 0xbe, 0xed, 0x85, 0xae, 0xdf, 0x14, 0x18, 0x5e, 0x91, 0x8c, 0x66, - 0xcc, 0x68, 0x1c, 0xc2, 0xea, 0x23, 0xdb, 0xa1, 0xed, 0x84, 0xd8, 0xa7, 0x21, 0x7e, 0x08, 0x85, - 0x81, 0xed, 0x50, 0x55, 0xd9, 0xcc, 0x6f, 0x55, 0xb7, 0xaf, 0x35, 0xa7, 0x94, 0x9a, 0x59, 0x8d, - 0x1e, 0x87, 0x75, 0xa1, 0xd1, 0xf8, 0x67, 0x01, 0xd6, 0xe6, 0x48, 0x31, 0x86, 0x02, 0x23, 0x23, - 0x6e, 0x51, 0xd9, 0xaa, 0xe8, 0xe2, 0x37, 0x56, 0x61, 0xc9, 0x23, 0xe6, 0x33, 0x32, 0xa4, 0x6a, - 0x4e, 0xc0, 0xf1, 0x10, 0xbf, 0x07, 0x60, 0x51, 0x8f, 0x32, 0x8b, 0x32, 0xf3, 0x5c, 0xcd, 0x6f, - 0xe6, 0xb7, 0x2a, 0x7a, 0x0a, 0xc1, 0xb7, 0x61, 0xd5, 0x1b, 0x9f, 0x3a, 0xb6, 0x69, 0xa4, 0x68, - 0xb0, 0x99, 0xdf, 0x2a, 0xea, 0x48, 0x0a, 0xda, 0x13, 0xf2, 0x0d, 0x58, 0x79, 0x41, 0xc9, 0xb3, - 0x34, 0xb5, 0x2a, 0xa8, 0x75, 0x0e, 0xa7, 0x88, 0x7b, 0x50, 0x1b, 0xd1, 0x20, 0x20, 0x43, 0x6a, - 0x84, 0xe7, 0x1e, 0x55, 0x0b, 0x62, 0xf5, 0x9b, 0x33, 0xab, 0x9f, 0x5e, 0x79, 0x35, 0xd2, 0x3a, - 0x3e, 0xf7, 0x28, 0x6e, 0x41, 0x85, 0xb2, 0xf1, 0x48, 0x5a, 0x28, 0x2e, 0x88, 0x9f, 0xc6, 0xc6, - 0xa3, 0x69, 0x2b, 0x65, 0xae, 0x16, 0x99, 0x58, 0x0a, 0xa8, 0xff, 0xdc, 0x36, 0xa9, 0x5a, 0x12, - 0x06, 0x6e, 0xcc, 0x18, 0xe8, 0x4b, 0xf9, 0xb4, 0x8d, 0x58, 0x0f, 0xef, 0x41, 0x85, 0xbe, 0x0c, - 0x29, 0x0b, 0x6c, 0x97, 0xa9, 0x4b, 0xc2, 0xc8, 0xf5, 0x39, 0xbb, 0x48, 0x1d, 0x6b, 0xda, 0xc4, - 0x44, 0x0f, 0x3f, 0x80, 0x25, 0xd7, 0x0b, 0x6d, 0x97, 0x05, 0x6a, 0x79, 0x53, 0xd9, 0xaa, 0x6e, - 0xbf, 0x33, 0x37, 0x11, 0xba, 0x92, 0xa3, 0xc7, 0x64, 0xdc, 0x01, 0x14, 0xb8, 0x63, 0xdf, 0xa4, - 0x86, 0xe9, 0x5a, 0xd4, 0xb0, 0xd9, 0xc0, 0x55, 0x2b, 0xc2, 0xc0, 0x95, 0xd9, 0x85, 0x08, 0xe2, - 0x9e, 0x6b, 0xd1, 0x0e, 0x1b, 0xb8, 0x7a, 0x3d, 0xc8, 0x8c, 0xf1, 0x25, 0x28, 0x05, 0xe7, 0x2c, - 0x24, 0x2f, 0xd5, 0x9a, 0xc8, 0x90, 0x68, 0xd4, 0xf8, 0x4f, 0x11, 0x56, 0x2e, 0x92, 0x62, 0x9f, - 0x40, 0x71, 0xc0, 0x57, 0xa9, 0xe6, 0xfe, 0x97, 0x18, 0x48, 0x9d, 0x6c, 0x10, 0x4b, 0xdf, 0x32, - 0x88, 0x2d, 0xa8, 0x32, 0x1a, 0x84, 0xd4, 0x92, 0x19, 0x91, 0xbf, 0x60, 0x4e, 0x81, 0x54, 0x9a, - 0x4d, 0xa9, 0xc2, 0xb7, 0x4a, 0xa9, 0x27, 0xb0, 0x92, 0xb8, 0x64, 0xf8, 0x84, 0x0d, 0xe3, 0xdc, - 0xbc, 0xf3, 0x3a, 0x4f, 0x9a, 0x5a, 0xac, 0xa7, 0x73, 0x35, 0xbd, 0x4e, 0x33, 0x63, 0xdc, 0x06, - 0x70, 0x19, 0x75, 0x07, 0x86, 0x45, 0x4d, 0x47, 0x2d, 0x2f, 0x88, 0x52, 0x97, 0x53, 0x66, 0xa2, - 0xe4, 0x4a, 0xd4, 0x74, 0xf0, 0xc7, 0x93, 0x54, 0x5b, 0x5a, 0x90, 0x29, 0x87, 0xf2, 0x90, 0xcd, - 0x64, 0xdb, 0x09, 0xd4, 0x7d, 0xca, 0xf3, 0x9e, 0x5a, 0xd1, 0xca, 0x2a, 0xc2, 0x89, 0xe6, 0x6b, - 0x57, 0xa6, 0x47, 0x6a, 0x72, 0x61, 0xcb, 0x7e, 0x7a, 0x88, 0xdf, 0x87, 0x04, 0x30, 0x44, 0x5a, - 0x81, 0xa8, 0x42, 0xb5, 0x18, 0x3c, 0x22, 0x23, 0xba, 0xf1, 0x10, 0xea, 0xd9, 0xf0, 0xe0, 0x75, - 0x28, 0x06, 0x21, 0xf1, 0x43, 0x91, 0x85, 0x45, 0x5d, 0x0e, 0x30, 0x82, 0x3c, 0x65, 0x96, 0xa8, - 0x72, 0x45, 0x9d, 0xff, 0xdc, 0xf8, 0x08, 0x96, 0x33, 0xd3, 0x5f, 0x54, 0xb1, 0xf1, 0xdb, 0x12, - 0xac, 0xcf, 0xcb, 0xb9, 0xb9, 0xe9, 0x7f, 0x09, 0x4a, 0x6c, 0x3c, 0x3a, 0xa5, 0xbe, 0x9a, 0x17, - 0x16, 0xa2, 0x11, 0x6e, 0x41, 0xd1, 0x21, 0xa7, 0xd4, 0x51, 0x0b, 0x9b, 0xca, 0x56, 0x7d, 0xfb, - 0xf6, 0x85, 0xb2, 0xba, 0x79, 0xc0, 0x55, 0x74, 0xa9, 0x89, 0x3f, 0x85, 0x42, 0x54, 0xe2, 0xb8, - 0x85, 0x5b, 0x17, 0xb3, 0xc0, 0x73, 0x51, 0x17, 0x7a, 0xf8, 0x6d, 0xa8, 0xf0, 0xbf, 0x32, 0xb6, - 0x25, 0xe1, 0x73, 0x99, 0x03, 0x3c, 0xae, 0x78, 0x03, 0xca, 0x22, 0xcd, 0x2c, 0x1a, 0x5f, 0x0d, - 0xc9, 0x98, 0x6f, 0x8c, 0x45, 0x07, 0x64, 0xec, 0x84, 0xc6, 0x73, 0xe2, 0x8c, 0xa9, 0x48, 0x98, - 0x8a, 0x5e, 0x8b, 0xc0, 0x9f, 0x73, 0x0c, 0x5f, 0x81, 0xaa, 0xcc, 0x4a, 0x9b, 0x59, 0xf4, 0xa5, - 0xa8, 0x3e, 0x45, 0x5d, 0x26, 0x6a, 0x87, 0x23, 0x7c, 0xfa, 0xa7, 0x81, 0xcb, 0xe2, 0xad, 0x15, - 0x53, 0x70, 0x40, 0x4c, 0xff, 0xd1, 0x74, 0xe1, 0x7b, 0x77, 0xfe, 0xf2, 0xa6, 0x73, 0xb1, 0xf1, - 0xe7, 0x1c, 0x14, 0xc4, 0x79, 0x5b, 0x81, 0xea, 0xf1, 0xe7, 0x3d, 0xcd, 0x68, 0x77, 0x4f, 0x76, - 0x0f, 0x34, 0xa4, 0xe0, 0x3a, 0x80, 0x00, 0x1e, 0x1d, 0x74, 0x5b, 0xc7, 0x28, 0x97, 0x8c, 0x3b, - 0x47, 0xc7, 0x0f, 0xee, 0xa1, 0x7c, 0xa2, 0x70, 0x22, 0x81, 0x42, 0x9a, 0x70, 0x77, 0x1b, 0x15, - 0x31, 0x82, 0x9a, 0x34, 0xd0, 0x79, 0xa2, 0xb5, 0x1f, 0xdc, 0x43, 0xa5, 0x2c, 0x72, 0x77, 0x1b, - 0x2d, 0xe1, 0x65, 0xa8, 0x08, 0x64, 0xb7, 0xdb, 0x3d, 0x40, 0xe5, 0xc4, 0x66, 0xff, 0x58, 0xef, - 0x1c, 0xed, 0xa3, 0x4a, 0x62, 0x73, 0x5f, 0xef, 0x9e, 0xf4, 0x10, 0x24, 0x16, 0x0e, 0xb5, 0x7e, - 0xbf, 0xb5, 0xaf, 0xa1, 0x6a, 0xc2, 0xd8, 0xfd, 0xfc, 0x58, 0xeb, 0xa3, 0x5a, 0xc6, 0xad, 0xbb, - 0xdb, 0x68, 0x39, 0x99, 0x42, 0x3b, 0x3a, 0x39, 0x44, 0x75, 0xbc, 0x0a, 0xcb, 0x72, 0x8a, 0xd8, - 0x89, 0x95, 0x29, 0xe8, 0xc1, 0x3d, 0x84, 0x26, 0x8e, 0x48, 0x2b, 0xab, 0x19, 0xe0, 0xc1, 0x3d, - 0x84, 0x1b, 0x7b, 0x50, 0x14, 0xd9, 0x85, 0x31, 0xd4, 0x0f, 0x5a, 0xbb, 0xda, 0x81, 0xd1, 0xed, - 0x1d, 0x77, 0xba, 0x47, 0xad, 0x03, 0xa4, 0x4c, 0x30, 0x5d, 0xfb, 0xd9, 0x49, 0x47, 0xd7, 0xda, - 0x28, 0x97, 0xc6, 0x7a, 0x5a, 0xeb, 0x58, 0x6b, 0xa3, 0x7c, 0xc3, 0x84, 0xf5, 0x79, 0x75, 0x66, - 0xee, 0xc9, 0x48, 0x6d, 0x71, 0x6e, 0xc1, 0x16, 0x0b, 0x5b, 0x33, 0x5b, 0xfc, 0x95, 0x02, 0x6b, - 0x73, 0x6a, 0xed, 0xdc, 0x49, 0x7e, 0x0a, 0x45, 0x99, 0xa2, 0xf2, 0xf6, 0xb9, 0x39, 0xb7, 0x68, - 0x8b, 0x84, 0x9d, 0xb9, 0x81, 0x84, 0x5e, 0xfa, 0x06, 0xce, 0x2f, 0xb8, 0x81, 0xb9, 0x89, 0x19, - 0x27, 0x7f, 0xa5, 0x80, 0xba, 0xc8, 0xf6, 0x6b, 0x0a, 0x45, 0x2e, 0x53, 0x28, 0x3e, 0x99, 0x76, - 0xe0, 0xea, 0xe2, 0x35, 0xcc, 0x78, 0xf1, 0xb5, 0x02, 0x97, 0xe6, 0x37, 0x2a, 0x73, 0x7d, 0xf8, - 0x14, 0x4a, 0x23, 0x1a, 0x9e, 0xb9, 0xf1, 0x65, 0xfd, 0xc1, 0x9c, 0x2b, 0x80, 0x8b, 0xa7, 0x63, - 0x15, 0x69, 0xa5, 0xef, 0x90, 0xfc, 0xa2, 0x6e, 0x43, 0x7a, 0x33, 0xe3, 0xe9, 0xaf, 0x73, 0xf0, - 0xe6, 0x5c, 0xe3, 0x73, 0x1d, 0x7d, 0x17, 0xc0, 0x66, 0xde, 0x38, 0x94, 0x17, 0xb2, 0xac, 0x4f, - 0x15, 0x81, 0x88, 0xb3, 0xcf, 0x6b, 0xcf, 0x38, 0x4c, 0xe4, 0x79, 0x21, 0x07, 0x09, 0x09, 0xc2, - 0xc3, 0x89, 0xa3, 0x05, 0xe1, 0xe8, 0x7b, 0x0b, 0x56, 0x3a, 0x73, 0xd7, 0x7d, 0x08, 0xc8, 0x74, - 0x6c, 0xca, 0x42, 0x23, 0x08, 0x7d, 0x4a, 0x46, 0x36, 0x1b, 0x8a, 0x02, 0x5c, 0xde, 0x29, 0x0e, - 0x88, 0x13, 0x50, 0x7d, 0x45, 0x8a, 0xfb, 0xb1, 0x94, 0x6b, 0x88, 0x5b, 0xc6, 0x4f, 0x69, 0x94, - 0x32, 0x1a, 0x52, 0x9c, 0x68, 0x34, 0x7e, 0xb3, 0x04, 0xd5, 0x54, 0x5b, 0x87, 0xaf, 0x42, 0xed, - 0x29, 0x79, 0x4e, 0x8c, 0xb8, 0x55, 0x97, 0x91, 0xa8, 0x72, 0xac, 0x17, 0xb5, 0xeb, 0x1f, 0xc2, - 0xba, 0xa0, 0xb8, 0xe3, 0x90, 0xfa, 0x86, 0xe9, 0x90, 0x20, 0x10, 0x41, 0x2b, 0x0b, 0x2a, 0xe6, - 0xb2, 0x2e, 0x17, 0xed, 0xc5, 0x12, 0x7c, 0x1f, 0xd6, 0x84, 0xc6, 0x68, 0xec, 0x84, 0xb6, 0xe7, - 0x50, 0x83, 0x7f, 0x3c, 0x04, 0xa2, 0x10, 0x27, 0x9e, 0xad, 0x72, 0xc6, 0x61, 0x44, 0xe0, 0x1e, - 0x05, 0xb8, 0x0d, 0xef, 0x0a, 0xb5, 0x21, 0x65, 0xd4, 0x27, 0x21, 0x35, 0xe8, 0x2f, 0xc7, 0xc4, - 0x09, 0x0c, 0xc2, 0x2c, 0xe3, 0x8c, 0x04, 0x67, 0xea, 0x3a, 0x37, 0xb0, 0x9b, 0x53, 0x15, 0xfd, - 0x32, 0x27, 0xee, 0x47, 0x3c, 0x4d, 0xd0, 0x5a, 0xcc, 0xfa, 0x8c, 0x04, 0x67, 0x78, 0x07, 0x2e, - 0x09, 0x2b, 0x41, 0xe8, 0xdb, 0x6c, 0x68, 0x98, 0x67, 0xd4, 0x7c, 0x66, 0x8c, 0xc3, 0xc1, 0x43, - 0xf5, 0xed, 0xf4, 0xfc, 0xc2, 0xc3, 0xbe, 0xe0, 0xec, 0x71, 0xca, 0x49, 0x38, 0x78, 0x88, 0xfb, - 0x50, 0xe3, 0x9b, 0x31, 0xb2, 0xbf, 0xa4, 0xc6, 0xc0, 0xf5, 0xc5, 0xcd, 0x52, 0x9f, 0x73, 0xb2, - 0x53, 0x11, 0x6c, 0x76, 0x23, 0x85, 0x43, 0xd7, 0xa2, 0x3b, 0xc5, 0x7e, 0x4f, 0xd3, 0xda, 0x7a, - 0x35, 0xb6, 0xf2, 0xc8, 0xf5, 0x79, 0x42, 0x0d, 0xdd, 0x24, 0xc0, 0x55, 0x99, 0x50, 0x43, 0x37, - 0x0e, 0xef, 0x7d, 0x58, 0x33, 0x4d, 0xb9, 0x66, 0xdb, 0x34, 0xa2, 0x16, 0x3f, 0x50, 0x51, 0x26, - 0x58, 0xa6, 0xb9, 0x2f, 0x09, 0x51, 0x8e, 0x07, 0xf8, 0x63, 0x78, 0x73, 0x12, 0xac, 0xb4, 0xe2, - 0xea, 0xcc, 0x2a, 0xa7, 0x55, 0xef, 0xc3, 0x9a, 0x77, 0x3e, 0xab, 0x88, 0x33, 0x33, 0x7a, 0xe7, - 0xd3, 0x6a, 0xd7, 0xc5, 0x67, 0x9b, 0x4f, 0x4d, 0x12, 0x52, 0x4b, 0x7d, 0x2b, 0xcd, 0x4e, 0x09, - 0xf0, 0x1d, 0x40, 0xa6, 0x69, 0x50, 0x46, 0x4e, 0x1d, 0x6a, 0x10, 0x9f, 0x32, 0x12, 0xa8, 0x57, - 0xd2, 0xe4, 0xba, 0x69, 0x6a, 0x42, 0xda, 0x12, 0x42, 0x7c, 0x0b, 0x56, 0xdd, 0xd3, 0xa7, 0xa6, - 0xcc, 0x2c, 0xc3, 0xf3, 0xe9, 0xc0, 0x7e, 0xa9, 0x5e, 0x13, 0x61, 0x5a, 0xe1, 0x02, 0x91, 0x57, - 0x3d, 0x01, 0xe3, 0x9b, 0x80, 0xcc, 0xe0, 0x8c, 0xf8, 0x9e, 0xb8, 0xda, 0x03, 0x8f, 0x98, 0x54, - 0xbd, 0x2e, 0xa9, 0x12, 0x3f, 0x8a, 0x61, 0xfc, 0x04, 0xd6, 0xc7, 0xcc, 0x66, 0x21, 0xf5, 0x3d, - 0x9f, 0xf2, 0x0e, 0x5d, 0x1e, 0x33, 0xf5, 0x5f, 0x4b, 0x0b, 0x7a, 0xec, 0x93, 0x34, 0x5b, 0xee, - 0xae, 0xbe, 0x36, 0x9e, 0x05, 0x1b, 0x3b, 0x50, 0x4b, 0x6f, 0x3a, 0xae, 0x80, 0xdc, 0x76, 0xa4, - 0xf0, 0x0b, 0x74, 0xaf, 0xdb, 0xe6, 0x57, 0xdf, 0x17, 0x1a, 0xca, 0xf1, 0x2b, 0xf8, 0xa0, 0x73, - 0xac, 0x19, 0xfa, 0xc9, 0xd1, 0x71, 0xe7, 0x50, 0x43, 0xf9, 0x5b, 0x95, 0xf2, 0xbf, 0x97, 0xd0, - 0xab, 0x57, 0xaf, 0x5e, 0xe5, 0x1e, 0x17, 0xca, 0x1f, 0xa0, 0x1b, 0x8d, 0xbf, 0xe6, 0xa0, 0x9e, - 0x6d, 0x7e, 0xf1, 0x4f, 0xe0, 0xad, 0xf8, 0x4b, 0x35, 0xa0, 0xa1, 0xf1, 0xc2, 0xf6, 0x45, 0x36, - 0x8e, 0x88, 0x6c, 0x1f, 0x93, 0x40, 0xae, 0x47, 0xac, 0x3e, 0x0d, 0x7f, 0x61, 0xfb, 0x3c, 0xd7, - 0x46, 0x24, 0xc4, 0x07, 0x70, 0x85, 0xb9, 0x46, 0x10, 0x12, 0x66, 0x11, 0xdf, 0x32, 0x26, 0x6f, - 0x04, 0x06, 0x31, 0x4d, 0x1a, 0x04, 0xae, 0xbc, 0x05, 0x12, 0x2b, 0xef, 0x30, 0xb7, 0x1f, 0x91, - 0x27, 0xe5, 0xb1, 0x15, 0x51, 0xa7, 0x36, 0x3d, 0xbf, 0x68, 0xd3, 0xdf, 0x86, 0xca, 0x88, 0x78, - 0x06, 0x65, 0xa1, 0x7f, 0x2e, 0x5a, 0xb6, 0xb2, 0x5e, 0x1e, 0x11, 0x4f, 0xe3, 0xe3, 0xef, 0x6e, - 0x27, 0xb2, 0xd1, 0x2c, 0xa3, 0x4a, 0xe3, 0x1f, 0x79, 0xa8, 0xa5, 0x9b, 0x37, 0xde, 0x0b, 0x9b, - 0xa2, 0x50, 0x2b, 0xe2, 0x28, 0xbf, 0xff, 0x8d, 0xad, 0x5e, 0x73, 0x8f, 0x57, 0xf0, 0x9d, 0x92, - 0x6c, 0xa9, 0x74, 0xa9, 0xc9, 0x6f, 0x4f, 0x7e, 0x78, 0xa9, 0x6c, 0xd4, 0xcb, 0x7a, 0x34, 0xc2, - 0xfb, 0x50, 0x7a, 0x1a, 0x08, 0xdb, 0x25, 0x61, 0xfb, 0xda, 0x37, 0xdb, 0x7e, 0xdc, 0x17, 0xc6, - 0x2b, 0x8f, 0xfb, 0xc6, 0x51, 0x57, 0x3f, 0x6c, 0x1d, 0xe8, 0x91, 0x3a, 0xbe, 0x0c, 0x05, 0x87, - 0x7c, 0x79, 0x9e, 0xad, 0xf5, 0x02, 0xba, 0x68, 0xf8, 0x2f, 0x43, 0xe1, 0x05, 0x25, 0xcf, 0xb2, - 0x15, 0x56, 0x40, 0xdf, 0xe1, 0x31, 0xb8, 0x03, 0x45, 0x11, 0x2f, 0x0c, 0x10, 0x45, 0x0c, 0xbd, - 0x81, 0xcb, 0x50, 0xd8, 0xeb, 0xea, 0xfc, 0x28, 0x20, 0xa8, 0x49, 0xd4, 0xe8, 0x75, 0xb4, 0x3d, - 0x0d, 0xe5, 0x1a, 0xf7, 0xa1, 0x24, 0x83, 0xc0, 0x8f, 0x49, 0x12, 0x06, 0xf4, 0x46, 0x34, 0x8c, - 0x6c, 0x28, 0xb1, 0xf4, 0xe4, 0x70, 0x57, 0xd3, 0x51, 0x2e, 0xbb, 0xc9, 0x05, 0x54, 0x6c, 0x04, - 0x50, 0x4b, 0x77, 0x6f, 0xdf, 0x4b, 0x7e, 0x35, 0xfe, 0xa2, 0x40, 0x35, 0xd5, 0x8d, 0xf1, 0x3e, - 0x80, 0x38, 0x8e, 0xfb, 0xc2, 0x20, 0x8e, 0x4d, 0x82, 0x28, 0x35, 0x40, 0x40, 0x2d, 0x8e, 0x5c, - 0x74, 0xeb, 0xbe, 0x17, 0xe7, 0xff, 0xa8, 0x00, 0x9a, 0xee, 0xe4, 0xa6, 0x1c, 0x54, 0x7e, 0x50, - 0x07, 0xff, 0xa0, 0x40, 0x3d, 0xdb, 0xbe, 0x4d, 0xb9, 0x77, 0xf5, 0x07, 0x75, 0xef, 0xf7, 0x0a, - 0x2c, 0x67, 0x9a, 0xb6, 0xff, 0x2b, 0xef, 0x7e, 0x97, 0x87, 0xb5, 0x39, 0x7a, 0xb8, 0x15, 0x75, - 0xb7, 0xb2, 0xe1, 0xfe, 0xf1, 0x45, 0xe6, 0x6a, 0xf2, 0xfb, 0xb3, 0x47, 0xfc, 0x30, 0x6a, 0x86, - 0x6f, 0x02, 0xb2, 0x2d, 0xca, 0x42, 0x7b, 0x60, 0x53, 0x3f, 0xfa, 0x22, 0x97, 0x2d, 0xef, 0xca, - 0x04, 0x97, 0x1f, 0xe5, 0x3f, 0x02, 0xec, 0xb9, 0x81, 0x1d, 0xda, 0xcf, 0xa9, 0x61, 0xb3, 0xf8, - 0xf3, 0x9d, 0xb7, 0xc0, 0x05, 0x1d, 0xc5, 0x92, 0x0e, 0x0b, 0x13, 0x36, 0xa3, 0x43, 0x32, 0xc5, - 0xe6, 0x15, 0x30, 0xaf, 0xa3, 0x58, 0x92, 0xb0, 0xaf, 0x42, 0xcd, 0x72, 0xc7, 0xbc, 0xa1, 0x90, - 0x3c, 0x5e, 0x70, 0x15, 0xbd, 0x2a, 0xb1, 0x84, 0x12, 0x75, 0x7c, 0x93, 0x77, 0x83, 0x9a, 0x5e, - 0x95, 0x98, 0xa4, 0xdc, 0x80, 0x15, 0x32, 0x1c, 0xfa, 0xdc, 0x78, 0x6c, 0x48, 0xf6, 0xb0, 0xf5, - 0x04, 0x16, 0xc4, 0x8d, 0xc7, 0x50, 0x8e, 0xe3, 0xc0, 0x6f, 0x36, 0x1e, 0x09, 0xc3, 0x93, 0xaf, - 0x37, 0xb9, 0xad, 0x8a, 0x5e, 0x66, 0xb1, 0xf0, 0x2a, 0xd4, 0xec, 0xc0, 0x98, 0x3c, 0x23, 0xe6, - 0x36, 0x73, 0x5b, 0x65, 0xbd, 0x6a, 0x07, 0xc9, 0xbb, 0x51, 0xe3, 0xeb, 0x1c, 0xd4, 0xb3, 0xcf, - 0xa0, 0xb8, 0x0d, 0x65, 0xc7, 0x35, 0x89, 0x48, 0x04, 0xf9, 0x06, 0xbf, 0xf5, 0x9a, 0x97, 0xd3, - 0xe6, 0x41, 0xc4, 0xd7, 0x13, 0xcd, 0x8d, 0xbf, 0x29, 0x50, 0x8e, 0x61, 0x7c, 0x09, 0x0a, 0x1e, - 0x09, 0xcf, 0x84, 0xb9, 0xe2, 0x6e, 0x0e, 0x29, 0xba, 0x18, 0x73, 0x3c, 0xf0, 0x08, 0x13, 0x29, - 0x10, 0xe1, 0x7c, 0xcc, 0xf7, 0xd5, 0xa1, 0xc4, 0x12, 0x0d, 0xb2, 0x3b, 0x1a, 0x51, 0x16, 0x06, - 0xf1, 0xbe, 0x46, 0xf8, 0x5e, 0x04, 0xe3, 0xdb, 0xb0, 0x1a, 0xfa, 0xc4, 0x76, 0x32, 0xdc, 0x82, - 0xe0, 0xa2, 0x58, 0x90, 0x90, 0x77, 0xe0, 0x72, 0x6c, 0xd7, 0xa2, 0x21, 0x31, 0xcf, 0xa8, 0x35, - 0x51, 0x2a, 0x89, 0x37, 0xb6, 0xb7, 0x22, 0x42, 0x3b, 0x92, 0xc7, 0xba, 0x8d, 0xbf, 0x2b, 0xb0, - 0x1a, 0xb7, 0xf4, 0x56, 0x12, 0xac, 0x43, 0x00, 0xc2, 0x98, 0x1b, 0xa6, 0xc3, 0x35, 0x9b, 0xca, - 0x33, 0x7a, 0xcd, 0x56, 0xa2, 0xa4, 0xa7, 0x0c, 0x6c, 0x8c, 0x00, 0x26, 0x92, 0x85, 0x61, 0xbb, - 0x02, 0xd5, 0xe8, 0x8d, 0x5b, 0xfc, 0xa3, 0x44, 0x7e, 0x04, 0x82, 0x84, 0x78, 0xef, 0x8f, 0xd7, - 0xa1, 0x78, 0x4a, 0x87, 0x36, 0x8b, 0x5e, 0xde, 0xe4, 0x20, 0x7e, 0xcf, 0x2b, 0x24, 0xef, 0x79, - 0xbb, 0x4f, 0x60, 0xcd, 0x74, 0x47, 0xd3, 0xee, 0xee, 0xa2, 0xa9, 0x0f, 0xd1, 0xe0, 0x33, 0xe5, - 0x0b, 0x98, 0x74, 0x6a, 0x5f, 0xe5, 0xf2, 0xfb, 0xbd, 0xdd, 0x3f, 0xe5, 0x36, 0xf6, 0xa5, 0x5e, - 0x2f, 0x5e, 0xa6, 0x4e, 0x07, 0x0e, 0x35, 0xb9, 0xeb, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x5f, - 0x1c, 0x48, 0x4f, 0x0d, 0x1a, 0x00, 0x00, + // 1635 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x58, 0xcd, 0x72, 0xdb, 0xd4, + 0x17, 0xff, 0xfb, 0x43, 0xfe, 0x38, 0x76, 0x1c, 0x45, 0x49, 0x5b, 0x35, 0xff, 0x96, 0xb4, 0xa6, + 0x2d, 0x69, 0x69, 0x1d, 0x26, 0x2d, 0xa5, 0x84, 0x55, 0x3e, 0xd4, 0xd4, 0x33, 0x4e, 0x6c, 0x12, + 0x87, 0xa1, 0x6c, 0x34, 0x37, 0xf2, 0xb5, 0xa3, 0x56, 0x96, 0x8c, 0x24, 0xa7, 0x4d, 0x19, 0x66, + 0x78, 0x00, 0x98, 0xe1, 0x09, 0x18, 0x5e, 0x81, 0x0d, 0x2b, 0x36, 0xec, 0x79, 0x03, 0xb6, 0x0c, + 0xf0, 0x18, 0x9c, 0x7b, 0xaf, 0x25, 0x4b, 0x8a, 0x9d, 0xb6, 0x4c, 0x4b, 0x57, 0xee, 0xb9, 0xbf, + 0x73, 0xce, 0xef, 0x9e, 0xcf, 0xab, 0xc0, 0x95, 0x9e, 0xe3, 0xf4, 0x2c, 0xba, 0x32, 0x70, 0x1d, + 0xdf, 0x39, 0x1c, 0x76, 0x57, 0x3a, 0xd4, 0x33, 0x5c, 0x73, 0xe0, 0x3b, 0x6e, 0x8d, 0xcb, 0x94, + 0x59, 0x81, 0xa8, 0x05, 0x88, 0xea, 0x36, 0xcc, 0x3d, 0x34, 0x2d, 0xba, 0x15, 0x02, 0xf7, 0xa9, + 0xaf, 0xac, 0x42, 0xb6, 0x8b, 0x42, 0x35, 0x75, 0x25, 0xb3, 0x5c, 0x5a, 0xbd, 0x56, 0x4b, 0x28, + 0xd5, 0xe2, 0x1a, 0x2d, 0x26, 0xae, 0xfe, 0x9e, 0x81, 0xf9, 0x09, 0x72, 0xa5, 0x0c, 0x59, 0x9b, + 0xf4, 0x99, 0xad, 0xd4, 0x72, 0x51, 0x99, 0x85, 0xfc, 0x80, 0x18, 0x4f, 0x49, 0x8f, 0xaa, 0x69, + 0x2e, 0x50, 0x00, 0x3a, 0x74, 0x40, 0xed, 0x0e, 0xb5, 0x8d, 0x13, 0x35, 0x83, 0x0e, 0x8b, 0xca, + 0x45, 0x98, 0x1b, 0x0c, 0x0f, 0x2d, 0xd3, 0xd0, 0x23, 0x47, 0x80, 0x47, 0x92, 0x72, 0x01, 0x66, + 0x9f, 0x51, 0xf2, 0x34, 0x7a, 0x50, 0xe2, 0x07, 0xf7, 0xa1, 0xdc, 0xa7, 0x9e, 0x87, 0x86, 0x75, + 0xff, 0x64, 0x40, 0xd5, 0x2c, 0xa7, 0x7e, 0xe5, 0x14, 0xf5, 0x24, 0xbd, 0x8f, 0xa0, 0x48, 0xed, + 0x61, 0x5f, 0x28, 0x49, 0x53, 0xee, 0xab, 0x21, 0x22, 0xa9, 0xf8, 0x00, 0xf2, 0x1e, 0x75, 0x8f, + 0x4d, 0x83, 0xaa, 0x39, 0xae, 0xf6, 0xde, 0x29, 0xb5, 0x7d, 0x71, 0x7e, 0x5a, 0xb3, 0x48, 0x9f, + 0xfb, 0xd4, 0xf6, 0x4c, 0xc7, 0x56, 0xf3, 0x5c, 0xf7, 0xfa, 0x84, 0x10, 0x53, 0xab, 0x93, 0xd4, + 0xbc, 0x03, 0x79, 0x67, 0xe0, 0xa3, 0x9a, 0xa7, 0x16, 0x30, 0x7a, 0xa5, 0xd5, 0x4b, 0x13, 0x53, + 0xd3, 0x14, 0x18, 0xe5, 0x63, 0x90, 0x3d, 0x67, 0xe8, 0x1a, 0x54, 0x37, 0x9c, 0x0e, 0xd5, 0x4d, + 0xbb, 0xeb, 0xa8, 0x45, 0xae, 0xb7, 0x74, 0x9a, 0x2b, 0x07, 0x6e, 0x22, 0xae, 0x8e, 0x30, 0xa5, + 0x02, 0x39, 0xef, 0xc4, 0xf6, 0xc9, 0x73, 0xb5, 0xcc, 0xd2, 0x54, 0xfd, 0x23, 0x03, 0xb3, 0x67, + 0x67, 0xf6, 0x1e, 0x48, 0x5d, 0xc6, 0x19, 0xf3, 0xfa, 0x1a, 0x37, 0x8a, 0xc5, 0x22, 0xf7, 0x3a, + 0x9a, 0x1f, 0x42, 0xc9, 0xa6, 0x9e, 0x4f, 0x3b, 0x22, 0x75, 0x99, 0x7f, 0x93, 0xef, 0xec, 0x6b, + 0xe4, 0xfb, 0x11, 0xcc, 0x86, 0x4c, 0x75, 0x97, 0xd8, 0xbd, 0xa0, 0x5c, 0x56, 0x5e, 0xe6, 0xb3, + 0xa6, 0x05, 0x7a, 0x7b, 0x4c, 0x0d, 0xd3, 0x02, 0x8e, 0x4d, 0x9d, 0x2e, 0x16, 0xb1, 0x61, 0x61, + 0x22, 0x27, 0x5f, 0xba, 0xc9, 0x20, 0x49, 0x12, 0x1f, 0x8c, 0x0b, 0x20, 0x3f, 0x25, 0x91, 0x3b, + 0xa2, 0x0b, 0x46, 0x35, 0xb0, 0x78, 0x1b, 0x2a, 0x09, 0xf7, 0x33, 0x20, 0x79, 0x3e, 0x71, 0x7d, + 0x9e, 0x37, 0x49, 0x29, 0x41, 0x06, 0x3b, 0x89, 0x77, 0xa3, 0x54, 0xfd, 0x45, 0x82, 0x85, 0x89, + 0xd1, 0x8e, 0xe7, 0x1a, 0xab, 0x03, 0x23, 0x74, 0x48, 0x5d, 0x0c, 0x3b, 0xb3, 0xb1, 0x06, 0x92, + 0x45, 0x0e, 0xa9, 0x85, 0x01, 0x4d, 0x2d, 0x57, 0x56, 0xdf, 0x7f, 0xa5, 0x0c, 0xd6, 0x1a, 0x4c, + 0x05, 0x2b, 0x20, 0x3b, 0xea, 0x3d, 0xa6, 0x7a, 0xeb, 0xd5, 0x54, 0xdb, 0xa8, 0xa1, 0xcc, 0x41, + 0x91, 0x69, 0xea, 0x9c, 0x58, 0x8e, 0x13, 0x93, 0xa1, 0xc0, 0x93, 0xd4, 0xa1, 0xc1, 0x7c, 0x39, + 0x07, 0x33, 0x1d, 0xda, 0x25, 0x43, 0xcb, 0xd7, 0x8f, 0x89, 0x35, 0xa4, 0x3c, 0x6e, 0x45, 0x65, + 0x1e, 0x4a, 0x22, 0x07, 0x26, 0x62, 0x9f, 0xf3, 0xae, 0x90, 0x98, 0xc1, 0x27, 0x1e, 0x66, 0x97, + 0x1b, 0x04, 0x8e, 0xab, 0x25, 0x3b, 0xee, 0xf2, 0x64, 0x82, 0xa3, 0x70, 0x57, 0x7f, 0x4e, 0x43, + 0x96, 0x93, 0x9b, 0x85, 0x52, 0xfb, 0x71, 0x4b, 0xd3, 0xb7, 0x9a, 0x07, 0x1b, 0x0d, 0x4d, 0x4e, + 0x61, 0xcc, 0x80, 0x0b, 0x1e, 0x36, 0x9a, 0xeb, 0x6d, 0x39, 0x1d, 0xfe, 0xbf, 0xbe, 0xdb, 0xbe, + 0x7f, 0x4f, 0xce, 0x84, 0x0a, 0x07, 0x42, 0x90, 0x8d, 0x02, 0xee, 0xae, 0xca, 0x12, 0xde, 0xad, + 0x2c, 0x0c, 0xd4, 0x3f, 0xd7, 0xb6, 0x10, 0x91, 0x8b, 0x4b, 0x10, 0x93, 0xc7, 0xdc, 0x16, 0xb9, + 0x64, 0xa3, 0xd9, 0x6c, 0xc8, 0x85, 0xd0, 0xe6, 0x7e, 0x7b, 0xaf, 0xbe, 0xbb, 0x2d, 0x17, 0x43, + 0x9b, 0xdb, 0x7b, 0xcd, 0x83, 0x96, 0x0c, 0xa1, 0x85, 0x1d, 0x6d, 0x7f, 0x7f, 0x7d, 0x5b, 0x93, + 0x4b, 0x21, 0x62, 0xe3, 0x71, 0x5b, 0xdb, 0x97, 0xcb, 0x31, 0x5a, 0xe8, 0x62, 0x26, 0x74, 0xa1, + 0xed, 0x1e, 0xec, 0xc8, 0x15, 0x8c, 0xd9, 0x8c, 0x70, 0x11, 0x90, 0x98, 0x4d, 0x88, 0x90, 0xa9, + 0x3c, 0x26, 0x22, 0xac, 0xcc, 0xc5, 0x04, 0x88, 0x50, 0xaa, 0x9b, 0x20, 0x89, 0x7a, 0x50, 0xa0, + 0xd2, 0x58, 0xdf, 0xd0, 0x1a, 0x7a, 0xb3, 0xd5, 0xae, 0x37, 0x77, 0xd7, 0x1b, 0x18, 0xbb, 0x50, + 0xb6, 0xa7, 0x7d, 0x7a, 0x50, 0xdf, 0xd3, 0xb6, 0x30, 0x7e, 0x11, 0x59, 0x4b, 0x5b, 0x6f, 0xa3, + 0x2c, 0x53, 0xbd, 0x06, 0x0b, 0x13, 0xdb, 0x26, 0x56, 0xbd, 0xd5, 0x6f, 0x53, 0x30, 0x3f, 0xa9, + 0xc3, 0xe3, 0x35, 0xfe, 0x00, 0x24, 0x51, 0x30, 0x62, 0x9e, 0xdd, 0x9c, 0x38, 0x24, 0x3e, 0x63, + 0x88, 0x33, 0xa6, 0x74, 0x66, 0xca, 0x94, 0x66, 0xba, 0x41, 0xc9, 0x58, 0xa0, 0x4e, 0x35, 0x35, + 0xad, 0xed, 0x78, 0xb7, 0xe2, 0x9a, 0x4e, 0x38, 0xba, 0x3a, 0x9d, 0x64, 0xe0, 0xed, 0xfb, 0x14, + 0x9c, 0x9f, 0xb2, 0x97, 0xe2, 0xce, 0xee, 0x43, 0xae, 0x4f, 0xfd, 0x23, 0x27, 0x18, 0xe8, 0x37, + 0x26, 0x4c, 0x1a, 0x76, 0x7c, 0xc6, 0x88, 0xca, 0x4c, 0xdb, 0x35, 0xc2, 0x7f, 0x40, 0xe9, 0xd7, + 0x14, 0x9c, 0x9b, 0x6c, 0x2b, 0xce, 0x08, 0x9f, 0x0a, 0xa6, 0x3d, 0x18, 0xfa, 0x62, 0x76, 0xa7, + 0xc3, 0x3e, 0x1e, 0xfa, 0xa1, 0x30, 0xc3, 0x85, 0x2b, 0x63, 0x0a, 0x59, 0x4e, 0xe1, 0x9d, 0x29, + 0xdc, 0x83, 0x45, 0xb9, 0x04, 0xb2, 0x61, 0x99, 0xd4, 0xf6, 0x75, 0xcf, 0x77, 0x29, 0xe9, 0x9b, + 0x76, 0x8f, 0xcf, 0xa3, 0xc2, 0x9a, 0xd4, 0x25, 0x96, 0x47, 0x19, 0x80, 0x2d, 0x7b, 0xea, 0x46, + 0x00, 0xb9, 0x08, 0xa0, 0xfa, 0x5b, 0x16, 0x4a, 0xd1, 0xd5, 0xbb, 0x00, 0xe5, 0x27, 0xe4, 0x98, + 0xe8, 0xc1, 0x63, 0x47, 0xdc, 0xe0, 0x12, 0x2c, 0x70, 0x29, 0x52, 0x46, 0x53, 0x86, 0x45, 0x3c, + 0x8f, 0xdf, 0xaf, 0xc0, 0x4f, 0xab, 0x30, 0xcf, 0x4f, 0xfb, 0x38, 0xac, 0xcc, 0x81, 0x45, 0x75, + 0xf6, 0x06, 0xf3, 0xf8, 0x20, 0x0a, 0x89, 0xdc, 0x86, 0xcb, 0x1c, 0xd3, 0xa3, 0x36, 0x75, 0x89, + 0x4f, 0x75, 0xfa, 0xe5, 0x10, 0x0f, 0x74, 0x62, 0x77, 0xf4, 0x23, 0xe2, 0x1d, 0xa9, 0x0b, 0x51, + 0xf4, 0x75, 0x38, 0xcf, 0xd1, 0x48, 0x1a, 0x19, 0xeb, 0xc6, 0x11, 0x35, 0x9e, 0xea, 0x43, 0xbf, + 0xfb, 0x40, 0xfd, 0x7f, 0x14, 0xf6, 0x10, 0xca, 0x2c, 0x5e, 0x7d, 0xf3, 0x05, 0xfa, 0x74, 0x5c, + 0x3e, 0x0d, 0x2b, 0x13, 0x2a, 0x3e, 0x72, 0xc1, 0x5a, 0x73, 0xa4, 0xb0, 0x83, 0x2f, 0x86, 0x35, + 0x69, 0xbf, 0xa5, 0x69, 0x5b, 0x2c, 0x41, 0x3d, 0x27, 0xbc, 0x72, 0x29, 0xb8, 0x94, 0x61, 0x08, + 0xba, 0xf8, 0x9e, 0x1b, 0xbd, 0x98, 0x3c, 0x55, 0x8e, 0xfa, 0xbf, 0x06, 0xe7, 0xc6, 0x97, 0x8a, + 0xa2, 0xe6, 0xa2, 0x28, 0xb4, 0x34, 0x38, 0x39, 0x8d, 0x51, 0xa2, 0x98, 0x8b, 0xfc, 0x35, 0xe9, + 0x52, 0x03, 0x43, 0xd3, 0x51, 0x2f, 0x24, 0x52, 0x88, 0x44, 0xa8, 0x4d, 0x0e, 0x31, 0xb2, 0xc4, + 0xc5, 0x1f, 0x9e, 0xba, 0x14, 0x05, 0x6c, 0xc2, 0xc2, 0xd0, 0x36, 0x6d, 0xcc, 0x0c, 0x1a, 0x60, + 0xef, 0x0a, 0x51, 0x43, 0xea, 0x5f, 0xf9, 0x29, 0xaf, 0x84, 0x83, 0x28, 0x5a, 0xc4, 0xa5, 0xba, + 0x06, 0xe5, 0x68, 0x64, 0x94, 0x22, 0x88, 0xd8, 0xe0, 0x10, 0xc3, 0xc1, 0xb9, 0xd9, 0xdc, 0x62, + 0x23, 0xef, 0x0b, 0x0d, 0xe7, 0x17, 0x8e, 0xde, 0x46, 0xbd, 0xad, 0xe9, 0x7b, 0x07, 0xbb, 0xed, + 0xfa, 0x8e, 0x26, 0x67, 0x6e, 0x15, 0x0b, 0x7f, 0xe7, 0xe5, 0x6f, 0xf0, 0x5f, 0xba, 0xfa, 0x67, + 0x0a, 0x2a, 0xf1, 0x45, 0xae, 0xdc, 0x80, 0x0b, 0xc1, 0x03, 0xd7, 0xa3, 0xbe, 0xfe, 0xcc, 0x74, + 0x79, 0xb2, 0xfa, 0x44, 0x2c, 0xf2, 0xf0, 0x1a, 0x35, 0x58, 0xb2, 0x1d, 0xcc, 0x38, 0x56, 0x04, + 0x71, 0x3b, 0xfa, 0xf8, 0x0b, 0x40, 0x27, 0x06, 0xc6, 0xcb, 0x73, 0xc4, 0xf4, 0x98, 0x12, 0xb2, + 0x4c, 0xf4, 0x08, 0xf7, 0x61, 0x9f, 0x0c, 0x30, 0x66, 0xbe, 0x7b, 0xc2, 0xf7, 0x66, 0xe1, 0x8d, + 0x04, 0x29, 0x7a, 0xd1, 0x1f, 0xd3, 0x50, 0x8e, 0x2e, 0x50, 0xf6, 0x94, 0x30, 0x78, 0x2b, 0xa7, + 0x78, 0x11, 0xbe, 0x7b, 0xe6, 0xba, 0xad, 0x6d, 0xb2, 0x5d, 0xbb, 0x96, 0x13, 0xfb, 0x8d, 0xcd, + 0x47, 0x56, 0x7c, 0x54, 0xbc, 0x66, 0x0a, 0x38, 0x1c, 0xb2, 0x16, 0x79, 0x71, 0x12, 0x6f, 0xe5, + 0x33, 0xee, 0x8b, 0x78, 0xf6, 0x71, 0x11, 0xef, 0xb8, 0x37, 0x52, 0x16, 0x2b, 0x20, 0x71, 0xaa, + 0xd8, 0x21, 0x23, 0xb2, 0xf2, 0xff, 0x94, 0x02, 0x64, 0x37, 0x9b, 0x7b, 0xac, 0x34, 0xb0, 0x16, + 0x84, 0x54, 0x6f, 0xd5, 0xb5, 0x4d, 0xac, 0x8e, 0x68, 0x88, 0xbe, 0x4b, 0x41, 0x29, 0xb2, 0x2f, + 0xd8, 0xc8, 0x23, 0x96, 0xe5, 0x3c, 0xd3, 0x89, 0x65, 0x62, 0x0d, 0x8b, 0xab, 0x9e, 0x71, 0xab, + 0x37, 0x9d, 0xb2, 0xaf, 0x41, 0x4e, 0x6e, 0x95, 0x84, 0xfb, 0xd4, 0xdb, 0x74, 0xff, 0x15, 0x54, + 0xe2, 0xfb, 0x23, 0xe1, 0xfc, 0xea, 0xdb, 0x74, 0xfe, 0x02, 0x66, 0xe2, 0x9b, 0xe3, 0x3f, 0xf4, + 0xfd, 0x43, 0x1a, 0xe6, 0x27, 0x40, 0x94, 0x4f, 0x46, 0x4b, 0x52, 0xac, 0xe9, 0x3b, 0xaf, 0x62, + 0xb6, 0xb6, 0x8b, 0x0a, 0x2d, 0xfc, 0x06, 0x50, 0x54, 0x90, 0x4d, 0xfc, 0x8c, 0xf6, 0x4d, 0xfc, + 0x76, 0x73, 0x47, 0x2f, 0x64, 0xb1, 0x44, 0x17, 0x41, 0x19, 0x38, 0x9e, 0xe9, 0x9b, 0xc7, 0xec, + 0xcb, 0x31, 0x78, 0x3d, 0xb3, 0x7d, 0x9a, 0x65, 0x67, 0x36, 0xed, 0x91, 0xc4, 0x19, 0x6b, 0xb3, + 0x0c, 0xdb, 0x7c, 0x1d, 0x67, 0xc8, 0x86, 0xac, 0x90, 0xb2, 0x35, 0x99, 0x62, 0xd2, 0xd1, 0x12, + 0x1a, 0xbf, 0xc2, 0xcb, 0xec, 0x6b, 0x9e, 0xf4, 0x7a, 0x2e, 0x33, 0x15, 0xc0, 0xf9, 0x2a, 0x5c, + 0xbc, 0x0b, 0x85, 0x90, 0x22, 0x4e, 0x21, 0x76, 0x3f, 0xdc, 0x2b, 0xfc, 0x9b, 0x25, 0x8d, 0xdc, + 0xd0, 0x9a, 0xe9, 0xe9, 0xe3, 0x0f, 0xc7, 0x34, 0x4a, 0x0b, 0xd5, 0x9f, 0x70, 0x68, 0x26, 0x3e, + 0x63, 0xd7, 0xa0, 0x60, 0x39, 0x98, 0x1b, 0x06, 0x12, 0x7f, 0xcc, 0x58, 0x7e, 0xc9, 0x97, 0x6f, + 0xad, 0x31, 0xc2, 0x2f, 0x1a, 0x50, 0x08, 0x7e, 0x63, 0x83, 0x66, 0x07, 0xc4, 0x3f, 0xe2, 0x36, + 0xa4, 0x8d, 0x34, 0x6f, 0xd9, 0xac, 0x37, 0x20, 0x36, 0x8f, 0xba, 0x90, 0x60, 0x28, 0x2d, 0x4a, + 0x3a, 0x7c, 0xd1, 0x3a, 0xfd, 0x3e, 0x06, 0xd5, 0x1b, 0x85, 0xf2, 0x22, 0xcc, 0xf9, 0x2e, 0x31, + 0xad, 0xd8, 0x11, 0x8b, 0x64, 0x71, 0xe3, 0x26, 0xae, 0x47, 0xa7, 0x9f, 0xe4, 0xb4, 0x21, 0x27, + 0x5e, 0x42, 0xde, 0xa3, 0xd4, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x3d, 0xe5, 0x5c, 0x96, 0xdd, + 0x11, 0x00, 0x00, } diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/generator/generator.go b/vendor/github.com/golang/protobuf/protoc-gen-go/generator/generator.go index a5879fe67..c2c96bf72 100644 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/generator/generator.go +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/generator/generator.go @@ -62,7 +62,7 @@ import ( // It is incremented whenever an incompatibility between the generated code and // proto package is introduced; the generated code references // a constant, proto.ProtoPackageIsVersionN (where N is generatedCodeVersion). -const generatedCodeVersion = 2 +const generatedCodeVersion = 1 // A Plugin provides functionality to add to the output during Go code generation, // such as to produce RPC stubs. @@ -264,36 +264,6 @@ type FileDescriptor struct { // PackageName is the package name we'll use in the generated code to refer to this file. func (d *FileDescriptor) PackageName() string { return uniquePackageOf(d.FileDescriptorProto) } -// VarName is the variable name we'll use in the generated code to refer -// to the compressed bytes of this descriptor. It is not exported, so -// it is only valid inside the generated package. -func (d *FileDescriptor) VarName() string { return fmt.Sprintf("fileDescriptor%d", d.index) } - -// goPackageOption interprets the file's go_package option. -// If there is no go_package, it returns ("", "", false). -// If there's a simple name, it returns ("", pkg, true). -// If the option implies an import path, it returns (impPath, pkg, true). -func (d *FileDescriptor) goPackageOption() (impPath, pkg string, ok bool) { - pkg = d.GetOptions().GetGoPackage() - if pkg == "" { - return - } - ok = true - // The presence of a slash implies there's an import path. - slash := strings.LastIndex(pkg, "/") - if slash < 0 { - return - } - impPath, pkg = pkg, pkg[slash+1:] - // A semicolon-delimited suffix overrides the package name. - sc := strings.IndexByte(impPath, ';') - if sc < 0 { - return - } - impPath, pkg = impPath[:sc], impPath[sc+1:] - return -} - // goPackageName returns the Go package name to use in the // generated Go file. The result explicit reports whether the name // came from an option go_package statement. If explicit is false, @@ -301,8 +271,10 @@ func (d *FileDescriptor) goPackageOption() (impPath, pkg string, ok bool) { // or the input file name. func (d *FileDescriptor) goPackageName() (name string, explicit bool) { // Does the file have a "go_package" option? - if _, pkg, ok := d.goPackageOption(); ok { - return pkg, true + if opts := d.Options; opts != nil { + if pkg := opts.GetGoPackage(); pkg != "" { + return pkg, true + } } // Does the file have a package clause? @@ -313,26 +285,6 @@ func (d *FileDescriptor) goPackageName() (name string, explicit bool) { return baseName(d.GetName()), false } -// goFileName returns the output name for the generated Go file. -func (d *FileDescriptor) goFileName() string { - name := *d.Name - if ext := path.Ext(name); ext == ".proto" || ext == ".protodevel" { - name = name[:len(name)-len(ext)] - } - name += ".pb.go" - - // Does the file have a "go_package" option? - // If it does, it may override the filename. - if impPath, _, ok := d.goPackageOption(); ok && impPath != "" { - // Replace the existing dirname with the declared import path. - _, name = path.Split(name) - name = path.Join(impPath, name) - return name - } - - return name -} - func (d *FileDescriptor) addExport(obj Object, sym symbol) { d.exported[obj] = append(d.exported[obj], sym) } @@ -368,6 +320,8 @@ func (ms *messageSymbol) GenerateAlias(g *Generator, pkg string) { if ms.hasExtensions { g.P("func (*", ms.sym, ") ExtensionRangeArray() []", g.Pkg["proto"], ".ExtensionRange ", "{ return (*", remoteSym, ")(nil).ExtensionRangeArray() }") + g.P("func (m *", ms.sym, ") ExtensionMap() map[int32]", g.Pkg["proto"], ".Extension ", + "{ return (*", remoteSym, ")(m).ExtensionMap() }") if ms.isMessageSet { g.P("func (m *", ms.sym, ") Marshal() ([]byte, error) ", "{ return (*", remoteSym, ")(m).Marshal() }") @@ -558,7 +512,7 @@ type Generator struct { Param map[string]string // Command-line parameters. PackageImportPath string // Go import path of the package we're generating code for ImportPrefix string // String to prefix to imported package file names. - ImportMap map[string]string // Mapping from .proto file name to import path + ImportMap map[string]string // Mapping from import name to generated name Pkg map[string]string // The names under which we import support packages @@ -626,6 +580,7 @@ func (g *Generator) CommandLineParameters(parameter string) { } } } + if pluginList != "" { // Amend the set of plugins. enabled := make(map[string]bool) @@ -805,9 +760,9 @@ AllFiles: // and FileDescriptorProtos into file-referenced objects within the Generator. // It also creates the list of files to generate and so should be called before GenerateAllFiles. func (g *Generator) WrapTypes() { - g.allFiles = make([]*FileDescriptor, 0, len(g.Request.ProtoFile)) + g.allFiles = make([]*FileDescriptor, len(g.Request.ProtoFile)) g.allFilesByName = make(map[string]*FileDescriptor, len(g.allFiles)) - for _, f := range g.Request.ProtoFile { + for i, f := range g.Request.ProtoFile { // We must wrap the descriptors before we wrap the enums descs := wrapDescriptors(f) g.buildNestedDescriptors(descs) @@ -823,22 +778,22 @@ func (g *Generator) WrapTypes() { proto3: fileIsProto3(f), } extractComments(fd) - g.allFiles = append(g.allFiles, fd) + g.allFiles[i] = fd g.allFilesByName[f.GetName()] = fd } for _, fd := range g.allFiles { fd.imp = wrapImported(fd.FileDescriptorProto, g) } - g.genFiles = make([]*FileDescriptor, 0, len(g.Request.FileToGenerate)) - for _, fileName := range g.Request.FileToGenerate { - fd := g.allFilesByName[fileName] - if fd == nil { + g.genFiles = make([]*FileDescriptor, len(g.Request.FileToGenerate)) + for i, fileName := range g.Request.FileToGenerate { + g.genFiles[i] = g.allFilesByName[fileName] + if g.genFiles[i] == nil { g.Fail("could not find file named", fileName) } - fd.index = len(g.genFiles) - g.genFiles = append(g.genFiles, fd) + g.genFiles[i].index = i } + g.Response.File = make([]*plugin.CodeGeneratorResponse_File, len(g.genFiles)) } // Scan the descriptors in this file. For each one, build the slice of nested descriptors @@ -902,8 +857,9 @@ func newDescriptor(desc *descriptor.DescriptorProto, parent *Descriptor, file *d } } - for _, field := range desc.Extension { - d.ext = append(d.ext, &ExtensionDescriptor{common{file}, field, d}) + d.ext = make([]*ExtensionDescriptor, len(desc.Extension)) + for i, field := range desc.Extension { + d.ext[i] = &ExtensionDescriptor{common{file}, field, d} } return d @@ -962,9 +918,9 @@ func wrapEnumDescriptors(file *descriptor.FileDescriptorProto, descs []*Descript // Return a slice of all the top-level ExtensionDescriptors defined within this file. func wrapExtensions(file *descriptor.FileDescriptorProto) []*ExtensionDescriptor { - var sl []*ExtensionDescriptor - for _, field := range file.Extension { - sl = append(sl, &ExtensionDescriptor{common{file}, field, nil}) + sl := make([]*ExtensionDescriptor, len(file.Extension)) + for i, field := range file.Extension { + sl[i] = &ExtensionDescriptor{common{file}, field, nil} } return sl } @@ -1133,6 +1089,7 @@ func (g *Generator) GenerateAllFiles() { for _, file := range g.genFiles { genFileMap[file] = true } + i := 0 for _, file := range g.allFiles { g.Reset() g.writeOutput = genFileMap[file] @@ -1140,10 +1097,10 @@ func (g *Generator) GenerateAllFiles() { if !g.writeOutput { continue } - g.Response.File = append(g.Response.File, &plugin.CodeGeneratorResponse_File{ - Name: proto.String(file.goFileName()), - Content: proto.String(g.String()), - }) + g.Response.File[i] = new(plugin.CodeGeneratorResponse_File) + g.Response.File[i].Name = proto.String(goFileName(*file.Name)) + g.Response.File[i].Content = proto.String(g.String()) + i++ } } @@ -1175,11 +1132,10 @@ func (g *Generator) generate(file *FileDescriptor) { // For one file in the package, assert version compatibility. g.P("// This is a compile-time assertion to ensure that this generated file") g.P("// is compatible with the proto package it is being compiled against.") - g.P("// A compilation error at this line likely means your copy of the") - g.P("// proto package needs to be updated.") - g.P("const _ = ", g.Pkg["proto"], ".ProtoPackageIsVersion", generatedCodeVersion, " // please upgrade the proto package") + g.P("const _ = ", g.Pkg["proto"], ".ProtoPackageIsVersion", generatedCodeVersion) g.P() } + for _, td := range g.file.imp { g.generateImported(td) } @@ -1329,7 +1285,7 @@ func (g *Generator) generateImports() { if fd.PackageName() == g.packageName { continue } - filename := fd.goFileName() + filename := goFileName(s) // By default, import path is the dirname of the Go filename. importPath := path.Dir(filename) if substitution, ok := g.ImportMap[s]; ok { @@ -1469,10 +1425,7 @@ func (g *Generator) generateEnum(enum *EnumDescriptor) { indexes = append([]string{strconv.Itoa(m.index)}, indexes...) } indexes = append(indexes, strconv.Itoa(enum.index)) - g.P("func (", ccTypeName, ") EnumDescriptor() ([]byte, []int) { return ", g.file.VarName(), ", []int{", strings.Join(indexes, ", "), "} }") - if enum.file.GetPackage() == "google.protobuf" && enum.GetName() == "NullValue" { - g.P("func (", ccTypeName, `) XXX_WellKnownType() string { return "`, enum.GetName(), `" }`) - } + g.P("func (", ccTypeName, ") EnumDescriptor() ([]byte, []int) { return fileDescriptor", g.file.index, ", []int{", strings.Join(indexes, ", "), "} }") g.P() } @@ -1549,11 +1502,7 @@ func (g *Generator) goTag(message *Descriptor, field *descriptor.FieldDescriptor enum += CamelCaseSlice(obj.TypeName()) } packed := "" - if (field.Options != nil && field.Options.GetPacked()) || - // Per https://developers.google.com/protocol-buffers/docs/proto3#simple: - // "In proto3, repeated fields of scalar numeric types use packed encoding by default." - (message.proto3() && (field.Options == nil || field.Options.Packed == nil) && - isRepeated(field) && isScalar(field)) { + if field.Options != nil && field.Options.GetPacked() { packed = ",packed" } fieldName := field.GetName() @@ -1568,11 +1517,6 @@ func (g *Generator) goTag(message *Descriptor, field *descriptor.FieldDescriptor name = name[i+1:] } } - if json := field.GetJsonName(); json != "" && json != name { - // TODO: escaping might be needed, in which case - // perhaps this should be in its own "json" tag. - name += ",json=" + json - } name = ",name=" + name if message.proto3() { // We only need the extra tag for []byte fields; @@ -1691,8 +1635,7 @@ func (g *Generator) RecordTypeUse(t string) { } // Method names that may be generated. Fields with these names get an -// underscore appended. Any change to this set is a potential incompatible -// API change because it changes generated field names. +// underscore appended. var methodNames = [...]string{ "Reset", "String", @@ -1704,28 +1647,6 @@ var methodNames = [...]string{ "Descriptor", } -// Names of messages in the `google.protobuf` package for which -// we will generate XXX_WellKnownType methods. -var wellKnownTypes = map[string]bool{ - "Any": true, - "Duration": true, - "Empty": true, - "Struct": true, - "Timestamp": true, - - "Value": true, - "ListValue": true, - "DoubleValue": true, - "FloatValue": true, - "Int64Value": true, - "UInt64Value": true, - "Int32Value": true, - "UInt32Value": true, - "BoolValue": true, - "StringValue": true, - "BytesValue": true, -} - // Generate the type and default constant definitions for this Descriptor. func (g *Generator) generateMessage(message *Descriptor) { // The full type name @@ -1877,7 +1798,7 @@ func (g *Generator) generateMessage(message *Descriptor) { g.RecordTypeUse(field.GetTypeName()) } if len(message.ExtensionRange) > 0 { - g.P(g.Pkg["proto"], ".XXX_InternalExtensions `json:\"-\"`") + g.P("XXX_extensions\t\tmap[int32]", g.Pkg["proto"], ".Extension `json:\"-\"`") } if !message.proto3() { g.P("XXX_unrecognized\t[]byte `json:\"-\"`") @@ -1906,15 +1827,13 @@ func (g *Generator) generateMessage(message *Descriptor) { g.P("func (m *", ccTypeName, ") Reset() { *m = ", ccTypeName, "{} }") g.P("func (m *", ccTypeName, ") String() string { return ", g.Pkg["proto"], ".CompactTextString(m) }") g.P("func (*", ccTypeName, ") ProtoMessage() {}") - var indexes []string - for m := message; m != nil; m = m.parent { - indexes = append([]string{strconv.Itoa(m.index)}, indexes...) - } - g.P("func (*", ccTypeName, ") Descriptor() ([]byte, []int) { return ", g.file.VarName(), ", []int{", strings.Join(indexes, ", "), "} }") - // TODO: Revisit the decision to use a XXX_WellKnownType method - // if we change proto.MessageName to work with multiple equivalents. - if message.file.GetPackage() == "google.protobuf" && wellKnownTypes[message.GetName()] { - g.P("func (*", ccTypeName, `) XXX_WellKnownType() string { return "`, message.GetName(), `" }`) + if !message.group { + var indexes []string + for m := message; m != nil; m = m.parent { + // XXX: skip groups? + indexes = append([]string{strconv.Itoa(m.index)}, indexes...) + } + g.P("func (*", ccTypeName, ") Descriptor() ([]byte, []int) { return fileDescriptor", g.file.index, ", []int{", strings.Join(indexes, ", "), "} }") } // Extension support methods @@ -1927,22 +1846,22 @@ func (g *Generator) generateMessage(message *Descriptor) { g.P() g.P("func (m *", ccTypeName, ") Marshal() ([]byte, error) {") g.In() - g.P("return ", g.Pkg["proto"], ".MarshalMessageSet(&m.XXX_InternalExtensions)") + g.P("return ", g.Pkg["proto"], ".MarshalMessageSet(m.ExtensionMap())") g.Out() g.P("}") g.P("func (m *", ccTypeName, ") Unmarshal(buf []byte) error {") g.In() - g.P("return ", g.Pkg["proto"], ".UnmarshalMessageSet(buf, &m.XXX_InternalExtensions)") + g.P("return ", g.Pkg["proto"], ".UnmarshalMessageSet(buf, m.ExtensionMap())") g.Out() g.P("}") g.P("func (m *", ccTypeName, ") MarshalJSON() ([]byte, error) {") g.In() - g.P("return ", g.Pkg["proto"], ".MarshalMessageSetJSON(&m.XXX_InternalExtensions)") + g.P("return ", g.Pkg["proto"], ".MarshalMessageSetJSON(m.XXX_extensions)") g.Out() g.P("}") g.P("func (m *", ccTypeName, ") UnmarshalJSON(buf []byte) error {") g.In() - g.P("return ", g.Pkg["proto"], ".UnmarshalMessageSetJSON(buf, &m.XXX_InternalExtensions)") + g.P("return ", g.Pkg["proto"], ".UnmarshalMessageSetJSON(buf, m.XXX_extensions)") g.Out() g.P("}") g.P("// ensure ", ccTypeName, " satisfies proto.Marshaler and proto.Unmarshaler") @@ -1964,6 +1883,16 @@ func (g *Generator) generateMessage(message *Descriptor) { g.P("return extRange_", ccTypeName) g.Out() g.P("}") + g.P("func (m *", ccTypeName, ") ExtensionMap() map[int32]", g.Pkg["proto"], ".Extension {") + g.In() + g.P("if m.XXX_extensions == nil {") + g.In() + g.P("m.XXX_extensions = make(map[int32]", g.Pkg["proto"], ".Extension)") + g.Out() + g.P("}") + g.P("return m.XXX_extensions") + g.Out() + g.P("}") } // Default constants @@ -2076,6 +2005,11 @@ func (g *Generator) generateMessage(message *Descriptor) { star = "*" } + // In proto3, only generate getters for message fields and oneof fields. + if message.proto3() && *field.Type != descriptor.FieldDescriptorProto_TYPE_MESSAGE && !oneof { + continue + } + // Only export getter symbols for basic types, // and for messages and enums in the same package. // Groups are not exported. @@ -2134,11 +2068,7 @@ func (g *Generator) generateMessage(message *Descriptor) { continue } if !oneof { - if message.proto3() { - g.P("if m != nil {") - } else { - g.P("if m != nil && m." + fname + " != nil {") - } + g.P("if m != nil && m." + fname + " != nil {") g.In() g.P("return " + star + "m." + fname) g.Out() @@ -2556,7 +2486,6 @@ func (g *Generator) generateExtension(ext *ExtensionDescriptor) { g.P("Field: ", field.Number, ",") g.P(`Name: "`, extName, `",`) g.P("Tag: ", tag, ",") - g.P(`Filename: "`, g.file.GetName(), `",`) g.Out() g.P("}") @@ -2612,10 +2541,7 @@ func (g *Generator) generateFileDescriptor(file *FileDescriptor) { w.Close() b = buf.Bytes() - v := file.VarName() - g.P() - g.P("func init() { ", g.Pkg["proto"], ".RegisterFile(", strconv.Quote(*file.Name), ", ", v, ") }") - g.P("var ", v, " = []byte{") + g.P("var fileDescriptor", file.index, " = []byte{") g.In() g.P("// ", len(b), " bytes of a gzipped FileDescriptorProto") for len(b) > 0 { @@ -2719,6 +2645,15 @@ func CamelCaseSlice(elem []string) string { return CamelCase(strings.Join(elem, // dottedSlice turns a sliced name into a dotted name. func dottedSlice(elem []string) string { return strings.Join(elem, ".") } +// Given a .proto file name, return the output name for the generated Go program. +func goFileName(name string) string { + ext := path.Ext(name) + if ext == ".proto" || ext == ".protodevel" { + name = name[0 : len(name)-len(ext)] + } + return name + ".pb.go" +} + // Is this field optional? func isOptional(field *descriptor.FieldDescriptorProto) bool { return field.Label != nil && *field.Label == descriptor.FieldDescriptorProto_LABEL_OPTIONAL @@ -2734,32 +2669,6 @@ func isRepeated(field *descriptor.FieldDescriptorProto) bool { return field.Label != nil && *field.Label == descriptor.FieldDescriptorProto_LABEL_REPEATED } -// Is this field a scalar numeric type? -func isScalar(field *descriptor.FieldDescriptorProto) bool { - if field.Type == nil { - return false - } - switch *field.Type { - case descriptor.FieldDescriptorProto_TYPE_DOUBLE, - descriptor.FieldDescriptorProto_TYPE_FLOAT, - descriptor.FieldDescriptorProto_TYPE_INT64, - descriptor.FieldDescriptorProto_TYPE_UINT64, - descriptor.FieldDescriptorProto_TYPE_INT32, - descriptor.FieldDescriptorProto_TYPE_FIXED64, - descriptor.FieldDescriptorProto_TYPE_FIXED32, - descriptor.FieldDescriptorProto_TYPE_BOOL, - descriptor.FieldDescriptorProto_TYPE_UINT32, - descriptor.FieldDescriptorProto_TYPE_ENUM, - descriptor.FieldDescriptorProto_TYPE_SFIXED32, - descriptor.FieldDescriptorProto_TYPE_SFIXED64, - descriptor.FieldDescriptorProto_TYPE_SINT32, - descriptor.FieldDescriptorProto_TYPE_SINT64: - return true - default: - return false - } -} - // badToUnderscore is the mapping function used to generate Go names from package names, // which can be dotted in the input .proto file. It replaces non-identifier characters such as // dot or dash with underscore. diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/generator/name_test.go b/vendor/github.com/golang/protobuf/protoc-gen-go/generator/name_test.go index a5ebc8533..f926918e4 100644 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/generator/name_test.go +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/generator/name_test.go @@ -33,8 +33,6 @@ package generator import ( "testing" - - "github.com/golang/protobuf/protoc-gen-go/descriptor" ) func TestCamelCase(t *testing.T) { @@ -56,30 +54,3 @@ func TestCamelCase(t *testing.T) { } } } - -func TestGoPackageOption(t *testing.T) { - tests := []struct { - in string - impPath, pkg string - ok bool - }{ - {"", "", "", false}, - {"foo", "", "foo", true}, - {"github.com/golang/bar", "github.com/golang/bar", "bar", true}, - {"github.com/golang/bar;baz", "github.com/golang/bar", "baz", true}, - } - for _, tc := range tests { - d := &FileDescriptor{ - FileDescriptorProto: &descriptor.FileDescriptorProto{ - Options: &descriptor.FileOptions{ - GoPackage: &tc.in, - }, - }, - } - impPath, pkg, ok := d.goPackageOption() - if impPath != tc.impPath || pkg != tc.pkg || ok != tc.ok { - t.Errorf("go_package = %q => (%q, %q, %t), want (%q, %q, %t)", tc.in, - impPath, pkg, ok, tc.impPath, tc.pkg, tc.ok) - } - } -} diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/grpc/grpc.go b/vendor/github.com/golang/protobuf/protoc-gen-go/internal/grpc/grpc.go similarity index 90% rename from vendor/github.com/golang/protobuf/protoc-gen-go/grpc/grpc.go rename to vendor/github.com/golang/protobuf/protoc-gen-go/internal/grpc/grpc.go index 2660e47a2..f33f7011b 100644 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/grpc/grpc.go +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/internal/grpc/grpc.go @@ -44,12 +44,6 @@ import ( "github.com/golang/protobuf/protoc-gen-go/generator" ) -// generatedCodeVersion indicates a version of the generated code. -// It is incremented whenever an incompatibility between the generated code and -// the grpc package is introduced; the generated code references -// a constant, grpc.SupportPackageIsVersionN (where N is generatedCodeVersion). -const generatedCodeVersion = 4 - // Paths for packages used by code generated in this file, // relative to the import_prefix of the generator.Generator. const ( @@ -107,18 +101,10 @@ func (g *grpc) Generate(file *generator.FileDescriptor) { if len(file.FileDescriptorProto.Service) == 0 { return } - g.P("// Reference imports to suppress errors if they are not otherwise used.") g.P("var _ ", contextPkg, ".Context") g.P("var _ ", grpcPkg, ".ClientConn") g.P() - - // Assert version compatibility. - g.P("// This is a compile-time assertion to ensure that this generated file") - g.P("// is compatible with the grpc package it is being compiled against.") - g.P("const _ = ", grpcPkg, ".SupportPackageIsVersion", generatedCodeVersion) - g.P() - for i, service := range file.FileDescriptorProto.Service { g.generateService(file, service, i) } @@ -218,7 +204,7 @@ func (g *grpc) generateService(file *generator.FileDescriptor, service *pb.Servi // Server handler implementations. var handlerNames []string for _, method := range service.Method { - hname := g.generateServerMethod(servName, fullServName, method) + hname := g.generateServerMethod(servName, method) handlerNames = append(handlerNames, hname) } @@ -254,7 +240,6 @@ func (g *grpc) generateService(file *generator.FileDescriptor, service *pb.Servi g.P("},") } g.P("},") - g.P("Metadata: \"", file.GetName(), "\",") g.P("}") g.P() } @@ -379,25 +364,19 @@ func (g *grpc) generateServerSignature(servName string, method *pb.MethodDescrip return methName + "(" + strings.Join(reqArgs, ", ") + ") " + ret } -func (g *grpc) generateServerMethod(servName, fullServName string, method *pb.MethodDescriptorProto) string { +func (g *grpc) generateServerMethod(servName string, method *pb.MethodDescriptorProto) string { methName := generator.CamelCase(method.GetName()) hname := fmt.Sprintf("_%s_%s_Handler", servName, methName) inType := g.typeName(method.GetInputType()) outType := g.typeName(method.GetOutputType()) if !method.GetServerStreaming() && !method.GetClientStreaming() { - g.P("func ", hname, "(srv interface{}, ctx ", contextPkg, ".Context, dec func(interface{}) error, interceptor ", grpcPkg, ".UnaryServerInterceptor) (interface{}, error) {") + g.P("func ", hname, "(srv interface{}, ctx ", contextPkg, ".Context, dec func(interface{}) error) (interface{}, error) {") g.P("in := new(", inType, ")") g.P("if err := dec(in); err != nil { return nil, err }") - g.P("if interceptor == nil { return srv.(", servName, "Server).", methName, "(ctx, in) }") - g.P("info := &", grpcPkg, ".UnaryServerInfo{") - g.P("Server: srv,") - g.P("FullMethod: ", strconv.Quote(fmt.Sprintf("/%s/%s", fullServName, methName)), ",") - g.P("}") - g.P("handler := func(ctx ", contextPkg, ".Context, req interface{}) (interface{}, error) {") - g.P("return srv.(", servName, "Server).", methName, "(ctx, req.(*", inType, "))") - g.P("}") - g.P("return interceptor(ctx, in, info, handler)") + g.P("out, err := srv.(", servName, "Server).", methName, "(ctx, in)") + g.P("if err != nil { return nil, err }") + g.P("return out, nil") g.P("}") g.P() return hname diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/link_grpc.go b/vendor/github.com/golang/protobuf/protoc-gen-go/link_grpc.go index 532a55005..24e490ec4 100644 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/link_grpc.go +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/link_grpc.go @@ -31,4 +31,4 @@ package main -import _ "github.com/golang/protobuf/protoc-gen-go/grpc" +import _ "github.com/golang/protobuf/protoc-gen-go/internal/grpc" diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go b/vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go index 0ff4e13a8..af31f733e 100644 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go @@ -3,7 +3,7 @@ // DO NOT EDIT! /* -Package plugin_go is a generated protocol buffer package. +Package google_protobuf_compiler is a generated protocol buffer package. It is generated from these files: google/protobuf/compiler/plugin.proto @@ -12,7 +12,7 @@ It has these top-level messages: CodeGeneratorRequest CodeGeneratorResponse */ -package plugin_go +package google_protobuf_compiler import proto "github.com/golang/protobuf/proto" import fmt "fmt" @@ -26,16 +26,14 @@ var _ = math.Inf // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion1 // An encoded CodeGeneratorRequest is written to the plugin's stdin. type CodeGeneratorRequest struct { // The .proto files that were explicitly listed on the command-line. The // code generator should generate code only for these files. Each file's // descriptor will be included in proto_file, below. - FileToGenerate []string `protobuf:"bytes,1,rep,name=file_to_generate,json=fileToGenerate" json:"file_to_generate,omitempty"` + FileToGenerate []string `protobuf:"bytes,1,rep,name=file_to_generate" json:"file_to_generate,omitempty"` // The generator parameter passed on the command-line. Parameter *string `protobuf:"bytes,2,opt,name=parameter" json:"parameter,omitempty"` // FileDescriptorProtos for all files in files_to_generate and everything @@ -49,7 +47,7 @@ type CodeGeneratorRequest struct { // the entire set into memory at once. However, as of this writing, this // is not similarly optimized on protoc's end -- it will store all fields in // memory at once before sending them to the plugin. - ProtoFile []*google_protobuf.FileDescriptorProto `protobuf:"bytes,15,rep,name=proto_file,json=protoFile" json:"proto_file,omitempty"` + ProtoFile []*google_protobuf.FileDescriptorProto `protobuf:"bytes,15,rep,name=proto_file" json:"proto_file,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -164,7 +162,7 @@ type CodeGeneratorResponse_File struct { // command line. // // If |insertion_point| is present, |name| must also be present. - InsertionPoint *string `protobuf:"bytes,2,opt,name=insertion_point,json=insertionPoint" json:"insertion_point,omitempty"` + InsertionPoint *string `protobuf:"bytes,2,opt,name=insertion_point" json:"insertion_point,omitempty"` // The file contents. Content *string `protobuf:"bytes,15,opt,name=content" json:"content,omitempty"` XXX_unrecognized []byte `json:"-"` @@ -202,28 +200,23 @@ func init() { proto.RegisterType((*CodeGeneratorResponse_File)(nil), "google.protobuf.compiler.CodeGeneratorResponse.File") } -func init() { proto.RegisterFile("google/protobuf/compiler/plugin.proto", fileDescriptor0) } - var fileDescriptor0 = []byte{ - // 310 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x51, 0xc1, 0x4a, 0xc3, 0x40, - 0x10, 0x25, 0xb6, 0x22, 0x19, 0xa5, 0x95, 0xa5, 0xc2, 0x52, 0x7a, 0x08, 0x45, 0x31, 0xa7, 0x14, - 0x44, 0xf0, 0xde, 0x8a, 0x7a, 0x2c, 0xc1, 0x93, 0x20, 0x21, 0xa6, 0xd3, 0xb0, 0x90, 0xec, 0xac, - 0xb3, 0xdb, 0x2f, 0xf2, 0x9f, 0xfc, 0x1e, 0xd9, 0x4d, 0x5b, 0xa5, 0xd8, 0xdb, 0xce, 0x7b, 0x6f, - 0xe6, 0xbd, 0x9d, 0x81, 0x9b, 0x9a, 0xa8, 0x6e, 0x70, 0x66, 0x98, 0x1c, 0x7d, 0x6c, 0xd6, 0xb3, - 0x8a, 0x5a, 0xa3, 0x1a, 0xe4, 0x99, 0x69, 0x36, 0xb5, 0xd2, 0x59, 0x20, 0x84, 0xec, 0x64, 0xd9, - 0x4e, 0x96, 0xed, 0x64, 0xe3, 0xe4, 0x70, 0xc0, 0x0a, 0x6d, 0xc5, 0xca, 0x38, 0xe2, 0x4e, 0x3d, - 0xfd, 0x8a, 0x60, 0xb4, 0xa0, 0x15, 0x3e, 0xa3, 0x46, 0x2e, 0x1d, 0x71, 0x8e, 0x9f, 0x1b, 0xb4, - 0x4e, 0xa4, 0x70, 0xb9, 0x56, 0x0d, 0x16, 0x8e, 0x8a, 0xba, 0xe3, 0x50, 0x46, 0x49, 0x2f, 0x8d, - 0xf3, 0x81, 0xc7, 0x5f, 0x69, 0xdb, 0x81, 0x62, 0x02, 0xb1, 0x29, 0xb9, 0x6c, 0xd1, 0x21, 0xcb, - 0x93, 0x24, 0x4a, 0xe3, 0xfc, 0x17, 0x10, 0x0b, 0x80, 0xe0, 0x54, 0xf8, 0x2e, 0x39, 0x4c, 0x7a, - 0xe9, 0xf9, 0xdd, 0x75, 0x76, 0x98, 0xf8, 0x49, 0x35, 0xf8, 0xb8, 0xcf, 0xb6, 0xf4, 0x70, 0x1e, - 0x07, 0xd6, 0x33, 0xd3, 0xef, 0x08, 0xae, 0x0e, 0x52, 0x5a, 0x43, 0xda, 0xa2, 0x18, 0xc1, 0x29, - 0x32, 0x13, 0xcb, 0x28, 0x18, 0x77, 0x85, 0x78, 0x81, 0xfe, 0x1f, 0xbb, 0xfb, 0xec, 0xd8, 0x82, - 0xb2, 0x7f, 0x87, 0x86, 0x34, 0x79, 0x98, 0x30, 0x7e, 0x87, 0xbe, 0xaf, 0x84, 0x80, 0xbe, 0x2e, - 0x5b, 0xdc, 0xda, 0x84, 0xb7, 0xb8, 0x85, 0xa1, 0xd2, 0x16, 0xd9, 0x29, 0xd2, 0x85, 0x21, 0xa5, - 0xdd, 0xf6, 0xfb, 0x83, 0x3d, 0xbc, 0xf4, 0xa8, 0x90, 0x70, 0x56, 0x91, 0x76, 0xa8, 0x9d, 0x1c, - 0x06, 0xc1, 0xae, 0x9c, 0x3f, 0xc0, 0xa4, 0xa2, 0xf6, 0x68, 0xbe, 0xf9, 0xc5, 0x32, 0x1c, 0x3a, - 0x2c, 0xc4, 0xbe, 0xc5, 0xdd, 0xd9, 0x8b, 0x9a, 0x7e, 0x02, 0x00, 0x00, 0xff, 0xff, 0x83, 0x7b, - 0x5c, 0x7c, 0x1b, 0x02, 0x00, 0x00, + // 269 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x91, 0xc1, 0x4a, 0xc3, 0x40, + 0x10, 0x86, 0xa9, 0x46, 0xa4, 0x63, 0x25, 0x1a, 0x14, 0x43, 0xf1, 0x10, 0x44, 0xc1, 0x83, 0x6c, + 0x40, 0x3c, 0x78, 0xf2, 0x10, 0x45, 0xaf, 0xc5, 0x17, 0x08, 0x31, 0x9d, 0x86, 0x85, 0x74, 0x67, + 0x9d, 0xdd, 0x1c, 0x7d, 0x21, 0x9f, 0xd2, 0xc9, 0xa6, 0x15, 0x09, 0xf6, 0x14, 0xf8, 0xe7, 0xcf, + 0xf7, 0xcd, 0xb0, 0x70, 0xd3, 0x10, 0x35, 0x2d, 0xe6, 0x96, 0xc9, 0xd3, 0x47, 0xb7, 0xca, 0x6b, + 0x5a, 0x5b, 0xdd, 0x22, 0xe7, 0xb6, 0xed, 0x1a, 0x6d, 0x54, 0x18, 0x24, 0xe9, 0x50, 0x53, 0xdb, + 0x9a, 0xda, 0xd6, 0xe6, 0xd9, 0x18, 0xb0, 0x44, 0x57, 0xb3, 0xb6, 0x9e, 0x78, 0x68, 0x5f, 0x7d, + 0xc1, 0xd9, 0x33, 0x2d, 0xf1, 0x0d, 0x0d, 0x72, 0x25, 0xf1, 0x3b, 0x7e, 0x76, 0xe8, 0x7c, 0x92, + 0xc2, 0xc9, 0x4a, 0x10, 0xa5, 0xa7, 0xb2, 0x19, 0x66, 0x98, 0x4e, 0xb2, 0xfd, 0xdb, 0x69, 0x72, + 0x0a, 0x53, 0x5b, 0x71, 0xb5, 0x46, 0x8f, 0x9c, 0xee, 0x65, 0x13, 0x89, 0x1e, 0x01, 0x02, 0xad, + 0xec, 0x7f, 0x49, 0x63, 0xa9, 0x1d, 0xdd, 0x5f, 0xab, 0xf1, 0x56, 0xaf, 0x32, 0x7c, 0xf9, 0xf5, + 0x2f, 0x82, 0xfe, 0x7b, 0x02, 0xe7, 0x23, 0xbf, 0xb3, 0x64, 0x1c, 0x26, 0xc7, 0x70, 0x80, 0xcc, + 0xc4, 0x62, 0xed, 0x15, 0x05, 0x44, 0x7f, 0xe0, 0x0f, 0x6a, 0xd7, 0xc9, 0xea, 0x5f, 0x5a, 0x70, + 0xcf, 0x9f, 0x20, 0xea, 0xbf, 0xc9, 0x0c, 0x22, 0x23, 0xfb, 0x6f, 0xc8, 0x17, 0x10, 0x6b, 0xa9, + 0xb0, 0xd7, 0x64, 0x4a, 0x4b, 0xda, 0xf8, 0xcd, 0x55, 0x31, 0x1c, 0xd6, 0x64, 0x3c, 0x4a, 0x10, + 0xf7, 0x41, 0x71, 0x07, 0x97, 0xa2, 0xd9, 0xa9, 0x2e, 0x66, 0x8b, 0xf0, 0x2a, 0xe1, 0x32, 0xf7, + 0x13, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x18, 0x2a, 0x2a, 0xbd, 0x01, 0x00, 0x00, } diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/Makefile b/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/Makefile index b1ac45c77..a85cc5655 100644 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/Makefile +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/Makefile @@ -47,7 +47,6 @@ golden: make -B my_test/test.pb.go sed -i '/return.*fileDescriptor/d' my_test/test.pb.go sed -i '/^var fileDescriptor/,/^}/d' my_test/test.pb.go - sed -i '/proto.RegisterFile.*fileDescriptor/d' my_test/test.pb.go gofmt -w my_test/test.pb.go diff -w my_test/test.pb.go my_test/test.pb.go.golden @@ -58,7 +57,7 @@ testbuild: regenerate regenerate: # Invoke protoc once to generate three independent .pb.go files in the same package. - protoc --go_out=. multi/multi1.proto multi/multi2.proto multi/multi3.proto + protoc --go_out=. multi/multi{1,2,3}.proto #extension_test: extension_test.$O # $(LD) -L. -o $@ $< diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/my_test/test.pb.go b/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/my_test/test.pb.go index 9ec3e1292..b0375f026 100644 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/my_test/test.pb.go +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/my_test/test.pb.go @@ -33,9 +33,7 @@ var _ = math.Inf // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion1 type HatType int32 @@ -185,14 +183,14 @@ type Request struct { Hat *HatType `protobuf:"varint,4,opt,name=hat,enum=my.test.HatType,def=1" json:"hat,omitempty"` // optional imp.ImportedMessage.Owner owner = 6; Deadline *float32 `protobuf:"fixed32,7,opt,name=deadline,def=inf" json:"deadline,omitempty"` - Somegroup *Request_SomeGroup `protobuf:"group,8,opt,name=SomeGroup,json=somegroup" json:"somegroup,omitempty"` + Somegroup *Request_SomeGroup `protobuf:"group,8,opt,name=SomeGroup" json:"somegroup,omitempty"` // This is a map field. It will generate map[int32]string. - NameMapping map[int32]string `protobuf:"bytes,14,rep,name=name_mapping,json=nameMapping" json:"name_mapping,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + NameMapping map[int32]string `protobuf:"bytes,14,rep,name=name_mapping" json:"name_mapping,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // This is a map field whose value type is a message. - MsgMapping map[int64]*Reply `protobuf:"bytes,15,rep,name=msg_mapping,json=msgMapping" json:"msg_mapping,omitempty" protobuf_key:"zigzag64,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + MsgMapping map[int64]*Reply `protobuf:"bytes,15,rep,name=msg_mapping" json:"msg_mapping,omitempty" protobuf_key:"zigzag64,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` Reset_ *int32 `protobuf:"varint,12,opt,name=reset" json:"reset,omitempty"` // This field should not conflict with any getters. - GetKey_ *string `protobuf:"bytes,16,opt,name=get_key,json=getKey" json:"get_key,omitempty"` + GetKey_ *string `protobuf:"bytes,16,opt,name=get_key" json:"get_key,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -268,7 +266,7 @@ func (m *Request) GetGetKey_() string { } type Request_SomeGroup struct { - GroupField *int32 `protobuf:"varint,9,opt,name=group_field,json=groupField" json:"group_field,omitempty"` + GroupField *int32 `protobuf:"varint,9,opt,name=group_field" json:"group_field,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -284,10 +282,10 @@ func (m *Request_SomeGroup) GetGroupField() int32 { } type Reply struct { - Found []*Reply_Entry `protobuf:"bytes,1,rep,name=found" json:"found,omitempty"` - CompactKeys []int32 `protobuf:"varint,2,rep,packed,name=compact_keys,json=compactKeys" json:"compact_keys,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + Found []*Reply_Entry `protobuf:"bytes,1,rep,name=found" json:"found,omitempty"` + CompactKeys []int32 `protobuf:"varint,2,rep,packed,name=compact_keys" json:"compact_keys,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *Reply) Reset() { *m = Reply{} } @@ -301,6 +299,12 @@ var extRange_Reply = []proto.ExtensionRange{ func (*Reply) ExtensionRangeArray() []proto.ExtensionRange { return extRange_Reply } +func (m *Reply) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} func (m *Reply) GetFound() []*Reply_Entry { if m != nil { @@ -317,9 +321,9 @@ func (m *Reply) GetCompactKeys() []int32 { } type Reply_Entry struct { - KeyThatNeeds_1234Camel_CasIng *int64 `protobuf:"varint,1,req,name=key_that_needs_1234camel_CasIng,json=keyThatNeeds1234camelCasIng" json:"key_that_needs_1234camel_CasIng,omitempty"` + KeyThatNeeds_1234Camel_CasIng *int64 `protobuf:"varint,1,req,name=key_that_needs_1234camel_CasIng" json:"key_that_needs_1234camel_CasIng,omitempty"` Value *int64 `protobuf:"varint,2,opt,name=value,def=7" json:"value,omitempty"` - XMyFieldName_2 *int64 `protobuf:"varint,3,opt,name=_my_field_name_2,json=myFieldName2" json:"_my_field_name_2,omitempty"` + XMyFieldName_2 *int64 `protobuf:"varint,3,opt,name=_my_field_name_2" json:"_my_field_name_2,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -351,9 +355,9 @@ func (m *Reply_Entry) GetXMyFieldName_2() int64 { } type OtherBase struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *OtherBase) Reset() { *m = OtherBase{} } @@ -367,6 +371,12 @@ var extRange_OtherBase = []proto.ExtensionRange{ func (*OtherBase) ExtensionRangeArray() []proto.ExtensionRange { return extRange_OtherBase } +func (m *OtherBase) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} func (m *OtherBase) GetName() string { if m != nil && m.Name != nil { @@ -424,8 +434,8 @@ func (m *OtherReplyExtensions) GetKey() int32 { } type OldReply struct { - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *OldReply) Reset() { *m = OldReply{} } @@ -433,16 +443,16 @@ func (m *OldReply) String() string { return proto.CompactTextString(m) } func (*OldReply) ProtoMessage() {} func (m *OldReply) Marshal() ([]byte, error) { - return proto.MarshalMessageSet(&m.XXX_InternalExtensions) + return proto.MarshalMessageSet(m.ExtensionMap()) } func (m *OldReply) Unmarshal(buf []byte) error { - return proto.UnmarshalMessageSet(buf, &m.XXX_InternalExtensions) + return proto.UnmarshalMessageSet(buf, m.ExtensionMap()) } func (m *OldReply) MarshalJSON() ([]byte, error) { - return proto.MarshalMessageSetJSON(&m.XXX_InternalExtensions) + return proto.MarshalMessageSetJSON(m.XXX_extensions) } func (m *OldReply) UnmarshalJSON(buf []byte) error { - return proto.UnmarshalMessageSetJSON(buf, &m.XXX_InternalExtensions) + return proto.UnmarshalMessageSetJSON(buf, m.XXX_extensions) } // ensure OldReply satisfies proto.Marshaler and proto.Unmarshaler @@ -456,9 +466,15 @@ var extRange_OldReply = []proto.ExtensionRange{ func (*OldReply) ExtensionRangeArray() []proto.ExtensionRange { return extRange_OldReply } +func (m *OldReply) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} type Communique struct { - MakeMeCry *bool `protobuf:"varint,1,opt,name=make_me_cry,json=makeMeCry" json:"make_me_cry,omitempty"` + MakeMeCry *bool `protobuf:"varint,1,opt,name=make_me_cry" json:"make_me_cry,omitempty"` // This is a oneof, called "union". // // Types that are valid to be assigned to Union: @@ -494,7 +510,7 @@ type Communique_Data struct { Data []byte `protobuf:"bytes,7,opt,name=data,oneof"` } type Communique_TempC struct { - TempC float64 `protobuf:"fixed64,8,opt,name=temp_c,json=tempC,oneof"` + TempC float64 `protobuf:"fixed64,8,opt,name=temp_c,oneof"` } type Communique_Height struct { Height float32 `protobuf:"fixed32,9,opt,name=height,oneof"` @@ -512,7 +528,7 @@ type Communique_Msg struct { Msg *Reply `protobuf:"bytes,13,opt,name=msg,oneof"` } type Communique_Somegroup struct { - Somegroup *Communique_SomeGroup `protobuf:"group,14,opt,name=SomeGroup,json=somegroup,oneof"` + Somegroup *Communique_SomeGroup `protobuf:"group,14,opt,name=SomeGroup,oneof"` } func (*Communique_Number) isCommunique_Union() {} diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/my_test/test.pb.go.golden b/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/my_test/test.pb.go.golden index 9ec3e1292..b0375f026 100644 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/my_test/test.pb.go.golden +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/my_test/test.pb.go.golden @@ -33,9 +33,7 @@ var _ = math.Inf // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion1 type HatType int32 @@ -185,14 +183,14 @@ type Request struct { Hat *HatType `protobuf:"varint,4,opt,name=hat,enum=my.test.HatType,def=1" json:"hat,omitempty"` // optional imp.ImportedMessage.Owner owner = 6; Deadline *float32 `protobuf:"fixed32,7,opt,name=deadline,def=inf" json:"deadline,omitempty"` - Somegroup *Request_SomeGroup `protobuf:"group,8,opt,name=SomeGroup,json=somegroup" json:"somegroup,omitempty"` + Somegroup *Request_SomeGroup `protobuf:"group,8,opt,name=SomeGroup" json:"somegroup,omitempty"` // This is a map field. It will generate map[int32]string. - NameMapping map[int32]string `protobuf:"bytes,14,rep,name=name_mapping,json=nameMapping" json:"name_mapping,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + NameMapping map[int32]string `protobuf:"bytes,14,rep,name=name_mapping" json:"name_mapping,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // This is a map field whose value type is a message. - MsgMapping map[int64]*Reply `protobuf:"bytes,15,rep,name=msg_mapping,json=msgMapping" json:"msg_mapping,omitempty" protobuf_key:"zigzag64,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + MsgMapping map[int64]*Reply `protobuf:"bytes,15,rep,name=msg_mapping" json:"msg_mapping,omitempty" protobuf_key:"zigzag64,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` Reset_ *int32 `protobuf:"varint,12,opt,name=reset" json:"reset,omitempty"` // This field should not conflict with any getters. - GetKey_ *string `protobuf:"bytes,16,opt,name=get_key,json=getKey" json:"get_key,omitempty"` + GetKey_ *string `protobuf:"bytes,16,opt,name=get_key" json:"get_key,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -268,7 +266,7 @@ func (m *Request) GetGetKey_() string { } type Request_SomeGroup struct { - GroupField *int32 `protobuf:"varint,9,opt,name=group_field,json=groupField" json:"group_field,omitempty"` + GroupField *int32 `protobuf:"varint,9,opt,name=group_field" json:"group_field,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -284,10 +282,10 @@ func (m *Request_SomeGroup) GetGroupField() int32 { } type Reply struct { - Found []*Reply_Entry `protobuf:"bytes,1,rep,name=found" json:"found,omitempty"` - CompactKeys []int32 `protobuf:"varint,2,rep,packed,name=compact_keys,json=compactKeys" json:"compact_keys,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + Found []*Reply_Entry `protobuf:"bytes,1,rep,name=found" json:"found,omitempty"` + CompactKeys []int32 `protobuf:"varint,2,rep,packed,name=compact_keys" json:"compact_keys,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *Reply) Reset() { *m = Reply{} } @@ -301,6 +299,12 @@ var extRange_Reply = []proto.ExtensionRange{ func (*Reply) ExtensionRangeArray() []proto.ExtensionRange { return extRange_Reply } +func (m *Reply) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} func (m *Reply) GetFound() []*Reply_Entry { if m != nil { @@ -317,9 +321,9 @@ func (m *Reply) GetCompactKeys() []int32 { } type Reply_Entry struct { - KeyThatNeeds_1234Camel_CasIng *int64 `protobuf:"varint,1,req,name=key_that_needs_1234camel_CasIng,json=keyThatNeeds1234camelCasIng" json:"key_that_needs_1234camel_CasIng,omitempty"` + KeyThatNeeds_1234Camel_CasIng *int64 `protobuf:"varint,1,req,name=key_that_needs_1234camel_CasIng" json:"key_that_needs_1234camel_CasIng,omitempty"` Value *int64 `protobuf:"varint,2,opt,name=value,def=7" json:"value,omitempty"` - XMyFieldName_2 *int64 `protobuf:"varint,3,opt,name=_my_field_name_2,json=myFieldName2" json:"_my_field_name_2,omitempty"` + XMyFieldName_2 *int64 `protobuf:"varint,3,opt,name=_my_field_name_2" json:"_my_field_name_2,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -351,9 +355,9 @@ func (m *Reply_Entry) GetXMyFieldName_2() int64 { } type OtherBase struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *OtherBase) Reset() { *m = OtherBase{} } @@ -367,6 +371,12 @@ var extRange_OtherBase = []proto.ExtensionRange{ func (*OtherBase) ExtensionRangeArray() []proto.ExtensionRange { return extRange_OtherBase } +func (m *OtherBase) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} func (m *OtherBase) GetName() string { if m != nil && m.Name != nil { @@ -424,8 +434,8 @@ func (m *OtherReplyExtensions) GetKey() int32 { } type OldReply struct { - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` } func (m *OldReply) Reset() { *m = OldReply{} } @@ -433,16 +443,16 @@ func (m *OldReply) String() string { return proto.CompactTextString(m) } func (*OldReply) ProtoMessage() {} func (m *OldReply) Marshal() ([]byte, error) { - return proto.MarshalMessageSet(&m.XXX_InternalExtensions) + return proto.MarshalMessageSet(m.ExtensionMap()) } func (m *OldReply) Unmarshal(buf []byte) error { - return proto.UnmarshalMessageSet(buf, &m.XXX_InternalExtensions) + return proto.UnmarshalMessageSet(buf, m.ExtensionMap()) } func (m *OldReply) MarshalJSON() ([]byte, error) { - return proto.MarshalMessageSetJSON(&m.XXX_InternalExtensions) + return proto.MarshalMessageSetJSON(m.XXX_extensions) } func (m *OldReply) UnmarshalJSON(buf []byte) error { - return proto.UnmarshalMessageSetJSON(buf, &m.XXX_InternalExtensions) + return proto.UnmarshalMessageSetJSON(buf, m.XXX_extensions) } // ensure OldReply satisfies proto.Marshaler and proto.Unmarshaler @@ -456,9 +466,15 @@ var extRange_OldReply = []proto.ExtensionRange{ func (*OldReply) ExtensionRangeArray() []proto.ExtensionRange { return extRange_OldReply } +func (m *OldReply) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} type Communique struct { - MakeMeCry *bool `protobuf:"varint,1,opt,name=make_me_cry,json=makeMeCry" json:"make_me_cry,omitempty"` + MakeMeCry *bool `protobuf:"varint,1,opt,name=make_me_cry" json:"make_me_cry,omitempty"` // This is a oneof, called "union". // // Types that are valid to be assigned to Union: @@ -494,7 +510,7 @@ type Communique_Data struct { Data []byte `protobuf:"bytes,7,opt,name=data,oneof"` } type Communique_TempC struct { - TempC float64 `protobuf:"fixed64,8,opt,name=temp_c,json=tempC,oneof"` + TempC float64 `protobuf:"fixed64,8,opt,name=temp_c,oneof"` } type Communique_Height struct { Height float32 `protobuf:"fixed32,9,opt,name=height,oneof"` @@ -512,7 +528,7 @@ type Communique_Msg struct { Msg *Reply `protobuf:"bytes,13,opt,name=msg,oneof"` } type Communique_Somegroup struct { - Somegroup *Communique_SomeGroup `protobuf:"group,14,opt,name=SomeGroup,json=somegroup,oneof"` + Somegroup *Communique_SomeGroup `protobuf:"group,14,opt,name=SomeGroup,oneof"` } func (*Communique_Number) isCommunique_Union() {} diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/proto3.proto b/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/proto3.proto index 869b9af5a..c994914e4 100644 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/proto3.proto +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/testdata/proto3.proto @@ -44,7 +44,6 @@ message Request { repeated int64 key = 2; Flavour taste = 3; Book book = 4; - repeated int64 unpacked = 5 [packed=false]; } message Book { diff --git a/vendor/github.com/golang/protobuf/ptypes/any.go b/vendor/github.com/golang/protobuf/ptypes/any.go deleted file mode 100644 index 89e07ae19..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/any.go +++ /dev/null @@ -1,136 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2016 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package ptypes - -// This file implements functions to marshal proto.Message to/from -// google.protobuf.Any message. - -import ( - "fmt" - "reflect" - "strings" - - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes/any" -) - -const googleApis = "type.googleapis.com/" - -// AnyMessageName returns the name of the message contained in a google.protobuf.Any message. -// -// Note that regular type assertions should be done using the Is -// function. AnyMessageName is provided for less common use cases like filtering a -// sequence of Any messages based on a set of allowed message type names. -func AnyMessageName(any *any.Any) (string, error) { - slash := strings.LastIndex(any.TypeUrl, "/") - if slash < 0 { - return "", fmt.Errorf("message type url %q is invalid", any.TypeUrl) - } - return any.TypeUrl[slash+1:], nil -} - -// MarshalAny takes the protocol buffer and encodes it into google.protobuf.Any. -func MarshalAny(pb proto.Message) (*any.Any, error) { - value, err := proto.Marshal(pb) - if err != nil { - return nil, err - } - return &any.Any{TypeUrl: googleApis + proto.MessageName(pb), Value: value}, nil -} - -// DynamicAny is a value that can be passed to UnmarshalAny to automatically -// allocate a proto.Message for the type specified in a google.protobuf.Any -// message. The allocated message is stored in the embedded proto.Message. -// -// Example: -// -// var x ptypes.DynamicAny -// if err := ptypes.UnmarshalAny(a, &x); err != nil { ... } -// fmt.Printf("unmarshaled message: %v", x.Message) -type DynamicAny struct { - proto.Message -} - -// Empty returns a new proto.Message of the type specified in a -// google.protobuf.Any message. It returns an error if corresponding message -// type isn't linked in. -func Empty(any *any.Any) (proto.Message, error) { - aname, err := AnyMessageName(any) - if err != nil { - return nil, err - } - - t := proto.MessageType(aname) - if t == nil { - return nil, fmt.Errorf("any: message type %q isn't linked in", aname) - } - return reflect.New(t.Elem()).Interface().(proto.Message), nil -} - -// UnmarshalAny parses the protocol buffer representation in a google.protobuf.Any -// message and places the decoded result in pb. It returns an error if type of -// contents of Any message does not match type of pb message. -// -// pb can be a proto.Message, or a *DynamicAny. -func UnmarshalAny(any *any.Any, pb proto.Message) error { - if d, ok := pb.(*DynamicAny); ok { - if d.Message == nil { - var err error - d.Message, err = Empty(any) - if err != nil { - return err - } - } - return UnmarshalAny(any, d.Message) - } - - aname, err := AnyMessageName(any) - if err != nil { - return err - } - - mname := proto.MessageName(pb) - if aname != mname { - return fmt.Errorf("mismatched message type: got %q want %q", aname, mname) - } - return proto.Unmarshal(any.Value, pb) -} - -// Is returns true if any value contains a given message type. -func Is(any *any.Any, pb proto.Message) bool { - aname, err := AnyMessageName(any) - if err != nil { - return false - } - - return aname == proto.MessageName(pb) -} diff --git a/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go b/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go deleted file mode 100644 index f2c6906b9..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go +++ /dev/null @@ -1,155 +0,0 @@ -// Code generated by protoc-gen-go. -// source: github.com/golang/protobuf/ptypes/any/any.proto -// DO NOT EDIT! - -/* -Package any is a generated protocol buffer package. - -It is generated from these files: - github.com/golang/protobuf/ptypes/any/any.proto - -It has these top-level messages: - Any -*/ -package any - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -// `Any` contains an arbitrary serialized protocol buffer message along with a -// URL that describes the type of the serialized message. -// -// Protobuf library provides support to pack/unpack Any values in the form -// of utility functions or additional generated methods of the Any type. -// -// Example 1: Pack and unpack a message in C++. -// -// Foo foo = ...; -// Any any; -// any.PackFrom(foo); -// ... -// if (any.UnpackTo(&foo)) { -// ... -// } -// -// Example 2: Pack and unpack a message in Java. -// -// Foo foo = ...; -// Any any = Any.pack(foo); -// ... -// if (any.is(Foo.class)) { -// foo = any.unpack(Foo.class); -// } -// -// Example 3: Pack and unpack a message in Python. -// -// foo = Foo(...) -// any = Any() -// any.Pack(foo) -// ... -// if any.Is(Foo.DESCRIPTOR): -// any.Unpack(foo) -// ... -// -// The pack methods provided by protobuf library will by default use -// 'type.googleapis.com/full.type.name' as the type URL and the unpack -// methods only use the fully qualified type name after the last '/' -// in the type URL, for example "foo.bar.com/x/y.z" will yield type -// name "y.z". -// -// -// JSON -// ==== -// The JSON representation of an `Any` value uses the regular -// representation of the deserialized, embedded message, with an -// additional field `@type` which contains the type URL. Example: -// -// package google.profile; -// message Person { -// string first_name = 1; -// string last_name = 2; -// } -// -// { -// "@type": "type.googleapis.com/google.profile.Person", -// "firstName": , -// "lastName": -// } -// -// If the embedded message type is well-known and has a custom JSON -// representation, that representation will be embedded adding a field -// `value` which holds the custom JSON in addition to the `@type` -// field. Example (for message [google.protobuf.Duration][]): -// -// { -// "@type": "type.googleapis.com/google.protobuf.Duration", -// "value": "1.212s" -// } -// -type Any struct { - // A URL/resource name whose content describes the type of the - // serialized protocol buffer message. - // - // For URLs which use the scheme `http`, `https`, or no scheme, the - // following restrictions and interpretations apply: - // - // * If no scheme is provided, `https` is assumed. - // * The last segment of the URL's path must represent the fully - // qualified name of the type (as in `path/google.protobuf.Duration`). - // The name should be in a canonical form (e.g., leading "." is - // not accepted). - // * An HTTP GET on the URL must yield a [google.protobuf.Type][] - // value in binary format, or produce an error. - // * Applications are allowed to cache lookup results based on the - // URL, or have them precompiled into a binary to avoid any - // lookup. Therefore, binary compatibility needs to be preserved - // on changes to types. (Use versioned type names to manage - // breaking changes.) - // - // Schemes other than `http`, `https` (or the empty scheme) might be - // used with implementation specific semantics. - // - TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl" json:"type_url,omitempty"` - // Must be a valid serialized protocol buffer of the above specified type. - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (m *Any) Reset() { *m = Any{} } -func (m *Any) String() string { return proto.CompactTextString(m) } -func (*Any) ProtoMessage() {} -func (*Any) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (*Any) XXX_WellKnownType() string { return "Any" } - -func init() { - proto.RegisterType((*Any)(nil), "google.protobuf.Any") -} - -func init() { proto.RegisterFile("github.com/golang/protobuf/ptypes/any/any.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 187 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xd2, 0x4f, 0xcf, 0x2c, 0xc9, - 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0xd7, 0x2f, 0x28, - 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0xcc, - 0xab, 0x04, 0x61, 0x3d, 0xb0, 0xb8, 0x10, 0x7f, 0x7a, 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, 0x1e, 0x4c, - 0x95, 0x92, 0x19, 0x17, 0xb3, 0x63, 0x5e, 0xa5, 0x90, 0x24, 0x17, 0x07, 0x48, 0x79, 0x7c, 0x69, - 0x51, 0x8e, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x3b, 0x88, 0x1f, 0x5a, 0x94, 0x23, 0x24, - 0xc2, 0xc5, 0x5a, 0x96, 0x98, 0x53, 0x9a, 0x2a, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x13, 0x04, 0xe1, - 0x38, 0x15, 0x71, 0x09, 0x27, 0xe7, 0xe7, 0xea, 0xa1, 0x19, 0xe7, 0xc4, 0xe1, 0x98, 0x57, 0x19, - 0x00, 0xe2, 0x04, 0x30, 0x46, 0xa9, 0x12, 0xe5, 0xb8, 0x05, 0x8c, 0x8c, 0x8b, 0x98, 0x98, 0xdd, - 0x03, 0x9c, 0x56, 0x31, 0xc9, 0xb9, 0x43, 0x4c, 0x0b, 0x80, 0xaa, 0xd2, 0x0b, 0x4f, 0xcd, 0xc9, - 0xf1, 0xce, 0xcb, 0x2f, 0xcf, 0x0b, 0x01, 0xa9, 0x4e, 0x62, 0x03, 0x6b, 0x37, 0x06, 0x04, 0x00, - 0x00, 0xff, 0xff, 0xc6, 0x4d, 0x03, 0x23, 0xf6, 0x00, 0x00, 0x00, -} diff --git a/vendor/github.com/golang/protobuf/ptypes/any/any.proto b/vendor/github.com/golang/protobuf/ptypes/any/any.proto deleted file mode 100644 index 81dcf46cc..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/any/any.proto +++ /dev/null @@ -1,140 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "github.com/golang/protobuf/ptypes/any"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "AnyProto"; -option java_multiple_files = true; -option java_generate_equals_and_hash = true; -option objc_class_prefix = "GPB"; - -// `Any` contains an arbitrary serialized protocol buffer message along with a -// URL that describes the type of the serialized message. -// -// Protobuf library provides support to pack/unpack Any values in the form -// of utility functions or additional generated methods of the Any type. -// -// Example 1: Pack and unpack a message in C++. -// -// Foo foo = ...; -// Any any; -// any.PackFrom(foo); -// ... -// if (any.UnpackTo(&foo)) { -// ... -// } -// -// Example 2: Pack and unpack a message in Java. -// -// Foo foo = ...; -// Any any = Any.pack(foo); -// ... -// if (any.is(Foo.class)) { -// foo = any.unpack(Foo.class); -// } -// -// Example 3: Pack and unpack a message in Python. -// -// foo = Foo(...) -// any = Any() -// any.Pack(foo) -// ... -// if any.Is(Foo.DESCRIPTOR): -// any.Unpack(foo) -// ... -// -// The pack methods provided by protobuf library will by default use -// 'type.googleapis.com/full.type.name' as the type URL and the unpack -// methods only use the fully qualified type name after the last '/' -// in the type URL, for example "foo.bar.com/x/y.z" will yield type -// name "y.z". -// -// -// JSON -// ==== -// The JSON representation of an `Any` value uses the regular -// representation of the deserialized, embedded message, with an -// additional field `@type` which contains the type URL. Example: -// -// package google.profile; -// message Person { -// string first_name = 1; -// string last_name = 2; -// } -// -// { -// "@type": "type.googleapis.com/google.profile.Person", -// "firstName": , -// "lastName": -// } -// -// If the embedded message type is well-known and has a custom JSON -// representation, that representation will be embedded adding a field -// `value` which holds the custom JSON in addition to the `@type` -// field. Example (for message [google.protobuf.Duration][]): -// -// { -// "@type": "type.googleapis.com/google.protobuf.Duration", -// "value": "1.212s" -// } -// -message Any { - // A URL/resource name whose content describes the type of the - // serialized protocol buffer message. - // - // For URLs which use the scheme `http`, `https`, or no scheme, the - // following restrictions and interpretations apply: - // - // * If no scheme is provided, `https` is assumed. - // * The last segment of the URL's path must represent the fully - // qualified name of the type (as in `path/google.protobuf.Duration`). - // The name should be in a canonical form (e.g., leading "." is - // not accepted). - // * An HTTP GET on the URL must yield a [google.protobuf.Type][] - // value in binary format, or produce an error. - // * Applications are allowed to cache lookup results based on the - // URL, or have them precompiled into a binary to avoid any - // lookup. Therefore, binary compatibility needs to be preserved - // on changes to types. (Use versioned type names to manage - // breaking changes.) - // - // Schemes other than `http`, `https` (or the empty scheme) might be - // used with implementation specific semantics. - // - string type_url = 1; - - // Must be a valid serialized protocol buffer of the above specified type. - bytes value = 2; -} diff --git a/vendor/github.com/golang/protobuf/ptypes/any_test.go b/vendor/github.com/golang/protobuf/ptypes/any_test.go deleted file mode 100644 index ed675b489..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/any_test.go +++ /dev/null @@ -1,113 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2016 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package ptypes - -import ( - "testing" - - "github.com/golang/protobuf/proto" - pb "github.com/golang/protobuf/protoc-gen-go/descriptor" - "github.com/golang/protobuf/ptypes/any" -) - -func TestMarshalUnmarshal(t *testing.T) { - orig := &any.Any{Value: []byte("test")} - - packed, err := MarshalAny(orig) - if err != nil { - t.Errorf("MarshalAny(%+v): got: _, %v exp: _, nil", orig, err) - } - - unpacked := &any.Any{} - err = UnmarshalAny(packed, unpacked) - if err != nil || !proto.Equal(unpacked, orig) { - t.Errorf("got: %v, %+v; want nil, %+v", err, unpacked, orig) - } -} - -func TestIs(t *testing.T) { - a, err := MarshalAny(&pb.FileDescriptorProto{}) - if err != nil { - t.Fatal(err) - } - if Is(a, &pb.DescriptorProto{}) { - t.Error("FileDescriptorProto is not a DescriptorProto, but Is says it is") - } - if !Is(a, &pb.FileDescriptorProto{}) { - t.Error("FileDescriptorProto is indeed a FileDescriptorProto, but Is says it is not") - } -} - -func TestIsDifferentUrlPrefixes(t *testing.T) { - m := &pb.FileDescriptorProto{} - a := &any.Any{TypeUrl: "foo/bar/" + proto.MessageName(m)} - if !Is(a, m) { - t.Errorf("message with type url %q didn't satisfy Is for type %q", a.TypeUrl, proto.MessageName(m)) - } -} - -func TestUnmarshalDynamic(t *testing.T) { - want := &pb.FileDescriptorProto{Name: proto.String("foo")} - a, err := MarshalAny(want) - if err != nil { - t.Fatal(err) - } - var got DynamicAny - if err := UnmarshalAny(a, &got); err != nil { - t.Fatal(err) - } - if !proto.Equal(got.Message, want) { - t.Errorf("invalid result from UnmarshalAny, got %q want %q", got.Message, want) - } -} - -func TestEmpty(t *testing.T) { - want := &pb.FileDescriptorProto{} - a, err := MarshalAny(want) - if err != nil { - t.Fatal(err) - } - got, err := Empty(a) - if err != nil { - t.Fatal(err) - } - if !proto.Equal(got, want) { - t.Errorf("unequal empty message, got %q, want %q", got, want) - } - - // that's a valid type_url for a message which shouldn't be linked into this - // test binary. We want an error. - a.TypeUrl = "type.googleapis.com/google.protobuf.FieldMask" - if _, err := Empty(a); err == nil { - t.Errorf("got no error for an attempt to create a message of type %q, which shouldn't be linked in", a.TypeUrl) - } -} diff --git a/vendor/github.com/golang/protobuf/ptypes/doc.go b/vendor/github.com/golang/protobuf/ptypes/doc.go deleted file mode 100644 index c0d595da7..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/doc.go +++ /dev/null @@ -1,35 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2016 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* -Package ptypes contains code for interacting with well-known types. -*/ -package ptypes diff --git a/vendor/github.com/golang/protobuf/ptypes/duration.go b/vendor/github.com/golang/protobuf/ptypes/duration.go deleted file mode 100644 index 65cb0f8eb..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/duration.go +++ /dev/null @@ -1,102 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2016 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package ptypes - -// This file implements conversions between google.protobuf.Duration -// and time.Duration. - -import ( - "errors" - "fmt" - "time" - - durpb "github.com/golang/protobuf/ptypes/duration" -) - -const ( - // Range of a durpb.Duration in seconds, as specified in - // google/protobuf/duration.proto. This is about 10,000 years in seconds. - maxSeconds = int64(10000 * 365.25 * 24 * 60 * 60) - minSeconds = -maxSeconds -) - -// validateDuration determines whether the durpb.Duration is valid according to the -// definition in google/protobuf/duration.proto. A valid durpb.Duration -// may still be too large to fit into a time.Duration (the range of durpb.Duration -// is about 10,000 years, and the range of time.Duration is about 290). -func validateDuration(d *durpb.Duration) error { - if d == nil { - return errors.New("duration: nil Duration") - } - if d.Seconds < minSeconds || d.Seconds > maxSeconds { - return fmt.Errorf("duration: %v: seconds out of range", d) - } - if d.Nanos <= -1e9 || d.Nanos >= 1e9 { - return fmt.Errorf("duration: %v: nanos out of range", d) - } - // Seconds and Nanos must have the same sign, unless d.Nanos is zero. - if (d.Seconds < 0 && d.Nanos > 0) || (d.Seconds > 0 && d.Nanos < 0) { - return fmt.Errorf("duration: %v: seconds and nanos have different signs", d) - } - return nil -} - -// Duration converts a durpb.Duration to a time.Duration. Duration -// returns an error if the durpb.Duration is invalid or is too large to be -// represented in a time.Duration. -func Duration(p *durpb.Duration) (time.Duration, error) { - if err := validateDuration(p); err != nil { - return 0, err - } - d := time.Duration(p.Seconds) * time.Second - if int64(d/time.Second) != p.Seconds { - return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p) - } - if p.Nanos != 0 { - d += time.Duration(p.Nanos) - if (d < 0) != (p.Nanos < 0) { - return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p) - } - } - return d, nil -} - -// DurationProto converts a time.Duration to a durpb.Duration. -func DurationProto(d time.Duration) *durpb.Duration { - nanos := d.Nanoseconds() - secs := nanos / 1e9 - nanos -= secs * 1e9 - return &durpb.Duration{ - Seconds: secs, - Nanos: int32(nanos), - } -} diff --git a/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go b/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go deleted file mode 100644 index 569748346..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go +++ /dev/null @@ -1,114 +0,0 @@ -// Code generated by protoc-gen-go. -// source: github.com/golang/protobuf/ptypes/duration/duration.proto -// DO NOT EDIT! - -/* -Package duration is a generated protocol buffer package. - -It is generated from these files: - github.com/golang/protobuf/ptypes/duration/duration.proto - -It has these top-level messages: - Duration -*/ -package duration - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -// A Duration represents a signed, fixed-length span of time represented -// as a count of seconds and fractions of seconds at nanosecond -// resolution. It is independent of any calendar and concepts like "day" -// or "month". It is related to Timestamp in that the difference between -// two Timestamp values is a Duration and it can be added or subtracted -// from a Timestamp. Range is approximately +-10,000 years. -// -// Example 1: Compute Duration from two Timestamps in pseudo code. -// -// Timestamp start = ...; -// Timestamp end = ...; -// Duration duration = ...; -// -// duration.seconds = end.seconds - start.seconds; -// duration.nanos = end.nanos - start.nanos; -// -// if (duration.seconds < 0 && duration.nanos > 0) { -// duration.seconds += 1; -// duration.nanos -= 1000000000; -// } else if (durations.seconds > 0 && duration.nanos < 0) { -// duration.seconds -= 1; -// duration.nanos += 1000000000; -// } -// -// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. -// -// Timestamp start = ...; -// Duration duration = ...; -// Timestamp end = ...; -// -// end.seconds = start.seconds + duration.seconds; -// end.nanos = start.nanos + duration.nanos; -// -// if (end.nanos < 0) { -// end.seconds -= 1; -// end.nanos += 1000000000; -// } else if (end.nanos >= 1000000000) { -// end.seconds += 1; -// end.nanos -= 1000000000; -// } -// -// -type Duration struct { - // Signed seconds of the span of time. Must be from -315,576,000,000 - // to +315,576,000,000 inclusive. - Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"` - // Signed fractions of a second at nanosecond resolution of the span - // of time. Durations less than one second are represented with a 0 - // `seconds` field and a positive or negative `nanos` field. For durations - // of one second or more, a non-zero value for the `nanos` field must be - // of the same sign as the `seconds` field. Must be from -999,999,999 - // to +999,999,999 inclusive. - Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"` -} - -func (m *Duration) Reset() { *m = Duration{} } -func (m *Duration) String() string { return proto.CompactTextString(m) } -func (*Duration) ProtoMessage() {} -func (*Duration) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (*Duration) XXX_WellKnownType() string { return "Duration" } - -func init() { - proto.RegisterType((*Duration)(nil), "google.protobuf.Duration") -} - -func init() { - proto.RegisterFile("github.com/golang/protobuf/ptypes/duration/duration.proto", fileDescriptor0) -} - -var fileDescriptor0 = []byte{ - // 189 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xb2, 0x4c, 0xcf, 0x2c, 0xc9, - 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0xd7, 0x2f, 0x28, - 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0x29, - 0x2d, 0x4a, 0x2c, 0xc9, 0xcc, 0xcf, 0x83, 0x33, 0xf4, 0xc0, 0x2a, 0x84, 0xf8, 0xd3, 0xf3, 0xf3, - 0xd3, 0x73, 0x52, 0xf5, 0x60, 0xea, 0x95, 0xac, 0xb8, 0x38, 0x5c, 0xa0, 0x4a, 0x84, 0x24, 0xb8, - 0xd8, 0x8b, 0x53, 0x93, 0xf3, 0xf3, 0x52, 0x8a, 0x25, 0x18, 0x15, 0x18, 0x35, 0x98, 0x83, 0x60, - 0x5c, 0x21, 0x11, 0x2e, 0xd6, 0xbc, 0xc4, 0xbc, 0xfc, 0x62, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xd6, - 0x20, 0x08, 0xc7, 0xa9, 0x86, 0x4b, 0x38, 0x39, 0x3f, 0x57, 0x0f, 0xcd, 0x48, 0x27, 0x5e, 0x98, - 0x81, 0x01, 0x20, 0x91, 0x00, 0xc6, 0x28, 0x2d, 0xe2, 0xdd, 0xbb, 0x80, 0x91, 0x71, 0x11, 0x13, - 0xb3, 0x7b, 0x80, 0xd3, 0x2a, 0x26, 0x39, 0x77, 0x88, 0xb9, 0x01, 0x50, 0xa5, 0x7a, 0xe1, 0xa9, - 0x39, 0x39, 0xde, 0x79, 0xf9, 0xe5, 0x79, 0x21, 0x20, 0x2d, 0x49, 0x6c, 0x60, 0x33, 0x8c, 0x01, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x62, 0xfb, 0xb1, 0x51, 0x0e, 0x01, 0x00, 0x00, -} diff --git a/vendor/github.com/golang/protobuf/ptypes/duration/duration.proto b/vendor/github.com/golang/protobuf/ptypes/duration/duration.proto deleted file mode 100644 index 96c1796d6..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/duration/duration.proto +++ /dev/null @@ -1,98 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "github.com/golang/protobuf/ptypes/duration"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "DurationProto"; -option java_multiple_files = true; -option java_generate_equals_and_hash = true; -option objc_class_prefix = "GPB"; - -// A Duration represents a signed, fixed-length span of time represented -// as a count of seconds and fractions of seconds at nanosecond -// resolution. It is independent of any calendar and concepts like "day" -// or "month". It is related to Timestamp in that the difference between -// two Timestamp values is a Duration and it can be added or subtracted -// from a Timestamp. Range is approximately +-10,000 years. -// -// Example 1: Compute Duration from two Timestamps in pseudo code. -// -// Timestamp start = ...; -// Timestamp end = ...; -// Duration duration = ...; -// -// duration.seconds = end.seconds - start.seconds; -// duration.nanos = end.nanos - start.nanos; -// -// if (duration.seconds < 0 && duration.nanos > 0) { -// duration.seconds += 1; -// duration.nanos -= 1000000000; -// } else if (durations.seconds > 0 && duration.nanos < 0) { -// duration.seconds -= 1; -// duration.nanos += 1000000000; -// } -// -// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. -// -// Timestamp start = ...; -// Duration duration = ...; -// Timestamp end = ...; -// -// end.seconds = start.seconds + duration.seconds; -// end.nanos = start.nanos + duration.nanos; -// -// if (end.nanos < 0) { -// end.seconds -= 1; -// end.nanos += 1000000000; -// } else if (end.nanos >= 1000000000) { -// end.seconds += 1; -// end.nanos -= 1000000000; -// } -// -// -message Duration { - - // Signed seconds of the span of time. Must be from -315,576,000,000 - // to +315,576,000,000 inclusive. - int64 seconds = 1; - - // Signed fractions of a second at nanosecond resolution of the span - // of time. Durations less than one second are represented with a 0 - // `seconds` field and a positive or negative `nanos` field. For durations - // of one second or more, a non-zero value for the `nanos` field must be - // of the same sign as the `seconds` field. Must be from -999,999,999 - // to +999,999,999 inclusive. - int32 nanos = 2; -} diff --git a/vendor/github.com/golang/protobuf/ptypes/duration_test.go b/vendor/github.com/golang/protobuf/ptypes/duration_test.go deleted file mode 100644 index e761289f1..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/duration_test.go +++ /dev/null @@ -1,121 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2016 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package ptypes - -import ( - "math" - "testing" - "time" - - "github.com/golang/protobuf/proto" - durpb "github.com/golang/protobuf/ptypes/duration" -) - -const ( - minGoSeconds = math.MinInt64 / int64(1e9) - maxGoSeconds = math.MaxInt64 / int64(1e9) -) - -var durationTests = []struct { - proto *durpb.Duration - isValid bool - inRange bool - dur time.Duration -}{ - // The zero duration. - {&durpb.Duration{0, 0}, true, true, 0}, - // Some ordinary non-zero durations. - {&durpb.Duration{100, 0}, true, true, 100 * time.Second}, - {&durpb.Duration{-100, 0}, true, true, -100 * time.Second}, - {&durpb.Duration{100, 987}, true, true, 100*time.Second + 987}, - {&durpb.Duration{-100, -987}, true, true, -(100*time.Second + 987)}, - // The largest duration representable in Go. - {&durpb.Duration{maxGoSeconds, int32(math.MaxInt64 - 1e9*maxGoSeconds)}, true, true, math.MaxInt64}, - // The smallest duration representable in Go. - {&durpb.Duration{minGoSeconds, int32(math.MinInt64 - 1e9*minGoSeconds)}, true, true, math.MinInt64}, - {nil, false, false, 0}, - {&durpb.Duration{-100, 987}, false, false, 0}, - {&durpb.Duration{100, -987}, false, false, 0}, - {&durpb.Duration{math.MinInt64, 0}, false, false, 0}, - {&durpb.Duration{math.MaxInt64, 0}, false, false, 0}, - // The largest valid duration. - {&durpb.Duration{maxSeconds, 1e9 - 1}, true, false, 0}, - // The smallest valid duration. - {&durpb.Duration{minSeconds, -(1e9 - 1)}, true, false, 0}, - // The smallest invalid duration above the valid range. - {&durpb.Duration{maxSeconds + 1, 0}, false, false, 0}, - // The largest invalid duration below the valid range. - {&durpb.Duration{minSeconds - 1, -(1e9 - 1)}, false, false, 0}, - // One nanosecond past the largest duration representable in Go. - {&durpb.Duration{maxGoSeconds, int32(math.MaxInt64-1e9*maxGoSeconds) + 1}, true, false, 0}, - // One nanosecond past the smallest duration representable in Go. - {&durpb.Duration{minGoSeconds, int32(math.MinInt64-1e9*minGoSeconds) - 1}, true, false, 0}, - // One second past the largest duration representable in Go. - {&durpb.Duration{maxGoSeconds + 1, int32(math.MaxInt64 - 1e9*maxGoSeconds)}, true, false, 0}, - // One second past the smallest duration representable in Go. - {&durpb.Duration{minGoSeconds - 1, int32(math.MinInt64 - 1e9*minGoSeconds)}, true, false, 0}, -} - -func TestValidateDuration(t *testing.T) { - for _, test := range durationTests { - err := validateDuration(test.proto) - gotValid := (err == nil) - if gotValid != test.isValid { - t.Errorf("validateDuration(%v) = %t, want %t", test.proto, gotValid, test.isValid) - } - } -} - -func TestDuration(t *testing.T) { - for _, test := range durationTests { - got, err := Duration(test.proto) - gotOK := (err == nil) - wantOK := test.isValid && test.inRange - if gotOK != wantOK { - t.Errorf("Duration(%v) ok = %t, want %t", test.proto, gotOK, wantOK) - } - if err == nil && got != test.dur { - t.Errorf("Duration(%v) = %v, want %v", test.proto, got, test.dur) - } - } -} - -func TestDurationProto(t *testing.T) { - for _, test := range durationTests { - if test.isValid && test.inRange { - got := DurationProto(test.dur) - if !proto.Equal(got, test.proto) { - t.Errorf("DurationProto(%v) = %v, want %v", test.dur, got, test.proto) - } - } - } -} diff --git a/vendor/github.com/golang/protobuf/ptypes/empty/empty.pb.go b/vendor/github.com/golang/protobuf/ptypes/empty/empty.pb.go deleted file mode 100644 index 46c765a96..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/empty/empty.pb.go +++ /dev/null @@ -1,69 +0,0 @@ -// Code generated by protoc-gen-go. -// source: github.com/golang/protobuf/ptypes/empty/empty.proto -// DO NOT EDIT! - -/* -Package empty is a generated protocol buffer package. - -It is generated from these files: - github.com/golang/protobuf/ptypes/empty/empty.proto - -It has these top-level messages: - Empty -*/ -package empty - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -// A generic empty message that you can re-use to avoid defining duplicated -// empty messages in your APIs. A typical example is to use it as the request -// or the response type of an API method. For instance: -// -// service Foo { -// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); -// } -// -// The JSON representation for `Empty` is empty JSON object `{}`. -type Empty struct { -} - -func (m *Empty) Reset() { *m = Empty{} } -func (m *Empty) String() string { return proto.CompactTextString(m) } -func (*Empty) ProtoMessage() {} -func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (*Empty) XXX_WellKnownType() string { return "Empty" } - -func init() { - proto.RegisterType((*Empty)(nil), "google.protobuf.Empty") -} - -func init() { - proto.RegisterFile("github.com/golang/protobuf/ptypes/empty/empty.proto", fileDescriptor0) -} - -var fileDescriptor0 = []byte{ - // 150 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x32, 0x4e, 0xcf, 0x2c, 0xc9, - 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0xd7, 0x2f, 0x28, - 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0xcd, - 0x2d, 0x28, 0xa9, 0x84, 0x90, 0x7a, 0x60, 0x39, 0x21, 0xfe, 0xf4, 0xfc, 0xfc, 0xf4, 0x9c, 0x54, - 0x3d, 0x98, 0x4a, 0x25, 0x76, 0x2e, 0x56, 0x57, 0x90, 0xbc, 0x53, 0x25, 0x97, 0x70, 0x72, 0x7e, - 0xae, 0x1e, 0x9a, 0xbc, 0x13, 0x17, 0x58, 0x36, 0x00, 0xc4, 0x0d, 0x60, 0x8c, 0x52, 0x27, 0xd2, - 0xce, 0x05, 0x8c, 0x8c, 0x3f, 0x18, 0x19, 0x17, 0x31, 0x31, 0xbb, 0x07, 0x38, 0xad, 0x62, 0x92, - 0x73, 0x87, 0x18, 0x1a, 0x00, 0x55, 0xaa, 0x17, 0x9e, 0x9a, 0x93, 0xe3, 0x9d, 0x97, 0x5f, 0x9e, - 0x17, 0x02, 0xd2, 0x92, 0xc4, 0x06, 0x36, 0xc3, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x7f, 0xbb, - 0xf4, 0x0e, 0xd2, 0x00, 0x00, 0x00, -} diff --git a/vendor/github.com/golang/protobuf/ptypes/empty/empty.proto b/vendor/github.com/golang/protobuf/ptypes/empty/empty.proto deleted file mode 100644 index 37f4cd10e..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/empty/empty.proto +++ /dev/null @@ -1,53 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "github.com/golang/protobuf/ptypes/empty"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "EmptyProto"; -option java_multiple_files = true; -option java_generate_equals_and_hash = true; -option objc_class_prefix = "GPB"; -option cc_enable_arenas = true; - -// A generic empty message that you can re-use to avoid defining duplicated -// empty messages in your APIs. A typical example is to use it as the request -// or the response type of an API method. For instance: -// -// service Foo { -// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); -// } -// -// The JSON representation for `Empty` is empty JSON object `{}`. -message Empty {} diff --git a/vendor/github.com/golang/protobuf/ptypes/regen.sh b/vendor/github.com/golang/protobuf/ptypes/regen.sh deleted file mode 100755 index 2a5b4e8bd..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/regen.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -e -# -# This script fetches and rebuilds the "well-known types" protocol buffers. -# To run this you will need protoc and goprotobuf installed; -# see https://github.com/golang/protobuf for instructions. -# You also need Go and Git installed. - -PKG=github.com/golang/protobuf/ptypes -UPSTREAM=https://github.com/google/protobuf -UPSTREAM_SUBDIR=src/google/protobuf -PROTO_FILES=' - any.proto - duration.proto - empty.proto - struct.proto - timestamp.proto - wrappers.proto -' - -function die() { - echo 1>&2 $* - exit 1 -} - -# Sanity check that the right tools are accessible. -for tool in go git protoc protoc-gen-go; do - q=$(which $tool) || die "didn't find $tool" - echo 1>&2 "$tool: $q" -done - -tmpdir=$(mktemp -d -t regen-wkt.XXXXXX) -trap 'rm -rf $tmpdir' EXIT - -echo -n 1>&2 "finding package dir... " -pkgdir=$(go list -f '{{.Dir}}' $PKG) -echo 1>&2 $pkgdir -base=$(echo $pkgdir | sed "s,/$PKG\$,,") -echo 1>&2 "base: $base" -cd $base - -echo 1>&2 "fetching latest protos... " -git clone -q $UPSTREAM $tmpdir -# Pass 1: build mapping from upstream filename to our filename. -declare -A filename_map -for f in $(cd $PKG && find * -name '*.proto'); do - echo -n 1>&2 "looking for latest version of $f... " - up=$(cd $tmpdir/$UPSTREAM_SUBDIR && find * -name $(basename $f) | grep -v /testdata/) - echo 1>&2 $up - if [ $(echo $up | wc -w) != "1" ]; then - die "not exactly one match" - fi - filename_map[$up]=$f -done -# Pass 2: copy files -for up in "${!filename_map[@]}"; do - f=${filename_map[$up]} - shortname=$(basename $f | sed 's,\.proto$,,') - cp $tmpdir/$UPSTREAM_SUBDIR/$up $PKG/$f -done - -# Run protoc once per package. -for dir in $(find $PKG -name '*.proto' | xargs dirname | sort | uniq); do - echo 1>&2 "* $dir" - protoc --go_out=. $dir/*.proto -done -echo 1>&2 "All OK" diff --git a/vendor/github.com/golang/protobuf/ptypes/struct/struct.pb.go b/vendor/github.com/golang/protobuf/ptypes/struct/struct.pb.go deleted file mode 100644 index 197042ed5..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/struct/struct.pb.go +++ /dev/null @@ -1,382 +0,0 @@ -// Code generated by protoc-gen-go. -// source: github.com/golang/protobuf/ptypes/struct/struct.proto -// DO NOT EDIT! - -/* -Package structpb is a generated protocol buffer package. - -It is generated from these files: - github.com/golang/protobuf/ptypes/struct/struct.proto - -It has these top-level messages: - Struct - Value - ListValue -*/ -package structpb - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -// `NullValue` is a singleton enumeration to represent the null value for the -// `Value` type union. -// -// The JSON representation for `NullValue` is JSON `null`. -type NullValue int32 - -const ( - // Null value. - NullValue_NULL_VALUE NullValue = 0 -) - -var NullValue_name = map[int32]string{ - 0: "NULL_VALUE", -} -var NullValue_value = map[string]int32{ - "NULL_VALUE": 0, -} - -func (x NullValue) String() string { - return proto.EnumName(NullValue_name, int32(x)) -} -func (NullValue) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (NullValue) XXX_WellKnownType() string { return "NullValue" } - -// `Struct` represents a structured data value, consisting of fields -// which map to dynamically typed values. In some languages, `Struct` -// might be supported by a native representation. For example, in -// scripting languages like JS a struct is represented as an -// object. The details of that representation are described together -// with the proto support for the language. -// -// The JSON representation for `Struct` is JSON object. -type Struct struct { - // Unordered map of dynamically typed values. - Fields map[string]*Value `protobuf:"bytes,1,rep,name=fields" json:"fields,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` -} - -func (m *Struct) Reset() { *m = Struct{} } -func (m *Struct) String() string { return proto.CompactTextString(m) } -func (*Struct) ProtoMessage() {} -func (*Struct) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (*Struct) XXX_WellKnownType() string { return "Struct" } - -func (m *Struct) GetFields() map[string]*Value { - if m != nil { - return m.Fields - } - return nil -} - -// `Value` represents a dynamically typed value which can be either -// null, a number, a string, a boolean, a recursive struct value, or a -// list of values. A producer of value is expected to set one of that -// variants, absence of any variant indicates an error. -// -// The JSON representation for `Value` is JSON value. -type Value struct { - // The kind of value. - // - // Types that are valid to be assigned to Kind: - // *Value_NullValue - // *Value_NumberValue - // *Value_StringValue - // *Value_BoolValue - // *Value_StructValue - // *Value_ListValue - Kind isValue_Kind `protobuf_oneof:"kind"` -} - -func (m *Value) Reset() { *m = Value{} } -func (m *Value) String() string { return proto.CompactTextString(m) } -func (*Value) ProtoMessage() {} -func (*Value) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } -func (*Value) XXX_WellKnownType() string { return "Value" } - -type isValue_Kind interface { - isValue_Kind() -} - -type Value_NullValue struct { - NullValue NullValue `protobuf:"varint,1,opt,name=null_value,json=nullValue,enum=google.protobuf.NullValue,oneof"` -} -type Value_NumberValue struct { - NumberValue float64 `protobuf:"fixed64,2,opt,name=number_value,json=numberValue,oneof"` -} -type Value_StringValue struct { - StringValue string `protobuf:"bytes,3,opt,name=string_value,json=stringValue,oneof"` -} -type Value_BoolValue struct { - BoolValue bool `protobuf:"varint,4,opt,name=bool_value,json=boolValue,oneof"` -} -type Value_StructValue struct { - StructValue *Struct `protobuf:"bytes,5,opt,name=struct_value,json=structValue,oneof"` -} -type Value_ListValue struct { - ListValue *ListValue `protobuf:"bytes,6,opt,name=list_value,json=listValue,oneof"` -} - -func (*Value_NullValue) isValue_Kind() {} -func (*Value_NumberValue) isValue_Kind() {} -func (*Value_StringValue) isValue_Kind() {} -func (*Value_BoolValue) isValue_Kind() {} -func (*Value_StructValue) isValue_Kind() {} -func (*Value_ListValue) isValue_Kind() {} - -func (m *Value) GetKind() isValue_Kind { - if m != nil { - return m.Kind - } - return nil -} - -func (m *Value) GetNullValue() NullValue { - if x, ok := m.GetKind().(*Value_NullValue); ok { - return x.NullValue - } - return NullValue_NULL_VALUE -} - -func (m *Value) GetNumberValue() float64 { - if x, ok := m.GetKind().(*Value_NumberValue); ok { - return x.NumberValue - } - return 0 -} - -func (m *Value) GetStringValue() string { - if x, ok := m.GetKind().(*Value_StringValue); ok { - return x.StringValue - } - return "" -} - -func (m *Value) GetBoolValue() bool { - if x, ok := m.GetKind().(*Value_BoolValue); ok { - return x.BoolValue - } - return false -} - -func (m *Value) GetStructValue() *Struct { - if x, ok := m.GetKind().(*Value_StructValue); ok { - return x.StructValue - } - return nil -} - -func (m *Value) GetListValue() *ListValue { - if x, ok := m.GetKind().(*Value_ListValue); ok { - return x.ListValue - } - return nil -} - -// XXX_OneofFuncs is for the internal use of the proto package. -func (*Value) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _Value_OneofMarshaler, _Value_OneofUnmarshaler, _Value_OneofSizer, []interface{}{ - (*Value_NullValue)(nil), - (*Value_NumberValue)(nil), - (*Value_StringValue)(nil), - (*Value_BoolValue)(nil), - (*Value_StructValue)(nil), - (*Value_ListValue)(nil), - } -} - -func _Value_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*Value) - // kind - switch x := m.Kind.(type) { - case *Value_NullValue: - b.EncodeVarint(1<<3 | proto.WireVarint) - b.EncodeVarint(uint64(x.NullValue)) - case *Value_NumberValue: - b.EncodeVarint(2<<3 | proto.WireFixed64) - b.EncodeFixed64(math.Float64bits(x.NumberValue)) - case *Value_StringValue: - b.EncodeVarint(3<<3 | proto.WireBytes) - b.EncodeStringBytes(x.StringValue) - case *Value_BoolValue: - t := uint64(0) - if x.BoolValue { - t = 1 - } - b.EncodeVarint(4<<3 | proto.WireVarint) - b.EncodeVarint(t) - case *Value_StructValue: - b.EncodeVarint(5<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.StructValue); err != nil { - return err - } - case *Value_ListValue: - b.EncodeVarint(6<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.ListValue); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("Value.Kind has unexpected type %T", x) - } - return nil -} - -func _Value_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*Value) - switch tag { - case 1: // kind.null_value - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Kind = &Value_NullValue{NullValue(x)} - return true, err - case 2: // kind.number_value - if wire != proto.WireFixed64 { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeFixed64() - m.Kind = &Value_NumberValue{math.Float64frombits(x)} - return true, err - case 3: // kind.string_value - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Kind = &Value_StringValue{x} - return true, err - case 4: // kind.bool_value - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Kind = &Value_BoolValue{x != 0} - return true, err - case 5: // kind.struct_value - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(Struct) - err := b.DecodeMessage(msg) - m.Kind = &Value_StructValue{msg} - return true, err - case 6: // kind.list_value - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(ListValue) - err := b.DecodeMessage(msg) - m.Kind = &Value_ListValue{msg} - return true, err - default: - return false, nil - } -} - -func _Value_OneofSizer(msg proto.Message) (n int) { - m := msg.(*Value) - // kind - switch x := m.Kind.(type) { - case *Value_NullValue: - n += proto.SizeVarint(1<<3 | proto.WireVarint) - n += proto.SizeVarint(uint64(x.NullValue)) - case *Value_NumberValue: - n += proto.SizeVarint(2<<3 | proto.WireFixed64) - n += 8 - case *Value_StringValue: - n += proto.SizeVarint(3<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(len(x.StringValue))) - n += len(x.StringValue) - case *Value_BoolValue: - n += proto.SizeVarint(4<<3 | proto.WireVarint) - n += 1 - case *Value_StructValue: - s := proto.Size(x.StructValue) - n += proto.SizeVarint(5<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(s)) - n += s - case *Value_ListValue: - s := proto.Size(x.ListValue) - n += proto.SizeVarint(6<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - -// `ListValue` is a wrapper around a repeated field of values. -// -// The JSON representation for `ListValue` is JSON array. -type ListValue struct { - // Repeated field of dynamically typed values. - Values []*Value `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"` -} - -func (m *ListValue) Reset() { *m = ListValue{} } -func (m *ListValue) String() string { return proto.CompactTextString(m) } -func (*ListValue) ProtoMessage() {} -func (*ListValue) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } -func (*ListValue) XXX_WellKnownType() string { return "ListValue" } - -func (m *ListValue) GetValues() []*Value { - if m != nil { - return m.Values - } - return nil -} - -func init() { - proto.RegisterType((*Struct)(nil), "google.protobuf.Struct") - proto.RegisterType((*Value)(nil), "google.protobuf.Value") - proto.RegisterType((*ListValue)(nil), "google.protobuf.ListValue") - proto.RegisterEnum("google.protobuf.NullValue", NullValue_name, NullValue_value) -} - -func init() { - proto.RegisterFile("github.com/golang/protobuf/ptypes/struct/struct.proto", fileDescriptor0) -} - -var fileDescriptor0 = []byte{ - // 416 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0x80, 0x3b, 0xc9, 0x36, 0x98, 0x17, 0x59, 0x97, 0x11, 0xb4, 0xac, 0xa0, 0xa1, 0x7b, 0x09, - 0x22, 0x09, 0x56, 0x04, 0x31, 0x5e, 0x0c, 0xac, 0xbb, 0x60, 0x58, 0x62, 0x74, 0x57, 0xf0, 0x52, - 0x9a, 0x34, 0x8d, 0xa1, 0xd3, 0x99, 0x90, 0xcc, 0x28, 0x3d, 0xfa, 0x2f, 0x3c, 0x8a, 0x47, 0x8f, - 0xfe, 0x42, 0x99, 0x99, 0x24, 0x4a, 0x4b, 0xc1, 0xd3, 0xf4, 0xbd, 0xf9, 0xde, 0x37, 0xef, 0xbd, - 0x06, 0x9e, 0x97, 0x15, 0xff, 0x2c, 0x32, 0x3f, 0x67, 0x9b, 0xa0, 0x64, 0x64, 0x41, 0xcb, 0xa0, - 0x6e, 0x18, 0x67, 0x99, 0x58, 0x05, 0x35, 0xdf, 0xd6, 0x45, 0x1b, 0xb4, 0xbc, 0x11, 0x39, 0xef, - 0x0e, 0x5f, 0xdd, 0xe2, 0x3b, 0x25, 0x63, 0x25, 0x29, 0xfc, 0x9e, 0x9d, 0x7e, 0x47, 0x60, 0xbd, - 0x57, 0x04, 0x0e, 0xc1, 0x5a, 0x55, 0x05, 0x59, 0xb6, 0x13, 0xe4, 0x9a, 0x9e, 0x33, 0x3b, 0xf3, - 0x77, 0x60, 0x5f, 0x83, 0xfe, 0x1b, 0x45, 0x9d, 0x53, 0xde, 0x6c, 0xd3, 0xae, 0xe4, 0xf4, 0x1d, - 0x38, 0xff, 0xa4, 0xf1, 0x09, 0x98, 0xeb, 0x62, 0x3b, 0x41, 0x2e, 0xf2, 0xec, 0x54, 0xfe, 0xc4, - 0x4f, 0x60, 0xfc, 0x65, 0x41, 0x44, 0x31, 0x31, 0x5c, 0xe4, 0x39, 0xb3, 0x7b, 0x7b, 0xf2, 0x1b, - 0x79, 0x9b, 0x6a, 0xe8, 0xa5, 0xf1, 0x02, 0x4d, 0x7f, 0x1b, 0x30, 0x56, 0x49, 0x1c, 0x02, 0x50, - 0x41, 0xc8, 0x5c, 0x0b, 0xa4, 0xf4, 0x78, 0x76, 0xba, 0x27, 0xb8, 0x12, 0x84, 0x28, 0xfe, 0x72, - 0x94, 0xda, 0xb4, 0x0f, 0xf0, 0x19, 0xdc, 0xa6, 0x62, 0x93, 0x15, 0xcd, 0xfc, 0xef, 0xfb, 0xe8, - 0x72, 0x94, 0x3a, 0x3a, 0x3b, 0x40, 0x2d, 0x6f, 0x2a, 0x5a, 0x76, 0x90, 0x29, 0x1b, 0x97, 0x90, - 0xce, 0x6a, 0xe8, 0x11, 0x40, 0xc6, 0x58, 0xdf, 0xc6, 0x91, 0x8b, 0xbc, 0x5b, 0xf2, 0x29, 0x99, - 0xd3, 0xc0, 0x2b, 0x65, 0x11, 0x39, 0xef, 0x90, 0xb1, 0x1a, 0xf5, 0xfe, 0x81, 0x3d, 0x76, 0x7a, - 0x91, 0xf3, 0x61, 0x4a, 0x52, 0xb5, 0x7d, 0xad, 0xa5, 0x6a, 0xf7, 0xa7, 0x8c, 0xab, 0x96, 0x0f, - 0x53, 0x92, 0x3e, 0x88, 0x2c, 0x38, 0x5a, 0x57, 0x74, 0x39, 0x0d, 0xc1, 0x1e, 0x08, 0xec, 0x83, - 0xa5, 0x64, 0xfd, 0x3f, 0x7a, 0x68, 0xe9, 0x1d, 0xf5, 0xf8, 0x01, 0xd8, 0xc3, 0x12, 0xf1, 0x31, - 0xc0, 0xd5, 0x75, 0x1c, 0xcf, 0x6f, 0x5e, 0xc7, 0xd7, 0xe7, 0x27, 0xa3, 0xe8, 0x1b, 0x82, 0xbb, - 0x39, 0xdb, 0xec, 0x2a, 0x22, 0x47, 0x4f, 0x93, 0xc8, 0x38, 0x41, 0x9f, 0x9e, 0xfe, 0xef, 0x87, - 0x19, 0xea, 0xa3, 0xce, 0x7e, 0x20, 0xf4, 0xd3, 0x30, 0x2f, 0x92, 0xe8, 0x97, 0xf1, 0xf0, 0x42, - 0xcb, 0x93, 0xbe, 0xbf, 0x8f, 0x05, 0x21, 0x6f, 0x29, 0xfb, 0x4a, 0x3f, 0xc8, 0xca, 0xcc, 0x52, - 0xaa, 0x67, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xbc, 0xcf, 0x6d, 0x50, 0xfe, 0x02, 0x00, 0x00, -} diff --git a/vendor/github.com/golang/protobuf/ptypes/struct/struct.proto b/vendor/github.com/golang/protobuf/ptypes/struct/struct.proto deleted file mode 100644 index beeba8118..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/struct/struct.proto +++ /dev/null @@ -1,96 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "github.com/golang/protobuf/ptypes/struct;structpb"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "StructProto"; -option java_multiple_files = true; -option java_generate_equals_and_hash = true; -option objc_class_prefix = "GPB"; - - -// `Struct` represents a structured data value, consisting of fields -// which map to dynamically typed values. In some languages, `Struct` -// might be supported by a native representation. For example, in -// scripting languages like JS a struct is represented as an -// object. The details of that representation are described together -// with the proto support for the language. -// -// The JSON representation for `Struct` is JSON object. -message Struct { - // Unordered map of dynamically typed values. - map fields = 1; -} - -// `Value` represents a dynamically typed value which can be either -// null, a number, a string, a boolean, a recursive struct value, or a -// list of values. A producer of value is expected to set one of that -// variants, absence of any variant indicates an error. -// -// The JSON representation for `Value` is JSON value. -message Value { - // The kind of value. - oneof kind { - // Represents a null value. - NullValue null_value = 1; - // Represents a double value. - double number_value = 2; - // Represents a string value. - string string_value = 3; - // Represents a boolean value. - bool bool_value = 4; - // Represents a structured value. - Struct struct_value = 5; - // Represents a repeated `Value`. - ListValue list_value = 6; - } -} - -// `NullValue` is a singleton enumeration to represent the null value for the -// `Value` type union. -// -// The JSON representation for `NullValue` is JSON `null`. -enum NullValue { - // Null value. - NULL_VALUE = 0; -} - -// `ListValue` is a wrapper around a repeated field of values. -// -// The JSON representation for `ListValue` is JSON array. -message ListValue { - // Repeated field of dynamically typed values. - repeated Value values = 1; -} diff --git a/vendor/github.com/golang/protobuf/ptypes/timestamp.go b/vendor/github.com/golang/protobuf/ptypes/timestamp.go deleted file mode 100644 index 1b3657622..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/timestamp.go +++ /dev/null @@ -1,125 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2016 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package ptypes - -// This file implements operations on google.protobuf.Timestamp. - -import ( - "errors" - "fmt" - "time" - - tspb "github.com/golang/protobuf/ptypes/timestamp" -) - -const ( - // Seconds field of the earliest valid Timestamp. - // This is time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC).Unix(). - minValidSeconds = -62135596800 - // Seconds field just after the latest valid Timestamp. - // This is time.Date(10000, 1, 1, 0, 0, 0, 0, time.UTC).Unix(). - maxValidSeconds = 253402300800 -) - -// validateTimestamp determines whether a Timestamp is valid. -// A valid timestamp represents a time in the range -// [0001-01-01, 10000-01-01) and has a Nanos field -// in the range [0, 1e9). -// -// If the Timestamp is valid, validateTimestamp returns nil. -// Otherwise, it returns an error that describes -// the problem. -// -// Every valid Timestamp can be represented by a time.Time, but the converse is not true. -func validateTimestamp(ts *tspb.Timestamp) error { - if ts == nil { - return errors.New("timestamp: nil Timestamp") - } - if ts.Seconds < minValidSeconds { - return fmt.Errorf("timestamp: %v before 0001-01-01", ts) - } - if ts.Seconds >= maxValidSeconds { - return fmt.Errorf("timestamp: %v after 10000-01-01", ts) - } - if ts.Nanos < 0 || ts.Nanos >= 1e9 { - return fmt.Errorf("timestamp: %v: nanos not in range [0, 1e9)", ts) - } - return nil -} - -// Timestamp converts a google.protobuf.Timestamp proto to a time.Time. -// It returns an error if the argument is invalid. -// -// Unlike most Go functions, if Timestamp returns an error, the first return value -// is not the zero time.Time. Instead, it is the value obtained from the -// time.Unix function when passed the contents of the Timestamp, in the UTC -// locale. This may or may not be a meaningful time; many invalid Timestamps -// do map to valid time.Times. -// -// A nil Timestamp returns an error. The first return value in that case is -// undefined. -func Timestamp(ts *tspb.Timestamp) (time.Time, error) { - // Don't return the zero value on error, because corresponds to a valid - // timestamp. Instead return whatever time.Unix gives us. - var t time.Time - if ts == nil { - t = time.Unix(0, 0).UTC() // treat nil like the empty Timestamp - } else { - t = time.Unix(ts.Seconds, int64(ts.Nanos)).UTC() - } - return t, validateTimestamp(ts) -} - -// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto. -// It returns an error if the resulting Timestamp is invalid. -func TimestampProto(t time.Time) (*tspb.Timestamp, error) { - seconds := t.Unix() - nanos := int32(t.Sub(time.Unix(seconds, 0))) - ts := &tspb.Timestamp{ - Seconds: seconds, - Nanos: nanos, - } - if err := validateTimestamp(ts); err != nil { - return nil, err - } - return ts, nil -} - -// TimestampString returns the RFC 3339 string for valid Timestamps. For invalid -// Timestamps, it returns an error message in parentheses. -func TimestampString(ts *tspb.Timestamp) string { - t, err := Timestamp(ts) - if err != nil { - return fmt.Sprintf("(%v)", err) - } - return t.Format(time.RFC3339Nano) -} diff --git a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go deleted file mode 100644 index ffcc51594..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go +++ /dev/null @@ -1,127 +0,0 @@ -// Code generated by protoc-gen-go. -// source: github.com/golang/protobuf/ptypes/timestamp/timestamp.proto -// DO NOT EDIT! - -/* -Package timestamp is a generated protocol buffer package. - -It is generated from these files: - github.com/golang/protobuf/ptypes/timestamp/timestamp.proto - -It has these top-level messages: - Timestamp -*/ -package timestamp - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -// A Timestamp represents a point in time independent of any time zone -// or calendar, represented as seconds and fractions of seconds at -// nanosecond resolution in UTC Epoch time. It is encoded using the -// Proleptic Gregorian Calendar which extends the Gregorian calendar -// backwards to year one. It is encoded assuming all minutes are 60 -// seconds long, i.e. leap seconds are "smeared" so that no leap second -// table is needed for interpretation. Range is from -// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. -// By restricting to that range, we ensure that we can convert to -// and from RFC 3339 date strings. -// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). -// -// Example 1: Compute Timestamp from POSIX `time()`. -// -// Timestamp timestamp; -// timestamp.set_seconds(time(NULL)); -// timestamp.set_nanos(0); -// -// Example 2: Compute Timestamp from POSIX `gettimeofday()`. -// -// struct timeval tv; -// gettimeofday(&tv, NULL); -// -// Timestamp timestamp; -// timestamp.set_seconds(tv.tv_sec); -// timestamp.set_nanos(tv.tv_usec * 1000); -// -// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. -// -// FILETIME ft; -// GetSystemTimeAsFileTime(&ft); -// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; -// -// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z -// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. -// Timestamp timestamp; -// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); -// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); -// -// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. -// -// long millis = System.currentTimeMillis(); -// -// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) -// .setNanos((int) ((millis % 1000) * 1000000)).build(); -// -// -// Example 5: Compute Timestamp from current time in Python. -// -// now = time.time() -// seconds = int(now) -// nanos = int((now - seconds) * 10**9) -// timestamp = Timestamp(seconds=seconds, nanos=nanos) -// -// -type Timestamp struct { - // Represents seconds of UTC time since Unix epoch - // 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to - // 9999-12-31T23:59:59Z inclusive. - Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"` - // Non-negative fractions of a second at nanosecond resolution. Negative - // second values with fractions must still have non-negative nanos values - // that count forward in time. Must be from 0 to 999,999,999 - // inclusive. - Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"` -} - -func (m *Timestamp) Reset() { *m = Timestamp{} } -func (m *Timestamp) String() string { return proto.CompactTextString(m) } -func (*Timestamp) ProtoMessage() {} -func (*Timestamp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" } - -func init() { - proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp") -} - -func init() { - proto.RegisterFile("github.com/golang/protobuf/ptypes/timestamp/timestamp.proto", fileDescriptor0) -} - -var fileDescriptor0 = []byte{ - // 194 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xb2, 0x4e, 0xcf, 0x2c, 0xc9, - 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0xd7, 0x2f, 0x28, - 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0xc9, - 0xcc, 0x4d, 0x2d, 0x2e, 0x49, 0xcc, 0x2d, 0x40, 0xb0, 0xf4, 0xc0, 0x6a, 0x84, 0xf8, 0xd3, 0xf3, - 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x60, 0x3a, 0x94, 0xac, 0xb9, 0x38, 0x43, 0x60, 0x6a, 0x84, 0x24, - 0xb8, 0xd8, 0x8b, 0x53, 0x93, 0xf3, 0xf3, 0x52, 0x8a, 0x25, 0x18, 0x15, 0x18, 0x35, 0x98, 0x83, - 0x60, 0x5c, 0x21, 0x11, 0x2e, 0xd6, 0xbc, 0xc4, 0xbc, 0xfc, 0x62, 0x09, 0x26, 0x05, 0x46, 0x0d, - 0xd6, 0x20, 0x08, 0xc7, 0xa9, 0x91, 0x91, 0x4b, 0x38, 0x39, 0x3f, 0x57, 0x0f, 0xcd, 0x50, 0x27, - 0x3e, 0xb8, 0x91, 0x01, 0x20, 0xa1, 0x00, 0xc6, 0x28, 0x6d, 0x12, 0x1c, 0xbd, 0x80, 0x91, 0xf1, - 0x07, 0x23, 0xe3, 0x22, 0x26, 0x66, 0xf7, 0x00, 0xa7, 0x55, 0x4c, 0x72, 0xee, 0x10, 0xc3, 0x03, - 0xa0, 0xca, 0xf5, 0xc2, 0x53, 0x73, 0x72, 0xbc, 0xf3, 0xf2, 0xcb, 0xf3, 0x42, 0x40, 0xda, 0x92, - 0xd8, 0xc0, 0xe6, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x17, 0x5f, 0xb7, 0xdc, 0x17, 0x01, - 0x00, 0x00, -} diff --git a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto deleted file mode 100644 index 7992a8588..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto +++ /dev/null @@ -1,111 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option cc_enable_arenas = true; -option go_package = "github.com/golang/protobuf/ptypes/timestamp"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "TimestampProto"; -option java_multiple_files = true; -option java_generate_equals_and_hash = true; -option objc_class_prefix = "GPB"; - -// A Timestamp represents a point in time independent of any time zone -// or calendar, represented as seconds and fractions of seconds at -// nanosecond resolution in UTC Epoch time. It is encoded using the -// Proleptic Gregorian Calendar which extends the Gregorian calendar -// backwards to year one. It is encoded assuming all minutes are 60 -// seconds long, i.e. leap seconds are "smeared" so that no leap second -// table is needed for interpretation. Range is from -// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. -// By restricting to that range, we ensure that we can convert to -// and from RFC 3339 date strings. -// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). -// -// Example 1: Compute Timestamp from POSIX `time()`. -// -// Timestamp timestamp; -// timestamp.set_seconds(time(NULL)); -// timestamp.set_nanos(0); -// -// Example 2: Compute Timestamp from POSIX `gettimeofday()`. -// -// struct timeval tv; -// gettimeofday(&tv, NULL); -// -// Timestamp timestamp; -// timestamp.set_seconds(tv.tv_sec); -// timestamp.set_nanos(tv.tv_usec * 1000); -// -// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. -// -// FILETIME ft; -// GetSystemTimeAsFileTime(&ft); -// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; -// -// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z -// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. -// Timestamp timestamp; -// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); -// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); -// -// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. -// -// long millis = System.currentTimeMillis(); -// -// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) -// .setNanos((int) ((millis % 1000) * 1000000)).build(); -// -// -// Example 5: Compute Timestamp from current time in Python. -// -// now = time.time() -// seconds = int(now) -// nanos = int((now - seconds) * 10**9) -// timestamp = Timestamp(seconds=seconds, nanos=nanos) -// -// -message Timestamp { - - // Represents seconds of UTC time since Unix epoch - // 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to - // 9999-12-31T23:59:59Z inclusive. - int64 seconds = 1; - - // Non-negative fractions of a second at nanosecond resolution. Negative - // second values with fractions must still have non-negative nanos values - // that count forward in time. Must be from 0 to 999,999,999 - // inclusive. - int32 nanos = 2; -} diff --git a/vendor/github.com/golang/protobuf/ptypes/timestamp_test.go b/vendor/github.com/golang/protobuf/ptypes/timestamp_test.go deleted file mode 100644 index 114a7f9fc..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/timestamp_test.go +++ /dev/null @@ -1,138 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2016 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package ptypes - -import ( - "math" - "testing" - "time" - - "github.com/golang/protobuf/proto" - tspb "github.com/golang/protobuf/ptypes/timestamp" -) - -var tests = []struct { - ts *tspb.Timestamp - valid bool - t time.Time -}{ - // The timestamp representing the Unix epoch date. - {&tspb.Timestamp{0, 0}, true, utcDate(1970, 1, 1)}, - // The smallest representable timestamp. - {&tspb.Timestamp{math.MinInt64, math.MinInt32}, false, - time.Unix(math.MinInt64, math.MinInt32).UTC()}, - // The smallest representable timestamp with non-negative nanos. - {&tspb.Timestamp{math.MinInt64, 0}, false, time.Unix(math.MinInt64, 0).UTC()}, - // The earliest valid timestamp. - {&tspb.Timestamp{minValidSeconds, 0}, true, utcDate(1, 1, 1)}, - //"0001-01-01T00:00:00Z"}, - // The largest representable timestamp. - {&tspb.Timestamp{math.MaxInt64, math.MaxInt32}, false, - time.Unix(math.MaxInt64, math.MaxInt32).UTC()}, - // The largest representable timestamp with nanos in range. - {&tspb.Timestamp{math.MaxInt64, 1e9 - 1}, false, - time.Unix(math.MaxInt64, 1e9-1).UTC()}, - // The largest valid timestamp. - {&tspb.Timestamp{maxValidSeconds - 1, 1e9 - 1}, true, - time.Date(9999, 12, 31, 23, 59, 59, 1e9-1, time.UTC)}, - // The smallest invalid timestamp that is larger than the valid range. - {&tspb.Timestamp{maxValidSeconds, 0}, false, time.Unix(maxValidSeconds, 0).UTC()}, - // A date before the epoch. - {&tspb.Timestamp{-281836800, 0}, true, utcDate(1961, 1, 26)}, - // A date after the epoch. - {&tspb.Timestamp{1296000000, 0}, true, utcDate(2011, 1, 26)}, - // A date after the epoch, in the middle of the day. - {&tspb.Timestamp{1296012345, 940483}, true, - time.Date(2011, 1, 26, 3, 25, 45, 940483, time.UTC)}, -} - -func TestValidateTimestamp(t *testing.T) { - for _, s := range tests { - got := validateTimestamp(s.ts) - if (got == nil) != s.valid { - t.Errorf("validateTimestamp(%v) = %v, want %v", s.ts, got, s.valid) - } - } -} - -func TestTimestamp(t *testing.T) { - for _, s := range tests { - got, err := Timestamp(s.ts) - if (err == nil) != s.valid { - t.Errorf("Timestamp(%v) error = %v, but valid = %t", s.ts, err, s.valid) - } else if s.valid && got != s.t { - t.Errorf("Timestamp(%v) = %v, want %v", s.ts, got, s.t) - } - } - // Special case: a nil Timestamp is an error, but returns the 0 Unix time. - got, err := Timestamp(nil) - want := time.Unix(0, 0).UTC() - if got != want { - t.Errorf("Timestamp(nil) = %v, want %v", got, want) - } - if err == nil { - t.Errorf("Timestamp(nil) error = nil, expected error") - } -} - -func TestTimestampProto(t *testing.T) { - for _, s := range tests { - got, err := TimestampProto(s.t) - if (err == nil) != s.valid { - t.Errorf("TimestampProto(%v) error = %v, but valid = %t", s.t, err, s.valid) - } else if s.valid && !proto.Equal(got, s.ts) { - t.Errorf("TimestampProto(%v) = %v, want %v", s.t, got, s.ts) - } - } - // No corresponding special case here: no time.Time results in a nil Timestamp. -} - -func TestTimestampString(t *testing.T) { - for _, test := range []struct { - ts *tspb.Timestamp - want string - }{ - // Not much testing needed because presumably time.Format is - // well-tested. - {&tspb.Timestamp{0, 0}, "1970-01-01T00:00:00Z"}, - {&tspb.Timestamp{minValidSeconds - 1, 0}, "(timestamp: seconds:-62135596801 before 0001-01-01)"}, - } { - got := TimestampString(test.ts) - if got != test.want { - t.Errorf("TimestampString(%v) = %q, want %q", test.ts, got, test.want) - } - } -} - -func utcDate(year, month, day int) time.Time { - return time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC) -} diff --git a/vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.pb.go b/vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.pb.go deleted file mode 100644 index 5e52a81c7..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.pb.go +++ /dev/null @@ -1,200 +0,0 @@ -// Code generated by protoc-gen-go. -// source: github.com/golang/protobuf/ptypes/wrappers/wrappers.proto -// DO NOT EDIT! - -/* -Package wrappers is a generated protocol buffer package. - -It is generated from these files: - github.com/golang/protobuf/ptypes/wrappers/wrappers.proto - -It has these top-level messages: - DoubleValue - FloatValue - Int64Value - UInt64Value - Int32Value - UInt32Value - BoolValue - StringValue - BytesValue -*/ -package wrappers - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -// Wrapper message for `double`. -// -// The JSON representation for `DoubleValue` is JSON number. -type DoubleValue struct { - // The double value. - Value float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` -} - -func (m *DoubleValue) Reset() { *m = DoubleValue{} } -func (m *DoubleValue) String() string { return proto.CompactTextString(m) } -func (*DoubleValue) ProtoMessage() {} -func (*DoubleValue) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (*DoubleValue) XXX_WellKnownType() string { return "DoubleValue" } - -// Wrapper message for `float`. -// -// The JSON representation for `FloatValue` is JSON number. -type FloatValue struct { - // The float value. - Value float32 `protobuf:"fixed32,1,opt,name=value" json:"value,omitempty"` -} - -func (m *FloatValue) Reset() { *m = FloatValue{} } -func (m *FloatValue) String() string { return proto.CompactTextString(m) } -func (*FloatValue) ProtoMessage() {} -func (*FloatValue) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } -func (*FloatValue) XXX_WellKnownType() string { return "FloatValue" } - -// Wrapper message for `int64`. -// -// The JSON representation for `Int64Value` is JSON string. -type Int64Value struct { - // The int64 value. - Value int64 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"` -} - -func (m *Int64Value) Reset() { *m = Int64Value{} } -func (m *Int64Value) String() string { return proto.CompactTextString(m) } -func (*Int64Value) ProtoMessage() {} -func (*Int64Value) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } -func (*Int64Value) XXX_WellKnownType() string { return "Int64Value" } - -// Wrapper message for `uint64`. -// -// The JSON representation for `UInt64Value` is JSON string. -type UInt64Value struct { - // The uint64 value. - Value uint64 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"` -} - -func (m *UInt64Value) Reset() { *m = UInt64Value{} } -func (m *UInt64Value) String() string { return proto.CompactTextString(m) } -func (*UInt64Value) ProtoMessage() {} -func (*UInt64Value) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } -func (*UInt64Value) XXX_WellKnownType() string { return "UInt64Value" } - -// Wrapper message for `int32`. -// -// The JSON representation for `Int32Value` is JSON number. -type Int32Value struct { - // The int32 value. - Value int32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"` -} - -func (m *Int32Value) Reset() { *m = Int32Value{} } -func (m *Int32Value) String() string { return proto.CompactTextString(m) } -func (*Int32Value) ProtoMessage() {} -func (*Int32Value) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } -func (*Int32Value) XXX_WellKnownType() string { return "Int32Value" } - -// Wrapper message for `uint32`. -// -// The JSON representation for `UInt32Value` is JSON number. -type UInt32Value struct { - // The uint32 value. - Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"` -} - -func (m *UInt32Value) Reset() { *m = UInt32Value{} } -func (m *UInt32Value) String() string { return proto.CompactTextString(m) } -func (*UInt32Value) ProtoMessage() {} -func (*UInt32Value) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } -func (*UInt32Value) XXX_WellKnownType() string { return "UInt32Value" } - -// Wrapper message for `bool`. -// -// The JSON representation for `BoolValue` is JSON `true` and `false`. -type BoolValue struct { - // The bool value. - Value bool `protobuf:"varint,1,opt,name=value" json:"value,omitempty"` -} - -func (m *BoolValue) Reset() { *m = BoolValue{} } -func (m *BoolValue) String() string { return proto.CompactTextString(m) } -func (*BoolValue) ProtoMessage() {} -func (*BoolValue) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } -func (*BoolValue) XXX_WellKnownType() string { return "BoolValue" } - -// Wrapper message for `string`. -// -// The JSON representation for `StringValue` is JSON string. -type StringValue struct { - // The string value. - Value string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"` -} - -func (m *StringValue) Reset() { *m = StringValue{} } -func (m *StringValue) String() string { return proto.CompactTextString(m) } -func (*StringValue) ProtoMessage() {} -func (*StringValue) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } -func (*StringValue) XXX_WellKnownType() string { return "StringValue" } - -// Wrapper message for `bytes`. -// -// The JSON representation for `BytesValue` is JSON string. -type BytesValue struct { - // The bytes value. - Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` -} - -func (m *BytesValue) Reset() { *m = BytesValue{} } -func (m *BytesValue) String() string { return proto.CompactTextString(m) } -func (*BytesValue) ProtoMessage() {} -func (*BytesValue) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } -func (*BytesValue) XXX_WellKnownType() string { return "BytesValue" } - -func init() { - proto.RegisterType((*DoubleValue)(nil), "google.protobuf.DoubleValue") - proto.RegisterType((*FloatValue)(nil), "google.protobuf.FloatValue") - proto.RegisterType((*Int64Value)(nil), "google.protobuf.Int64Value") - proto.RegisterType((*UInt64Value)(nil), "google.protobuf.UInt64Value") - proto.RegisterType((*Int32Value)(nil), "google.protobuf.Int32Value") - proto.RegisterType((*UInt32Value)(nil), "google.protobuf.UInt32Value") - proto.RegisterType((*BoolValue)(nil), "google.protobuf.BoolValue") - proto.RegisterType((*StringValue)(nil), "google.protobuf.StringValue") - proto.RegisterType((*BytesValue)(nil), "google.protobuf.BytesValue") -} - -func init() { - proto.RegisterFile("github.com/golang/protobuf/ptypes/wrappers/wrappers.proto", fileDescriptor0) -} - -var fileDescriptor0 = []byte{ - // 260 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xb2, 0x4c, 0xcf, 0x2c, 0xc9, - 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0xd7, 0x2f, 0x28, - 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x2f, - 0x4a, 0x2c, 0x28, 0x48, 0x2d, 0x42, 0x30, 0xf4, 0xc0, 0x2a, 0x84, 0xf8, 0xd3, 0xf3, 0xf3, 0xd3, - 0x73, 0x52, 0xf5, 0x60, 0xea, 0x95, 0x94, 0xb9, 0xb8, 0x5d, 0xf2, 0x4b, 0x93, 0x72, 0x52, 0xc3, - 0x12, 0x73, 0x4a, 0x53, 0x85, 0x44, 0xb8, 0x58, 0xcb, 0x40, 0x0c, 0x09, 0x46, 0x05, 0x46, 0x0d, - 0xc6, 0x20, 0x08, 0x47, 0x49, 0x89, 0x8b, 0xcb, 0x2d, 0x27, 0x3f, 0xb1, 0x04, 0x8b, 0x1a, 0x26, - 0x24, 0x35, 0x9e, 0x79, 0x25, 0x66, 0x26, 0x58, 0xd4, 0x30, 0xc3, 0xd4, 0x28, 0x73, 0x71, 0x87, - 0xe2, 0x52, 0xc4, 0x82, 0x6a, 0x90, 0xb1, 0x11, 0x16, 0x35, 0xac, 0x68, 0x06, 0x61, 0x55, 0xc4, - 0x0b, 0x53, 0xa4, 0xc8, 0xc5, 0xe9, 0x94, 0x9f, 0x9f, 0x83, 0x45, 0x09, 0x07, 0x92, 0x39, 0xc1, - 0x25, 0x45, 0x99, 0x79, 0xe9, 0x58, 0x14, 0x71, 0x22, 0x39, 0xc8, 0xa9, 0xb2, 0x24, 0xb5, 0x18, - 0x8b, 0x1a, 0x1e, 0xa8, 0x1a, 0xa7, 0x7a, 0x2e, 0xe1, 0xe4, 0xfc, 0x5c, 0x3d, 0xb4, 0xd0, 0x75, - 0xe2, 0x0d, 0x87, 0x06, 0x7f, 0x00, 0x48, 0x24, 0x80, 0x31, 0x4a, 0x8b, 0xf8, 0xa8, 0x5b, 0xc0, - 0xc8, 0xf8, 0x83, 0x91, 0x71, 0x11, 0x13, 0xb3, 0x7b, 0x80, 0xd3, 0x2a, 0x26, 0x39, 0x77, 0x88, - 0xd1, 0x01, 0x50, 0xd5, 0x7a, 0xe1, 0xa9, 0x39, 0x39, 0xde, 0x79, 0xf9, 0xe5, 0x79, 0x21, 0x20, - 0x5d, 0x49, 0x6c, 0x60, 0x63, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xdf, 0x64, 0x4b, - 0x1c, 0x02, 0x00, 0x00, -} diff --git a/vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.proto b/vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.proto deleted file mode 100644 index 4828ad9ae..000000000 --- a/vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.proto +++ /dev/null @@ -1,119 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Wrappers for primitive (non-message) types. These types are useful -// for embedding primitives in the `google.protobuf.Any` type and for places -// where we need to distinguish between the absence of a primitive -// typed field and its default value. - -syntax = "proto3"; - -package google.protobuf; - -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option cc_enable_arenas = true; -option go_package = "github.com/golang/protobuf/ptypes/wrappers"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "WrappersProto"; -option java_multiple_files = true; -option java_generate_equals_and_hash = true; -option objc_class_prefix = "GPB"; - -// Wrapper message for `double`. -// -// The JSON representation for `DoubleValue` is JSON number. -message DoubleValue { - // The double value. - double value = 1; -} - -// Wrapper message for `float`. -// -// The JSON representation for `FloatValue` is JSON number. -message FloatValue { - // The float value. - float value = 1; -} - -// Wrapper message for `int64`. -// -// The JSON representation for `Int64Value` is JSON string. -message Int64Value { - // The int64 value. - int64 value = 1; -} - -// Wrapper message for `uint64`. -// -// The JSON representation for `UInt64Value` is JSON string. -message UInt64Value { - // The uint64 value. - uint64 value = 1; -} - -// Wrapper message for `int32`. -// -// The JSON representation for `Int32Value` is JSON number. -message Int32Value { - // The int32 value. - int32 value = 1; -} - -// Wrapper message for `uint32`. -// -// The JSON representation for `UInt32Value` is JSON number. -message UInt32Value { - // The uint32 value. - uint32 value = 1; -} - -// Wrapper message for `bool`. -// -// The JSON representation for `BoolValue` is JSON `true` and `false`. -message BoolValue { - // The bool value. - bool value = 1; -} - -// Wrapper message for `string`. -// -// The JSON representation for `StringValue` is JSON string. -message StringValue { - // The string value. - string value = 1; -} - -// Wrapper message for `bytes`. -// -// The JSON representation for `BytesValue` is JSON string. -message BytesValue { - // The bytes value. - bytes value = 1; -} diff --git a/vendor/github.com/gopherjs/gopherjs/.gitignore b/vendor/github.com/gopherjs/gopherjs/.gitignore deleted file mode 100644 index e08709760..000000000 --- a/vendor/github.com/gopherjs/gopherjs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/node-syscall/build -/node_modules diff --git a/vendor/github.com/gopherjs/gopherjs/LICENSE b/vendor/github.com/gopherjs/gopherjs/LICENSE deleted file mode 100644 index d496fef10..000000000 --- a/vendor/github.com/gopherjs/gopherjs/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2013 Richard Musiol. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/gopherjs/gopherjs/README.md b/vendor/github.com/gopherjs/gopherjs/README.md deleted file mode 100644 index 2b11296ea..000000000 --- a/vendor/github.com/gopherjs/gopherjs/README.md +++ /dev/null @@ -1,140 +0,0 @@ -GopherJS - A compiler from Go to JavaScript -------------------------------------------- - -[![Sourcegraph](https://sourcegraph.com/github.com/gopherjs/gopherjs/-/badge.svg)](https://sourcegraph.com/github.com/gopherjs/gopherjs?badge) -[![Circle CI](https://circleci.com/gh/gopherjs/gopherjs.svg?style=svg)](https://circleci.com/gh/gopherjs/gopherjs) - -GopherJS compiles Go code ([golang.org](https://golang.org/)) to pure JavaScript code. Its main purpose is to give you the opportunity to write front-end code in Go which will still run in all browsers. - -### Playground -Give GopherJS a try on the [GopherJS Playground](http://gopherjs.github.io/playground/). - -### What is supported? -Nearly everything, including Goroutines ([compatibility table](https://github.com/gopherjs/gopherjs/blob/master/doc/packages.md)). Performance is quite good in most cases, see [HTML5 game engine benchmark](https://ajhager.github.io/engi/demos/botmark.html). Cgo is not supported. Using a vendored copy of GopherJS is currently not supported, see [#415](https://github.com/gopherjs/gopherjs/issues/415). - -### Installation and Usage -Get or update GopherJS and dependencies with: - -``` -go get -u github.com/gopherjs/gopherjs -``` - -Now you can use `gopherjs build [package]`, `gopherjs build [files]` or `gopherjs install [package]` which behave similar to the `go` tool. For `main` packages, these commands create a `.js` file and `.js.map` source map in the current directory or in `$GOPATH/bin`. The generated JavaScript file can be used as usual in a website. Use `gopherjs help [command]` to get a list of possible command line flags, e.g. for minification and automatically watching for changes. - -*Note: GopherJS will try to write compiled object files of the core packages to your $GOROOT/pkg directory. If that fails, it will fall back to $GOPATH/pkg.* - -#### gopherjs run, gopherjs test - -If you want to use `gopherjs run` or `gopherjs test` to run the generated code locally, install Node.js 4.x (or newer), and the `source-map-support` module: - -``` -npm install --global source-map-support -``` - -For system calls (file system access, etc.), see [this page](https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md). - -#### gopherjs serve - -`gopherjs serve` is a useful command you can use during development. It will start an HTTP server serving on ":8080" by default, and dynamically compile Go packages with GopherJS and serve them. - -For example, navigating to `http://localhost:8080/example.com/user/project/` should compile and run the Go package `example.com/user/project`. The generated JavaScript output will be served at `http://localhost:8080/example.com/user/project/project.js`. If the directory contains `index.html` it will be served, otherwise a minimal `index.html` that includes `` will be provided, causing the JavaScript to be executed. All other static files will be served too. - -Refreshing in the browser will rebuild the served files if needed. Compilation errors will be displayed in terminal, and in browser console. Additionally, it will serve $GOROOT and $GOPATH for sourcemaps. - -If you include an argument, it will be the root from which everything is served. For example, if you run gopherjs serve github.com/user/project then the generated JavaScript for the package github.com/user/project/mypkg will be served at http://localhost:8080/mypkg/mypkg.js. - -### Performance Tips - -- Use the `-m` command line flag to generate minified code. -- Apply gzip compression (https://en.wikipedia.org/wiki/HTTP_compression). -- Use `int` instead of `(u)int8/16/32/64`. -- Use `float64` instead of `float32`. - -### Community -- [#gopherjs Channel on Gophers Slack](https://gophers.slack.com/messages/gopherjs/) (invites to Gophers Slack are available [here](http://blog.gopheracademy.com/gophers-slack-community/#how-can-i-be-invited-to-join:2facdc921b2310f18cb851c36fa92369)) -- [Bindings to JavaScript APIs and libraries](https://github.com/gopherjs/gopherjs/wiki/bindings) -- [GopherJS Blog](https://medium.com/gopherjs) -- [GopherJS on Twitter](https://twitter.com/GopherJS) - -### Getting started - -#### Interacting with the DOM -The package `github.com/gopherjs/gopherjs/js` (see [documentation](https://godoc.org/github.com/gopherjs/gopherjs/js)) provides functions for interacting with native JavaScript APIs. For example the line - -```js -document.write("Hello world!"); -``` - -would look like this in Go: - -```go -js.Global.Get("document").Call("write", "Hello world!") -``` - -You may also want use the [DOM bindings](http://dominik.honnef.co/go/js/dom), the [jQuery bindings](https://github.com/gopherjs/jquery) (see [TodoMVC Example](https://github.com/gopherjs/todomvc)) or the [AngularJS bindings](https://github.com/wvell/go-angularjs). Those are some of the [bindings to JavaScript APIs and libraries](https://github.com/gopherjs/gopherjs/wiki/bindings) by community members. - -#### Providing library functions for use in other JavaScript code -Set a global variable to a map that contains the functions: - -```go -package main - -import "github.com/gopherjs/gopherjs/js" - -func main() { - js.Global.Set("pet", map[string]interface{}{ - "New": New, - }) -} - -type Pet struct { - name string -} - -func New(name string) *js.Object { - return js.MakeWrapper(&Pet{name}) -} - -func (p *Pet) Name() string { - return p.name -} - -func (p *Pet) SetName(name string) { - p.name = name -} -``` - -For more details see [Jason Stone's blog post](http://legacytotheedge.blogspot.de/2014/03/gopherjs-go-to-javascript-transpiler.html) about GopherJS. - -### Architecture - -#### General -GopherJS emulates a 32-bit environment. This means that `int`, `uint` and `uintptr` have a precision of 32 bits. However, the explicit 64-bit integer types `int64` and `uint64` are supported. The `GOARCH` value of GopherJS is "js". You may use it as a build constraint: `// +build js`. - -#### Application Lifecycle - -The `main` function is executed as usual after all `init` functions have run. JavaScript callbacks can also invoke Go functions, even after the `main` function has exited. Therefore the end of the `main` function should not be regarded as the end of the application and does not end the execution of other goroutines. - -In the browser, calling `os.Exit` (e.g. indirectly by `log.Fatal`) also does not terminate the execution of the program. For convenience, it calls `runtime.Goexit` to immediately terminate the calling goroutine. - -#### Goroutines -Goroutines are fully supported by GopherJS. The only restriction is that you need to start a new goroutine if you want to use blocking code called from external JavaScript: - -```go -js.Global.Get("myButton").Call("addEventListener", "click", func() { - go func() { - [...] - someBlockingFunction() - [...] - }() -}) -``` - -How it works: - -JavaScript has no concept of concurrency (except web workers, but those are too strictly separated to be used for goroutines). Because of that, instructions in JavaScript are never blocking. A blocking call would effectively freeze the responsiveness of your web page, so calls with callback arguments are used instead. - -GopherJS does some heavy lifting to work around this restriction: Whenever an instruction is blocking (e.g. communicating with a channel that isn't ready), the whole stack will unwind (= all functions return) and the goroutine will be put to sleep. Then another goroutine which is ready to resume gets picked and its stack with all local variables will be restored. - -### GopherJS Development -If you're looking to make changes to the GopherJS compiler, see [Developer Guidelines](https://github.com/gopherjs/gopherjs/wiki/Developer-Guidelines) for additional developer information. diff --git a/vendor/github.com/gopherjs/gopherjs/build/build.go b/vendor/github.com/gopherjs/gopherjs/build/build.go deleted file mode 100644 index fe82226b4..000000000 --- a/vendor/github.com/gopherjs/gopherjs/build/build.go +++ /dev/null @@ -1,779 +0,0 @@ -package build - -import ( - "fmt" - "go/ast" - "go/build" - "go/parser" - "go/scanner" - "go/token" - "go/types" - "io" - "io/ioutil" - "os" - "os/exec" - "path" - "path/filepath" - "runtime" - "strconv" - "strings" - "time" - - "github.com/fsnotify/fsnotify" - "github.com/gopherjs/gopherjs/compiler" - "github.com/gopherjs/gopherjs/compiler/natives" - "github.com/neelance/sourcemap" -) - -type ImportCError struct { - pkgPath string -} - -func (e *ImportCError) Error() string { - return e.pkgPath + `: importing "C" is not supported by GopherJS` -} - -func NewBuildContext(installSuffix string, buildTags []string) *build.Context { - return &build.Context{ - GOROOT: build.Default.GOROOT, - GOPATH: build.Default.GOPATH, - GOOS: build.Default.GOOS, - GOARCH: "js", - InstallSuffix: installSuffix, - Compiler: "gc", - BuildTags: append(buildTags, "netgo"), - ReleaseTags: build.Default.ReleaseTags, - CgoEnabled: true, // detect `import "C"` to throw proper error - } -} - -// Import returns details about the Go package named by the import path. If the -// path is a local import path naming a package that can be imported using -// a standard import path, the returned package will set p.ImportPath to -// that path. -// -// In the directory containing the package, .go and .inc.js files are -// considered part of the package except for: -// -// - .go files in package documentation -// - files starting with _ or . (likely editor temporary files) -// - files with build constraints not satisfied by the context -// -// If an error occurs, Import returns a non-nil error and a nil -// *PackageData. -func Import(path string, mode build.ImportMode, installSuffix string, buildTags []string) (*PackageData, error) { - wd, err := os.Getwd() - if err != nil { - // Getwd may fail if we're in GOARCH=js mode. That's okay, handle - // it by falling back to empty working directory. It just means - // Import will not be able to resolve relative import paths. - wd = "" - } - return importWithSrcDir(path, wd, mode, installSuffix, buildTags) -} - -func importWithSrcDir(path string, srcDir string, mode build.ImportMode, installSuffix string, buildTags []string) (*PackageData, error) { - buildContext := NewBuildContext(installSuffix, buildTags) - if path == "syscall" { // syscall needs to use a typical GOARCH like amd64 to pick up definitions for _Socklen, BpfInsn, IFNAMSIZ, Timeval, BpfStat, SYS_FCNTL, Flock_t, etc. - buildContext.GOARCH = runtime.GOARCH - buildContext.InstallSuffix = "js" - if installSuffix != "" { - buildContext.InstallSuffix += "_" + installSuffix - } - } - pkg, err := buildContext.Import(path, srcDir, mode) - if err != nil { - return nil, err - } - - // TODO: Resolve issue #415 and remove this temporary workaround. - if strings.HasSuffix(pkg.ImportPath, "/vendor/github.com/gopherjs/gopherjs/js") { - return nil, fmt.Errorf("vendoring github.com/gopherjs/gopherjs/js package is not supported, see https://github.com/gopherjs/gopherjs/issues/415") - } - - switch path { - case "os": - pkg.GoFiles = stripExecutable(pkg.GoFiles) // Need to strip executable implementation files, because some of them contain package scope variables that perform (indirectly) syscalls on init. - case "runtime": - pkg.GoFiles = []string{"error.go"} - case "runtime/internal/sys": - pkg.GoFiles = []string{fmt.Sprintf("zgoos_%s.go", buildContext.GOOS), "zversion.go"} - case "runtime/pprof": - pkg.GoFiles = nil - case "crypto/rand": - pkg.GoFiles = []string{"rand.go", "util.go"} - case "crypto/x509": - pkg.CgoFiles = nil - } - - if len(pkg.CgoFiles) > 0 { - return nil, &ImportCError{path} - } - - if pkg.IsCommand() { - pkg.PkgObj = filepath.Join(pkg.BinDir, filepath.Base(pkg.ImportPath)+".js") - } - - if _, err := os.Stat(pkg.PkgObj); os.IsNotExist(err) && strings.HasPrefix(pkg.PkgObj, build.Default.GOROOT) { - // fall back to GOPATH - firstGopathWorkspace := filepath.SplitList(build.Default.GOPATH)[0] // TODO: Need to check inside all GOPATH workspaces. - gopathPkgObj := filepath.Join(firstGopathWorkspace, pkg.PkgObj[len(build.Default.GOROOT):]) - if _, err := os.Stat(gopathPkgObj); err == nil { - pkg.PkgObj = gopathPkgObj - } - } - - jsFiles, err := jsFilesFromDir(pkg.Dir) - if err != nil { - return nil, err - } - - return &PackageData{Package: pkg, JSFiles: jsFiles}, nil -} - -// stripExecutable strips all executable implementation .go files. -// They have "executable_" prefix. -func stripExecutable(goFiles []string) []string { - var s []string - for _, f := range goFiles { - if strings.HasPrefix(f, "executable_") { - continue - } - s = append(s, f) - } - return s -} - -// ImportDir is like Import but processes the Go package found in the named -// directory. -func ImportDir(dir string, mode build.ImportMode, installSuffix string, buildTags []string) (*PackageData, error) { - pkg, err := NewBuildContext(installSuffix, buildTags).ImportDir(dir, mode) - if err != nil { - return nil, err - } - - jsFiles, err := jsFilesFromDir(pkg.Dir) - if err != nil { - return nil, err - } - - return &PackageData{Package: pkg, JSFiles: jsFiles}, nil -} - -// parseAndAugment parses and returns all .go files of given pkg. -// Standard Go library packages are augmented with files in compiler/natives folder. -// If isTest is true and pkg.ImportPath has no _test suffix, package is built for running internal tests. -// If isTest is true and pkg.ImportPath has _test suffix, package is built for running external tests. -// -// The native packages are augmented by the contents of natives.FS in the following way. -// The file names do not matter except the usual `_test` suffix. The files for -// native overrides get added to the package (even if they have the same name -// as an existing file from the standard library). For all identifiers that exist -// in the original AND the overrides, the original identifier in the AST gets -// replaced by `_`. New identifiers that don't exist in original package get added. -func parseAndAugment(pkg *build.Package, isTest bool, fileSet *token.FileSet) ([]*ast.File, error) { - var files []*ast.File - replacedDeclNames := make(map[string]bool) - funcName := func(d *ast.FuncDecl) string { - if d.Recv == nil || len(d.Recv.List) == 0 { - return d.Name.Name - } - recv := d.Recv.List[0].Type - if star, ok := recv.(*ast.StarExpr); ok { - recv = star.X - } - return recv.(*ast.Ident).Name + "." + d.Name.Name - } - isXTest := strings.HasSuffix(pkg.ImportPath, "_test") - importPath := pkg.ImportPath - if isXTest { - importPath = importPath[:len(importPath)-5] - } - - nativesContext := &build.Context{ - GOROOT: "/", - GOOS: build.Default.GOOS, - GOARCH: "js", - Compiler: "gc", - JoinPath: path.Join, - SplitPathList: func(list string) []string { - if list == "" { - return nil - } - return strings.Split(list, "/") - }, - IsAbsPath: path.IsAbs, - IsDir: func(name string) bool { - dir, err := natives.FS.Open(name) - if err != nil { - return false - } - defer dir.Close() - info, err := dir.Stat() - if err != nil { - return false - } - return info.IsDir() - }, - HasSubdir: func(root, name string) (rel string, ok bool) { - panic("not implemented") - }, - ReadDir: func(name string) (fi []os.FileInfo, err error) { - dir, err := natives.FS.Open(name) - if err != nil { - return nil, err - } - defer dir.Close() - return dir.Readdir(0) - }, - OpenFile: func(name string) (r io.ReadCloser, err error) { - return natives.FS.Open(name) - }, - } - if nativesPkg, err := nativesContext.Import(importPath, "", 0); err == nil { - names := nativesPkg.GoFiles - if isTest { - names = append(names, nativesPkg.TestGoFiles...) - } - if isXTest { - names = nativesPkg.XTestGoFiles - } - for _, name := range names { - fullPath := path.Join(nativesPkg.Dir, name) - r, err := nativesContext.OpenFile(fullPath) - if err != nil { - panic(err) - } - file, err := parser.ParseFile(fileSet, fullPath, r, parser.ParseComments) - if err != nil { - panic(err) - } - r.Close() - for _, decl := range file.Decls { - switch d := decl.(type) { - case *ast.FuncDecl: - replacedDeclNames[funcName(d)] = true - case *ast.GenDecl: - switch d.Tok { - case token.TYPE: - for _, spec := range d.Specs { - replacedDeclNames[spec.(*ast.TypeSpec).Name.Name] = true - } - case token.VAR, token.CONST: - for _, spec := range d.Specs { - for _, name := range spec.(*ast.ValueSpec).Names { - replacedDeclNames[name.Name] = true - } - } - } - } - } - files = append(files, file) - } - } - delete(replacedDeclNames, "init") - - var errList compiler.ErrorList - for _, name := range pkg.GoFiles { - if !filepath.IsAbs(name) { - name = filepath.Join(pkg.Dir, name) - } - r, err := os.Open(name) - if err != nil { - return nil, err - } - file, err := parser.ParseFile(fileSet, name, r, parser.ParseComments) - r.Close() - if err != nil { - if list, isList := err.(scanner.ErrorList); isList { - if len(list) > 10 { - list = append(list[:10], &scanner.Error{Pos: list[9].Pos, Msg: "too many errors"}) - } - for _, entry := range list { - errList = append(errList, entry) - } - continue - } - errList = append(errList, err) - continue - } - - switch pkg.ImportPath { - case "crypto/rand", "encoding/gob", "encoding/json", "expvar", "go/token", "log", "math/big", "math/rand", "regexp", "testing", "time": - for _, spec := range file.Imports { - path, _ := strconv.Unquote(spec.Path.Value) - if path == "sync" { - if spec.Name == nil { - spec.Name = ast.NewIdent("sync") - } - spec.Path.Value = `"github.com/gopherjs/gopherjs/nosync"` - } - } - } - - for _, decl := range file.Decls { - switch d := decl.(type) { - case *ast.FuncDecl: - if replacedDeclNames[funcName(d)] { - d.Name = ast.NewIdent("_") - } - case *ast.GenDecl: - switch d.Tok { - case token.TYPE: - for _, spec := range d.Specs { - s := spec.(*ast.TypeSpec) - if replacedDeclNames[s.Name.Name] { - s.Name = ast.NewIdent("_") - } - } - case token.VAR, token.CONST: - for _, spec := range d.Specs { - s := spec.(*ast.ValueSpec) - for i, name := range s.Names { - if replacedDeclNames[name.Name] { - s.Names[i] = ast.NewIdent("_") - } - } - } - } - } - } - files = append(files, file) - } - if errList != nil { - return nil, errList - } - return files, nil -} - -type Options struct { - GOROOT string - GOPATH string - Verbose bool - Quiet bool - Watch bool - CreateMapFile bool - MapToLocalDisk bool - Minify bool - Color bool - BuildTags []string -} - -func (o *Options) PrintError(format string, a ...interface{}) { - if o.Color { - format = "\x1B[31m" + format + "\x1B[39m" - } - fmt.Fprintf(os.Stderr, format, a...) -} - -func (o *Options) PrintSuccess(format string, a ...interface{}) { - if o.Color { - format = "\x1B[32m" + format + "\x1B[39m" - } - fmt.Fprintf(os.Stderr, format, a...) -} - -type PackageData struct { - *build.Package - JSFiles []string - IsTest bool // IsTest is true if the package is being built for running tests. - SrcModTime time.Time - UpToDate bool -} - -type Session struct { - options *Options - Archives map[string]*compiler.Archive - Types map[string]*types.Package - Watcher *fsnotify.Watcher -} - -func NewSession(options *Options) *Session { - if options.GOROOT == "" { - options.GOROOT = build.Default.GOROOT - } - if options.GOPATH == "" { - options.GOPATH = build.Default.GOPATH - } - options.Verbose = options.Verbose || options.Watch - - s := &Session{ - options: options, - Archives: make(map[string]*compiler.Archive), - } - s.Types = make(map[string]*types.Package) - if options.Watch { - if out, err := exec.Command("ulimit", "-n").Output(); err == nil { - if n, err := strconv.Atoi(strings.TrimSpace(string(out))); err == nil && n < 1024 { - fmt.Printf("Warning: The maximum number of open file descriptors is very low (%d). Change it with 'ulimit -n 8192'.\n", n) - } - } - - var err error - s.Watcher, err = fsnotify.NewWatcher() - if err != nil { - panic(err) - } - } - return s -} - -func (s *Session) InstallSuffix() string { - if s.options.Minify { - return "min" - } - return "" -} - -func (s *Session) BuildDir(packagePath string, importPath string, pkgObj string) error { - if s.Watcher != nil { - s.Watcher.Add(packagePath) - } - buildPkg, err := NewBuildContext(s.InstallSuffix(), s.options.BuildTags).ImportDir(packagePath, 0) - if err != nil { - return err - } - pkg := &PackageData{Package: buildPkg} - jsFiles, err := jsFilesFromDir(pkg.Dir) - if err != nil { - return err - } - pkg.JSFiles = jsFiles - archive, err := s.BuildPackage(pkg) - if err != nil { - return err - } - if pkgObj == "" { - pkgObj = filepath.Base(packagePath) + ".js" - } - if pkg.IsCommand() && !pkg.UpToDate { - if err := s.WriteCommandPackage(archive, pkgObj); err != nil { - return err - } - } - return nil -} - -func (s *Session) BuildFiles(filenames []string, pkgObj string, packagePath string) error { - pkg := &PackageData{ - Package: &build.Package{ - Name: "main", - ImportPath: "main", - Dir: packagePath, - }, - } - - for _, file := range filenames { - if strings.HasSuffix(file, ".inc.js") { - pkg.JSFiles = append(pkg.JSFiles, file) - continue - } - pkg.GoFiles = append(pkg.GoFiles, file) - } - - archive, err := s.BuildPackage(pkg) - if err != nil { - return err - } - if s.Types["main"].Name() != "main" { - return fmt.Errorf("cannot build/run non-main package") - } - return s.WriteCommandPackage(archive, pkgObj) -} - -func (s *Session) BuildImportPath(path string) (*compiler.Archive, error) { - _, archive, err := s.buildImportPathWithSrcDir(path, "") - return archive, err -} - -func (s *Session) buildImportPathWithSrcDir(path string, srcDir string) (*PackageData, *compiler.Archive, error) { - pkg, err := importWithSrcDir(path, srcDir, 0, s.InstallSuffix(), s.options.BuildTags) - if s.Watcher != nil && pkg != nil { // add watch even on error - s.Watcher.Add(pkg.Dir) - } - if err != nil { - return nil, nil, err - } - - archive, err := s.BuildPackage(pkg) - if err != nil { - return nil, nil, err - } - - return pkg, archive, nil -} - -func (s *Session) BuildPackage(pkg *PackageData) (*compiler.Archive, error) { - if archive, ok := s.Archives[pkg.ImportPath]; ok { - return archive, nil - } - - if pkg.PkgObj != "" { - var fileInfo os.FileInfo - gopherjsBinary, err := os.Executable() - if err == nil { - fileInfo, err = os.Stat(gopherjsBinary) - if err == nil { - pkg.SrcModTime = fileInfo.ModTime() - } - } - if err != nil { - os.Stderr.WriteString("Could not get GopherJS binary's modification timestamp. Please report issue.\n") - pkg.SrcModTime = time.Now() - } - - for _, importedPkgPath := range pkg.Imports { - // Ignore all imports that aren't mentioned in import specs of pkg. - // For example, this ignores imports such as runtime/internal/sys and runtime/internal/atomic. - ignored := true - for _, pos := range pkg.ImportPos[importedPkgPath] { - importFile := filepath.Base(pos.Filename) - for _, file := range pkg.GoFiles { - if importFile == file { - ignored = false - break - } - } - if !ignored { - break - } - } - - if importedPkgPath == "unsafe" || ignored { - continue - } - importedPkg, _, err := s.buildImportPathWithSrcDir(importedPkgPath, pkg.Dir) - if err != nil { - return nil, err - } - impModTime := importedPkg.SrcModTime - if impModTime.After(pkg.SrcModTime) { - pkg.SrcModTime = impModTime - } - } - - for _, name := range append(pkg.GoFiles, pkg.JSFiles...) { - fileInfo, err := os.Stat(filepath.Join(pkg.Dir, name)) - if err != nil { - return nil, err - } - if fileInfo.ModTime().After(pkg.SrcModTime) { - pkg.SrcModTime = fileInfo.ModTime() - } - } - - pkgObjFileInfo, err := os.Stat(pkg.PkgObj) - if err == nil && !pkg.SrcModTime.After(pkgObjFileInfo.ModTime()) { - // package object is up to date, load from disk if library - pkg.UpToDate = true - if pkg.IsCommand() { - return nil, nil - } - - objFile, err := os.Open(pkg.PkgObj) - if err != nil { - return nil, err - } - defer objFile.Close() - - archive, err := compiler.ReadArchive(pkg.PkgObj, pkg.ImportPath, objFile, s.Types) - if err != nil { - return nil, err - } - - s.Archives[pkg.ImportPath] = archive - return archive, err - } - } - - fileSet := token.NewFileSet() - files, err := parseAndAugment(pkg.Package, pkg.IsTest, fileSet) - if err != nil { - return nil, err - } - - localImportPathCache := make(map[string]*compiler.Archive) - importContext := &compiler.ImportContext{ - Packages: s.Types, - Import: func(path string) (*compiler.Archive, error) { - if archive, ok := localImportPathCache[path]; ok { - return archive, nil - } - _, archive, err := s.buildImportPathWithSrcDir(path, pkg.Dir) - if err != nil { - return nil, err - } - localImportPathCache[path] = archive - return archive, nil - }, - } - archive, err := compiler.Compile(pkg.ImportPath, files, fileSet, importContext, s.options.Minify) - if err != nil { - return nil, err - } - - for _, jsFile := range pkg.JSFiles { - code, err := ioutil.ReadFile(filepath.Join(pkg.Dir, jsFile)) - if err != nil { - return nil, err - } - archive.IncJSCode = append(archive.IncJSCode, []byte("\t(function() {\n")...) - archive.IncJSCode = append(archive.IncJSCode, code...) - archive.IncJSCode = append(archive.IncJSCode, []byte("\n\t}).call($global);\n")...) - } - - if s.options.Verbose { - fmt.Println(pkg.ImportPath) - } - - s.Archives[pkg.ImportPath] = archive - - if pkg.PkgObj == "" || pkg.IsCommand() { - return archive, nil - } - - if err := s.writeLibraryPackage(archive, pkg.PkgObj); err != nil { - if strings.HasPrefix(pkg.PkgObj, s.options.GOROOT) { - // fall back to first GOPATH workspace - firstGopathWorkspace := filepath.SplitList(s.options.GOPATH)[0] - if err := s.writeLibraryPackage(archive, filepath.Join(firstGopathWorkspace, pkg.PkgObj[len(s.options.GOROOT):])); err != nil { - return nil, err - } - return archive, nil - } - return nil, err - } - - return archive, nil -} - -func (s *Session) writeLibraryPackage(archive *compiler.Archive, pkgObj string) error { - if err := os.MkdirAll(filepath.Dir(pkgObj), 0777); err != nil { - return err - } - - objFile, err := os.Create(pkgObj) - if err != nil { - return err - } - defer objFile.Close() - - return compiler.WriteArchive(archive, objFile) -} - -func (s *Session) WriteCommandPackage(archive *compiler.Archive, pkgObj string) error { - if err := os.MkdirAll(filepath.Dir(pkgObj), 0777); err != nil { - return err - } - codeFile, err := os.Create(pkgObj) - if err != nil { - return err - } - defer codeFile.Close() - - sourceMapFilter := &compiler.SourceMapFilter{Writer: codeFile} - if s.options.CreateMapFile { - m := &sourcemap.Map{File: filepath.Base(pkgObj)} - mapFile, err := os.Create(pkgObj + ".map") - if err != nil { - return err - } - - defer func() { - m.WriteTo(mapFile) - mapFile.Close() - fmt.Fprintf(codeFile, "//# sourceMappingURL=%s.map\n", filepath.Base(pkgObj)) - }() - - sourceMapFilter.MappingCallback = NewMappingCallback(m, s.options.GOROOT, s.options.GOPATH, s.options.MapToLocalDisk) - } - - deps, err := compiler.ImportDependencies(archive, func(path string) (*compiler.Archive, error) { - if archive, ok := s.Archives[path]; ok { - return archive, nil - } - _, archive, err := s.buildImportPathWithSrcDir(path, "") - return archive, err - }) - if err != nil { - return err - } - return compiler.WriteProgramCode(deps, sourceMapFilter) -} - -func NewMappingCallback(m *sourcemap.Map, goroot, gopath string, localMap bool) func(generatedLine, generatedColumn int, originalPos token.Position) { - return func(generatedLine, generatedColumn int, originalPos token.Position) { - if !originalPos.IsValid() { - m.AddMapping(&sourcemap.Mapping{GeneratedLine: generatedLine, GeneratedColumn: generatedColumn}) - return - } - - file := originalPos.Filename - - switch hasGopathPrefix, prefixLen := hasGopathPrefix(file, gopath); { - case localMap: - // no-op: keep file as-is - case hasGopathPrefix: - file = filepath.ToSlash(file[prefixLen+4:]) - case strings.HasPrefix(file, goroot): - file = filepath.ToSlash(file[len(goroot)+4:]) - default: - file = filepath.Base(file) - } - - m.AddMapping(&sourcemap.Mapping{GeneratedLine: generatedLine, GeneratedColumn: generatedColumn, OriginalFile: file, OriginalLine: originalPos.Line, OriginalColumn: originalPos.Column}) - } -} - -func jsFilesFromDir(dir string) ([]string, error) { - files, err := ioutil.ReadDir(dir) - if err != nil { - return nil, err - } - var jsFiles []string - for _, file := range files { - if strings.HasSuffix(file.Name(), ".inc.js") && file.Name()[0] != '_' && file.Name()[0] != '.' { - jsFiles = append(jsFiles, file.Name()) - } - } - return jsFiles, nil -} - -// hasGopathPrefix returns true and the length of the matched GOPATH workspace, -// iff file has a prefix that matches one of the GOPATH workspaces. -func hasGopathPrefix(file, gopath string) (hasGopathPrefix bool, prefixLen int) { - gopathWorkspaces := filepath.SplitList(gopath) - for _, gopathWorkspace := range gopathWorkspaces { - gopathWorkspace = filepath.Clean(gopathWorkspace) - if strings.HasPrefix(file, gopathWorkspace) { - return true, len(gopathWorkspace) - } - } - return false, 0 -} - -func (s *Session) WaitForChange() { - s.options.PrintSuccess("watching for changes...\n") - for { - select { - case ev := <-s.Watcher.Events: - if ev.Op&(fsnotify.Create|fsnotify.Write|fsnotify.Remove|fsnotify.Rename) == 0 || filepath.Base(ev.Name)[0] == '.' { - continue - } - if !strings.HasSuffix(ev.Name, ".go") && !strings.HasSuffix(ev.Name, ".inc.js") { - continue - } - s.options.PrintSuccess("change detected: %s\n", ev.Name) - case err := <-s.Watcher.Errors: - s.options.PrintError("watcher error: %s\n", err.Error()) - } - break - } - - go func() { - for range s.Watcher.Events { - // consume, else Close() may deadlock - } - }() - s.Watcher.Close() -} diff --git a/vendor/github.com/gopherjs/gopherjs/build/build_test.go b/vendor/github.com/gopherjs/gopherjs/build/build_test.go deleted file mode 100644 index 837af1c49..000000000 --- a/vendor/github.com/gopherjs/gopherjs/build/build_test.go +++ /dev/null @@ -1,199 +0,0 @@ -package build - -import ( - "fmt" - gobuild "go/build" - "go/token" - "strconv" - "strings" - "testing" - - "github.com/kisielk/gotool" - "github.com/shurcooL/go/importgraphutil" -) - -// Natives augment the standard library with GopherJS-specific changes. -// This test ensures that none of the standard library packages are modified -// in a way that adds imports which the original upstream standard library package -// does not already import. Doing that can increase generated output size or cause -// other unexpected issues (since the cmd/go tool does not know about these extra imports), -// so it's best to avoid it. -// -// It checks all standard library packages. Each package is considered as a normal -// package, as a test package, and as an external test package. -func TestNativesDontImportExtraPackages(t *testing.T) { - // Calculate the forward import graph for all standard library packages. - // It's needed for populateImportSet. - stdOnly := gobuild.Default - stdOnly.GOPATH = "" // We only care about standard library, so skip all GOPATH packages. - forward, _, err := importgraphutil.BuildNoTests(&stdOnly) - if err != nil { - t.Fatalf("importgraphutil.BuildNoTests: %v", err) - } - - // populateImportSet takes a slice of imports, and populates set with those - // imports, as well as their transitive dependencies. That way, the set can - // be quickly queried to check if a package is in the import graph of imports. - // - // Note, this does not include transitive imports of test/xtest packages, - // which could cause some false positives. It currently doesn't, but if it does, - // then support for that should be added here. - populateImportSet := func(imports []string, set *stringSet) { - for _, p := range imports { - (*set)[p] = struct{}{} - switch p { - case "sync": - (*set)["github.com/gopherjs/gopherjs/nosync"] = struct{}{} - } - transitiveImports := forward.Search(p) - for p := range transitiveImports { - (*set)[p] = struct{}{} - } - } - } - - // Check all standard library packages. - // - // The general strategy is to first import each standard library package using the - // normal build.Import, which returns a *build.Package. That contains Imports, TestImports, - // and XTestImports values that are considered the "real imports". - // - // That list of direct imports is then expanded to the transitive closure by populateImportSet, - // meaning all packages that are indirectly imported are also added to the set. - // - // Then, github.com/gopherjs/gopherjs/build.parseAndAugment(*build.Package) returns []*ast.File. - // Those augmented parsed Go files of the package are checked, one file at at time, one import - // at a time. Each import is verified to belong in the set of allowed real imports. - for _, pkg := range gotool.ImportPaths([]string{"std"}) { - // Normal package. - { - // Import the real normal package, and populate its real import set. - bpkg, err := gobuild.Import(pkg, "", gobuild.ImportComment) - if err != nil { - t.Fatalf("gobuild.Import: %v", err) - } - realImports := make(stringSet) - populateImportSet(bpkg.Imports, &realImports) - - // Use parseAndAugment to get a list of augmented AST files. - fset := token.NewFileSet() - files, err := parseAndAugment(bpkg, false, fset) - if err != nil { - t.Fatalf("github.com/gopherjs/gopherjs/build.parseAndAugment: %v", err) - } - - // Verify imports of normal augmented AST files. - for _, f := range files { - fileName := fset.File(f.Pos()).Name() - normalFile := !strings.HasSuffix(fileName, "_test.go") - if !normalFile { - continue - } - for _, imp := range f.Imports { - importPath, err := strconv.Unquote(imp.Path.Value) - if err != nil { - t.Fatalf("strconv.Unquote(%v): %v", imp.Path.Value, err) - } - if importPath == "github.com/gopherjs/gopherjs/js" { - continue - } - if _, ok := realImports[importPath]; !ok { - t.Errorf("augmented normal package %q imports %q in file %v, but real %q doesn't:\nrealImports = %v", bpkg.ImportPath, importPath, fileName, bpkg.ImportPath, realImports) - } - } - } - } - - // Test package. - { - // Import the real test package, and populate its real import set. - bpkg, err := gobuild.Import(pkg, "", gobuild.ImportComment) - if err != nil { - t.Fatalf("gobuild.Import: %v", err) - } - realTestImports := make(stringSet) - populateImportSet(bpkg.TestImports, &realTestImports) - - // Use parseAndAugment to get a list of augmented AST files. - fset := token.NewFileSet() - files, err := parseAndAugment(bpkg, true, fset) - if err != nil { - t.Fatalf("github.com/gopherjs/gopherjs/build.parseAndAugment: %v", err) - } - - // Verify imports of test augmented AST files. - for _, f := range files { - fileName, pkgName := fset.File(f.Pos()).Name(), f.Name.String() - testFile := strings.HasSuffix(fileName, "_test.go") && !strings.HasSuffix(pkgName, "_test") - if !testFile { - continue - } - for _, imp := range f.Imports { - importPath, err := strconv.Unquote(imp.Path.Value) - if err != nil { - t.Fatalf("strconv.Unquote(%v): %v", imp.Path.Value, err) - } - if importPath == "github.com/gopherjs/gopherjs/js" { - continue - } - if _, ok := realTestImports[importPath]; !ok { - t.Errorf("augmented test package %q imports %q in file %v, but real %q doesn't:\nrealTestImports = %v", bpkg.ImportPath, importPath, fileName, bpkg.ImportPath, realTestImports) - } - } - } - } - - // External test package. - { - // Import the real external test package, and populate its real import set. - bpkg, err := gobuild.Import(pkg, "", gobuild.ImportComment) - if err != nil { - t.Fatalf("gobuild.Import: %v", err) - } - realXTestImports := make(stringSet) - populateImportSet(bpkg.XTestImports, &realXTestImports) - - // Add _test suffix to import path to cause parseAndAugment to use external test mode. - bpkg.ImportPath += "_test" - - // Use parseAndAugment to get a list of augmented AST files, then check only the external test files. - fset := token.NewFileSet() - files, err := parseAndAugment(bpkg, true, fset) - if err != nil { - t.Fatalf("github.com/gopherjs/gopherjs/build.parseAndAugment: %v", err) - } - - // Verify imports of external test augmented AST files. - for _, f := range files { - fileName, pkgName := fset.File(f.Pos()).Name(), f.Name.String() - xTestFile := strings.HasSuffix(fileName, "_test.go") && strings.HasSuffix(pkgName, "_test") - if !xTestFile { - continue - } - for _, imp := range f.Imports { - importPath, err := strconv.Unquote(imp.Path.Value) - if err != nil { - t.Fatalf("strconv.Unquote(%v): %v", imp.Path.Value, err) - } - if importPath == "github.com/gopherjs/gopherjs/js" { - continue - } - if _, ok := realXTestImports[importPath]; !ok { - t.Errorf("augmented external test package %q imports %q in file %v, but real %q doesn't:\nrealXTestImports = %v", bpkg.ImportPath, importPath, fileName, bpkg.ImportPath, realXTestImports) - } - } - } - } - } -} - -// stringSet is used to print a set of strings in a more readable way. -type stringSet map[string]struct{} - -func (m stringSet) String() string { - s := make([]string, 0, len(m)) - for v := range m { - s = append(s, v) - } - return fmt.Sprintf("%q", s) -} diff --git a/vendor/github.com/gopherjs/gopherjs/circle.yml b/vendor/github.com/gopherjs/gopherjs/circle.yml deleted file mode 100644 index fa572933b..000000000 --- a/vendor/github.com/gopherjs/gopherjs/circle.yml +++ /dev/null @@ -1,129 +0,0 @@ -machine: - node: - version: 6.2.2 - environment: - SOURCE_MAP_SUPPORT: false - -dependencies: - pre: - - cd /usr/local && sudo rm -rf go && curl https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz | sudo tar -xz && sudo chmod a+w go/src/path/filepath - post: - - mv ./gopherjs $HOME/bin - - npm install --global node-gyp - - cd node-syscall && node-gyp rebuild && mkdir -p ~/.node_libraries/ && cp build/Release/syscall.node ~/.node_libraries/syscall.node - -test: - override: - - diff -u <(echo -n) <(gofmt -d .) - - go tool vet *.go # Go package in root directory. - - for d in */; do echo $d; done | grep -v tests/ | grep -v third_party/ | xargs go tool vet # All subdirectories except "tests", "third_party". - - > - gopherjs test --short --minify - github.com/gopherjs/gopherjs/tests - github.com/gopherjs/gopherjs/tests/main - github.com/gopherjs/gopherjs/js - archive/tar - archive/zip - bufio - bytes - compress/bzip2 - compress/flate - compress/gzip - compress/lzw - compress/zlib - container/heap - container/list - container/ring - crypto/aes - crypto/cipher - crypto/des - crypto/dsa - crypto/ecdsa - crypto/elliptic - crypto/hmac - crypto/md5 - crypto/rand - crypto/rc4 - crypto/rsa - crypto/sha1 - crypto/sha256 - crypto/sha512 - crypto/subtle - crypto/x509 - database/sql - database/sql/driver - debug/dwarf - debug/elf - debug/macho - debug/pe - encoding/ascii85 - encoding/asn1 - encoding/base32 - encoding/base64 - encoding/binary - encoding/csv - encoding/gob - encoding/hex - encoding/json - encoding/pem - encoding/xml - errors - expvar - flag - fmt - go/ast - go/constant - go/doc - go/format - go/parser - go/printer - go/scanner - go/token - hash/adler32 - hash/crc32 - hash/crc64 - hash/fnv - html - html/template - image - image/color - image/draw - image/gif - image/jpeg - image/png - index/suffixarray - io - io/ioutil - math - math/big - math/cmplx - math/rand - mime - mime/multipart - mime/quotedprintable - net/http/cookiejar - net/http/fcgi - net/mail - net/rpc/jsonrpc - net/textproto - net/url - path - path/filepath - reflect - regexp - regexp/syntax - sort - strconv - strings - sync - sync/atomic - testing/quick - text/scanner - text/tabwriter - text/template - text/template/parse - time - unicode - unicode/utf16 - unicode/utf8 - - go test -v -race ./... diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/analysis/bool.go b/vendor/github.com/gopherjs/gopherjs/compiler/analysis/bool.go deleted file mode 100644 index cba7c1c14..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/analysis/bool.go +++ /dev/null @@ -1,43 +0,0 @@ -package analysis - -import ( - "go/ast" - "go/constant" - "go/token" - "go/types" -) - -func BoolValue(expr ast.Expr, info *types.Info) (bool, bool) { - v := info.Types[expr].Value - if v != nil && v.Kind() == constant.Bool { - return constant.BoolVal(v), true - } - switch e := expr.(type) { - case *ast.BinaryExpr: - switch e.Op { - case token.LAND: - if b, ok := BoolValue(e.X, info); ok { - if !b { - return false, true - } - return BoolValue(e.Y, info) - } - case token.LOR: - if b, ok := BoolValue(e.X, info); ok { - if b { - return true, true - } - return BoolValue(e.Y, info) - } - } - case *ast.UnaryExpr: - if e.Op == token.NOT { - if b, ok := BoolValue(e.X, info); ok { - return !b, true - } - } - case *ast.ParenExpr: - return BoolValue(e.X, info) - } - return false, false -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/analysis/break.go b/vendor/github.com/gopherjs/gopherjs/compiler/analysis/break.go deleted file mode 100644 index 579815d92..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/analysis/break.go +++ /dev/null @@ -1,32 +0,0 @@ -package analysis - -import ( - "go/ast" - "go/token" -) - -func HasBreak(n ast.Node) bool { - v := hasBreakVisitor{} - ast.Walk(&v, n) - return v.hasBreak -} - -type hasBreakVisitor struct { - hasBreak bool -} - -func (v *hasBreakVisitor) Visit(node ast.Node) (w ast.Visitor) { - if v.hasBreak { - return nil - } - switch n := node.(type) { - case *ast.BranchStmt: - if n.Tok == token.BREAK && n.Label == nil { - v.hasBreak = true - return nil - } - case *ast.ForStmt, *ast.RangeStmt, *ast.SwitchStmt, *ast.TypeSwitchStmt, *ast.SelectStmt, ast.Expr: - return nil - } - return v -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/analysis/escape.go b/vendor/github.com/gopherjs/gopherjs/compiler/analysis/escape.go deleted file mode 100644 index 2807ecf64..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/analysis/escape.go +++ /dev/null @@ -1,70 +0,0 @@ -package analysis - -import ( - "go/ast" - "go/token" - "go/types" -) - -func EscapingObjects(n ast.Node, info *types.Info) []*types.Var { - v := escapeAnalysis{ - info: info, - escaping: make(map[*types.Var]bool), - topScope: info.Scopes[n], - bottomScopes: make(map[*types.Scope]bool), - } - ast.Walk(&v, n) - var list []*types.Var - for obj := range v.escaping { - list = append(list, obj) - } - return list -} - -type escapeAnalysis struct { - info *types.Info - escaping map[*types.Var]bool - topScope *types.Scope - bottomScopes map[*types.Scope]bool -} - -func (v *escapeAnalysis) Visit(node ast.Node) (w ast.Visitor) { - // huge overapproximation - switch n := node.(type) { - case *ast.UnaryExpr: - if n.Op == token.AND { - if _, ok := n.X.(*ast.Ident); ok { - return &escapingObjectCollector{v} - } - } - case *ast.FuncLit: - v.bottomScopes[v.info.Scopes[n.Type]] = true - return &escapingObjectCollector{v} - case *ast.ForStmt: - v.bottomScopes[v.info.Scopes[n.Body]] = true - case *ast.RangeStmt: - v.bottomScopes[v.info.Scopes[n.Body]] = true - } - return v -} - -type escapingObjectCollector struct { - analysis *escapeAnalysis -} - -func (v *escapingObjectCollector) Visit(node ast.Node) (w ast.Visitor) { - if id, ok := node.(*ast.Ident); ok { - if obj, ok := v.analysis.info.Uses[id].(*types.Var); ok { - for s := obj.Parent(); s != nil; s = s.Parent() { - if s == v.analysis.topScope { - v.analysis.escaping[obj] = true - break - } - if v.analysis.bottomScopes[s] { - break - } - } - } - } - return v -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/analysis/info.go b/vendor/github.com/gopherjs/gopherjs/compiler/analysis/info.go deleted file mode 100644 index a8181615f..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/analysis/info.go +++ /dev/null @@ -1,254 +0,0 @@ -package analysis - -import ( - "go/ast" - "go/token" - "go/types" - - "github.com/gopherjs/gopherjs/compiler/astutil" - "github.com/gopherjs/gopherjs/compiler/typesutil" -) - -type continueStmt struct { - forStmt *ast.ForStmt - analyzeStack []ast.Node -} - -type Info struct { - *types.Info - Pkg *types.Package - IsBlocking func(*types.Func) bool - HasPointer map[*types.Var]bool - FuncDeclInfos map[*types.Func]*FuncInfo - FuncLitInfos map[*ast.FuncLit]*FuncInfo - InitFuncInfo *FuncInfo - allInfos []*FuncInfo - comments ast.CommentMap -} - -type FuncInfo struct { - HasDefer bool - Flattened map[ast.Node]bool - Blocking map[ast.Node]bool - GotoLabel map[*types.Label]bool - LocalCalls map[*types.Func][][]ast.Node - ContinueStmts []continueStmt - p *Info - analyzeStack []ast.Node -} - -func (info *Info) newFuncInfo() *FuncInfo { - funcInfo := &FuncInfo{ - p: info, - Flattened: make(map[ast.Node]bool), - Blocking: make(map[ast.Node]bool), - GotoLabel: make(map[*types.Label]bool), - LocalCalls: make(map[*types.Func][][]ast.Node), - } - info.allInfos = append(info.allInfos, funcInfo) - return funcInfo -} - -func AnalyzePkg(files []*ast.File, fileSet *token.FileSet, typesInfo *types.Info, typesPkg *types.Package, isBlocking func(*types.Func) bool) *Info { - info := &Info{ - Info: typesInfo, - Pkg: typesPkg, - HasPointer: make(map[*types.Var]bool), - comments: make(ast.CommentMap), - IsBlocking: isBlocking, - FuncDeclInfos: make(map[*types.Func]*FuncInfo), - FuncLitInfos: make(map[*ast.FuncLit]*FuncInfo), - } - info.InitFuncInfo = info.newFuncInfo() - - for _, file := range files { - for k, v := range ast.NewCommentMap(fileSet, file, file.Comments) { - info.comments[k] = v - } - ast.Walk(info.InitFuncInfo, file) - } - - for { - done := true - for _, funcInfo := range info.allInfos { - for obj, calls := range funcInfo.LocalCalls { - if len(info.FuncDeclInfos[obj].Blocking) != 0 { - for _, call := range calls { - funcInfo.markBlocking(call) - } - delete(funcInfo.LocalCalls, obj) - done = false - } - } - } - if done { - break - } - } - - for _, funcInfo := range info.allInfos { - for _, continueStmt := range funcInfo.ContinueStmts { - if funcInfo.Blocking[continueStmt.forStmt.Post] { - funcInfo.markBlocking(continueStmt.analyzeStack) - } - } - } - - return info -} - -func (c *FuncInfo) Visit(node ast.Node) ast.Visitor { - if node == nil { - if len(c.analyzeStack) != 0 { - c.analyzeStack = c.analyzeStack[:len(c.analyzeStack)-1] - } - return nil - } - c.analyzeStack = append(c.analyzeStack, node) - - switch n := node.(type) { - case *ast.FuncDecl: - newInfo := c.p.newFuncInfo() - c.p.FuncDeclInfos[c.p.Defs[n.Name].(*types.Func)] = newInfo - return newInfo - case *ast.FuncLit: - newInfo := c.p.newFuncInfo() - c.p.FuncLitInfos[n] = newInfo - return newInfo - case *ast.BranchStmt: - switch n.Tok { - case token.GOTO: - for _, n2 := range c.analyzeStack { - c.Flattened[n2] = true - } - c.GotoLabel[c.p.Uses[n.Label].(*types.Label)] = true - case token.CONTINUE: - if n.Label != nil { - label := c.p.Uses[n.Label].(*types.Label) - for i := len(c.analyzeStack) - 1; i >= 0; i-- { - if labelStmt, ok := c.analyzeStack[i].(*ast.LabeledStmt); ok && c.p.Defs[labelStmt.Label] == label { - if _, ok := labelStmt.Stmt.(*ast.RangeStmt); ok { - return nil - } - stack := make([]ast.Node, len(c.analyzeStack)) - copy(stack, c.analyzeStack) - c.ContinueStmts = append(c.ContinueStmts, continueStmt{labelStmt.Stmt.(*ast.ForStmt), stack}) - return nil - } - } - return nil - } - for i := len(c.analyzeStack) - 1; i >= 0; i-- { - if _, ok := c.analyzeStack[i].(*ast.RangeStmt); ok { - return nil - } - if forStmt, ok := c.analyzeStack[i].(*ast.ForStmt); ok { - stack := make([]ast.Node, len(c.analyzeStack)) - copy(stack, c.analyzeStack) - c.ContinueStmts = append(c.ContinueStmts, continueStmt{forStmt, stack}) - return nil - } - } - } - case *ast.CallExpr: - callTo := func(obj types.Object) { - switch o := obj.(type) { - case *types.Func: - if recv := o.Type().(*types.Signature).Recv(); recv != nil { - if _, ok := recv.Type().Underlying().(*types.Interface); ok { - c.markBlocking(c.analyzeStack) - return - } - } - if o.Pkg() != c.p.Pkg { - if c.p.IsBlocking(o) { - c.markBlocking(c.analyzeStack) - } - return - } - stack := make([]ast.Node, len(c.analyzeStack)) - copy(stack, c.analyzeStack) - c.LocalCalls[o] = append(c.LocalCalls[o], stack) - case *types.Var: - c.markBlocking(c.analyzeStack) - } - } - switch f := astutil.RemoveParens(n.Fun).(type) { - case *ast.Ident: - callTo(c.p.Uses[f]) - case *ast.SelectorExpr: - if sel := c.p.Selections[f]; sel != nil && typesutil.IsJsObject(sel.Recv()) { - break - } - callTo(c.p.Uses[f.Sel]) - case *ast.FuncLit: - ast.Walk(c, n.Fun) - for _, arg := range n.Args { - ast.Walk(c, arg) - } - if len(c.p.FuncLitInfos[f].Blocking) != 0 { - c.markBlocking(c.analyzeStack) - } - return nil - default: - if !astutil.IsTypeExpr(f, c.p.Info) { - c.markBlocking(c.analyzeStack) - } - } - case *ast.SendStmt: - c.markBlocking(c.analyzeStack) - case *ast.UnaryExpr: - switch n.Op { - case token.AND: - if id, ok := astutil.RemoveParens(n.X).(*ast.Ident); ok { - c.p.HasPointer[c.p.Uses[id].(*types.Var)] = true - } - case token.ARROW: - c.markBlocking(c.analyzeStack) - } - case *ast.RangeStmt: - if _, ok := c.p.TypeOf(n.X).Underlying().(*types.Chan); ok { - c.markBlocking(c.analyzeStack) - } - case *ast.SelectStmt: - for _, s := range n.Body.List { - if s.(*ast.CommClause).Comm == nil { // default clause - return c - } - } - c.markBlocking(c.analyzeStack) - case *ast.CommClause: - switch comm := n.Comm.(type) { - case *ast.SendStmt: - ast.Walk(c, comm.Chan) - ast.Walk(c, comm.Value) - case *ast.ExprStmt: - ast.Walk(c, comm.X.(*ast.UnaryExpr).X) - case *ast.AssignStmt: - ast.Walk(c, comm.Rhs[0].(*ast.UnaryExpr).X) - } - for _, s := range n.Body { - ast.Walk(c, s) - } - return nil - case *ast.GoStmt: - ast.Walk(c, n.Call.Fun) - for _, arg := range n.Call.Args { - ast.Walk(c, arg) - } - return nil - case *ast.DeferStmt: - c.HasDefer = true - if funcLit, ok := n.Call.Fun.(*ast.FuncLit); ok { - ast.Walk(c, funcLit.Body) - } - } - return c -} - -func (c *FuncInfo) markBlocking(stack []ast.Node) { - for _, n := range stack { - c.Blocking[n] = true - c.Flattened[n] = true - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/analysis/sideeffect.go b/vendor/github.com/gopherjs/gopherjs/compiler/analysis/sideeffect.go deleted file mode 100644 index a94d92b67..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/analysis/sideeffect.go +++ /dev/null @@ -1,37 +0,0 @@ -package analysis - -import ( - "go/ast" - "go/token" - "go/types" -) - -func HasSideEffect(n ast.Node, info *types.Info) bool { - v := hasSideEffectVisitor{info: info} - ast.Walk(&v, n) - return v.hasSideEffect -} - -type hasSideEffectVisitor struct { - info *types.Info - hasSideEffect bool -} - -func (v *hasSideEffectVisitor) Visit(node ast.Node) (w ast.Visitor) { - if v.hasSideEffect { - return nil - } - switch n := node.(type) { - case *ast.CallExpr: - if _, isSig := v.info.TypeOf(n.Fun).(*types.Signature); isSig { // skip conversions - v.hasSideEffect = true - return nil - } - case *ast.UnaryExpr: - if n.Op == token.ARROW { - v.hasSideEffect = true - return nil - } - } - return v -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/astutil/astutil.go b/vendor/github.com/gopherjs/gopherjs/compiler/astutil/astutil.go deleted file mode 100644 index 7cd93b3dd..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/astutil/astutil.go +++ /dev/null @@ -1,48 +0,0 @@ -package astutil - -import ( - "go/ast" - "go/types" -) - -func RemoveParens(e ast.Expr) ast.Expr { - for { - p, isParen := e.(*ast.ParenExpr) - if !isParen { - return e - } - e = p.X - } -} - -func SetType(info *types.Info, t types.Type, e ast.Expr) ast.Expr { - info.Types[e] = types.TypeAndValue{Type: t} - return e -} - -func NewIdent(name string, t types.Type, info *types.Info, pkg *types.Package) *ast.Ident { - ident := ast.NewIdent(name) - info.Types[ident] = types.TypeAndValue{Type: t} - obj := types.NewVar(0, pkg, name, t) - info.Uses[ident] = obj - return ident -} - -func IsTypeExpr(expr ast.Expr, info *types.Info) bool { - switch e := expr.(type) { - case *ast.ArrayType, *ast.ChanType, *ast.FuncType, *ast.InterfaceType, *ast.MapType, *ast.StructType: - return true - case *ast.StarExpr: - return IsTypeExpr(e.X, info) - case *ast.Ident: - _, ok := info.Uses[e].(*types.TypeName) - return ok - case *ast.SelectorExpr: - _, ok := info.Uses[e.Sel].(*types.TypeName) - return ok - case *ast.ParenExpr: - return IsTypeExpr(e.X, info) - default: - return false - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/compiler.go b/vendor/github.com/gopherjs/gopherjs/compiler/compiler.go deleted file mode 100644 index 5a2fd32ad..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/compiler.go +++ /dev/null @@ -1,293 +0,0 @@ -package compiler - -import ( - "bytes" - "encoding/binary" - "encoding/gob" - "encoding/json" - "fmt" - "go/token" - "go/types" - "io" - "strings" - - "github.com/gopherjs/gopherjs/compiler/prelude" - "github.com/gopherjs/gopherjs/third_party/importer" -) - -var sizes32 = &types.StdSizes{WordSize: 4, MaxAlign: 8} -var reservedKeywords = make(map[string]bool) -var _ = ___GOPHERJS_REQUIRES_GO_VERSION_1_8___ // Compile error on other Go versions, because they're not supported. - -func init() { - for _, keyword := range []string{"abstract", "arguments", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "eval", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "typeof", "undefined", "var", "void", "volatile", "while", "with", "yield"} { - reservedKeywords[keyword] = true - } -} - -type ErrorList []error - -func (err ErrorList) Error() string { - return err[0].Error() -} - -type Archive struct { - ImportPath string - Name string - Imports []string - ExportData []byte - Declarations []*Decl - IncJSCode []byte - FileSet []byte - Minified bool -} - -type Decl struct { - FullName string - Vars []string - DeclCode []byte - MethodListCode []byte - TypeInitCode []byte - InitCode []byte - DceObjectFilter string - DceMethodFilter string - DceDeps []string - Blocking bool -} - -type Dependency struct { - Pkg string - Type string - Method string -} - -func ImportDependencies(archive *Archive, importPkg func(string) (*Archive, error)) ([]*Archive, error) { - var deps []*Archive - paths := make(map[string]bool) - var collectDependencies func(path string) error - collectDependencies = func(path string) error { - if paths[path] { - return nil - } - dep, err := importPkg(path) - if err != nil { - return err - } - for _, imp := range dep.Imports { - if err := collectDependencies(imp); err != nil { - return err - } - } - deps = append(deps, dep) - paths[dep.ImportPath] = true - return nil - } - - if err := collectDependencies("runtime"); err != nil { - return nil, err - } - for _, imp := range archive.Imports { - if err := collectDependencies(imp); err != nil { - return nil, err - } - } - - deps = append(deps, archive) - return deps, nil -} - -type dceInfo struct { - decl *Decl - objectFilter string - methodFilter string -} - -func WriteProgramCode(pkgs []*Archive, w *SourceMapFilter) error { - mainPkg := pkgs[len(pkgs)-1] - minify := mainPkg.Minified - - byFilter := make(map[string][]*dceInfo) - var pendingDecls []*Decl - for _, pkg := range pkgs { - for _, d := range pkg.Declarations { - if d.DceObjectFilter == "" && d.DceMethodFilter == "" { - pendingDecls = append(pendingDecls, d) - continue - } - info := &dceInfo{decl: d} - if d.DceObjectFilter != "" { - info.objectFilter = pkg.ImportPath + "." + d.DceObjectFilter - byFilter[info.objectFilter] = append(byFilter[info.objectFilter], info) - } - if d.DceMethodFilter != "" { - info.methodFilter = pkg.ImportPath + "." + d.DceMethodFilter - byFilter[info.methodFilter] = append(byFilter[info.methodFilter], info) - } - } - } - - dceSelection := make(map[*Decl]struct{}) - for len(pendingDecls) != 0 { - d := pendingDecls[len(pendingDecls)-1] - pendingDecls = pendingDecls[:len(pendingDecls)-1] - - dceSelection[d] = struct{}{} - - for _, dep := range d.DceDeps { - if infos, ok := byFilter[dep]; ok { - delete(byFilter, dep) - for _, info := range infos { - if info.objectFilter == dep { - info.objectFilter = "" - } - if info.methodFilter == dep { - info.methodFilter = "" - } - if info.objectFilter == "" && info.methodFilter == "" { - pendingDecls = append(pendingDecls, info.decl) - } - } - } - } - } - - if _, err := w.Write([]byte("\"use strict\";\n(function() {\n\n")); err != nil { - return err - } - if _, err := w.Write(removeWhitespace([]byte(prelude.Prelude), minify)); err != nil { - return err - } - if _, err := w.Write([]byte("\n")); err != nil { - return err - } - - // write packages - for _, pkg := range pkgs { - if err := WritePkgCode(pkg, dceSelection, minify, w); err != nil { - return err - } - } - - if _, err := w.Write([]byte("$synthesizeMethods();\nvar $mainPkg = $packages[\"" + string(mainPkg.ImportPath) + "\"];\n$packages[\"runtime\"].$init();\n$go($mainPkg.$init, []);\n$flushConsole();\n\n}).call(this);\n")); err != nil { - return err - } - - return nil -} - -func WritePkgCode(pkg *Archive, dceSelection map[*Decl]struct{}, minify bool, w *SourceMapFilter) error { - if w.MappingCallback != nil && pkg.FileSet != nil { - w.fileSet = token.NewFileSet() - if err := w.fileSet.Read(json.NewDecoder(bytes.NewReader(pkg.FileSet)).Decode); err != nil { - panic(err) - } - } - if _, err := w.Write(pkg.IncJSCode); err != nil { - return err - } - if _, err := w.Write(removeWhitespace([]byte(fmt.Sprintf("$packages[\"%s\"] = (function() {\n", pkg.ImportPath)), minify)); err != nil { - return err - } - vars := []string{"$pkg = {}", "$init"} - var filteredDecls []*Decl - for _, d := range pkg.Declarations { - if _, ok := dceSelection[d]; ok { - vars = append(vars, d.Vars...) - filteredDecls = append(filteredDecls, d) - } - } - if _, err := w.Write(removeWhitespace([]byte(fmt.Sprintf("\tvar %s;\n", strings.Join(vars, ", "))), minify)); err != nil { - return err - } - for _, d := range filteredDecls { - if _, err := w.Write(d.DeclCode); err != nil { - return err - } - } - for _, d := range filteredDecls { - if _, err := w.Write(d.MethodListCode); err != nil { - return err - } - } - for _, d := range filteredDecls { - if _, err := w.Write(d.TypeInitCode); err != nil { - return err - } - } - - if _, err := w.Write(removeWhitespace([]byte("\t$init = function() {\n\t\t$pkg.$init = function() {};\n\t\t/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:\n"), minify)); err != nil { - return err - } - for _, d := range filteredDecls { - if _, err := w.Write(d.InitCode); err != nil { - return err - } - } - if _, err := w.Write(removeWhitespace([]byte("\t\t/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;\n\t};\n\t$pkg.$init = $init;\n\treturn $pkg;\n})();"), minify)); err != nil { - return err - } - if _, err := w.Write([]byte("\n")); err != nil { // keep this \n even when minified - return err - } - return nil -} - -func ReadArchive(filename, path string, r io.Reader, packages map[string]*types.Package) (*Archive, error) { - var a Archive - if err := gob.NewDecoder(r).Decode(&a); err != nil { - return nil, err - } - - var err error - _, packages[path], err = importer.ImportData(packages, a.ExportData) - if err != nil { - return nil, err - } - - return &a, nil -} - -func WriteArchive(a *Archive, w io.Writer) error { - return gob.NewEncoder(w).Encode(a) -} - -type SourceMapFilter struct { - Writer io.Writer - MappingCallback func(generatedLine, generatedColumn int, originalPos token.Position) - line int - column int - fileSet *token.FileSet -} - -func (f *SourceMapFilter) Write(p []byte) (n int, err error) { - var n2 int - for { - i := bytes.IndexByte(p, '\b') - w := p - if i != -1 { - w = p[:i] - } - - n2, err = f.Writer.Write(w) - n += n2 - for { - i := bytes.IndexByte(w, '\n') - if i == -1 { - f.column += len(w) - break - } - f.line++ - f.column = 0 - w = w[i+1:] - } - - if err != nil || i == -1 { - return - } - if f.MappingCallback != nil { - f.MappingCallback(f.line+1, f.column, f.fileSet.Position(token.Pos(binary.BigEndian.Uint32(p[i+1:i+5])))) - } - p = p[i+5:] - n += 5 - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/expressions.go b/vendor/github.com/gopherjs/gopherjs/compiler/expressions.go deleted file mode 100644 index d87b8c0d0..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/expressions.go +++ /dev/null @@ -1,1373 +0,0 @@ -package compiler - -import ( - "bytes" - "fmt" - "go/ast" - "go/constant" - "go/token" - "go/types" - "sort" - "strconv" - "strings" - - "github.com/gopherjs/gopherjs/compiler/analysis" - "github.com/gopherjs/gopherjs/compiler/astutil" - "github.com/gopherjs/gopherjs/compiler/typesutil" -) - -type expression struct { - str string - parens bool -} - -func (e *expression) String() string { - return e.str -} - -func (e *expression) StringWithParens() string { - if e.parens { - return "(" + e.str + ")" - } - return e.str -} - -func (c *funcContext) translateExpr(expr ast.Expr) *expression { - exprType := c.p.TypeOf(expr) - if value := c.p.Types[expr].Value; value != nil { - basic := exprType.Underlying().(*types.Basic) - switch { - case isBoolean(basic): - return c.formatExpr("%s", strconv.FormatBool(constant.BoolVal(value))) - case isInteger(basic): - if is64Bit(basic) { - if basic.Kind() == types.Int64 { - d, ok := constant.Int64Val(constant.ToInt(value)) - if !ok { - panic("could not get exact uint") - } - return c.formatExpr("new %s(%s, %s)", c.typeName(exprType), strconv.FormatInt(d>>32, 10), strconv.FormatUint(uint64(d)&(1<<32-1), 10)) - } - d, ok := constant.Uint64Val(constant.ToInt(value)) - if !ok { - panic("could not get exact uint") - } - return c.formatExpr("new %s(%s, %s)", c.typeName(exprType), strconv.FormatUint(d>>32, 10), strconv.FormatUint(d&(1<<32-1), 10)) - } - d, ok := constant.Int64Val(constant.ToInt(value)) - if !ok { - panic("could not get exact int") - } - return c.formatExpr("%s", strconv.FormatInt(d, 10)) - case isFloat(basic): - f, _ := constant.Float64Val(value) - return c.formatExpr("%s", strconv.FormatFloat(f, 'g', -1, 64)) - case isComplex(basic): - r, _ := constant.Float64Val(constant.Real(value)) - i, _ := constant.Float64Val(constant.Imag(value)) - if basic.Kind() == types.UntypedComplex { - exprType = types.Typ[types.Complex128] - } - return c.formatExpr("new %s(%s, %s)", c.typeName(exprType), strconv.FormatFloat(r, 'g', -1, 64), strconv.FormatFloat(i, 'g', -1, 64)) - case isString(basic): - return c.formatExpr("%s", encodeString(constant.StringVal(value))) - default: - panic("Unhandled constant type: " + basic.String()) - } - } - - var obj types.Object - switch e := expr.(type) { - case *ast.SelectorExpr: - obj = c.p.Uses[e.Sel] - case *ast.Ident: - obj = c.p.Defs[e] - if obj == nil { - obj = c.p.Uses[e] - } - } - - if obj != nil && typesutil.IsJsPackage(obj.Pkg()) { - switch obj.Name() { - case "Global": - return c.formatExpr("$global") - case "Module": - return c.formatExpr("$module") - case "Undefined": - return c.formatExpr("undefined") - } - } - - switch e := expr.(type) { - case *ast.CompositeLit: - if ptrType, isPointer := exprType.(*types.Pointer); isPointer { - exprType = ptrType.Elem() - } - - collectIndexedElements := func(elementType types.Type) []string { - var elements []string - i := 0 - zero := c.translateExpr(c.zeroValue(elementType)).String() - for _, element := range e.Elts { - if kve, isKve := element.(*ast.KeyValueExpr); isKve { - key, ok := constant.Int64Val(constant.ToInt(c.p.Types[kve.Key].Value)) - if !ok { - panic("could not get exact int") - } - i = int(key) - element = kve.Value - } - for len(elements) <= i { - elements = append(elements, zero) - } - elements[i] = c.translateImplicitConversionWithCloning(element, elementType).String() - i++ - } - return elements - } - - switch t := exprType.Underlying().(type) { - case *types.Array: - elements := collectIndexedElements(t.Elem()) - if len(elements) == 0 { - return c.formatExpr("%s.zero()", c.typeName(t)) - } - zero := c.translateExpr(c.zeroValue(t.Elem())).String() - for len(elements) < int(t.Len()) { - elements = append(elements, zero) - } - return c.formatExpr(`$toNativeArray(%s, [%s])`, typeKind(t.Elem()), strings.Join(elements, ", ")) - case *types.Slice: - return c.formatExpr("new %s([%s])", c.typeName(exprType), strings.Join(collectIndexedElements(t.Elem()), ", ")) - case *types.Map: - entries := make([]string, len(e.Elts)) - for i, element := range e.Elts { - kve := element.(*ast.KeyValueExpr) - entries[i] = fmt.Sprintf("{ k: %s, v: %s }", c.translateImplicitConversionWithCloning(kve.Key, t.Key()), c.translateImplicitConversionWithCloning(kve.Value, t.Elem())) - } - return c.formatExpr("$makeMap(%s.keyFor, [%s])", c.typeName(t.Key()), strings.Join(entries, ", ")) - case *types.Struct: - elements := make([]string, t.NumFields()) - isKeyValue := true - if len(e.Elts) != 0 { - _, isKeyValue = e.Elts[0].(*ast.KeyValueExpr) - } - if !isKeyValue { - for i, element := range e.Elts { - elements[i] = c.translateImplicitConversionWithCloning(element, t.Field(i).Type()).String() - } - } - if isKeyValue { - for i := range elements { - elements[i] = c.translateExpr(c.zeroValue(t.Field(i).Type())).String() - } - for _, element := range e.Elts { - kve := element.(*ast.KeyValueExpr) - for j := range elements { - if kve.Key.(*ast.Ident).Name == t.Field(j).Name() { - elements[j] = c.translateImplicitConversionWithCloning(kve.Value, t.Field(j).Type()).String() - break - } - } - } - } - return c.formatExpr("new %s.ptr(%s)", c.typeName(exprType), strings.Join(elements, ", ")) - default: - panic(fmt.Sprintf("Unhandled CompositeLit type: %T\n", t)) - } - - case *ast.FuncLit: - _, fun := translateFunction(e.Type, nil, e.Body, c, exprType.(*types.Signature), c.p.FuncLitInfos[e], "") - if len(c.p.escapingVars) != 0 { - names := make([]string, 0, len(c.p.escapingVars)) - for obj := range c.p.escapingVars { - names = append(names, c.p.objectNames[obj]) - } - sort.Strings(names) - list := strings.Join(names, ", ") - return c.formatExpr("(function(%s) { return %s; })(%s)", list, fun, list) - } - return c.formatExpr("(%s)", fun) - - case *ast.UnaryExpr: - t := c.p.TypeOf(e.X) - switch e.Op { - case token.AND: - if typesutil.IsJsObject(exprType) { - return c.formatExpr("%e.object", e.X) - } - - switch t.Underlying().(type) { - case *types.Struct, *types.Array: - return c.translateExpr(e.X) - } - - switch x := astutil.RemoveParens(e.X).(type) { - case *ast.CompositeLit: - return c.formatExpr("$newDataPointer(%e, %s)", x, c.typeName(c.p.TypeOf(e))) - case *ast.Ident: - obj := c.p.Uses[x].(*types.Var) - if c.p.escapingVars[obj] { - return c.formatExpr("(%1s.$ptr || (%1s.$ptr = new %2s(function() { return this.$target[0]; }, function($v) { this.$target[0] = $v; }, %1s)))", c.p.objectNames[obj], c.typeName(exprType)) - } - return c.formatExpr(`(%1s || (%1s = new %2s(function() { return %3s; }, function($v) { %4s })))`, c.varPtrName(obj), c.typeName(exprType), c.objectName(obj), c.translateAssign(x, c.newIdent("$v", exprType), false)) - case *ast.SelectorExpr: - sel, ok := c.p.SelectionOf(x) - if !ok { - // qualified identifier - obj := c.p.Uses[x.Sel].(*types.Var) - return c.formatExpr(`(%1s || (%1s = new %2s(function() { return %3s; }, function($v) { %4s })))`, c.varPtrName(obj), c.typeName(exprType), c.objectName(obj), c.translateAssign(x, c.newIdent("$v", exprType), false)) - } - newSel := &ast.SelectorExpr{X: c.newIdent("this.$target", c.p.TypeOf(x.X)), Sel: x.Sel} - c.setType(newSel, exprType) - c.p.additionalSelections[newSel] = sel - return c.formatExpr("(%1e.$ptr_%2s || (%1e.$ptr_%2s = new %3s(function() { return %4e; }, function($v) { %5s }, %1e)))", x.X, x.Sel.Name, c.typeName(exprType), newSel, c.translateAssign(newSel, c.newIdent("$v", exprType), false)) - case *ast.IndexExpr: - if _, ok := c.p.TypeOf(x.X).Underlying().(*types.Slice); ok { - return c.formatExpr("$indexPtr(%1e.$array, %1e.$offset + %2e, %3s)", x.X, x.Index, c.typeName(exprType)) - } - return c.formatExpr("$indexPtr(%e, %e, %s)", x.X, x.Index, c.typeName(exprType)) - case *ast.StarExpr: - return c.translateExpr(x.X) - default: - panic(fmt.Sprintf("Unhandled: %T\n", x)) - } - - case token.ARROW: - call := &ast.CallExpr{ - Fun: c.newIdent("$recv", types.NewSignature(nil, types.NewTuple(types.NewVar(0, nil, "", t)), types.NewTuple(types.NewVar(0, nil, "", exprType), types.NewVar(0, nil, "", types.Typ[types.Bool])), false)), - Args: []ast.Expr{e.X}, - } - c.Blocking[call] = true - if _, isTuple := exprType.(*types.Tuple); isTuple { - return c.formatExpr("%e", call) - } - return c.formatExpr("%e[0]", call) - } - - basic := t.Underlying().(*types.Basic) - switch e.Op { - case token.ADD: - return c.translateExpr(e.X) - case token.SUB: - switch { - case is64Bit(basic): - return c.formatExpr("new %1s(-%2h, -%2l)", c.typeName(t), e.X) - case isComplex(basic): - return c.formatExpr("new %1s(-%2r, -%2i)", c.typeName(t), e.X) - case isUnsigned(basic): - return c.fixNumber(c.formatExpr("-%e", e.X), basic) - default: - return c.formatExpr("-%e", e.X) - } - case token.XOR: - if is64Bit(basic) { - return c.formatExpr("new %1s(~%2h, ~%2l >>> 0)", c.typeName(t), e.X) - } - return c.fixNumber(c.formatExpr("~%e", e.X), basic) - case token.NOT: - return c.formatExpr("!%e", e.X) - default: - panic(e.Op) - } - - case *ast.BinaryExpr: - if e.Op == token.NEQ { - return c.formatExpr("!(%s)", c.translateExpr(&ast.BinaryExpr{ - X: e.X, - Op: token.EQL, - Y: e.Y, - })) - } - - t := c.p.TypeOf(e.X) - t2 := c.p.TypeOf(e.Y) - _, isInterface := t2.Underlying().(*types.Interface) - if isInterface || types.Identical(t, types.Typ[types.UntypedNil]) { - t = t2 - } - - if basic, isBasic := t.Underlying().(*types.Basic); isBasic && isNumeric(basic) { - if is64Bit(basic) { - switch e.Op { - case token.MUL: - return c.formatExpr("$mul64(%e, %e)", e.X, e.Y) - case token.QUO: - return c.formatExpr("$div64(%e, %e, false)", e.X, e.Y) - case token.REM: - return c.formatExpr("$div64(%e, %e, true)", e.X, e.Y) - case token.SHL: - return c.formatExpr("$shiftLeft64(%e, %f)", e.X, e.Y) - case token.SHR: - return c.formatExpr("$shiftRight%s(%e, %f)", toJavaScriptType(basic), e.X, e.Y) - case token.EQL: - return c.formatExpr("(%1h === %2h && %1l === %2l)", e.X, e.Y) - case token.LSS: - return c.formatExpr("(%1h < %2h || (%1h === %2h && %1l < %2l))", e.X, e.Y) - case token.LEQ: - return c.formatExpr("(%1h < %2h || (%1h === %2h && %1l <= %2l))", e.X, e.Y) - case token.GTR: - return c.formatExpr("(%1h > %2h || (%1h === %2h && %1l > %2l))", e.X, e.Y) - case token.GEQ: - return c.formatExpr("(%1h > %2h || (%1h === %2h && %1l >= %2l))", e.X, e.Y) - case token.ADD, token.SUB: - return c.formatExpr("new %3s(%1h %4t %2h, %1l %4t %2l)", e.X, e.Y, c.typeName(t), e.Op) - case token.AND, token.OR, token.XOR: - return c.formatExpr("new %3s(%1h %4t %2h, (%1l %4t %2l) >>> 0)", e.X, e.Y, c.typeName(t), e.Op) - case token.AND_NOT: - return c.formatExpr("new %3s(%1h & ~%2h, (%1l & ~%2l) >>> 0)", e.X, e.Y, c.typeName(t)) - default: - panic(e.Op) - } - } - - if isComplex(basic) { - switch e.Op { - case token.EQL: - return c.formatExpr("(%1r === %2r && %1i === %2i)", e.X, e.Y) - case token.ADD, token.SUB: - return c.formatExpr("new %3s(%1r %4t %2r, %1i %4t %2i)", e.X, e.Y, c.typeName(t), e.Op) - case token.MUL: - return c.formatExpr("new %3s(%1r * %2r - %1i * %2i, %1r * %2i + %1i * %2r)", e.X, e.Y, c.typeName(t)) - case token.QUO: - return c.formatExpr("$divComplex(%e, %e)", e.X, e.Y) - default: - panic(e.Op) - } - } - - switch e.Op { - case token.EQL: - return c.formatParenExpr("%e === %e", e.X, e.Y) - case token.LSS, token.LEQ, token.GTR, token.GEQ: - return c.formatExpr("%e %t %e", e.X, e.Op, e.Y) - case token.ADD, token.SUB: - return c.fixNumber(c.formatExpr("%e %t %e", e.X, e.Op, e.Y), basic) - case token.MUL: - switch basic.Kind() { - case types.Int32, types.Int: - return c.formatParenExpr("$imul(%e, %e)", e.X, e.Y) - case types.Uint32, types.Uintptr: - return c.formatParenExpr("$imul(%e, %e) >>> 0", e.X, e.Y) - } - return c.fixNumber(c.formatExpr("%e * %e", e.X, e.Y), basic) - case token.QUO: - if isInteger(basic) { - // cut off decimals - shift := ">>" - if isUnsigned(basic) { - shift = ">>>" - } - return c.formatExpr(`(%1s = %2e / %3e, (%1s === %1s && %1s !== 1/0 && %1s !== -1/0) ? %1s %4s 0 : $throwRuntimeError("integer divide by zero"))`, c.newVariable("_q"), e.X, e.Y, shift) - } - if basic.Kind() == types.Float32 { - return c.fixNumber(c.formatExpr("%e / %e", e.X, e.Y), basic) - } - return c.formatExpr("%e / %e", e.X, e.Y) - case token.REM: - return c.formatExpr(`(%1s = %2e %% %3e, %1s === %1s ? %1s : $throwRuntimeError("integer divide by zero"))`, c.newVariable("_r"), e.X, e.Y) - case token.SHL, token.SHR: - op := e.Op.String() - if e.Op == token.SHR && isUnsigned(basic) { - op = ">>>" - } - if v := c.p.Types[e.Y].Value; v != nil { - i, _ := constant.Uint64Val(constant.ToInt(v)) - if i >= 32 { - return c.formatExpr("0") - } - return c.fixNumber(c.formatExpr("%e %s %s", e.X, op, strconv.FormatUint(i, 10)), basic) - } - if e.Op == token.SHR && !isUnsigned(basic) { - return c.fixNumber(c.formatParenExpr("%e >> $min(%f, 31)", e.X, e.Y), basic) - } - y := c.newVariable("y") - return c.fixNumber(c.formatExpr("(%s = %f, %s < 32 ? (%e %s %s) : 0)", y, e.Y, y, e.X, op, y), basic) - case token.AND, token.OR: - if isUnsigned(basic) { - return c.formatParenExpr("(%e %t %e) >>> 0", e.X, e.Op, e.Y) - } - return c.formatParenExpr("%e %t %e", e.X, e.Op, e.Y) - case token.AND_NOT: - return c.fixNumber(c.formatParenExpr("%e & ~%e", e.X, e.Y), basic) - case token.XOR: - return c.fixNumber(c.formatParenExpr("%e ^ %e", e.X, e.Y), basic) - default: - panic(e.Op) - } - } - - switch e.Op { - case token.ADD, token.LSS, token.LEQ, token.GTR, token.GEQ: - return c.formatExpr("%e %t %e", e.X, e.Op, e.Y) - case token.LAND: - if c.Blocking[e.Y] { - skipCase := c.caseCounter - c.caseCounter++ - resultVar := c.newVariable("_v") - c.Printf("if (!(%s)) { %s = false; $s = %d; continue s; }", c.translateExpr(e.X), resultVar, skipCase) - c.Printf("%s = %s; case %d:", resultVar, c.translateExpr(e.Y), skipCase) - return c.formatExpr("%s", resultVar) - } - return c.formatExpr("%e && %e", e.X, e.Y) - case token.LOR: - if c.Blocking[e.Y] { - skipCase := c.caseCounter - c.caseCounter++ - resultVar := c.newVariable("_v") - c.Printf("if (%s) { %s = true; $s = %d; continue s; }", c.translateExpr(e.X), resultVar, skipCase) - c.Printf("%s = %s; case %d:", resultVar, c.translateExpr(e.Y), skipCase) - return c.formatExpr("%s", resultVar) - } - return c.formatExpr("%e || %e", e.X, e.Y) - case token.EQL: - switch u := t.Underlying().(type) { - case *types.Array, *types.Struct: - return c.formatExpr("$equal(%e, %e, %s)", e.X, e.Y, c.typeName(t)) - case *types.Interface: - return c.formatExpr("$interfaceIsEqual(%s, %s)", c.translateImplicitConversion(e.X, t), c.translateImplicitConversion(e.Y, t)) - case *types.Pointer: - if _, ok := u.Elem().Underlying().(*types.Array); ok { - return c.formatExpr("$equal(%s, %s, %s)", c.translateImplicitConversion(e.X, t), c.translateImplicitConversion(e.Y, t), c.typeName(u.Elem())) - } - case *types.Basic: - if isBoolean(u) { - if b, ok := analysis.BoolValue(e.X, c.p.Info.Info); ok && b { - return c.translateExpr(e.Y) - } - if b, ok := analysis.BoolValue(e.Y, c.p.Info.Info); ok && b { - return c.translateExpr(e.X) - } - } - } - return c.formatExpr("%s === %s", c.translateImplicitConversion(e.X, t), c.translateImplicitConversion(e.Y, t)) - default: - panic(e.Op) - } - - case *ast.ParenExpr: - return c.formatParenExpr("%e", e.X) - - case *ast.IndexExpr: - switch t := c.p.TypeOf(e.X).Underlying().(type) { - case *types.Array, *types.Pointer: - pattern := rangeCheck("%1e[%2f]", c.p.Types[e.Index].Value != nil, true) - if _, ok := t.(*types.Pointer); ok { // check pointer for nix (attribute getter causes a panic) - pattern = `(%1e.nilCheck, ` + pattern + `)` - } - return c.formatExpr(pattern, e.X, e.Index) - case *types.Slice: - return c.formatExpr(rangeCheck("%1e.$array[%1e.$offset + %2f]", c.p.Types[e.Index].Value != nil, false), e.X, e.Index) - case *types.Map: - if typesutil.IsJsObject(c.p.TypeOf(e.Index)) { - c.p.errList = append(c.p.errList, types.Error{Fset: c.p.fileSet, Pos: e.Index.Pos(), Msg: "cannot use js.Object as map key"}) - } - key := fmt.Sprintf("%s.keyFor(%s)", c.typeName(t.Key()), c.translateImplicitConversion(e.Index, t.Key())) - if _, isTuple := exprType.(*types.Tuple); isTuple { - return c.formatExpr(`(%1s = %2e[%3s], %1s !== undefined ? [%1s.v, true] : [%4e, false])`, c.newVariable("_entry"), e.X, key, c.zeroValue(t.Elem())) - } - return c.formatExpr(`(%1s = %2e[%3s], %1s !== undefined ? %1s.v : %4e)`, c.newVariable("_entry"), e.X, key, c.zeroValue(t.Elem())) - case *types.Basic: - return c.formatExpr("%e.charCodeAt(%f)", e.X, e.Index) - default: - panic(fmt.Sprintf("Unhandled IndexExpr: %T\n", t)) - } - - case *ast.SliceExpr: - if b, isBasic := c.p.TypeOf(e.X).Underlying().(*types.Basic); isBasic && isString(b) { - switch { - case e.Low == nil && e.High == nil: - return c.translateExpr(e.X) - case e.Low == nil: - return c.formatExpr("$substring(%e, 0, %f)", e.X, e.High) - case e.High == nil: - return c.formatExpr("$substring(%e, %f)", e.X, e.Low) - default: - return c.formatExpr("$substring(%e, %f, %f)", e.X, e.Low, e.High) - } - } - slice := c.translateConversionToSlice(e.X, exprType) - switch { - case e.Low == nil && e.High == nil: - return c.formatExpr("%s", slice) - case e.Low == nil: - if e.Max != nil { - return c.formatExpr("$subslice(%s, 0, %f, %f)", slice, e.High, e.Max) - } - return c.formatExpr("$subslice(%s, 0, %f)", slice, e.High) - case e.High == nil: - return c.formatExpr("$subslice(%s, %f)", slice, e.Low) - default: - if e.Max != nil { - return c.formatExpr("$subslice(%s, %f, %f, %f)", slice, e.Low, e.High, e.Max) - } - return c.formatExpr("$subslice(%s, %f, %f)", slice, e.Low, e.High) - } - - case *ast.SelectorExpr: - sel, ok := c.p.SelectionOf(e) - if !ok { - // qualified identifier - return c.formatExpr("%s", c.objectName(obj)) - } - - switch sel.Kind() { - case types.FieldVal: - fields, jsTag := c.translateSelection(sel, e.Pos()) - if jsTag != "" { - if _, ok := sel.Type().(*types.Signature); ok { - return c.formatExpr("$internalize(%1e.%2s.%3s, %4s, %1e.%2s)", e.X, strings.Join(fields, "."), jsTag, c.typeName(sel.Type())) - } - return c.internalize(c.formatExpr("%e.%s.%s", e.X, strings.Join(fields, "."), jsTag), sel.Type()) - } - return c.formatExpr("%e.%s", e.X, strings.Join(fields, ".")) - case types.MethodVal: - return c.formatExpr(`$methodVal(%s, "%s")`, c.makeReceiver(e), sel.Obj().(*types.Func).Name()) - case types.MethodExpr: - if !sel.Obj().Exported() { - c.p.dependencies[sel.Obj()] = true - } - if _, ok := sel.Recv().Underlying().(*types.Interface); ok { - return c.formatExpr(`$ifaceMethodExpr("%s")`, sel.Obj().(*types.Func).Name()) - } - return c.formatExpr(`$methodExpr(%s, "%s")`, c.typeName(sel.Recv()), sel.Obj().(*types.Func).Name()) - default: - panic(fmt.Sprintf("unexpected sel.Kind(): %T", sel.Kind())) - } - - case *ast.CallExpr: - plainFun := astutil.RemoveParens(e.Fun) - - if astutil.IsTypeExpr(plainFun, c.p.Info.Info) { - return c.formatExpr("(%s)", c.translateConversion(e.Args[0], c.p.TypeOf(plainFun))) - } - - sig := c.p.TypeOf(plainFun).Underlying().(*types.Signature) - - switch f := plainFun.(type) { - case *ast.Ident: - obj := c.p.Uses[f] - if o, ok := obj.(*types.Builtin); ok { - return c.translateBuiltin(o.Name(), sig, e.Args, e.Ellipsis.IsValid()) - } - if typesutil.IsJsPackage(obj.Pkg()) && obj.Name() == "InternalObject" { - return c.translateExpr(e.Args[0]) - } - return c.translateCall(e, sig, c.translateExpr(f)) - - case *ast.SelectorExpr: - sel, ok := c.p.SelectionOf(f) - if !ok { - // qualified identifier - obj := c.p.Uses[f.Sel] - if typesutil.IsJsPackage(obj.Pkg()) { - switch obj.Name() { - case "Debugger": - return c.formatExpr("debugger") - case "InternalObject": - return c.translateExpr(e.Args[0]) - } - } - return c.translateCall(e, sig, c.translateExpr(f)) - } - - externalizeExpr := func(e ast.Expr) string { - t := c.p.TypeOf(e) - if types.Identical(t, types.Typ[types.UntypedNil]) { - return "null" - } - return c.externalize(c.translateExpr(e).String(), t) - } - externalizeArgs := func(args []ast.Expr) string { - s := make([]string, len(args)) - for i, arg := range args { - s[i] = externalizeExpr(arg) - } - return strings.Join(s, ", ") - } - - switch sel.Kind() { - case types.MethodVal: - recv := c.makeReceiver(f) - declaredFuncRecv := sel.Obj().(*types.Func).Type().(*types.Signature).Recv().Type() - if typesutil.IsJsObject(declaredFuncRecv) { - globalRef := func(id string) string { - if recv.String() == "$global" && id[0] == '$' && len(id) > 1 { - return id - } - return recv.String() + "." + id - } - switch sel.Obj().Name() { - case "Get": - if id, ok := c.identifierConstant(e.Args[0]); ok { - return c.formatExpr("%s", globalRef(id)) - } - return c.formatExpr("%s[$externalize(%e, $String)]", recv, e.Args[0]) - case "Set": - if id, ok := c.identifierConstant(e.Args[0]); ok { - return c.formatExpr("%s = %s", globalRef(id), externalizeExpr(e.Args[1])) - } - return c.formatExpr("%s[$externalize(%e, $String)] = %s", recv, e.Args[0], externalizeExpr(e.Args[1])) - case "Delete": - return c.formatExpr("delete %s[$externalize(%e, $String)]", recv, e.Args[0]) - case "Length": - return c.formatExpr("$parseInt(%s.length)", recv) - case "Index": - return c.formatExpr("%s[%e]", recv, e.Args[0]) - case "SetIndex": - return c.formatExpr("%s[%e] = %s", recv, e.Args[0], externalizeExpr(e.Args[1])) - case "Call": - if id, ok := c.identifierConstant(e.Args[0]); ok { - if e.Ellipsis.IsValid() { - objVar := c.newVariable("obj") - return c.formatExpr("(%s = %s, %s.%s.apply(%s, %s))", objVar, recv, objVar, id, objVar, externalizeExpr(e.Args[1])) - } - return c.formatExpr("%s(%s)", globalRef(id), externalizeArgs(e.Args[1:])) - } - if e.Ellipsis.IsValid() { - objVar := c.newVariable("obj") - return c.formatExpr("(%s = %s, %s[$externalize(%e, $String)].apply(%s, %s))", objVar, recv, objVar, e.Args[0], objVar, externalizeExpr(e.Args[1])) - } - return c.formatExpr("%s[$externalize(%e, $String)](%s)", recv, e.Args[0], externalizeArgs(e.Args[1:])) - case "Invoke": - if e.Ellipsis.IsValid() { - return c.formatExpr("%s.apply(undefined, %s)", recv, externalizeExpr(e.Args[0])) - } - return c.formatExpr("%s(%s)", recv, externalizeArgs(e.Args)) - case "New": - if e.Ellipsis.IsValid() { - return c.formatExpr("new ($global.Function.prototype.bind.apply(%s, [undefined].concat(%s)))", recv, externalizeExpr(e.Args[0])) - } - return c.formatExpr("new (%s)(%s)", recv, externalizeArgs(e.Args)) - case "Bool": - return c.internalize(recv, types.Typ[types.Bool]) - case "String": - return c.internalize(recv, types.Typ[types.String]) - case "Int": - return c.internalize(recv, types.Typ[types.Int]) - case "Int64": - return c.internalize(recv, types.Typ[types.Int64]) - case "Uint64": - return c.internalize(recv, types.Typ[types.Uint64]) - case "Float": - return c.internalize(recv, types.Typ[types.Float64]) - case "Interface": - return c.internalize(recv, types.NewInterface(nil, nil)) - case "Unsafe": - return recv - default: - panic("Invalid js package object: " + sel.Obj().Name()) - } - } - - methodName := sel.Obj().Name() - if reservedKeywords[methodName] { - methodName += "$" - } - return c.translateCall(e, sig, c.formatExpr("%s.%s", recv, methodName)) - - case types.FieldVal: - fields, jsTag := c.translateSelection(sel, f.Pos()) - if jsTag != "" { - call := c.formatExpr("%e.%s.%s(%s)", f.X, strings.Join(fields, "."), jsTag, externalizeArgs(e.Args)) - switch sig.Results().Len() { - case 0: - return call - case 1: - return c.internalize(call, sig.Results().At(0).Type()) - default: - c.p.errList = append(c.p.errList, types.Error{Fset: c.p.fileSet, Pos: f.Pos(), Msg: "field with js tag can not have func type with multiple results"}) - } - } - return c.translateCall(e, sig, c.formatExpr("%e.%s", f.X, strings.Join(fields, "."))) - - case types.MethodExpr: - return c.translateCall(e, sig, c.translateExpr(f)) - - default: - panic(fmt.Sprintf("unexpected sel.Kind(): %T", sel.Kind())) - } - default: - return c.translateCall(e, sig, c.translateExpr(plainFun)) - } - - case *ast.StarExpr: - if typesutil.IsJsObject(c.p.TypeOf(e.X)) { - return c.formatExpr("new $jsObjectPtr(%e)", e.X) - } - if c1, isCall := e.X.(*ast.CallExpr); isCall && len(c1.Args) == 1 { - if c2, isCall := c1.Args[0].(*ast.CallExpr); isCall && len(c2.Args) == 1 && types.Identical(c.p.TypeOf(c2.Fun), types.Typ[types.UnsafePointer]) { - if unary, isUnary := c2.Args[0].(*ast.UnaryExpr); isUnary && unary.Op == token.AND { - return c.translateExpr(unary.X) // unsafe conversion - } - } - } - switch exprType.Underlying().(type) { - case *types.Struct, *types.Array: - return c.translateExpr(e.X) - } - return c.formatExpr("%e.$get()", e.X) - - case *ast.TypeAssertExpr: - if e.Type == nil { - return c.translateExpr(e.X) - } - t := c.p.TypeOf(e.Type) - if _, isTuple := exprType.(*types.Tuple); isTuple { - return c.formatExpr("$assertType(%e, %s, true)", e.X, c.typeName(t)) - } - return c.formatExpr("$assertType(%e, %s)", e.X, c.typeName(t)) - - case *ast.Ident: - if e.Name == "_" { - panic("Tried to translate underscore identifier.") - } - switch o := obj.(type) { - case *types.Var, *types.Const: - return c.formatExpr("%s", c.objectName(o)) - case *types.Func: - return c.formatExpr("%s", c.objectName(o)) - case *types.TypeName: - return c.formatExpr("%s", c.typeName(o.Type())) - case *types.Nil: - if typesutil.IsJsObject(exprType) { - return c.formatExpr("null") - } - switch t := exprType.Underlying().(type) { - case *types.Basic: - if t.Kind() != types.UnsafePointer { - panic("unexpected basic type") - } - return c.formatExpr("0") - case *types.Slice, *types.Pointer: - return c.formatExpr("%s.nil", c.typeName(exprType)) - case *types.Chan: - return c.formatExpr("$chanNil") - case *types.Map: - return c.formatExpr("false") - case *types.Interface: - return c.formatExpr("$ifaceNil") - case *types.Signature: - return c.formatExpr("$throwNilPointerError") - default: - panic(fmt.Sprintf("unexpected type: %T", t)) - } - default: - panic(fmt.Sprintf("Unhandled object: %T\n", o)) - } - - case nil: - return c.formatExpr("") - - default: - panic(fmt.Sprintf("Unhandled expression: %T\n", e)) - - } -} - -func (c *funcContext) translateCall(e *ast.CallExpr, sig *types.Signature, fun *expression) *expression { - args := c.translateArgs(sig, e.Args, e.Ellipsis.IsValid()) - if c.Blocking[e] { - resumeCase := c.caseCounter - c.caseCounter++ - returnVar := "$r" - if sig.Results().Len() != 0 { - returnVar = c.newVariable("_r") - } - c.Printf("%[1]s = %[2]s(%[3]s); /* */ $s = %[4]d; case %[4]d: if($c) { $c = false; %[1]s = %[1]s.$blk(); } if (%[1]s && %[1]s.$blk !== undefined) { break s; }", returnVar, fun, strings.Join(args, ", "), resumeCase) - if sig.Results().Len() != 0 { - return c.formatExpr("%s", returnVar) - } - return c.formatExpr("") - } - return c.formatExpr("%s(%s)", fun, strings.Join(args, ", ")) -} - -func (c *funcContext) makeReceiver(e *ast.SelectorExpr) *expression { - sel, _ := c.p.SelectionOf(e) - if !sel.Obj().Exported() { - c.p.dependencies[sel.Obj()] = true - } - - x := e.X - recvType := sel.Recv() - if len(sel.Index()) > 1 { - for _, index := range sel.Index()[:len(sel.Index())-1] { - if ptr, isPtr := recvType.(*types.Pointer); isPtr { - recvType = ptr.Elem() - } - s := recvType.Underlying().(*types.Struct) - recvType = s.Field(index).Type() - } - - fakeSel := &ast.SelectorExpr{X: x, Sel: ast.NewIdent("o")} - c.p.additionalSelections[fakeSel] = &fakeSelection{ - kind: types.FieldVal, - recv: sel.Recv(), - index: sel.Index()[:len(sel.Index())-1], - typ: recvType, - } - x = c.setType(fakeSel, recvType) - } - - _, isPointer := recvType.Underlying().(*types.Pointer) - methodsRecvType := sel.Obj().Type().(*types.Signature).Recv().Type() - _, pointerExpected := methodsRecvType.(*types.Pointer) - if !isPointer && pointerExpected { - recvType = types.NewPointer(recvType) - x = c.setType(&ast.UnaryExpr{Op: token.AND, X: x}, recvType) - } - if isPointer && !pointerExpected { - x = c.setType(x, methodsRecvType) - } - - recv := c.translateImplicitConversionWithCloning(x, methodsRecvType) - if isWrapped(recvType) { - recv = c.formatExpr("new %s(%s)", c.typeName(methodsRecvType), recv) - } - return recv -} - -func (c *funcContext) translateBuiltin(name string, sig *types.Signature, args []ast.Expr, ellipsis bool) *expression { - switch name { - case "new": - t := sig.Results().At(0).Type().(*types.Pointer) - if c.p.Pkg.Path() == "syscall" && types.Identical(t.Elem().Underlying(), types.Typ[types.Uintptr]) { - return c.formatExpr("new Uint8Array(8)") - } - switch t.Elem().Underlying().(type) { - case *types.Struct, *types.Array: - return c.formatExpr("%e", c.zeroValue(t.Elem())) - default: - return c.formatExpr("$newDataPointer(%e, %s)", c.zeroValue(t.Elem()), c.typeName(t)) - } - case "make": - switch argType := c.p.TypeOf(args[0]).Underlying().(type) { - case *types.Slice: - t := c.typeName(c.p.TypeOf(args[0])) - if len(args) == 3 { - return c.formatExpr("$makeSlice(%s, %f, %f)", t, args[1], args[2]) - } - return c.formatExpr("$makeSlice(%s, %f)", t, args[1]) - case *types.Map: - if len(args) == 2 && c.p.Types[args[1]].Value == nil { - return c.formatExpr(`((%1f < 0 || %1f > 2147483647) ? $throwRuntimeError("makemap: size out of range") : {})`, args[1]) - } - return c.formatExpr("{}") - case *types.Chan: - length := "0" - if len(args) == 2 { - length = c.formatExpr("%f", args[1]).String() - } - return c.formatExpr("new $Chan(%s, %s)", c.typeName(c.p.TypeOf(args[0]).Underlying().(*types.Chan).Elem()), length) - default: - panic(fmt.Sprintf("Unhandled make type: %T\n", argType)) - } - case "len": - switch argType := c.p.TypeOf(args[0]).Underlying().(type) { - case *types.Basic: - return c.formatExpr("%e.length", args[0]) - case *types.Slice: - return c.formatExpr("%e.$length", args[0]) - case *types.Pointer: - return c.formatExpr("(%e, %d)", args[0], argType.Elem().(*types.Array).Len()) - case *types.Map: - return c.formatExpr("$keys(%e).length", args[0]) - case *types.Chan: - return c.formatExpr("%e.$buffer.length", args[0]) - // length of array is constant - default: - panic(fmt.Sprintf("Unhandled len type: %T\n", argType)) - } - case "cap": - switch argType := c.p.TypeOf(args[0]).Underlying().(type) { - case *types.Slice, *types.Chan: - return c.formatExpr("%e.$capacity", args[0]) - case *types.Pointer: - return c.formatExpr("(%e, %d)", args[0], argType.Elem().(*types.Array).Len()) - // capacity of array is constant - default: - panic(fmt.Sprintf("Unhandled cap type: %T\n", argType)) - } - case "panic": - return c.formatExpr("$panic(%s)", c.translateImplicitConversion(args[0], types.NewInterface(nil, nil))) - case "append": - if ellipsis || len(args) == 1 { - argStr := c.translateArgs(sig, args, ellipsis) - return c.formatExpr("$appendSlice(%s, %s)", argStr[0], argStr[1]) - } - sliceType := sig.Results().At(0).Type().Underlying().(*types.Slice) - return c.formatExpr("$append(%e, %s)", args[0], strings.Join(c.translateExprSlice(args[1:], sliceType.Elem()), ", ")) - case "delete": - keyType := c.p.TypeOf(args[0]).Underlying().(*types.Map).Key() - return c.formatExpr(`delete %e[%s.keyFor(%s)]`, args[0], c.typeName(keyType), c.translateImplicitConversion(args[1], keyType)) - case "copy": - if basic, isBasic := c.p.TypeOf(args[1]).Underlying().(*types.Basic); isBasic && isString(basic) { - return c.formatExpr("$copyString(%e, %e)", args[0], args[1]) - } - return c.formatExpr("$copySlice(%e, %e)", args[0], args[1]) - case "print", "println": - return c.formatExpr("console.log(%s)", strings.Join(c.translateExprSlice(args, nil), ", ")) - case "complex": - argStr := c.translateArgs(sig, args, ellipsis) - return c.formatExpr("new %s(%s, %s)", c.typeName(sig.Results().At(0).Type()), argStr[0], argStr[1]) - case "real": - return c.formatExpr("%e.$real", args[0]) - case "imag": - return c.formatExpr("%e.$imag", args[0]) - case "recover": - return c.formatExpr("$recover()") - case "close": - return c.formatExpr(`$close(%e)`, args[0]) - default: - panic(fmt.Sprintf("Unhandled builtin: %s\n", name)) - } -} - -func (c *funcContext) identifierConstant(expr ast.Expr) (string, bool) { - val := c.p.Types[expr].Value - if val == nil { - return "", false - } - s := constant.StringVal(val) - if len(s) == 0 { - return "", false - } - for i, c := range s { - if !((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (i > 0 && c >= '0' && c <= '9') || c == '_' || c == '$') { - return "", false - } - } - return s, true -} - -func (c *funcContext) translateExprSlice(exprs []ast.Expr, desiredType types.Type) []string { - parts := make([]string, len(exprs)) - for i, expr := range exprs { - parts[i] = c.translateImplicitConversion(expr, desiredType).String() - } - return parts -} - -func (c *funcContext) translateConversion(expr ast.Expr, desiredType types.Type) *expression { - exprType := c.p.TypeOf(expr) - if types.Identical(exprType, desiredType) { - return c.translateExpr(expr) - } - - if c.p.Pkg.Path() == "reflect" { - if call, isCall := expr.(*ast.CallExpr); isCall && types.Identical(c.p.TypeOf(call.Fun), types.Typ[types.UnsafePointer]) { - if ptr, isPtr := desiredType.(*types.Pointer); isPtr { - if named, isNamed := ptr.Elem().(*types.Named); isNamed { - switch named.Obj().Name() { - case "arrayType", "chanType", "funcType", "interfaceType", "mapType", "ptrType", "sliceType", "structType": - return c.formatExpr("%e.kindType", call.Args[0]) // unsafe conversion - default: - return c.translateExpr(expr) - } - } - } - } - } - - switch t := desiredType.Underlying().(type) { - case *types.Basic: - switch { - case isInteger(t): - basicExprType := exprType.Underlying().(*types.Basic) - switch { - case is64Bit(t): - if !is64Bit(basicExprType) { - if basicExprType.Kind() == types.Uintptr { // this might be an Object returned from reflect.Value.Pointer() - return c.formatExpr("new %1s(0, %2e.constructor === Number ? %2e : 1)", c.typeName(desiredType), expr) - } - return c.formatExpr("new %s(0, %e)", c.typeName(desiredType), expr) - } - return c.formatExpr("new %1s(%2h, %2l)", c.typeName(desiredType), expr) - case is64Bit(basicExprType): - if !isUnsigned(t) && !isUnsigned(basicExprType) { - return c.fixNumber(c.formatParenExpr("%1l + ((%1h >> 31) * 4294967296)", expr), t) - } - return c.fixNumber(c.formatExpr("%s.$low", c.translateExpr(expr)), t) - case isFloat(basicExprType): - return c.formatParenExpr("%e >> 0", expr) - case types.Identical(exprType, types.Typ[types.UnsafePointer]): - return c.translateExpr(expr) - default: - return c.fixNumber(c.translateExpr(expr), t) - } - case isFloat(t): - if t.Kind() == types.Float32 && exprType.Underlying().(*types.Basic).Kind() == types.Float64 { - return c.formatExpr("$fround(%e)", expr) - } - return c.formatExpr("%f", expr) - case isComplex(t): - return c.formatExpr("new %1s(%2r, %2i)", c.typeName(desiredType), expr) - case isString(t): - value := c.translateExpr(expr) - switch et := exprType.Underlying().(type) { - case *types.Basic: - if is64Bit(et) { - value = c.formatExpr("%s.$low", value) - } - if isNumeric(et) { - return c.formatExpr("$encodeRune(%s)", value) - } - return value - case *types.Slice: - if types.Identical(et.Elem().Underlying(), types.Typ[types.Rune]) { - return c.formatExpr("$runesToString(%s)", value) - } - return c.formatExpr("$bytesToString(%s)", value) - default: - panic(fmt.Sprintf("Unhandled conversion: %v\n", et)) - } - case t.Kind() == types.UnsafePointer: - if unary, isUnary := expr.(*ast.UnaryExpr); isUnary && unary.Op == token.AND { - if indexExpr, isIndexExpr := unary.X.(*ast.IndexExpr); isIndexExpr { - return c.formatExpr("$sliceToArray(%s)", c.translateConversionToSlice(indexExpr.X, types.NewSlice(types.Typ[types.Uint8]))) - } - if ident, isIdent := unary.X.(*ast.Ident); isIdent && ident.Name == "_zero" { - return c.formatExpr("new Uint8Array(0)") - } - } - if ptr, isPtr := c.p.TypeOf(expr).(*types.Pointer); c.p.Pkg.Path() == "syscall" && isPtr { - if s, isStruct := ptr.Elem().Underlying().(*types.Struct); isStruct { - array := c.newVariable("_array") - target := c.newVariable("_struct") - c.Printf("%s = new Uint8Array(%d);", array, sizes32.Sizeof(s)) - c.Delayed(func() { - c.Printf("%s = %s, %s;", target, c.translateExpr(expr), c.loadStruct(array, target, s)) - }) - return c.formatExpr("%s", array) - } - } - if call, ok := expr.(*ast.CallExpr); ok { - if id, ok := call.Fun.(*ast.Ident); ok && id.Name == "new" { - return c.formatExpr("new Uint8Array(%d)", int(sizes32.Sizeof(c.p.TypeOf(call.Args[0])))) - } - } - } - - case *types.Slice: - switch et := exprType.Underlying().(type) { - case *types.Basic: - if isString(et) { - if types.Identical(t.Elem().Underlying(), types.Typ[types.Rune]) { - return c.formatExpr("new %s($stringToRunes(%e))", c.typeName(desiredType), expr) - } - return c.formatExpr("new %s($stringToBytes(%e))", c.typeName(desiredType), expr) - } - case *types.Array, *types.Pointer: - return c.formatExpr("new %s(%e)", c.typeName(desiredType), expr) - } - - case *types.Pointer: - switch u := t.Elem().Underlying().(type) { - case *types.Array: - return c.translateExpr(expr) - case *types.Struct: - if c.p.Pkg.Path() == "syscall" && types.Identical(exprType, types.Typ[types.UnsafePointer]) { - array := c.newVariable("_array") - target := c.newVariable("_struct") - return c.formatExpr("(%s = %e, %s = %e, %s, %s)", array, expr, target, c.zeroValue(t.Elem()), c.loadStruct(array, target, u), target) - } - return c.formatExpr("$pointerOfStructConversion(%e, %s)", expr, c.typeName(t)) - } - - if !types.Identical(exprType, types.Typ[types.UnsafePointer]) { - exprTypeElem := exprType.Underlying().(*types.Pointer).Elem() - ptrVar := c.newVariable("_ptr") - getterConv := c.translateConversion(c.setType(&ast.StarExpr{X: c.newIdent(ptrVar, exprType)}, exprTypeElem), t.Elem()) - setterConv := c.translateConversion(c.newIdent("$v", t.Elem()), exprTypeElem) - return c.formatExpr("(%1s = %2e, new %3s(function() { return %4s; }, function($v) { %1s.$set(%5s); }, %1s.$target))", ptrVar, expr, c.typeName(desiredType), getterConv, setterConv) - } - - case *types.Interface: - if types.Identical(exprType, types.Typ[types.UnsafePointer]) { - return c.translateExpr(expr) - } - } - - return c.translateImplicitConversionWithCloning(expr, desiredType) -} - -func (c *funcContext) translateImplicitConversionWithCloning(expr ast.Expr, desiredType types.Type) *expression { - switch desiredType.Underlying().(type) { - case *types.Struct, *types.Array: - switch expr.(type) { - case nil, *ast.CompositeLit: - // nothing - default: - return c.formatExpr("$clone(%e, %s)", expr, c.typeName(desiredType)) - } - } - - return c.translateImplicitConversion(expr, desiredType) -} - -func (c *funcContext) translateImplicitConversion(expr ast.Expr, desiredType types.Type) *expression { - if desiredType == nil { - return c.translateExpr(expr) - } - - exprType := c.p.TypeOf(expr) - if types.Identical(exprType, desiredType) { - return c.translateExpr(expr) - } - - basicExprType, isBasicExpr := exprType.Underlying().(*types.Basic) - if isBasicExpr && basicExprType.Kind() == types.UntypedNil { - return c.formatExpr("%e", c.zeroValue(desiredType)) - } - - switch desiredType.Underlying().(type) { - case *types.Slice: - return c.formatExpr("$subslice(new %1s(%2e.$array), %2e.$offset, %2e.$offset + %2e.$length)", c.typeName(desiredType), expr) - - case *types.Interface: - if typesutil.IsJsObject(exprType) { - // wrap JS object into js.Object struct when converting to interface - return c.formatExpr("new $jsObjectPtr(%e)", expr) - } - if isWrapped(exprType) { - return c.formatExpr("new %s(%e)", c.typeName(exprType), expr) - } - if _, isStruct := exprType.Underlying().(*types.Struct); isStruct { - return c.formatExpr("new %1e.constructor.elem(%1e)", expr) - } - } - - return c.translateExpr(expr) -} - -func (c *funcContext) translateConversionToSlice(expr ast.Expr, desiredType types.Type) *expression { - switch c.p.TypeOf(expr).Underlying().(type) { - case *types.Array, *types.Pointer: - return c.formatExpr("new %s(%e)", c.typeName(desiredType), expr) - } - return c.translateExpr(expr) -} - -func (c *funcContext) loadStruct(array, target string, s *types.Struct) string { - view := c.newVariable("_view") - code := fmt.Sprintf("%s = new DataView(%s.buffer, %s.byteOffset)", view, array, array) - var fields []*types.Var - var collectFields func(s *types.Struct, path string) - collectFields = func(s *types.Struct, path string) { - for i := 0; i < s.NumFields(); i++ { - field := s.Field(i) - if fs, isStruct := field.Type().Underlying().(*types.Struct); isStruct { - collectFields(fs, path+"."+fieldName(s, i)) - continue - } - fields = append(fields, types.NewVar(0, nil, path+"."+fieldName(s, i), field.Type())) - } - } - collectFields(s, target) - offsets := sizes32.Offsetsof(fields) - for i, field := range fields { - switch t := field.Type().Underlying().(type) { - case *types.Basic: - if isNumeric(t) { - if is64Bit(t) { - code += fmt.Sprintf(", %s = new %s(%s.getUint32(%d, true), %s.getUint32(%d, true))", field.Name(), c.typeName(field.Type()), view, offsets[i]+4, view, offsets[i]) - break - } - code += fmt.Sprintf(", %s = %s.get%s(%d, true)", field.Name(), view, toJavaScriptType(t), offsets[i]) - } - case *types.Array: - code += fmt.Sprintf(`, %s = new ($nativeArray(%s))(%s.buffer, $min(%s.byteOffset + %d, %s.buffer.byteLength))`, field.Name(), typeKind(t.Elem()), array, array, offsets[i], array) - } - } - return code -} - -func (c *funcContext) fixNumber(value *expression, basic *types.Basic) *expression { - switch basic.Kind() { - case types.Int8: - return c.formatParenExpr("%s << 24 >> 24", value) - case types.Uint8: - return c.formatParenExpr("%s << 24 >>> 24", value) - case types.Int16: - return c.formatParenExpr("%s << 16 >> 16", value) - case types.Uint16: - return c.formatParenExpr("%s << 16 >>> 16", value) - case types.Int32, types.Int, types.UntypedInt: - return c.formatParenExpr("%s >> 0", value) - case types.Uint32, types.Uint, types.Uintptr: - return c.formatParenExpr("%s >>> 0", value) - case types.Float32: - return c.formatExpr("$fround(%s)", value) - case types.Float64: - return value - default: - panic(fmt.Sprintf("fixNumber: unhandled basic.Kind(): %s", basic.String())) - } -} - -func (c *funcContext) internalize(s *expression, t types.Type) *expression { - if typesutil.IsJsObject(t) { - return s - } - switch u := t.Underlying().(type) { - case *types.Basic: - switch { - case isBoolean(u): - return c.formatExpr("!!(%s)", s) - case isInteger(u) && !is64Bit(u): - return c.fixNumber(c.formatExpr("$parseInt(%s)", s), u) - case isFloat(u): - return c.formatExpr("$parseFloat(%s)", s) - } - } - return c.formatExpr("$internalize(%s, %s)", s, c.typeName(t)) -} - -func (c *funcContext) formatExpr(format string, a ...interface{}) *expression { - return c.formatExprInternal(format, a, false) -} - -func (c *funcContext) formatParenExpr(format string, a ...interface{}) *expression { - return c.formatExprInternal(format, a, true) -} - -func (c *funcContext) formatExprInternal(format string, a []interface{}, parens bool) *expression { - processFormat := func(f func(uint8, uint8, int)) { - n := 0 - for i := 0; i < len(format); i++ { - b := format[i] - if b == '%' { - i++ - k := format[i] - if k >= '0' && k <= '9' { - n = int(k - '0' - 1) - i++ - k = format[i] - } - f(0, k, n) - n++ - continue - } - f(b, 0, 0) - } - } - - counts := make([]int, len(a)) - processFormat(func(b, k uint8, n int) { - switch k { - case 'e', 'f', 'h', 'l', 'r', 'i': - counts[n]++ - } - }) - - out := bytes.NewBuffer(nil) - vars := make([]string, len(a)) - hasAssignments := false - for i, e := range a { - if counts[i] <= 1 { - continue - } - if _, isIdent := e.(*ast.Ident); isIdent { - continue - } - if val := c.p.Types[e.(ast.Expr)].Value; val != nil { - continue - } - if !hasAssignments { - hasAssignments = true - out.WriteByte('(') - parens = false - } - v := c.newVariable("x") - out.WriteString(v + " = " + c.translateExpr(e.(ast.Expr)).String() + ", ") - vars[i] = v - } - - processFormat(func(b, k uint8, n int) { - writeExpr := func(suffix string) { - if vars[n] != "" { - out.WriteString(vars[n] + suffix) - return - } - out.WriteString(c.translateExpr(a[n].(ast.Expr)).StringWithParens() + suffix) - } - switch k { - case 0: - out.WriteByte(b) - case 's': - if e, ok := a[n].(*expression); ok { - out.WriteString(e.StringWithParens()) - return - } - out.WriteString(a[n].(string)) - case 'd': - out.WriteString(strconv.Itoa(a[n].(int))) - case 't': - out.WriteString(a[n].(token.Token).String()) - case 'e': - e := a[n].(ast.Expr) - if val := c.p.Types[e].Value; val != nil { - out.WriteString(c.translateExpr(e).String()) - return - } - writeExpr("") - case 'f': - e := a[n].(ast.Expr) - if val := c.p.Types[e].Value; val != nil { - d, _ := constant.Int64Val(constant.ToInt(val)) - out.WriteString(strconv.FormatInt(d, 10)) - return - } - if is64Bit(c.p.TypeOf(e).Underlying().(*types.Basic)) { - out.WriteString("$flatten64(") - writeExpr("") - out.WriteString(")") - return - } - writeExpr("") - case 'h': - e := a[n].(ast.Expr) - if val := c.p.Types[e].Value; val != nil { - d, _ := constant.Uint64Val(constant.ToInt(val)) - if c.p.TypeOf(e).Underlying().(*types.Basic).Kind() == types.Int64 { - out.WriteString(strconv.FormatInt(int64(d)>>32, 10)) - return - } - out.WriteString(strconv.FormatUint(d>>32, 10)) - return - } - writeExpr(".$high") - case 'l': - if val := c.p.Types[a[n].(ast.Expr)].Value; val != nil { - d, _ := constant.Uint64Val(constant.ToInt(val)) - out.WriteString(strconv.FormatUint(d&(1<<32-1), 10)) - return - } - writeExpr(".$low") - case 'r': - if val := c.p.Types[a[n].(ast.Expr)].Value; val != nil { - r, _ := constant.Float64Val(constant.Real(val)) - out.WriteString(strconv.FormatFloat(r, 'g', -1, 64)) - return - } - writeExpr(".$real") - case 'i': - if val := c.p.Types[a[n].(ast.Expr)].Value; val != nil { - i, _ := constant.Float64Val(constant.Imag(val)) - out.WriteString(strconv.FormatFloat(i, 'g', -1, 64)) - return - } - writeExpr(".$imag") - case '%': - out.WriteRune('%') - default: - panic(fmt.Sprintf("formatExpr: %%%c%d", k, n)) - } - }) - - if hasAssignments { - out.WriteByte(')') - } - return &expression{str: out.String(), parens: parens} -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/filter/assign.go b/vendor/github.com/gopherjs/gopherjs/compiler/filter/assign.go deleted file mode 100644 index 2681d4c6a..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/filter/assign.go +++ /dev/null @@ -1,106 +0,0 @@ -package filter - -import ( - "go/ast" - "go/token" - "go/types" - - "github.com/gopherjs/gopherjs/compiler/astutil" -) - -func Assign(stmt ast.Stmt, info *types.Info, pkg *types.Package) ast.Stmt { - if s, ok := stmt.(*ast.AssignStmt); ok && s.Tok != token.ASSIGN && s.Tok != token.DEFINE { - var op token.Token - switch s.Tok { - case token.ADD_ASSIGN: - op = token.ADD - case token.SUB_ASSIGN: - op = token.SUB - case token.MUL_ASSIGN: - op = token.MUL - case token.QUO_ASSIGN: - op = token.QUO - case token.REM_ASSIGN: - op = token.REM - case token.AND_ASSIGN: - op = token.AND - case token.OR_ASSIGN: - op = token.OR - case token.XOR_ASSIGN: - op = token.XOR - case token.SHL_ASSIGN: - op = token.SHL - case token.SHR_ASSIGN: - op = token.SHR - case token.AND_NOT_ASSIGN: - op = token.AND_NOT - default: - panic(s.Tok) - } - - var list []ast.Stmt - - var viaTmpVars func(expr ast.Expr, name string) ast.Expr - viaTmpVars = func(expr ast.Expr, name string) ast.Expr { - switch e := astutil.RemoveParens(expr).(type) { - case *ast.IndexExpr: - return astutil.SetType(info, info.TypeOf(e), &ast.IndexExpr{ - X: viaTmpVars(e.X, "_slice"), - Index: viaTmpVars(e.Index, "_index"), - }) - - case *ast.SelectorExpr: - sel, ok := info.Selections[e] - if !ok { - // qualified identifier - return e - } - newSel := &ast.SelectorExpr{ - X: viaTmpVars(e.X, "_struct"), - Sel: e.Sel, - } - info.Selections[newSel] = sel - return astutil.SetType(info, info.TypeOf(e), newSel) - - case *ast.StarExpr: - return astutil.SetType(info, info.TypeOf(e), &ast.StarExpr{ - X: viaTmpVars(e.X, "_ptr"), - }) - - case *ast.Ident, *ast.BasicLit: - return e - - default: - tmpVar := astutil.NewIdent(name, info.TypeOf(e), info, pkg) - list = append(list, &ast.AssignStmt{ - Lhs: []ast.Expr{tmpVar}, - Tok: token.DEFINE, - Rhs: []ast.Expr{e}, - }) - return tmpVar - - } - } - - lhs := viaTmpVars(s.Lhs[0], "_val") - - list = append(list, &ast.AssignStmt{ - Lhs: []ast.Expr{lhs}, - Tok: token.ASSIGN, - Rhs: []ast.Expr{ - astutil.SetType(info, info.TypeOf(s.Lhs[0]), &ast.BinaryExpr{ - X: lhs, - Op: op, - Y: astutil.SetType(info, info.TypeOf(s.Rhs[0]), &ast.ParenExpr{ - X: s.Rhs[0], - }), - }), - }, - }) - - return &ast.BlockStmt{ - List: list, - } - } - return stmt -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/filter/incdecstmt.go b/vendor/github.com/gopherjs/gopherjs/compiler/filter/incdecstmt.go deleted file mode 100644 index c4899ba1d..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/filter/incdecstmt.go +++ /dev/null @@ -1,39 +0,0 @@ -package filter - -import ( - "go/ast" - "go/constant" - "go/token" - "go/types" -) - -func IncDecStmt(stmt ast.Stmt, info *types.Info) ast.Stmt { - if s, ok := stmt.(*ast.IncDecStmt); ok { - t := info.TypeOf(s.X) - if iExpr, isIExpr := s.X.(*ast.IndexExpr); isIExpr { - switch u := info.TypeOf(iExpr.X).Underlying().(type) { - case *types.Array: - t = u.Elem() - case *types.Slice: - t = u.Elem() - case *types.Map: - t = u.Elem() - } - } - - tok := token.ADD_ASSIGN - if s.Tok == token.DEC { - tok = token.SUB_ASSIGN - } - - one := &ast.BasicLit{Kind: token.INT} - info.Types[one] = types.TypeAndValue{Type: t, Value: constant.MakeInt64(1)} - - return &ast.AssignStmt{ - Lhs: []ast.Expr{s.X}, - Tok: tok, - Rhs: []ast.Expr{one}, - } - } - return stmt -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/doc.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/doc.go deleted file mode 100644 index c176d5b33..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/doc.go +++ /dev/null @@ -1,8 +0,0 @@ -// Package natives provides native packages via a virtual filesystem. -// -// See documentation of parseAndAugment in github.com/gopherjs/gopherjs/build -// for explanation of behavior used to augment the native packages using the files -// in src subfolder. -package natives - -//go:generate vfsgendev -source="github.com/gopherjs/gopherjs/compiler/natives".FS -tag=gopherjsdev diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/fs.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/fs.go deleted file mode 100644 index 57ceec8c5..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/fs.go +++ /dev/null @@ -1,29 +0,0 @@ -// +build gopherjsdev - -package natives - -import ( - "go/build" - "log" - "net/http" - "os" - "strings" - - "github.com/shurcooL/httpfs/filter" -) - -func importPathToDir(importPath string) string { - p, err := build.Import(importPath, "", build.FindOnly) - if err != nil { - log.Fatalln(err) - } - return p.Dir -} - -// FS is a virtual filesystem that contains native packages. -var FS = filter.Keep( - http.Dir(importPathToDir("github.com/gopherjs/gopherjs/compiler/natives")), - func(path string, fi os.FileInfo) bool { - return path == "/" || path == "/src" || strings.HasPrefix(path, "/src/") - }, -) diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/fs_vfsdata.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/fs_vfsdata.go deleted file mode 100644 index d4fff8d58..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/fs_vfsdata.go +++ /dev/null @@ -1,848 +0,0 @@ -// Code generated by vfsgen; DO NOT EDIT. - -// +build !gopherjsdev - -package natives - -import ( - "bytes" - "compress/gzip" - "fmt" - "io" - "io/ioutil" - "net/http" - "os" - pathpkg "path" - "time" -) - -// FS is a virtual filesystem that contains native packages. -var FS = func() http.FileSystem { - mustUnmarshalTextTime := func(text string) time.Time { - var t time.Time - err := t.UnmarshalText([]byte(text)) - if err != nil { - panic(err) - } - return t - } - - fs := vfsgen۰FS{ - "/": &vfsgen۰DirInfo{ - name: "/", - modTime: mustUnmarshalTextTime("2017-05-20T21:21:23Z"), - }, - "/src": &vfsgen۰DirInfo{ - name: "src", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/bytes": &vfsgen۰DirInfo{ - name: "bytes", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/bytes/bytes.go": &vfsgen۰CompressedFileInfo{ - name: "bytes.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 508, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\x90\xcd\x4e\xc3\x30\x10\x84\xcf\xde\xa7\x18\x6e\x8d\x68\x55\x72\x45\x4d\x0f\x20\x0e\x3c\x43\xd5\xc3\xda\xdd\x54\x86\xe0\x14\x27\x91\xa8\x50\xde\x1d\xd9\x71\x1a\x19\x55\xca\x21\xde\x9f\x99\x6f\x67\xbb\xc5\xa3\x1e\x6c\x73\xc2\x47\x47\x74\x61\xf3\xc9\x67\x81\xbe\xf6\xd2\x11\xd5\x83\x33\x78\x77\x27\xf9\x79\xb9\xf6\xb2\xea\x70\x38\x86\xce\x1a\x26\x4e\x14\xb0\xae\xc7\x2f\xa9\xba\xf5\xb0\x6b\x68\x3c\x57\xf0\xec\xce\x82\x2e\x94\x95\xad\xa1\x51\x55\x30\xf1\xa5\xbc\xf4\x83\x77\xb0\xa4\xd4\x48\xe1\x4b\x85\x4d\x49\x63\x32\x7b\xfb\x1e\xb8\x59\x71\xd0\x9a\xbc\x0a\xe8\xb6\x6d\xc2\xbe\xad\xd1\x88\x5b\x71\x81\x87\x2a\xfe\xe9\x22\xca\x26\x91\x9a\x9b\x4e\xa2\x6a\xa2\x31\x0b\x0d\xcf\x34\x26\xec\xea\x83\x3d\x66\x40\x69\x35\x87\xea\xfd\x20\x37\xac\xd7\xf6\xeb\xc2\x5e\x72\xb0\xfc\x78\xc3\x77\xfc\x2c\xf6\x19\xeb\x2c\x5e\x4e\x6e\xca\xc4\xc8\x02\x50\xe2\x63\xec\x60\x74\x36\xbb\x99\x87\xa7\xfe\xfe\x7f\xbf\xbc\x91\x2f\x09\xed\xee\x04\x14\x74\x96\xf3\x9e\x68\xa4\xbf\x00\x00\x00\xff\xff\x23\x2d\xfc\x5d\xfc\x01\x00\x00"), - }, - "/src/bytes/bytes_test.go": &vfsgen۰FileInfo{ - name: "bytes_test.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - content: []byte("\x2f\x2f\x20\x2b\x62\x75\x69\x6c\x64\x20\x6a\x73\x0a\x0a\x70\x61\x63\x6b\x61\x67\x65\x20\x62\x79\x74\x65\x73\x5f\x74\x65\x73\x74\x0a\x0a\x69\x6d\x70\x6f\x72\x74\x20\x28\x0a\x09\x22\x74\x65\x73\x74\x69\x6e\x67\x22\x0a\x29\x0a\x0a\x66\x75\x6e\x63\x20\x54\x65\x73\x74\x45\x71\x75\x61\x6c\x4e\x65\x61\x72\x50\x61\x67\x65\x42\x6f\x75\x6e\x64\x61\x72\x79\x28\x74\x20\x2a\x74\x65\x73\x74\x69\x6e\x67\x2e\x54\x29\x20\x7b\x0a\x09\x74\x2e\x53\x6b\x69\x70\x28\x29\x0a\x7d\x0a"), - }, - "/src/crypto": &vfsgen۰DirInfo{ - name: "crypto", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/crypto/rand": &vfsgen۰DirInfo{ - name: "rand", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/crypto/rand/rand.go": &vfsgen۰CompressedFileInfo{ - name: "rand.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 1175, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\x53\x4b\x6f\x9b\x40\x10\x3e\x7b\x7f\xc5\x94\x56\x15\xdb\x38\x50\x29\x4a\x0e\xa9\x5c\x29\x8d\xa2\x28\x97\xb4\x8d\xfa\x38\x54\x3d\x2c\x30\xc0\x3a\x30\x4b\x77\x07\x53\x2b\xe2\xbf\x57\xb0\xe0\xb8\x89\xab\x5e\x0c\xeb\xef\xb5\xf3\x20\x8e\xe1\x28\x69\x75\x95\xc1\xda\x09\xd1\xa8\xf4\x5e\x15\x08\x56\x51\x26\x84\xae\x1b\x63\x19\x42\xb1\x08\xd0\x5a\x63\x5d\x20\xc4\x22\x28\x34\x97\x6d\x12\xa5\xa6\x8e\x0b\xd3\x94\x68\xd7\xee\xf1\x65\xed\x02\x21\x85\xc8\x5b\x4a\x41\x93\xe6\x50\xc2\x83\x58\xdc\xa1\xca\xd0\xc2\x0a\x5e\x5b\x2a\xfc\xe1\xa1\x17\xbd\x10\xbc\x6d\x10\x76\xff\x81\x63\xdb\xa6\xfc\xd0\x4f\x06\xa1\x85\x37\x3b\x50\xc2\xf0\x0c\x13\xf8\xf1\x33\xd9\x32\x4a\x08\x09\x34\xf1\x12\xd0\x5a\x18\xaf\x37\x46\x29\x6b\xd5\x16\xce\x57\xb0\x76\xd1\x0d\x31\x5a\x52\xd5\xc7\x64\x8d\x29\x87\x89\x8c\xae\x91\xc3\xe0\xd5\xc8\x09\xa4\x58\x98\x3c\x77\xc8\xff\x61\x7b\x52\x20\x07\x42\x28\x85\x58\xc4\x31\x24\xd6\x74\x0e\xad\x58\xa4\x76\xdb\xb0\x99\x1c\xae\x2b\x93\xa8\xca\xcb\x3c\x30\x84\xe8\x1c\x26\xd6\x6a\x64\x7d\xa5\x0c\x73\x4d\x98\x0d\xd7\x9d\x0d\x9e\xe9\x6b\x77\xb9\x73\xe8\xf7\x4d\x5e\x1c\x30\xd9\xa1\x5e\x5b\x20\xdf\x29\xca\x4c\xfd\x4d\x55\x2d\xba\x40\x1e\x14\x2d\x08\x56\x50\x21\x85\x89\x1c\x4e\x3a\x07\x82\xf7\x70\x76\x7a\x7a\x72\xe6\xf1\xa1\xd0\x8b\x8d\xd1\x19\x7c\x6e\x0d\xab\xab\xdf\x29\x62\x86\xd9\xd5\xd0\x6b\xe0\xd2\x9a\x8e\x20\xd9\xc2\x93\xb4\x59\xd9\x95\x48\x83\x7d\xc1\x25\x68\x07\xb5\xb1\x08\x5c\x2a\xf2\x09\x4b\x50\x0e\x5c\x83\xa9\xce\x35\x66\xa0\x69\x96\x95\xcc\xcd\x79\x1c\x77\x5d\x17\x75\x27\x91\xb1\x45\xfc\xe5\x2e\xfe\x8e\x89\xef\xc6\xc5\xa7\x9b\xf8\xa5\x7f\x3d\xae\x91\x4b\x93\x1d\x1f\x8a\x1f\x2a\x1b\x63\x86\x53\x3f\xfc\x4c\xed\xb9\x54\x55\xf5\xbc\x3f\x4b\x18\x37\x62\x42\x5d\x9b\xf8\x05\x59\x82\x1f\xfd\xfc\x3c\x22\x39\x76\xca\x22\xb7\x96\x80\x96\x40\xba\x12\x63\x40\xef\xd7\xe2\xd6\x64\x18\xad\xdd\x38\x2e\x8b\xbf\x5a\x6d\xf1\xc0\x6a\x4c\x48\x20\xdf\xed\x48\xff\x18\xaa\x1d\x6f\xf9\x61\xcb\xe8\x06\x9f\x89\x1d\xdd\xd0\xc6\xdc\xe3\xe3\x8e\x4d\xb6\x8f\xe4\xd1\x7a\x4f\x7b\x70\xfc\x7f\xd5\x8c\x1c\x2c\xf7\x25\x73\x86\xdf\x0f\x39\xb7\x60\xbf\x7e\x0f\x3d\x69\xc2\x84\xbd\x5d\xfa\x4f\xd2\x45\xb7\xd8\xcd\x17\x8d\x07\x7f\x20\xc3\xa0\x36\x4a\x57\x2a\xa9\x10\x34\x01\x97\xda\x01\xd2\x46\x5b\x43\x35\x12\x07\x52\xf4\xe2\x4f\x00\x00\x00\xff\xff\xe9\xf9\x0b\x94\x97\x04\x00\x00"), - }, - "/src/crypto/x509": &vfsgen۰DirInfo{ - name: "x509", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/crypto/x509/x509.go": &vfsgen۰CompressedFileInfo{ - name: "x509.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 211, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x7c\xcc\x31\xae\x82\x40\x10\x80\xe1\x9a\x39\xc5\x84\x0a\xde\x23\xae\x8d\x85\xb5\xa1\x25\x46\x4e\x80\xcb\x68\x56\x97\x1d\x32\x3b\x1b\x21\x86\xbb\x1b\x0d\xb6\xf6\xff\xff\x19\x83\xff\xe7\xe4\x7c\x8f\xb7\x08\x30\x76\xf6\xde\x5d\x09\xa7\xdd\x76\x0f\xe0\x86\x91\x45\x31\xe7\x98\x03\x5c\x52\xb0\xe8\xb9\xeb\xdb\x39\x2a\x0d\x27\x66\x8d\x45\x89\xc5\xdf\x81\x44\x8f\xcc\xbe\x42\x12\x61\x29\xf1\x09\x99\x31\x18\x18\xe3\xa7\x44\x79\xa7\x90\x09\x69\x92\x80\x0d\x3d\xbe\x47\x51\x56\x18\x9c\x87\x65\xd5\x69\x22\xdb\x92\x4d\xe2\x74\xfe\xed\xaf\x56\x70\xbe\x42\x8e\x9b\x5a\xa4\x61\xad\x27\x17\x15\x16\x78\x05\x00\x00\xff\xff\x1e\x97\x17\x12\xd3\x00\x00\x00"), - }, - "/src/crypto/x509/x509_test.go": &vfsgen۰CompressedFileInfo{ - name: "x509_test.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 231, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd7\x57\xd0\x4e\x2a\xcd\xcc\x49\x51\xc8\x2a\xe6\xe2\x2a\x48\x4c\xce\x4e\x4c\x4f\x55\xa8\x30\x35\xb0\xe4\xe2\xca\xcc\x2d\xc8\x2f\x2a\x51\x50\x2a\x49\x2d\x2e\xc9\xcc\x4b\x57\xe2\xe2\x4a\x2b\xcd\x4b\x56\x08\x49\x2d\x2e\x09\xae\x2c\x2e\x49\xcd\x0d\xca\xcf\x2f\x29\xd6\x28\x51\xd0\x82\xaa\xd0\x0b\xd1\x54\xa8\xe6\xe2\x2c\xd1\x0b\xce\xce\x2c\xd0\x50\xca\xcb\x57\x28\x06\xab\x53\x28\x02\x29\x54\xd2\xe4\xaa\xc5\x30\x22\x2c\xb5\x28\x33\xad\x92\x08\x33\xd0\x74\x7b\x82\xdd\x46\x8c\xe5\x60\x8d\x80\x00\x00\x00\xff\xff\xc0\x80\xbe\xca\xe7\x00\x00\x00"), - }, - "/src/database": &vfsgen۰DirInfo{ - name: "database", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/database/sql": &vfsgen۰DirInfo{ - name: "sql", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/database/sql/driver": &vfsgen۰DirInfo{ - name: "driver", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/database/sql/driver/driver_test.go": &vfsgen۰CompressedFileInfo{ - name: "driver_test.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 1185, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x53\x4d\x8f\xd3\x30\x10\x3d\x93\x5f\x31\x9a\x03\x38\x60\x35\xc9\x0a\xad\x44\x24\x2e\xb0\xe2\xba\x1c\x7a\xdb\xf6\xe0\x24\x0e\x32\x18\x3b\xf8\x23\xa5\xaa\xfa\xdf\x91\xe3\x06\xa4\xd6\x6d\xc3\x25\x9e\xcc\x9b\x79\xf3\xe4\x79\x2e\x0a\x78\xd7\x78\x21\x3b\xf8\x6e\xb3\x6c\x60\xed\x0f\xf6\x8d\x43\x67\xc4\xc8\x4d\x96\x8d\xcc\xc0\xc8\xa4\xe7\x9f\xb5\x1a\xb9\x71\xdc\xac\xb9\x75\x16\x3e\xc2\xcb\xf6\x32\x7f\xc8\x5e\x1d\x3e\x69\x2d\x29\xa0\x33\x9e\x23\x85\x70\x50\x40\x3c\xd2\x7f\xd0\xfa\x2a\xf4\xb2\x6d\xf6\x8e\x13\x74\x98\x27\xf1\x98\x4a\x71\x56\x69\xc2\x2a\x99\x15\xca\x3d\xbe\x27\x55\x7a\x86\x17\xca\x55\x8f\xd7\x50\xec\x99\xb4\x41\xfd\x74\x9e\x81\xa7\x5c\x0a\xc2\xf2\x4a\x4f\x99\x4e\x47\x89\x65\x9e\x46\x4f\x1a\x2f\xe1\xb6\x86\xb9\xbf\x06\xec\xb5\x46\x0a\xdc\x98\x1a\xd0\xfe\x92\x45\x5c\x6a\x0d\xad\xf6\xb2\x53\x6f\x1c\xb4\x71\x79\xb0\x09\xa5\x1b\x0c\x53\x35\xb8\xfd\xc0\xa1\xd1\x5a\x26\x28\x1f\x16\xd1\x3d\x24\x89\x9e\x78\xcf\xbc\x74\x5f\x99\x61\x3f\xb9\xe3\xe6\xaf\x73\x28\x28\xbd\x3b\x7d\xf0\x6e\x2d\x79\x3b\xdd\x4d\x4e\x94\x90\x39\x05\x25\xe4\x92\xae\xd7\x4c\xd9\x5d\x08\xe6\x73\x41\xcb\xb9\xaa\xa2\xb8\x55\x2e\xc8\x87\x7c\xde\x5b\x88\x42\x0f\x14\x05\xac\x9f\x9f\x9e\x6b\xf8\x22\x7e\xaf\x6e\x8f\xeb\x49\xb9\x0a\xa6\xeb\xa5\x66\xd3\xee\xa7\xbf\xfb\x32\x1b\x12\x6c\x7a\xe6\xd6\xdb\x52\x1b\x7b\xa8\x8e\xf3\x6b\x9b\xc2\xff\x15\x6b\x09\xb2\xf0\x46\x91\xe1\x12\x8d\x22\x0e\x8c\xbb\xf2\xca\xfa\x61\xd0\xc6\xf1\x2e\x5a\x24\xfa\x68\x25\x2c\x05\x06\x56\x8a\x96\x83\xee\xc3\x4d\x06\xde\x63\xf6\x27\x00\x00\xff\xff\x8d\xf2\x41\x9a\xa1\x04\x00\x00"), - }, - "/src/debug": &vfsgen۰DirInfo{ - name: "debug", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/debug/elf": &vfsgen۰DirInfo{ - name: "elf", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/debug/elf/elf_test.go": &vfsgen۰FileInfo{ - name: "elf_test.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - content: []byte("\x2f\x2f\x20\x2b\x62\x75\x69\x6c\x64\x20\x6a\x73\x0a\x0a\x70\x61\x63\x6b\x61\x67\x65\x20\x65\x6c\x66\x0a\x0a\x69\x6d\x70\x6f\x72\x74\x20\x22\x74\x65\x73\x74\x69\x6e\x67\x22\x0a\x0a\x66\x75\x6e\x63\x20\x54\x65\x73\x74\x4e\x6f\x53\x65\x63\x74\x69\x6f\x6e\x4f\x76\x65\x72\x6c\x61\x70\x73\x28\x74\x20\x2a\x74\x65\x73\x74\x69\x6e\x67\x2e\x54\x29\x20\x7b\x0a\x09\x74\x2e\x53\x6b\x69\x70\x28\x22\x6e\x6f\x74\x20\x36\x6c\x22\x29\x0a\x7d\x0a"), - }, - "/src/encoding": &vfsgen۰DirInfo{ - name: "encoding", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/encoding/json": &vfsgen۰DirInfo{ - name: "json", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/encoding/json/stream_test.go": &vfsgen۰FileInfo{ - name: "stream_test.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - content: []byte("\x2f\x2f\x20\x2b\x62\x75\x69\x6c\x64\x20\x6a\x73\x0a\x0a\x70\x61\x63\x6b\x61\x67\x65\x20\x6a\x73\x6f\x6e\x0a\x0a\x69\x6d\x70\x6f\x72\x74\x20\x22\x74\x65\x73\x74\x69\x6e\x67\x22\x0a\x0a\x66\x75\x6e\x63\x20\x54\x65\x73\x74\x48\x54\x54\x50\x44\x65\x63\x6f\x64\x69\x6e\x67\x28\x74\x20\x2a\x74\x65\x73\x74\x69\x6e\x67\x2e\x54\x29\x20\x7b\x0a\x09\x74\x2e\x53\x6b\x69\x70\x28\x22\x6e\x65\x74\x77\x6f\x72\x6b\x20\x61\x63\x63\x65\x73\x73\x20\x69\x73\x20\x6e\x6f\x74\x20\x73\x75\x70\x70\x6f\x72\x74\x65\x64\x20\x62\x79\x20\x47\x6f\x70\x68\x65\x72\x4a\x53\x22\x29\x0a\x7d\x0a"), - }, - "/src/fmt": &vfsgen۰DirInfo{ - name: "fmt", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/fmt/fmt_test.go": &vfsgen۰FileInfo{ - name: "fmt_test.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - content: []byte("\x2f\x2f\x20\x2b\x62\x75\x69\x6c\x64\x20\x6a\x73\x0a\x0a\x70\x61\x63\x6b\x61\x67\x65\x20\x66\x6d\x74\x5f\x74\x65\x73\x74\x0a\x0a\x63\x6f\x6e\x73\x74\x20\x69\x6e\x74\x43\x6f\x75\x6e\x74\x20\x3d\x20\x31\x30\x30\x0a"), - }, - "/src/go": &vfsgen۰DirInfo{ - name: "go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/go/token": &vfsgen۰DirInfo{ - name: "token", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/go/token/token_test.go": &vfsgen۰FileInfo{ - name: "token_test.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - content: []byte("\x2f\x2f\x20\x2b\x62\x75\x69\x6c\x64\x20\x6a\x73\x0a\x0a\x70\x61\x63\x6b\x61\x67\x65\x20\x74\x6f\x6b\x65\x6e\x0a\x0a\x69\x6d\x70\x6f\x72\x74\x20\x28\x0a\x09\x22\x74\x65\x73\x74\x69\x6e\x67\x22\x0a\x29\x0a\x0a\x66\x75\x6e\x63\x20\x54\x65\x73\x74\x46\x69\x6c\x65\x53\x65\x74\x52\x61\x63\x65\x28\x74\x20\x2a\x74\x65\x73\x74\x69\x6e\x67\x2e\x54\x29\x20\x7b\x0a\x09\x74\x2e\x53\x6b\x69\x70\x28\x29\x0a\x7d\x0a"), - }, - "/src/internal": &vfsgen۰DirInfo{ - name: "internal", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/internal/testenv": &vfsgen۰DirInfo{ - name: "testenv", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/internal/testenv/testenv.go": &vfsgen۰CompressedFileInfo{ - name: "testenv.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 424, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\x8f\xc1\x6a\xc3\x30\x0c\x86\xcf\xd1\x53\x08\x9f\x12\x36\x92\xfb\x6e\xa3\x8c\xf5\xd6\xb2\x3e\x81\xeb\x2a\x8d\xbb\x58\x2e\x92\xb2\xb4\x8c\xbe\xfb\xf0\xd6\x52\xd8\x06\x3e\xfd\x9f\xfd\xf1\xb9\xeb\xf0\x61\x3b\xc5\x71\x87\x07\x05\x38\xfa\xf0\xee\xf7\x84\x46\x6a\xc4\x1f\x00\x31\x1d\xb3\x18\xd6\x50\x39\x99\xd8\x62\x22\x07\x95\x53\x93\xc8\x7b\x75\xd0\x00\x74\x1d\x2e\xbd\xbe\x9c\x28\xa0\x50\xb9\xac\x38\x0f\x64\x03\x09\xda\x40\x18\x26\x11\x62\x43\x3d\xab\x51\xc2\xe0\x19\xd5\xbc\x18\x32\xcd\x78\x94\x1c\x48\x95\xb4\x58\x26\x8d\xbc\xc7\xac\xed\xa6\xf0\xf5\x0f\xc2\x2c\x58\xa7\x2c\x84\x21\xa7\x94\x79\x3c\x37\x48\x27\x0a\xed\x22\xa7\xe4\x79\xd7\x42\x3f\x71\xb8\x15\xd4\x0d\x6e\x73\x1e\xf1\x13\x2a\x9d\xa3\x85\x01\xaf\xd1\xed\xeb\x6a\xb5\x29\x73\xf0\x4a\xe8\xd8\x87\xd1\x3d\x41\x55\x09\xd9\x24\x8c\xbd\x1f\x95\x6e\x70\xe7\x65\x8e\xfc\x8d\x63\x8f\xd7\xaf\xb6\x4b\xaf\x6b\xa1\x3e\x9e\xea\xbb\xf2\xf9\x6d\xb1\x7c\x44\xe7\x25\xb9\xa6\xc8\x7f\xfb\xaa\x0b\x94\xf3\x27\xa5\xbc\xbb\xc7\x1c\xf4\x9f\x94\x0b\xdc\x06\x93\x89\xe0\x02\x5f\x01\x00\x00\xff\xff\xdc\xf8\xeb\x9e\xa8\x01\x00\x00"), - }, - "/src/io": &vfsgen۰DirInfo{ - name: "io", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/io/io_test.go": &vfsgen۰CompressedFileInfo{ - name: "io_test.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 326, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x8f\xb1\x4a\xc4\x40\x10\x86\xeb\x9b\xa7\x18\x52\x25\x2a\xb9\x67\xb0\xf0\x04\xc1\xc6\x1c\x58\x1e\x6b\xf2\x9b\x8c\xb7\x99\x5d\x66\x67\x51\x14\xdf\x5d\xee\xb4\x12\x6c\xac\x06\x3e\xf8\x3e\xe6\xdf\x6e\xf9\xf2\xa9\x4a\x9c\xf8\xa5\x10\xe5\x30\x1e\xc3\x0c\x96\x74\x70\x14\x27\x92\x35\x27\x73\x6e\x69\xd3\x9c\x80\xe8\xdc\x50\x47\xf4\x5c\x75\xe4\x3d\x8a\xdf\xd7\xe8\xf2\x68\xe2\xb0\xc3\xf9\x0c\x6e\xa2\xf3\x20\x3a\x47\x5c\xc7\x98\xc6\xd6\xf9\xe2\x47\xed\xf7\x1d\x7f\xd0\xc6\xfb\xe1\x28\xb9\xed\xe8\xf3\x77\xe8\x01\x61\x82\xed\x62\x70\x87\xfe\x43\x34\xa0\xdc\xbc\x2d\xa1\x16\xc7\xf4\xcd\xca\x9f\x99\xf3\x20\x36\x44\x41\xe1\xa4\x6c\x55\x5d\x56\xf4\x03\x7c\x27\x1a\xa2\xbc\xc3\xae\xf8\x75\x91\x71\xe1\xdb\x94\x17\xd8\xdd\xc0\x53\x42\x61\x4d\xce\xb2\xe6\x88\x15\xea\xcd\xe9\x9d\xaf\x00\x00\x00\xff\xff\xae\x39\x5e\xf6\x46\x01\x00\x00"), - }, - "/src/math": &vfsgen۰DirInfo{ - name: "math", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/math/big": &vfsgen۰DirInfo{ - name: "big", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/math/big/big.go": &vfsgen۰CompressedFileInfo{ - name: "big.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 875, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\xd2\xc1\x4e\x84\x30\x10\x06\xe0\xb3\x7d\x8a\x39\xb2\xb1\xc9\xee\x3e\x82\x77\x3d\x4a\x0f\xc6\x6c\x80\x22\x56\xbb\x55\x0b\x35\x88\xf1\xdd\xcd\x0c\x50\xea\x32\x26\xbb\x37\x20\xff\xff\xa5\x33\x74\xbb\x85\xeb\x32\x18\xab\xe1\xa5\x15\xe2\xbd\xa8\x5e\x8b\xa6\x86\xd2\x34\x42\x3c\x05\x57\xc1\x31\x58\xa5\xb2\x5e\xc2\x17\xa8\x37\xaf\x37\x90\x0d\x7b\x09\xc3\x6e\x7a\xfb\x16\x57\xbe\xee\x82\x77\x63\xf0\xd0\x50\x74\x23\x7e\xc6\xb6\x36\x9f\xd8\xde\x4b\xe8\x77\x09\xf1\x21\xc1\xaf\x00\xca\x22\x30\xa7\xa3\x52\x68\x9d\xe7\xd9\x20\x81\x8e\xf1\xf0\x38\x29\xd5\x8a\xa0\xe0\xa1\x99\xa3\x11\x68\x43\x79\x1e\x40\x41\x06\x40\x58\xd1\xd7\xa9\x9d\x0c\xc3\x1f\x43\xfd\x73\x8c\xf3\x15\x4a\x73\xca\xb3\xcd\xef\xff\x2a\x2d\x04\xe3\x3a\x5e\xc1\x74\x54\xda\x44\xf1\x17\x29\x9e\x55\x8e\xc1\xde\xe0\xb0\xa7\x53\x2d\xff\x97\xc1\x62\x69\x19\x4e\x82\x4f\x77\x7d\x17\x6c\x7e\xd9\xbe\xc7\x06\xb3\x2d\xbc\x55\x48\x45\xa7\x77\x30\x3d\xac\x69\xfe\x52\x46\xd7\x9d\xd8\xa5\xe9\x6e\x6b\x97\xf5\x73\xdd\x01\xed\x6f\x69\x8f\x01\xbc\xd3\xd8\xf9\x0d\x00\x00\xff\xff\x99\x66\xd8\x28\x6b\x03\x00\x00"), - }, - "/src/math/big/big_test.go": &vfsgen۰CompressedFileInfo{ - name: "big_test.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 148, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd7\x57\xd0\x4e\x2a\xcd\xcc\x49\x51\xc8\x2a\xe6\xe2\x2a\x48\x4c\xce\x4e\x4c\x4f\x55\x48\xca\x4c\xe7\xe2\xca\xcc\x2d\xc8\x2f\x2a\x51\x50\x2a\x49\x2d\x2e\xc9\xcc\x4b\x57\xe2\xe2\x4a\x2b\xcd\x4b\x56\x08\x49\x2d\x2e\x71\xaa\x2c\x49\x2d\xd6\x28\x51\xd0\x82\xca\xe9\x85\x68\x2a\x54\x73\x71\x96\xe8\x05\x67\x67\x16\x68\x28\x25\x15\xe5\x67\xa7\xe6\x29\x69\x72\xd5\x22\xe9\xf1\xcd\x4f\x09\x2e\x2c\x2a\xc1\xad\xab\x38\x27\xbf\x1c\xac\x07\x10\x00\x00\xff\xff\x9b\x59\x2d\xf0\x94\x00\x00\x00"), - }, - "/src/math/math.go": &vfsgen۰CompressedFileInfo{ - name: "math.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 4321, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x57\x6f\x6f\xa3\xb8\x13\x7e\x1d\x3e\xc5\xfc\xa2\x9f\x56\x70\x4b\xfe\x40\xab\x6a\xb5\x6a\x2a\xed\xf5\xb6\x7b\x95\xda\xde\xe9\xda\xbb\x37\x55\x5e\x18\x62\x27\xce\x82\x4d\x8d\xd9\x92\x6d\xfb\xdd\x4f\x36\x10\x0c\x81\x24\xbd\x77\xb1\xfd\xcc\x33\x8f\xc7\x33\xc3\x64\x32\x81\x8f\x41\x46\xa3\x05\xac\x53\xcb\x4a\x50\xf8\x1d\x2d\x31\xc4\x48\xae\x2c\x8b\xc6\x09\x17\x12\x6c\x6b\x30\x5c\x52\xb9\xca\x82\x71\xc8\xe3\xc9\x92\x27\x2b\x2c\xd6\x69\xfd\x63\x9d\x0e\x2d\xc7\xb2\x7e\x20\xa1\x0d\x61\x06\xeb\x74\xfc\x2d\xe2\x01\x8a\xc6\xdf\xb0\xb4\x87\xb7\x48\xae\x86\x8e\x06\xfc\xc4\x82\x03\x89\x38\x92\x67\xa7\x30\x83\xa9\xde\x4c\x78\x7a\xcd\x08\xcc\xc0\x83\x89\x46\xe8\x5d\x86\x97\xc5\xee\xa8\xb9\x8d\x98\x32\xac\xb6\x2c\x92\xb1\x10\xbe\x84\x3c\xb5\xf3\x8a\xd8\xd9\x7a\x78\xb1\x06\x02\xcb\x4c\x30\xad\x6c\x7c\x89\xa2\xc8\x1e\xa2\x90\xa7\x43\x17\x72\x67\x7c\xa5\x60\xb6\x63\xbd\x55\x34\x29\x65\xc7\xd3\xa4\x94\xf5\xd0\x48\xf4\x0e\x1a\x89\xf6\xd0\xf8\xf6\xc6\x85\xf7\x50\xf9\x43\x17\x36\x9d\x74\x97\x98\x46\x47\xab\x0a\x31\x8d\xba\x55\x5d\xf2\x64\x93\xd2\x25\xb3\x73\x17\x36\x9d\x6c\x94\x80\x9d\xc3\x39\x4c\xe1\xf5\x15\xbc\x49\x0e\xb3\x59\xf9\x98\x0e\xfc\x6f\x06\xf6\xa6\x3e\xdb\x98\x67\x2f\xd6\xa0\x52\x32\xca\xad\xc1\xdb\x56\x57\x6e\x38\x3f\xfe\x99\x7b\x5f\xf9\x92\xa7\xab\xf7\xb0\xac\xba\x69\x7e\xa3\x71\x7f\x0c\x4a\xa2\x45\x89\xa9\xad\xbe\xe6\xc9\xd1\xbe\x71\x9e\x74\xbb\xfe\x9a\x27\xfe\xd1\x2c\x09\x7f\x1e\xba\xe0\xf7\x11\xc5\xde\x7e\x26\x5c\x40\x6a\x9b\xab\x88\x73\x71\xb4\x77\xa2\xd0\xdd\xb7\xb8\x12\x38\x4f\x6c\x52\x13\xd9\x44\xa0\xb0\x5a\xba\xca\x33\x50\x26\x1d\x83\x98\x14\x26\x35\xc7\xef\x9b\x84\x4b\x3b\x71\xe1\x69\x9f\x9e\xd5\x16\x55\x5b\x5e\x33\x62\xab\x3c\x2e\x5c\x18\x36\xe9\x33\x95\xe1\x4a\xfd\x0a\x51\x8a\x41\x63\x2e\x66\x30\xfd\x5c\xa7\x67\xd1\xb0\xac\xc1\x02\x13\x94\x45\xd2\x38\x29\x72\x59\x25\xef\xd6\x8f\x82\xd6\xb7\x74\xa1\x76\x1a\x70\x1e\x95\x05\x43\x54\x21\x94\x7d\xd0\xa8\x83\xad\x73\x5d\x0e\x15\xae\xec\x8c\x6d\xdc\x79\x85\xab\x82\x85\xa2\x14\x1b\x3a\xee\xd0\x5d\x23\xda\x34\xd5\x0a\x1a\xf1\x55\x05\x4a\xb6\x36\x37\x0b\x1d\xee\xee\x57\x69\x56\xbc\x06\xcd\x54\x63\x36\x64\xa9\xcd\x4a\xb9\xb2\xbb\x98\x81\x37\xf5\x4f\xdb\x10\xf8\xa5\x33\x5f\xbd\xa9\x7f\xb2\xcd\x9a\x1e\x0c\xce\x93\x51\x03\x67\xba\x3b\x57\xdf\x8e\xe3\xfd\x8d\x8e\x74\xf8\x71\xd7\xe1\x61\x72\x9c\x27\xbb\x15\x70\xc3\x97\x3d\x85\x44\x09\xe4\xea\x2d\x72\x78\x81\xc9\x04\x9e\xb9\xf8\x8e\x04\xcf\xd8\x02\x08\x17\xc0\x13\x49\x63\xfa\x13\x0b\x08\xb2\x25\x50\x06\xff\x7c\x72\x41\xe0\x98\xff\xc0\x80\x24\xa4\x3c\xc6\x90\x70\xca\xa4\x91\x98\x88\x99\x4a\x0d\x89\x11\x5f\x76\xd7\xe7\x0d\x5f\x7a\xd3\xfd\x85\x1e\x15\x90\xa6\xcd\x81\x06\x17\x15\x90\x86\xcd\x81\x6e\x16\x69\x44\x6d\x71\x8b\xf2\x83\xad\x37\x2e\x31\x86\x15\xdd\xf3\xd1\xaa\xac\x4a\x8c\x61\xc5\x17\x07\xad\xea\x79\xa7\x08\xe9\xff\x63\xbe\x50\x31\x55\x44\x3b\x61\xbd\xe5\x0b\xd2\xec\x7a\x55\x69\x6d\xb7\x76\x7b\xc2\xeb\x6b\x5f\xe9\x13\x77\xfb\xb6\x94\x80\x37\xe9\x87\xe9\xb6\x34\xd0\x39\xfa\x79\xa6\xef\x45\x5c\xf0\x1c\xa3\xf8\x47\x3a\x83\xdd\xa2\x6e\x2b\xbd\xaa\x6d\x74\x5d\x5a\x79\xad\x30\x7f\xf2\xe7\xbd\xf3\x80\x9e\x01\x3c\x75\x0b\x5b\xff\x1c\x79\xf0\xe1\x83\x9a\x04\x1a\x37\x34\xa7\x81\xc6\x38\xe0\xf5\xa4\x6e\x51\x5d\xdd\x61\xfe\x0b\xc7\x88\xb2\x05\x16\x07\x5f\x4f\x34\x90\x35\xc3\x3d\x5d\xb2\x80\x4a\x33\x35\xab\x8e\x5d\x0d\x26\x9d\x53\x8e\x41\x70\xfc\x18\xd8\x3b\x4c\xde\x53\x76\xfc\xb4\x92\x52\xd6\x33\xad\xdc\x53\xd6\x9a\x91\xed\x94\x32\x17\x42\x9e\x36\xf2\xae\xe4\xd4\xd2\x1d\xb7\x18\xb8\x0c\x96\x27\x21\x8f\x17\xf3\x24\x64\xb7\x98\x87\x77\xcc\xc7\xbd\xe3\xf1\x03\x7a\x47\x60\x24\xea\x0b\xcc\x83\xc8\x58\xb8\xaf\x0b\x37\x52\xd4\x78\xe6\x62\xa9\x7b\x74\x3b\x03\xcc\xdc\x6d\x4c\xb2\x25\xb7\x4d\x99\xb4\x73\x47\x8b\x50\xff\x69\x82\x8c\x40\x2a\x45\x16\x4a\x65\x99\x51\x26\x4f\x7c\x24\x04\xda\x00\x3c\xfa\xf3\x62\x6d\x0d\xb4\x71\x75\xf0\xe8\xcf\xcb\x75\x79\x70\x76\x5a\x1e\x78\xf3\x72\xbd\xbd\x22\x65\x54\x7d\xd0\x5e\xac\x01\x0a\x54\xe9\xb7\xfe\x9e\x7d\x51\x76\xbf\x66\x84\x60\x31\x74\xc6\x77\xf8\xd9\xfe\xe4\x58\x83\x75\x3a\xbe\x66\x12\x0b\x86\xa2\x3f\x82\x35\x0e\xa5\x1d\x64\xc4\x19\xdf\x2b\x0b\x43\xe1\xd0\x6d\xd3\xfd\xad\x0f\x35\x69\x49\x87\x02\xe7\x00\xa1\x79\xb5\x5d\xc6\xab\xe2\xf4\x3f\x50\x96\x41\xe9\xa1\x3c\x3b\xdd\xa1\x34\x86\x5c\xe5\x32\xa0\x32\xad\x7a\xf5\x89\xef\x40\x71\x71\x15\xc9\x20\x23\x63\x53\xf5\xe3\x74\x0e\x6a\x74\xaa\x5e\x5a\x9d\x1b\x61\x7a\x9c\xce\xdb\xdc\x44\xf0\x58\xf3\x07\x25\xad\x53\xf9\xa9\xf8\x9b\xf6\x30\x83\xa0\x41\xdf\x72\xdf\xe4\x3f\x3b\x35\xb5\xab\xbc\x56\x6c\x45\x5a\x6f\x8d\xcb\xf0\xb4\xb5\x17\x48\xbb\x2d\xc1\x9b\x3b\xe7\xe7\x27\x3e\x7c\xec\x03\x4c\xe7\x4e\x5b\x44\xeb\x92\xad\xfa\xea\xbc\x64\xb1\x61\x07\xce\xee\xb9\x67\x9e\xc3\xc5\x05\x9c\xf8\xce\x6e\x48\xea\x5b\x59\x6f\xd6\xbf\x01\x00\x00\xff\xff\xa9\xe5\x7f\x9e\xe1\x10\x00\x00"), - }, - "/src/math/math_test.go": &vfsgen۰CompressedFileInfo{ - name: "math_test.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 587, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\x90\x31\x6b\xdc\x40\x10\x85\x7b\xfd\x8a\xd7\x39\x26\x77\x27\x0c\x17\x17\x69\xae\x09\x04\x17\xe1\x02\x71\x1f\x46\xab\xd1\xed\x24\xab\xdd\xcb\xcc\xc8\xb2\x08\xf9\xef\x41\x92\x41\x6e\x6e\xbb\x85\xf7\xbe\xf7\xe6\xd5\x35\x3e\x36\x83\xa4\x16\xbf\xac\xaa\xae\x14\x7e\xd3\x85\xd1\x93\xc7\x9f\xce\xe6\x55\x55\xd7\xf8\x91\xe4\x12\xd3\x84\x28\x97\xc8\x0a\x2f\x89\x95\x72\x60\x83\x47\xca\x18\xae\xe6\xca\xd4\xef\x50\x3c\xb2\x8e\x62\x8c\x67\x36\xff\x4a\x7d\x4f\xe8\x48\x92\x1d\x66\xcc\xf3\xf9\xcb\xf9\x33\x9e\x66\x17\x2b\x83\xd0\xb0\x3b\x2b\x46\x9a\xe0\x05\x9d\xbc\x6e\xb6\x13\x9e\xfc\xce\x30\xb2\x68\x3b\xa7\x38\x4a\x4e\x13\x4a\x66\x2c\xb5\xea\x1a\xeb\x53\xfe\x33\x88\xb2\x41\x72\x50\x26\x93\x7c\x79\x57\xf0\x80\xef\xac\x91\xae\x6f\x99\x77\xb6\xa5\x76\xf2\x7a\xc2\x37\x9a\x1a\xc6\xc8\x1b\xcf\x62\x19\x52\x8b\xf2\xc2\xaa\xd2\xbe\x3f\xc4\xae\x1c\xa4\x93\x40\x29\x4d\xa0\xdc\x22\x17\x9f\xb1\x78\x1b\x6d\x3f\xce\xfa\x2d\x7b\xb7\x41\x1b\x0e\x34\x18\xc3\xa3\x18\x46\x49\x09\xeb\xbf\xa7\x3c\xad\xa3\x2d\x57\xd9\x3c\x43\xc3\x48\x6c\x06\x0a\x61\x50\x72\x3e\xe0\xac\xe8\x97\x9e\xb3\x7d\x83\x8a\xa1\x93\xcc\xa7\xaa\x1b\x72\x40\x48\xc5\xf8\x03\xed\xd0\xa0\x4b\x85\xfc\xf1\x78\x8f\xa6\x94\xb4\x48\xff\x42\xd9\x07\xcd\x5b\xbb\x45\xb9\xc3\x91\xf7\x0f\xc7\x7b\xfc\x5b\x19\x2f\xac\xd3\x4d\xce\x4d\xc6\x23\xef\x1f\x3e\xcd\x8c\xff\x01\x00\x00\xff\xff\xc7\x9d\xb5\x9f\x4b\x02\x00\x00"), - }, - "/src/math/rand": &vfsgen۰DirInfo{ - name: "rand", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/math/rand/rand_test.go": &vfsgen۰CompressedFileInfo{ - name: "rand_test.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 160, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\xcb\x51\x0a\xc2\x30\x0c\x00\xd0\x6f\x73\x8a\xd0\xaf\x4d\x61\x03\x3d\x82\xe0\x05\xdc\x05\x6a\x57\x4b\x5c\x4d\x4a\x93\x22\x22\xde\x5d\x10\x3f\xfc\xd9\xf7\xe3\x8d\x23\xee\x2e\x8d\xf2\x8c\x37\x05\x28\x3e\x2c\x3e\x45\xac\x9e\x67\x00\xba\x17\xa9\x86\xce\xa2\x1a\x71\x72\x00\xd7\xc6\x01\xa7\xa8\x76\xca\xe2\xed\xb0\xef\x0c\xb7\x3f\x1d\xa6\x1e\x5f\xb0\xb1\xe1\xbc\x50\xe9\x9c\x66\x79\xb8\x1e\xde\x7f\xe7\x28\x1c\x5a\xad\x91\x6d\xbd\x35\x25\x4e\xc8\xa2\x4f\x0e\xdf\xfe\x09\x00\x00\xff\xff\x3d\xb4\x3b\xb8\xa0\x00\x00\x00"), - }, - "/src/net": &vfsgen۰DirInfo{ - name: "net", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/net/http": &vfsgen۰DirInfo{ - name: "http", - modTime: mustUnmarshalTextTime("2017-05-20T21:21:23Z"), - }, - "/src/net/http/cookiejar": &vfsgen۰DirInfo{ - name: "cookiejar", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/net/http/cookiejar/example_test.go": &vfsgen۰CompressedFileInfo{ - name: "example_test.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 269, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\xcc\x41\x4e\xc3\x30\x10\x85\xe1\x75\xe7\x14\x4f\x5d\xb5\x02\x35\x82\x65\x77\xa8\x02\x24\x16\x05\xd1\x03\xd0\xa9\x3d\x21\x6e\x1c\xdb\x78\x26\x0d\x08\x71\x77\x14\xb1\x65\xfb\xf4\xbd\xbf\x69\x70\x75\x1a\x43\xf4\x38\x2b\x51\x61\xd7\xf3\xbb\xc0\xe5\xdc\x07\x39\x73\x7d\x33\x51\x23\x0a\x43\xc9\xd5\xb0\x6c\x07\x5b\x12\xb5\x63\x72\xb8\xff\xe4\xa1\x44\xd9\xcb\xb4\x5a\xe3\x9b\x16\x4d\x83\x24\x36\xe5\xda\x83\x9d\x13\x55\xa4\x6c\xd0\xb1\xcc\x4f\xf1\x38\x7d\xe1\x31\x97\x4e\xea\xd3\xe1\x1a\x9c\x3c\xac\x0b\x8a\x39\x0f\x2f\x45\x92\x57\xe4\x84\xce\xac\xcc\xdb\x66\x2f\xd3\x41\xea\x45\x2a\xd1\xa2\x1d\x6c\xf3\x52\x43\xb2\x98\x56\xc7\xbb\xd6\xa4\xe2\x46\x0d\x55\x3e\x46\x51\xdb\x12\xf0\x10\xf9\x92\xeb\x16\xbb\x2e\xbb\x1c\xd9\x04\xbb\x2e\x14\xfa\xb3\xb7\xc9\xff\x67\x9f\xd9\x06\xe1\x88\x57\x0e\x1a\xd2\x71\x4d\x3f\xf4\x1b\x00\x00\xff\xff\x4a\xaa\xb1\x5a\x0d\x01\x00\x00"), - }, - "/src/net/http/fetch.go": &vfsgen۰CompressedFileInfo{ - name: "fetch.go", - modTime: mustUnmarshalTextTime("2017-05-20T21:22:56Z"), - uncompressedSize: 3551, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x56\x5f\x6f\xdb\x36\x10\x7f\x16\x3f\xc5\x4d\xc3\x3a\x29\xb5\xa5\x16\x28\xfa\xe0\xc5\x0f\xa9\x9b\x76\xc1\xda\xa5\x48\xb2\xa7\x20\x18\x68\xe9\x24\x31\x91\x48\x85\xa4\x92\x18\x81\xbf\xfb\x70\xa4\x24\xcb\x49\xda\x62\x01\xea\x4a\xe2\xf1\xee\x77\x77\xbf\xfb\x93\xa6\xf0\x7a\xdd\x89\x3a\x87\x6b\xc3\x58\xcb\xb3\x1b\x5e\x22\x54\xd6\xb6\x8c\x89\xa6\x55\xda\x42\xc4\x82\x10\xb5\x56\xda\x84\x2c\x08\x8b\xc6\xd2\x7f\x42\xf9\xdf\x54\xa8\xce\x8a\x9a\x5e\x8c\xd5\x99\x92\x77\x21\x63\x41\x58\x0a\x5b\x75\xeb\x24\x53\x4d\x5a\xaa\xb6\x42\x7d\x6d\x76\x0f\xd7\x26\x64\x31\x63\x69\x0a\xc6\x6a\xe4\xcd\x19\xf2\x1c\x35\x88\xa6\xad\xb1\x41\x69\x0d\x70\x09\x42\x25\xf4\x7d\x55\x2b\x83\x1a\xee\x35\x6f\x5b\xd4\x50\x28\x0d\xf4\x99\xaf\x6b\x3c\x77\x97\x41\x15\x0e\xae\x59\xa4\x69\x81\x36\xab\x12\xd3\x62\x96\xdc\x57\xdc\xde\x97\x89\xd2\x65\x9a\x30\xbb\x69\x71\xdf\x96\xb1\xba\xcb\x2c\x3c\xb2\xa0\x45\x99\x0b\x59\xc2\xe5\xd5\x7a\x63\x91\x05\x5e\x0c\xe0\xe0\xda\x24\xa7\xeb\x6b\xcc\x2c\xdb\x32\x56\x74\x32\x83\x48\xc3\xc1\x54\x4b\xec\xa0\x44\x6d\x7f\x37\x86\x48\x82\x90\x76\x06\xa8\x35\xb8\x88\xc5\x64\x41\x14\x50\xa3\x8c\x74\xd2\x9b\x8a\x61\xb9\x84\x37\x74\x12\xdc\x71\x4d\xe1\x0d\x82\xf5\xaa\x02\x80\x25\x34\xfc\x06\xa3\xac\xe2\x72\xd0\x49\x87\xa8\xf5\xaa\xda\x3b\xf4\xca\x59\x10\xd0\x3f\x9d\x78\x50\xc9\x8a\xd7\x75\x14\x6a\xe4\x79\x18\xf7\x2f\xb6\x42\x19\xce\x48\x09\x79\x10\x69\x34\x5d\x6d\x27\xbe\x39\x80\x41\x40\x18\xfd\x59\xf2\x19\x6d\x14\xe6\x4a\x62\x18\x27\x1f\x94\xaa\xa3\x41\xa4\x87\x71\x38\xa7\xd4\x1c\x9f\x7e\xf2\x1f\x35\xda\x4e\x4b\xf7\xbc\x75\xbf\x6b\x2f\x33\xd5\x76\xc7\xeb\x8e\xd4\x9d\x48\x8b\xba\xe0\x19\x46\x71\x12\x4d\xfc\xdb\x4e\x01\x72\xa3\xe4\x0b\x00\xd3\x14\x8e\x8c\xe9\x1a\x34\x20\xec\xef\x06\x38\x7c\x3c\xfd\x7a\xfc\x90\x61\x6b\x85\x92\x09\xdb\x03\xe8\xd9\x9a\xfc\x8d\xf7\xbd\x42\x8f\xa3\x41\x63\x78\x49\x48\xce\xad\x16\xb2\x8c\xe2\x9d\x79\x7a\x32\x58\xa3\x27\x45\x90\x71\x83\xb0\x86\xc5\x12\x0e\xe7\xeb\x55\xb5\x20\xb9\x31\x81\xb0\x84\xf5\x20\x43\xa9\x76\x52\xce\xb8\x97\x73\x21\x81\x37\x8e\x07\xcc\xc5\x65\xcb\x02\x09\x4b\xc8\x54\xbb\x89\xda\x19\xec\xa8\xc0\xf6\xb4\x8e\xcf\x97\x72\x71\xc5\x06\x45\x72\x06\x52\xd4\x3f\x60\xa1\xab\x91\x28\xf6\x6e\x13\xfc\x34\x85\x8b\x4a\x18\x10\xa5\x54\x1a\xa9\x9c\x36\xfd\xa1\x57\x89\x39\x14\x5a\x35\x90\x71\x99\x61\x0d\x0d\xda\x4a\xe5\x09\x9c\x2b\x28\xb8\x9e\xc1\x09\xe4\x22\x07\xa9\x2c\xa0\xcc\x54\x47\x59\x73\x2a\x32\x25\x33\x8d\x54\x24\x54\xba\xc2\x76\x9c\x62\x0f\xf7\x15\x6a\x04\x8d\xd4\x2c\xc8\x0f\x5b\x61\x6f\x4d\x18\x68\x90\x4b\x21\xcb\xa2\xab\x13\xf8\xaa\x8c\x85\xce\xa0\x1e\x90\xf5\x62\x0e\x8b\x46\xd3\x26\x1f\x54\xbe\x49\x7a\x77\x12\x67\xe6\xa4\x20\x7d\x1a\x5d\xca\x25\x62\x0e\x56\xf5\xb6\xfa\xdb\x74\x3a\x03\x61\xc9\x1b\x58\xe3\xae\x8d\x60\x0e\x5c\xe6\x60\xd1\xd0\xe3\x7d\x85\x12\x6c\xc5\xad\xd7\x92\x29\xa2\x52\xd7\x26\xec\x69\xfd\xf8\xa0\x84\xf1\x2e\xfe\x3e\xf8\x69\x0a\xae\xbf\x5c\x68\x2e\x8d\xb3\x2f\x08\xd3\x99\xea\x64\x7e\xa1\x85\x6b\x4f\x4e\x3f\x05\x7e\x82\xa1\x33\x14\x94\x4f\x74\x15\x8e\xbe\x9d\x24\x70\x62\xc1\x74\x2d\x69\x30\x7d\x53\x12\xb2\x24\xf5\x14\x02\x25\x89\x78\x2a\x17\x68\xfa\xbe\xf5\xc4\xa8\xef\x5c\x8f\x23\x1b\x2c\x1c\xec\x4b\xc4\x3b\x48\x91\xc6\x5b\x38\x38\xc3\xdb\x0e\x8d\x8d\x21\x3a\x38\xeb\x2d\xcc\x26\xed\xa9\x72\x2c\x32\xc4\xe2\x6b\x93\x7c\xae\xd5\x9a\xd7\xbe\x5e\xfe\xf4\x27\x61\xec\x2a\x29\x66\x01\x75\xdf\x1b\xdc\xcc\xc0\x55\xb4\xbb\xa2\xb9\x2c\x29\xf9\xb7\x89\x97\x76\xd5\x43\x72\xff\xf6\x52\x3b\xa1\xfe\x92\xab\xe7\xde\x68\x1f\x72\xea\xed\x32\x0f\x67\x13\xe5\xf1\x58\x38\xaa\xb5\xa4\xa3\xe1\xed\xa5\x71\x65\x7b\x25\x86\x3e\xf2\xb8\x25\x65\xa1\xe7\x6f\xb8\x00\xf7\x47\x58\xbe\xba\x2f\x54\xd7\x61\x6f\xa9\x3f\xed\xdf\xdc\x49\xa6\x31\x47\x69\x05\xaf\xe9\x34\x34\xbc\xc1\xb9\xd2\xa2\x14\xae\x63\x6e\x99\x6f\x8a\xb7\x8e\x94\xf0\xcb\x92\x78\xe0\xc0\x53\x75\x9d\x7e\x3c\x5d\xc0\x27\x21\x73\x50\x9d\x05\x2f\x48\x41\xa6\xd4\x6d\x06\x26\xfa\xe4\x62\x4e\x43\x41\xb9\xb2\x70\x99\x1a\x65\x35\x27\x6a\x13\x69\x68\x6e\x00\xcf\xef\x88\x7a\x8e\xd0\x89\xb7\xe3\xff\xce\x11\xe1\x43\x57\x14\xa8\xcf\x55\xa7\x33\x04\x6e\x7f\x32\xf2\x7e\x25\x18\xf3\x46\x3c\x08\xd7\x1a\xe9\x6d\x36\xb4\x2a\x3f\xb0\xdd\x70\x3d\xaa\xeb\x68\xf0\x90\x02\x2e\x0a\x27\x34\xf1\x35\x18\x8e\x87\xaa\x84\x34\xdd\xf1\x0b\x9a\xce\x58\xe0\xf5\x3d\xdf\x18\xc8\x48\xc0\x79\xe9\xcd\x09\x99\xd5\x9d\x6b\x6c\x4a\x0e\x1d\x79\xd2\x1e\xa5\xa8\x27\x0d\xf2\x99\x1d\x16\x50\xe2\x2f\x43\xd2\x15\x5e\x51\xc7\x55\xf9\xc6\x65\x85\xaa\xe4\x9b\x56\x8d\x30\xb8\xcf\x59\xcf\x25\x17\x90\x70\xe6\x32\xf7\xcf\xd9\x97\xb1\xd5\xcf\x40\xb5\x36\x66\x6c\x9c\xb9\xa4\xe7\xc9\x58\x1d\xeb\x83\xcc\xfb\x69\xf2\xe2\xd8\x8d\xf7\x50\x3c\x1d\xb5\x3f\x9c\xb4\x9e\x80\x04\xdc\xd7\xcb\xe3\xd6\xc7\x64\x37\x2d\xab\xb1\xea\x7a\x87\x94\x3e\xe6\xce\x25\xa7\xd8\x55\x87\xab\x94\x17\xa6\x64\x76\x43\x9a\x57\x5c\x2a\x29\x32\x5e\x7b\x13\x7f\xe1\x26\xba\xc1\xcd\xfe\xd0\xeb\x81\x5c\x66\x37\x14\x5c\x5f\x80\xd1\xee\x5b\x5f\x85\x4f\x06\x25\x85\x2f\x08\x32\x25\x2d\x4a\xfb\x05\x65\x69\x2b\xc7\x28\x69\xdf\xbf\x8b\xe6\x6f\x9d\x90\x28\x20\xab\x47\xb2\xf5\x3b\x61\xf2\x8d\x6b\x83\x27\xd2\xf6\x26\xbc\xa7\x2b\xaf\x68\xee\x35\x85\xf1\x0c\xde\xbe\x99\xc1\xfb\x77\xf1\x1f\xee\xfa\x72\x42\xc3\x27\x46\x97\x90\xd5\x0e\x91\x03\x34\x99\xdb\x7e\x28\xf7\xa9\x3d\x9c\xc3\xab\x21\xa3\x5e\xcb\xb9\xe5\xb6\x33\x7d\xa3\x80\xbd\x25\xc5\xb8\xa3\xc9\x6e\x00\xaf\x21\x84\x10\x5e\x83\xbf\x74\x81\x0f\x36\x7a\xf1\x02\xb9\x15\xc7\xb3\x89\x81\x95\xca\x71\xf1\x5d\x03\x4e\xde\x8b\xfb\x04\x8d\x78\x7c\x70\xfc\xd1\x6a\xea\xf0\x02\xf6\xfc\xf7\x12\x54\x2e\xe3\x55\x80\x57\xd3\xa5\xe0\xd1\xbf\x2c\xf6\x10\xb8\x5a\x1a\x68\x55\xa2\xf5\xa2\x61\xec\xf7\xaf\xa0\x9f\x13\x8b\x31\x38\xb7\xee\xfb\x76\x31\xc6\xf5\x70\x4e\x55\xe5\x90\x3d\xd8\x28\x4e\x3e\x2a\x89\x51\xbc\x60\xfd\xf2\xb7\x9d\xb0\xff\xe5\x35\xee\x59\xa6\xc6\x95\xad\x68\x6c\x72\x4c\xe5\x55\x44\xa1\x44\x9b\x52\x7f\x5b\xf8\x7e\x19\xc5\x50\x70\x51\x63\xbe\x80\xdf\x8c\xab\x6c\xb7\xd2\x8d\xd4\xfc\x5f\xf8\x62\x36\x01\xf1\x93\x4b\x63\xa3\x3f\x5a\xd3\xe4\x1d\xda\xb6\x28\xa0\x55\xc6\x88\x75\x8d\xcf\x86\x3b\x7b\xd6\xdf\x86\x45\x74\xe2\xd5\xa0\xc8\x6f\x1a\x98\xd3\xae\x31\xf2\xd6\x6f\x93\x9e\xc1\x8b\x9d\x3a\xfa\xe0\xf7\xc0\xef\xed\x9d\xcf\xfa\xea\x96\x6d\xd9\x7f\x01\x00\x00\xff\xff\xcd\xea\xf8\xb6\xdf\x0d\x00\x00"), - }, - "/src/net/http/http.go": &vfsgen۰CompressedFileInfo{ - name: "http.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 2998, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x56\x61\x6f\xdb\x36\x10\xfd\x2c\xfe\x8a\xab\x06\x04\x52\xaa\xc8\x0d\x50\x74\x43\x1a\x63\xc8\xd2\xae\x09\xd0\x74\x85\x93\x02\x05\xba\xa2\xa0\xa5\x93\xc4\x84\x26\x15\x92\x8a\xe3\x15\xfe\xef\xc3\x91\xb2\x22\x3b\xe9\x86\x2d\x5f\x42\x93\xc7\xbb\x7b\x8f\xef\xee\x34\x99\xc0\xf3\x79\x27\x64\x09\xd7\x96\xb1\x96\x17\x37\xbc\x46\x68\x9c\x6b\x19\x13\x8b\x56\x1b\x07\x09\x8b\xe2\x79\x57\x09\x1d\xd3\x62\xe5\xd0\xd2\x02\x8d\xd1\xc6\xaf\x84\x9e\x08\xdd\x39\x21\xe9\x87\x42\x37\x71\x78\xef\x5a\xa3\x9d\xbf\x60\x9d\x29\xb4\xba\x8b\x19\x8b\xe2\x5a\xb8\xa6\x9b\xe7\x85\x5e\x4c\x6a\xdd\x36\x68\xae\xed\xc3\xe2\xda\xc6\x2c\x65\xec\x8e\x1b\x78\x83\x15\xef\xa4\xbb\x32\x5c\x59\x9f\xc2\x14\xaa\x4e\x15\x49\x0a\x33\xdd\xa9\xf2\xca\x88\xb6\x45\x03\xdf\x59\x64\x97\xc2\x15\x0d\xad\x0a\x6e\x11\xae\x6d\xfe\x4e\xea\x39\x97\xf9\x3b\x74\x49\x5c\xa1\x2b\x9a\x38\x85\x67\x53\x3a\xf9\xa4\x4a\xac\x84\xc2\x12\xf6\xf6\x76\x2d\x67\xc8\x4b\x3e\x97\x78\xe9\x0c\xf2\xc5\xe3\x2b\x47\x30\x99\xc0\xb6\x11\x08\x0b\x9d\xc5\x12\xb8\x05\x0e\x45\x83\xc5\x0d\x54\xda\x80\xed\x5a\x9f\xb3\xae\xc0\x7a\x43\xa1\x6a\x30\x68\x5b\xad\x2c\xc2\x5c\x97\x02\x6d\x06\x16\x03\xcb\xf6\x68\x32\xf1\x69\xe6\xb6\xc5\x22\x5f\x36\xdc\x2d\xeb\x5c\x9b\x7a\xf2\x53\xb8\x6d\x73\x16\x45\x06\x5d\x67\x14\xec\x79\xcb\x81\x96\xef\xeb\xa7\x61\x7f\xbe\x78\x7f\xe6\x5c\x3b\xc3\xdb\x0e\xad\x7b\x02\xcc\xc8\xe3\xe7\xb3\xd9\x96\xbf\x32\x50\x3f\x32\x51\x7a\xcb\x60\xcd\xd6\x49\xca\xd8\x64\x32\x3e\x18\xb8\x58\x36\xa8\x40\xa1\x70\x0d\x1a\xf8\x9d\xb2\x85\x93\x8f\xe7\xa0\xb4\x81\xed\xac\xfc\x36\x37\x08\xfc\x8e\x0b\x49\xac\xe6\x70\xee\x80\xcb\x25\x5f\x59\xa8\xb8\x90\x36\x67\x6e\xd5\xe2\x56\x18\xeb\x4c\x57\x50\x1a\x8c\xf4\x00\xc9\xe8\x6c\xa4\x8d\xc4\xe0\x2d\xec\xf7\x81\x52\x48\xf6\x67\x3d\xfb\x19\x78\xd5\xa6\xa4\x97\x0d\x3a\x21\xfb\x5d\x9b\x7f\xc0\x65\xe2\x05\x4c\x0f\x73\x34\xc0\xd0\x55\x8f\xe4\x69\x14\x96\xc0\x0f\x28\xe2\x94\xad\x59\x48\x7c\x4c\x6d\x9f\x39\x05\x16\xaa\x92\xa2\x6e\x1c\x2c\x78\xfb\x65\x93\xe5\xd7\xfd\x6b\x9b\xff\x31\xbf\xc6\xc2\xb1\x01\x9d\x83\xfd\xb1\x8f\xff\x8a\xf0\xbe\x31\x70\x34\xfd\x37\x71\x78\xd4\x29\x63\x91\xa8\xc0\xe5\x43\x72\xd3\x29\x51\x43\x6e\xa2\xf1\xee\x8f\x92\x0e\xca\x18\x99\x7e\x31\x78\xfb\x15\xa6\x70\xdf\x18\x2f\x2a\x34\x50\xa2\x44\x87\xc9\x83\x4d\x06\x06\x6f\x29\x34\x55\xc7\x69\x43\xc9\x2e\xf8\x0d\x26\x45\xc3\x15\x0c\x90\x52\x16\xa1\x31\xbb\xc7\x01\x26\xf3\x28\xf3\x4b\x02\xa6\x95\xd4\xbc\x8c\xb3\x4d\xab\xa0\xd4\x1b\xe4\x25\x9a\x0c\xbe\xd1\xe5\xa1\x2d\x11\xe4\x99\x3f\x49\x7c\x5f\x1b\xff\xa6\xf6\x36\xfa\xfd\xe5\x2b\xed\x24\x14\xe4\x94\x4b\x99\xc4\x35\xba\x13\x29\x37\xb9\x9d\x79\x2b\x1b\xa7\xf9\xa5\x33\x42\xd5\x49\x0a\xcf\x21\xfe\x53\xc5\x69\x9a\xa6\x39\xf9\xb8\x38\xbf\x78\x1b\xac\x92\x94\x45\xd1\x5c\x97\xab\x27\x1e\xe5\x93\x50\xee\x97\x13\x63\xf8\xaa\x7f\x10\x0a\xe8\x4f\x36\x8d\x23\x4e\xd3\xfc\x5c\x39\x34\x15\x2f\x30\x49\xf3\x3e\x33\x62\x20\x2a\xb4\x72\xa8\xdc\x7b\x54\xb5\xf3\x34\x09\xe5\x5e\xbd\x4c\x0e\x0e\x29\x62\xdf\x21\x0d\xde\xe6\x17\xe8\x1a\x5d\x7a\x62\x7c\xdb\x88\xcf\xde\x9e\xbc\x89\xa9\xd4\xe9\xf1\x43\x1d\xd0\xf5\xbe\x65\xe7\x1f\xb9\xb1\x78\xae\x5c\x12\x68\x0c\x09\x9d\x86\x60\x07\x21\x5a\x9c\x66\x70\xf8\x22\x83\x57\x2f\xd3\xd7\xfe\xfa\x48\x37\xbb\x89\x4d\x41\xd2\xee\x9a\x45\xe3\x2e\xf3\xc8\x28\x24\x2f\x51\x25\x44\x56\x4a\x18\xd6\xcc\xb7\x23\x2f\x92\xe3\x03\xd8\xdb\xd0\xef\xa3\x5c\x3a\xee\x3a\x7b\x04\xfd\xdf\xc0\x9c\xf5\xfb\x3b\x4f\x03\x31\x3c\xdf\x35\xb9\xc2\x7b\x37\x32\xcb\x1e\x9c\x9e\xea\x12\x8f\x9e\x76\x4a\xb4\x04\xd3\xf0\xba\x43\xfc\xfe\xb1\x03\x65\xc1\xe2\x74\x8c\xf0\x08\xb6\x00\x7b\x83\xdf\x74\xb9\x1a\x1c\x00\x84\x69\x9a\x7f\xd0\xed\xa9\xd4\xf6\x09\x55\x06\x62\xfc\xd5\xbe\x14\x37\xb7\x0d\xde\x66\x9e\xb0\x68\xbd\x53\x1c\xbe\x60\x36\xd5\x81\xf0\x50\xba\xa1\x52\x42\x89\x1d\x1f\xfc\xa0\x17\xee\xb4\x3d\xea\xcf\x58\xc6\xe9\xe3\x30\x7c\xae\x8d\xfb\xdf\x61\x4c\xef\xbf\xe0\xaa\xc0\xdd\x08\xa1\x00\x75\x8b\x2a\xce\x46\x7a\x0e\xeb\x4f\xb3\xf7\xc3\x0b\xa6\xa3\x8c\x36\xf5\x73\xb5\x6a\x31\xce\x20\xe6\x54\x64\xf3\xae\xaa\xd0\xc4\x29\x0d\xf5\x86\x5b\x70\x1a\xe6\x08\xbc\x72\x68\x20\x04\x80\x4e\x39\x21\x87\x09\x3d\xef\xea\xbf\x84\x94\x3c\x5f\xe8\xf0\x9f\x06\xb4\x6d\xf4\xf2\xdb\xbc\xab\xf3\xa2\x16\xbf\x8a\x72\x7a\x78\x78\xf8\xe2\xe7\x57\x87\x34\x0e\x0c\x5a\x2d\xef\xb0\x64\x11\x7d\x11\xdc\xe0\x2a\x83\x3b\x2e\x3b\xb4\x54\x5e\x86\xab\x1a\x7d\xd2\x41\x2b\x9e\x18\xb2\xfb\xd6\x5b\x3d\x18\xf5\x97\xbc\xce\x1f\x28\xb0\xe8\xfa\x87\x08\x0e\xe2\x6c\x14\x22\xed\x9f\xdf\x37\x74\x0a\x42\xe2\x1a\x97\xe5\xd8\x8f\x0a\x0c\x03\x4a\x8b\xfe\x90\x94\x35\xf4\x81\x5e\x87\x24\xba\x13\x29\x93\x8d\x33\x8a\x20\x2a\x6f\xf4\x6c\x54\xed\x9b\xe3\xdc\x8b\x36\xf1\xe4\x0e\x03\x0b\x16\x9d\x1d\xa6\x7b\x41\x06\xe0\x1a\xff\x35\xb4\xca\x40\xa8\x42\x76\x25\x7d\x26\x69\xb5\x11\x46\xf0\xb8\x35\xa2\x03\xb0\x47\x71\x1e\x43\xca\xbc\x5f\x02\xc6\x58\x64\x51\x62\x18\xbc\xbe\xe7\x91\x1e\x08\xdb\xf1\x41\xe8\x27\xa3\x0f\x1d\xda\xc8\x28\x5a\x6f\xda\xb3\x70\x7c\xe0\x45\x3b\xfe\x22\x1a\x12\x5a\xff\xc3\xb0\x3e\xf5\x1a\xee\x1f\x6a\x67\x60\x7f\xf7\xaf\x73\xdf\x98\x0c\xf4\x8d\x9f\x4d\xdb\x83\xf3\x35\x6d\x6f\x3f\x56\x28\xac\x34\xc4\xfc\x3b\x00\x00\xff\xff\x05\x0b\xbb\x60\xb6\x0b\x00\x00"), - }, - "/src/net/net.go": &vfsgen۰CompressedFileInfo{ - name: "net.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 770, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x92\x41\x8b\xdb\x30\x10\x85\xcf\xd1\xaf\x18\x74\x92\x5a\xe3\x5c\x96\xde\x5b\x17\x82\x4b\x9b\x04\x02\x6d\xaf\xb2\x3c\x71\xe4\xc8\x92\xd1\x8c\x9b\x0d\x65\xff\x7b\x51\xe2\xec\x2e\xbb\xb9\xf6\x64\x6b\xf4\xf8\xe6\xe9\xcd\x2c\x97\xf0\xb1\x99\x9c\x6f\xa1\x27\x21\x46\x63\x8f\xa6\x43\x08\xc8\x42\xb8\x61\x8c\x89\x41\x89\x85\xc4\x94\x62\x22\x29\x16\x92\xce\x64\x8d\xf7\x52\x88\x85\xec\x1c\x1f\xa6\xa6\xb4\x71\x58\x76\x71\x3c\x60\xea\xe9\xe5\xa7\x27\x29\xb4\x10\xfb\x29\x58\x68\xce\x8c\x75\x68\xf1\x51\x11\x10\x27\x17\xba\x02\xae\x55\x0d\x2e\x30\xfc\x15\x8b\x84\x3c\xa5\x00\x3d\x95\x75\x60\x4c\xc1\xf8\x4d\xd3\xa3\x65\x45\xba\xac\x8c\xf7\x4a\xba\x0c\xd8\xec\x65\x91\x45\x2b\x1f\x1b\xe3\xcb\x15\xb2\x92\xbb\x0b\x51\xde\x74\xfb\x14\x87\xea\x60\x52\x15\x5b\x94\x05\x58\xad\x33\x52\x69\xf1\x34\xbb\xf9\xee\x88\x31\xa8\x80\x5c\x80\x37\x6d\x9b\x66\x4f\x1a\xd4\xf5\x0a\x53\x01\x97\x17\xeb\xec\x6c\x34\xc1\x59\x75\x4d\xa0\x5c\xe3\x49\xc9\x80\x7c\x8a\xe9\x08\xc6\x5a\x24\x02\x47\x10\x22\x03\x4d\x63\xce\x0b\x5b\x68\xce\xb0\xba\xc4\xf0\x6d\x27\xf5\x4b\x5f\xd5\xc2\x87\xaf\xce\x78\x4c\x1a\xf2\x57\xcd\x9c\x02\xb2\x89\x4c\x7a\xf6\x51\xc5\x10\xfe\x8b\x07\x3a\x53\x1d\x1c\xab\x4c\xbd\xd5\xc6\x14\x1b\xac\xb7\x7f\x1e\x76\x6c\xec\x51\x69\x68\x62\xf4\xaf\x66\xb2\x37\x9e\xf0\x9d\xfa\xd3\x4d\xad\xe6\xa6\x94\x8b\x05\xbc\x3a\x3d\x0c\x66\xbc\xc0\xf4\x5b\x5a\x71\x0f\xfa\xcb\x85\x36\x9e\xa8\xde\xbe\x23\xff\x74\xc4\xa6\xde\xde\x67\x3d\x43\x06\xf3\x78\x9b\xdf\x17\x63\x8f\x3e\x76\xea\xed\x7a\xcd\xdb\x5b\xee\x36\x3f\x3e\xff\xae\x36\xeb\xb5\x78\x12\xff\x02\x00\x00\xff\xff\xaa\x32\xc7\x87\x02\x03\x00\x00"), - }, - "/src/os": &vfsgen۰DirInfo{ - name: "os", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/os/os.go": &vfsgen۰CompressedFileInfo{ - name: "os.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 581, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x5c\x91\x4f\x6b\xdc\x30\x10\xc5\xcf\x9e\x4f\x31\xd5\x49\x62\x5b\x3b\xb9\x76\x6b\x4a\x28\x61\x5b\x28\x2d\xb4\x94\x1e\x42\x28\xfe\x33\xd6\x8e\x23\x4b\x46\x92\x9b\x85\x65\xbf\x7b\x91\xd6\x4e\x21\xe0\x83\xd1\xfc\xde\x9b\x99\x37\x55\x85\xbb\x76\x61\xd3\xe3\x18\x00\xe6\xa6\x7b\x6a\x34\xa1\x0b\x00\x3c\xcd\xce\x47\x94\x50\x08\xf2\xde\xf9\x20\x00\x0a\xa1\x39\x1e\x97\xb6\xec\xdc\x54\x69\x37\x1f\xc9\x8f\xe1\xff\xcf\x18\x04\x28\x80\x61\xb1\x1d\xfa\xc5\x46\x9e\xe8\x4f\xe3\x75\x90\x0a\x1f\x1e\x43\xf4\x6c\x35\x9e\xb1\xaa\xd0\xba\x88\x5d\x63\x0c\xf5\xe8\x2c\xfe\x66\xdb\xbb\xe7\x00\x85\xa7\xb8\x78\x8b\x77\x5e\x07\xb8\xac\x3e\x6c\x39\x4a\x85\x67\x28\x78\xc0\xd9\xbb\x8e\x42\xc0\xf7\x35\x8e\xa1\x3c\x18\xd7\x36\xa6\x3c\x50\x94\x62\xad\x08\xb5\x7f\x81\xde\x64\xe8\x97\xed\x69\x60\x4b\x7d\xb2\x28\x1a\xaf\xff\x26\xf5\xca\x5c\xb5\xe9\x51\x28\x28\x8a\xd4\x18\x6b\x9c\x9a\x27\x92\xdb\xc0\x6f\x31\x95\xcb\xaf\x64\x75\x3c\x4a\xf5\xee\x36\x81\x83\xf3\xc8\xc9\xe7\x66\x8f\x8c\x1f\x5e\x23\x7b\xe4\xdd\x2e\xf7\xcb\x96\x0f\xfc\x88\xf5\x95\xf9\x62\x7b\x3a\x49\xc6\x1d\xde\xaa\xf2\x67\x6e\x20\x93\xe1\x05\xd2\xc7\x03\x1a\xb2\x32\x69\x14\xd6\x35\xde\x64\x8f\x75\xaa\x6d\xa0\xb3\xf8\x28\x32\x7e\x79\x95\x74\x4b\x83\xf3\x74\x7f\xba\xe6\xb5\x55\xe9\x44\xdd\x12\x9b\xd6\x90\x54\x28\xb7\x9d\xf2\x45\x73\xaa\x6b\xe6\x42\xac\x8f\xa1\xfc\x46\xcf\x52\xdc\xbf\xc8\xf2\xb1\x78\x9a\x0d\x4d\x64\x23\xf5\x98\x96\x3f\x7c\xbf\xfb\xf1\xe9\x73\x3d\x06\xa1\xe0\x02\xff\x02\x00\x00\xff\xff\x55\xfc\x3a\xb3\x45\x02\x00\x00"), - }, - "/src/reflect": &vfsgen۰DirInfo{ - name: "reflect", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/reflect/example_test.go": &vfsgen۰CompressedFileInfo{ - name: "example_test.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 311, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x5c\x8d\xcf\x4a\x33\x31\x14\xc5\xd7\xbd\x4f\x71\xc9\xe2\xa3\xe5\x93\xa4\x95\xba\xe8\xec\x5c\x88\xe2\xa6\x62\x1f\xc0\xa6\x93\x9b\x3f\x75\x92\x0c\xc9\x8d\x08\xa5\xef\x2e\x33\x22\x82\xbb\x03\xbf\x73\xce\x4f\x29\xfc\x7f\x6a\x61\x30\x78\xae\x00\xa3\xee\xdf\xb5\x23\x2c\x64\x07\xea\xf9\x8d\xa9\x32\x40\x88\x63\x2e\x8c\xc2\x46\x16\x00\xb6\xa5\x1e\x1f\x3e\x75\x1c\x07\x3a\x70\x69\x3d\xef\xed\x72\x85\x17\x58\x28\x85\x8f\x79\xf4\x54\x9e\x0f\x68\x32\x55\x4c\x99\x31\x4c\xbd\x48\x89\x7f\x4e\xa5\x36\xe6\xf5\x3b\xee\xad\xc5\x44\x64\xc8\xa0\xcd\x05\xd9\x87\x8a\x93\x52\xce\x5f\x07\x22\xf4\xcc\x63\xed\x94\x72\x81\x7d\x3b\xc9\x3e\x47\xe5\x66\xc5\xb9\xfe\x86\x50\x6b\xa3\xaa\xb6\xbb\x1d\xc0\xc2\x46\x96\x2f\x25\x24\x1e\xd2\xf2\xf8\xa1\x87\x46\x1d\xfe\xbb\x3c\x51\x70\x9e\xbb\xb5\xdc\xe2\xbd\xa3\xee\xf6\x0a\xe7\x9a\x53\x87\x78\x11\x7e\x46\x62\x62\x37\x42\x3b\x12\x13\xfd\x3b\xdc\xc8\xbb\x79\xb8\x59\x5f\x8f\x2b\xb8\xc2\x57\x00\x00\x00\xff\xff\x0d\x48\xa9\x1a\x37\x01\x00\x00"), - }, - "/src/reflect/reflect.go": &vfsgen۰CompressedFileInfo{ - name: "reflect.go", - modTime: mustUnmarshalTextTime("2017-01-10T10:59:23Z"), - uncompressedSize: 36514, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x7d\xfd\x73\x1b\x37\x92\xe8\xcf\xe4\x5f\x01\xb3\xb6\x74\x33\xd6\x84\x12\x95\x7d\xa9\x94\x62\xe5\x6a\xe3\x24\xfb\xb4\x1b\x5b\xa9\x38\xce\x7b\xf5\x74\x2a\x1f\x44\x62\x28\x88\x43\xcc\xec\x0c\x48\x8b\x91\xf8\xbf\xbf\x42\x37\xbe\x67\x86\xa4\x1c\xef\xdd\xfe\x70\xa9\x8a\x45\xe2\xa3\xd1\x68\x34\x1a\xfd\x05\xf0\xe4\x84\x1c\xdf\xae\x78\x31\x23\xf7\xcd\x70\x58\xd1\xe9\x82\xce\x19\xa9\x59\x5e\xb0\xa9\x1c\x0e\xf9\xb2\x2a\x6b\x49\x92\xe1\x60\xc4\xea\xba\xac\x9b\xd1\x70\x30\x6a\x64\x3d\x2d\xc5\x5a\x7d\x5c\x89\x86\xe6\x6c\x34\x1c\x0e\x46\x73\x2e\xef\x56\xb7\xe3\x69\xb9\x3c\x99\x97\xd5\x1d\xab\xef\x1b\xf7\xe1\xbe\x19\x0d\xd3\xe1\x70\x4d\x6b\xc2\x05\x97\x9c\x16\xfc\x77\x36\x23\x17\x24\xa7\x45\xc3\x86\xc3\x7c\x25\xa6\x50\x93\xa4\xe4\x71\x38\x38\x39\x21\x74\x5d\xf2\x19\x99\x31\x3a\x23\xd3\x72\xc6\x08\x2b\xf8\x92\x0b\x2a\x79\x29\x86\x83\x55\xc3\x66\xe4\xfc\x82\xa8\x6e\x09\x27\x5c\x48\x56\xe7\x74\xca\x1e\xb7\x29\x79\xdc\x62\x7d\x52\xcb\x4d\xa5\x4a\xf4\xd7\x95\x98\x96\xcb\x65\x29\x7e\x0d\x4a\x97\x4c\xde\x95\x33\xf7\x9d\xd6\x35\xdd\x84\x4d\xa6\x77\x34\xea\xa4\x86\x0d\x4b\x2c\x06\x11\x74\x5a\x85\x05\x95\xac\xc3\x82\xa6\xe0\x71\xa7\x46\xd6\xab\xa9\x8c\xe0\xc7\x78\x62\xa3\x1f\x39\x2b\xa0\x70\x38\x08\xc9\x2a\xeb\x15\x1b\x0e\x56\x5c\xc8\xaf\x15\x20\x72\x41\xd4\x9f\xab\x3c\x81\xa2\xe4\x34\x4d\xc7\xc9\x4b\x20\x50\x4a\x4e\x4e\x48\xc3\x24\xc9\xcb\x9a\xd4\x8c\x16\xc3\xad\x5e\x8e\xfb\x46\xf5\x49\xe4\xa6\x82\xce\x29\x79\x79\xdf\x8c\xaf\x6e\xef\xd9\x54\xaa\x35\xaa\x99\x5c\xd5\x82\xdc\x37\xe3\x4b\x35\x79\x41\x0b\xac\x53\x1d\xd2\xf1\x5f\x99\x4c\x46\x08\x61\x94\x5a\x90\x9a\xaf\x2c\x5c\x07\x31\x25\x88\x8e\x82\xcc\x73\x22\x37\x15\x82\xf0\x7a\x8c\x52\x72\x71\xa1\xc6\x7b\x2f\x66\x2c\xe7\x82\xcd\x54\xe3\x41\x2d\x15\x27\x1c\xe1\x6a\x0f\x07\x83\x41\xc3\x7f\x67\xe7\x44\x4d\xb4\x92\x75\x62\x21\xa9\xe2\x51\xaa\x90\x4d\xd2\x34\x53\x0d\x17\x5c\xcc\xb0\xe1\xd7\xae\x99\x2a\x0c\x9b\x35\xb2\x3e\x27\x44\xb0\x8f\x6f\xe9\x92\x5d\xe5\x79\xa2\x3f\xe2\xa2\x0b\x5a\xbc\x0b\x86\x91\x35\x17\xf3\x51\x9a\x66\x64\x34\xc2\xff\x6d\x1d\x7b\x50\xbb\x89\x29\xf8\xdf\x95\x65\x91\xa4\x38\xc2\x76\x38\x18\xb4\xc9\x58\xcb\x74\xfc\xce\xa3\x22\xc0\x49\x87\x83\x81\x02\xf7\x2e\xa6\x4d\xd6\xb1\x10\xb5\x4c\x15\x67\x0c\x90\x77\xde\x31\x20\xd4\x7d\x33\xfe\x6b\x51\xde\xd2\x62\xfc\x9a\x16\x45\x32\xfa\x93\xad\x75\x23\xf0\x9c\xd8\xd2\xf1\x4f\x4c\xcc\xe5\x5d\x92\x92\x17\x17\xe4\x94\x3c\x3d\xb9\xe9\x08\xba\xf4\xe6\x02\x8b\x31\xa8\xe5\x58\xe6\x05\x9d\x93\xa7\x0b\x02\x1f\xde\xeb\x6d\xa7\x2a\xfd\x85\xed\xea\xdc\xee\xad\xe8\x3c\x53\x55\x5b\x00\x8e\x13\x7e\x03\xb8\x35\x6a\x36\x4b\xba\x60\xc9\xf5\x0d\x62\x9b\x75\x60\xad\xa6\x33\x50\xac\xcd\x55\xf3\x9a\x0a\x27\xdd\x0c\x18\x1c\x7a\x09\xe0\x6c\xff\x4b\x31\x63\x0f\x09\x4f\x11\xad\xa0\xc3\x35\xbf\x21\xa6\x29\xf6\x1d\xa8\xc9\x9c\xef\x63\x91\xa5\x9b\x78\xc0\x1e\x1d\x6d\xaa\x85\xe2\x20\xc5\xee\xa3\x91\xe6\xc2\xc1\x60\x29\x37\x15\x0c\x82\x5b\x39\x4f\xfc\xdd\xa4\x3b\xca\x4d\x35\x4a\x4d\x8f\xad\x25\xdc\x0a\xf7\x48\x20\x02\xa1\x49\xb5\x98\xff\x4c\xe5\xdd\x33\xf8\x1b\x51\x73\xd8\x83\x00\x37\x23\x2e\xa7\xe5\x4a\xc8\x73\x42\x60\x57\x4d\xbe\x4a\x3a\x16\x04\x5b\x7e\xc0\x9a\xe6\x3c\x5a\x8d\xcc\xe1\xec\x21\xfb\x86\x56\xd7\xb5\x54\x64\x5f\x49\x55\xd7\xe6\xf5\x55\xdf\x6e\xd9\xaa\x1d\xd0\x7c\xe4\x72\x7a\x47\x6a\x39\xfe\x3b\x17\x33\xcd\x6e\x53\xda\x30\xf2\x17\x25\xef\xcf\x61\x9b\x33\xa9\x2a\x81\x9a\xb5\xcc\xc8\x91\x3b\x0a\x00\x63\x56\xb0\xe5\x79\x2c\xc1\xf4\xbe\x2e\xd8\xd2\xae\x53\xc1\xc4\x39\x69\x8b\x9f\x82\x89\x50\xac\x28\x51\x8e\x38\xbc\xbe\xa3\x02\x50\x98\xf1\x5a\xad\xd3\x77\xa5\xbc\xfb\x9e\xd7\xf1\x8e\x69\x98\x98\x5d\x89\x62\x13\x6f\x1a\xd5\xeb\x82\xbc\x63\x62\xa6\x3b\x6d\xe3\x9e\x35\x9b\xae\xfb\x7b\xfe\xc2\xa6\x6b\xbf\x67\x8b\x10\xf6\x00\x7c\x16\x1d\x66\xbc\xf6\xe8\x30\xe3\x75\x3c\xed\x1f\x57\x62\x0a\xd3\xae\x68\x4d\x97\xb0\x9d\x1d\x97\x41\xd1\x08\xb6\x1f\x17\xde\x4e\xc7\x53\x22\x23\xd8\x60\xe7\x36\xe7\x42\x4f\x93\x0b\xdc\xb2\x3e\xce\xba\xbf\xd9\xe6\xa9\x27\x63\x9a\x55\x21\x43\x6c\x74\x19\xa2\x53\xe2\x66\x8a\xf0\xd1\x4d\x76\x22\xa4\x7a\x22\x46\xe5\x4a\xb6\x51\x32\x20\xda\x38\x95\x2b\xf9\x5a\x6d\x2c\x05\x4a\x6f\xac\xce\xf1\xfc\x35\x5f\xd3\x9a\xd3\x19\x9f\xc6\x6b\x6e\x61\x3d\x5d\x90\x09\x79\xf5\x8a\x4c\xfe\x57\xff\xca\x5b\x45\x47\x4b\xe7\x4d\xc5\xd4\xe6\x56\x67\x75\xa6\x49\xfb\x5a\xef\x78\x8d\x57\xbc\x2e\x59\x30\xe8\x39\x31\x9f\xb4\x14\xe0\x02\xe0\x11\xc2\x85\x2e\x29\x57\x12\x8b\xca\x95\x8c\x18\xe6\xd2\x28\x59\xc0\x35\x4b\x77\x0a\xd8\x49\xeb\x32\xcd\x37\xcb\xd6\x39\xc1\xc3\x83\x62\x0f\xff\x2c\xfb\x0e\x88\x26\x3c\x1e\x4c\x43\x5c\x52\xfe\x5f\x7f\x32\xc0\xc1\xf0\x69\x27\x43\x6b\xc9\x43\x4d\x36\x5c\x77\xbb\xec\x56\x78\x9b\xa9\x47\x2b\xf5\x86\x56\xdd\x32\xd5\x28\xc4\x00\x65\xc1\x36\xe7\xa4\x5b\x92\x2c\xd8\xc6\x4e\xef\x40\x81\xe3\x46\xff\x59\xd6\xdd\xa3\x1b\xed\xfb\xd3\xc0\xbe\x53\xaa\x7a\x37\x60\xa7\xc5\x7f\x22\x68\xd0\xe6\x01\x76\xae\x54\xfa\x90\xab\xb1\x08\x99\x5a\x03\xfd\xd1\xb6\xd2\x9c\xed\xd9\x03\x19\xc1\x0e\x87\xe8\x40\x1a\x0e\xa2\x9d\x83\x49\x85\x7d\xbb\xf4\x1f\x6c\x8c\x5c\xee\xdb\x1f\x3e\xa7\x5b\x45\x22\x60\xf0\x3c\x62\xf0\x8e\x3a\x49\x9d\x5e\x91\xf7\xa9\xcb\x01\xbf\x87\xac\x93\xfb\x6c\xae\xdb\x95\x79\xde\x30\xe9\x6c\x01\xbe\x9f\xfd\x3d\xe3\xab\x87\xf7\xad\xca\xb4\x4f\x4d\x52\xad\x3a\x54\x25\x84\x82\x64\x76\xec\x8f\xb4\x75\x6c\xb1\x1d\x82\xe6\xa2\x8d\x2c\x63\xab\x25\x68\x6f\x8f\x7f\x2e\x61\xd0\xa4\xdb\x4c\x1a\xbf\x87\x56\xca\xbc\xb0\x96\x57\x38\x51\x62\x8e\xad\x85\x2e\x8b\x4c\xe8\xe1\x2e\x7b\xc4\xf4\xe9\xb4\x39\x4c\xa5\x62\xba\x1d\xb5\xda\x80\x91\x3b\x4d\x97\xed\x70\x08\x26\xa1\xaf\x09\x6a\xc6\x53\x28\x6a\x12\x13\x81\x92\x75\xa8\xb5\x4f\x73\x14\x0d\x07\x1f\xf0\x68\xb1\xdf\x97\x65\x9e\x9b\xef\x5f\x9e\x85\xf5\x5f\x9e\x0d\x87\x56\x29\x25\xc6\xa2\xb0\xe4\x4b\x24\x79\xe9\xa3\x91\x9a\x93\x20\x49\x6d\x63\xcf\x28\x96\x63\x03\x4a\x41\x58\xd3\x9a\x44\xda\x2c\xd1\x1b\x77\x49\xab\x6b\x5c\x8b\x9b\x10\xbe\x37\xae\x36\xd3\x4d\x75\x92\x86\xa8\x78\xc3\xc6\x2a\xb3\xbc\xb1\x34\x34\x27\xb9\x47\x3f\xb4\xb7\x09\x21\xff\xa9\xb9\xe7\x7c\xa4\x5a\x8d\xfe\x73\x68\x8e\x75\x47\x3a\xab\x35\xe8\x82\xa1\x3a\xba\x09\x31\xfa\xcf\x10\xce\x6d\xf7\xd5\x27\x9b\x19\x39\x25\x5c\x00\xb5\x9c\xa1\xef\xa8\xc5\x45\x4f\x9f\x72\x25\x7b\x3b\x95\x2b\x69\xe7\xa7\x98\xc0\x9b\xdb\xed\x46\xb2\x86\xbc\x54\x7f\x82\x26\xdf\x53\x49\xbd\x66\xd0\x4b\xfd\x87\x56\xfb\x70\x20\xe9\x9c\x04\x05\x86\xc9\x6c\x81\x11\x4a\xe4\xb6\x2c\x0b\xb3\xba\x0a\x4e\xbc\xaa\x6a\xec\x9b\x97\x66\x50\xbb\xa0\x02\x1a\xa7\xf0\x6f\x92\x92\xa4\xd1\x90\x53\x6f\x6e\x1a\xdc\xb5\x18\xc3\x3c\x6e\xc6\xaa\xc0\x11\xc8\x80\x90\x74\x7e\x30\x04\x49\xe7\x6d\x00\x7a\x72\x49\xaa\x21\xec\x02\xa0\xdb\xb6\x81\xf0\xe6\x07\x4d\x92\x24\x05\xa2\xec\x82\x62\xa8\x67\xc1\x18\x21\x2a\x32\x35\x9d\xcc\xa0\xa4\x11\xca\x48\x40\x6e\xa4\x1a\xac\xaf\x3a\xaa\x04\xfb\x98\x28\xb8\x29\x2e\xa4\x1a\xe8\x56\x9d\x4d\x47\x86\xe8\x4a\x84\x9b\x63\x89\x10\xd0\x30\x25\x9d\x6b\x8d\x53\x0d\x37\xf4\x2d\x60\xfd\x49\x15\x9a\x51\xcf\xed\xf8\x99\x92\xc7\xfe\xb4\x14\x6c\x98\xd4\x39\xb9\x85\x4a\x8f\x15\xae\xf2\xfc\x27\xde\xa8\xfd\x00\x0b\xd7\xda\xca\xba\x4d\xa2\xe4\x91\xfe\xec\xa6\xe6\x8d\xa1\xe1\x5c\x73\x21\x55\xdb\xf4\x26\x26\x1b\x28\x94\x1e\x43\x5d\xe5\x39\x38\xd0\x14\x75\x0a\x26\x12\x0f\x88\x26\x92\x41\xed\x82\xd0\xaa\x62\x62\xe6\x37\xc9\x88\x48\xe3\xf1\x95\x0a\xa0\x67\x26\x51\xb9\xd4\x33\xd3\x3b\xbd\x35\x37\xdd\x0a\xe6\xa6\x3f\xfb\xbe\x3d\xb3\x7b\x1d\xac\xee\xd9\x19\x4d\xb6\x05\x38\x98\x9f\x07\x26\x1d\x0e\x7c\x04\xed\xfc\xbc\xc2\x8c\xc8\x34\xc6\x40\xcf\x4f\xfb\x9f\xdd\x41\xde\xc8\xfa\xea\xf6\x3e\x70\x50\xba\x3d\xa2\xa8\x31\xd5\x62\xe4\x51\xfd\x35\x75\xdb\xae\x43\x6f\xaa\x4f\xbb\x46\xd6\xa3\x8c\x20\x60\xf0\xba\xce\x99\x34\x1d\x3f\x72\x79\xa7\x24\xa8\x41\x81\xff\x0e\xc2\x46\xe3\x3a\x1d\x37\xb2\x76\x68\x36\xff\xa7\x56\x93\x9b\x79\xae\xd9\x68\xdf\x39\xd7\xad\xf6\xc4\x7e\xc4\x1e\x56\x93\xb2\xc0\xa6\x65\xb5\x41\xed\x33\x99\x29\x0a\x35\xf5\xd4\x9b\x34\x78\x51\xf4\x10\x8f\x43\x4f\x37\x6d\x0d\xe0\x74\x54\xab\x68\x9e\x7e\x43\x38\x79\x15\x2b\xa3\xdf\x10\x7e\x7c\x0c\x0a\x67\x55\x97\x55\x87\xc6\xa9\xf5\xa7\xba\xac\x46\xe9\xf8\x1d\x90\x27\x51\x1a\xd1\xac\x91\x40\x47\x55\x03\x78\x42\x43\xf5\x4d\xe9\x1a\x5b\x3b\x23\x25\x81\x7f\xa3\xc5\x8a\x25\x12\x30\xcf\xc8\x3a\x98\x51\x5e\x90\xbc\xa0\xf3\x94\x40\x23\x3c\x08\x41\xdd\x1e\x9b\xf3\x15\x3d\xd0\xc6\x55\x74\x71\x81\x4e\x22\x70\x7d\x7a\x85\x48\xb5\xb8\xf4\x67\x59\xa3\x57\x1a\x17\x02\xc6\x78\x54\x9a\x65\xa4\xb9\xad\x9d\x92\x06\x28\x3d\x01\x52\x89\x01\x95\x6e\x7d\x79\xd3\x0b\xa5\xe5\xcc\x15\xec\xa3\x12\x7c\xba\x7e\x94\x91\x75\x66\xd6\xaa\x96\x63\x65\xff\x94\x4a\x2d\xdc\x33\xb8\x2e\xb8\x14\x33\x5e\x3b\xc2\xbe\xa1\x0b\x06\x36\x90\xe5\xbb\x4c\x6d\xc2\x8c\x4c\x69\xa5\x18\xd7\xa3\xa8\x76\x44\x68\xb2\xbc\xb8\x40\xdb\x09\x57\x9d\x0a\x3e\xb5\x0a\xeb\xd8\x02\x25\x65\x4e\x44\x29\xbe\x00\x53\x0a\x76\xe7\x08\x96\x55\xc1\x2a\x98\x20\xaf\xc8\xe9\xce\xfe\x4a\x1f\x9f\x53\xc9\xd7\x8c\x80\xab\xcd\xf4\x55\xc8\x3d\xa3\xef\x94\x56\xe1\xb8\xdf\x02\x84\xdd\xbd\x6d\x3b\xec\x6a\xd7\xcd\x63\xc5\x4d\x95\x75\xb8\xde\x0d\x88\x51\xe6\xef\x28\x47\xd6\x2e\xd5\x18\x62\x5e\x61\x30\x86\xb4\xb6\xfd\xf8\x87\x82\x2d\x93\x34\xd5\x23\xfd\xce\xea\x72\x94\x92\xad\x5a\xef\x53\xb7\xf9\x75\x4c\x28\x0a\xa0\xfd\xea\xc2\x30\x2f\xfc\xa8\xd2\x23\xb1\x61\x39\x88\x05\xaa\x15\xb3\x11\x26\xc7\xf2\x3a\x12\xb3\x35\x44\xe4\x6a\x5b\x08\x5e\xf8\xdb\x42\xf0\xc2\xe7\x6f\xdf\x8e\x6b\x4f\xd8\x88\x84\x69\x29\x50\xe4\x96\xf5\xc8\xb3\x6c\x80\xc0\xed\x59\xf8\xbc\xd8\x85\x02\xee\xa9\x60\x9b\xb9\xe5\xfa\x14\x84\xba\xd6\xca\xb4\xfc\xd3\x9a\x16\xa3\x90\xf6\x20\x53\xae\xf2\x04\x6d\x16\x2e\x64\x46\x58\xc1\x96\x5a\xd8\x46\x8a\x7d\x84\x4f\xc8\x45\xd6\x4f\xed\xb8\x48\x41\x4a\x33\x02\xb0\x3d\x52\xbd\xbe\xa3\xe2\x2a\x4f\x66\xbc\x86\x8f\xdf\xf3\x3a\x23\xf2\x13\x46\x34\x0e\x61\x8f\x6d\xd3\x8c\x80\x37\xd9\x3a\xa2\xed\x77\xed\x5e\xf6\xd0\xf8\x71\x25\xa6\x6a\xc1\x44\x46\xd0\x6a\xd0\x62\x5a\x7b\x2c\xb5\xaa\xe7\xb1\xa1\xad\x39\x3a\x22\x89\x3a\xf7\xb9\x00\x61\x0b\xe1\x28\x2e\xae\x75\xd1\x17\x93\x9b\x58\xe4\xa4\x5d\x3b\x17\xc7\x3f\x27\x05\x6d\x24\xa1\xf5\x5c\x31\xb2\x1d\x02\xcf\x90\x55\x23\xc9\x2d\x23\x20\x8c\xcc\xa6\xbe\x6f\x2e\x03\x4f\xb4\x77\xa6\x68\x04\xcc\xe9\xa7\x8e\x9c\xd8\x0d\xad\x7a\xa3\xeb\x44\x93\x6c\x8d\x62\xe6\xbe\xb9\x0a\x1d\xca\x11\xd8\x72\x25\xbb\xe1\x1a\x6f\x32\x00\xe8\x82\x7c\xc8\x4a\x1a\x43\x0b\x56\xf2\x52\xa8\x7f\xaf\x56\xd2\xad\x85\xb7\x6a\x6f\x68\x75\x95\x27\x0b\xb6\xe9\x64\x54\x1d\x61\x59\xb0\x8d\x17\x62\xb1\x6e\xfe\x4c\xf5\xce\x9c\x07\xad\x25\x4a\x2b\xb5\x1e\x5c\xac\x69\xc1\x67\x0a\x08\x1c\x00\x64\x44\x8e\x01\xa2\xd1\x02\x42\xe9\xba\x73\x62\xda\xd1\xe8\x38\x74\xc1\x36\x69\xb8\x3f\xbc\xb9\x79\x6a\xa6\x3e\x23\xdb\x2a\xeb\xce\xe1\xb4\x67\xd1\xdf\x10\x1e\x78\x98\xf7\x55\x9e\x7c\xca\x5e\xb3\xae\xc5\x36\xec\x93\x13\xe4\x56\xd4\x44\xae\xf2\x44\xeb\x67\xd7\x37\xef\x9c\x77\xce\x8e\x76\x72\x42\x06\xf7\x4d\xcb\x71\x18\xf3\x1b\xc2\x48\x53\x68\x9f\x37\x4c\xf3\x66\x75\x8d\x9a\xaa\x76\x34\x3e\x6e\x1f\xb7\xd8\x02\xf9\x32\x77\x7c\x99\x1b\x97\xa2\xaa\x56\xbb\x37\x1f\x63\x0a\x82\x11\xc1\x50\x1e\xb3\x80\x99\xc3\x39\xf6\x87\xa5\xd7\x79\x26\xe3\x4b\x59\xd2\x84\xa7\xe4\x98\x8c\xc8\x1d\x6d\x88\x28\x8d\x7e\x00\xa0\x90\x12\x68\xe9\x81\x3e\x39\x56\xa6\x91\x1d\x1e\x8a\xc1\x5f\x6e\xc7\x3e\x39\x21\x3f\x2c\x6f\xd9\x6c\xc6\x66\x38\x9c\x2e\xb7\xc8\xb6\x14\x3a\xac\x0f\x3a\xbe\x7c\x49\xa8\x98\x91\x97\xde\xa9\x43\x68\xcd\x08\x2f\x0a\x36\xa7\x85\xe9\x02\x7b\x05\xb0\x02\xc0\x78\x2e\x9b\x4a\x9e\x93\x85\xaa\x54\x8d\xf4\x98\xdf\x90\x85\x19\xf6\xe9\x09\x3f\xdb\xb8\x87\x43\xa4\x9f\x7c\x7a\x78\x42\x45\x29\x36\xcb\x72\xd5\x68\x82\xda\x0d\xa5\x11\x71\x7b\x4a\x83\xdc\x9a\x0f\x48\x30\xc4\xc9\xea\xdf\x58\xb7\x25\xac\x68\x3c\x34\x74\xd3\x08\xa4\x69\x1c\x2e\x0f\xcf\xc9\x87\x8c\xcc\x56\xa8\xf3\x37\x4c\x5e\xab\xde\x37\xdf\x40\xd1\x5e\xae\x98\xad\xaa\x82\x4f\xa9\x64\x1e\x7f\x80\xdd\x6b\x06\x81\x3f\x0e\xac\x75\x51\x03\xa7\x62\xed\x7d\x93\x87\x19\x10\x70\x36\x23\xf3\x8f\xd2\xf1\x5b\xf6\xd1\xe0\x7e\xdf\xe4\x68\xb3\x81\x19\x92\xf9\x23\xd9\x2a\x70\x66\x77\x57\x59\xc7\x75\x06\x89\x38\x71\xb5\xdc\x54\x6e\x33\x23\xed\xd2\x56\x1b\x3a\x07\x47\xf8\xaf\x74\x6e\xab\x7c\xff\xfb\x7d\x93\x43\x31\x4e\xfc\x20\x41\x62\x3d\xdb\xda\x1d\x6d\x00\xe2\xd8\x46\x56\xfd\x3f\x56\x97\x9e\x61\xe9\x8c\xa4\x1e\x95\xd6\xd9\x81\xbe\xaa\x19\xa8\x3a\x68\xb4\x7c\x50\xf4\x85\xa4\x1f\xeb\xd0\xf4\x6d\x19\xef\x10\xf1\x4c\x07\x73\x88\xb8\x00\x89\x75\x75\x46\x86\x50\x64\x8f\x56\xb2\x36\x4b\xea\x8c\x9d\x61\x14\xf3\xdf\x0f\xcb\x9f\x93\x0f\x67\xc6\x72\xba\x2a\x76\x22\xb4\xcf\x32\xeb\x27\x9d\xa7\xc6\x77\x58\x6c\xb1\xad\x7b\x29\x64\x92\x83\xbd\x96\x91\x5b\x2e\x1b\xd0\xc9\xbf\xfa\xb3\xd3\xec\xec\x12\x2a\xe2\x47\x86\x6e\x25\x21\xe3\x20\x5c\xa1\x74\xd7\x4a\x5c\x0a\xf9\xb5\x9a\xf6\xcb\x44\x49\xbe\xaf\xd3\xa4\x92\x75\x4a\x2e\x08\x64\x51\xa9\xf1\x53\xd7\x70\xf2\x95\x6b\x39\xf9\xca\x6f\x3a\xf9\x2a\x6e\x9b\xa9\x7f\xbe\x3c\x73\x1d\xbe\x3c\xf3\x3b\x7c\x79\x16\x77\xf8\xea\xcf\xae\xed\x57\x7f\xf6\xdb\x7e\xf5\xe7\xa0\xed\x7b\xee\x50\x5e\x05\x38\xaf\x5a\x48\xbf\xe7\x1e\xd6\xab\x10\xed\x55\x1b\xef\xf7\xa0\xb7\xbf\x07\xfc\xf0\x6f\x85\xb1\x47\xdd\xdb\x9b\xc3\xaa\x3d\x89\xf7\xdc\x9b\xc5\x2a\x9c\xc6\x2a\x98\x47\xec\x0a\x80\xbd\x57\xc9\x5a\x1d\xbc\x9e\xad\x6e\x0d\x79\xbb\x6c\x69\x68\xbe\x2b\x5d\xcc\xb3\xde\x73\x81\x19\x94\xb4\x9e\x2b\xad\x01\x60\xa7\xc4\xe4\x16\xd8\x92\x5d\x86\xbd\x82\xd8\xa1\x63\x9f\x93\x29\x2d\x0a\xa5\x58\x9b\x61\xc1\xc5\x05\x16\x3e\x7c\x73\x06\xfe\x70\x20\x4d\xb4\xd3\xf1\x65\xae\x79\x35\x71\xa1\x80\x56\xec\x0b\x92\xdb\xf2\xb5\x16\xe9\x76\x7a\x30\x23\x79\xc7\x9b\xc0\xeb\x43\xeb\xf9\x6a\xc9\x04\xcc\xca\x77\xea\xf9\xa7\xb7\x9a\x06\x90\xc2\x69\x47\x30\xf1\x8c\x28\x74\xc6\x6f\x57\xcb\x4b\x81\xd1\xd4\x28\x98\x0a\x9d\x20\x5e\x48\xeb\x39\x28\x3b\xea\x88\x53\x7d\x2e\x85\xb2\x01\xdd\xbc\x70\x00\x9d\x41\x66\x45\xa9\xee\xe5\x61\x79\xcd\x6f\x40\x84\x62\x98\x52\x2f\x08\xfa\x49\x14\x68\x01\x4b\x96\xba\xcc\x26\x83\xe0\xd5\x4a\xfa\xd9\x4d\xa7\xe7\x18\x33\x76\x46\x37\x96\x4f\xfc\x72\x1f\xfa\xf5\xe9\xcd\xb8\x44\xdb\x15\x7c\x6e\x4e\xcc\xf9\x89\x31\xd1\x09\x0a\xf2\x54\x4b\xdb\x00\x11\x17\x78\xce\x48\xed\xc7\x9e\xbd\xe9\xe8\x30\xab\x4e\x67\x79\xc7\xa4\xf6\x03\x66\xa4\xb6\x98\xf8\xd9\x39\x3e\xca\x3a\x4e\x9a\x0e\xe3\xed\xd1\x72\x94\xe5\x91\xbf\x8d\xce\x13\xc5\x2c\xde\xf6\x50\x0c\x39\x5b\xb2\xe5\xb2\x5c\xb3\xc4\x05\x48\xad\x53\x34\x04\xd8\x13\x23\x9d\x35\x32\xb5\xe7\x2d\x64\x54\xb6\xdb\x34\xf5\xd4\xb6\x99\x33\xe9\xbb\x32\x8a\x92\xce\xde\x4d\x69\x41\xeb\xa4\x8a\x06\xcc\x88\x30\x61\xec\xd4\x7c\xd8\x99\x85\x5b\x85\x83\xd8\xe9\x07\x67\x87\x32\xe4\xbd\x33\x39\x23\x0d\xff\x9d\x69\xd9\x93\x92\x64\x7a\xd7\x35\xed\xa9\xdd\x9b\xc6\x0f\xd0\x15\x97\x4e\xd3\xe1\xde\xa3\x11\x7d\x23\xaf\xef\xa8\xd0\xdc\xa3\x4f\x3e\x35\xc2\x58\xfb\x30\x14\x46\xfe\xe9\xe7\xa3\xbf\xa4\x95\x67\xb9\x25\xcb\x2e\x6c\x0f\xc2\x21\xd4\x01\x3b\x46\x5b\xb0\xcd\x8f\x65\xed\xf1\x85\xb2\x51\xe3\xd1\x12\x5f\xe0\x78\x31\xb9\x85\x91\x51\x71\x34\x9c\x6d\xd0\xd7\xbc\x58\x6b\x52\xc0\x52\x29\xb1\xda\xca\x72\x5e\xac\xc9\x85\x6a\xe7\xaf\x29\x9c\x0b\x0b\xdf\x1d\x3f\xfe\x3b\xdb\x38\xaf\x1f\x22\x3d\xca\xc8\x62\xed\x7b\xd2\x35\x45\x16\xeb\x8c\x2c\x3c\x72\x56\x74\x3a\x65\x4d\xe3\xcd\x71\xd9\x3d\xcd\xb6\xde\xf6\x21\x43\x33\xc6\x50\x09\xfa\xa5\xc3\x01\x13\xb2\xde\x74\xcf\x7d\x89\x7a\xda\x02\x09\x80\x0d\x3b\xb3\xbb\x3b\x1d\x86\xcf\x56\xb6\x60\x00\x9d\x18\xe7\xa9\x58\x3f\x83\x7a\x25\x8d\xb7\x34\xed\x66\xb4\x8a\x36\x0d\x9f\x8b\x16\x65\x32\xb2\xa6\x45\x17\xcf\x01\x69\xbb\x08\x72\xdf\xfc\x46\x8b\x6e\x82\xac\x69\x91\x46\xab\xcb\x74\x5c\x42\xdb\x8c\x40\xa8\x8e\x08\x04\x44\x39\xd9\x47\x0b\x19\x3d\x1c\x32\xd4\x2a\x95\xe4\x77\xa1\x1e\x6c\xae\xc8\x00\x7f\x98\x4c\xc1\x91\xa4\x40\x40\x58\xf5\x37\x8a\xe4\xf6\x17\x70\x87\xcd\x84\xed\x74\x76\x08\xf2\x5b\x50\xb6\x1e\xe9\xa1\x3a\x93\x42\x96\x18\x1f\x5b\xe8\x55\x0a\x28\x3f\x63\x05\x93\xbe\x3c\x8e\xf7\x78\x37\x8b\xee\xe0\xc9\xce\xf1\xbf\xc7\x61\x16\x2e\xe7\x64\x49\xab\x4b\xc5\xdd\x2e\x57\x40\x12\x42\x08\xba\xba\x97\x90\x03\x69\x37\xfb\x70\xb0\x60\x9b\x26\x28\xe0\x98\xd3\x28\xfd\xb9\x70\xc9\x6a\xb8\xe2\xd2\x3f\x9b\x14\x53\x16\x3c\xb9\x95\x40\x41\x4b\xc0\x1e\x69\xfc\xd4\x51\xd7\x35\xa3\x8e\x60\x83\xc2\xb1\xf3\x40\x5a\x42\x54\x60\x1b\xb2\xbc\x42\x76\xc1\x36\x09\x97\x88\x52\xd7\xb6\x57\x6d\xf0\x20\xd0\xd8\xb4\xd0\xe4\xe0\xbb\x84\x75\x50\x8d\xc7\x0a\x07\x13\xe8\x53\xdf\xf9\x01\x87\x44\xdf\x96\x06\x00\x98\xdc\xb8\x70\xde\x0c\x9d\x3e\xd8\xda\xe3\xd0\xda\xc8\xc7\xbe\x7d\xae\x1a\x09\xf6\x20\xbd\x59\x3f\x63\x9a\x38\xa3\xe3\x63\x1f\x62\xc1\x44\xc7\xb1\xc4\x45\x74\x83\xe6\xf0\x95\xb2\x71\x54\x17\xc1\x5d\xcb\xef\x79\x0d\x22\x84\x68\x75\xb5\xc3\x7c\x5f\xd3\x5a\xa9\x31\xb8\xc3\xd7\x9e\x8e\xc7\x73\x5b\xee\x1c\xc8\x63\x67\x48\x0b\x5e\x8c\x52\x5f\x14\xef\xf0\x00\xb8\x0e\x19\x59\x8f\x21\xca\x8a\x1a\xbe\x1a\x5d\xc9\x4a\x7f\x8b\x18\x8f\xb1\x51\xfe\x9d\xfb\xcb\x1a\xfd\xc6\x5d\xdc\x18\xc5\xd7\x1f\x4c\x89\x1e\xc4\x5c\x1f\x9e\x14\xd5\xd0\xd4\x74\x40\xd9\xf3\x27\x4c\x02\x1c\x65\x24\x68\xac\x4b\x5b\xad\x0b\x20\x6f\xdc\x5a\x97\xb6\x5a\x4f\xd5\xa9\xc9\xe5\x26\x6e\x6f\xcb\xa1\xc7\x1a\x88\xbe\x9f\xa3\x01\x72\x7c\x36\x29\x4d\xca\x18\x8c\x3a\xb1\x55\x1b\x61\x78\x2c\x74\x9f\x07\x61\x1b\x55\x09\x6b\x6a\xbe\xa3\xd2\x8d\x78\x21\xe2\x50\x70\x5b\x33\xba\xb0\xba\xb6\x41\x3b\x24\x39\xe8\xe2\xde\x51\xb2\x56\x07\x08\xc2\xc8\xbc\x21\xa1\x99\x81\xb7\x1d\xf6\x41\x0b\xa8\x06\xc7\x5e\x44\x49\xb3\x48\x91\x17\xa8\x0d\x2d\xf6\xfa\x0c\x77\x62\x19\xb8\x82\x32\xf2\x5d\x59\x16\x19\xc4\xc4\x32\x1d\xaf\xb0\x3e\x57\x13\xba\x00\x01\xe3\x0f\xdd\x3a\xc0\xc7\x4a\x37\x0f\x5c\x43\x68\x13\x1f\xc1\x6e\xf9\xa1\xae\xcb\xfa\xd1\x7a\x36\x5f\x97\x62\xcd\x6a\xc5\x96\x8b\x6d\xb7\x81\x6f\xad\xc6\x76\xee\x00\x2d\x7c\x6b\x06\x77\xda\x51\xa2\xfe\xfd\xe5\xea\xc9\x7a\x03\xd2\x9d\xee\x80\xd7\x65\xb5\x71\x29\x1f\xda\xf4\xd7\x82\x69\x06\x9b\x72\xd6\xc8\xf1\x02\xba\x81\x94\x98\x2d\x94\x62\x8a\xa9\x10\x47\x47\xfa\x6b\x1c\xd7\xef\x99\x6b\xa5\x76\xc8\xcc\xcc\x14\x81\xd9\xbc\x8a\x47\x9d\xdc\xb1\x5c\x35\xf2\x3b\xf6\x17\xd0\xb5\xe8\x6d\xa1\x6c\x15\xd5\xda\x55\xb9\x3c\xb3\xe1\x70\xd0\x00\x8e\x4d\x3d\xf5\x71\x6c\x42\x1c\x9b\x67\xe3\xd8\x18\x1c\x15\xe0\x8e\x51\xd5\xb1\xdd\xbc\x59\x35\xf2\x0d\x95\xd3\xbb\xa4\x35\xc5\x46\x7a\xdb\x0c\xb3\x54\xfc\x3d\x01\xb3\xd1\x8a\x9a\x6a\x1b\x88\xe1\x0e\x9a\xfc\xe6\xb3\xb9\x89\x22\x85\x83\xa4\xc8\xef\xd8\x58\x8b\x5b\x2d\xd0\x35\x7d\x42\x59\x1f\x0d\x62\xcf\x84\x68\x90\x08\x73\x7f\xb7\x86\x51\xb8\x76\x70\x58\xed\x3a\x9d\xd4\x80\x58\x99\x9d\xa7\xaf\x3f\xb9\xf3\x11\x52\x64\x7f\x61\x53\xc6\xd7\xac\x4e\xca\xca\x66\xfd\xd9\x93\x8c\x63\x62\x49\xf2\x21\x23\x4e\x6b\xca\x63\x6d\x21\x35\x27\x1c\xa4\x14\x99\x4c\x4d\x9e\x6b\xa1\xe7\x24\xa4\x1f\x49\x19\x0c\xa4\xc4\x63\x3d\xb8\xf2\xd0\x3a\xdc\xf1\x30\xd4\xd7\x22\x39\xe4\x92\x3c\x3d\x11\x4e\xbe\xd5\x29\x68\x72\xac\x53\x7d\xb5\x58\x8d\x1d\x61\x26\xa5\x0b\x93\x26\x5c\x94\x53\x27\x0d\x73\xa5\x0d\x8d\x8c\xa7\x07\x42\x45\x47\x0e\xe6\x35\xbf\xc1\x81\x5f\x48\x39\x36\x29\x79\x4b\xf8\x94\x8e\x83\xcc\xcb\xce\xb1\x47\xe4\x98\x94\x15\x04\xce\xca\x9c\xac\x84\xcd\xa6\x44\xf0\x76\x58\x49\x2e\x88\x04\xae\xd2\x03\xe8\xcb\x73\x40\x4f\xa8\x8a\xc7\xc6\xf4\xd5\xa1\x8b\x08\x99\x4b\x86\x48\x72\x97\xac\x8c\xe8\xaf\xa4\x89\xff\x3d\x3d\x81\x7f\x21\xe1\xa9\xa2\x20\x7c\x5c\xc9\x31\xa6\x6e\x7f\x36\x0a\xae\x2c\x01\x93\xd4\x91\x10\x51\xfb\xe7\x52\x11\xc7\x70\x84\x5c\x86\x94\xdc\x79\xfb\x36\xd0\xbe\xd2\x7d\x09\x71\xea\xc8\x98\xae\x6b\xa4\x79\xb0\xc7\x5d\x82\x20\x82\x42\xed\x4d\xb5\x8d\x35\x3c\xb5\xa9\x55\x05\x82\xcb\x05\xb9\x88\xcf\x1a\x55\xeb\x12\xed\xfc\x28\x04\xee\x7f\xbb\x99\xd7\x6a\xc3\xda\xfd\xe5\x74\x51\xd5\x5e\x67\x74\x44\xbe\x56\xd8\x9f\x70\xdb\x17\x52\x39\xf6\x08\x68\x28\x1b\xdb\x01\x46\x60\xb2\x98\xe3\x04\x06\x39\x3a\x32\x47\x21\x9e\x84\x78\x61\xb9\x23\xff\x23\x02\x75\x4e\xa6\x54\x88\x52\x9a\x2c\x2a\x98\x09\x29\x6f\x25\x05\x2f\x44\x5e\x97\x4b\x7f\xd1\x31\xfe\x58\xd6\xde\xea\x6f\xbd\xc9\xc0\xe0\x78\x99\xd5\x21\xb0\xd6\xee\x5e\x2c\x47\xed\x79\xe4\xcf\x65\xad\x85\x6a\xef\xea\x21\x6a\x1e\x05\x63\x31\xd5\x5e\x58\xc7\x15\xc1\x8d\x10\x4f\xd7\xd8\x01\xce\x75\xee\xba\x4d\xc2\x55\xa7\x1f\xce\x2e\x3d\x53\x56\x69\x11\x1e\x3c\x90\xfd\x9f\xd7\x69\x1a\x1f\x1c\x6f\x31\x83\xbe\x95\xba\x3e\xfa\xf7\x1f\x2f\xff\xef\x9b\x1f\xfe\x7d\x14\xf8\x0a\x7d\xd2\xb7\x4f\x9a\x30\xc4\xd1\x5e\xc9\x8b\x6e\x56\xea\x97\x4d\xab\x06\x32\x1a\xd5\xc8\x3f\xd3\x5a\x72\x5a\x28\xbd\xd2\x44\x3c\x3e\x64\xe4\x03\x9c\x63\xf6\x4a\xa1\x77\x0a\x42\xd2\xa6\x92\x8b\xda\x84\xfa\xf6\x5b\x87\xc8\xbb\x3b\x9e\x43\x12\xf3\x67\xde\xf9\x9f\x39\x8a\xd2\xeb\x95\xce\x85\x59\x6a\x5a\x55\x85\x52\x99\x14\x12\x1e\xe0\x14\xfc\xf9\xa1\x32\xbc\x86\x10\x79\x92\xf6\x6b\xc4\xa1\x7b\x3f\x94\x02\x4f\x9d\xee\x7e\x3f\xe3\x07\x81\x34\xde\xf5\x05\x13\xfe\x8c\x83\x9f\x3f\xcb\x5a\xdb\x03\xbe\xad\x80\x36\x46\xd6\x8a\x2b\xe3\x23\x1c\xed\x50\x31\xbe\x79\x32\xe8\x44\xe6\x75\xb9\xac\x68\x8d\xea\xef\x5e\x74\xf4\xf0\x68\x36\xea\x3b\x97\xe1\x18\x9d\xf1\x6e\xe3\x51\x1c\xfb\x83\xb5\x4c\xac\x38\x8f\x5b\x8e\xdf\xae\x96\x90\x31\xe0\x27\x71\xa3\x6e\x32\xc6\x72\x9e\x62\x22\x48\x30\x09\x13\xe0\xf1\xd1\xc2\xf3\x32\x48\xbe\x04\x62\x75\x10\x04\xf9\x3e\x31\x8a\xe0\x52\x17\xa4\x26\x1a\xf9\x07\xb5\x3b\xf0\xdc\x58\x1c\xe4\xd8\x0c\x87\xfb\xc2\xbf\x63\x6c\xef\xae\xbc\x31\x9a\xc5\xb0\x5b\x23\x0c\xd4\xc1\x58\x5e\xbc\xf1\x74\x16\x48\xe1\x2b\x73\x8c\x8a\xe9\x73\xa4\xf2\x6e\x19\x83\xe6\x52\x99\xb4\x26\xa7\x83\xa1\x0e\x93\x0e\x07\x4b\xc8\x74\x22\x17\x04\x1a\x59\x9d\x2c\x07\xd5\xdf\x71\xfd\x10\x9e\x8e\x40\x18\x46\x33\xa9\x8c\x66\x92\xcb\x3d\x71\xd6\xa5\x56\x7f\x83\x6b\xf8\x18\xae\x3c\xcd\xc8\xe4\x18\x92\xc6\xe4\x98\x0b\x3c\x5d\xb8\x70\x77\x2f\xb8\xc0\x2b\x17\x8a\x95\x3e\xc0\x26\xf7\xd2\xc4\xb0\x0b\x10\x29\xee\x43\x6b\x74\x1c\x45\x77\xed\xed\xa0\x7a\x48\xb8\x1b\x96\x3a\xf8\x35\x3a\xcc\x2d\xfc\xd2\x06\x43\x15\x1c\x3b\x42\xb9\x92\xd0\x56\x2f\x31\xf4\x09\x53\x52\x33\xd5\xfb\xb2\xf9\x4d\x27\x41\x82\xba\xb3\xd4\x59\x6c\x64\x29\x87\xf6\xea\xc2\x1e\x75\xae\xf5\x32\x4e\xf4\x2e\xce\x5e\x1d\x0f\x4f\x88\xcf\x28\x97\xf5\xb1\xe1\xe2\xcc\xa7\x37\x8e\xfd\x23\x5d\x6f\xa7\x9c\xbe\x9e\x9c\xdf\x68\x59\xbd\x84\x84\x5a\x72\xa1\xa5\xf5\x52\xda\xa7\x85\xda\x72\x5a\x84\x61\x58\x75\x16\x2e\x91\x08\xe4\x82\x70\x97\x65\xe4\x24\x81\x3d\xa0\xcd\x41\x17\x3d\x43\xd4\x61\xe5\xd9\xeb\x1a\x71\x85\xe7\x20\xeb\x3d\xa1\x8c\x1b\xa7\xa5\xd3\x61\x86\x85\x53\xe9\x7a\x03\x39\x00\x20\x0a\xe5\x60\x16\x73\xa1\x43\x7b\x41\xf8\x13\x74\xa9\xb7\xe0\x65\x55\x1a\xac\x29\x0f\x92\xcb\xb1\x9f\x77\x7e\xa3\x54\xd5\xe7\x42\x30\x4d\xa8\xf0\xd2\x4b\x32\x97\x2b\x13\xb9\xcd\x7c\x55\xd1\x62\x73\xc7\xe7\x77\xe0\xbe\x75\xbe\xcf\xf2\x23\xba\x31\xf5\x63\x25\xe5\xb2\x2a\xd8\x83\x02\xac\x3f\x4e\xce\xbe\x3e\x14\x7a\xcd\x30\x0f\xde\x95\xf0\x25\xdc\xfb\xb6\xe0\xdd\x25\x7b\x43\xb2\x8b\x8b\x1e\xa2\xc4\xfe\xe9\x1e\x0c\x5c\x2b\x6c\x63\x9d\x9c\xe8\xe5\x6c\x87\xce\x3a\x31\xf7\x9c\xcb\xa6\x4b\xec\x5f\x5e\x77\x3a\x97\xa3\xd6\xd6\xbf\xbc\xee\x74\x2e\x47\xad\x3d\xff\xf2\xba\xc7\xb9\x6c\x26\x6d\xa2\x76\xf6\x68\xdd\xc1\xe2\xbe\xff\xd0\x3f\x83\x7b\x77\x83\xbe\x01\x38\xa5\x45\xf1\xbf\x59\x51\xb1\x9a\xb4\xf9\x58\x55\xe2\x0b\x37\xda\x04\x4c\xc7\x28\xad\xc6\xe3\x71\x70\x33\xc3\x13\x50\xad\x4d\xae\x80\xf8\xea\x39\x17\x2e\x2f\x49\x7f\x30\xbe\x9e\x04\x2c\x6e\xbc\x99\x8f\x17\x50\x72\x41\x48\x24\x71\x8c\xcc\xf3\x03\x0f\xe9\x3e\x6b\xed\x43\x46\x24\x68\xe7\x9f\xa8\x9c\x1b\x8d\xdb\x57\xce\x7b\xb5\xf3\xbd\xea\x39\xa8\x49\xce\xcb\x62\x9d\x0c\x38\xe1\x96\xc1\xde\x65\xb8\xf9\x46\x80\x8b\xaf\x5b\x8b\x53\x81\x71\xf7\x63\x3a\x8d\x65\x25\xcd\x5c\x4e\x97\x6a\xaa\x16\x4e\xf2\x52\x18\x93\x86\xbb\xf4\xa4\xb2\x82\x7c\x6b\xd5\x07\x1d\x81\xc3\x81\x40\xed\x43\xa7\x50\x69\x5b\xc5\x39\x66\x51\x89\xf4\x4f\xdc\x6e\x4f\x8c\x05\x69\x6e\x8b\x05\xd7\x36\x0c\x3a\xc0\xfd\x78\x7d\x0b\x6e\x8a\xbc\x22\x62\x1f\x38\x48\x4e\x93\x65\x49\x72\xf6\x91\x70\x51\xad\xa4\x3b\xea\xba\x40\x7e\xfb\x0c\x90\x4b\x2a\x36\x7d\x30\xbd\x85\x05\x65\xb6\x4d\x02\xf1\xc5\x17\xcf\x9c\xd1\xc1\x93\x89\x49\x7e\x74\x74\xd8\xfc\x0e\x9c\x9a\xd5\xcb\x1e\x5a\x97\x61\x78\x4e\x1e\x02\xc5\x1d\x8d\xe6\x7d\xde\xb7\x55\xa3\x2c\xfd\xdf\x59\x5d\x6a\x73\xdd\x0c\x1a\x8d\xe9\x9b\x2d\xc2\xd9\x2a\x6a\x54\x99\x11\xa9\xf5\x50\x78\x16\x4a\x9b\x96\x99\xa2\xbd\x48\x78\xfa\x0d\x79\xf1\x20\xc7\x2e\x08\xf1\x6b\x99\xa8\xf6\xfb\x3d\x83\x88\x9b\x2a\x78\x90\x56\x83\x83\x1a\xda\xb8\xe4\x7b\x05\xcb\xbf\xce\x32\xb0\xd7\xe4\x5e\x98\xfd\x70\x74\xd4\xc5\x07\x27\x27\xa4\xaa\x59\x45\x6b\x7d\x29\x49\x3f\xd7\xb8\xa4\x5c\xa8\x71\xc1\x67\xd5\x18\xf7\xa7\x59\xc5\x2f\x88\xf0\xa3\xa7\xde\x05\x4e\x35\x59\x91\x42\x22\xcb\x52\xa1\x61\x6e\x29\xe8\x0a\x9b\x72\xd2\x22\xe7\xd2\x33\xfd\x1e\x34\x15\xc5\x31\xb8\x58\x91\xbe\xaa\xec\x41\x53\xb5\x83\x98\x90\xd5\xa5\x8f\xeb\x76\xca\x28\xb8\xe1\x56\x0d\xdb\x4b\xc7\xe0\x72\x02\xd4\x72\xa1\x57\xc3\x25\x0b\x62\xa4\xd6\xaa\xd8\xea\x48\x7d\x30\xec\x5f\xd6\x7c\x8e\xd7\xb9\xb8\x30\x16\x48\x98\xf3\x29\x8e\x27\x26\x88\x98\x70\x71\x7d\x2e\x6e\x32\x82\xbd\x40\x9c\x8b\x6b\x01\x97\x0c\xd4\x18\x28\x01\x05\x5a\x48\x9a\xf8\xb0\xa8\xaa\xe8\x85\x27\xf8\xf6\x09\xd8\x8f\x75\x29\xe6\x96\xab\xf1\xfe\x9e\x36\x0c\x85\xb6\x85\xa4\xcd\xae\x1c\x0e\x21\x99\x14\xb5\xdd\xdd\x59\x99\xd2\x4b\x5e\xd5\xf9\x98\x81\x31\xa6\xb7\xa5\x05\x17\xe4\x61\xae\xc4\xc7\x9a\x56\x7f\x6b\x8c\x11\x83\x1b\x05\x20\x8c\x31\x33\xea\xd7\xb2\x6b\x3a\x23\xbb\xa9\x3c\xc7\x8d\xe0\x45\xea\xfc\x92\x46\xfb\xb0\x99\xa5\x4e\xc3\xe8\xb8\x77\x99\x2b\x8e\xb5\x76\x08\x62\x0a\xa1\x40\x54\x83\x85\xbe\x11\xe7\x32\x5f\xfd\xe4\x31\x97\xf7\xaa\x4b\xf5\x42\x3f\x7a\xf9\x0c\x63\x45\xd7\xd3\x34\x23\xd1\x84\x4d\xb1\x46\x14\x6e\x37\x6c\x63\xcf\x4e\x3b\x6b\x58\x21\xd4\x91\x2d\xac\xda\x3e\xea\x64\xd6\x38\x13\x18\xc7\xe2\xdd\x28\x70\x87\x82\x7b\x24\x2e\x48\x13\xd6\xc9\xb1\x32\x70\x2e\x59\xe5\xea\x35\xad\x12\x1b\xe3\x5d\xa0\xfb\xd0\x04\x4f\x6d\x36\xc6\x63\x8f\xd3\x08\x8d\x8c\x9f\x98\xb0\xae\x22\x74\x81\x59\x85\xdd\xb6\xb3\xfa\x47\xac\xae\xea\xf0\x1f\xb8\x39\xf6\x39\xfa\x5f\xd3\x4a\xc7\xc6\xb5\xee\x79\xaf\x69\xf1\xb3\xac\xa3\x77\xf3\x62\x45\xd4\x6b\xa9\x54\x64\xa4\x42\x48\x4e\x9b\x01\x1f\x26\xa5\x74\xd8\x96\xaa\x29\x24\xc6\xb8\xd1\x03\xf3\x51\x63\x60\x6b\xad\xdd\x10\x28\xd6\x6b\xef\x59\xdd\x78\x3b\x7d\x2e\x5c\xac\x81\x50\xea\xe4\xbc\x3e\x04\x1c\x43\xe8\x6c\x10\xab\x56\xfb\x29\x39\x86\x35\xfc\x84\x9c\xe0\x01\x3e\x6d\x00\xc7\x4a\xee\xda\x64\x12\xf5\x5a\xb9\x8f\x5e\x22\xb7\xbd\x85\x8d\x01\x34\xf4\x52\xf9\x8b\xdb\x6d\xfa\xa5\xbd\xe9\x48\xce\x4c\xd2\x57\xae\x03\x67\xb0\x92\x16\x51\x26\xcd\x7a\x7c\xd9\xbc\xe5\xee\xfd\xda\x2e\xbc\xba\xa6\x6a\xdc\x8b\xfa\xe6\xe7\x8e\xb0\x71\xae\x3b\xb7\x9d\xd2\xfe\xa5\x8d\xbf\xcc\x66\x35\x36\x7e\xd2\xbe\x3b\x29\xc7\xde\xbd\xc0\x34\xbe\xba\xae\xab\x5b\x3e\x96\x90\xbb\x4c\x23\x48\x2f\x6d\xf9\x5e\x0e\xcb\x55\xc1\x1d\xa9\x98\xc5\xa5\xab\xb4\x99\x49\xbb\x80\xdb\x2f\x41\x18\x4e\x82\x5c\x0c\xe7\x81\xd9\x3b\x20\x00\x54\x96\xaf\xee\xaf\xc3\x7d\x86\xf0\xee\x3e\x5b\x3f\xed\x79\xde\x0a\x36\xeb\x98\xbd\xb9\xe6\xda\xe9\xa4\x85\x91\x7b\x7d\xb4\xbe\xfb\xaf\xe5\x68\x30\xef\xa0\xec\xf5\xec\xc1\x10\x3a\xd8\x9f\x9b\x8b\x7d\xf6\x8e\x16\x94\x80\x95\x37\x0c\xf9\x07\xb2\x7c\xde\x49\x3e\x5d\x6c\xfc\x5c\x9f\x27\xc3\x42\x5d\x49\x3f\xa8\x5f\x22\x48\x70\x14\xb7\x42\xde\xca\x08\x74\xd5\xfa\x69\x2a\x73\x67\x76\xe0\x73\x25\x5c\x7f\xfd\xe5\x6a\x38\xf0\x4d\x17\xaf\xde\xa0\xe6\x9e\xb0\x53\x82\x8b\x82\xae\xe1\xcf\x14\x47\x82\x17\xac\xbe\x81\xfa\x17\x30\xda\xd1\x11\xe1\xce\x10\xe7\xb9\x22\x31\x76\x9e\x33\xf9\x37\xf5\x39\x91\x74\x9e\x7e\xa3\xcb\x5f\x78\x28\x96\xb5\x49\x6b\x03\x0b\x19\xd9\xf1\x34\xb5\xae\xa4\x71\x8f\xf8\x1c\x0c\x06\x65\xb8\xbb\x63\x31\x3a\x88\xe5\x02\x48\x9a\xee\xf8\xab\x97\xb5\x07\x27\x01\xf6\xee\x88\x7a\xee\x7c\xc6\x23\xf2\x2a\xbb\x57\x81\xd8\x28\x23\x25\xe0\x07\x04\x08\x2e\x0b\xa6\x29\xd9\x9a\x97\x0f\xfb\x06\x7c\x08\x4e\x98\x47\x52\x82\x56\x0c\xb0\x3a\x52\x86\xd9\x83\x3f\xee\x43\x38\x98\x37\x5a\x4b\xb2\x38\xef\x5a\x87\x7b\xd6\x23\x3c\x2e\x95\x35\x36\xbc\x97\x19\x35\xf3\x34\xbb\x7c\xac\xe8\xbc\x28\x62\xef\xac\x32\xa0\x82\x3b\x6a\x36\x1f\x2c\x7a\x93\xa6\xe5\x0d\xfe\xa4\xd5\x7d\xd6\xd2\xc6\x47\x7f\x46\x1a\xef\x19\x23\x43\xd1\x03\x17\xaf\xf1\xde\x43\x6a\x6b\x15\x19\x79\xb0\x10\xdb\x0b\xd4\xf5\xea\x09\x74\xda\x8d\xa1\xea\xed\xe2\xf0\xfe\x9e\xb4\x17\x5e\x5c\x3c\x5e\x6d\x49\x19\xec\xd2\x93\x13\xd2\x2c\x78\x45\x0a\x46\x67\xaa\x51\x53\x51\x65\x3d\xe1\x83\x5e\xa7\x56\x55\x7e\x85\x99\x55\x74\x0e\x3e\x09\x49\xe7\xa0\x26\x5f\x90\x7f\x23\xff\xa6\x83\x8e\xc7\xc7\x46\x65\xa0\x73\x72\x81\x4d\xce\x75\x9e\x8f\xc4\x8c\x12\x23\x18\x5c\x12\xaa\x46\x60\x4a\x05\x91\x25\x99\x96\x45\x29\xc6\x58\x46\x11\x13\x52\xd6\x84\x92\x7f\xac\x4a\xc9\x08\x6f\x54\xe9\x46\x48\xfa\x80\xb1\x7d\x40\x73\x2f\x96\x2f\x10\xcb\xb0\xe0\x3c\x2e\x18\xb5\xe6\xc1\x73\xc2\x8f\x27\x36\xa9\x4c\x01\x7d\x7a\x8a\x60\x98\x82\xe3\x49\x08\xc5\x4f\xb3\x35\xd1\x42\x5c\x05\x05\xe8\xfa\x9c\xdf\xa4\x21\xa5\x8e\x27\xe7\x37\x3e\x35\x60\xc6\x33\xb3\x72\xb2\x24\x39\x17\x33\xf4\x29\xe8\x59\x4f\xf6\xcf\xda\xce\x29\xf7\x57\xec\x3f\xfe\x43\x17\xeb\xb9\xea\xc7\xc9\x83\x79\x07\xb3\x6e\xcd\xe8\x1f\x98\x8f\x13\xcf\xe9\x78\xd2\x37\x2b\xff\xcd\x87\xfb\x46\x73\xc1\x1a\x4d\xb2\x0f\x1a\x0e\xbc\x2b\xf1\x5e\xc0\xc4\x13\x1c\x21\xf5\xd4\x3f\x33\xf5\x60\xa3\x8c\x46\x1d\x5a\x8f\x3e\xe6\x23\xad\x67\x9f\x22\x6d\x8d\x2b\xa3\xcc\xd8\x37\x7c\x0e\x4f\x3f\x04\x2f\xb4\x94\xe3\x82\x89\x1e\xef\x14\x00\xed\x51\x63\x7c\x7d\x5b\x2b\x89\x91\xaa\x4a\x8e\x48\xb2\x53\x5b\x4d\x23\x75\xd5\x53\x38\x86\x83\x01\xdd\x2d\xb9\x3f\x9b\xe8\xfe\x63\x27\xf3\x1f\x14\xde\xd4\xd9\xe1\xf6\x34\x3c\x50\x78\xd3\x9d\x3e\x96\x50\x7c\x77\x1d\xb0\xdb\x5e\x13\x68\x27\x9a\x28\xc0\x5b\x17\x2c\xba\x2c\xb9\x30\xb3\xa1\x89\xa2\x55\x68\xcc\x77\x33\x1e\x7a\x1c\x77\x31\x9e\xd1\xe1\xcd\xe3\x36\x3b\xd8\xbe\x87\x49\x0d\x17\x46\xcc\x19\x98\x59\x3b\x19\x94\x93\x63\x37\x2b\x13\xb1\x33\x2e\x0a\x64\xdf\x26\x0c\xfe\xfd\x0f\xd7\xfe\x6b\x70\xad\xbd\x8a\xd1\xe0\xeb\x15\x2f\xc1\x18\x54\xca\x47\x20\x5e\xda\x99\x39\x8d\xac\xfb\x38\x16\x8f\xbe\x1d\x2c\xdb\x6f\xc5\x27\xf0\xc0\x04\xf8\x8a\xf5\xe9\x82\x29\xc7\xc1\x12\xdb\x87\xf2\x5a\x0b\x7d\x34\xf5\x1f\x61\xd4\x6f\x2e\x3e\xcf\x34\x07\x3a\xed\xb2\xcd\xad\xe3\xe6\x7b\x2a\x69\x92\x92\xeb\xb3\x1b\xef\x0e\x39\xc2\xc7\xdf\xf7\x02\x26\x1b\x05\xed\x95\x2a\x24\x4a\x49\x9a\x55\x65\xde\xe2\xdd\x90\xbf\xc2\x2f\x7b\xfd\xed\x9d\x7f\x7d\xdd\x1b\x4f\xbb\x54\xa2\x04\xb6\xde\xf3\x10\xf2\xea\xfa\x3d\x89\xbb\xae\xa6\x0d\xc3\xdf\x50\xe9\xe9\x1b\x85\xaa\xef\xa8\x78\xeb\x75\x36\xbf\x44\x72\x50\x67\x79\x57\x97\x1f\xdf\xf2\x42\xaf\x1f\x2c\x88\x85\x14\x26\xe1\xb5\x00\xc5\x5b\x0c\x1e\x84\xef\x72\xae\x1d\x84\x89\xf3\xa9\x3d\x93\x5d\xd4\xea\xec\x62\x17\xf0\xf2\x1a\x47\xf1\x41\xba\x8c\x7f\x41\xaa\xed\x08\xb6\x77\x16\xa3\x63\xa7\xcf\x65\x1c\x9e\x31\xfb\x56\x58\x77\xba\x5d\xe5\x39\xb3\x69\x21\x9d\x20\xc2\xd5\xe9\xbb\x77\xe9\xe7\x4d\x3b\xcc\x9f\x43\xe0\x9f\x98\xd8\x45\x5e\xb3\xf3\x83\x87\x1c\xf6\x91\x19\xbd\xed\x90\x7b\x0a\xbb\x05\x45\xab\x06\xb5\xd3\x97\x79\x1a\xca\xdd\x8e\x04\x81\x68\x1b\x1c\x0a\x69\x12\xaf\xe7\x27\xa0\x10\x1c\xb0\x1e\x42\xcf\x21\xb7\xbb\x41\xd9\x4b\x72\x88\xfd\x99\x2f\x8f\xc3\xc1\xba\xf3\xb6\xd9\x43\xfb\xca\xd7\xe0\x81\x5c\x90\x87\x8e\x38\x17\xe6\xf8\x81\x38\xc2\xa8\xd6\x9e\x7c\xb1\xbe\x5c\xad\xe8\x57\xa8\x42\x31\x87\x8c\x39\xc5\xcb\x65\x7d\xca\x74\x57\xcd\x03\xd4\xf4\xfc\x72\xce\xbe\x9c\xb5\xbe\x24\xfc\xe8\x8a\xc7\x83\xfd\xf1\xaf\xae\xdf\x31\xf1\x2e\x5f\x3e\x1f\x71\x4d\xd8\xf8\x09\x9a\xc3\x10\x7f\x08\xde\x8d\x71\x6c\x07\xb6\x1c\x74\x80\x25\xad\xbc\x27\xb5\x03\x46\xf9\x6e\x23\x59\x93\x3c\x90\xeb\x1b\x7b\x05\xbc\x9b\x5d\x4c\x29\x5e\x9a\x4b\xbd\x5c\xc4\xf0\x6a\xee\x8b\x0b\x7c\x83\xaa\x3f\xfa\x6b\x46\x35\x69\x2d\xf0\x08\x80\xf7\xf8\xa8\x7f\x03\xba\x45\x31\x7f\x60\x7d\x27\x02\x3d\x2e\x36\x03\x52\xa3\x13\x54\x3e\xa2\x6a\xcd\x66\xef\xa2\xcb\xd5\x5e\x06\x12\x06\xd0\x5b\x09\x70\xae\x5b\xeb\x8a\xb5\xd7\xc1\x4f\x82\x6b\xf5\x70\xd7\xac\xbd\x1e\x7e\x22\x5c\xab\x87\x7f\xd5\xda\xeb\x13\x26\xc3\x21\x99\x2e\x88\xeb\xad\xdf\x58\x3d\x84\x6f\x1a\x5c\xc5\x4e\x9e\x78\x4d\xab\x44\xa0\x91\x7f\x38\x3b\xec\x74\x5e\x46\x09\xa2\x3c\x27\x82\xbc\xea\xb3\xb2\x9e\x9e\x88\x20\xdf\xda\xda\x38\xa4\xda\x19\xc4\x40\x5a\x98\xa6\x81\x52\x4b\xb8\xd0\x93\x32\xc9\x05\xec\xe3\x2e\x36\x68\xb1\x80\x69\xdf\x5a\xff\xf6\xda\x47\x4d\xdd\xc2\xb7\x17\x3d\x6a\xea\xad\xb8\xe8\x7c\xb8\xa3\x6b\x11\x0d\x8c\x9e\x75\x54\x9a\xcd\x7f\xc5\x3a\x9e\xfe\x81\x25\x43\x8a\x74\x2d\xd8\x4f\xf6\x61\xf3\xff\x86\x05\x13\x3b\x57\xa8\x3d\xcf\xcf\xb3\x64\x90\xae\xc4\x33\x72\x1f\x79\xd8\x4c\x06\xa8\x7e\x7b\x5e\xfb\x09\xf4\x4b\xe4\x4d\xf4\x3c\x8b\x97\xdf\xc0\xc5\x2c\xd2\xb0\x54\x49\xcb\x2f\x17\x1e\xe5\xe0\x67\xb0\x57\xc0\x7a\x44\x38\x3e\x05\xdf\x98\xec\xc4\x95\xa0\xb3\x59\xcd\x9a\x46\xb1\x15\x71\x1e\x84\xed\x33\xbd\x7e\x53\xf8\x59\x19\xcf\xd7\xa7\xa7\x7a\xe1\x5e\x15\x46\xcf\x08\xc8\xbf\x8e\x27\x16\x3c\x75\xb6\xe5\xf7\x41\x40\x26\x9d\xb4\x89\x73\x56\x71\xec\x3e\x16\xfe\x64\x7b\xfc\x9e\xbc\x22\x1c\x3f\x7c\xbb\xd3\x2e\x8f\x48\x8b\x36\x7a\x87\x73\xe9\xb6\x5c\x89\x99\x4b\x6d\xf4\x0d\xef\xab\x3c\x01\x83\xfc\xfc\xfe\x26\x7d\xa6\x55\x6d\x2e\xb1\x2b\x0e\xd9\x7a\xf7\x33\x3b\xa7\xd1\xf3\x23\x01\x1d\xbc\xd1\x83\xf9\x33\x7e\x36\xa0\x59\xdd\x36\x1a\xb7\x26\x23\x6a\x73\xb4\xf3\x1c\x7a\xb6\xd2\x97\xb0\x97\x32\xb2\xf8\x9f\xed\xf4\x2f\xb8\x9d\x9e\xcd\x9d\x5f\x1e\xc2\x9e\x0b\xf2\x8a\xdc\xe3\x87\x43\xf8\xf4\xcb\x7f\x26\xa3\x66\x64\x71\x08\xaf\xbe\x2e\xca\x46\xdf\x1d\xb4\xa7\xb1\x32\x80\xbd\xd3\xd9\xb7\xd1\xda\x6f\x50\xa8\xfe\xa1\x29\x6f\xf2\xc8\x1a\xa6\x26\xdc\x7b\x8b\x01\xab\x3f\xf1\x1e\xc3\xf4\x8e\x8a\x9a\x4d\xd7\xde\xb5\xe8\xd6\x13\x8a\x19\x11\xb7\xe0\x17\xeb\x7e\x3d\x2e\x41\x04\xd8\x2c\x23\x35\xde\x3a\x30\x3f\x7d\xa5\x36\x55\xb9\xc4\xdf\xc9\xbd\xbe\xf1\xef\x79\x3d\x3e\x76\xfc\xe8\xd0\x5d\xba\xc5\xc4\x62\x71\x8b\x76\x26\xf4\xb5\x97\xe0\xe0\x6b\x16\x5c\x17\x7b\x34\x4f\x9f\x00\x06\xbf\x30\x18\xc9\x27\x17\x76\x4a\x0d\xd4\xa3\x23\x62\x9b\x6a\x57\xed\xa9\xd1\x6e\x2e\x2e\xc8\xc4\x8f\xac\x83\xa1\x98\xb9\x9b\xaf\x03\x45\xa6\x60\x08\x07\x64\xd2\xad\x39\x78\xef\xe3\xa1\xde\xa0\x41\xd8\xa1\xd3\xe0\x2e\x69\x5c\x3f\x69\xff\xf4\xd1\x1d\x15\x0d\xfc\x44\xd4\xae\xd5\x6a\x2f\x92\x5d\x41\xe7\xdf\x7c\xde\xc2\xf4\xd8\xd6\xa1\x2a\xf9\x2f\xb7\x7a\xbd\x97\x75\x6b\x84\x93\xe8\xbf\x0d\xb9\xbe\xa9\x57\x42\xf2\x25\x7b\x07\x05\xf0\x90\x68\xd9\x30\x81\xbf\x72\x02\x3f\x46\xfd\xf7\x0e\xa6\xd6\xc9\xb3\xed\x9f\x24\x30\x80\xbd\xec\xe5\xc6\x4b\xa7\x35\xc3\x7a\x5e\x16\x1c\xf8\x7b\x5e\x27\xcd\x18\x5e\x42\xb2\x9e\x16\x5d\xe3\x39\x15\x60\x7c\xcc\xc3\x0d\xe9\x19\x76\xf9\x85\x4d\xd7\xd8\xfe\xae\x23\xd9\xda\x77\x29\xeb\xbc\xa5\xd6\x13\x06\xe3\xe9\x9d\x79\xdb\x33\xaa\x3a\x35\x19\xf1\xd3\xbb\xce\xa7\xa5\xa0\xab\x0d\x9e\xf7\x21\x3c\xbd\x8b\x50\x7e\xc7\xc4\xec\x50\x94\xbb\x5e\x68\xfb\x27\x4e\xa4\xf7\x15\xad\x66\xdc\xf1\x10\xe6\xde\x89\xc3\x36\x75\x57\xca\xf7\xef\x81\x69\x97\xe0\x39\xb5\xde\x62\x9e\x7b\x2c\x64\x18\xec\x7a\x7a\x83\xcc\x04\x3f\x72\x63\x78\x42\xef\x93\x9d\xd2\xac\xeb\xd7\x54\x3d\xa0\x07\x89\x36\xfb\x5b\x70\xfd\x82\xcd\xdb\xa0\x53\x23\x6b\xcd\x26\xfd\x9e\xb1\xea\x87\x7f\xac\x68\x91\xd0\x49\x46\xe8\x59\xf8\x63\x49\x46\x8e\xf1\x49\xb7\xa9\x4b\xd5\x2c\xf8\x59\x4f\xe5\x99\xbe\xd0\x35\x51\x94\xe1\x67\xbe\xe4\xc0\x27\x10\xb6\x5e\xbd\x7e\x03\x88\x9f\xf9\x5f\x26\x3d\x77\x5e\xf9\x59\x57\xc5\x2e\xc9\x34\x63\xac\x42\xa5\x49\x4d\xf6\x6f\x4d\x62\xac\x00\x3a\x49\x33\x6b\x12\xd0\x33\x7d\x15\xc1\xd2\xa7\xd5\x6f\x3d\xc9\xc8\xfa\xcc\xbc\x62\xb3\xe6\x0d\x97\x6c\xa6\xe4\xfb\xd9\x4d\x7c\x66\x5b\xea\xe5\xe4\xc5\x7a\x02\x77\x77\x0a\x3e\x43\xb7\xcd\x8b\xf5\x99\x57\xe0\x61\x1e\xb6\x3c\x3a\x0a\x5b\xda\xfb\xc7\x13\x7d\x95\x46\x51\x63\x7d\x66\xbe\x74\x52\x20\x68\xde\x9f\x27\x1e\x05\x6d\xbd\x56\x99\xea\x6f\x15\x26\x05\x62\x67\xdb\x33\xdf\xcf\xba\x75\xf7\x30\xd6\x93\xf8\x9d\x0a\x1d\x22\x72\xbf\x01\x94\x45\xef\x4c\x7c\xd0\x6f\xbf\x3a\xa9\x6e\x08\x6e\x52\x8a\xd6\x13\x74\xdc\x5e\x60\xc3\xeb\xd3\x1b\xb8\x2d\x7d\x16\x96\x4e\x6e\xc2\xe7\x26\x90\xfd\xdc\x95\x58\x03\xd5\x1e\xa4\xba\x20\x23\xad\x65\x7d\xc4\x11\x33\x3d\xc6\xf6\xc0\x39\x06\xb1\x90\x89\x7f\xf7\xdc\xbd\x76\x8e\x55\x26\x4e\x82\x0b\x1b\x44\x4d\x3a\x5f\xcb\xd0\xdd\xfc\x80\xa0\xb7\x04\x7b\xe6\x4d\x6b\x22\x94\x39\x32\x31\x37\x38\xd0\x51\x85\x63\x63\xb8\xcf\x8f\xd7\x98\x81\xb7\x1d\x37\xc0\x44\xf4\xf8\x47\xc7\xce\xb1\x81\x7b\xa0\x9e\xf7\x05\xa9\xbd\xe7\x4d\x90\x70\x12\xed\xf8\x45\x48\xbe\xa7\xa7\x16\xf9\x4c\x94\xc9\x35\x42\x56\xd1\xdf\xc2\x51\xba\xd0\x37\xcf\xf7\xad\xcf\xdc\x47\x8d\x7a\x78\x7f\xe0\x0f\xc1\xf0\x5f\xb3\xb4\xcb\xe3\xde\x58\xf9\x44\xd2\x9b\x97\x58\x60\x64\xef\xcb\xa7\x92\x5e\xc7\x4c\xf7\xf2\x6c\x07\xe7\x1c\xc0\xb0\x21\xbf\x1a\x56\x85\xe7\x94\x81\x1c\x6f\x68\xf5\x77\xb6\x69\x0c\xc7\x2a\x6d\x50\x55\xa6\x07\x73\xae\x79\x06\x1a\xa5\x0a\x00\x36\xf9\x80\x70\xd6\xe1\x18\xc8\xa2\x0b\xad\x09\x15\x70\xd0\xad\xcf\xe2\x1a\x90\xef\xb4\x68\x49\x78\x5a\x9c\x45\x45\xed\x85\xa1\xc5\x04\x94\x94\xb3\x3f\xb0\x14\x71\x9a\x42\x2f\x7f\xe3\xf3\x0f\x71\x80\xd8\x75\xeb\x59\x92\xdd\xef\x3a\x5a\x85\xe1\xb2\x81\x59\x1d\x12\x22\x54\x87\xa8\x8e\x11\x1e\xd2\xfa\xcc\x45\x14\x9d\xb1\xf6\xff\x03\x00\x00\xff\xff\x7f\x81\xd8\xa9\xa2\x8e\x00\x00"), - }, - "/src/reflect/reflect_test.go": &vfsgen۰CompressedFileInfo{ - name: "reflect_test.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 3556, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x55\xdf\x6f\xe2\x38\x10\x7e\x4e\xfe\x8a\x51\x1e\x56\x70\x67\x41\x03\x2d\x0f\x48\xf7\x40\xcb\xee\xaa\xd2\x1e\x9c\xb6\xd5\xdd\x03\x42\x27\x6f\x98\x80\x0f\xe3\x70\xb6\xc3\x16\x45\xf9\xdf\x57\x0e\x21\x38\x09\x69\xb3\x3f\x1e\x4a\xed\x99\x6f\xbe\xb1\xe7\x1b\x4f\xfa\x7d\xf8\xfd\x4b\xcc\xf8\x0a\xfe\x53\xae\xbb\xa7\xc1\x96\xae\x11\x24\x86\x1c\x03\xfd\xaf\x46\xa5\x5d\x97\xed\xf6\x91\xd4\xd0\x71\x1d\x6f\x47\xf5\xc6\x73\x1d\x2f\x07\x98\xa5\xc1\x30\xb1\xf6\xdc\xae\xeb\x86\xb1\x08\xe0\x19\x95\x9e\x70\xb6\x16\x3b\x14\xba\xa3\xe1\xb7\x1c\xd1\x7b\xee\x42\xe2\x3a\xba\xf7\xb4\x65\xfb\x4e\xd7\x4d\x2d\xfc\x13\x67\x01\xce\x0f\x28\x43\x1e\x7d\x6d\x19\xf3\x21\x16\xc1\x27\x7a\x8c\xe2\xb6\x49\x26\x52\xd2\xe3\x3c\x9c\x32\x89\x81\x7e\x0c\x69\x80\x2d\x03\x9f\x8f\x7b\xe4\x4c\x6c\xd5\x53\x24\x35\xae\x5a\x46\x7d\x7c\xb8\x67\x5a\xb5\x04\x3f\x6c\xa8\x98\x70\x1e\x05\x2d\xf1\x33\xba\xc3\xfb\xa3\x46\x35\x91\x98\x15\xbb\xf5\xb1\xe6\x61\xa8\x50\x7f\x8a\x82\x6d\x5b\x6d\xd0\x48\x3d\x17\x8f\xe2\x40\x39\xbb\x92\x26\x6f\x86\xde\x09\xd8\x59\x2c\xcb\x86\x07\xaa\x30\x71\x1d\xc7\xfc\x39\x53\x26\xc7\x00\x65\xc0\x67\x0c\x0e\xc4\x38\x4d\x11\xc6\x85\xf3\x6f\xca\x63\x4c\x52\xe3\x49\x09\x34\x46\x3f\xa1\x58\xbd\x1e\xed\x18\x48\xc5\x33\x0f\x3b\x7e\xb7\x46\x5d\x66\x9e\x62\x48\x63\xae\x4f\x28\xd7\x49\x2b\x65\xd1\x32\x0e\xf4\x3c\x6c\xac\xa2\x77\x46\x78\xd7\x03\xdf\xbf\x98\x67\xf5\x39\xe6\xd8\xdc\x24\x6f\x71\x7c\x7c\xf8\xe1\xd0\x09\x5f\xff\x78\x5a\x14\x28\x59\xf0\x33\x14\x6d\x5e\xe1\x5b\x1c\xff\x30\xbd\x79\x14\x1a\xe5\xf7\xb0\x1c\xa8\x84\x15\xe2\xfe\xfd\xff\x31\xe5\x86\x4d\xc1\x1f\xb0\x58\x4e\x6d\x53\xe2\x3a\xfd\x3e\x64\x5b\xa6\x19\x2a\xd7\x49\x04\xe3\x04\xb2\x1f\x2d\x63\x34\xfd\x90\xf8\x04\x7c\x6b\xcb\x84\x1e\x0e\x4c\x57\xc1\x65\x55\x38\x6f\x7a\x77\x04\xb2\x9f\xc2\x14\xf2\x88\x1a\xdc\x4d\xef\xae\x4b\xa0\xbc\x2b\x40\xde\x06\x39\x8f\x3c\x02\xc5\xa2\x70\xed\xe8\x16\x3b\x8b\x25\x13\x9a\x80\x7f\xd3\x25\x50\x33\x14\xd0\x77\x8b\xa1\x31\x9b\x13\x0f\x08\x0c\x53\x02\x75\x4b\x01\xbe\xa7\x8a\x05\xc6\x71\xd3\xbb\x4b\x09\x54\xb6\x05\x0c\xa5\x8c\x64\x47\x30\xde\x25\x60\xaf\xad\xf3\xed\x17\x4c\xe8\xa5\xd2\x92\x89\x75\xe2\x8f\xc1\x8b\x04\x7a\x04\x06\x63\xf0\xf4\xd7\xc8\x4b\xcd\x91\x4b\x98\xb3\x87\xc0\x19\x6d\x67\x0c\x85\x4f\x20\x14\x83\xc2\x94\xa9\xf4\x28\xd0\xd6\xe9\x74\xa1\x90\x72\x75\x5d\x95\x41\xd7\xf6\xe6\xb2\x8c\x6c\x5b\x93\x2e\xa3\x52\xa4\x2d\xcc\xd1\xb3\x3d\xaf\xeb\xe2\x97\x58\xde\x12\xe6\x36\xb5\xd1\xcd\xca\x8c\x1a\x70\x05\x6a\x70\xda\xd8\xa7\x6c\x50\x67\xf8\x7d\xea\xb4\x60\xcc\xe2\x5e\x7e\x1d\xe3\xcf\xf2\x5c\x45\x37\xe7\xba\xf0\x64\xcf\xdf\xb7\x2d\x7e\x3e\x13\xac\xee\x39\x35\xe9\xb0\x6c\x1b\xd6\x6c\x8b\x65\xd6\x11\x49\xe2\xa7\x29\x81\x62\x37\x48\x2b\x27\xd7\x9b\xde\x8c\xce\x3a\x59\x1b\x5d\xd6\x76\x07\xf9\xcb\xac\x47\x47\xb7\x16\x3a\x6b\xa4\x06\x47\x8b\x58\x85\x3c\x4c\xec\xa7\xb7\xb8\x8e\x6b\x30\xdb\xb7\x6c\xc7\x6f\xaa\x9f\x23\xaf\x44\x8c\xc1\xcf\x15\xaa\x62\xfc\x31\x0c\x6a\x52\xbf\x45\x54\xc9\x9e\x4d\x91\x19\xe3\x70\x50\x80\xbb\xbd\x3e\x8e\x41\x44\x1a\xf4\x06\x41\xd1\x1d\xf6\xb2\x6b\x18\x71\xb2\x0b\x33\xa1\xf3\x41\x67\xdf\xd2\x76\x57\x0a\x77\x09\xb0\xd7\xb5\x29\x99\x07\x5a\xdb\x5a\x9a\x66\x68\xad\x96\x65\x8a\xba\xc5\xbe\xfa\x9f\x4c\xed\xa8\x0e\x36\xb8\x02\x7d\xdc\x9f\x87\xa8\xdf\xbb\x69\x1c\xa3\xa3\xdb\x8e\x5f\x1f\xa3\xc5\x44\xac\x16\xe6\x32\xdc\x6a\xd3\xae\x36\x09\x4f\xdf\xf2\x24\xb5\xe6\xdf\x75\x8f\xa7\xbc\xd7\x66\xe3\x2c\xd2\x15\x4b\xb9\x8e\xf1\xaf\xf8\x32\x9d\x29\xb3\x32\xfe\x15\x29\xc5\xbe\x70\x04\x1e\x45\x7b\x65\xba\xe6\x9d\x59\xf9\x04\xce\xff\xcf\x0a\xf5\xfb\x65\x57\xf1\x41\x83\x7e\x1f\x9e\xe7\xd3\xf9\x18\x3e\xb0\x97\x82\xe1\x78\xc6\x1d\xaf\x70\x5c\x9c\x4d\x2c\xa9\xfb\x2d\x00\x00\xff\xff\x1e\x24\x5a\xae\xe4\x0d\x00\x00"), - }, - "/src/reflect/swapper.go": &vfsgen۰CompressedFileInfo{ - name: "swapper.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 605, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x51\xc1\x8e\xd3\x30\x10\x3d\x7b\xbe\xe2\xd1\x03\x72\xc4\x2a\x6d\xf6\x18\x69\x8f\x8b\x84\x80\xe5\x50\xc4\xdd\x38\x93\xd6\x25\x75\x2c\xdb\x71\x81\x6c\xfe\x1d\xd9\xe9\x22\x24\xa4\x6a\x0f\x51\x3c\x33\x6f\xde\x7b\x7e\xde\x6e\xf1\xee\xfb\x64\x86\x0e\xa7\x40\xe4\x94\xfe\xa1\x0e\x0c\xcf\xfd\xc0\x3a\x12\xf5\x93\xd5\xd8\x5f\x94\x73\xec\x65\x18\x8c\x66\x18\x1b\xd9\xf7\x4a\xf3\xbc\x54\xc8\x73\x69\xee\x70\xca\xed\x0a\x33\x89\x84\xf6\x01\xdf\xd4\x30\xf1\x97\x7e\xdd\xa8\x48\x98\x1e\xa9\xfe\x68\x6c\x27\x2b\xbc\x79\xc0\xbe\x10\xcd\x24\x84\x53\xd6\x68\xf9\xb6\xe0\x1f\xbd\x1f\xfd\xfc\x99\xe3\x71\xec\x5a\x6c\xae\xaa\x9b\x3b\xe4\xc5\xf6\x2f\xc1\x52\x91\x58\x48\x6c\xb7\x78\xaf\x42\x84\x53\xf1\x88\x7e\xf4\x28\x5a\x01\x63\x8f\x60\x7e\x33\x76\x50\xb6\x43\x53\xe3\x69\x8c\x47\x63\x0f\x88\x23\xc2\x45\xb9\x9a\x44\xb8\x98\xa8\x8f\x48\xf5\x27\xb6\xb2\x98\xd6\x2a\x30\x76\x2d\x09\xe1\x39\x4e\xde\xfe\x77\x2f\xac\x46\x37\xd7\x60\x5a\xbc\x64\xd1\xf1\x4f\x8c\x53\xcc\xb2\x5e\xd9\x03\x6f\x2a\x2c\x57\xbe\xe6\x06\x1f\x09\x91\x43\x31\x39\x8d\x1d\x9e\x9f\x71\x5a\x4f\x65\x20\x5e\x2f\x96\xe1\x0b\x95\x6f\x21\x11\xcf\x2e\xa7\xff\xc4\x17\x99\xea\xaf\xbf\x1c\xcb\xaa\x7e\x1c\xf8\x2c\xab\x97\x3f\xdd\x30\x94\x9a\xbc\x9c\xea\x0f\x59\x47\x9a\xcc\x9d\xee\xff\x6d\x9d\x72\x2b\x9e\x5d\xbd\xe7\x28\x53\x53\x00\xcd\x5a\xdc\xaf\xe8\x52\xc4\xb3\x2b\x4f\xb4\xd0\x9f\x00\x00\x00\xff\xff\x77\x0c\x80\x10\x5d\x02\x00\x00"), - }, - "/src/regexp": &vfsgen۰DirInfo{ - name: "regexp", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/regexp/regexp_test.go": &vfsgen۰FileInfo{ - name: "regexp_test.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - content: []byte("\x2f\x2f\x20\x2b\x62\x75\x69\x6c\x64\x20\x6a\x73\x0a\x0a\x70\x61\x63\x6b\x61\x67\x65\x20\x72\x65\x67\x65\x78\x70\x0a\x0a\x69\x6d\x70\x6f\x72\x74\x20\x28\x0a\x09\x22\x74\x65\x73\x74\x69\x6e\x67\x22\x0a\x29\x0a\x0a\x66\x75\x6e\x63\x20\x54\x65\x73\x74\x4f\x6e\x65\x50\x61\x73\x73\x43\x75\x74\x6f\x66\x66\x28\x74\x20\x2a\x74\x65\x73\x74\x69\x6e\x67\x2e\x54\x29\x20\x7b\x0a\x09\x74\x2e\x53\x6b\x69\x70\x28\x29\x20\x2f\x2f\x20\x22\x4d\x61\x78\x69\x6d\x75\x6d\x20\x63\x61\x6c\x6c\x20\x73\x74\x61\x63\x6b\x20\x73\x69\x7a\x65\x20\x65\x78\x63\x65\x65\x64\x65\x64\x22\x20\x6f\x6e\x20\x56\x38\x0a\x7d\x0a"), - }, - "/src/runtime": &vfsgen۰DirInfo{ - name: "runtime", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/runtime/debug": &vfsgen۰DirInfo{ - name: "debug", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/runtime/debug/debug.go": &vfsgen۰CompressedFileInfo{ - name: "debug.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 298, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\xce\xb1\x4e\x03\x31\x0c\xc6\xf1\xb9\x7e\x8a\x6f\x2c\x02\x9a\x34\xa5\x3c\x00\x0c\x9d\x8a\x10\xf0\x02\x49\xce\x1c\xa6\x77\x6e\x75\x71\x24\x2a\xd4\x77\x47\xbd\x0e\x87\xd8\xf0\xe2\xe1\x2f\xff\x64\xe7\x70\x9d\xaa\x74\x0d\x3e\x0b\xd1\x21\xe6\x5d\x6c\x19\x0d\xa7\xda\x12\xbd\x57\xcd\x28\x6c\x9b\xc7\x67\x1e\x32\xab\xcd\x45\x6d\x15\xae\x30\x2e\x7c\xd3\xcc\x39\x3c\xed\x0d\xd2\x1f\x3a\xee\x59\x8d\x9b\x05\x5e\xd8\xea\xa0\x10\x15\x93\xd8\x9d\xef\x4d\xb4\x5d\xd0\x6c\xb8\x84\xa5\xf7\x74\x9a\xf0\x6d\xfc\x7a\xb5\x98\x77\xf3\x74\x34\x2e\x67\x7a\xf4\xff\xad\x3b\x87\xb7\x0f\xfe\x1b\x20\x05\x4b\x6c\x1e\xb0\x57\xdc\xdf\xdd\x26\x31\x94\x63\x31\xee\xcb\x0d\xc2\xda\x63\x3b\x96\x55\xf8\x5d\xa6\x57\xc3\xda\x5f\x86\x4e\xf4\x13\x00\x00\xff\xff\xad\x79\xbd\xd2\x2a\x01\x00\x00"), - }, - "/src/runtime/pprof": &vfsgen۰DirInfo{ - name: "pprof", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/runtime/pprof/pprof.go": &vfsgen۰CompressedFileInfo{ - name: "pprof.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 660, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x92\x4f\x6b\xc2\x40\x10\xc5\xcf\x99\x4f\x31\xe4\xb4\x69\x45\xfb\x15\x8a\x97\x1e\xda\x22\xb5\xa5\x07\xf1\xb0\x26\x13\xd9\x9a\xfd\xc3\x64\x56\x2b\xe2\x77\x2f\x6b\xa4\x2c\x18\x0a\x3d\xee\xcc\xfb\x0d\xef\x3d\x76\x36\xc3\xfb\x4d\x34\x5d\x83\x5f\x3d\x40\xd0\xf5\x4e\x6f\x09\x43\x60\xdf\x02\x18\x1b\x3c\x0b\x2a\x28\x4a\xe3\x4b\x28\xca\xfe\xe8\xea\x12\x2a\x00\x39\x06\xc2\x05\xfb\xd6\x74\x84\xbd\x70\xac\x05\x4f\x50\x38\x6d\x09\xd3\xdb\xb8\x2d\x14\x36\x22\x22\x26\x66\xfa\x12\x85\xbe\xa1\xb0\x69\x80\x56\x87\x95\x71\x42\xdc\xea\x9a\x4e\xe7\xf5\x6a\x1d\x8d\x93\x20\x0c\x45\xed\xa3\x13\x6c\xa3\xab\x55\x85\xc6\x09\x14\x07\x36\x42\xc3\xc4\xf8\xe9\x67\x7a\xf1\x24\xad\x2a\x24\x66\xcf\x70\x06\x48\x5b\x54\x01\xef\xae\x8e\x2a\xbc\xe8\xde\xbd\x3a\x60\x06\x35\xb4\x89\xdb\x0c\x4d\x8e\x99\x24\xb2\x43\x67\xba\xf1\x43\xf3\x64\x68\xf0\x92\xc9\x1f\xc6\xc5\xaf\xda\x92\xaa\xae\xf9\x33\x79\x59\x8e\xeb\x1f\x9b\x46\xed\x75\x17\x09\xb3\x3a\x26\xd8\xef\x4c\x18\x6c\x9e\xc6\xb9\x37\xb2\x7e\x4f\xb7\x68\x0e\x2c\x45\xb3\xcc\x17\x1f\x57\x28\x6f\xe2\xef\xf8\x4b\xf1\x21\xe3\xf2\x9b\x17\xfc\x89\x74\xf8\xf7\xd1\x67\xef\x77\x31\xa8\xcb\xff\x18\xea\xa9\x7e\xf3\xdc\x20\x3f\x01\x00\x00\xff\xff\x14\x4a\xfc\x56\x94\x02\x00\x00"), - }, - "/src/runtime/runtime.go": &vfsgen۰CompressedFileInfo{ - name: "runtime.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 4973, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x58\x6d\x72\x1b\xbd\x0d\xfe\xbd\x7b\x0a\x74\xa7\x1f\xbb\x8e\x22\xd9\x6e\x92\x4e\x33\xf5\x8f\x44\x89\x9d\x4c\x63\xcb\x63\x39\xed\x3b\x93\x66\x32\x14\x17\x2b\xd1\xe2\x92\x5b\x92\x6b\x59\xf1\xe8\x00\x3d\x48\x2f\xd6\x93\x74\x40\xee\x87\x64\xcb\x49\xfb\xea\x47\xac\x80\x0f\x40\xf0\x01\x01\x02\x1a\x8d\xe0\xd9\xac\x16\x32\x87\x1b\x1b\xc7\x15\xe3\x4b\x36\x47\x30\xb5\x72\xa2\xc4\x38\x16\x65\xa5\x8d\x83\x34\x8e\x92\x46\x36\x12\xca\xa1\x51\x4c\x8e\xec\xda\x26\x71\x1c\x25\x73\xe1\x16\xf5\x6c\xc8\x75\x39\x9a\xeb\x6a\x81\xe6\xc6\xf6\x5f\x6e\x6c\x12\x67\x71\xcc\xb5\xb2\x0e\xce\x26\x93\x29\x9c\x80\x5d\xdb\x21\x7d\xed\xa4\x6f\xae\xc6\x1f\xe0\x04\x12\x02\x07\xd9\x58\x97\x95\x90\x68\x48\xda\xda\x4a\xe2\x78\x34\x82\x82\x2d\x11\x0a\x6d\x00\x8d\xd1\x66\x38\xd7\xb1\x5b\x57\x08\x58\x30\x8e\x60\x9d\xa9\xb9\x83\xfb\x38\xfa\xe6\xa5\x07\xfe\x4f\xbc\x09\x98\x20\xeb\x30\x9b\x38\x2e\x6a\xc5\x21\x75\x0d\x2e\xa3\x35\xa1\xe6\x69\xfb\x85\x0c\x19\x74\xb5\x51\x90\x24\x1d\x5e\x28\xe1\xd2\x8c\xd6\x6e\xec\xe5\x72\x0e\xaf\x4f\xe0\xc6\x0e\xcf\xa4\x9e\x31\x39\x3c\x43\x97\x26\xbf\x6d\x78\xb4\x49\x16\x04\x3f\xa3\x28\x23\x5b\xad\x89\xa9\x37\x71\x63\x27\xb3\x1b\xe4\xee\xd2\x99\x64\x00\x7e\xa7\x60\x2b\x88\x5b\xcb\x95\x33\x49\xb6\x57\xfd\x3d\xf1\xf3\x48\xdb\x4b\x7f\xa6\xec\x16\x46\xaf\xae\x42\xbc\x83\x02\xd9\x18\x7e\x6c\x22\x1f\x3c\x48\x89\x8c\xb4\xb4\xf3\x86\x2c\xcf\x48\x54\x31\x25\x78\xea\x63\x33\x0d\x64\x96\x76\x4e\x7b\x6c\xe8\x9f\xd1\x08\xd8\xad\x16\x39\xe4\xc8\x72\xe0\x3a\x47\x40\x29\x4a\xa1\x98\x13\x5a\xc5\xd1\x2d\x33\x80\x21\xb2\x71\x84\x70\x02\xbf\xbf\x5e\x57\xf8\xc6\x5a\x34\x04\xf0\xbe\xdc\x6f\xe2\xe8\x1b\x9c\x00\x76\x01\x39\x9b\x5c\x4d\x26\xd7\x3b\x51\xab\x8c\xe6\x68\xed\x9e\xd8\x34\x2b\x44\xb9\x28\xa0\xc5\x9d\x78\xdc\x67\x95\x63\x21\x14\xe6\xfe\x28\x6d\xe4\x47\x49\x1c\x6d\xe2\x68\xae\x8d\xd6\x8e\x2c\x36\x4a\xc1\x1e\xaa\xdb\x96\xce\xe0\x47\x63\xb9\x81\xff\xe6\x69\xc3\x01\x31\x6c\x68\xca\xfc\x26\xcd\x12\x65\xc8\x3b\x2c\x58\x2d\xdd\x99\x47\x75\x67\x7d\x6b\x90\x2d\x2b\x2d\x54\x77\x05\x87\xef\x70\x56\xcf\xe7\x68\xd2\xac\x43\x8d\x99\x94\x68\x52\xbb\x14\x15\x08\xe5\x32\x48\x2b\x0e\xb5\x50\xae\x72\x66\x00\x85\x90\xd8\x70\x35\x00\x29\x14\x12\x66\x00\x7a\x09\x33\xad\xa5\x37\x2b\x54\xa1\xf7\x90\xd7\xde\x9e\x0b\x5c\xa5\xcd\xa1\xad\x63\x7c\x99\x64\x43\xda\x32\x4d\x6c\x25\x85\x4b\x06\x90\xfc\x43\x25\xd9\xf0\xa3\xca\xf1\x2e\x78\xf1\x0c\x8e\x03\x2f\xde\xf2\x0f\xe8\x3e\x1c\x40\x92\x0c\xe8\x4f\xc1\xa4\x45\xcf\x4a\xc5\x8c\xf3\xb1\x24\xe5\x76\xa7\x7a\x16\x8e\x90\x0c\xb6\xc5\x82\xb6\x9c\x14\xe4\x42\xea\x3d\x70\x69\xf6\xec\xe8\x29\x48\xd6\x42\x1e\xf9\xff\x9a\xc2\xd8\xbb\xe4\x3d\x68\xce\x73\x98\x75\x31\xdb\x5d\x38\x6a\x8c\x0d\xc0\x99\x1a\x1f\x04\xc3\x76\xd1\x18\x40\xc5\xe1\xcb\xd7\x26\x1c\x19\x89\xb6\x0a\xcd\x61\x7f\xad\xc7\x3e\xc4\xdd\x7f\x35\xde\xf5\x85\x67\xb7\xde\xf0\xda\xd0\x3d\xa9\x9d\x50\x98\x64\x21\x8b\x09\x9d\x04\x57\x76\x52\x3c\x1c\x34\xe4\x78\x32\x00\x25\x64\xb6\x95\x49\xe7\x6f\x7e\xb9\xbc\x9a\x8c\xa7\xa9\x0a\x17\x67\xd7\xb9\xa3\x2d\x6f\x2c\x5f\x60\x1e\xdc\xe1\x14\x9b\x92\x2d\x31\xe5\x0b\xa6\x9a\x0a\x7b\xbf\xd9\xb7\xad\x45\x77\x2d\x4a\xd4\xb5\x7b\xba\xa6\x64\x70\x0f\x5c\x6a\x8b\x29\xcf\x60\x93\x0d\xe0\x30\x8b\xa3\xbf\x3c\xe7\xdd\xe6\x17\x75\x39\xbe\xfc\x9c\x3e\xed\xdd\x45\x5d\x76\x7c\x3c\x82\x3d\x24\xcf\x69\xc7\x64\x07\xb7\xed\x95\x20\x63\xfe\xc1\x38\xc7\x72\xea\x98\xb3\x5b\xaf\xcb\x68\x04\x67\xa8\xd0\x30\x09\xd6\x31\x27\xac\x13\xdc\x0e\xe3\xe8\x8d\x94\x9a\x83\xff\x50\x78\x5f\xbd\x80\xd1\x08\x66\x6b\x87\x16\x18\x2d\x31\x87\x39\x30\x95\x83\x75\x42\x4a\x10\x0a\x6a\xba\xe2\xd7\xe4\x41\xd0\x7d\x5a\x2d\xc5\x5b\x54\x20\x0a\x28\x0c\x62\x9e\xc5\xd1\x74\x6d\x01\xf6\x6f\xa6\x67\x8e\xf9\xc4\x2a\x8c\x2e\xa9\x9a\x38\x2c\x21\xb5\x75\x09\xba\x80\x5f\xee\xee\x48\x75\x86\x52\xaf\xb2\x38\xfa\xa4\xf5\xb2\xae\xec\xae\x19\x55\x97\x33\x34\x84\xf6\xb5\x06\x0d\xc8\x00\x8b\xa3\x73\xef\xd2\x93\xf8\x32\x2c\xc7\xd1\xa9\x41\xb4\x0f\xdd\xeb\x71\x74\x0a\x1b\x7b\x2a\xcf\x99\x50\xed\x41\x85\x56\xb0\x40\x56\xed\xf2\xfa\x01\x59\xd5\x71\xfb\xff\x30\x4b\x8a\x1d\x4f\xff\x0b\x4b\x41\xe5\x63\x2e\x71\xaf\x8a\x50\x20\x68\xcd\x56\x4c\xd9\x06\xab\x6a\x8b\x4f\x60\x95\x56\xcf\x3b\x7c\x80\x5f\xa1\x44\x66\x31\x7f\x04\x37\xed\x82\xd3\xe0\x16\x08\x93\x69\x50\x08\x99\x61\xb7\xed\xfb\x1b\xbb\xc5\x65\xcf\x80\x0e\xe0\xc0\xeb\x27\xbd\x7a\x2e\xf1\x16\x25\x14\xe2\x0e\xf3\xe7\x56\x7c\x6f\xdb\x9f\xda\x60\xab\xa5\xcd\x2e\xd7\xa3\x51\x14\x8e\x24\x6c\xe3\x59\x4d\x5e\x29\xbd\x0a\x8b\x44\x67\xb7\xb4\x8f\xc2\x61\x1c\x4d\xe9\x51\x68\x88\x79\x78\x4e\x6f\x6d\xb6\x06\xff\x70\xf4\x4e\x34\x4a\x4d\xb0\x82\x52\x1c\x9d\x4f\x2b\xa6\x1e\x19\x2a\x89\xce\xfe\x24\xb6\xc1\x3d\xd4\x1d\x33\xbe\xc0\xa0\xbc\xa5\xcb\x49\xba\xab\xec\x81\x41\xbb\x55\x7e\x5b\xf3\xe5\x07\x66\x17\x24\xed\x95\x2b\xa3\x0b\x21\xa9\xc7\x98\xd5\x7c\x89\x0e\x16\xcc\x2e\xc0\xb1\x99\xc4\x38\x3a\x1b\xf7\x19\xd9\xab\x9c\x8d\xa1\x44\xc7\x72\xe6\x58\x1c\x4d\xdc\x02\xcd\x8e\x9b\x04\xd1\x24\x6d\xb3\xb4\xcf\x83\x26\x8a\x67\xcc\xcc\xa8\x27\xe7\x5a\x4a\xe4\x8f\xc2\x75\x81\x77\xee\x6c\xfc\xb8\x10\x28\xbc\x73\xad\x0e\x25\xd5\x8a\xd2\x62\xc1\xaa\x0a\x15\xac\x16\xa8\xa0\xcf\xa9\xff\xfc\xeb\xdf\xe0\x16\xc2\x02\x2b\x75\xad\x5c\x1c\x7d\x62\x76\xaf\x4d\x54\x39\x50\x4f\x48\x77\x4e\x32\xbb\x63\x3f\x55\x4c\x69\x8b\x5c\xab\xdc\x82\x15\x8a\x23\x1c\xfd\xf9\x4f\x54\xb9\x2f\x59\x6d\xd1\x97\xb8\x0b\xdb\x13\xec\xa5\x17\x2d\x5f\x5f\x8e\x5f\xbe\xfa\xda\x6f\xc4\x85\xe1\xb5\x64\x06\x66\x75\x51\x84\x3b\x6e\x90\xa3\x72\x44\x67\x45\x9a\x90\xd7\x26\xb0\x34\x80\x52\x5b\xd7\xae\x33\x07\x5f\x52\x2a\xff\xe3\x67\xc7\x2f\x5f\x66\xbf\x23\xbb\xcd\x66\xef\x55\xfe\x6b\x37\x6b\x0f\x6e\xe3\xc8\xdb\x86\x6d\x6e\xfe\x78\x4c\xb1\x1f\x5f\x7e\x3e\x35\x2c\x70\x51\x48\xcd\x1a\xe3\x45\x2b\xd3\x05\x8c\x2f\x3f\x07\xfa\xda\x14\x38\x1b\xc7\xd1\x7b\x45\xb7\xa7\x35\x49\x0d\x58\x1c\xf9\x8e\xae\xdb\xc5\xcb\xfc\x55\xb8\x44\x13\x92\x78\xab\x58\x3e\xc8\x5d\x78\x75\x44\xd9\x79\x51\x97\x53\xf1\x1d\xc7\x92\x59\x1b\x4a\x11\x95\x94\xb1\x6f\xb9\x87\x71\xf4\x76\x4d\xab\xf0\xe5\xd5\xd1\xd7\xfe\x51\x8b\xbc\x6c\xeb\x50\x5d\xa9\x6f\x63\xd6\xd5\xf4\x56\xb0\xe9\x5e\xdc\x2b\x64\x79\xfb\x50\xa6\x25\x1c\xb4\xdf\xb7\x3b\x98\x29\xba\x53\xa1\x98\x14\xdf\xd1\xa4\x77\x03\xa0\x66\xd0\xa1\xa1\xc9\xed\x7e\xd3\x00\xfd\x8b\x7b\x4a\xe8\xde\x31\x5d\xb1\x7f\xd6\xd8\xb5\x15\x44\x6b\xad\xf0\x8e\x26\x53\xaa\x3c\x02\xa5\x2f\x9a\xb9\xb0\xe4\xef\x0a\xb8\x56\xb7\x68\xac\x4f\xa1\x6e\xc8\xfb\x06\x07\x64\x36\x83\xf7\xca\x99\x75\x9a\xb5\xed\x30\xfc\xf0\x73\x0f\x6d\x5b\x06\x9b\x87\x86\x4e\x85\xc4\x4f\xd4\x60\xf4\xbd\x75\x06\xe9\xde\xe6\x3a\xeb\x0d\xf9\xe6\xf6\xb1\xb1\x0b\x56\x62\x3f\xc1\xfc\xe4\xb3\x65\x0c\xda\x03\x92\x99\x53\x6d\x2e\xc7\x3b\xee\x78\xeb\x5b\xbd\x8f\x12\x92\x28\xa1\x39\xeb\x1c\xcb\x4b\x5f\xce\xf0\x8a\x39\xef\x25\x9c\xc0\xcb\xa3\x63\x38\x80\xa3\xc3\xe3\x17\x7d\xcc\xde\x4a\xcd\x97\x5b\xd0\xd4\x34\xf8\x07\xb1\x3d\xaf\x1d\xde\x35\xb8\x36\x15\xb6\xb0\x4d\x13\x36\x1a\xc1\xf5\xe4\xdd\xe4\x35\x7c\x54\xb7\x68\x9d\x98\x13\x80\xaa\xcf\x10\x3e\x16\x20\xdc\x1f\x2c\x54\xda\x5a\x31\x93\x48\x41\x15\x65\x25\xb1\x44\xea\x9a\xb9\x56\x56\xe4\x68\x20\xd7\xc4\x91\xd5\x83\x50\x39\x57\xc2\x22\x18\x2c\xf5\x6d\x30\x04\x5c\x97\xa4\x31\xdc\xd3\x53\xfb\x37\x26\x9d\xd5\x05\x7c\xf9\x4a\xcf\xd1\x80\x52\xa9\x19\x7b\x1a\x07\xf7\x0d\x8d\x4f\xcf\x3d\x7e\xa6\xf9\xe1\xfc\x78\xb8\x3d\xd8\x71\x5d\xad\x69\xfb\x01\xd8\x9d\x39\x26\xe9\x05\x5b\xe3\x49\x33\x44\xf9\x11\xa6\x1f\x3a\xfa\x76\xfd\x93\xe6\xcb\xc9\xf4\x7a\x61\x90\xf9\x4e\xbc\x95\x7f\x56\xf2\x89\x95\xbf\x85\xbc\xd8\xf7\x0b\x07\xcd\x9c\xd7\x0b\x6c\x10\xdb\x8c\x19\x77\x6d\x18\xa7\xeb\xe9\x27\xf3\xfe\xfa\x29\x21\xdb\x9b\x3c\x75\xba\x6a\x51\xed\x2d\xdd\xf4\xa5\xa1\x5d\x0a\xac\xfb\x1f\x72\xfe\x8e\xe1\xb7\x1c\x06\x7c\xae\x01\xd5\xad\x30\x5a\x51\xdc\x28\xec\x9c\x39\xbe\x08\xdb\xd9\x21\x5c\x2f\xd0\x60\xa1\x0d\xac\x10\x16\xec\x76\xf7\x62\x34\x4f\x97\xca\x81\xc9\x15\x5b\xdb\x2e\x63\xfb\x59\x61\xae\x3d\xb5\x3e\xc4\xaf\x5e\xec\x1d\xb6\xfc\xef\x47\x93\x22\xc5\x0a\x0e\x76\xaa\xd2\x41\xf8\x65\xe9\x3e\x6e\x7e\xda\x48\x1a\xe4\x6b\x50\xda\x81\xad\xab\x50\x86\x92\x3e\x2a\x7f\x45\xac\xde\x48\x71\x8b\xe9\x6e\x79\xdb\xc4\xff\x0d\x00\x00\xff\xff\x86\x93\xb7\xf5\x6d\x13\x00\x00"), - }, - "/src/strings": &vfsgen۰DirInfo{ - name: "strings", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/strings/strings.go": &vfsgen۰CompressedFileInfo{ - name: "strings.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 806, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\x92\xc1\x8e\xd3\x30\x10\x86\xcf\x9e\xa7\x18\xf9\x14\x2b\x25\x69\x6f\xa8\x52\x38\xd0\xc3\xaa\x12\xd2\x4a\x70\x44\x1c\x1c\x77\xd2\x3a\xeb\xda\x91\xc7\x11\xac\x50\xdf\x1d\x39\x69\xd8\x52\xe0\x00\x7b\x1b\x25\xff\x7c\xff\x97\xd8\x75\x8d\x65\x3b\x5a\x77\xc0\x9e\x01\x06\x6d\x9e\xf4\x91\x90\x53\xb4\xfe\xc8\x00\xf6\x3c\x84\x98\xb0\x00\x21\x47\x6f\x4d\x38\x50\x3d\xa6\xee\xad\x04\x10\xf2\x68\xd3\x69\x6c\x2b\x13\xce\xf5\x31\x0c\x27\x8a\x3d\xbf\x0c\x3d\x4b\x50\x00\xdd\xe8\x0d\xee\xfd\x81\xbe\xbd\x7f\x4e\x54\xf0\x95\xbc\x42\x83\xed\x73\x22\x85\xd6\x27\xfc\x0e\x22\x52\x1a\xa3\xc7\x9e\xab\xbd\x4f\x14\xbd\x76\x8f\x6d\x4f\x26\x15\xac\xaa\x9d\x76\xae\x90\x36\x43\x1e\x3b\xb9\xca\xa1\x07\x17\x5a\xed\xaa\x07\x4a\x85\xfc\x34\x11\xe5\x92\xeb\x62\x38\xef\x4e\x3a\xee\xc2\x81\xe4\x0a\x8d\x52\x19\x59\x28\xb8\xdc\xda\x14\xbc\x42\xa6\xe1\xaa\xf3\xbf\x1a\xf7\x21\x1a\x7e\x6b\xfb\xa0\x39\xbd\xae\xd1\x2d\x84\x7f\x68\xdd\x85\xd1\xa7\xbf\x34\x7a\xdc\x36\xb8\x06\x51\xd7\xc8\x03\x19\xab\x1d\x1a\xcd\xc4\x20\xf8\xab\x4d\xe6\x94\x33\xf9\x01\x3a\xf2\x13\x1c\x9b\x06\xd7\x5b\x10\x8b\x6b\xbe\x00\xd5\xc7\xd1\xd3\xd4\xb2\xf7\xf3\x01\x14\xac\xb0\xc4\xcd\xfd\xee\xbb\x79\x54\x37\xfb\xeb\x3f\xf0\x5f\x42\xb6\x9b\xa4\x9b\x06\x39\x9b\xfc\xdc\xda\x80\x10\x97\x5f\x20\x17\x00\xd1\x85\x38\xa5\x86\xc0\xf9\xb3\x6e\xff\xb4\x9a\x61\xf9\x4d\xd3\xe0\x9b\xcd\x4c\x6b\x23\xe9\xa7\x2b\xca\x97\x25\x08\xc1\xd8\x20\x7f\x1e\x02\x97\x8b\xd0\xf6\x4b\x86\x2f\x4d\x1e\x2e\xf0\x23\x00\x00\xff\xff\x1d\x5f\x2c\x75\x26\x03\x00\x00"), - }, - "/src/sync": &vfsgen۰DirInfo{ - name: "sync", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/sync/atomic": &vfsgen۰DirInfo{ - name: "atomic", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/sync/atomic/atomic.go": &vfsgen۰CompressedFileInfo{ - name: "atomic.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 3060, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x56\xcf\x6f\x9b\x3e\x14\x3f\xe3\xbf\xe2\x7d\x39\x54\xd0\x7e\x45\xa4\xad\xea\xa1\x52\x0e\xd5\x0e\x53\xa5\x49\x9b\x54\x75\x77\x07\x4c\xea\xcc\xb1\x91\xb1\x69\xa2\x28\xff\xfb\x64\x03\xc1\x80\x61\x5d\xb2\xf6\x84\x8b\xfc\xf9\xc1\x7b\x9f\xf7\x9a\xc5\x02\x6e\x56\x9a\xb2\x0c\x36\x25\x42\x05\x4e\x7f\xe1\x35\x01\xac\xc4\x96\xa6\x08\xd1\x6d\x21\xa4\x82\x08\x05\xa1\xe6\x25\xce\x49\x88\x50\x10\xae\xa9\x7a\xd1\xab\x24\x15\xdb\xc5\x5a\x14\x2f\x44\x6e\xca\xee\xb0\x29\x43\x14\x23\x94\x6b\x9e\xc2\xd3\x2b\x2e\x1e\xb9\xfa\xfc\x29\xc2\x59\x26\xe1\x9a\x9a\xf3\xff\xc0\xc9\x2b\xd8\x63\x5c\x3f\xe0\x80\x02\xc1\x32\xb8\x5f\xc2\xb5\xb9\x88\x02\xfb\x80\xa5\xb9\x89\x02\x49\x94\x96\x1c\x04\xcb\xd0\xb1\x4f\x7c\x77\xdb\x11\xdf\xdd\x9e\x88\xef\x6e\xe3\xfa\x71\x1e\xf1\x33\x75\x2c\x6b\xc7\xb3\x6e\x4c\xeb\x0b\x5c\x3f\x53\xc7\xb6\x76\x7c\xeb\xc6\xb8\xbe\xd0\x79\xa1\xa4\xc3\x5e\x28\xd9\xd1\x17\x4a\xc6\xed\xe1\x3c\x81\x1f\x82\x72\x45\x4e\x02\x36\x12\x49\xf3\xb2\xd1\xe9\xbd\x8b\x07\x7f\xff\xbd\xea\x17\xb1\x2d\xb0\x24\x0f\x3c\x9b\x08\x93\x60\x59\x2f\x51\x2b\x21\x98\x91\xa1\x39\x34\xdc\x4b\x73\xc7\xbc\xea\x8b\xb5\x6a\x4a\x6a\x82\x82\xe3\x49\x3d\xc7\xac\x24\xd3\xfa\xc3\xcc\xb9\xfa\xa6\x7f\xef\xaa\xef\x8d\xe6\xc9\x81\xfe\x88\x12\x78\x03\xdc\xb3\xf0\x21\x55\xf0\xc4\xbc\x67\xc2\x66\xfd\x5d\x5d\xcc\xcf\x42\x67\x66\x30\x10\xff\xd8\xd3\x43\x96\x79\x86\x22\x23\x4c\xe1\xd1\x8e\x35\x76\xda\xc9\x83\x9b\xfa\x92\x7f\x02\xcd\xd9\x51\xf0\xc6\xae\xd6\x18\xef\xc4\xb3\x55\x3c\xc3\x75\xfa\x8e\xde\x4a\xbf\xe8\x3b\x46\xd9\xed\xbe\xa3\xbf\x7e\x2f\x52\xf1\xc4\xb3\xd3\x19\xee\xe1\xf3\x94\xbe\x09\x3c\x6e\xbd\xd3\xed\x06\x52\xef\xd9\x01\xa8\x5f\x67\xa7\xb4\x93\x20\x4f\x04\xdc\xa6\xcf\xe2\x06\x25\x77\x8b\x3c\x8b\x1b\x15\xb1\x57\xb5\x49\xe8\xdc\x60\xfa\xfe\x21\x79\x89\x9e\x94\x90\xc4\x33\x59\x15\x66\xed\x5c\x1d\xba\x1e\x55\x98\x8d\x90\xc3\x2c\x37\x48\xf3\xfd\x73\x48\xef\xac\x19\xac\x7e\x83\xac\x37\xe0\x2d\xf8\x2d\xca\x9e\xdc\xb6\x70\x5b\xff\x39\xfc\xfc\x42\xb4\x34\x83\x5e\x4c\xb0\x45\x15\x5c\xff\xc4\x4c\x93\xd8\xf6\x33\x8a\x21\xda\x81\x85\xe4\x38\x25\x87\x63\xec\x74\xad\x4a\x2a\x1f\xce\x1a\xf2\xa0\x68\x0e\x3b\xb3\x71\x39\xb5\x4b\x38\x28\x30\xa7\x69\x14\x96\x7b\x9e\x2e\xea\x1f\xbd\xf7\x50\x1a\x2c\x88\xdc\x5e\xaa\x0c\x9f\xa1\x11\x60\xa9\xc3\xd8\xee\x62\x9a\x1b\x65\xf8\xaf\x66\xba\xba\x82\x4d\x99\x3c\x1a\x2d\x8e\xd9\xf7\xd5\x86\xa4\x2a\xda\xc5\xc9\x57\xa2\xa2\x30\x15\xbc\x54\x52\xa7\x4a\xc8\x30\x36\x88\xf1\xd5\x2a\xa9\xbc\x97\xff\xe8\x90\x72\x03\xa0\xa5\x22\x5c\xb1\x3d\xa8\x7d\x41\xb2\x29\xcb\xc6\xef\x12\x76\xe8\x88\x7e\x07\x00\x00\xff\xff\x2a\xf7\xf1\xfd\xf4\x0b\x00\x00"), - }, - "/src/sync/atomic/atomic_test.go": &vfsgen۰FileInfo{ - name: "atomic_test.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - content: []byte("\x2f\x2f\x20\x2b\x62\x75\x69\x6c\x64\x20\x6a\x73\x0a\x0a\x70\x61\x63\x6b\x61\x67\x65\x20\x61\x74\x6f\x6d\x69\x63\x5f\x74\x65\x73\x74\x0a\x0a\x69\x6d\x70\x6f\x72\x74\x20\x22\x74\x65\x73\x74\x69\x6e\x67\x22\x0a\x0a\x66\x75\x6e\x63\x20\x54\x65\x73\x74\x48\x61\x6d\x6d\x65\x72\x53\x74\x6f\x72\x65\x4c\x6f\x61\x64\x28\x74\x20\x2a\x74\x65\x73\x74\x69\x6e\x67\x2e\x54\x29\x20\x7b\x0a\x09\x74\x2e\x53\x6b\x69\x70\x28\x22\x75\x73\x65\x20\x6f\x66\x20\x75\x6e\x73\x61\x66\x65\x22\x29\x0a\x7d\x0a"), - }, - "/src/sync/cond.go": &vfsgen۰CompressedFileInfo{ - name: "cond.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 511, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\x8f\x31\x73\xab\x30\x10\x84\x6b\xdd\xaf\xd8\x12\x1e\x83\x71\xfd\x6c\x9a\xe7\x96\xee\x4d\x26\xb5\x2c\x84\x7d\x41\x3e\x31\x20\x92\x61\x32\xfc\xf7\x8c\x90\x93\x14\xb6\x9a\x93\x76\x75\xfb\xcd\x56\x15\x8a\xf3\xcc\xae\xc5\xdb\x44\x34\x68\xd3\xeb\x8b\xc5\xb4\x88\x21\x0a\xcb\x60\x71\xf2\xd2\x62\x0a\xe3\x6c\x02\x3e\x49\x55\x15\x3a\xb6\xae\x9d\x30\x4f\xb6\xc5\x79\xc1\xbb\x16\x76\x4e\x83\x6f\x83\xb3\x37\x2b\x41\x07\xf6\x42\x4a\xfc\xc9\x0f\x0b\x90\x26\xa9\x06\xe9\x34\xde\xf4\x76\x8c\x7e\xe0\x6e\xf3\xe3\x6c\x78\x0a\xa4\xcc\xd5\x46\x13\xc6\x0f\xcb\x29\xdd\xe9\x19\x53\xec\xc7\x23\x0f\x60\xd9\x32\x60\xae\x5a\x70\xf6\xde\xd1\x4a\xd4\xcd\x62\x90\x19\xfc\x89\x4d\x72\xbc\x6a\x0e\x59\x1e\xab\x98\x9d\x14\x05\x29\xee\x60\x76\xe6\x8a\xba\x86\xb0\x8b\x86\x4a\x6f\xdc\x74\x6f\xb3\x9f\xac\x9c\xd4\x1a\x97\x9a\xdd\x8b\x38\x6f\xfa\x2c\x27\x75\x2c\xe3\xd7\xa4\x36\x49\x7b\x24\xfe\xe7\x8b\x68\x97\x98\x1b\x4c\x22\x6b\xbf\x91\x46\x1b\xe6\x51\xee\xc9\x52\x96\x94\xd8\xc7\x12\x61\x9c\xed\x93\xb0\x7f\xa3\xd7\xad\xd1\xd3\xbd\x83\xe0\x6f\x1d\x13\xb7\x75\xd4\xd8\x93\xea\xfc\x08\x8e\xf2\xfe\x00\xc6\x11\x72\x00\x17\xc5\x6f\xaf\xef\x6c\xb5\xd2\x4a\x5f\x01\x00\x00\xff\xff\x2c\xcb\x53\xaf\xff\x01\x00\x00"), - }, - "/src/sync/pool.go": &vfsgen۰CompressedFileInfo{ - name: "pool.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 505, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\x90\xcf\x4e\xf3\x30\x10\xc4\xcf\xde\xa7\x98\xaf\xa7\xe4\x03\x5a\xb8\x56\xca\x89\x03\x37\x54\x89\x63\x55\x21\xe3\x6e\x2a\x83\xeb\x58\xce\x5a\xa4\x54\x79\x77\xe4\x24\xfd\x83\x20\x97\x68\x77\x46\xbf\x99\xf5\x62\x81\x9b\xb7\x64\xdd\x16\xef\x2d\x51\xd0\xe6\x43\xef\x18\xed\xc1\x1b\x22\xbb\x0f\x4d\x14\xcc\x92\x6f\x75\xcd\x33\x22\x39\x04\xc6\xaa\x69\x1c\x5a\x89\xc9\x08\x8e\xa4\x5c\x63\xb4\x43\xfe\x46\xdb\x7c\xd5\x58\x2f\x1c\x27\xe5\xc5\x7e\x31\x92\xf5\x12\x24\x12\xa9\x56\x9a\xc8\x58\x6f\x06\x4b\xad\x0d\x1f\x7b\x52\xcf\xfc\x09\xa0\x4e\xde\x14\x25\xae\x95\x9e\x28\x6f\x51\x04\xfc\xcf\xb1\x25\x9e\x58\x7e\x7a\x72\x05\x5b\xc3\xb1\x2f\xc2\x7c\xa0\x97\xa8\x2a\xdc\xe7\x7d\x16\xc2\x3c\xd3\xff\x55\xf0\xd6\x0d\x3b\x15\x59\x52\xf4\xa3\x50\x94\xa4\x54\x4f\xe7\xa5\xb7\x8e\xf2\xdc\x61\x59\x61\xe2\xad\xaf\xd9\x77\x0f\x1b\x52\xd3\x80\x8b\x65\xf9\xcb\x33\x01\xbb\x3f\x6e\x58\x25\x29\xba\xeb\x1b\xca\xe9\x88\x2e\x37\x3f\xf5\x1c\x01\x43\x9b\x4b\x9e\x0e\x81\xfd\xf6\x94\x74\x8b\xae\x3c\xf3\x63\xf2\x62\xf7\xfc\x1a\x79\x67\x5b\xe1\x98\xb3\x1e\x1d\x6b\x9f\x42\x61\xc6\xff\xf4\xc4\x39\xae\xa7\xef\x00\x00\x00\xff\xff\xd6\xf1\x0f\x08\xf9\x01\x00\x00"), - }, - "/src/sync/sync.go": &vfsgen۰CompressedFileInfo{ - name: "sync.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 818, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\x92\x31\x6f\xdb\x30\x10\x85\x67\xf1\x57\xbc\xad\x92\x23\xc7\x69\xbb\x05\xf1\xd4\x2e\x01\x5a\x64\x48\x81\x0e\x86\x51\xd0\xd4\x29\xba\x58\x22\x55\xde\x31\x6e\x1a\xe4\xbf\x17\xb4\x8d\xda\x8e\xb3\x49\xd4\xbb\xef\xe9\xf0\x71\x36\xc3\xc5\x2a\x71\xdf\xe0\x51\x8c\x19\xad\x5b\xdb\x07\x82\x3c\x7b\x67\xcc\x93\x8d\x10\x1a\x7e\x5a\x56\x8a\x82\x39\x06\xbb\xa6\x72\xb0\xe3\x62\x92\xd8\xeb\xe7\x4f\xcb\xc5\xd2\x75\xd6\x63\x15\x42\x5f\x19\xd3\x26\xef\x10\x93\x57\x1e\xe8\xd7\x3d\x0d\xd6\xfd\x4e\x1c\xa9\x14\xec\xf3\x15\x5e\x4c\xc1\x2d\x26\x82\xf9\x1c\x57\xf9\xad\x70\x1d\xae\xf7\xe4\x23\x56\x51\x1c\x8a\x17\xb2\xc4\x1c\x76\x1c\xc9\x37\xe5\xc9\x71\x0d\xd7\xe5\xec\xcd\xd4\x75\xa6\x78\x35\xc5\x44\xa6\x53\xf3\x6a\xcc\x6c\x86\x43\xff\xf7\xa4\xf4\x07\x2c\xe8\x79\x4d\x47\xe7\x35\x56\x49\xd1\x86\x88\x31\x86\x96\x7b\xf6\x0f\x70\xc1\x2b\xf9\x86\x1a\x6c\xa7\x48\x2e\x33\x6b\x47\x38\xa4\x58\xe0\x83\x42\xd2\x38\x86\xa8\xd4\xd4\x90\x80\xc7\x24\x8a\x24\x04\xed\x08\x62\x07\x02\x0f\x63\x4f\x03\x79\xb5\xca\xc1\x6f\x49\x3f\xee\xbe\xde\x5d\xe3\xd6\x3f\x91\x28\x3f\x58\xcd\x69\x96\x4b\xdc\xb6\x60\xfd\x20\x18\x83\x08\xaf\x7a\x82\x86\xc3\x78\x9d\x7f\x4b\xb8\xa1\x88\x26\xe4\x7e\x09\x35\x82\x76\x14\x37\x2c\x84\x48\x43\x78\xda\x81\xe0\xc2\x90\x27\x2e\xb7\xee\xce\x55\xec\x16\x99\xbf\xf3\xe5\xdc\x5e\xa4\x9e\xac\xbc\xb5\x37\x91\x8b\x0b\x63\x8a\x4d\x96\x76\xe2\x62\x2b\xb6\x27\x5f\x6e\xaa\x83\xdc\x48\x9a\xa2\xcf\x6a\xcc\x5e\xf4\x66\x71\xb5\xcc\xe3\xf9\xe9\xe3\xf5\xd2\x9c\x79\xde\xbc\x0b\x6a\xa8\x27\xa5\x23\xfb\x35\xa4\xfa\xcf\xbd\x99\x42\x63\xa2\x6c\xfe\x64\x0b\x1f\x94\xdb\xe7\x6f\x2c\xfa\xa5\x23\xb7\x2e\x85\xff\x12\xf2\x32\xa3\xc6\x0a\x2f\x6f\xe3\xce\xfa\xfb\x91\x7d\xc9\x60\xaf\xd5\xf6\x26\xe6\xf2\xdd\x12\x68\x6d\x2f\xb9\xe2\x5f\x00\x00\x00\xff\xff\x5e\xef\xdf\x22\x32\x03\x00\x00"), - }, - "/src/sync/sync_test.go": &vfsgen۰CompressedFileInfo{ - name: "sync_test.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 240, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd7\x57\xd0\x4e\x2a\xcd\xcc\x49\x51\xc8\x2a\xe6\xe2\x2a\x48\x4c\xce\x4e\x4c\x4f\x55\x28\xae\xcc\x4b\x8e\x2f\x49\x2d\x2e\xe1\xe2\xca\xcc\x2d\xc8\x2f\x2a\x51\xd0\xe0\xe2\x54\x02\x09\x64\xe6\xa5\x2b\x71\x69\x72\x71\xa5\x95\xe6\x25\x2b\x84\xa4\x16\x97\x04\xe4\xe7\xe7\x68\x94\x28\x68\x41\x25\xf5\x42\x34\x15\xaa\xb9\x38\x4b\xf4\x82\xb3\x33\x0b\x34\x34\xb9\x6a\xd1\x94\xba\x3b\x93\xa0\x38\x28\x35\x27\x35\xb1\x38\x95\x48\x1d\xce\xf9\x79\x29\xce\xf9\x05\x95\x78\x95\x03\x02\x00\x00\xff\xff\x93\xcf\x90\x60\xf0\x00\x00\x00"), - }, - "/src/sync/waitgroup.go": &vfsgen۰CompressedFileInfo{ - name: "waitgroup.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 446, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\xd0\x4b\x4e\xc3\x30\x10\x06\xe0\xb5\xe7\x14\x3f\x5d\x54\x0e\x08\xd4\x96\x1d\x6a\x90\x58\x71\x04\x16\x88\x85\x71\xdc\xc4\x6a\x3a\x89\x92\x31\x55\x54\xe5\xee\xc8\x26\x40\x78\x34\xab\xe8\xf7\xe8\x9b\x47\x6b\xec\xde\x94\x0e\xfd\xc0\x96\x48\x86\xd6\xe1\xc9\x78\x79\xec\x9a\xd0\xa2\x97\x2e\x58\xc1\x89\x94\x6d\x02\x8b\xeb\xe0\x59\x48\xd9\x0a\xe9\xb3\x95\xe1\xa9\xe6\x34\x12\xa9\x5e\x8c\xb8\x35\x9e\xd7\x9b\x97\xd7\x41\x1c\xa9\xde\x1d\x0c\x80\xe0\x59\x6e\x37\x34\x12\xed\x02\x5b\xe8\x63\x89\xcb\xaf\x26\x19\x1e\x8a\x42\x17\xae\x16\x13\xf5\x2c\x76\x3b\x96\x37\x9f\x0d\xaf\x72\xa4\x37\x52\x7e\x87\x59\xbe\xc5\x2a\x56\xaa\xd6\xb0\xb7\x7a\x11\xc7\xbf\x03\xbb\xd2\x88\x7f\x9b\xaf\x30\xd5\x2f\x32\x52\xe3\x6f\xe3\x1e\x2b\x2c\x97\x29\xa9\x90\xe7\x60\x5f\x27\x73\x0a\x70\x30\x7b\xa7\x7f\x2c\xf9\x9f\x92\xe7\x73\xe6\xe2\x9b\xb1\x75\xd3\x3b\x9d\xe2\x6c\xa6\xb2\xaf\xa3\x72\xee\x1a\xf1\x57\xa7\x2b\xfc\x1d\x36\xaa\xdb\xeb\x04\x7d\x10\xef\x01\x00\x00\xff\xff\x61\x38\x6e\x82\xbe\x01\x00\x00"), - }, - "/src/syscall": &vfsgen۰DirInfo{ - name: "syscall", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/syscall/syscall.go": &vfsgen۰CompressedFileInfo{ - name: "syscall.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 1281, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x94\xbf\x6e\xdb\x30\x10\xc6\x67\xf1\x29\x2e\x42\x01\x4b\x88\x22\x36\xab\x01\x2f\xc9\x10\x64\x6a\x80\xb6\xe8\x90\x66\x20\xa5\x93\x7c\x0e\x7d\x14\x48\xca\x4d\x5a\xf8\xdd\x0b\x9a\x52\x63\x3b\x40\x0b\x74\x13\x44\xde\x9f\xef\x7e\x1f\x4f\x4a\xb8\xd4\x23\x99\x16\x36\x5e\x88\x41\x35\xcf\xaa\x47\xf0\xaf\xbe\x51\xc6\x08\x41\xdb\xc1\xba\x00\x85\xc8\xf2\x91\xbd\xea\x30\x17\x22\xcb\x7b\x0a\xeb\x51\xd7\x8d\xdd\xca\xde\x0e\x6b\x74\x1b\xff\xf6\xb1\xf1\xb9\x28\x85\xd8\x29\x07\x3f\x94\x63\xe2\xfe\xc1\x11\x07\x6c\x61\x05\x9d\x32\x1e\x0f\x47\x86\x18\x6f\xc6\xae\x43\x07\x8f\x4f\xfa\x35\xa0\x10\xdd\xc8\x0d\x10\x53\x28\x4a\xf8\x25\xb2\x8d\xaf\xef\x8c\xd5\xca\xd4\x9f\x31\x14\xf9\x87\xce\x8c\x7e\x7d\x6b\xd9\x5b\x83\x79\x05\x1b\x5f\xdf\x73\x40\xc7\xca\x7c\xd2\x1b\x6c\x42\x11\xe3\x53\x68\x46\x1d\x18\xe4\xe2\xad\x48\x09\x17\x2b\xf8\x78\x38\x3b\x4a\x7c\x17\x13\x37\x53\xca\xb2\xbe\x55\xc6\x14\xb9\xb1\x7d\x5e\x81\x0f\x8e\xb8\x3f\xce\x50\xc6\xd8\xa3\xb6\x57\xc0\x64\x44\x96\xed\x45\xb6\x2f\x4b\xb1\x9f\x04\x0c\x51\xec\xb7\x24\x3c\x75\x43\x1d\x5c\x9c\x4d\x22\xf6\xf1\x8f\x36\xd0\x39\xeb\xf2\x0a\xf2\x29\x74\x19\xa1\x04\xdc\x42\x04\xe3\x81\x6d\x00\xb5\x53\x64\x94\x36\x58\x81\x47\x84\x75\x08\x83\x5f\x4a\xf9\x57\x3a\xda\x58\x2d\xb7\xca\x07\x74\xb2\xb5\x8d\x9c\x48\xfb\x7a\xdb\xe6\xa5\x88\x62\xde\x41\x0b\x6e\xc4\x53\x79\x5f\xec\xc4\xa1\xd0\x13\xbd\x83\xd0\xde\x3e\x9c\x9c\xc2\x72\x05\x67\x2a\xcf\xaf\xc4\x9a\xd4\xc1\xbb\xc8\x8b\x43\xe4\x57\x6e\xb1\x23\x9e\x06\x76\x7e\xa9\xbe\xe7\x9d\x7d\xc6\xe2\xbd\x13\xf4\x01\x96\xc3\x30\x3a\x8e\x9a\xc4\x29\x37\x35\x0c\xc8\xed\x11\xdb\x0a\x74\x5d\xd7\xa5\xc8\x3a\xeb\x92\x7f\x62\xeb\xc4\x2d\xbe\xdc\xbc\x06\x3c\xb9\xb9\xf8\xce\x8b\x32\x59\x8c\x60\xb5\x82\xab\xeb\xe4\x2a\xed\x50\x3d\x27\x3b\xfc\xa7\xc3\x1e\x97\xf4\x54\x96\x20\x25\xb4\x96\x17\x01\x46\x8f\x69\xdc\x86\x2b\xf0\xc4\x0d\x02\x05\x68\x2d\x26\xfa\xf8\x92\x34\xd3\x4f\x84\xed\x68\x02\x45\x0e\xd0\xac\x95\x53\x4d\x40\xe7\xc5\x99\x5b\x8f\x0a\xd1\xe5\xf5\xf2\x29\x0e\x66\xa6\x3a\x7a\x2c\x06\x48\x2f\xbc\x7e\xb0\x91\xbc\x3b\x20\x95\x12\xd8\x5e\xd9\x21\xde\x94\xf2\x6d\x24\x40\x1e\x1a\x3b\x10\xb6\xd0\x39\xbb\x85\x58\xdb\xc3\xbc\x3e\x82\x05\xb5\xb3\xd4\x42\x5a\x1f\xc4\x7d\xec\xbc\x48\x1a\xc2\x1a\xc1\xa1\x32\xf3\x92\xf9\x13\x15\x95\xf1\x22\x94\xf5\xbc\x09\xe6\xf1\xfb\xc9\x64\x15\x34\x90\xcc\x46\x1c\x62\x77\x11\x17\x55\xa0\x23\x2d\xa7\x38\x2e\xae\xf9\xf9\xeb\xc8\xa6\x49\x68\x92\x11\x80\xa6\xc7\x2a\xe6\x1f\x57\xd7\x62\x2f\x7e\x07\x00\x00\xff\xff\xfd\x00\xda\x9e\x01\x05\x00\x00"), - }, - "/src/syscall/syscall_unix.go": &vfsgen۰CompressedFileInfo{ - name: "syscall_unix.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 2931, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xe4\x56\xdd\x6e\x1b\x37\x13\xbd\x5e\x3e\xc5\x78\xf1\x21\xe0\x46\xfc\x56\x3f\x6d\x8d\xa2\xae\x2e\x5c\x43\x35\x04\xb8\x71\x10\xc9\x4d\x8a\x20\x30\x28\xed\xac\x4c\x69\x45\xaa\x24\x57\x8e\x90\xe8\xdd\x0b\xfe\xac\x25\x4b\xba\x49\x0d\xf4\x26\x77\x8b\x9d\x33\x33\x87\x87\x87\x43\xb6\xdb\xd0\x9a\xd4\xa2\x2a\x60\x6e\xd8\xd9\xa3\x90\x85\x7a\x34\x84\xac\xf8\x74\xc1\x67\x08\x66\x63\xa6\xbc\xaa\x08\x11\xcb\x95\xd2\x16\x28\x49\x52\x5d\x4b\x2b\x96\x98\x92\x24\xad\xa5\xe1\x25\xa6\x84\x24\xe9\x4c\xd8\x87\x7a\x92\x4f\xd5\xb2\x3d\x53\xab\x07\xd4\x73\xb3\xfb\x98\x9b\x94\x64\x84\x94\xb5\x9c\x42\x4c\xbf\x47\xb9\x36\x34\x83\x8f\x9f\x8c\xd5\x42\xce\xe0\x0b\x49\x56\x5a\x4d\xd1\x18\xf8\xa5\x0f\x73\x93\x5f\x57\x6a\xc2\xab\xfc\x1a\x2d\x4d\x63\x24\xcd\x48\x22\x4a\x68\x70\x7d\x8f\xbb\x93\x05\x96\x42\x62\xe1\x4a\x24\x1a\x6d\xad\x25\x48\x51\x91\x64\x4b\x92\xb9\x19\xc8\xb5\x2b\x18\x73\x42\x39\x94\x6b\x57\x0a\xe5\x7a\x81\x9b\x53\xfd\x6e\x27\x73\x9c\xda\x34\xcb\xaf\x78\x55\xd1\xd4\xa1\x52\x06\xbe\x58\xc8\xf3\x49\x4b\xbe\x40\xda\x2c\x80\x41\x2c\x97\xdf\xa0\x9c\xd9\x07\x9a\x65\x24\x29\x95\x06\xe1\xa0\x9d\x0b\x10\xf0\xeb\x11\xe4\x02\x44\xab\xe5\x79\x2f\x70\xe3\x70\x0d\x60\x28\x0b\xfc\x4c\x45\x96\x8f\x7c\x71\x9a\x91\xc4\xb7\xfd\x28\x3e\x41\x1f\x1c\xb8\x05\x69\x3f\x85\x56\x20\xe5\x59\x2f\x70\xb3\x8f\xdf\x92\x46\x0c\x97\x48\xb6\x51\x7f\x83\x16\xe5\xfa\x7e\x4a\x17\x0c\xd6\x10\xb8\x67\xff\x46\xfd\xb3\x13\xea\x1f\xab\x9c\x8f\x1c\x33\x06\x6b\xcf\x68\x4b\xc8\x9a\xeb\xc6\x56\x7f\xa8\xa2\xae\x10\x5e\xcf\x4d\x1e\x04\xf7\x41\x5e\x69\xe4\xc5\x66\xac\x05\x16\x63\x75\xa3\x78\x01\x7d\x28\x79\x65\xd0\x87\x97\x42\xd6\xe6\x56\x22\xf4\xe1\xff\xdd\x66\x4d\xa1\x1e\x95\x7c\x89\x4f\x4b\xda\x95\x75\xd4\x0a\x2c\x51\x83\x43\xd3\x2c\x1a\x65\xaa\xd6\xa8\xbd\xb2\xed\x36\xec\x7c\x03\xa2\x84\x18\xc4\x82\x24\x5b\x1a\x96\xfd\x9c\x73\xbf\xef\xa1\xae\x90\x28\x4f\x51\x76\x91\x67\x66\x74\xfb\x91\x9c\x5c\x9b\xd5\x35\x7a\x42\x7f\xd7\x42\xe3\x09\xfd\x63\xc4\xe9\x9f\x78\x72\x01\x78\xca\xfe\xc9\x8a\x4b\x31\xa5\xa9\xc7\xba\x8e\x07\xb4\x9b\xe4\x7c\x28\xd7\x6a\x81\x34\x8d\xf1\xf4\x99\x61\x9e\x25\x79\x0e\x4e\xd9\xec\xc9\x43\xa3\xa8\xb7\xd5\x7c\xc5\x80\x77\x19\xf0\x1e\x03\xfe\x03\xd4\x42\xda\x95\xd5\x19\x50\xdd\x65\xa0\x7b\xcd\x0f\x06\xa8\x35\x0c\xb4\x96\xca\xab\x2f\x4a\x28\xdd\x42\x9b\x8d\x4b\x47\x0d\x8d\x0b\x28\x9d\xb3\x1a\x71\xb5\x43\x95\x0d\xdb\xc3\x7e\xd9\xee\xc0\xc7\x46\x54\xc7\xa3\xd3\xc9\xf2\xa1\xb4\x34\xcb\xd8\x51\xa8\xbb\x0b\x79\x46\x4f\x81\x5e\x13\xf0\x5a\x88\x12\x5c\x3f\x27\xf3\xe8\xaf\xd1\xfd\xfb\x77\xc3\xf1\x00\x5e\xbd\x02\xca\xbb\xee\x5f\x17\xbe\x7e\x85\xf0\xd9\x0b\x8e\xe2\x5a\xf3\x4d\xdc\xbe\xa1\xb4\xa8\x25\xaf\x82\x01\x29\xef\x39\xaa\xa6\x12\x53\xdc\x1b\x1c\x93\x8d\x45\x06\x3e\x6d\x7f\x68\x24\xc7\xf9\x3e\x33\x9c\xa5\xf4\x7f\x3e\x21\x8d\x89\x99\x3f\x75\x42\xda\xb1\xba\x52\xd2\xa8\x0a\x23\xf8\x58\x9a\x83\x46\x0c\x3a\x0c\x3a\xa7\x96\x3a\xf8\x30\x1c\x07\xf5\xc3\xac\xce\xaf\x15\x7e\x16\x36\x0e\x15\xdf\xed\x3d\xd7\x32\xce\x99\x83\x2e\xcd\xf9\x0c\xf5\x07\x97\x57\x57\x83\xd1\xa1\x71\xce\x8f\x76\x92\x01\xff\x91\x01\xff\x89\x01\x3f\x7f\xb1\x8b\xce\xbf\xd1\x46\xfb\xcd\xff\x13\x4b\x9d\xf5\xa1\xd7\xe9\xc1\x17\x68\xb7\x61\x81\x5a\xe6\xca\x68\xac\x90\x1b\x04\x25\xe1\x76\x04\x1f\x18\x3c\xf0\xd5\x0a\xa5\x01\x21\x41\x48\x61\x41\x95\x90\x2a\x93\x42\xbc\x9a\x9b\x6d\xdf\xdb\x88\xed\xb7\xed\xc5\x3b\xfe\xf8\x5d\x9c\xe3\x97\xf8\x75\xa7\xd1\xf7\x6a\xd9\x97\xa8\xf7\xdb\xc6\xe2\x5b\xab\x7f\xd7\x6a\x19\x9f\x25\xe6\xe9\x76\xa6\xaf\xc3\xf4\x43\xad\x95\xf6\xd2\xec\x8f\xcf\xfd\xdb\xef\x4e\x48\xfb\xf3\xa5\x9f\x79\x59\xfe\x06\x1f\x69\x85\x92\x9a\x0c\x5a\xd0\x6d\x5e\x58\x0c\x26\x2e\x51\x73\x39\x43\x08\x73\xd5\x21\xe2\xed\x3c\x71\x73\xad\x73\x78\x23\x33\x18\x0c\xdf\xfc\x79\x79\xd3\xdc\xcc\x7e\x38\x8e\xd0\xc6\x97\x17\x83\x49\x10\xe0\x20\x10\x9a\x33\xe8\xec\xb4\x08\x4b\xc9\x68\x78\x0d\xe7\x6f\x95\x70\xc3\x3b\x8e\xdb\x3b\xff\x93\x66\x4e\x67\xf7\x0e\xd8\x92\x7f\x02\x00\x00\xff\xff\xba\x7d\x55\xf6\x73\x0b\x00\x00"), - }, - "/src/syscall/syscall_windows.go": &vfsgen۰CompressedFileInfo{ - name: "syscall_windows.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 2363, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x95\x5f\x6f\xdb\x36\x10\xc0\x9f\xa3\x4f\x71\xf0\xc3\x40\x7a\x5c\x1c\xb9\x4b\x96\x14\xf0\x43\x10\xbb\xe9\x00\x77\x29\x12\x17\x05\x56\x14\xc5\x49\x3c\xcb\x6c\x29\x52\x20\x29\xa3\x4e\x9a\xef\x3e\x50\x7f\x6c\x67\x49\x81\x0d\x1d\x82\xbd\x48\xe4\xdd\xf1\xee\x77\x7f\x44\x8d\x46\xf0\x73\x56\x2b\x2d\xe1\xb3\x4f\x92\x0a\xf3\x2f\x58\x10\xf8\x8d\xcf\x51\xeb\x24\x51\x65\x65\x5d\x80\x81\xab\x4d\x50\x25\x0d\x92\x64\x8d\x0e\x4a\x65\x6a\x7f\x65\x08\x26\xf0\x4b\x9a\x24\xcb\xda\xe4\x70\xd3\x1e\x61\xc1\x61\x25\xc0\xa0\x2b\xbc\x00\x4c\x05\xe0\x58\x00\xbe\x80\x5a\x99\x50\x05\xc7\x81\xb9\x54\x80\x1b\xf7\x02\x01\xe4\x1c\xcc\x9c\x33\x96\xc3\x5d\x72\x50\x39\x65\xc2\x7b\x74\x46\x99\x82\xf1\xe4\xc0\x51\xa8\x9d\xe9\xad\x59\x1f\x9a\x0b\x38\x12\x30\x3b\xbf\xb8\x98\xdd\x24\xf7\x0f\x19\x4e\xbe\x07\x21\x00\x7f\x15\x80\xc7\x02\xf0\xe4\x39\x81\xce\xfe\x09\x90\x00\xfc\x4d\x00\x9e\x0a\xc0\xb3\xe7\x84\x4b\xc7\xff\x96\x2e\xda\x1c\xc5\x47\xb4\x4c\xc7\xcf\x0a\x7b\xfc\x83\xb0\xf1\x11\x6d\xd3\x68\x9c\x1e\x3f\x0b\xbb\xb6\x28\xb5\xca\x1c\xba\x0d\x5b\x2a\x4d\x06\x4b\x82\x61\x3c\x9a\x9e\x70\x60\x2b\x34\x52\xd3\x8f\x07\xfe\x5b\xd4\x82\x42\xe5\x6c\x8e\x52\x3a\xf2\xfe\x51\x94\xa8\xdb\x81\x9c\x72\x60\x51\xf2\x9f\x53\x30\x09\xc3\x39\xde\x6e\xa6\xf3\x39\x87\xb9\x45\xc9\x78\x74\x6d\x5d\xf4\xda\x79\xf9\x69\x3a\x9f\xcf\xa2\xec\xee\x8d\x2f\x5e\xc2\xc0\x6f\x7c\xa0\x12\x62\xbf\x3d\x18\x1b\x00\xd7\xa8\x34\x66\x9a\x04\x78\x22\x58\x85\x50\xf9\x97\xa3\x51\xa1\xc2\xaa\xce\x0e\x73\x5b\x8e\x0a\x5b\xad\xc8\x7d\xf6\xbb\x45\xa6\x6d\x36\x2a\xd1\x07\x72\x23\x69\xf3\x51\x77\xa5\xf9\xc3\x52\x0e\xee\x77\x78\x55\x8b\xf7\xd6\xd9\x9c\xc3\x2b\x65\xfe\x67\x7c\x05\x85\x9b\x20\x5f\x37\xbd\x63\x2b\x50\x26\x70\x60\x4b\x09\xad\xa4\x69\x8d\x5a\xc2\x0a\x26\x13\xb8\x59\x4c\x3f\x5d\xbd\x5b\xbc\x7d\xb7\xf8\xf4\xfa\xfc\x8f\xe9\x7c\x16\x95\x7d\x0a\x69\x72\x70\xff\xd0\x74\x76\x7d\x7d\x75\xfd\x84\xe5\xb8\xb1\xec\x36\x47\x5b\x90\x4b\x0a\x17\xd6\x78\xab\xe9\x8d\x95\xc4\xf2\x76\xdd\x71\x08\x28\xad\xec\x26\xe9\xc5\x98\x03\x8b\xc3\xd3\x54\x91\xef\x95\x71\x5a\x97\xe5\xa6\xad\xe3\x2e\xc1\xf7\x4e\x05\x7a\xa5\x62\x76\xed\x80\xf6\x1e\xb3\x7a\x09\x1f\x3e\x66\x9b\x40\x02\xa4\x35\x5b\xef\x02\xec\x9a\x9c\xc6\xaa\x22\x09\xc3\xab\xed\xfa\x51\xd4\x98\x6c\xeb\x72\x32\x81\x14\xbe\x7d\xdb\xdb\x8e\x9b\x8c\x9b\xa1\x5e\xd8\x2e\x2f\x96\xd5\x4b\x9e\x1c\x1c\x0c\x9b\x68\x13\x68\xc3\x31\x4d\xa6\xd1\xf0\x5d\x89\x8c\xd2\x4d\x91\xbe\xf3\x51\x44\x75\x9f\xde\xec\xab\x0a\x71\xb6\xe2\x17\x48\x5f\x55\xc8\x63\x9d\xfa\x32\xc5\xd2\xb4\xff\xd5\xc3\x4b\x1b\xb5\x8c\x3f\xac\x77\x59\xa2\x91\x73\x65\x88\x71\x60\x79\x29\x77\x97\xc6\xb6\xaa\xdb\x03\x7b\xd6\x0b\x7b\xee\x8a\xf5\xfe\x01\x01\xe8\x8a\x1c\x86\x7d\x7f\xd0\x15\x6b\x18\x7e\x38\x4d\xcf\xc6\x1f\xbb\x57\x6f\xf8\x64\xeb\x8c\xd2\xe2\xe9\xfe\x5d\x52\x20\xb3\x66\x5f\x68\x03\x3e\x38\x65\x0a\x0e\x6c\x8d\xba\xa6\x6e\x2b\x60\x69\x6b\x23\x21\xb3\x56\xef\x7b\x1c\x0c\x04\x2c\x51\x7b\xda\xf7\xb4\x50\x25\xfd\x69\x0d\xfd\x6e\x96\xd6\x95\x18\x94\x35\x2c\xdc\x2a\x18\x46\xc5\xad\x35\xa4\x76\x8a\x78\x63\xe7\xd0\xcf\xc4\x93\xd4\x47\x8f\x99\xc3\xa6\xa2\x3d\x61\x84\xac\xf3\x70\xb7\xbd\x0e\xf6\x95\x1c\x9a\x17\xe3\x5d\x2a\x0f\xe8\x93\xfb\xe4\xaf\x00\x00\x00\xff\xff\x4f\x7e\x0c\x93\x3b\x09\x00\x00"), - }, - "/src/testing": &vfsgen۰DirInfo{ - name: "testing", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - }, - "/src/testing/example.go": &vfsgen۰CompressedFileInfo{ - name: "example.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 1424, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x54\x5d\x6b\xf3\x36\x14\xbe\x96\x7e\xc5\xa9\x20\x45\x5a\x5d\x85\xdd\x06\x7c\x51\xb6\x06\x0a\xa5\x2b\xcd\x7a\x57\x18\xaa\x73\xec\x6a\xb5\x25\x23\xc9\x49\xc7\x9a\xff\x3e\x74\xec\x7c\x8e\xf7\xe6\xbd\x09\x91\x2c\x3d\xe7\xf9\x38\x47\xf3\x39\xdc\xbc\x0f\xb6\x5d\xc3\xdf\x91\xf3\xde\x54\x9f\xa6\x41\x48\x18\x93\x75\x0d\xe7\xb6\xeb\x7d\x48\x20\x39\x13\x75\x97\x04\x67\xc2\xc7\xfc\x1b\x53\xb0\xae\xa1\xbf\xc9\x76\x28\xb8\xe2\xbc\x1e\x5c\x05\x61\x70\xf7\x5f\xa6\xeb\x5b\x94\xd8\xc0\x83\x4b\x18\x9c\x69\xa7\x2d\x05\xd2\x7f\xc2\xbb\xf7\xad\x82\x7f\x39\xb3\x35\xfc\x52\x7d\x98\x94\xfe\xc9\x2b\x56\x77\x49\x3f\x07\xeb\x52\x2d\x45\x59\x96\xf0\xf2\xfa\x04\x00\xb3\xf8\xe6\x44\x01\xd8\xe8\x27\xd3\xa1\xe2\x6c\xc7\x39\x9b\xcf\xe1\x37\xd3\xa7\x21\x20\xc4\xb4\xf6\x43\xd2\x9c\x8d\x7f\x60\x51\x82\x8f\x7a\x45\x0b\xce\xb6\x05\x60\x08\x79\x33\x61\xd7\x2f\x6d\x8b\x52\x68\x01\x37\x7b\x3c\xb8\x01\xa1\x27\x08\xa1\x88\x52\x3e\x7f\x55\x82\xb3\xed\x81\xd5\xb2\xcf\xb4\x5a\x27\x47\x64\x0c\x81\x60\x15\x67\xcc\x47\x7d\xff\x65\x93\xfc\x95\x98\xb1\x43\x69\x28\x61\xcb\x33\x29\x13\x88\x53\x76\x49\x3f\xf9\xad\x54\x9c\xf9\x4f\x28\x21\x85\x01\x27\x25\x2d\x1a\x07\x43\x0f\xd6\x81\x81\x35\xd6\x18\x02\xae\xa1\x32\x6d\x0b\xd1\xc3\x16\xa1\x32\x0e\x02\x56\x7e\x83\x01\x6c\x0d\xe9\x03\x01\x47\x47\xa1\x37\xce\x56\x51\x73\x46\xf7\x20\x67\x20\xc9\x5c\xb6\x8e\x89\x84\xd7\x5d\xfa\x7d\x08\x26\x59\xef\xe4\x91\x85\x5e\x0d\xef\x92\xd8\x29\xc5\x39\x1b\x79\xf8\x88\x50\xdb\x16\x0b\x08\x18\x93\x3f\xb8\x5b\x40\x83\x09\xfc\x90\x7a\x72\x9a\x6d\x35\x9d\x95\x93\x01\x07\xc5\x71\x72\x9d\xd1\x9d\x80\x66\x9d\x1d\xbf\x1f\x03\xd8\x2f\xe5\x96\x9c\x97\x2a\xdf\xfe\x0b\x28\xae\x17\xec\xfc\xe6\xfc\x8b\xad\xcf\x00\x4e\x12\x39\x89\xa4\x3e\x4d\x44\x4c\x5d\xbb\xa0\x8b\xd6\x35\x13\x1f\x92\xb4\x80\xd9\x86\x1a\xe9\x04\x34\x97\x39\x0b\x90\x7a\x8b\x6d\x4c\x80\xda\xd8\x16\xc6\x26\xe7\x8c\xe1\x5e\x01\x45\x40\xb2\x1b\x4f\xb1\x4e\x73\xa0\xff\x0c\xb6\x5b\xf5\xa6\x42\xe9\x87\x94\xbf\x6f\x8d\xfb\xc1\x01\x6c\xf4\x1f\xe4\xe4\xa4\x12\x1b\xfd\xea\x7c\x58\x63\x0e\x9d\xf4\xd9\x1a\xa2\x0f\xe9\xd1\x3a\x8c\xb2\xf1\x49\x65\xf5\xc7\x9d\x0c\xad\xe0\xfa\x9a\x3a\xb5\x3c\xf1\x85\x11\x6b\x4a\x5c\xaf\x26\x7f\x44\xe3\xd3\xe2\xcd\xe5\x29\x22\x4a\x72\xd8\xd7\x52\xd3\xb6\x28\x80\xe2\x3a\xe3\x95\x7b\x99\xed\x00\xdb\x88\x07\x4e\x59\xf2\x55\x09\x04\xf3\x73\xd5\x8f\x15\x1b\x9f\x0a\x42\x3a\x16\x1b\xdd\x20\x90\xab\x12\x84\x80\xef\xef\xcb\x59\x3c\x7b\x22\x6e\x6f\x6f\x61\x79\xf7\xf0\xb8\x80\x59\x04\x39\x8b\x2a\x83\x1f\x5f\x8a\x02\xf2\x00\x14\x04\x38\x06\x9d\xa7\xae\x36\x6d\xc4\xa3\xb4\x8b\x17\xe8\x7f\xf8\xcf\x77\xab\xd5\x09\xfe\x25\xba\x3a\xf2\xbe\x64\x4a\x73\x29\xa7\x47\x62\xc7\xd9\x4e\xaa\x71\xda\x5f\x06\xb7\x1f\x5e\xcd\x19\x36\x7a\x99\xfb\x29\x60\x1a\x82\xe3\x3b\xfe\x5f\x00\x00\x00\xff\xff\x6d\xa8\x39\x72\x90\x05\x00\x00"), - }, - "/src/testing/ioutil.go": &vfsgen۰CompressedFileInfo{ - name: "ioutil.go", - modTime: mustUnmarshalTextTime("2017-05-20T20:04:40Z"), - uncompressedSize: 1163, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x53\x61\x6f\x23\x35\x10\xfd\x6c\xff\x8a\x21\x12\xc8\xbe\x8d\x36\xbb\x69\x2f\x52\x7b\x04\xe9\xc8\x05\x74\x52\x29\x28\x6d\x05\x12\x42\x95\xb3\x3b\x2e\x43\x37\xf6\xca\xf6\x96\x44\xd0\xff\x8e\x6c\x6f\xb7\x94\x4f\x7c\x48\x76\x3c\x9e\x7d\xf3\xe6\xcd\xdb\xc5\x02\x8a\xfd\x40\x5d\x0b\x7f\x78\xce\x7b\xd5\x3c\xaa\x07\x84\x80\x3e\x90\x79\xe0\x9c\x0e\xbd\x75\x01\x04\x67\xb3\xfd\x29\xa0\x9f\x71\x36\x23\x1b\xff\x6d\x8a\x7d\x70\x8d\x35\x4f\x29\x3c\x99\x26\x3e\x03\x1d\x70\xc6\x25\xe7\x4f\xca\x81\x53\xa6\x85\x81\x4c\x38\x5b\x4e\xe7\xc3\x00\xb1\xb6\xfc\x61\x08\x78\xe4\x5c\x0f\xa6\x01\x87\x1e\xb1\x15\x72\xac\x85\xbf\x38\x73\x18\x06\x67\xc6\x84\x88\xa8\xe5\xb5\xfd\x53\xc8\xf2\xce\xd0\xf1\x5a\x19\x2b\x24\x14\x40\x26\xac\xce\x85\xf5\xe5\xf7\x18\x7a\x6a\x85\x94\x92\x3f\x8f\xa0\x06\x8f\xe1\x66\xd0\x9a\x8e\x42\x82\x0f\x8e\xcc\x43\x02\x4e\x1c\xca\x2b\xdb\x3c\x0a\xc9\x99\x83\xcb\x75\xe2\xc5\x19\x69\x70\xb0\x5e\x43\x15\xcb\x98\x83\xf5\xc4\x8b\xb3\x67\x9e\x13\xef\xea\xd5\xea\xfc\xfd\xf2\x3d\x14\x50\x57\xf5\xd9\x45\x75\xbe\x5c\x9e\xc1\x62\x01\x8d\x35\x3e\x28\x13\x3c\x68\x67\x0f\x70\x3d\x1c\xd0\x51\xa3\x3a\xd8\x61\x43\x3d\xfa\xdc\x38\x42\x4c\x14\xee\x4c\xf7\x42\x22\x0f\x3b\xca\x59\x7e\x0e\x56\x09\x32\x41\xd4\x78\x01\x05\xb8\x2f\x6b\xbc\x90\xf2\xd7\xfa\xf2\xb7\x38\xdc\x62\x01\x1f\x21\x4e\x18\xc8\x1a\xd5\x41\x63\xfb\x13\x58\x0d\x64\x87\x40\x5d\x79\x8b\x87\xfe\x3b\xea\x70\x0e\xc1\x82\x7a\xb2\xd4\x02\x1e\x83\x53\x90\x97\xe9\xcb\xac\x4e\x18\xcb\x44\xef\x50\xd3\x71\x14\x48\x82\xd0\xf0\xce\xfa\x32\x23\xa0\x73\xf1\x67\x9d\x8c\x92\xb4\x94\xc4\xb2\x3e\xf5\xf8\x44\x4e\x48\xce\x99\x69\xac\xd1\x1d\x35\x21\xde\x55\x9c\x69\xeb\x80\x52\xfc\x01\x08\xbe\x86\xba\xaa\xaa\x18\x16\x45\x92\xd5\xa8\x03\xc6\xdb\x08\x56\x8c\x5d\xe3\x02\x7f\x52\xe1\xf7\x1b\xec\x95\x53\x21\xb6\x2b\x60\xe4\x55\xbc\xd9\x23\x67\x4c\x67\x5a\x89\xc7\x8f\x3d\x9a\x34\x44\x44\x9d\xa7\xcc\xfd\xee\xd3\xcf\xbb\xbf\x53\xb4\xd9\x6d\x3f\xde\x6e\x73\xbc\xfd\x65\x73\x35\x87\x6a\x55\x55\x11\x83\x74\xac\xfd\xec\xb7\x47\xf2\x41\xa0\xcb\xf3\xa5\xfc\x34\x4e\x51\x7c\x78\x3d\xc0\x37\x50\x67\x5b\xb0\xff\x1a\x68\xcc\xbc\x71\xcb\x6b\xd5\xeb\x8e\x59\xf4\x10\x63\x8d\x35\x81\xcc\x80\x3c\x9f\xf7\x0e\xd5\x63\xb6\x57\xf2\xc0\xe4\x5e\x87\xaa\x4d\xa3\x69\xea\x30\x89\x36\x6d\x28\x07\xf3\x7f\x6d\x66\xd4\xe4\x72\x12\x65\x7a\x4b\x26\x5b\xc7\xcb\x2f\xd6\x60\xa8\xcb\xd6\xce\x76\x9b\xcd\xd2\x6b\xa9\x7b\x8b\x1a\x1d\xe8\x72\xd3\x59\x8f\x91\x6e\xfc\x5c\xf7\x83\x86\xf4\xdd\x97\xdf\x0e\x5a\xa3\xe3\xec\xfe\x45\x7c\xb2\xe5\xc6\xf6\x27\xf1\xd5\x7e\xd0\x73\xd0\xff\xb7\xcd\x98\xda\x0f\xba\xbc\xc9\xab\x97\xf3\x58\xcf\x9f\xf9\x3f\x01\x00\x00\xff\xff\x2f\x92\x73\x9b\x8b\x04\x00\x00"), - }, - "/src/text": &vfsgen۰DirInfo{ - name: "text", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/text/template": &vfsgen۰DirInfo{ - name: "template", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/text/template/template.go": &vfsgen۰FileInfo{ - name: "template.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - content: []byte("\x70\x61\x63\x6b\x61\x67\x65\x20\x74\x65\x6d\x70\x6c\x61\x74\x65\x0a\x0a\x63\x6f\x6e\x73\x74\x20\x6d\x61\x78\x45\x78\x65\x63\x44\x65\x70\x74\x68\x20\x3d\x20\x33\x30\x30\x30\x0a"), - }, - "/src/time": &vfsgen۰DirInfo{ - name: "time", - modTime: mustUnmarshalTextTime("2017-02-15T23:00:22Z"), - }, - "/src/time/time.go": &vfsgen۰CompressedFileInfo{ - name: "time.go", - modTime: mustUnmarshalTextTime("2017-02-15T23:00:22Z"), - uncompressedSize: 2387, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x56\xdb\x6e\xdb\x38\x10\x7d\x26\xbf\x62\x2a\xec\x22\x54\xe2\x48\x49\x5b\x74\xb1\x41\xbc\x40\x37\xbd\xa0\x40\x5b\x03\x9b\xf4\xa5\x45\x51\xd0\xd4\xc8\xa6\x2b\x93\x02\x49\xe5\x62\xd7\xff\xbe\x18\x52\x96\xed\xb6\x5b\x60\xfd\x24\x92\xc3\x99\x73\x0e\xe7\xe2\xb2\x84\x93\x69\xa7\x9b\x0a\x16\x9e\xf3\x56\xaa\xaf\x72\x86\x10\xf4\x12\x39\xd7\xcb\xd6\xba\x00\x82\xb3\xcc\x75\x86\xf6\x32\xce\x59\x36\xd3\x61\xde\x4d\x0b\x65\x97\xe5\xcc\xb6\x73\x74\x0b\xbf\xfb\x58\xf8\x8c\xe7\x9c\x97\x25\xbc\x93\x5f\x11\x7c\xe7\x92\xb7\xe2\x83\xd1\xf7\x50\x77\x46\x81\x34\x55\xda\xba\xd1\x4b\x04\x1f\x5c\xa7\x02\xe8\x00\x0e\x43\xe7\x8c\x07\xe9\x10\x64\x73\x27\x1f\x3c\x68\xa3\x9a\xae\xc2\x0a\xee\x74\x98\x43\x98\x6b\x0f\x5b\x88\xa2\x42\xdf\xea\x80\xf0\xe2\xea\x65\x3e\xa2\x80\x53\x54\xb2\xf3\x08\x61\x8e\x0f\x47\x0e\xc1\x20\xd2\xd5\xda\x3a\xd0\x26\xa0\x33\xb2\xd1\x2b\x19\xb4\x35\x25\xde\x1f\xac\xc1\xd6\x3b\x44\xe5\x0b\x19\xb0\x80\x6b\x44\xd0\xde\x77\x08\xf3\x10\x5a\x7f\x51\x96\xbf\xe4\x1d\x4d\x7d\xf9\xf8\x8f\x3f\x0b\x1e\x59\x6a\xa3\x83\xc8\x61\xcd\x59\x59\x82\xbc\xb5\xba\x82\x0a\x65\x05\xca\x56\x08\xd8\xe8\xa5\x36\x31\x36\x67\xb7\xd2\xc1\x17\x88\x62\x8c\x81\x64\x12\x67\x23\x38\xcb\xf9\x86\xf3\xf0\xd0\x22\xf4\xda\x93\x81\xdb\xca\xb5\xe6\x4c\x43\xfa\x69\x13\x9e\x3c\xe6\xec\x6e\x8e\xa6\x5f\x3e\x7b\xca\x59\x8b\x4e\xdb\x6a\x58\xd6\xbd\x31\x41\x13\x51\x8d\x5a\x2a\x5c\x6f\x46\xd0\x69\x13\xda\xe0\x72\xce\xa4\x9b\x6d\x1d\x6e\x8f\x39\xa3\xc8\xb6\x0b\x70\xbc\xf0\xc5\x64\xba\x40\x15\x38\x93\x2a\xe8\x5b\x04\x98\x5a\xdb\x10\xca\x81\xef\x5b\xab\x64\x93\x48\x57\x70\x31\x86\x85\x2f\x5e\x37\x76\x2a\x9b\xe2\x35\x06\x91\x91\xb0\x59\x5e\xbc\xc7\x3b\x91\x73\xe6\xc9\xa2\x2a\xae\x83\xd3\x66\x46\x1b\x9a\x36\xb4\xa9\xf0\xfe\xef\x87\x80\xc2\x8f\xe0\x48\x1c\xe5\x9c\x2d\x7e\xdc\xcf\x69\x5f\xd7\xa0\x61\x3c\x86\xd3\x73\xf8\xf6\x0d\x16\xfd\xe7\x9a\x33\xd6\x10\x8e\xb7\x56\x15\x46\x46\x51\xb3\x0f\x37\x57\x19\x67\x2c\x65\x18\x67\x1b\xfe\x83\x89\xff\xa4\x4f\xce\xe1\x02\x16\x9f\xf7\xce\x56\xd6\xd0\xd9\xa7\xcf\xf4\xb1\x5e\x1f\xdc\x19\x41\x55\x5c\xc9\xa6\x11\xd9\x0c\x03\xbd\x0d\xd9\x4c\xea\xda\x63\xc8\xf2\xe2\x8d\xa1\xc7\x3f\x86\xd3\x67\x67\x23\xa8\x65\xe3\x71\xb3\x19\xa4\xea\x1f\xf4\xbd\x34\x56\xe4\xe9\x85\x08\x76\x42\xf7\x2b\xd1\x0e\x03\xa6\x30\xcf\x9e\xc6\x40\xd1\x8b\x78\xa7\x9b\x46\x7b\x54\xd6\x54\xf9\x10\xce\xd8\x3b\x91\x83\xf0\xa8\x92\xd5\x08\x4c\xff\xfd\xe4\x71\x7c\x2b\x43\x02\x1f\x80\x1a\xc0\x18\x28\x7b\xd7\xd7\xc9\xeb\x28\xdd\x13\x06\x7e\x3f\x3c\xd8\xc5\xbb\x6e\x10\x5b\x51\xc1\x8b\xce\xc5\x0c\x8f\x31\x14\xc5\x58\xca\xaf\x28\xd4\x5c\x9a\x3e\x8d\xd7\x1b\x7a\xde\x81\x6f\x62\xf7\x9b\x4f\xf4\x6c\x17\xb2\x11\xa9\xf1\xa6\x2f\xde\x94\x7e\x22\xa6\x70\x0e\x6b\x50\x8d\xf5\x28\x54\x0e\x9b\x84\x4a\x54\xe5\x3e\xff\x9c\xb3\xcb\x53\x35\xa0\xf2\x41\xba\xe8\xd7\x89\x00\xc7\xfb\x35\x15\xf1\x85\xa2\xcf\xea\x31\x04\xd7\x21\x67\x95\xae\x6b\xc2\x2c\x42\x11\x4b\xeb\xf4\x50\xa1\x7c\x10\xe6\x40\x73\x4a\xca\x78\xf3\x2f\x38\xbf\xbc\x7c\x72\x4e\x09\x09\x65\x09\x4b\x19\xe6\xc5\x3b\x79\xff\x26\x15\xeb\x7e\x26\x6e\x6f\x5c\xc2\x59\x4c\xde\xb8\x18\xc3\x59\x3c\x0c\xc5\xb6\x00\xf7\xab\xe9\xff\x09\xc5\xd9\x3e\xbb\x98\x8c\x9c\x51\xd8\x50\xf4\x5d\xe2\xd1\xb8\x8f\xcd\x7a\xb2\x27\xe3\xe1\x90\x76\xf7\xb5\xcb\x39\x23\x60\x6c\x66\x21\x14\xb5\x08\x85\x74\xb3\xd8\xae\x18\x3d\x03\x81\x3f\x39\xcf\xf7\x54\xb7\xed\x7f\x88\x4e\xdd\x83\x82\x7e\x4f\x4b\x35\x28\xdd\x8e\xd7\xa0\x40\xce\xd9\x9d\xf4\xcf\x13\x8f\x0b\x02\x98\x38\xf1\x9f\xb0\xeb\xb3\x77\xb0\x1f\xf0\x34\x56\x56\xd4\xa5\x28\x2f\x45\x2c\x7d\x1f\xfb\x4f\x0e\xe2\x78\xbb\x3f\x02\x74\xce\xa6\xb4\xe8\x1d\xd1\xb5\x8f\xd6\xe0\x2b\xdd\xa0\xe8\x69\x14\xaf\x27\xff\x4c\x26\x37\x22\x3f\xc9\xca\x46\x4f\x4b\xda\x2b\xa9\x09\x68\x53\xdb\x62\xa5\xdb\x6c\x04\x14\x61\x27\x46\x6d\x9d\xc2\x8f\xba\x25\x2f\xaf\xac\xbb\x41\x1f\xa8\xf5\xad\x74\x3b\x31\xcd\x43\x14\x84\x82\xee\x77\xd4\xde\x86\x62\xa7\xa7\x5c\x45\x74\xc4\xff\x80\x4a\xf6\x7c\x89\x4e\x2b\x59\xbe\xb5\xfe\xcb\x73\x33\xc3\x06\x7d\x96\xd2\x91\xcc\x1f\x8d\xc1\xe8\xa8\x36\x6b\xa5\xd1\x4a\x64\x4a\x1a\x63\x43\x74\x02\x3f\xb9\x1b\xa7\x66\x48\xc1\x2f\x20\x83\x13\x72\x53\xbc\x24\x5d\x04\x55\xd6\x86\xb3\xd5\xd0\x5d\x63\xdb\xcf\x76\x7d\x13\xc6\x70\xbc\x22\x1a\x65\xb9\xeb\xdb\xa0\x3d\x28\xdb\x6a\x9a\xc8\xce\x2e\x7b\xdd\x77\xf3\x3c\xd8\x7e\x4a\xa6\x7f\x1d\xda\xcc\xe8\x3f\x81\xf0\xda\xa8\x38\xd2\xc1\xa1\x6c\xe2\x94\x1e\xae\x54\x16\xbd\x39\x0a\xf9\x30\x71\x87\x11\xd1\x7b\x1f\x81\x82\xe9\x43\xc0\xd8\x64\x0f\x5b\xec\x77\xb5\xe2\xb7\xbd\x35\x3a\x99\xd4\xa9\xa0\xf6\xfb\x70\x9a\x53\xd9\xd6\x8e\x38\x5c\xcd\xa5\xbb\xb2\x15\x66\x23\x50\x79\xdf\xf3\xf9\x86\xff\x1b\x00\x00\xff\xff\xa0\xca\x7f\x2e\x53\x09\x00\x00"), - }, - "/src/unicode": &vfsgen۰DirInfo{ - name: "unicode", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - }, - "/src/unicode/unicode.go": &vfsgen۰CompressedFileInfo{ - name: "unicode.go", - modTime: mustUnmarshalTextTime("2016-08-31T19:22:39Z"), - uncompressedSize: 600, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x51\xc1\x8e\xd3\x30\x10\x3d\x7b\xbe\xe2\x9d\xa2\x44\xd9\x25\x5b\x8e\xab\x96\x4b\x91\x40\x08\x2e\xe5\x58\x15\x64\x9c\x49\x63\x70\xec\x68\xe2\x48\xa0\x6d\xff\x1d\xd9\xe9\x46\xdd\xdb\xf8\xcd\x9b\x37\x7e\x6f\x9a\x06\xf5\xaf\xd9\xba\x16\xbf\x27\xa2\x51\x9b\x3f\xfa\xcc\x98\xbd\x35\xa1\x65\xa2\x6e\xf6\x06\x31\x94\x3f\x8d\x9e\x18\xd6\xc7\x07\x08\x64\xf6\xfc\x80\x84\x1c\xb4\x3f\x33\x8e\xa7\xfd\x6b\x5d\xe5\x26\x5e\x48\xd9\x0e\xcb\xd0\x16\x4f\xb8\x5c\xf0\x4d\xff\xdd\xe7\xe7\xee\x86\xbf\x90\x52\xc2\x71\x16\x8f\x03\x8f\x4e\x1b\x1e\xd8\xc7\x7d\xaf\x85\xd4\x95\x94\x0b\x78\xde\xe1\x89\x54\x6f\x53\xe1\xd8\x97\xeb\xc6\x8a\x54\x17\x04\x2e\x60\x8b\xde\x66\xa5\x21\x93\x02\x6a\x94\xbd\x7d\x74\xa1\x6a\xde\x93\x52\x46\x12\x5c\xac\x83\xc7\xe1\x84\xa6\xc1\xc8\xd2\x05\x19\xb4\x37\x0c\x23\x36\x5a\xa3\x1d\x92\xe2\xa7\x30\xf6\x2c\x5f\xbe\x3f\xe3\xcc\x11\xba\x6d\x85\xa7\x09\x3d\x4b\xf2\x3e\x45\xd6\x2d\x42\x07\x13\xc6\x7f\xd6\x9f\x11\x7b\xc6\xea\x9c\x54\xb2\x9c\xdc\x97\x46\xde\x7d\x0d\x55\x72\x2a\x28\x0a\x48\xae\x6e\x8d\xcf\xb6\xca\xff\x55\x2d\xbb\xa8\xd3\xef\x5e\x3b\x1f\x13\x70\xcc\xd9\x9c\xaa\xc4\xb0\x1d\x16\xd2\x87\x14\xde\xe1\x96\xab\x5a\x53\xbb\xdf\x55\xa3\x2c\xe5\xf1\x0e\xa9\x8a\x1f\x1b\x5c\x16\x4e\xd6\x2c\x36\x55\x56\xbd\xd2\x9d\x02\xea\x65\x05\x2d\x78\x32\x80\xed\x1b\xe1\xbc\xb1\xb7\xd8\x61\x48\x24\xb0\xbb\x9d\x2e\x1d\x68\x87\x01\x35\x36\xcb\xf4\x95\x56\x59\xba\xd2\xff\x00\x00\x00\xff\xff\xba\x6a\xe6\xd2\x58\x02\x00\x00"), - }, - } - fs["/"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src"].(os.FileInfo), - } - fs["/src"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/bytes"].(os.FileInfo), - fs["/src/crypto"].(os.FileInfo), - fs["/src/database"].(os.FileInfo), - fs["/src/debug"].(os.FileInfo), - fs["/src/encoding"].(os.FileInfo), - fs["/src/fmt"].(os.FileInfo), - fs["/src/go"].(os.FileInfo), - fs["/src/internal"].(os.FileInfo), - fs["/src/io"].(os.FileInfo), - fs["/src/math"].(os.FileInfo), - fs["/src/net"].(os.FileInfo), - fs["/src/os"].(os.FileInfo), - fs["/src/reflect"].(os.FileInfo), - fs["/src/regexp"].(os.FileInfo), - fs["/src/runtime"].(os.FileInfo), - fs["/src/strings"].(os.FileInfo), - fs["/src/sync"].(os.FileInfo), - fs["/src/syscall"].(os.FileInfo), - fs["/src/testing"].(os.FileInfo), - fs["/src/text"].(os.FileInfo), - fs["/src/time"].(os.FileInfo), - fs["/src/unicode"].(os.FileInfo), - } - fs["/src/bytes"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/bytes/bytes.go"].(os.FileInfo), - fs["/src/bytes/bytes_test.go"].(os.FileInfo), - } - fs["/src/crypto"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/crypto/rand"].(os.FileInfo), - fs["/src/crypto/x509"].(os.FileInfo), - } - fs["/src/crypto/rand"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/crypto/rand/rand.go"].(os.FileInfo), - } - fs["/src/crypto/x509"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/crypto/x509/x509.go"].(os.FileInfo), - fs["/src/crypto/x509/x509_test.go"].(os.FileInfo), - } - fs["/src/database"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/database/sql"].(os.FileInfo), - } - fs["/src/database/sql"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/database/sql/driver"].(os.FileInfo), - } - fs["/src/database/sql/driver"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/database/sql/driver/driver_test.go"].(os.FileInfo), - } - fs["/src/debug"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/debug/elf"].(os.FileInfo), - } - fs["/src/debug/elf"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/debug/elf/elf_test.go"].(os.FileInfo), - } - fs["/src/encoding"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/encoding/json"].(os.FileInfo), - } - fs["/src/encoding/json"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/encoding/json/stream_test.go"].(os.FileInfo), - } - fs["/src/fmt"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/fmt/fmt_test.go"].(os.FileInfo), - } - fs["/src/go"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/go/token"].(os.FileInfo), - } - fs["/src/go/token"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/go/token/token_test.go"].(os.FileInfo), - } - fs["/src/internal"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/internal/testenv"].(os.FileInfo), - } - fs["/src/internal/testenv"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/internal/testenv/testenv.go"].(os.FileInfo), - } - fs["/src/io"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/io/io_test.go"].(os.FileInfo), - } - fs["/src/math"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/math/big"].(os.FileInfo), - fs["/src/math/math.go"].(os.FileInfo), - fs["/src/math/math_test.go"].(os.FileInfo), - fs["/src/math/rand"].(os.FileInfo), - } - fs["/src/math/big"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/math/big/big.go"].(os.FileInfo), - fs["/src/math/big/big_test.go"].(os.FileInfo), - } - fs["/src/math/rand"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/math/rand/rand_test.go"].(os.FileInfo), - } - fs["/src/net"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/net/http"].(os.FileInfo), - fs["/src/net/net.go"].(os.FileInfo), - } - fs["/src/net/http"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/net/http/cookiejar"].(os.FileInfo), - fs["/src/net/http/fetch.go"].(os.FileInfo), - fs["/src/net/http/http.go"].(os.FileInfo), - } - fs["/src/net/http/cookiejar"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/net/http/cookiejar/example_test.go"].(os.FileInfo), - } - fs["/src/os"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/os/os.go"].(os.FileInfo), - } - fs["/src/reflect"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/reflect/example_test.go"].(os.FileInfo), - fs["/src/reflect/reflect.go"].(os.FileInfo), - fs["/src/reflect/reflect_test.go"].(os.FileInfo), - fs["/src/reflect/swapper.go"].(os.FileInfo), - } - fs["/src/regexp"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/regexp/regexp_test.go"].(os.FileInfo), - } - fs["/src/runtime"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/runtime/debug"].(os.FileInfo), - fs["/src/runtime/pprof"].(os.FileInfo), - fs["/src/runtime/runtime.go"].(os.FileInfo), - } - fs["/src/runtime/debug"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/runtime/debug/debug.go"].(os.FileInfo), - } - fs["/src/runtime/pprof"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/runtime/pprof/pprof.go"].(os.FileInfo), - } - fs["/src/strings"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/strings/strings.go"].(os.FileInfo), - } - fs["/src/sync"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/sync/atomic"].(os.FileInfo), - fs["/src/sync/cond.go"].(os.FileInfo), - fs["/src/sync/pool.go"].(os.FileInfo), - fs["/src/sync/sync.go"].(os.FileInfo), - fs["/src/sync/sync_test.go"].(os.FileInfo), - fs["/src/sync/waitgroup.go"].(os.FileInfo), - } - fs["/src/sync/atomic"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/sync/atomic/atomic.go"].(os.FileInfo), - fs["/src/sync/atomic/atomic_test.go"].(os.FileInfo), - } - fs["/src/syscall"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/syscall/syscall.go"].(os.FileInfo), - fs["/src/syscall/syscall_unix.go"].(os.FileInfo), - fs["/src/syscall/syscall_windows.go"].(os.FileInfo), - } - fs["/src/testing"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/testing/example.go"].(os.FileInfo), - fs["/src/testing/ioutil.go"].(os.FileInfo), - } - fs["/src/text"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/text/template"].(os.FileInfo), - } - fs["/src/text/template"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/text/template/template.go"].(os.FileInfo), - } - fs["/src/time"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/time/time.go"].(os.FileInfo), - } - fs["/src/unicode"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/src/unicode/unicode.go"].(os.FileInfo), - } - - return fs -}() - -type vfsgen۰FS map[string]interface{} - -func (fs vfsgen۰FS) Open(path string) (http.File, error) { - path = pathpkg.Clean("/" + path) - f, ok := fs[path] - if !ok { - return nil, &os.PathError{Op: "open", Path: path, Err: os.ErrNotExist} - } - - switch f := f.(type) { - case *vfsgen۰CompressedFileInfo: - gr, err := gzip.NewReader(bytes.NewReader(f.compressedContent)) - if err != nil { - // This should never happen because we generate the gzip bytes such that they are always valid. - panic("unexpected error reading own gzip compressed bytes: " + err.Error()) - } - return &vfsgen۰CompressedFile{ - vfsgen۰CompressedFileInfo: f, - gr: gr, - }, nil - case *vfsgen۰FileInfo: - return &vfsgen۰File{ - vfsgen۰FileInfo: f, - Reader: bytes.NewReader(f.content), - }, nil - case *vfsgen۰DirInfo: - return &vfsgen۰Dir{ - vfsgen۰DirInfo: f, - }, nil - default: - // This should never happen because we generate only the above types. - panic(fmt.Sprintf("unexpected type %T", f)) - } -} - -// vfsgen۰CompressedFileInfo is a static definition of a gzip compressed file. -type vfsgen۰CompressedFileInfo struct { - name string - modTime time.Time - compressedContent []byte - uncompressedSize int64 -} - -func (f *vfsgen۰CompressedFileInfo) Readdir(count int) ([]os.FileInfo, error) { - return nil, fmt.Errorf("cannot Readdir from file %s", f.name) -} -func (f *vfsgen۰CompressedFileInfo) Stat() (os.FileInfo, error) { return f, nil } - -func (f *vfsgen۰CompressedFileInfo) GzipBytes() []byte { - return f.compressedContent -} - -func (f *vfsgen۰CompressedFileInfo) Name() string { return f.name } -func (f *vfsgen۰CompressedFileInfo) Size() int64 { return f.uncompressedSize } -func (f *vfsgen۰CompressedFileInfo) Mode() os.FileMode { return 0444 } -func (f *vfsgen۰CompressedFileInfo) ModTime() time.Time { return f.modTime } -func (f *vfsgen۰CompressedFileInfo) IsDir() bool { return false } -func (f *vfsgen۰CompressedFileInfo) Sys() interface{} { return nil } - -// vfsgen۰CompressedFile is an opened compressedFile instance. -type vfsgen۰CompressedFile struct { - *vfsgen۰CompressedFileInfo - gr *gzip.Reader - grPos int64 // Actual gr uncompressed position. - seekPos int64 // Seek uncompressed position. -} - -func (f *vfsgen۰CompressedFile) Read(p []byte) (n int, err error) { - if f.grPos > f.seekPos { - // Rewind to beginning. - err = f.gr.Reset(bytes.NewReader(f.compressedContent)) - if err != nil { - return 0, err - } - f.grPos = 0 - } - if f.grPos < f.seekPos { - // Fast-forward. - _, err = io.CopyN(ioutil.Discard, f.gr, f.seekPos-f.grPos) - if err != nil { - return 0, err - } - f.grPos = f.seekPos - } - n, err = f.gr.Read(p) - f.grPos += int64(n) - f.seekPos = f.grPos - return n, err -} -func (f *vfsgen۰CompressedFile) Seek(offset int64, whence int) (int64, error) { - switch whence { - case io.SeekStart: - f.seekPos = 0 + offset - case io.SeekCurrent: - f.seekPos += offset - case io.SeekEnd: - f.seekPos = f.uncompressedSize + offset - default: - panic(fmt.Errorf("invalid whence value: %v", whence)) - } - return f.seekPos, nil -} -func (f *vfsgen۰CompressedFile) Close() error { - return f.gr.Close() -} - -// vfsgen۰FileInfo is a static definition of an uncompressed file (because it's not worth gzip compressing). -type vfsgen۰FileInfo struct { - name string - modTime time.Time - content []byte -} - -func (f *vfsgen۰FileInfo) Readdir(count int) ([]os.FileInfo, error) { - return nil, fmt.Errorf("cannot Readdir from file %s", f.name) -} -func (f *vfsgen۰FileInfo) Stat() (os.FileInfo, error) { return f, nil } - -func (f *vfsgen۰FileInfo) NotWorthGzipCompressing() {} - -func (f *vfsgen۰FileInfo) Name() string { return f.name } -func (f *vfsgen۰FileInfo) Size() int64 { return int64(len(f.content)) } -func (f *vfsgen۰FileInfo) Mode() os.FileMode { return 0444 } -func (f *vfsgen۰FileInfo) ModTime() time.Time { return f.modTime } -func (f *vfsgen۰FileInfo) IsDir() bool { return false } -func (f *vfsgen۰FileInfo) Sys() interface{} { return nil } - -// vfsgen۰File is an opened file instance. -type vfsgen۰File struct { - *vfsgen۰FileInfo - *bytes.Reader -} - -func (f *vfsgen۰File) Close() error { - return nil -} - -// vfsgen۰DirInfo is a static definition of a directory. -type vfsgen۰DirInfo struct { - name string - modTime time.Time - entries []os.FileInfo -} - -func (d *vfsgen۰DirInfo) Read([]byte) (int, error) { - return 0, fmt.Errorf("cannot Read from directory %s", d.name) -} -func (d *vfsgen۰DirInfo) Close() error { return nil } -func (d *vfsgen۰DirInfo) Stat() (os.FileInfo, error) { return d, nil } - -func (d *vfsgen۰DirInfo) Name() string { return d.name } -func (d *vfsgen۰DirInfo) Size() int64 { return 0 } -func (d *vfsgen۰DirInfo) Mode() os.FileMode { return 0755 | os.ModeDir } -func (d *vfsgen۰DirInfo) ModTime() time.Time { return d.modTime } -func (d *vfsgen۰DirInfo) IsDir() bool { return true } -func (d *vfsgen۰DirInfo) Sys() interface{} { return nil } - -// vfsgen۰Dir is an opened dir instance. -type vfsgen۰Dir struct { - *vfsgen۰DirInfo - pos int // Position within entries for Seek and Readdir. -} - -func (d *vfsgen۰Dir) Seek(offset int64, whence int) (int64, error) { - if offset == 0 && whence == io.SeekStart { - d.pos = 0 - return 0, nil - } - return 0, fmt.Errorf("unsupported Seek in directory %s", d.name) -} - -func (d *vfsgen۰Dir) Readdir(count int) ([]os.FileInfo, error) { - if d.pos >= len(d.entries) && count > 0 { - return nil, io.EOF - } - if count <= 0 || count > len(d.entries)-d.pos { - count = len(d.entries) - d.pos - } - e := d.entries[d.pos : d.pos+count] - d.pos += count - return e, nil -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/bytes/bytes.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/bytes/bytes.go deleted file mode 100644 index 2bf919efd..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/bytes/bytes.go +++ /dev/null @@ -1,43 +0,0 @@ -// +build js - -package bytes - -func IndexByte(s []byte, c byte) int { - for i, b := range s { - if b == c { - return i - } - } - return -1 -} - -func Equal(a, b []byte) bool { - if len(a) != len(b) { - return false - } - for i, c := range a { - if c != b[i] { - return false - } - } - return true -} - -func Compare(a, b []byte) int { - for i, ca := range a { - if i >= len(b) { - return 1 - } - cb := b[i] - if ca < cb { - return -1 - } - if ca > cb { - return 1 - } - } - if len(a) < len(b) { - return -1 - } - return 0 -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/bytes/bytes_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/bytes/bytes_test.go deleted file mode 100644 index 3f9766932..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/bytes/bytes_test.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build js - -package bytes_test - -import ( - "testing" -) - -func TestEqualNearPageBoundary(t *testing.T) { - t.Skip() -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/rand/rand.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/rand/rand.go deleted file mode 100644 index 0e63a76e1..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/rand/rand.go +++ /dev/null @@ -1,49 +0,0 @@ -// +build js - -package rand - -import ( - "errors" - - "github.com/gopherjs/gopherjs/js" -) - -func init() { - Reader = &rngReader{} -} - -type rngReader struct{} - -func (r *rngReader) Read(b []byte) (n int, err error) { - array := js.InternalObject(b).Get("$array") - offset := js.InternalObject(b).Get("$offset").Int() - - // browser - crypto := js.Global.Get("crypto") - if crypto == js.Undefined { - crypto = js.Global.Get("msCrypto") - } - if crypto != js.Undefined { - if crypto.Get("getRandomValues") != js.Undefined { - n = len(b) - if n > 65536 { - // Avoid QuotaExceededError thrown by getRandomValues - // when length is more than 65536, as specified in - // http://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues - n = 65536 - } - crypto.Call("getRandomValues", array.Call("subarray", offset, offset+n)) - return n, nil - } - } - - // Node.js - if require := js.Global.Get("require"); require != js.Undefined { - if randomBytes := require.Invoke("crypto").Get("randomBytes"); randomBytes != js.Undefined { - array.Call("set", randomBytes.Invoke(len(b)), offset) - return len(b), nil - } - } - - return 0, errors.New("crypto/rand not available in this environment") -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/x509/x509.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/x509/x509.go deleted file mode 100644 index 21c477800..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/x509/x509.go +++ /dev/null @@ -1,14 +0,0 @@ -// +build js - -package x509 - -import "os" - -func loadSystemRoots() (*CertPool, error) { - // no system roots - return NewCertPool(), nil -} - -func execSecurityRoots() (*CertPool, error) { - return nil, os.ErrNotExist -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/x509/x509_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/x509/x509_test.go deleted file mode 100644 index 5df0388b4..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/x509/x509_test.go +++ /dev/null @@ -1,17 +0,0 @@ -// +build js - -package x509 - -import "testing" - -func TestSystemRoots(t *testing.T) { - t.Skip("no system roots") -} - -func TestSystemVerify(t *testing.T) { - t.Skip("no system") -} - -func TestImports(t *testing.T) { - t.Skip("no system") -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/database/sql/driver/driver_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/database/sql/driver/driver_test.go deleted file mode 100644 index c52960c45..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/database/sql/driver/driver_test.go +++ /dev/null @@ -1,32 +0,0 @@ -// +build js - -package driver - -var valueConverterTests = []valueConverterTest{ - {Bool, "true", true, ""}, - {Bool, "True", true, ""}, - {Bool, []byte("t"), true, ""}, - {Bool, true, true, ""}, - {Bool, "1", true, ""}, - {Bool, 1, true, ""}, - {Bool, int64(1), true, ""}, - {Bool, uint16(1), true, ""}, - {Bool, "false", false, ""}, - {Bool, false, false, ""}, - {Bool, "0", false, ""}, - {Bool, 0, false, ""}, - {Bool, int64(0), false, ""}, - {Bool, uint16(0), false, ""}, - {c: Bool, in: "foo", err: "sql/driver: couldn't convert \"foo\" into type bool"}, - {c: Bool, in: 2, err: "sql/driver: couldn't convert 2 into type bool"}, - {DefaultParameterConverter, now, now, ""}, - {DefaultParameterConverter, (*int64)(nil), nil, ""}, - {DefaultParameterConverter, &answer, answer, ""}, - {DefaultParameterConverter, &now, now, ""}, - //{DefaultParameterConverter, i(9), int64(9), ""}, // TODO: Fix. - {DefaultParameterConverter, f(0.1), float64(0.1), ""}, - {DefaultParameterConverter, b(true), true, ""}, - //{DefaultParameterConverter, bs{1}, []byte{1}, ""}, // TODO: Fix. - {DefaultParameterConverter, s("a"), "a", ""}, - {DefaultParameterConverter, is{1}, nil, "unsupported type driver.is, a slice of int"}, -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/debug/elf/elf_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/debug/elf/elf_test.go deleted file mode 100644 index 4c636e40a..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/debug/elf/elf_test.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build js - -package elf - -import "testing" - -func TestNoSectionOverlaps(t *testing.T) { - t.Skip("not 6l") -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/encoding/json/stream_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/encoding/json/stream_test.go deleted file mode 100644 index 7e6f37a05..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/encoding/json/stream_test.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build js - -package json - -import "testing" - -func TestHTTPDecoding(t *testing.T) { - t.Skip("network access is not supported by GopherJS") -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/fmt/fmt_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/fmt/fmt_test.go deleted file mode 100644 index 65b000269..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/fmt/fmt_test.go +++ /dev/null @@ -1,5 +0,0 @@ -// +build js - -package fmt_test - -const intCount = 100 diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/go/token/token_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/go/token/token_test.go deleted file mode 100644 index f975308de..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/go/token/token_test.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build js - -package token - -import ( - "testing" -) - -func TestFileSetRace(t *testing.T) { - t.Skip() -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/internal/testenv/testenv.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/internal/testenv/testenv.go deleted file mode 100644 index 481414e08..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/internal/testenv/testenv.go +++ /dev/null @@ -1,26 +0,0 @@ -// +build js - -package testenv - -import ( - "runtime" - "strings" -) - -// HasExec reports whether the current system can start new processes -// using os.StartProcess or (more commonly) exec.Command. -func HasExec() bool { - switch runtime.GOOS { - case "nacl": - return false - case "darwin": - if strings.HasPrefix(runtime.GOARCH, "arm") { - return false - } - } - switch runtime.GOARCH { - case "js": - return false - } - return true -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/io/io_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/io/io_test.go deleted file mode 100644 index d2fb6dee7..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/io/io_test.go +++ /dev/null @@ -1,19 +0,0 @@ -// +build js - -package io_test - -import ( - "testing" -) - -func TestMultiWriter_WriteStringSingleAlloc(t *testing.T) { - t.Skip() -} - -func TestMultiReaderFlatten(t *testing.T) { - t.Skip() -} - -func TestMultiReaderFreesExhaustedReaders(t *testing.T) { - t.Skip("test relies on runtime.SetFinalizer, which GopherJS does not implement") -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/big/big.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/big/big.go deleted file mode 100644 index 6e9b162fd..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/big/big.go +++ /dev/null @@ -1,40 +0,0 @@ -// +build js - -package big - -func mulWW(x, y Word) (z1, z0 Word) { - return mulWW_g(x, y) -} -func divWW(x1, x0, y Word) (q, r Word) { - return divWW_g(x1, x0, y) -} -func addVV(z, x, y []Word) (c Word) { - return addVV_g(z, x, y) -} -func subVV(z, x, y []Word) (c Word) { - return subVV_g(z, x, y) -} -func addVW(z, x []Word, y Word) (c Word) { - return addVW_g(z, x, y) -} -func subVW(z, x []Word, y Word) (c Word) { - return subVW_g(z, x, y) -} -func shlVU(z, x []Word, s uint) (c Word) { - return shlVU_g(z, x, s) -} -func shrVU(z, x []Word, s uint) (c Word) { - return shrVU_g(z, x, s) -} -func mulAddVWW(z, x []Word, y, r Word) (c Word) { - return mulAddVWW_g(z, x, y, r) -} -func addMulVVW(z, x []Word, y Word) (c Word) { - return addMulVVW_g(z, x, y) -} -func divWVW(z []Word, xn Word, x []Word, y Word) (r Word) { - return divWVW_g(z, xn, x, y) -} -func bitLen(x Word) (n int) { - return bitLen_g(x) -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/big/big_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/big/big_test.go deleted file mode 100644 index 782095620..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/big/big_test.go +++ /dev/null @@ -1,13 +0,0 @@ -// +build js - -package big - -import "testing" - -func TestBytes(t *testing.T) { - t.Skip("broken") -} - -func TestModSqrt(t *testing.T) { - t.Skip("slow") -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/math.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/math.go deleted file mode 100644 index c91428d00..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/math.go +++ /dev/null @@ -1,238 +0,0 @@ -// +build js - -package math - -import ( - "github.com/gopherjs/gopherjs/js" -) - -var math = js.Global.Get("Math") -var zero float64 = 0 -var posInf = 1 / zero -var negInf = -1 / zero -var nan = 0 / zero - -func Acos(x float64) float64 { - return math.Call("acos", x).Float() -} - -func Asin(x float64) float64 { - return math.Call("asin", x).Float() -} - -func Atan(x float64) float64 { - return math.Call("atan", x).Float() -} - -func Atan2(y, x float64) float64 { - return math.Call("atan2", y, x).Float() -} - -func Ceil(x float64) float64 { - return math.Call("ceil", x).Float() -} - -func Copysign(x, y float64) float64 { - if (x < 0 || 1/x == negInf) != (y < 0 || 1/y == negInf) { - return -x - } - return x -} - -func Cos(x float64) float64 { - return math.Call("cos", x).Float() -} - -func Cosh(x float64) float64 { - return math.Call("cosh", x).Float() -} - -func Dim(x, y float64) float64 { - return dim(x, y) -} - -func Exp(x float64) float64 { - return math.Call("exp", x).Float() -} - -func Exp2(x float64) float64 { - return math.Call("pow", 2, x).Float() -} - -func Expm1(x float64) float64 { - return expm1(x) -} - -func Floor(x float64) float64 { - return math.Call("floor", x).Float() -} - -func Frexp(f float64) (frac float64, exp int) { - return frexp(f) -} - -func Hypot(p, q float64) float64 { - return hypot(p, q) -} - -func Inf(sign int) float64 { - switch { - case sign >= 0: - return posInf - default: - return negInf - } -} - -func IsInf(f float64, sign int) bool { - if f == posInf { - return sign >= 0 - } - if f == negInf { - return sign <= 0 - } - return false -} - -func IsNaN(f float64) (is bool) { - return f != f -} - -func Ldexp(frac float64, exp int) float64 { - if frac == 0 { - return frac - } - if exp >= 1024 { - return frac * math.Call("pow", 2, 1023).Float() * math.Call("pow", 2, exp-1023).Float() - } - if exp <= -1024 { - return frac * math.Call("pow", 2, -1023).Float() * math.Call("pow", 2, exp+1023).Float() - } - return frac * math.Call("pow", 2, exp).Float() -} - -func Log(x float64) float64 { - if x != x { // workaround for optimizer bug in V8, remove at some point - return nan - } - return math.Call("log", x).Float() -} - -func Log10(x float64) float64 { - return log10(x) -} - -func Log1p(x float64) float64 { - return log1p(x) -} - -func Log2(x float64) float64 { - return log2(x) -} - -func Max(x, y float64) float64 { - return max(x, y) -} - -func Min(x, y float64) float64 { - return min(x, y) -} - -func Mod(x, y float64) float64 { - return js.Global.Call("$mod", x, y).Float() -} - -func Modf(f float64) (float64, float64) { - if f == posInf || f == negInf { - return f, nan - } - if 1/f == negInf { - return f, f - } - frac := Mod(f, 1) - return f - frac, frac -} - -func NaN() float64 { - return nan -} - -func Pow(x, y float64) float64 { - if x == 1 || (x == -1 && (y == posInf || y == negInf)) { - return 1 - } - return math.Call("pow", x, y).Float() -} - -func Remainder(x, y float64) float64 { - return remainder(x, y) -} - -func Signbit(x float64) bool { - return x < 0 || 1/x == negInf -} - -func Sin(x float64) float64 { - return math.Call("sin", x).Float() -} - -func Sinh(x float64) float64 { - return math.Call("sinh", x).Float() -} - -func Sincos(x float64) (sin, cos float64) { - return Sin(x), Cos(x) -} - -func Sqrt(x float64) float64 { - return math.Call("sqrt", x).Float() -} - -func Tan(x float64) float64 { - return math.Call("tan", x).Float() -} - -func Tanh(x float64) float64 { - return math.Call("tanh", x).Float() -} - -func Trunc(x float64) float64 { - if x == posInf || x == negInf || x != x || 1/x == negInf { - return x - } - return float64(int(x)) -} - -var buf struct { - uint32array [2]uint32 - float32array [2]float32 - float64array [1]float64 -} - -func init() { - ab := js.Global.Get("ArrayBuffer").New(8) - js.InternalObject(buf).Set("uint32array", js.Global.Get("Uint32Array").New(ab)) - js.InternalObject(buf).Set("float32array", js.Global.Get("Float32Array").New(ab)) - js.InternalObject(buf).Set("float64array", js.Global.Get("Float64Array").New(ab)) -} - -func Float32bits(f float32) uint32 { - buf.float32array[0] = f - return buf.uint32array[0] -} - -func Float32frombits(b uint32) float32 { - buf.uint32array[0] = b - return buf.float32array[0] -} - -func Float64bits(f float64) uint64 { - buf.float64array[0] = f - return uint64(buf.uint32array[1])<<32 + uint64(buf.uint32array[0]) -} - -func Float64frombits(b uint64) float64 { - buf.uint32array[0] = uint32(b) - buf.uint32array[1] = uint32(b >> 32) - return buf.float64array[0] -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/math_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/math_test.go deleted file mode 100644 index 58e929869..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/math_test.go +++ /dev/null @@ -1,12 +0,0 @@ -// +build js - -package math_test - -// Slighly higher tolerances than upstream, otherwise TestGamma fails. -// TODO: Is there a better way to fix TestGamma? It's weird that only one test -// requires increasing tolerances. Perhaps there's a better fix? Maybe we -// should override TestGamma specifically and not the package-wide tolerances, -// because this will cause many other tests to be less accurate. Or maybe this -// is fine? -func close(a, b float64) bool { return tolerance(a, b, 4e-14) } -func veryclose(a, b float64) bool { return tolerance(a, b, 6e-15) } diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/rand/rand_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/rand/rand_test.go deleted file mode 100644 index 0475334d2..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/rand/rand_test.go +++ /dev/null @@ -1,13 +0,0 @@ -// +build js - -package rand - -import "testing" - -func TestFloat32(t *testing.T) { - t.Skip("slow") -} - -func TestConcurrent(t *testing.T) { - t.Skip("using nosync") -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/http/cookiejar/example_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/http/cookiejar/example_test.go deleted file mode 100644 index ab42bef6d..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/http/cookiejar/example_test.go +++ /dev/null @@ -1,14 +0,0 @@ -// +build js - -package cookiejar_test - -import "fmt" - -func ExampleNew() { - // network access not supported by GopherJS, and this test depends on httptest.NewServer - - fmt.Println(`After 1st request: - Flavor: Chocolate Chip -After 2nd request: - Flavor: Oatmeal Raisin`) -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/http/fetch.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/http/fetch.go deleted file mode 100644 index f9123d090..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/http/fetch.go +++ /dev/null @@ -1,134 +0,0 @@ -// +build js - -package http - -import ( - "errors" - "fmt" - "io" - "io/ioutil" - "strconv" - - "github.com/gopherjs/gopherjs/js" -) - -// streamReader implements an io.ReadCloser wrapper for ReadableStream of https://fetch.spec.whatwg.org/. -type streamReader struct { - pending []byte - stream *js.Object -} - -func (r *streamReader) Read(p []byte) (n int, err error) { - if len(r.pending) == 0 { - var ( - bCh = make(chan []byte) - errCh = make(chan error) - ) - r.stream.Call("read").Call("then", - func(result *js.Object) { - if result.Get("done").Bool() { - errCh <- io.EOF - return - } - bCh <- result.Get("value").Interface().([]byte) - }, - func(reason *js.Object) { - // Assumes it's a DOMException. - errCh <- errors.New(reason.Get("message").String()) - }, - ) - select { - case b := <-bCh: - r.pending = b - case err := <-errCh: - return 0, err - } - } - n = copy(p, r.pending) - r.pending = r.pending[n:] - return n, nil -} - -func (r *streamReader) Close() error { - // This ignores any error returned from cancel method. So far, I did not encounter any concrete - // situation where reporting the error is meaningful. Most users ignore error from resp.Body.Close(). - // If there's a need to report error here, it can be implemented and tested when that need comes up. - r.stream.Call("cancel") - return nil -} - -// fetchTransport is a RoundTripper that is implemented using Fetch API. It supports streaming -// response bodies. -type fetchTransport struct{} - -func (t *fetchTransport) RoundTrip(req *Request) (*Response, error) { - headers := js.Global.Get("Headers").New() - for key, values := range req.Header { - for _, value := range values { - headers.Call("append", key, value) - } - } - opt := map[string]interface{}{ - "method": req.Method, - "headers": headers, - "credentials": "same-origin", - } - if req.Body != nil { - // TODO: Find out if request body can be streamed into the fetch request rather than in advance here. - // See BufferSource at https://fetch.spec.whatwg.org/#body-mixin. - body, err := ioutil.ReadAll(req.Body) - if err != nil { - req.Body.Close() // RoundTrip must always close the body, including on errors. - return nil, err - } - req.Body.Close() - opt["body"] = body - } - respPromise := js.Global.Call("fetch", req.URL.String(), opt) - - var ( - respCh = make(chan *Response) - errCh = make(chan error) - ) - respPromise.Call("then", - func(result *js.Object) { - header := Header{} - result.Get("headers").Call("forEach", func(value, key *js.Object) { - ck := CanonicalHeaderKey(key.String()) - header[ck] = append(header[ck], value.String()) - }) - - contentLength := int64(-1) - if cl, err := strconv.ParseInt(header.Get("Content-Length"), 10, 64); err == nil { - contentLength = cl - } - - select { - case respCh <- &Response{ - Status: result.Get("status").String() + " " + StatusText(result.Get("status").Int()), - StatusCode: result.Get("status").Int(), - Header: header, - ContentLength: contentLength, - Body: &streamReader{stream: result.Get("body").Call("getReader")}, - Request: req, - }: - case <-req.Context().Done(): - } - }, - func(reason *js.Object) { - select { - case errCh <- fmt.Errorf("net/http: fetch() failed: %s", reason.String()): - case <-req.Context().Done(): - } - }, - ) - select { - case <-req.Context().Done(): - // TODO: Abort request if possible using Fetch API. - return nil, errors.New("net/http: request canceled") - case resp := <-respCh: - return resp, nil - case err := <-errCh: - return nil, err - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/http/http.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/http/http.go deleted file mode 100644 index 105f72831..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/http/http.go +++ /dev/null @@ -1,113 +0,0 @@ -// +build js - -package http - -import ( - "bufio" - "bytes" - "errors" - "io/ioutil" - "net/textproto" - "strconv" - - "github.com/gopherjs/gopherjs/js" -) - -var DefaultTransport = func() RoundTripper { - switch { - case js.Global.Get("fetch") != js.Undefined && js.Global.Get("ReadableStream") != js.Undefined: // ReadableStream is used as a check for support of streaming response bodies, see https://fetch.spec.whatwg.org/#streams. - return &fetchTransport{} - case js.Global.Get("XMLHttpRequest") != js.Undefined: - return &XHRTransport{} - default: - return noTransport{} - } -}() - -// noTransport is used when neither Fetch API nor XMLHttpRequest API are available. It always fails. -type noTransport struct{} - -func (noTransport) RoundTrip(req *Request) (*Response, error) { - return nil, errors.New("net/http: neither of Fetch nor XMLHttpRequest APIs is available") -} - -type XHRTransport struct { - inflight map[*Request]*js.Object -} - -func (t *XHRTransport) RoundTrip(req *Request) (*Response, error) { - xhr := js.Global.Get("XMLHttpRequest").New() - - if t.inflight == nil { - t.inflight = map[*Request]*js.Object{} - } - t.inflight[req] = xhr - defer delete(t.inflight, req) - - respCh := make(chan *Response) - errCh := make(chan error) - - xhr.Set("onload", func() { - header, _ := textproto.NewReader(bufio.NewReader(bytes.NewReader([]byte(xhr.Call("getAllResponseHeaders").String() + "\n")))).ReadMIMEHeader() - body := js.Global.Get("Uint8Array").New(xhr.Get("response")).Interface().([]byte) - - contentLength := int64(-1) - switch req.Method { - case "HEAD": - if l, err := strconv.ParseInt(header.Get("Content-Length"), 10, 64); err == nil { - contentLength = l - } - default: - contentLength = int64(len(body)) - } - - respCh <- &Response{ - Status: xhr.Get("status").String() + " " + xhr.Get("statusText").String(), - StatusCode: xhr.Get("status").Int(), - Header: Header(header), - ContentLength: contentLength, - Body: ioutil.NopCloser(bytes.NewReader(body)), - Request: req, - } - }) - - xhr.Set("onerror", func(e *js.Object) { - errCh <- errors.New("net/http: XMLHttpRequest failed") - }) - - xhr.Set("onabort", func(e *js.Object) { - errCh <- errors.New("net/http: request canceled") - }) - - xhr.Call("open", req.Method, req.URL.String()) - xhr.Set("responseType", "arraybuffer") // has to be after "open" until https://bugzilla.mozilla.org/show_bug.cgi?id=1110761 is resolved - for key, values := range req.Header { - for _, value := range values { - xhr.Call("setRequestHeader", key, value) - } - } - if req.Body == nil { - xhr.Call("send") - } else { - body, err := ioutil.ReadAll(req.Body) - if err != nil { - req.Body.Close() // RoundTrip must always close the body, including on errors. - return nil, err - } - req.Body.Close() - xhr.Call("send", body) - } - - select { - case resp := <-respCh: - return resp, nil - case err := <-errCh: - return nil, err - } -} - -func (t *XHRTransport) CancelRequest(req *Request) { - if xhr, ok := t.inflight[req]; ok { - xhr.Call("abort") - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/net.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/net.go deleted file mode 100644 index 25dfc5f30..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/net.go +++ /dev/null @@ -1,41 +0,0 @@ -// +build js - -package net - -import ( - "errors" - "syscall" - - "github.com/gopherjs/gopherjs/js" -) - -func byteIndex(s string, c byte) int { - return js.InternalObject(s).Call("indexOf", js.Global.Get("String").Call("fromCharCode", c)).Int() -} - -func Listen(net, laddr string) (Listener, error) { - panic(errors.New("network access is not supported by GopherJS")) -} - -func (d *Dialer) Dial(network, address string) (Conn, error) { - panic(errors.New("network access is not supported by GopherJS")) -} - -func sysInit() { -} - -func probeIPv4Stack() bool { - return false -} - -func probeIPv6Stack() (supportsIPv6, supportsIPv4map bool) { - return false, false -} - -func probeWindowsIPStack() (supportsVistaIP bool) { - return false -} - -func maxListenerBacklog() int { - return syscall.SOMAXCONN -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/os/os.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/os/os.go deleted file mode 100644 index 96f36d28b..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/os/os.go +++ /dev/null @@ -1,32 +0,0 @@ -// +build js - -package os - -import ( - "errors" - - "github.com/gopherjs/gopherjs/js" -) - -func runtime_args() []string { // not called on Windows - return Args -} - -func init() { - if process := js.Global.Get("process"); process != js.Undefined { - argv := process.Get("argv") - Args = make([]string, argv.Length()-1) - for i := 0; i < argv.Length()-1; i++ { - Args[i] = argv.Index(i + 1).String() - } - } - if len(Args) == 0 { - Args = []string{"?"} - } -} - -func runtime_beforeExit() {} - -func executable() (string, error) { - return "", errors.New("Executable not implemented for GOARCH=js") -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/example_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/example_test.go deleted file mode 100644 index 0953ebd12..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/example_test.go +++ /dev/null @@ -1,14 +0,0 @@ -// +build js - -package reflect_test - -import "fmt" - -func ExampleStructOf() { - // GopherJS does not implement reflect.addReflectOff needed for this test. - // See https://github.com/gopherjs/gopherjs/issues/499 - - fmt.Println(`value: &{Height:0.4 Age:2} -json: {"height":0.4,"age":2} -value: &{Height:1.5 Age:10}`) -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/reflect.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/reflect.go deleted file mode 100644 index 6069d7696..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/reflect.go +++ /dev/null @@ -1,1451 +0,0 @@ -// +build js - -package reflect - -import ( - "errors" - "strconv" - "unsafe" - - "github.com/gopherjs/gopherjs/js" -) - -var initialized = false - -func init() { - // avoid dead code elimination - used := func(i interface{}) {} - used(rtype{}) - used(uncommonType{}) - used(method{}) - used(arrayType{}) - used(chanType{}) - used(funcType{}) - used(interfaceType{}) - used(mapType{}) - used(ptrType{}) - used(sliceType{}) - used(structType{}) - used(imethod{}) - used(structField{}) - - initialized = true - uint8Type = TypeOf(uint8(0)).(*rtype) // set for real -} - -func jsType(typ Type) *js.Object { - return js.InternalObject(typ).Get("jsType") -} - -func reflectType(typ *js.Object) *rtype { - if typ.Get("reflectType") == js.Undefined { - rt := &rtype{ - size: uintptr(typ.Get("size").Int()), - kind: uint8(typ.Get("kind").Int()), - str: newNameOff(newName(internalStr(typ.Get("string")), "", "", typ.Get("exported").Bool())), - } - js.InternalObject(rt).Set("jsType", typ) - typ.Set("reflectType", js.InternalObject(rt)) - - methodSet := js.Global.Call("$methodSet", typ) - if methodSet.Length() != 0 || typ.Get("named").Bool() { - rt.tflag |= tflagUncommon - if typ.Get("named").Bool() { - rt.tflag |= tflagNamed - } - reflectMethods := make([]method, methodSet.Length()) - for i := range reflectMethods { - m := methodSet.Index(i) - reflectMethods[i] = method{ - name: newNameOff(newName(internalStr(m.Get("name")), "", "", internalStr(m.Get("pkg")) == "")), - mtyp: newTypeOff(reflectType(m.Get("typ"))), - } - } - ut := &uncommonType{ - pkgPath: newNameOff(newName(internalStr(typ.Get("pkg")), "", "", false)), - mcount: uint16(methodSet.Length()), - _methods: reflectMethods, - } - uncommonTypeMap[rt] = ut - js.InternalObject(ut).Set("jsType", typ) - } - - switch rt.Kind() { - case Array: - setKindType(rt, &arrayType{ - elem: reflectType(typ.Get("elem")), - len: uintptr(typ.Get("len").Int()), - }) - case Chan: - dir := BothDir - if typ.Get("sendOnly").Bool() { - dir = SendDir - } - if typ.Get("recvOnly").Bool() { - dir = RecvDir - } - setKindType(rt, &chanType{ - elem: reflectType(typ.Get("elem")), - dir: uintptr(dir), - }) - case Func: - params := typ.Get("params") - in := make([]*rtype, params.Length()) - for i := range in { - in[i] = reflectType(params.Index(i)) - } - results := typ.Get("results") - out := make([]*rtype, results.Length()) - for i := range out { - out[i] = reflectType(results.Index(i)) - } - outCount := uint16(results.Length()) - if typ.Get("variadic").Bool() { - outCount |= 1 << 15 - } - setKindType(rt, &funcType{ - rtype: *rt, - inCount: uint16(params.Length()), - outCount: outCount, - _in: in, - _out: out, - }) - case Interface: - methods := typ.Get("methods") - imethods := make([]imethod, methods.Length()) - for i := range imethods { - m := methods.Index(i) - imethods[i] = imethod{ - name: newNameOff(newName(internalStr(m.Get("name")), "", "", internalStr(m.Get("pkg")) == "")), - typ: newTypeOff(reflectType(m.Get("typ"))), - } - } - setKindType(rt, &interfaceType{ - rtype: *rt, - methods: imethods, - }) - case Map: - setKindType(rt, &mapType{ - key: reflectType(typ.Get("key")), - elem: reflectType(typ.Get("elem")), - }) - case Ptr: - setKindType(rt, &ptrType{ - elem: reflectType(typ.Get("elem")), - }) - case Slice: - setKindType(rt, &sliceType{ - elem: reflectType(typ.Get("elem")), - }) - case Struct: - fields := typ.Get("fields") - reflectFields := make([]structField, fields.Length()) - for i := range reflectFields { - f := fields.Index(i) - reflectFields[i] = structField{ - name: newName(internalStr(f.Get("name")), internalStr(f.Get("tag")), "", f.Get("exported").Bool()), - typ: reflectType(f.Get("typ")), - offset: uintptr(i), - } - } - setKindType(rt, &structType{ - rtype: *rt, - pkgPath: newName(internalStr(typ.Get("pkgPath")), "", "", false), - fields: reflectFields, - }) - } - } - - return (*rtype)(unsafe.Pointer(typ.Get("reflectType").Unsafe())) -} - -func setKindType(rt *rtype, kindType interface{}) { - js.InternalObject(rt).Set("kindType", js.InternalObject(kindType)) - js.InternalObject(kindType).Set("rtype", js.InternalObject(rt)) -} - -type uncommonType struct { - pkgPath nameOff - mcount uint16 - _ uint16 - moff uint32 - _ uint32 - - _methods []method -} - -func (t *uncommonType) methods() []method { - return t._methods -} - -var uncommonTypeMap = make(map[*rtype]*uncommonType) - -func (t *rtype) uncommon() *uncommonType { - return uncommonTypeMap[t] -} - -type funcType struct { - rtype `reflect:"func"` - inCount uint16 - outCount uint16 - - _in []*rtype - _out []*rtype -} - -func (t *funcType) in() []*rtype { - return t._in -} - -func (t *funcType) out() []*rtype { - return t._out -} - -type name struct { - bytes *byte -} - -type nameData struct { - name string - tag string - pkgPath string - exported bool -} - -var nameMap = make(map[*byte]*nameData) - -func (n name) name() (s string) { - return nameMap[n.bytes].name -} - -func (n name) tag() (s string) { - return nameMap[n.bytes].tag -} - -func (n name) pkgPath() string { - return nameMap[n.bytes].pkgPath -} - -func (n name) isExported() bool { - return nameMap[n.bytes].exported -} - -func newName(n, tag, pkgPath string, exported bool) name { - b := new(byte) - nameMap[b] = &nameData{ - name: n, - tag: tag, - pkgPath: pkgPath, - exported: exported, - } - return name{ - bytes: b, - } -} - -var nameOffList []name - -func (t *rtype) nameOff(off nameOff) name { - return nameOffList[int(off)] -} - -func newNameOff(n name) nameOff { - i := len(nameOffList) - nameOffList = append(nameOffList, n) - return nameOff(i) -} - -var typeOffList []*rtype - -func (t *rtype) typeOff(off typeOff) *rtype { - return typeOffList[int(off)] -} - -func newTypeOff(t *rtype) typeOff { - i := len(typeOffList) - typeOffList = append(typeOffList, t) - return typeOff(i) -} - -func internalStr(strObj *js.Object) string { - var c struct{ str string } - js.InternalObject(c).Set("str", strObj) // get string without internalizing - return c.str -} - -func isWrapped(typ Type) bool { - return jsType(typ).Get("wrapped").Bool() -} - -func copyStruct(dst, src *js.Object, typ Type) { - fields := jsType(typ).Get("fields") - for i := 0; i < fields.Length(); i++ { - prop := fields.Index(i).Get("prop").String() - dst.Set(prop, src.Get(prop)) - } -} - -func makeValue(t Type, v *js.Object, fl flag) Value { - rt := t.common() - if t.Kind() == Array || t.Kind() == Struct || t.Kind() == Ptr { - return Value{rt, unsafe.Pointer(v.Unsafe()), fl | flag(t.Kind())} - } - return Value{rt, unsafe.Pointer(js.Global.Call("$newDataPointer", v, jsType(rt.ptrTo())).Unsafe()), fl | flag(t.Kind()) | flagIndir} -} - -func MakeSlice(typ Type, len, cap int) Value { - if typ.Kind() != Slice { - panic("reflect.MakeSlice of non-slice type") - } - if len < 0 { - panic("reflect.MakeSlice: negative len") - } - if cap < 0 { - panic("reflect.MakeSlice: negative cap") - } - if len > cap { - panic("reflect.MakeSlice: len > cap") - } - - return makeValue(typ, js.Global.Call("$makeSlice", jsType(typ), len, cap, js.InternalObject(func() *js.Object { return jsType(typ.Elem()).Call("zero") })), 0) -} - -func TypeOf(i interface{}) Type { - if !initialized { // avoid error of uint8Type - return &rtype{} - } - if i == nil { - return nil - } - return reflectType(js.InternalObject(i).Get("constructor")) -} - -func ValueOf(i interface{}) Value { - if i == nil { - return Value{} - } - return makeValue(reflectType(js.InternalObject(i).Get("constructor")), js.InternalObject(i).Get("$val"), 0) -} - -func ArrayOf(count int, elem Type) Type { - return reflectType(js.Global.Call("$arrayType", jsType(elem), count)) -} - -func ChanOf(dir ChanDir, t Type) Type { - return reflectType(js.Global.Call("$chanType", jsType(t), dir == SendDir, dir == RecvDir)) -} - -func FuncOf(in, out []Type, variadic bool) Type { - if variadic && (len(in) == 0 || in[len(in)-1].Kind() != Slice) { - panic("reflect.FuncOf: last arg of variadic func must be slice") - } - - jsIn := make([]*js.Object, len(in)) - for i, v := range in { - jsIn[i] = jsType(v) - } - jsOut := make([]*js.Object, len(out)) - for i, v := range out { - jsOut[i] = jsType(v) - } - return reflectType(js.Global.Call("$funcType", jsIn, jsOut, variadic)) -} - -func MapOf(key, elem Type) Type { - switch key.Kind() { - case Func, Map, Slice: - panic("reflect.MapOf: invalid key type " + key.String()) - } - - return reflectType(js.Global.Call("$mapType", jsType(key), jsType(elem))) -} - -func (t *rtype) ptrTo() *rtype { - return reflectType(js.Global.Call("$ptrType", jsType(t))) -} - -func SliceOf(t Type) Type { - return reflectType(js.Global.Call("$sliceType", jsType(t))) -} - -// func StructOf(fields []StructField) Type { -// jsFields := make([]*js.Object, len(fields)) -// fset := map[string]struct{}{} -// for i, f := range fields { -// if f.Type == nil { -// panic("reflect.StructOf: field " + strconv.Itoa(i) + " has no type") -// } - -// name := f.Name -// if name == "" { -// // Embedded field -// if f.Type.Kind() == Ptr { -// // Embedded ** and *interface{} are illegal -// elem := f.Type.Elem() -// if k := elem.Kind(); k == Ptr || k == Interface { -// panic("reflect.StructOf: illegal anonymous field type " + f.Type.String()) -// } -// name = elem.String() -// } else { -// name = f.Type.String() -// } -// } - -// if _, dup := fset[name]; dup { -// panic("reflect.StructOf: duplicate field " + name) -// } -// fset[name] = struct{}{} - -// jsf := js.Global.Get("Object").New() -// jsf.Set("prop", name) -// jsf.Set("name", name) -// jsf.Set("exported", true) -// jsf.Set("typ", jsType(f.Type)) -// jsf.Set("tag", f.Tag) -// jsFields[i] = jsf -// } -// return reflectType(js.Global.Call("$structType", "", jsFields)) -// } - -func Zero(typ Type) Value { - return makeValue(typ, jsType(typ).Call("zero"), 0) -} - -func unsafe_New(typ *rtype) unsafe.Pointer { - switch typ.Kind() { - case Struct: - return unsafe.Pointer(jsType(typ).Get("ptr").New().Unsafe()) - case Array: - return unsafe.Pointer(jsType(typ).Call("zero").Unsafe()) - default: - return unsafe.Pointer(js.Global.Call("$newDataPointer", jsType(typ).Call("zero"), jsType(typ.ptrTo())).Unsafe()) - } -} - -func makeInt(f flag, bits uint64, t Type) Value { - typ := t.common() - ptr := unsafe_New(typ) - switch typ.Kind() { - case Int8: - *(*int8)(ptr) = int8(bits) - case Int16: - *(*int16)(ptr) = int16(bits) - case Int, Int32: - *(*int32)(ptr) = int32(bits) - case Int64: - *(*int64)(ptr) = int64(bits) - case Uint8: - *(*uint8)(ptr) = uint8(bits) - case Uint16: - *(*uint16)(ptr) = uint16(bits) - case Uint, Uint32, Uintptr: - *(*uint32)(ptr) = uint32(bits) - case Uint64: - *(*uint64)(ptr) = uint64(bits) - } - return Value{typ, ptr, f | flagIndir | flag(typ.Kind())} -} - -func MakeFunc(typ Type, fn func(args []Value) (results []Value)) Value { - if typ.Kind() != Func { - panic("reflect: call of MakeFunc with non-Func type") - } - - t := typ.common() - ftyp := (*funcType)(unsafe.Pointer(t)) - - fv := js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} { - args := make([]Value, ftyp.NumIn()) - for i := range args { - argType := ftyp.In(i).common() - args[i] = makeValue(argType, arguments[i], 0) - } - resultsSlice := fn(args) - switch ftyp.NumOut() { - case 0: - return nil - case 1: - return resultsSlice[0].object() - default: - results := js.Global.Get("Array").New(ftyp.NumOut()) - for i, r := range resultsSlice { - results.SetIndex(i, r.object()) - } - return results - } - }) - - return Value{t, unsafe.Pointer(fv.Unsafe()), flag(Func)} -} - -func typedmemmove(t *rtype, dst, src unsafe.Pointer) { - js.InternalObject(dst).Call("$set", js.InternalObject(src).Call("$get")) -} - -func loadScalar(p unsafe.Pointer, n uintptr) uintptr { - return js.InternalObject(p).Call("$get").Unsafe() -} - -func makechan(typ *rtype, size uint64) (ch unsafe.Pointer) { - ctyp := (*chanType)(unsafe.Pointer(typ)) - return unsafe.Pointer(js.Global.Get("$Chan").New(jsType(ctyp.elem), size).Unsafe()) -} - -func makemap(t *rtype) (m unsafe.Pointer) { - return unsafe.Pointer(js.Global.Get("Object").New().Unsafe()) -} - -func keyFor(t *rtype, key unsafe.Pointer) (*js.Object, string) { - kv := js.InternalObject(key) - if kv.Get("$get") != js.Undefined { - kv = kv.Call("$get") - } - k := jsType(t.Key()).Call("keyFor", kv).String() - return kv, k -} - -func mapaccess(t *rtype, m, key unsafe.Pointer) unsafe.Pointer { - _, k := keyFor(t, key) - entry := js.InternalObject(m).Get(k) - if entry == js.Undefined { - return nil - } - return unsafe.Pointer(js.Global.Call("$newDataPointer", entry.Get("v"), jsType(PtrTo(t.Elem()))).Unsafe()) -} - -func mapassign(t *rtype, m, key, val unsafe.Pointer) { - kv, k := keyFor(t, key) - jsVal := js.InternalObject(val).Call("$get") - et := t.Elem() - if et.Kind() == Struct { - newVal := jsType(et).Call("zero") - copyStruct(newVal, jsVal, et) - jsVal = newVal - } - entry := js.Global.Get("Object").New() - entry.Set("k", kv) - entry.Set("v", jsVal) - js.InternalObject(m).Set(k, entry) -} - -func mapdelete(t *rtype, m unsafe.Pointer, key unsafe.Pointer) { - _, k := keyFor(t, key) - js.InternalObject(m).Delete(k) -} - -type mapIter struct { - t Type - m *js.Object - keys *js.Object - i int -} - -func mapiterinit(t *rtype, m unsafe.Pointer) *byte { - return (*byte)(unsafe.Pointer(&mapIter{t, js.InternalObject(m), js.Global.Call("$keys", js.InternalObject(m)), 0})) -} - -func mapiterkey(it *byte) unsafe.Pointer { - iter := (*mapIter)(unsafe.Pointer(it)) - k := iter.keys.Index(iter.i) - return unsafe.Pointer(js.Global.Call("$newDataPointer", iter.m.Get(k.String()).Get("k"), jsType(PtrTo(iter.t.Key()))).Unsafe()) -} - -func mapiternext(it *byte) { - iter := (*mapIter)(unsafe.Pointer(it)) - iter.i++ -} - -func maplen(m unsafe.Pointer) int { - return js.Global.Call("$keys", js.InternalObject(m)).Length() -} - -func cvtDirect(v Value, typ Type) Value { - var srcVal = v.object() - if srcVal == jsType(v.typ).Get("nil") { - return makeValue(typ, jsType(typ).Get("nil"), v.flag) - } - - var val *js.Object - switch k := typ.Kind(); k { - case Slice: - slice := jsType(typ).New(srcVal.Get("$array")) - slice.Set("$offset", srcVal.Get("$offset")) - slice.Set("$length", srcVal.Get("$length")) - slice.Set("$capacity", srcVal.Get("$capacity")) - val = js.Global.Call("$newDataPointer", slice, jsType(PtrTo(typ))) - case Ptr: - if typ.Elem().Kind() == Struct { - if typ.Elem() == v.typ.Elem() { - val = srcVal - break - } - val = jsType(typ).New() - copyStruct(val, srcVal, typ.Elem()) - break - } - val = jsType(typ).New(srcVal.Get("$get"), srcVal.Get("$set")) - case Struct: - val = jsType(typ).Get("ptr").New() - copyStruct(val, srcVal, typ) - case Array, Bool, Chan, Func, Interface, Map, String: - val = js.InternalObject(v.ptr) - default: - panic(&ValueError{"reflect.Convert", k}) - } - return Value{typ.common(), unsafe.Pointer(val.Unsafe()), v.flag&(flagRO|flagIndir) | flag(typ.Kind())} -} - -func Copy(dst, src Value) int { - dk := dst.kind() - if dk != Array && dk != Slice { - panic(&ValueError{"reflect.Copy", dk}) - } - if dk == Array { - dst.mustBeAssignable() - } - dst.mustBeExported() - - sk := src.kind() - if sk != Array && sk != Slice { - panic(&ValueError{"reflect.Copy", sk}) - } - src.mustBeExported() - - typesMustMatch("reflect.Copy", dst.typ.Elem(), src.typ.Elem()) - - dstVal := dst.object() - if dk == Array { - dstVal = jsType(SliceOf(dst.typ.Elem())).New(dstVal) - } - - srcVal := src.object() - if sk == Array { - srcVal = jsType(SliceOf(src.typ.Elem())).New(srcVal) - } - - return js.Global.Call("$copySlice", dstVal, srcVal).Int() -} - -func methodReceiver(op string, v Value, i int) (_, t *rtype, fn unsafe.Pointer) { - var prop string - if v.typ.Kind() == Interface { - tt := (*interfaceType)(unsafe.Pointer(v.typ)) - if i < 0 || i >= len(tt.methods) { - panic("reflect: internal error: invalid method index") - } - m := &tt.methods[i] - if !tt.nameOff(m.name).isExported() { - panic("reflect: " + op + " of unexported method") - } - t = tt.typeOff(m.typ) - prop = tt.nameOff(m.name).name() - } else { - ut := v.typ.uncommon() - if ut == nil || uint(i) >= uint(ut.mcount) { - panic("reflect: internal error: invalid method index") - } - m := ut.methods()[i] - if !v.typ.nameOff(m.name).isExported() { - panic("reflect: " + op + " of unexported method") - } - t = v.typ.typeOff(m.mtyp) - prop = js.Global.Call("$methodSet", jsType(v.typ)).Index(i).Get("prop").String() - } - rcvr := v.object() - if isWrapped(v.typ) { - rcvr = jsType(v.typ).New(rcvr) - } - fn = unsafe.Pointer(rcvr.Get(prop).Unsafe()) - return -} - -func valueInterface(v Value, safe bool) interface{} { - if v.flag == 0 { - panic(&ValueError{"reflect.Value.Interface", 0}) - } - if safe && v.flag&flagRO != 0 { - panic("reflect.Value.Interface: cannot return value obtained from unexported field or method") - } - if v.flag&flagMethod != 0 { - v = makeMethodValue("Interface", v) - } - - if isWrapped(v.typ) { - return interface{}(unsafe.Pointer(jsType(v.typ).New(v.object()).Unsafe())) - } - return interface{}(unsafe.Pointer(v.object().Unsafe())) -} - -func ifaceE2I(t *rtype, src interface{}, dst unsafe.Pointer) { - js.InternalObject(dst).Call("$set", js.InternalObject(src)) -} - -func methodName() string { - return "?FIXME?" -} - -func makeMethodValue(op string, v Value) Value { - if v.flag&flagMethod == 0 { - panic("reflect: internal error: invalid use of makePartialFunc") - } - - _, _, fn := methodReceiver(op, v, int(v.flag)>>flagMethodShift) - rcvr := v.object() - if isWrapped(v.typ) { - rcvr = jsType(v.typ).New(rcvr) - } - fv := js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} { - return js.InternalObject(fn).Call("apply", rcvr, arguments) - }) - return Value{v.Type().common(), unsafe.Pointer(fv.Unsafe()), v.flag&flagRO | flag(Func)} -} - -func (t *rtype) pointers() bool { - switch t.Kind() { - case Ptr, Map, Chan, Func, Struct, Array: - return true - default: - return false - } -} - -func (t *rtype) Comparable() bool { - switch t.Kind() { - case Func, Slice, Map: - return false - case Array: - return t.Elem().Comparable() - case Struct: - for i := 0; i < t.NumField(); i++ { - if !t.Field(i).Type.Comparable() { - return false - } - } - } - return true -} - -func (t *rtype) Method(i int) (m Method) { - if t.Kind() == Interface { - tt := (*interfaceType)(unsafe.Pointer(t)) - return tt.Method(i) - } - methods := t.exportedMethods() - if i < 0 || i >= len(methods) { - panic("reflect: Method index out of range") - } - p := methods[i] - pname := t.nameOff(p.name) - m.Name = pname.name() - fl := flag(Func) - mtyp := t.typeOff(p.mtyp) - ft := (*funcType)(unsafe.Pointer(mtyp)) - in := make([]Type, 0, 1+len(ft.in())) - in = append(in, t) - for _, arg := range ft.in() { - in = append(in, arg) - } - out := make([]Type, 0, len(ft.out())) - for _, ret := range ft.out() { - out = append(out, ret) - } - mt := FuncOf(in, out, ft.IsVariadic()) - m.Type = mt - prop := js.Global.Call("$methodSet", js.InternalObject(t).Get("jsType")).Index(i).Get("prop").String() - fn := js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} { - rcvr := arguments[0] - return rcvr.Get(prop).Call("apply", rcvr, arguments[1:]) - }) - m.Func = Value{mt.(*rtype), unsafe.Pointer(fn.Unsafe()), fl} - - m.Index = i - return m -} - -func (v Value) object() *js.Object { - if v.typ.Kind() == Array || v.typ.Kind() == Struct { - return js.InternalObject(v.ptr) - } - if v.flag&flagIndir != 0 { - val := js.InternalObject(v.ptr).Call("$get") - if val != js.Global.Get("$ifaceNil") && val.Get("constructor") != jsType(v.typ) { - switch v.typ.Kind() { - case Uint64, Int64: - val = jsType(v.typ).New(val.Get("$high"), val.Get("$low")) - case Complex64, Complex128: - val = jsType(v.typ).New(val.Get("$real"), val.Get("$imag")) - case Slice: - if val == val.Get("constructor").Get("nil") { - val = jsType(v.typ).Get("nil") - break - } - newVal := jsType(v.typ).New(val.Get("$array")) - newVal.Set("$offset", val.Get("$offset")) - newVal.Set("$length", val.Get("$length")) - newVal.Set("$capacity", val.Get("$capacity")) - val = newVal - } - } - return js.InternalObject(val.Unsafe()) - } - return js.InternalObject(v.ptr) -} - -var callHelper = js.Global.Get("$call").Interface().(func(...interface{}) *js.Object) - -func (v Value) call(op string, in []Value) []Value { - var ( - t *rtype - fn unsafe.Pointer - rcvr *js.Object - ) - if v.flag&flagMethod != 0 { - _, t, fn = methodReceiver(op, v, int(v.flag)>>flagMethodShift) - rcvr = v.object() - if isWrapped(v.typ) { - rcvr = jsType(v.typ).New(rcvr) - } - } else { - t = v.typ - fn = unsafe.Pointer(v.object().Unsafe()) - rcvr = js.Undefined - } - - if fn == nil { - panic("reflect.Value.Call: call of nil function") - } - - isSlice := op == "CallSlice" - n := t.NumIn() - if isSlice { - if !t.IsVariadic() { - panic("reflect: CallSlice of non-variadic function") - } - if len(in) < n { - panic("reflect: CallSlice with too few input arguments") - } - if len(in) > n { - panic("reflect: CallSlice with too many input arguments") - } - } else { - if t.IsVariadic() { - n-- - } - if len(in) < n { - panic("reflect: Call with too few input arguments") - } - if !t.IsVariadic() && len(in) > n { - panic("reflect: Call with too many input arguments") - } - } - for _, x := range in { - if x.Kind() == Invalid { - panic("reflect: " + op + " using zero Value argument") - } - } - for i := 0; i < n; i++ { - if xt, targ := in[i].Type(), t.In(i); !xt.AssignableTo(targ) { - panic("reflect: " + op + " using " + xt.String() + " as type " + targ.String()) - } - } - if !isSlice && t.IsVariadic() { - // prepare slice for remaining values - m := len(in) - n - slice := MakeSlice(t.In(n), m, m) - elem := t.In(n).Elem() - for i := 0; i < m; i++ { - x := in[n+i] - if xt := x.Type(); !xt.AssignableTo(elem) { - panic("reflect: cannot use " + xt.String() + " as type " + elem.String() + " in " + op) - } - slice.Index(i).Set(x) - } - origIn := in - in = make([]Value, n+1) - copy(in[:n], origIn) - in[n] = slice - } - - nin := len(in) - if nin != t.NumIn() { - panic("reflect.Value.Call: wrong argument count") - } - nout := t.NumOut() - - argsArray := js.Global.Get("Array").New(t.NumIn()) - for i, arg := range in { - argsArray.SetIndex(i, unwrapJsObject(t.In(i), arg.assignTo("reflect.Value.Call", t.In(i).common(), nil).object())) - } - results := callHelper(js.InternalObject(fn), rcvr, argsArray) - - switch nout { - case 0: - return nil - case 1: - return []Value{makeValue(t.Out(0), wrapJsObject(t.Out(0), results), 0)} - default: - ret := make([]Value, nout) - for i := range ret { - ret[i] = makeValue(t.Out(i), wrapJsObject(t.Out(i), results.Index(i)), 0) - } - return ret - } -} - -func (v Value) Cap() int { - k := v.kind() - switch k { - case Array: - return v.typ.Len() - case Chan, Slice: - return v.object().Get("$capacity").Int() - } - panic(&ValueError{"reflect.Value.Cap", k}) -} - -var jsObjectPtr = reflectType(js.Global.Get("$jsObjectPtr")) - -func wrapJsObject(typ Type, val *js.Object) *js.Object { - if typ == jsObjectPtr { - return jsType(jsObjectPtr).New(val) - } - return val -} - -func unwrapJsObject(typ Type, val *js.Object) *js.Object { - if typ == jsObjectPtr { - return val.Get("object") - } - return val -} - -func (v Value) Elem() Value { - switch k := v.kind(); k { - case Interface: - val := v.object() - if val == js.Global.Get("$ifaceNil") { - return Value{} - } - typ := reflectType(val.Get("constructor")) - return makeValue(typ, val.Get("$val"), v.flag&flagRO) - - case Ptr: - if v.IsNil() { - return Value{} - } - val := v.object() - tt := (*ptrType)(unsafe.Pointer(v.typ)) - fl := v.flag&flagRO | flagIndir | flagAddr - fl |= flag(tt.elem.Kind()) - return Value{tt.elem, unsafe.Pointer(wrapJsObject(tt.elem, val).Unsafe()), fl} - - default: - panic(&ValueError{"reflect.Value.Elem", k}) - } -} - -func (v Value) Field(i int) Value { - if v.kind() != Struct { - panic(&ValueError{"reflect.Value.Field", v.kind()}) - } - tt := (*structType)(unsafe.Pointer(v.typ)) - if uint(i) >= uint(len(tt.fields)) { - panic("reflect: Field index out of range") - } - - prop := jsType(v.typ).Get("fields").Index(i).Get("prop").String() - field := &tt.fields[i] - typ := field.typ - - fl := v.flag&(flagStickyRO|flagIndir|flagAddr) | flag(typ.Kind()) - if !field.name.isExported() { - if field.name.name() == "" { - fl |= flagEmbedRO - } else { - fl |= flagStickyRO - } - } - - if tag := tt.fields[i].name.tag(); tag != "" && i != 0 { - if jsTag := getJsTag(tag); jsTag != "" { - for { - v = v.Field(0) - if v.typ == jsObjectPtr { - o := v.object().Get("object") - return Value{typ, unsafe.Pointer(jsType(PtrTo(typ)).New( - js.InternalObject(func() *js.Object { return js.Global.Call("$internalize", o.Get(jsTag), jsType(typ)) }), - js.InternalObject(func(x *js.Object) { o.Set(jsTag, js.Global.Call("$externalize", x, jsType(typ))) }), - ).Unsafe()), fl} - } - if v.typ.Kind() == Ptr { - v = v.Elem() - } - } - } - } - - s := js.InternalObject(v.ptr) - if fl&flagIndir != 0 && typ.Kind() != Array && typ.Kind() != Struct { - return Value{typ, unsafe.Pointer(jsType(PtrTo(typ)).New( - js.InternalObject(func() *js.Object { return wrapJsObject(typ, s.Get(prop)) }), - js.InternalObject(func(x *js.Object) { s.Set(prop, unwrapJsObject(typ, x)) }), - ).Unsafe()), fl} - } - return makeValue(typ, wrapJsObject(typ, s.Get(prop)), fl) -} - -func getJsTag(tag string) string { - for tag != "" { - // skip leading space - i := 0 - for i < len(tag) && tag[i] == ' ' { - i++ - } - tag = tag[i:] - if tag == "" { - break - } - - // scan to colon. - // a space or a quote is a syntax error - i = 0 - for i < len(tag) && tag[i] != ' ' && tag[i] != ':' && tag[i] != '"' { - i++ - } - if i+1 >= len(tag) || tag[i] != ':' || tag[i+1] != '"' { - break - } - name := string(tag[:i]) - tag = tag[i+1:] - - // scan quoted string to find value - i = 1 - for i < len(tag) && tag[i] != '"' { - if tag[i] == '\\' { - i++ - } - i++ - } - if i >= len(tag) { - break - } - qvalue := string(tag[:i+1]) - tag = tag[i+1:] - - if name == "js" { - value, _ := strconv.Unquote(qvalue) - return value - } - } - return "" -} - -func (v Value) Index(i int) Value { - switch k := v.kind(); k { - case Array: - tt := (*arrayType)(unsafe.Pointer(v.typ)) - if i < 0 || i > int(tt.len) { - panic("reflect: array index out of range") - } - typ := tt.elem - fl := v.flag & (flagRO | flagIndir | flagAddr) - fl |= flag(typ.Kind()) - - a := js.InternalObject(v.ptr) - if fl&flagIndir != 0 && typ.Kind() != Array && typ.Kind() != Struct { - return Value{typ, unsafe.Pointer(jsType(PtrTo(typ)).New( - js.InternalObject(func() *js.Object { return wrapJsObject(typ, a.Index(i)) }), - js.InternalObject(func(x *js.Object) { a.SetIndex(i, unwrapJsObject(typ, x)) }), - ).Unsafe()), fl} - } - return makeValue(typ, wrapJsObject(typ, a.Index(i)), fl) - - case Slice: - s := v.object() - if i < 0 || i >= s.Get("$length").Int() { - panic("reflect: slice index out of range") - } - tt := (*sliceType)(unsafe.Pointer(v.typ)) - typ := tt.elem - fl := flagAddr | flagIndir | v.flag&flagRO - fl |= flag(typ.Kind()) - - i += s.Get("$offset").Int() - a := s.Get("$array") - if fl&flagIndir != 0 && typ.Kind() != Array && typ.Kind() != Struct { - return Value{typ, unsafe.Pointer(jsType(PtrTo(typ)).New( - js.InternalObject(func() *js.Object { return wrapJsObject(typ, a.Index(i)) }), - js.InternalObject(func(x *js.Object) { a.SetIndex(i, unwrapJsObject(typ, x)) }), - ).Unsafe()), fl} - } - return makeValue(typ, wrapJsObject(typ, a.Index(i)), fl) - - case String: - str := *(*string)(v.ptr) - if i < 0 || i >= len(str) { - panic("reflect: string index out of range") - } - fl := v.flag&flagRO | flag(Uint8) - c := str[i] - return Value{uint8Type, unsafe.Pointer(&c), fl | flagIndir} - - default: - panic(&ValueError{"reflect.Value.Index", k}) - } -} - -func (v Value) InterfaceData() [2]uintptr { - panic(errors.New("InterfaceData is not supported by GopherJS")) -} - -func (v Value) IsNil() bool { - switch k := v.kind(); k { - case Ptr, Slice: - return v.object() == jsType(v.typ).Get("nil") - case Chan: - return v.object() == js.Global.Get("$chanNil") - case Func: - return v.object() == js.Global.Get("$throwNilPointerError") - case Map: - return v.object() == js.InternalObject(false) - case Interface: - return v.object() == js.Global.Get("$ifaceNil") - default: - panic(&ValueError{"reflect.Value.IsNil", k}) - } -} - -func (v Value) Len() int { - switch k := v.kind(); k { - case Array, String: - return v.object().Length() - case Slice: - return v.object().Get("$length").Int() - case Chan: - return v.object().Get("$buffer").Get("length").Int() - case Map: - return js.Global.Call("$keys", v.object()).Length() - default: - panic(&ValueError{"reflect.Value.Len", k}) - } -} - -func (v Value) Pointer() uintptr { - switch k := v.kind(); k { - case Chan, Map, Ptr, UnsafePointer: - if v.IsNil() { - return 0 - } - return v.object().Unsafe() - case Func: - if v.IsNil() { - return 0 - } - return 1 - case Slice: - if v.IsNil() { - return 0 - } - return v.object().Get("$array").Unsafe() - default: - panic(&ValueError{"reflect.Value.Pointer", k}) - } -} - -func (v Value) Set(x Value) { - v.mustBeAssignable() - x.mustBeExported() - x = x.assignTo("reflect.Set", v.typ, nil) - if v.flag&flagIndir != 0 { - switch v.typ.Kind() { - case Array: - jsType(v.typ).Call("copy", js.InternalObject(v.ptr), js.InternalObject(x.ptr)) - case Interface: - js.InternalObject(v.ptr).Call("$set", js.InternalObject(valueInterface(x, false))) - case Struct: - copyStruct(js.InternalObject(v.ptr), js.InternalObject(x.ptr), v.typ) - default: - js.InternalObject(v.ptr).Call("$set", x.object()) - } - return - } - v.ptr = x.ptr -} - -func (v Value) SetBytes(x []byte) { - v.mustBeAssignable() - v.mustBe(Slice) - if v.typ.Elem().Kind() != Uint8 { - panic("reflect.Value.SetBytes of non-byte slice") - } - slice := js.InternalObject(x) - if v.typ.Name() != "" || v.typ.Elem().Name() != "" { - typedSlice := jsType(v.typ).New(slice.Get("$array")) - typedSlice.Set("$offset", slice.Get("$offset")) - typedSlice.Set("$length", slice.Get("$length")) - typedSlice.Set("$capacity", slice.Get("$capacity")) - slice = typedSlice - } - js.InternalObject(v.ptr).Call("$set", slice) -} - -func (v Value) SetCap(n int) { - v.mustBeAssignable() - v.mustBe(Slice) - s := js.InternalObject(v.ptr).Call("$get") - if n < s.Get("$length").Int() || n > s.Get("$capacity").Int() { - panic("reflect: slice capacity out of range in SetCap") - } - newSlice := jsType(v.typ).New(s.Get("$array")) - newSlice.Set("$offset", s.Get("$offset")) - newSlice.Set("$length", s.Get("$length")) - newSlice.Set("$capacity", n) - js.InternalObject(v.ptr).Call("$set", newSlice) -} - -func (v Value) SetLen(n int) { - v.mustBeAssignable() - v.mustBe(Slice) - s := js.InternalObject(v.ptr).Call("$get") - if n < 0 || n > s.Get("$capacity").Int() { - panic("reflect: slice length out of range in SetLen") - } - newSlice := jsType(v.typ).New(s.Get("$array")) - newSlice.Set("$offset", s.Get("$offset")) - newSlice.Set("$length", n) - newSlice.Set("$capacity", s.Get("$capacity")) - js.InternalObject(v.ptr).Call("$set", newSlice) -} - -func (v Value) Slice(i, j int) Value { - var ( - cap int - typ Type - s *js.Object - ) - switch kind := v.kind(); kind { - case Array: - if v.flag&flagAddr == 0 { - panic("reflect.Value.Slice: slice of unaddressable array") - } - tt := (*arrayType)(unsafe.Pointer(v.typ)) - cap = int(tt.len) - typ = SliceOf(tt.elem) - s = jsType(typ).New(v.object()) - - case Slice: - typ = v.typ - s = v.object() - cap = s.Get("$capacity").Int() - - case String: - str := *(*string)(v.ptr) - if i < 0 || j < i || j > len(str) { - panic("reflect.Value.Slice: string slice index out of bounds") - } - return ValueOf(str[i:j]) - - default: - panic(&ValueError{"reflect.Value.Slice", kind}) - } - - if i < 0 || j < i || j > cap { - panic("reflect.Value.Slice: slice index out of bounds") - } - - return makeValue(typ, js.Global.Call("$subslice", s, i, j), v.flag&flagRO) -} - -func (v Value) Slice3(i, j, k int) Value { - var ( - cap int - typ Type - s *js.Object - ) - switch kind := v.kind(); kind { - case Array: - if v.flag&flagAddr == 0 { - panic("reflect.Value.Slice: slice of unaddressable array") - } - tt := (*arrayType)(unsafe.Pointer(v.typ)) - cap = int(tt.len) - typ = SliceOf(tt.elem) - s = jsType(typ).New(v.object()) - - case Slice: - typ = v.typ - s = v.object() - cap = s.Get("$capacity").Int() - - default: - panic(&ValueError{"reflect.Value.Slice3", kind}) - } - - if i < 0 || j < i || k < j || k > cap { - panic("reflect.Value.Slice3: slice index out of bounds") - } - - return makeValue(typ, js.Global.Call("$subslice", s, i, j, k), v.flag&flagRO) -} - -func (v Value) Close() { - v.mustBe(Chan) - v.mustBeExported() - js.Global.Call("$close", v.object()) -} - -var selectHelper = js.Global.Get("$select").Interface().(func(...interface{}) *js.Object) - -func chanrecv(t *rtype, ch unsafe.Pointer, nb bool, val unsafe.Pointer) (selected, received bool) { - comms := [][]*js.Object{{js.InternalObject(ch)}} - if nb { - comms = append(comms, []*js.Object{}) - } - selectRes := selectHelper(comms) - if nb && selectRes.Index(0).Int() == 1 { - return false, false - } - recvRes := selectRes.Index(1) - js.InternalObject(val).Call("$set", recvRes.Index(0)) - return true, recvRes.Index(1).Bool() -} - -func chansend(t *rtype, ch unsafe.Pointer, val unsafe.Pointer, nb bool) bool { - comms := [][]*js.Object{{js.InternalObject(ch), js.InternalObject(val).Call("$get")}} - if nb { - comms = append(comms, []*js.Object{}) - } - selectRes := selectHelper(comms) - if nb && selectRes.Index(0).Int() == 1 { - return false - } - return true -} - -func rselect(rselects []runtimeSelect) (chosen int, recvOK bool) { - comms := make([][]*js.Object, len(rselects)) - for i, s := range rselects { - switch SelectDir(s.dir) { - case SelectDefault: - comms[i] = []*js.Object{} - case SelectRecv: - ch := js.Global.Get("$chanNil") - if js.InternalObject(s.ch) != js.InternalObject(0) { - ch = js.InternalObject(s.ch) - } - comms[i] = []*js.Object{ch} - case SelectSend: - ch := js.Global.Get("$chanNil") - var val *js.Object - if js.InternalObject(s.ch) != js.InternalObject(0) { - ch = js.InternalObject(s.ch) - val = js.InternalObject(s.val).Call("$get") - } - comms[i] = []*js.Object{ch, val} - } - } - selectRes := selectHelper(comms) - c := selectRes.Index(0).Int() - if SelectDir(rselects[c].dir) == SelectRecv { - recvRes := selectRes.Index(1) - js.InternalObject(rselects[c].val).Call("$set", recvRes.Index(0)) - return c, recvRes.Index(1).Bool() - } - return c, false -} - -func DeepEqual(a1, a2 interface{}) bool { - i1 := js.InternalObject(a1) - i2 := js.InternalObject(a2) - if i1 == i2 { - return true - } - if i1 == nil || i2 == nil || i1.Get("constructor") != i2.Get("constructor") { - return false - } - return deepValueEqualJs(ValueOf(a1), ValueOf(a2), nil) -} - -func deepValueEqualJs(v1, v2 Value, visited [][2]unsafe.Pointer) bool { - if !v1.IsValid() || !v2.IsValid() { - return !v1.IsValid() && !v2.IsValid() - } - if v1.Type() != v2.Type() { - return false - } - if v1.Type() == jsObjectPtr { - return unwrapJsObject(jsObjectPtr, v1.object()) == unwrapJsObject(jsObjectPtr, v2.object()) - } - - switch v1.Kind() { - case Array, Map, Slice, Struct: - for _, entry := range visited { - if v1.ptr == entry[0] && v2.ptr == entry[1] { - return true - } - } - visited = append(visited, [2]unsafe.Pointer{v1.ptr, v2.ptr}) - } - - switch v1.Kind() { - case Array, Slice: - if v1.Kind() == Slice { - if v1.IsNil() != v2.IsNil() { - return false - } - if v1.object() == v2.object() { - return true - } - } - var n = v1.Len() - if n != v2.Len() { - return false - } - for i := 0; i < n; i++ { - if !deepValueEqualJs(v1.Index(i), v2.Index(i), visited) { - return false - } - } - return true - case Interface: - if v1.IsNil() || v2.IsNil() { - return v1.IsNil() && v2.IsNil() - } - return deepValueEqualJs(v1.Elem(), v2.Elem(), visited) - case Ptr: - return deepValueEqualJs(v1.Elem(), v2.Elem(), visited) - case Struct: - var n = v1.NumField() - for i := 0; i < n; i++ { - if !deepValueEqualJs(v1.Field(i), v2.Field(i), visited) { - return false - } - } - return true - case Map: - if v1.IsNil() != v2.IsNil() { - return false - } - if v1.object() == v2.object() { - return true - } - var keys = v1.MapKeys() - if len(keys) != v2.Len() { - return false - } - for _, k := range keys { - val1 := v1.MapIndex(k) - val2 := v2.MapIndex(k) - if !val1.IsValid() || !val2.IsValid() || !deepValueEqualJs(val1, val2, visited) { - return false - } - } - return true - case Func: - return v1.IsNil() && v2.IsNil() - case UnsafePointer: - return v1.object() == v2.object() - } - - return js.Global.Call("$interfaceIsEqual", js.InternalObject(valueInterface(v1, false)), js.InternalObject(valueInterface(v2, false))).Bool() -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/reflect_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/reflect_test.go deleted file mode 100644 index c2b677594..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/reflect_test.go +++ /dev/null @@ -1,154 +0,0 @@ -// +build js - -package reflect_test - -import ( - "math" - "reflect" - "testing" -) - -func TestAlignment(t *testing.T) { - t.Skip() -} - -func TestSliceOverflow(t *testing.T) { - t.Skip() -} - -func TestFuncLayout(t *testing.T) { - t.Skip() -} - -func TestArrayOfDirectIface(t *testing.T) { - t.Skip() -} - -func TestTypelinksSorted(t *testing.T) { - t.Skip() -} - -func TestGCBits(t *testing.T) { - t.Skip() -} - -func TestChanAlloc(t *testing.T) { - t.Skip() -} - -func TestNameBytesAreAligned(t *testing.T) { - t.Skip() -} - -func TestOffsetLock(t *testing.T) { - t.Skip() -} - -func TestSelectOnInvalid(t *testing.T) { - reflect.Select([]reflect.SelectCase{ - { - Dir: reflect.SelectRecv, - Chan: reflect.Value{}, - }, { - Dir: reflect.SelectSend, - Chan: reflect.Value{}, - Send: reflect.ValueOf(1), - }, { - Dir: reflect.SelectDefault, - }, - }) -} - -func TestStructOf(t *testing.T) { - t.Skip("StructOf") -} - -func TestStructOfExportRules(t *testing.T) { - t.Skip("StructOf") -} - -func TestStructOfGC(t *testing.T) { - t.Skip("StructOf") -} - -func TestStructOfAlg(t *testing.T) { - t.Skip("StructOf") -} - -func TestStructOfGenericAlg(t *testing.T) { - t.Skip("StructOf") -} - -func TestStructOfDirectIface(t *testing.T) { - t.Skip("StructOf") -} - -func TestStructOfWithInterface(t *testing.T) { - t.Skip("StructOf") -} - -var deepEqualTests = []DeepEqualTest{ - // Equalities - {nil, nil, true}, - {1, 1, true}, - {int32(1), int32(1), true}, - {0.5, 0.5, true}, - {float32(0.5), float32(0.5), true}, - {"hello", "hello", true}, - {make([]int, 10), make([]int, 10), true}, - {&[3]int{1, 2, 3}, &[3]int{1, 2, 3}, true}, - {Basic{1, 0.5}, Basic{1, 0.5}, true}, - {error(nil), error(nil), true}, - {map[int]string{1: "one", 2: "two"}, map[int]string{2: "two", 1: "one"}, true}, - {fn1, fn2, true}, - - // Inequalities - {1, 2, false}, - {int32(1), int32(2), false}, - {0.5, 0.6, false}, - {float32(0.5), float32(0.6), false}, - {"hello", "hey", false}, - {make([]int, 10), make([]int, 11), false}, - {&[3]int{1, 2, 3}, &[3]int{1, 2, 4}, false}, - {Basic{1, 0.5}, Basic{1, 0.6}, false}, - {Basic{1, 0}, Basic{2, 0}, false}, - {map[int]string{1: "one", 3: "two"}, map[int]string{2: "two", 1: "one"}, false}, - {map[int]string{1: "one", 2: "txo"}, map[int]string{2: "two", 1: "one"}, false}, - {map[int]string{1: "one"}, map[int]string{2: "two", 1: "one"}, false}, - {map[int]string{2: "two", 1: "one"}, map[int]string{1: "one"}, false}, - {nil, 1, false}, - {1, nil, false}, - {fn1, fn3, false}, - {fn3, fn3, false}, - {[][]int{{1}}, [][]int{{2}}, false}, - {math.NaN(), math.NaN(), false}, - {&[1]float64{math.NaN()}, &[1]float64{math.NaN()}, false}, - {&[1]float64{math.NaN()}, self{}, true}, - {[]float64{math.NaN()}, []float64{math.NaN()}, false}, - {[]float64{math.NaN()}, self{}, true}, - {map[float64]float64{math.NaN(): 1}, map[float64]float64{1: 2}, false}, - {map[float64]float64{math.NaN(): 1}, self{}, true}, - - // Nil vs empty: not the same. - {[]int{}, []int(nil), false}, - {[]int{}, []int{}, true}, - {[]int(nil), []int(nil), true}, - {map[int]int{}, map[int]int(nil), false}, - {map[int]int{}, map[int]int{}, true}, - {map[int]int(nil), map[int]int(nil), true}, - - // Mismatched types - {1, 1.0, false}, - {int32(1), int64(1), false}, - {0.5, "hello", false}, - {[]int{1, 2, 3}, [3]int{1, 2, 3}, false}, - {&[3]interface{}{1, 2, 4}, &[3]interface{}{1, 2, "s"}, false}, - {Basic{1, 0.5}, NotBasic{1, 0.5}, false}, - {map[uint]string{1: "one", 2: "two"}, map[int]string{2: "two", 1: "one"}, false}, - - // Possible loops. - {&loop1, &loop1, true}, - //{&loop1, &loop2, true}, // TODO: Fix. - {&loopy1, &loopy1, true}, - //{&loopy1, &loopy2, true}, // TODO: Fix. -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/swapper.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/swapper.go deleted file mode 100644 index b163fabbe..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/swapper.go +++ /dev/null @@ -1,29 +0,0 @@ -// +build js - -package reflect - -func Swapper(slice interface{}) func(i, j int) { - v := ValueOf(slice) - if v.Kind() != Slice { - panic(&ValueError{Method: "Swapper", Kind: v.Kind()}) - } - // Fast path for slices of size 0 and 1. Nothing to swap. - switch v.Len() { - case 0: - return func(i, j int) { panic("reflect: slice index out of range") } - case 1: - return func(i, j int) { - if i != 0 || j != 0 { - panic("reflect: slice index out of range") - } - } - } - tmp := New(v.Type().Elem()).Elem() - return func(i, j int) { - v1 := v.Index(i) - v2 := v.Index(j) - tmp.Set(v1) - v1.Set(v2) - v2.Set(tmp) - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/regexp/regexp_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/regexp/regexp_test.go deleted file mode 100644 index 823aec6fe..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/regexp/regexp_test.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build js - -package regexp - -import ( - "testing" -) - -func TestOnePassCutoff(t *testing.T) { - t.Skip() // "Maximum call stack size exceeded" on V8 -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/debug/debug.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/debug/debug.go deleted file mode 100644 index 6597dcc45..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/debug/debug.go +++ /dev/null @@ -1,14 +0,0 @@ -// +build js - -package debug - -func setGCPercent(int32) int32 { - // Not implemented. Return initial setting. - return 100 -} - -func setMaxStack(bytes int) int { - // Not implemented. Return initial setting. - // The initial setting is 1 GB on 64-bit systems, 250 MB on 32-bit systems. - return 250000000 -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/pprof/pprof.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/pprof/pprof.go deleted file mode 100644 index 8af83a907..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/pprof/pprof.go +++ /dev/null @@ -1,49 +0,0 @@ -// +build js - -package pprof - -import ( - "io" - "sync" -) - -type Profile struct { - name string - mu sync.Mutex - m map[interface{}][]uintptr - count func() int - write func(io.Writer, int) error -} - -func (p *Profile) WriteTo(w io.Writer, debug int) error { - return nil -} - -func (p *Profile) Count() int { - return 0 -} - -func (p *Profile) Name() string { - return "" -} - -func (p *Profile) Add(value interface{}, skip int) { -} - -func (p *Profile) Remove(value interface{}) { -} - -func StartCPUProfile(w io.Writer) error { - return nil -} - -func StopCPUProfile() { -} - -func WriteHeapProfile(w io.Writer) error { - return nil -} - -func Lookup(name string) *Profile { - return nil -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/runtime.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/runtime.go deleted file mode 100644 index 98a980498..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/runtime.go +++ /dev/null @@ -1,201 +0,0 @@ -// +build js - -package runtime - -import ( - "runtime/internal/sys" - - "github.com/gopherjs/gopherjs/js" -) - -const GOOS = sys.GOOS -const GOARCH = "js" -const Compiler = "gopherjs" - -// fake for error.go -type eface struct { - _type *_type -} -type _type struct { -} - -func (t *_type) string() string { - return "" -} - -func init() { - jsPkg := js.Global.Get("$packages").Get("github.com/gopherjs/gopherjs/js") - js.Global.Set("$jsObjectPtr", jsPkg.Get("Object").Get("ptr")) - js.Global.Set("$jsErrorPtr", jsPkg.Get("Error").Get("ptr")) - js.Global.Set("$throwRuntimeError", js.InternalObject(func(msg string) { - panic(errorString(msg)) - })) - // avoid dead code elimination - var e error - e = &TypeAssertionError{} - _ = e -} - -func GOROOT() string { - process := js.Global.Get("process") - if process == js.Undefined { - return "/" - } - goroot := process.Get("env").Get("GOROOT") - if goroot != js.Undefined { - return goroot.String() - } - return sys.DefaultGoroot -} - -func Breakpoint() { - js.Debugger() -} - -func Caller(skip int) (pc uintptr, file string, line int, ok bool) { - info := js.Global.Get("Error").New().Get("stack").Call("split", "\n").Index(skip + 2) - if info == js.Undefined { - return 0, "", 0, false - } - parts := info.Call("substring", info.Call("indexOf", "(").Int()+1, info.Call("indexOf", ")").Int()).Call("split", ":") - return 0, parts.Index(0).String(), parts.Index(1).Int(), true -} - -func Callers(skip int, pc []uintptr) int { - return 0 -} - -func GC() { -} - -func Goexit() { - js.Global.Get("$curGoroutine").Set("exit", true) - js.Global.Call("$throw", nil) -} - -func GOMAXPROCS(n int) int { - return 1 -} - -func Gosched() { - c := make(chan struct{}) - js.Global.Call("$setTimeout", js.InternalObject(func() { close(c) }), 0) - <-c -} - -func NumCPU() int { - return 1 -} - -func NumGoroutine() int { - return js.Global.Get("$totalGoroutines").Int() -} - -type MemStats struct { - // General statistics. - Alloc uint64 // bytes allocated and still in use - TotalAlloc uint64 // bytes allocated (even if freed) - Sys uint64 // bytes obtained from system (sum of XxxSys below) - Lookups uint64 // number of pointer lookups - Mallocs uint64 // number of mallocs - Frees uint64 // number of frees - - // Main allocation heap statistics. - HeapAlloc uint64 // bytes allocated and still in use - HeapSys uint64 // bytes obtained from system - HeapIdle uint64 // bytes in idle spans - HeapInuse uint64 // bytes in non-idle span - HeapReleased uint64 // bytes released to the OS - HeapObjects uint64 // total number of allocated objects - - // Low-level fixed-size structure allocator statistics. - // Inuse is bytes used now. - // Sys is bytes obtained from system. - StackInuse uint64 // bytes used by stack allocator - StackSys uint64 - MSpanInuse uint64 // mspan structures - MSpanSys uint64 - MCacheInuse uint64 // mcache structures - MCacheSys uint64 - BuckHashSys uint64 // profiling bucket hash table - GCSys uint64 // GC metadata - OtherSys uint64 // other system allocations - - // Garbage collector statistics. - NextGC uint64 // next collection will happen when HeapAlloc ≥ this amount - LastGC uint64 // end time of last collection (nanoseconds since 1970) - PauseTotalNs uint64 - PauseNs [256]uint64 // circular buffer of recent GC pause durations, most recent at [(NumGC+255)%256] - PauseEnd [256]uint64 // circular buffer of recent GC pause end times - NumGC uint32 - GCCPUFraction float64 // fraction of CPU time used by GC - EnableGC bool - DebugGC bool - - // Per-size allocation statistics. - // 61 is NumSizeClasses in the C code. - BySize [61]struct { - Size uint32 - Mallocs uint64 - Frees uint64 - } -} - -func ReadMemStats(m *MemStats) { -} - -func SetFinalizer(x, f interface{}) { -} - -type Func struct { - opaque struct{} // unexported field to disallow conversions -} - -func (_ *Func) Entry() uintptr { return 0 } -func (_ *Func) FileLine(pc uintptr) (file string, line int) { return "", 0 } -func (_ *Func) Name() string { return "" } - -func FuncForPC(pc uintptr) *Func { - return nil -} - -var MemProfileRate int = 512 * 1024 - -func SetBlockProfileRate(rate int) { -} - -func SetMutexProfileFraction(rate int) int { - // TODO: Investigate this. If it's possible to implement, consider doing so, otherwise remove this comment. - return 0 -} - -func Stack(buf []byte, all bool) int { - s := js.Global.Get("Error").New().Get("stack") - if s == js.Undefined { - return 0 - } - return copy(buf, s.Call("substr", s.Call("indexOf", "\n").Int()+1).String()) -} - -func LockOSThread() {} - -func UnlockOSThread() {} - -func Version() string { - return sys.TheVersion -} - -func StartTrace() error { return nil } -func StopTrace() {} -func ReadTrace() []byte - -// We fake a cgo environment to catch errors. Therefor we have to implement this and always return 0 -func NumCgoCall() int64 { - return 0 -} - -func efaceOf(ep *interface{}) *eface { - panic("efaceOf: not supported") -} - -func KeepAlive(interface{}) {} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/strings/strings.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/strings/strings.go deleted file mode 100644 index da96a3997..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/strings/strings.go +++ /dev/null @@ -1,47 +0,0 @@ -// +build js - -package strings - -import ( - "unicode/utf8" - - "github.com/gopherjs/gopherjs/js" -) - -func IndexByte(s string, c byte) int { - return js.InternalObject(s).Call("indexOf", js.Global.Get("String").Call("fromCharCode", c)).Int() -} - -func Index(s, sep string) int { - return js.InternalObject(s).Call("indexOf", js.InternalObject(sep)).Int() -} - -func LastIndex(s, sep string) int { - return js.InternalObject(s).Call("lastIndexOf", js.InternalObject(sep)).Int() -} - -func Count(s, sep string) int { - n := 0 - // special cases - switch { - case len(sep) == 0: - return utf8.RuneCountInString(s) + 1 - case len(sep) > len(s): - return 0 - case len(sep) == len(s): - if sep == s { - return 1 - } - return 0 - } - - for { - pos := Index(s, sep) - if pos == -1 { - break - } - n++ - s = s[pos+len(sep):] - } - return n -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/atomic/atomic.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/atomic/atomic.go deleted file mode 100644 index 636017121..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/atomic/atomic.go +++ /dev/null @@ -1,185 +0,0 @@ -// +build js - -package atomic - -import ( - "unsafe" - - "github.com/gopherjs/gopherjs/js" -) - -func SwapInt32(addr *int32, new int32) int32 { - old := *addr - *addr = new - return old -} - -func SwapInt64(addr *int64, new int64) int64 { - old := *addr - *addr = new - return old -} - -func SwapUint32(addr *uint32, new uint32) uint32 { - old := *addr - *addr = new - return old -} - -func SwapUint64(addr *uint64, new uint64) uint64 { - old := *addr - *addr = new - return old -} - -func SwapUintptr(addr *uintptr, new uintptr) uintptr { - old := *addr - *addr = new - return old -} - -func SwapPointer(addr *unsafe.Pointer, new unsafe.Pointer) unsafe.Pointer { - old := *addr - *addr = new - return old -} - -func CompareAndSwapInt32(addr *int32, old, new int32) bool { - if *addr == old { - *addr = new - return true - } - return false -} - -func CompareAndSwapInt64(addr *int64, old, new int64) bool { - if *addr == old { - *addr = new - return true - } - return false -} - -func CompareAndSwapUint32(addr *uint32, old, new uint32) bool { - if *addr == old { - *addr = new - return true - } - return false -} - -func CompareAndSwapUint64(addr *uint64, old, new uint64) bool { - if *addr == old { - *addr = new - return true - } - return false -} - -func CompareAndSwapUintptr(addr *uintptr, old, new uintptr) bool { - if *addr == old { - *addr = new - return true - } - return false -} - -func CompareAndSwapPointer(addr *unsafe.Pointer, old, new unsafe.Pointer) bool { - if *addr == old { - *addr = new - return true - } - return false -} - -func AddInt32(addr *int32, delta int32) int32 { - new := *addr + delta - *addr = new - return new -} - -func AddUint32(addr *uint32, delta uint32) uint32 { - new := *addr + delta - *addr = new - return new -} - -func AddInt64(addr *int64, delta int64) int64 { - new := *addr + delta - *addr = new - return new -} - -func AddUint64(addr *uint64, delta uint64) uint64 { - new := *addr + delta - *addr = new - return new -} - -func AddUintptr(addr *uintptr, delta uintptr) uintptr { - new := *addr + delta - *addr = new - return new -} - -func LoadInt32(addr *int32) int32 { - return *addr -} - -func LoadInt64(addr *int64) int64 { - return *addr -} - -func LoadUint32(addr *uint32) uint32 { - return *addr -} - -func LoadUint64(addr *uint64) uint64 { - return *addr -} - -func LoadUintptr(addr *uintptr) uintptr { - return *addr -} - -func LoadPointer(addr *unsafe.Pointer) unsafe.Pointer { - return *addr -} - -func StoreInt32(addr *int32, val int32) { - *addr = val -} - -func StoreInt64(addr *int64, val int64) { - *addr = val -} - -func StoreUint32(addr *uint32, val uint32) { - *addr = val -} - -func StoreUint64(addr *uint64, val uint64) { - *addr = val -} - -func StoreUintptr(addr *uintptr, val uintptr) { - *addr = val -} - -func StorePointer(addr *unsafe.Pointer, val unsafe.Pointer) { - *addr = val -} - -func (v *Value) Load() (x interface{}) { - return v.v -} - -func (v *Value) Store(x interface{}) { - if x == nil { - panic("sync/atomic: store of nil value into Value") - } - if v.v != nil && js.InternalObject(x).Get("constructor") != js.InternalObject(v.v).Get("constructor") { - panic("sync/atomic: store of inconsistently typed value into Value") - } - v.v = x -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/atomic/atomic_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/atomic/atomic_test.go deleted file mode 100644 index 9ad30a2c7..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/atomic/atomic_test.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build js - -package atomic_test - -import "testing" - -func TestHammerStoreLoad(t *testing.T) { - t.Skip("use of unsafe") -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/cond.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/cond.go deleted file mode 100644 index 829dac2ef..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/cond.go +++ /dev/null @@ -1,41 +0,0 @@ -// +build js - -package sync - -type Cond struct { - // fields used by vanilla implementation - noCopy noCopy - L Locker - notify notifyList - checker copyChecker - - // fields used by new implementation - n int - ch chan bool -} - -func (c *Cond) Wait() { - c.n++ - if c.ch == nil { - c.ch = make(chan bool) - } - c.L.Unlock() - <-c.ch - c.L.Lock() -} - -func (c *Cond) Signal() { - if c.n == 0 { - return - } - c.n-- - c.ch <- true -} - -func (c *Cond) Broadcast() { - n := c.n - c.n = 0 - for i := 0; i < n; i++ { - c.ch <- true - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/pool.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/pool.go deleted file mode 100644 index 629010d9e..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/pool.go +++ /dev/null @@ -1,35 +0,0 @@ -// +build js - -package sync - -import "unsafe" - -type Pool struct { - local unsafe.Pointer - localSize uintptr - - store []interface{} - New func() interface{} -} - -func (p *Pool) Get() interface{} { - if len(p.store) == 0 { - if p.New != nil { - return p.New() - } - return nil - } - x := p.store[len(p.store)-1] - p.store = p.store[:len(p.store)-1] - return x -} - -func (p *Pool) Put(x interface{}) { - if x == nil { - return - } - p.store = append(p.store, x) -} - -func runtime_registerPoolCleanup(cleanup func()) { -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/sync.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/sync.go deleted file mode 100644 index 3d86637aa..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/sync.go +++ /dev/null @@ -1,43 +0,0 @@ -// +build js - -package sync - -var semWaiters = make(map[*uint32][]chan bool) - -func runtime_Semacquire(s *uint32) { - if *s == 0 { - ch := make(chan bool) - semWaiters[s] = append(semWaiters[s], ch) - <-ch - } - *s-- -} - -// SemacquireMutex is like Semacquire, but for profiling contended Mutexes. -// Mutex profiling is not supported, so just use the same implementation. -// TODO: Investigate this. If it's possible to implement, consider doing so, otherwise remove this comment. -var runtime_SemacquireMutex = runtime_Semacquire - -func runtime_Semrelease(s *uint32) { - *s++ - - w := semWaiters[s] - if len(w) == 0 { - return - } - - ch := w[0] - w = w[1:] - semWaiters[s] = w - if len(w) == 0 { - delete(semWaiters, s) - } - - ch <- true -} - -func runtime_notifyListCheck(size uintptr) {} - -func runtime_canSpin(i int) bool { - return false -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/sync_test.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/sync_test.go deleted file mode 100644 index a61bcf3e1..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/sync_test.go +++ /dev/null @@ -1,23 +0,0 @@ -// +build js - -package sync_test - -import ( - "testing" -) - -func TestPool(t *testing.T) { - t.Skip() -} - -func TestPoolGC(t *testing.T) { - t.Skip() -} - -func TestPoolRelease(t *testing.T) { - t.Skip() -} - -func TestCondCopy(t *testing.T) { - t.Skip() -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/waitgroup.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/waitgroup.go deleted file mode 100644 index 993f94b6a..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/waitgroup.go +++ /dev/null @@ -1,29 +0,0 @@ -package sync - -type WaitGroup struct { - counter int - ch chan struct{} - - state1 [12]byte - sema uint32 -} - -func (wg *WaitGroup) Add(delta int) { - wg.counter += delta - if wg.counter < 0 { - panic("sync: negative WaitGroup counter") - } - if wg.counter > 0 && wg.ch == nil { - wg.ch = make(chan struct{}) - } - if wg.counter == 0 && wg.ch != nil { - close(wg.ch) - wg.ch = nil - } -} - -func (wg *WaitGroup) Wait() { - if wg.counter > 0 { - <-wg.ch - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/syscall/syscall.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/syscall/syscall.go deleted file mode 100644 index a269ea717..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/syscall/syscall.go +++ /dev/null @@ -1,60 +0,0 @@ -// +build js - -package syscall - -import ( - "unsafe" - - "github.com/gopherjs/gopherjs/js" -) - -var warningPrinted = false -var lineBuffer []byte - -func init() { - js.Global.Set("$flushConsole", js.InternalObject(func() { - if len(lineBuffer) != 0 { - js.Global.Get("console").Call("log", string(lineBuffer)) - lineBuffer = nil - } - })) -} - -func printWarning() { - if !warningPrinted { - js.Global.Get("console").Call("error", "warning: system calls not available, see https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md") - } - warningPrinted = true -} - -func printToConsole(b []byte) { - goPrintToConsole := js.Global.Get("goPrintToConsole") - if goPrintToConsole != js.Undefined { - goPrintToConsole.Invoke(js.InternalObject(b)) - return - } - - lineBuffer = append(lineBuffer, b...) - for { - i := indexByte(lineBuffer, '\n') - if i == -1 { - break - } - js.Global.Get("console").Call("log", string(lineBuffer[:i])) // don't use println, since it does not externalize multibyte characters - lineBuffer = lineBuffer[i+1:] - } -} - -func use(p unsafe.Pointer) { - // no-op -} - -// indexByte is copied from bytes package to avoid importing it (since the real syscall package doesn't). -func indexByte(s []byte, c byte) int { - for i, b := range s { - if b == c { - return i - } - } - return -1 -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/syscall/syscall_unix.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/syscall/syscall_unix.go deleted file mode 100644 index cd2c58913..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/syscall/syscall_unix.go +++ /dev/null @@ -1,115 +0,0 @@ -// +build js,!windows - -package syscall - -import ( - "runtime" - "unsafe" - - "github.com/gopherjs/gopherjs/js" -) - -func runtime_envs() []string { - process := js.Global.Get("process") - if process == js.Undefined { - return nil - } - jsEnv := process.Get("env") - envkeys := js.Global.Get("Object").Call("keys", jsEnv) - envs := make([]string, envkeys.Length()) - for i := 0; i < envkeys.Length(); i++ { - key := envkeys.Index(i).String() - envs[i] = key + "=" + jsEnv.Get(key).String() - } - return envs -} - -func setenv_c(k, v string) { - process := js.Global.Get("process") - if process != js.Undefined { - process.Get("env").Set(k, v) - } -} - -var syscallModule *js.Object -var alreadyTriedToLoad = false -var minusOne = -1 - -func syscall(name string) *js.Object { - defer func() { - recover() - // return nil if recovered - }() - if syscallModule == nil { - if alreadyTriedToLoad { - return nil - } - alreadyTriedToLoad = true - require := js.Global.Get("require") - if require == js.Undefined { - panic("") - } - syscallModule = require.Invoke("syscall") - } - return syscallModule.Get(name) -} - -func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { - if f := syscall("Syscall"); f != nil { - r := f.Invoke(trap, a1, a2, a3) - return uintptr(r.Index(0).Int()), uintptr(r.Index(1).Int()), Errno(r.Index(2).Int()) - } - if trap == SYS_WRITE && (a1 == 1 || a1 == 2) { - array := js.InternalObject(a2) - slice := make([]byte, array.Length()) - js.InternalObject(slice).Set("$array", array) - printToConsole(slice) - return uintptr(array.Length()), 0, 0 - } - if trap == SYS_EXIT { - runtime.Goexit() - } - printWarning() - return uintptr(minusOne), 0, EACCES -} - -func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { - if f := syscall("Syscall6"); f != nil { - r := f.Invoke(trap, a1, a2, a3, a4, a5, a6) - return uintptr(r.Index(0).Int()), uintptr(r.Index(1).Int()), Errno(r.Index(2).Int()) - } - if trap != 202 { // kern.osrelease on OS X, happens in init of "os" package - printWarning() - } - return uintptr(minusOne), 0, EACCES -} - -func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { - if f := syscall("Syscall"); f != nil { - r := f.Invoke(trap, a1, a2, a3) - return uintptr(r.Index(0).Int()), uintptr(r.Index(1).Int()), Errno(r.Index(2).Int()) - } - printWarning() - return uintptr(minusOne), 0, EACCES -} - -func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { - if f := syscall("Syscall6"); f != nil { - r := f.Invoke(trap, a1, a2, a3, a4, a5, a6) - return uintptr(r.Index(0).Int()), uintptr(r.Index(1).Int()), Errno(r.Index(2).Int()) - } - printWarning() - return uintptr(minusOne), 0, EACCES -} - -func BytePtrFromString(s string) (*byte, error) { - array := js.Global.Get("Uint8Array").New(len(s) + 1) - for i, b := range []byte(s) { - if b == 0 { - return nil, EINVAL - } - array.SetIndex(i, b) - } - array.SetIndex(len(s), 0) - return (*byte)(unsafe.Pointer(array.Unsafe())), nil -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/syscall/syscall_windows.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/syscall/syscall_windows.go deleted file mode 100644 index 016be8e54..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/syscall/syscall_windows.go +++ /dev/null @@ -1,100 +0,0 @@ -// +build js - -package syscall - -import "runtime" - -var minusOne = -1 - -func Syscall(trap, nargs, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { - printWarning() - return uintptr(minusOne), 0, EACCES -} - -func Syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { - printWarning() - return uintptr(minusOne), 0, EACCES -} - -func Syscall9(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) { - printWarning() - return uintptr(minusOne), 0, EACCES -} - -func Syscall12(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12 uintptr) (r1, r2 uintptr, err Errno) { - printWarning() - return uintptr(minusOne), 0, EACCES -} - -func Syscall15(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2 uintptr, err Errno) { - printWarning() - return uintptr(minusOne), 0, EACCES -} - -func loadlibrary(filename *uint16) (handle uintptr, err Errno) { - printWarning() - return uintptr(minusOne), EACCES -} - -func getprocaddress(handle uintptr, procname *uint8) (proc uintptr, err Errno) { - printWarning() - return uintptr(minusOne), EACCES -} - -func (d *LazyDLL) Load() error { - return &DLLError{Msg: "system calls not available, see https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md"} -} - -func (p *LazyProc) Find() error { - return &DLLError{Msg: "system calls not available, see https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md"} -} - -func getStdHandle(h int) (fd Handle) { - if h == STD_OUTPUT_HANDLE { - return 1 - } - if h == STD_ERROR_HANDLE { - return 2 - } - return 0 -} - -func GetConsoleMode(console Handle, mode *uint32) (err error) { - return DummyError{} -} - -func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) { - if handle == 1 || handle == 2 { - printToConsole(buf) - *done = uint32(len(buf)) - return nil - } - printWarning() - return nil -} - -func ExitProcess(exitcode uint32) { - runtime.Goexit() -} - -func GetCommandLine() (cmd *uint16) { - return -} - -func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) { - return nil, DummyError{} -} - -func Getenv(key string) (value string, found bool) { - return "", false -} - -func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) { - return 0, DummyError{} -} - -type DummyError struct{} - -func (e DummyError) Error() string { - return "" -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/testing/example.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/testing/example.go deleted file mode 100644 index b44af1328..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/testing/example.go +++ /dev/null @@ -1,70 +0,0 @@ -// +build js - -package testing - -import ( - "fmt" - "os" - "strings" - "time" -) - -func runExample(eg InternalExample) (ok bool) { - if *chatty { - fmt.Printf("=== RUN %s\n", eg.Name) - } - - // Capture stdout. - stdout := os.Stdout - w, err := tempFile("." + eg.Name + ".stdout.") - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - os.Stdout = w - - start := time.Now() - ok = true - - // Clean up in a deferred call so we can recover if the example panics. - defer func() { - dstr := fmtDuration(time.Now().Sub(start)) - - // Close file, restore stdout, get output. - w.Close() - os.Stdout = stdout - out, readFileErr := readFile(w.Name()) - _ = os.Remove(w.Name()) - if readFileErr != nil { - fmt.Fprintf(os.Stderr, "testing: reading stdout file: %v\n", readFileErr) - os.Exit(1) - } - - var fail string - err := recover() - got := strings.TrimSpace(out) - want := strings.TrimSpace(eg.Output) - if eg.Unordered { - if sortLines(got) != sortLines(want) && err == nil { - fail = fmt.Sprintf("got:\n%s\nwant (unordered):\n%s\n", out, eg.Output) - } - } else { - if got != want && err == nil { - fail = fmt.Sprintf("got:\n%s\nwant:\n%s\n", got, want) - } - } - if fail != "" || err != nil { - fmt.Printf("--- FAIL: %s (%s)\n%s", eg.Name, dstr, fail) - ok = false - } else if *chatty { - fmt.Printf("--- PASS: %s (%s)\n", eg.Name, dstr) - } - if err != nil { - panic(err) - } - }() - - // Run example. - eg.F() - return -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/testing/ioutil.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/testing/ioutil.go deleted file mode 100644 index a1527f9cc..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/testing/ioutil.go +++ /dev/null @@ -1,66 +0,0 @@ -// +build js - -package testing - -import ( - "bytes" - "io" - "os" - "strconv" - "sync" - "time" -) - -var rand uint32 -var randmu sync.Mutex - -func reseed() uint32 { - return uint32(time.Now().UnixNano() + int64(os.Getpid())) -} - -func nextSuffix() string { - randmu.Lock() - r := rand - if r == 0 { - r = reseed() - } - r = r*1664525 + 1013904223 // constants from Numerical Recipes - rand = r - randmu.Unlock() - return strconv.Itoa(int(1e9 + r%1e9))[1:] -} - -// A functional copy of ioutil.TempFile, to avoid extra imports. -func tempFile(prefix string) (f *os.File, err error) { - dir := os.TempDir() - - nconflict := 0 - for i := 0; i < 10000; i++ { - name := dir + string(os.PathSeparator) + prefix + nextSuffix() - f, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) - if os.IsExist(err) { - if nconflict++; nconflict > 10 { - randmu.Lock() - rand = reseed() - randmu.Unlock() - } - continue - } - break - } - return -} - -func readFile(filename string) (string, error) { - f, err := os.Open(filename) - if err != nil { - return "", err - } - defer f.Close() - var buf bytes.Buffer - _, err = io.Copy(&buf, f) - if err != nil { - return "", err - } - return buf.String(), nil -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/text/template/template.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/text/template/template.go deleted file mode 100644 index 619df98e6..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/text/template/template.go +++ /dev/null @@ -1,3 +0,0 @@ -package template - -const maxExecDepth = 3000 diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/time/time.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/time/time.go deleted file mode 100644 index 0dff8395c..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/time/time.go +++ /dev/null @@ -1,101 +0,0 @@ -// +build js - -package time - -import ( - "runtime" - - "github.com/gopherjs/gopherjs/js" -) - -// Make sure time.Unix func and time.Time struct it returns are always included with this package (despite DCE), -// because they're needed for internalization/externalization of time.Time/Date. See issue https://github.com/gopherjs/gopherjs/issues/279. -func init() { - // avoid dead code elimination - var _ Time = Unix(0, 0) -} - -type runtimeTimer struct { - i int32 - when int64 - period int64 - f func(interface{}, uintptr) - arg interface{} - timeout *js.Object - active bool -} - -func initLocal() { - d := js.Global.Get("Date").New() - s := d.String() - i := indexByte(s, '(') - j := indexByte(s, ')') - if i == -1 || j == -1 { - localLoc.name = "UTC" - return - } - localLoc.name = s[i+1 : j] - localLoc.zone = []zone{{localLoc.name, d.Call("getTimezoneOffset").Int() * -60, false}} -} - -func runtimeNano() int64 { - return js.Global.Get("Date").New().Call("getTime").Int64() * int64(Millisecond) -} - -func now() (sec int64, nsec int32) { - n := runtimeNano() - return n / int64(Second), int32(n % int64(Second)) -} - -func Sleep(d Duration) { - c := make(chan struct{}) - js.Global.Call("$setTimeout", js.InternalObject(func() { close(c) }), int(d/Millisecond)) - <-c -} - -func startTimer(t *runtimeTimer) { - t.active = true - diff := (t.when - runtimeNano()) / int64(Millisecond) - if diff > 1<<31-1 { // math.MaxInt32 - return - } - if diff < 0 { - diff = 0 - } - t.timeout = js.Global.Call("$setTimeout", js.InternalObject(func() { - t.active = false - if t.period != 0 { - t.when += t.period - startTimer(t) - } - go t.f(t.arg, 0) - }), diff+1) -} - -func stopTimer(t *runtimeTimer) bool { - js.Global.Call("clearTimeout", t.timeout) - wasActive := t.active - t.active = false - return wasActive -} - -func loadLocation(name string) (*Location, error) { - return loadZoneFile(runtime.GOROOT()+"/lib/time/zoneinfo.zip", name) -} - -func forceZipFileForTesting(zipOnly bool) { -} - -func initTestingZone() { - z, err := loadLocation("America/Los_Angeles") - if err != nil { - panic("cannot load America/Los_Angeles for testing: " + err.Error()) - } - z.name = "Local" - localLoc = *z -} - -// indexByte is copied from strings package to avoid importing it (since the real time package doesn't). -func indexByte(s string, c byte) int { - return js.InternalObject(s).Call("indexOf", js.Global.Get("String").Call("fromCharCode", c)).Int() -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/unicode/unicode.go b/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/unicode/unicode.go deleted file mode 100644 index c03d5d3e8..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/natives/src/unicode/unicode.go +++ /dev/null @@ -1,28 +0,0 @@ -// +build js - -package unicode - -func to(_case int, r rune, caseRange []CaseRange) rune { - if _case < 0 || MaxCase <= _case { - return ReplacementChar - } - lo := 0 - hi := len(caseRange) - for lo < hi { - m := lo + (hi-lo)/2 - cr := &caseRange[m] // performance critical for GopherJS: get address here instead of copying the CaseRange - if rune(cr.Lo) <= r && r <= rune(cr.Hi) { - delta := rune(cr.Delta[_case]) - if delta > MaxRune { - return rune(cr.Lo) + ((r-rune(cr.Lo))&^1 | rune(_case&1)) - } - return r + delta - } - if r < rune(cr.Lo) { - hi = m - } else { - lo = m + 1 - } - } - return r -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/package.go b/vendor/github.com/gopherjs/gopherjs/compiler/package.go deleted file mode 100644 index d2a9a758a..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/package.go +++ /dev/null @@ -1,801 +0,0 @@ -package compiler - -import ( - "bytes" - "encoding/json" - "fmt" - "go/ast" - "go/constant" - "go/token" - "go/types" - "sort" - "strings" - - "github.com/gopherjs/gopherjs/compiler/analysis" - "github.com/gopherjs/gopherjs/third_party/importer" - "github.com/neelance/astrewrite" - "golang.org/x/tools/go/types/typeutil" -) - -type pkgContext struct { - *analysis.Info - additionalSelections map[*ast.SelectorExpr]selection - - typeNames []*types.TypeName - pkgVars map[string]string - objectNames map[types.Object]string - varPtrNames map[*types.Var]string - anonTypes []*types.TypeName - anonTypeMap typeutil.Map - escapingVars map[*types.Var]bool - indentation int - dependencies map[types.Object]bool - minify bool - fileSet *token.FileSet - errList ErrorList -} - -func (p *pkgContext) SelectionOf(e *ast.SelectorExpr) (selection, bool) { - if sel, ok := p.Selections[e]; ok { - return sel, true - } - if sel, ok := p.additionalSelections[e]; ok { - return sel, true - } - return nil, false -} - -type selection interface { - Kind() types.SelectionKind - Recv() types.Type - Index() []int - Obj() types.Object - Type() types.Type -} - -type fakeSelection struct { - kind types.SelectionKind - recv types.Type - index []int - obj types.Object - typ types.Type -} - -func (sel *fakeSelection) Kind() types.SelectionKind { return sel.kind } -func (sel *fakeSelection) Recv() types.Type { return sel.recv } -func (sel *fakeSelection) Index() []int { return sel.index } -func (sel *fakeSelection) Obj() types.Object { return sel.obj } -func (sel *fakeSelection) Type() types.Type { return sel.typ } - -type funcContext struct { - *analysis.FuncInfo - p *pkgContext - parent *funcContext - sig *types.Signature - allVars map[string]int - localVars []string - resultNames []ast.Expr - flowDatas map[*types.Label]*flowData - caseCounter int - labelCases map[*types.Label]int - output []byte - delayedOutput []byte - posAvailable bool - pos token.Pos -} - -type flowData struct { - postStmt func() - beginCase int - endCase int -} - -type ImportContext struct { - Packages map[string]*types.Package - Import func(string) (*Archive, error) -} - -// packageImporter implements go/types.Importer interface. -type packageImporter struct { - importContext *ImportContext - importError *error // A pointer to importError in Compile. -} - -func (pi packageImporter) Import(path string) (*types.Package, error) { - if path == "unsafe" { - return types.Unsafe, nil - } - - a, err := pi.importContext.Import(path) - if err != nil { - if *pi.importError == nil { - // If import failed, show first error of import only (https://github.com/gopherjs/gopherjs/issues/119). - *pi.importError = err - } - return nil, err - } - - return pi.importContext.Packages[a.ImportPath], nil -} - -func Compile(importPath string, files []*ast.File, fileSet *token.FileSet, importContext *ImportContext, minify bool) (*Archive, error) { - typesInfo := &types.Info{ - Types: make(map[ast.Expr]types.TypeAndValue), - Defs: make(map[*ast.Ident]types.Object), - Uses: make(map[*ast.Ident]types.Object), - Implicits: make(map[ast.Node]types.Object), - Selections: make(map[*ast.SelectorExpr]*types.Selection), - Scopes: make(map[ast.Node]*types.Scope), - } - - var importError error - var errList ErrorList - var previousErr error - config := &types.Config{ - Importer: packageImporter{ - importContext: importContext, - importError: &importError, - }, - Sizes: sizes32, - Error: func(err error) { - if previousErr != nil && previousErr.Error() == err.Error() { - return - } - errList = append(errList, err) - previousErr = err - }, - } - typesPkg, err := config.Check(importPath, fileSet, files, typesInfo) - if importError != nil { - return nil, importError - } - if errList != nil { - if len(errList) > 10 { - pos := token.NoPos - if last, ok := errList[9].(types.Error); ok { - pos = last.Pos - } - errList = append(errList[:10], types.Error{Fset: fileSet, Pos: pos, Msg: "too many errors"}) - } - return nil, errList - } - if err != nil { - return nil, err - } - importContext.Packages[importPath] = typesPkg - - exportData := importer.ExportData(typesPkg) - encodedFileSet := bytes.NewBuffer(nil) - if err := fileSet.Write(json.NewEncoder(encodedFileSet).Encode); err != nil { - return nil, err - } - - simplifiedFiles := make([]*ast.File, len(files)) - for i, file := range files { - simplifiedFiles[i] = astrewrite.Simplify(file, typesInfo, false) - } - - isBlocking := func(f *types.Func) bool { - archive, err := importContext.Import(f.Pkg().Path()) - if err != nil { - panic(err) - } - fullName := f.FullName() - for _, d := range archive.Declarations { - if string(d.FullName) == fullName { - return d.Blocking - } - } - panic(fullName) - } - pkgInfo := analysis.AnalyzePkg(simplifiedFiles, fileSet, typesInfo, typesPkg, isBlocking) - c := &funcContext{ - FuncInfo: pkgInfo.InitFuncInfo, - p: &pkgContext{ - Info: pkgInfo, - additionalSelections: make(map[*ast.SelectorExpr]selection), - - pkgVars: make(map[string]string), - objectNames: make(map[types.Object]string), - varPtrNames: make(map[*types.Var]string), - escapingVars: make(map[*types.Var]bool), - indentation: 1, - dependencies: make(map[types.Object]bool), - minify: minify, - fileSet: fileSet, - }, - allVars: make(map[string]int), - flowDatas: map[*types.Label]*flowData{nil: {}}, - caseCounter: 1, - labelCases: make(map[*types.Label]int), - } - for name := range reservedKeywords { - c.allVars[name] = 1 - } - - // imports - var importDecls []*Decl - var importedPaths []string - for _, importedPkg := range typesPkg.Imports() { - c.p.pkgVars[importedPkg.Path()] = c.newVariableWithLevel(importedPkg.Name(), true) - importedPaths = append(importedPaths, importedPkg.Path()) - } - sort.Strings(importedPaths) - for _, impPath := range importedPaths { - id := c.newIdent(fmt.Sprintf(`%s.$init`, c.p.pkgVars[impPath]), types.NewSignature(nil, nil, nil, false)) - call := &ast.CallExpr{Fun: id} - c.Blocking[call] = true - c.Flattened[call] = true - importDecls = append(importDecls, &Decl{ - Vars: []string{c.p.pkgVars[impPath]}, - DeclCode: []byte(fmt.Sprintf("\t%s = $packages[\"%s\"];\n", c.p.pkgVars[impPath], impPath)), - InitCode: c.CatchOutput(1, func() { c.translateStmt(&ast.ExprStmt{X: call}, nil) }), - }) - } - - var functions []*ast.FuncDecl - var vars []*types.Var - for _, file := range simplifiedFiles { - for _, decl := range file.Decls { - switch d := decl.(type) { - case *ast.FuncDecl: - sig := c.p.Defs[d.Name].(*types.Func).Type().(*types.Signature) - var recvType types.Type - if sig.Recv() != nil { - recvType = sig.Recv().Type() - if ptr, isPtr := recvType.(*types.Pointer); isPtr { - recvType = ptr.Elem() - } - } - if sig.Recv() == nil { - c.objectName(c.p.Defs[d.Name].(*types.Func)) // register toplevel name - } - if !isBlank(d.Name) { - functions = append(functions, d) - } - case *ast.GenDecl: - switch d.Tok { - case token.TYPE: - for _, spec := range d.Specs { - o := c.p.Defs[spec.(*ast.TypeSpec).Name].(*types.TypeName) - c.p.typeNames = append(c.p.typeNames, o) - c.objectName(o) // register toplevel name - } - case token.VAR: - for _, spec := range d.Specs { - for _, name := range spec.(*ast.ValueSpec).Names { - if !isBlank(name) { - o := c.p.Defs[name].(*types.Var) - vars = append(vars, o) - c.objectName(o) // register toplevel name - } - } - } - case token.CONST: - // skip, constants are inlined - } - } - } - } - - collectDependencies := func(f func()) []string { - c.p.dependencies = make(map[types.Object]bool) - f() - var deps []string - for o := range c.p.dependencies { - qualifiedName := o.Pkg().Path() + "." + o.Name() - if f, ok := o.(*types.Func); ok && f.Type().(*types.Signature).Recv() != nil { - deps = append(deps, qualifiedName+"~") - continue - } - deps = append(deps, qualifiedName) - } - sort.Strings(deps) - return deps - } - - // variables - var varDecls []*Decl - varsWithInit := make(map[*types.Var]bool) - for _, init := range c.p.InitOrder { - for _, o := range init.Lhs { - varsWithInit[o] = true - } - } - for _, o := range vars { - var d Decl - if !o.Exported() { - d.Vars = []string{c.objectName(o)} - } - if c.p.HasPointer[o] && !o.Exported() { - d.Vars = append(d.Vars, c.varPtrName(o)) - } - if _, ok := varsWithInit[o]; !ok { - d.DceDeps = collectDependencies(func() { - d.InitCode = []byte(fmt.Sprintf("\t\t%s = %s;\n", c.objectName(o), c.translateExpr(c.zeroValue(o.Type())).String())) - }) - } - d.DceObjectFilter = o.Name() - varDecls = append(varDecls, &d) - } - for _, init := range c.p.InitOrder { - lhs := make([]ast.Expr, len(init.Lhs)) - for i, o := range init.Lhs { - ident := ast.NewIdent(o.Name()) - c.p.Defs[ident] = o - lhs[i] = c.setType(ident, o.Type()) - varsWithInit[o] = true - } - var d Decl - d.DceDeps = collectDependencies(func() { - c.localVars = nil - d.InitCode = c.CatchOutput(1, func() { - c.translateStmt(&ast.AssignStmt{ - Lhs: lhs, - Tok: token.DEFINE, - Rhs: []ast.Expr{init.Rhs}, - }, nil) - }) - d.Vars = append(d.Vars, c.localVars...) - }) - if len(init.Lhs) == 1 { - if !analysis.HasSideEffect(init.Rhs, c.p.Info.Info) { - d.DceObjectFilter = init.Lhs[0].Name() - } - } - varDecls = append(varDecls, &d) - } - - // functions - var funcDecls []*Decl - var mainFunc *types.Func - for _, fun := range functions { - o := c.p.Defs[fun.Name].(*types.Func) - funcInfo := c.p.FuncDeclInfos[o] - d := Decl{ - FullName: o.FullName(), - Blocking: len(funcInfo.Blocking) != 0, - } - if fun.Recv == nil { - d.Vars = []string{c.objectName(o)} - d.DceObjectFilter = o.Name() - switch o.Name() { - case "main": - mainFunc = o - d.DceObjectFilter = "" - case "init": - d.InitCode = c.CatchOutput(1, func() { - id := c.newIdent("", types.NewSignature(nil, nil, nil, false)) - c.p.Uses[id] = o - call := &ast.CallExpr{Fun: id} - if len(c.p.FuncDeclInfos[o].Blocking) != 0 { - c.Blocking[call] = true - } - c.translateStmt(&ast.ExprStmt{X: call}, nil) - }) - d.DceObjectFilter = "" - } - } - if fun.Recv != nil { - recvType := o.Type().(*types.Signature).Recv().Type() - ptr, isPointer := recvType.(*types.Pointer) - namedRecvType, _ := recvType.(*types.Named) - if isPointer { - namedRecvType = ptr.Elem().(*types.Named) - } - d.DceObjectFilter = namedRecvType.Obj().Name() - if !fun.Name.IsExported() { - d.DceMethodFilter = o.Name() + "~" - } - } - - d.DceDeps = collectDependencies(func() { - d.DeclCode = c.translateToplevelFunction(fun, funcInfo) - }) - funcDecls = append(funcDecls, &d) - } - if typesPkg.Name() == "main" { - if mainFunc == nil { - return nil, fmt.Errorf("missing main function") - } - id := c.newIdent("", types.NewSignature(nil, nil, nil, false)) - c.p.Uses[id] = mainFunc - call := &ast.CallExpr{Fun: id} - ifStmt := &ast.IfStmt{ - Cond: c.newIdent("$pkg === $mainPkg", types.Typ[types.Bool]), - Body: &ast.BlockStmt{ - List: []ast.Stmt{ - &ast.ExprStmt{X: call}, - &ast.AssignStmt{ - Lhs: []ast.Expr{c.newIdent("$mainFinished", types.Typ[types.Bool])}, - Tok: token.ASSIGN, - Rhs: []ast.Expr{c.newConst(types.Typ[types.Bool], constant.MakeBool(true))}, - }, - }, - }, - } - if len(c.p.FuncDeclInfos[mainFunc].Blocking) != 0 { - c.Blocking[call] = true - c.Flattened[ifStmt] = true - } - funcDecls = append(funcDecls, &Decl{ - InitCode: c.CatchOutput(1, func() { - c.translateStmt(ifStmt, nil) - }), - }) - } - - // named types - var typeDecls []*Decl - for _, o := range c.p.typeNames { - typeName := c.objectName(o) - d := Decl{ - Vars: []string{typeName}, - DceObjectFilter: o.Name(), - } - d.DceDeps = collectDependencies(func() { - d.DeclCode = c.CatchOutput(0, func() { - typeName := c.objectName(o) - lhs := typeName - if isPkgLevel(o) { - lhs += " = $pkg." + encodeIdent(o.Name()) - } - size := int64(0) - constructor := "null" - switch t := o.Type().Underlying().(type) { - case *types.Struct: - params := make([]string, t.NumFields()) - for i := 0; i < t.NumFields(); i++ { - params[i] = fieldName(t, i) + "_" - } - constructor = fmt.Sprintf("function(%s) {\n\t\tthis.$val = this;\n\t\tif (arguments.length === 0) {\n", strings.Join(params, ", ")) - for i := 0; i < t.NumFields(); i++ { - constructor += fmt.Sprintf("\t\t\tthis.%s = %s;\n", fieldName(t, i), c.translateExpr(c.zeroValue(t.Field(i).Type())).String()) - } - constructor += "\t\t\treturn;\n\t\t}\n" - for i := 0; i < t.NumFields(); i++ { - constructor += fmt.Sprintf("\t\tthis.%[1]s = %[1]s_;\n", fieldName(t, i)) - } - constructor += "\t}" - case *types.Basic, *types.Array, *types.Slice, *types.Chan, *types.Signature, *types.Interface, *types.Pointer, *types.Map: - size = sizes32.Sizeof(t) - } - c.Printf(`%s = $newType(%d, %s, "%s.%s", %t, "%s", %t, %s);`, lhs, size, typeKind(o.Type()), o.Pkg().Name(), o.Name(), o.Name() != "", o.Pkg().Path(), o.Exported(), constructor) - }) - d.MethodListCode = c.CatchOutput(0, func() { - if _, isInterface := o.Type().Underlying().(*types.Interface); !isInterface { - named := o.Type().(*types.Named) - var methods []string - var ptrMethods []string - for i := 0; i < named.NumMethods(); i++ { - method := named.Method(i) - name := method.Name() - if reservedKeywords[name] { - name += "$" - } - pkgPath := "" - if !method.Exported() { - pkgPath = method.Pkg().Path() - } - t := method.Type().(*types.Signature) - entry := fmt.Sprintf(`{prop: "%s", name: "%s", pkg: "%s", typ: $funcType(%s)}`, name, method.Name(), pkgPath, c.initArgs(t)) - if _, isPtr := t.Recv().Type().(*types.Pointer); isPtr { - ptrMethods = append(ptrMethods, entry) - continue - } - methods = append(methods, entry) - } - if len(methods) > 0 { - c.Printf("%s.methods = [%s];", c.typeName(o.Type()), strings.Join(methods, ", ")) - } - if len(ptrMethods) > 0 { - c.Printf("%s.methods = [%s];", c.typeName(types.NewPointer(o.Type())), strings.Join(ptrMethods, ", ")) - } - } - }) - switch t := o.Type().Underlying().(type) { - case *types.Array, *types.Chan, *types.Interface, *types.Map, *types.Pointer, *types.Slice, *types.Signature, *types.Struct: - d.TypeInitCode = c.CatchOutput(0, func() { - c.Printf("%s.init(%s);", c.objectName(o), c.initArgs(t)) - }) - } - }) - typeDecls = append(typeDecls, &d) - } - - // anonymous types - for _, t := range c.p.anonTypes { - d := Decl{ - Vars: []string{t.Name()}, - DceObjectFilter: t.Name(), - } - d.DceDeps = collectDependencies(func() { - d.DeclCode = []byte(fmt.Sprintf("\t%s = $%sType(%s);\n", t.Name(), strings.ToLower(typeKind(t.Type())[5:]), c.initArgs(t.Type()))) - }) - typeDecls = append(typeDecls, &d) - } - - var allDecls []*Decl - for _, d := range append(append(append(importDecls, typeDecls...), varDecls...), funcDecls...) { - d.DeclCode = removeWhitespace(d.DeclCode, minify) - d.MethodListCode = removeWhitespace(d.MethodListCode, minify) - d.TypeInitCode = removeWhitespace(d.TypeInitCode, minify) - d.InitCode = removeWhitespace(d.InitCode, minify) - allDecls = append(allDecls, d) - } - - if len(c.p.errList) != 0 { - return nil, c.p.errList - } - - return &Archive{ - ImportPath: importPath, - Name: typesPkg.Name(), - Imports: importedPaths, - ExportData: exportData, - Declarations: allDecls, - FileSet: encodedFileSet.Bytes(), - Minified: minify, - }, nil -} - -func (c *funcContext) initArgs(ty types.Type) string { - switch t := ty.(type) { - case *types.Array: - return fmt.Sprintf("%s, %d", c.typeName(t.Elem()), t.Len()) - case *types.Chan: - return fmt.Sprintf("%s, %t, %t", c.typeName(t.Elem()), t.Dir()&types.SendOnly != 0, t.Dir()&types.RecvOnly != 0) - case *types.Interface: - methods := make([]string, t.NumMethods()) - for i := range methods { - method := t.Method(i) - pkgPath := "" - if !method.Exported() { - pkgPath = method.Pkg().Path() - } - methods[i] = fmt.Sprintf(`{prop: "%s", name: "%s", pkg: "%s", typ: $funcType(%s)}`, method.Name(), method.Name(), pkgPath, c.initArgs(method.Type())) - } - return fmt.Sprintf("[%s]", strings.Join(methods, ", ")) - case *types.Map: - return fmt.Sprintf("%s, %s", c.typeName(t.Key()), c.typeName(t.Elem())) - case *types.Pointer: - return fmt.Sprintf("%s", c.typeName(t.Elem())) - case *types.Slice: - return fmt.Sprintf("%s", c.typeName(t.Elem())) - case *types.Signature: - params := make([]string, t.Params().Len()) - for i := range params { - params[i] = c.typeName(t.Params().At(i).Type()) - } - results := make([]string, t.Results().Len()) - for i := range results { - results[i] = c.typeName(t.Results().At(i).Type()) - } - return fmt.Sprintf("[%s], [%s], %t", strings.Join(params, ", "), strings.Join(results, ", "), t.Variadic()) - case *types.Struct: - pkgPath := "" - fields := make([]string, t.NumFields()) - for i := range fields { - field := t.Field(i) - name := "" - if !field.Anonymous() { - name = field.Name() - } - if !field.Exported() { - pkgPath = field.Pkg().Path() - } - fields[i] = fmt.Sprintf(`{prop: "%s", name: "%s", exported: %t, typ: %s, tag: %s}`, fieldName(t, i), name, field.Exported(), c.typeName(field.Type()), encodeString(t.Tag(i))) - } - return fmt.Sprintf(`"%s", [%s]`, pkgPath, strings.Join(fields, ", ")) - default: - panic("invalid type") - } -} - -func (c *funcContext) translateToplevelFunction(fun *ast.FuncDecl, info *analysis.FuncInfo) []byte { - o := c.p.Defs[fun.Name].(*types.Func) - sig := o.Type().(*types.Signature) - var recv *ast.Ident - if fun.Recv != nil && fun.Recv.List[0].Names != nil { - recv = fun.Recv.List[0].Names[0] - } - - var joinedParams string - primaryFunction := func(funcRef string) []byte { - if fun.Body == nil { - return []byte(fmt.Sprintf("\t%s = function() {\n\t\t$throwRuntimeError(\"native function not implemented: %s\");\n\t};\n", funcRef, o.FullName())) - } - - params, fun := translateFunction(fun.Type, recv, fun.Body, c, sig, info, funcRef) - joinedParams = strings.Join(params, ", ") - return []byte(fmt.Sprintf("\t%s = %s;\n", funcRef, fun)) - } - - code := bytes.NewBuffer(nil) - - if fun.Recv == nil { - funcRef := c.objectName(o) - code.Write(primaryFunction(funcRef)) - if fun.Name.IsExported() { - fmt.Fprintf(code, "\t$pkg.%s = %s;\n", encodeIdent(fun.Name.Name), funcRef) - } - return code.Bytes() - } - - recvType := sig.Recv().Type() - ptr, isPointer := recvType.(*types.Pointer) - namedRecvType, _ := recvType.(*types.Named) - if isPointer { - namedRecvType = ptr.Elem().(*types.Named) - } - typeName := c.objectName(namedRecvType.Obj()) - funName := fun.Name.Name - if reservedKeywords[funName] { - funName += "$" - } - - if _, isStruct := namedRecvType.Underlying().(*types.Struct); isStruct { - code.Write(primaryFunction(typeName + ".ptr.prototype." + funName)) - fmt.Fprintf(code, "\t%s.prototype.%s = function(%s) { return this.$val.%s(%s); };\n", typeName, funName, joinedParams, funName, joinedParams) - return code.Bytes() - } - - if isPointer { - if _, isArray := ptr.Elem().Underlying().(*types.Array); isArray { - code.Write(primaryFunction(typeName + ".prototype." + funName)) - fmt.Fprintf(code, "\t$ptrType(%s).prototype.%s = function(%s) { return (new %s(this.$get())).%s(%s); };\n", typeName, funName, joinedParams, typeName, funName, joinedParams) - return code.Bytes() - } - return primaryFunction(fmt.Sprintf("$ptrType(%s).prototype.%s", typeName, funName)) - } - - value := "this.$get()" - if isWrapped(recvType) { - value = fmt.Sprintf("new %s(%s)", typeName, value) - } - code.Write(primaryFunction(typeName + ".prototype." + funName)) - fmt.Fprintf(code, "\t$ptrType(%s).prototype.%s = function(%s) { return %s.%s(%s); };\n", typeName, funName, joinedParams, value, funName, joinedParams) - return code.Bytes() -} - -func translateFunction(typ *ast.FuncType, recv *ast.Ident, body *ast.BlockStmt, outerContext *funcContext, sig *types.Signature, info *analysis.FuncInfo, funcRef string) ([]string, string) { - if info == nil { - panic("nil info") - } - - c := &funcContext{ - FuncInfo: info, - p: outerContext.p, - parent: outerContext, - sig: sig, - allVars: make(map[string]int, len(outerContext.allVars)), - localVars: []string{"$ptr"}, - flowDatas: map[*types.Label]*flowData{nil: {}}, - caseCounter: 1, - labelCases: make(map[*types.Label]int), - } - for k, v := range outerContext.allVars { - c.allVars[k] = v - } - prevEV := c.p.escapingVars - - var params []string - for _, param := range typ.Params.List { - if len(param.Names) == 0 { - params = append(params, c.newVariable("param")) - continue - } - for _, ident := range param.Names { - if isBlank(ident) { - params = append(params, c.newVariable("param")) - continue - } - params = append(params, c.objectName(c.p.Defs[ident])) - } - } - - bodyOutput := string(c.CatchOutput(1, func() { - if len(c.Blocking) != 0 { - c.p.Scopes[body] = c.p.Scopes[typ] - c.handleEscapingVars(body) - } - - if c.sig != nil && c.sig.Results().Len() != 0 && c.sig.Results().At(0).Name() != "" { - c.resultNames = make([]ast.Expr, c.sig.Results().Len()) - for i := 0; i < c.sig.Results().Len(); i++ { - result := c.sig.Results().At(i) - c.Printf("%s = %s;", c.objectName(result), c.translateExpr(c.zeroValue(result.Type())).String()) - id := ast.NewIdent("") - c.p.Uses[id] = result - c.resultNames[i] = c.setType(id, result.Type()) - } - } - - if recv != nil && !isBlank(recv) { - this := "this" - if isWrapped(c.p.TypeOf(recv)) { - this = "this.$val" - } - c.Printf("%s = %s;", c.translateExpr(recv), this) - } - - c.translateStmtList(body.List) - if len(c.Flattened) != 0 && !endsWithReturn(body.List) { - c.translateStmt(&ast.ReturnStmt{}, nil) - } - })) - - sort.Strings(c.localVars) - - var prefix, suffix, functionName string - - if len(c.Flattened) != 0 { - c.localVars = append(c.localVars, "$s") - prefix = prefix + " $s = 0;" - } - - if c.HasDefer { - c.localVars = append(c.localVars, "$deferred") - suffix = " }" + suffix - if len(c.Blocking) != 0 { - suffix = " }" + suffix - } - } - - if len(c.Blocking) != 0 { - c.localVars = append(c.localVars, "$r") - if funcRef == "" { - funcRef = "$b" - functionName = " $b" - } - var stores, loads string - for _, v := range c.localVars { - loads += fmt.Sprintf("%s = $f.%s; ", v, v) - stores += fmt.Sprintf("$f.%s = %s; ", v, v) - } - prefix = prefix + " var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; " + loads + "}" - suffix = " if ($f === undefined) { $f = { $blk: " + funcRef + " }; } " + stores + "return $f;" + suffix - } - - if c.HasDefer { - prefix = prefix + " var $err = null; try {" - deferSuffix := " } catch(err) { $err = err;" - if len(c.Blocking) != 0 { - deferSuffix += " $s = -1;" - } - if c.resultNames == nil && c.sig.Results().Len() > 0 { - deferSuffix += fmt.Sprintf(" return%s;", c.translateResults(nil)) - } - deferSuffix += " } finally { $callDeferred($deferred, $err);" - if c.resultNames != nil { - deferSuffix += fmt.Sprintf(" if (!$curGoroutine.asleep) { return %s; }", c.translateResults(c.resultNames)) - } - if len(c.Blocking) != 0 { - deferSuffix += " if($curGoroutine.asleep) {" - } - suffix = deferSuffix + suffix - } - - if len(c.Flattened) != 0 { - prefix = prefix + " s: while (true) { switch ($s) { case 0:" - suffix = " } return; }" + suffix - } - - if c.HasDefer { - prefix = prefix + " $deferred = []; $deferred.index = $curGoroutine.deferStack.length; $curGoroutine.deferStack.push($deferred);" - } - - if prefix != "" { - bodyOutput = strings.Repeat("\t", c.p.indentation+1) + "/* */" + prefix + "\n" + bodyOutput - } - if suffix != "" { - bodyOutput = bodyOutput + strings.Repeat("\t", c.p.indentation+1) + "/* */" + suffix + "\n" - } - if len(c.localVars) != 0 { - bodyOutput = fmt.Sprintf("%svar %s;\n", strings.Repeat("\t", c.p.indentation+1), strings.Join(c.localVars, ", ")) + bodyOutput - } - - c.p.escapingVars = prevEV - - return params, fmt.Sprintf("function%s(%s) {\n%s%s}", functionName, strings.Join(params, ", "), bodyOutput, strings.Repeat("\t", c.p.indentation)) -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/prelude/goroutines.go b/vendor/github.com/gopherjs/gopherjs/compiler/prelude/goroutines.go deleted file mode 100644 index 071c4c889..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/prelude/goroutines.go +++ /dev/null @@ -1,358 +0,0 @@ -package prelude - -const goroutines = ` -var $stackDepthOffset = 0; -var $getStackDepth = function() { - var err = new Error(); - if (err.stack === undefined) { - return undefined; - } - return $stackDepthOffset + err.stack.split("\n").length; -}; - -var $panicStackDepth = null, $panicValue; -var $callDeferred = function(deferred, jsErr, fromPanic) { - if (!fromPanic && deferred !== null && deferred.index >= $curGoroutine.deferStack.length) { - throw jsErr; - } - if (jsErr !== null) { - var newErr = null; - try { - $curGoroutine.deferStack.push(deferred); - $panic(new $jsErrorPtr(jsErr)); - } catch (err) { - newErr = err; - } - $curGoroutine.deferStack.pop(); - $callDeferred(deferred, newErr); - return; - } - if ($curGoroutine.asleep) { - return; - } - - $stackDepthOffset--; - var outerPanicStackDepth = $panicStackDepth; - var outerPanicValue = $panicValue; - - var localPanicValue = $curGoroutine.panicStack.pop(); - if (localPanicValue !== undefined) { - $panicStackDepth = $getStackDepth(); - $panicValue = localPanicValue; - } - - try { - while (true) { - if (deferred === null) { - deferred = $curGoroutine.deferStack[$curGoroutine.deferStack.length - 1]; - if (deferred === undefined) { - /* The panic reached the top of the stack. Clear it and throw it as a JavaScript error. */ - $panicStackDepth = null; - if (localPanicValue.Object instanceof Error) { - throw localPanicValue.Object; - } - var msg; - if (localPanicValue.constructor === $String) { - msg = localPanicValue.$val; - } else if (localPanicValue.Error !== undefined) { - msg = localPanicValue.Error(); - } else if (localPanicValue.String !== undefined) { - msg = localPanicValue.String(); - } else { - msg = localPanicValue; - } - throw new Error(msg); - } - } - var call = deferred.pop(); - if (call === undefined) { - $curGoroutine.deferStack.pop(); - if (localPanicValue !== undefined) { - deferred = null; - continue; - } - return; - } - var r = call[0].apply(call[2], call[1]); - if (r && r.$blk !== undefined) { - deferred.push([r.$blk, [], r]); - if (fromPanic) { - throw null; - } - return; - } - - if (localPanicValue !== undefined && $panicStackDepth === null) { - throw null; /* error was recovered */ - } - } - } finally { - if (localPanicValue !== undefined) { - if ($panicStackDepth !== null) { - $curGoroutine.panicStack.push(localPanicValue); - } - $panicStackDepth = outerPanicStackDepth; - $panicValue = outerPanicValue; - } - $stackDepthOffset++; - } -}; - -var $panic = function(value) { - $curGoroutine.panicStack.push(value); - $callDeferred(null, null, true); -}; -var $recover = function() { - if ($panicStackDepth === null || ($panicStackDepth !== undefined && $panicStackDepth !== $getStackDepth() - 2)) { - return $ifaceNil; - } - $panicStackDepth = null; - return $panicValue; -}; -var $throw = function(err) { throw err; }; - -var $noGoroutine = { asleep: false, exit: false, deferStack: [], panicStack: [] }; -var $curGoroutine = $noGoroutine, $totalGoroutines = 0, $awakeGoroutines = 0, $checkForDeadlock = true; -var $mainFinished = false; -var $go = function(fun, args, direct) { - $totalGoroutines++; - $awakeGoroutines++; - var $goroutine = function() { - try { - $curGoroutine = $goroutine; - var r = fun.apply(undefined, args); - if (r && r.$blk !== undefined) { - fun = function() { return r.$blk(); }; - args = []; - return; - } - $goroutine.exit = true; - } catch (err) { - if (!$goroutine.exit) { - throw err; - } - } finally { - $curGoroutine = $noGoroutine; - if ($goroutine.exit) { /* also set by runtime.Goexit() */ - $totalGoroutines--; - $goroutine.asleep = true; - } - if ($goroutine.asleep) { - $awakeGoroutines--; - if (!$mainFinished && $awakeGoroutines === 0 && $checkForDeadlock) { - console.error("fatal error: all goroutines are asleep - deadlock!"); - if ($global.process !== undefined) { - $global.process.exit(2); - } - } - } - } - }; - $goroutine.asleep = false; - $goroutine.exit = false; - $goroutine.deferStack = []; - $goroutine.panicStack = []; - $schedule($goroutine); -}; - -var $scheduled = []; -var $runScheduled = function() { - try { - var r; - while ((r = $scheduled.shift()) !== undefined) { - r(); - } - } finally { - if ($scheduled.length > 0) { - setTimeout($runScheduled, 0); - } - } -}; - -var $schedule = function(goroutine) { - if (goroutine.asleep) { - goroutine.asleep = false; - $awakeGoroutines++; - } - $scheduled.push(goroutine); - if ($curGoroutine === $noGoroutine) { - $runScheduled(); - } -}; - -var $setTimeout = function(f, t) { - $awakeGoroutines++; - return setTimeout(function() { - $awakeGoroutines--; - f(); - }, t); -}; - -var $block = function() { - if ($curGoroutine === $noGoroutine) { - $throwRuntimeError("cannot block in JavaScript callback, fix by wrapping code in goroutine"); - } - $curGoroutine.asleep = true; -}; - -var $send = function(chan, value) { - if (chan.$closed) { - $throwRuntimeError("send on closed channel"); - } - var queuedRecv = chan.$recvQueue.shift(); - if (queuedRecv !== undefined) { - queuedRecv([value, true]); - return; - } - if (chan.$buffer.length < chan.$capacity) { - chan.$buffer.push(value); - return; - } - - var thisGoroutine = $curGoroutine; - var closedDuringSend; - chan.$sendQueue.push(function(closed) { - closedDuringSend = closed; - $schedule(thisGoroutine); - return value; - }); - $block(); - return { - $blk: function() { - if (closedDuringSend) { - $throwRuntimeError("send on closed channel"); - } - } - }; -}; -var $recv = function(chan) { - var queuedSend = chan.$sendQueue.shift(); - if (queuedSend !== undefined) { - chan.$buffer.push(queuedSend(false)); - } - var bufferedValue = chan.$buffer.shift(); - if (bufferedValue !== undefined) { - return [bufferedValue, true]; - } - if (chan.$closed) { - return [chan.$elem.zero(), false]; - } - - var thisGoroutine = $curGoroutine; - var f = { $blk: function() { return this.value; } }; - var queueEntry = function(v) { - f.value = v; - $schedule(thisGoroutine); - }; - chan.$recvQueue.push(queueEntry); - $block(); - return f; -}; -var $close = function(chan) { - if (chan.$closed) { - $throwRuntimeError("close of closed channel"); - } - chan.$closed = true; - while (true) { - var queuedSend = chan.$sendQueue.shift(); - if (queuedSend === undefined) { - break; - } - queuedSend(true); /* will panic */ - } - while (true) { - var queuedRecv = chan.$recvQueue.shift(); - if (queuedRecv === undefined) { - break; - } - queuedRecv([chan.$elem.zero(), false]); - } -}; -var $select = function(comms) { - var ready = []; - var selection = -1; - for (var i = 0; i < comms.length; i++) { - var comm = comms[i]; - var chan = comm[0]; - switch (comm.length) { - case 0: /* default */ - selection = i; - break; - case 1: /* recv */ - if (chan.$sendQueue.length !== 0 || chan.$buffer.length !== 0 || chan.$closed) { - ready.push(i); - } - break; - case 2: /* send */ - if (chan.$closed) { - $throwRuntimeError("send on closed channel"); - } - if (chan.$recvQueue.length !== 0 || chan.$buffer.length < chan.$capacity) { - ready.push(i); - } - break; - } - } - - if (ready.length !== 0) { - selection = ready[Math.floor(Math.random() * ready.length)]; - } - if (selection !== -1) { - var comm = comms[selection]; - switch (comm.length) { - case 0: /* default */ - return [selection]; - case 1: /* recv */ - return [selection, $recv(comm[0])]; - case 2: /* send */ - $send(comm[0], comm[1]); - return [selection]; - } - } - - var entries = []; - var thisGoroutine = $curGoroutine; - var f = { $blk: function() { return this.selection; } }; - var removeFromQueues = function() { - for (var i = 0; i < entries.length; i++) { - var entry = entries[i]; - var queue = entry[0]; - var index = queue.indexOf(entry[1]); - if (index !== -1) { - queue.splice(index, 1); - } - } - }; - for (var i = 0; i < comms.length; i++) { - (function(i) { - var comm = comms[i]; - switch (comm.length) { - case 1: /* recv */ - var queueEntry = function(value) { - f.selection = [i, value]; - removeFromQueues(); - $schedule(thisGoroutine); - }; - entries.push([comm[0].$recvQueue, queueEntry]); - comm[0].$recvQueue.push(queueEntry); - break; - case 2: /* send */ - var queueEntry = function() { - if (comm[0].$closed) { - $throwRuntimeError("send on closed channel"); - } - f.selection = [i]; - removeFromQueues(); - $schedule(thisGoroutine); - return comm[1]; - }; - entries.push([comm[0].$sendQueue, queueEntry]); - comm[0].$sendQueue.push(queueEntry); - break; - } - })(i); - } - $block(); - return f; -}; -` diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/prelude/jsmapping.go b/vendor/github.com/gopherjs/gopherjs/compiler/prelude/jsmapping.go deleted file mode 100644 index 562819f40..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/prelude/jsmapping.go +++ /dev/null @@ -1,385 +0,0 @@ -package prelude - -const jsmapping = ` -var $jsObjectPtr, $jsErrorPtr; - -var $needsExternalization = function(t) { - switch (t.kind) { - case $kindBool: - case $kindInt: - case $kindInt8: - case $kindInt16: - case $kindInt32: - case $kindUint: - case $kindUint8: - case $kindUint16: - case $kindUint32: - case $kindUintptr: - case $kindFloat32: - case $kindFloat64: - return false; - default: - return t !== $jsObjectPtr; - } -}; - -var $externalize = function(v, t) { - if (t === $jsObjectPtr) { - return v; - } - switch (t.kind) { - case $kindBool: - case $kindInt: - case $kindInt8: - case $kindInt16: - case $kindInt32: - case $kindUint: - case $kindUint8: - case $kindUint16: - case $kindUint32: - case $kindUintptr: - case $kindFloat32: - case $kindFloat64: - return v; - case $kindInt64: - case $kindUint64: - return $flatten64(v); - case $kindArray: - if ($needsExternalization(t.elem)) { - return $mapArray(v, function(e) { return $externalize(e, t.elem); }); - } - return v; - case $kindFunc: - return $externalizeFunction(v, t, false); - case $kindInterface: - if (v === $ifaceNil) { - return null; - } - if (v.constructor === $jsObjectPtr) { - return v.$val.object; - } - return $externalize(v.$val, v.constructor); - case $kindMap: - var m = {}; - var keys = $keys(v); - for (var i = 0; i < keys.length; i++) { - var entry = v[keys[i]]; - m[$externalize(entry.k, t.key)] = $externalize(entry.v, t.elem); - } - return m; - case $kindPtr: - if (v === t.nil) { - return null; - } - return $externalize(v.$get(), t.elem); - case $kindSlice: - if ($needsExternalization(t.elem)) { - return $mapArray($sliceToArray(v), function(e) { return $externalize(e, t.elem); }); - } - return $sliceToArray(v); - case $kindString: - if ($isASCII(v)) { - return v; - } - var s = "", r; - for (var i = 0; i < v.length; i += r[1]) { - r = $decodeRune(v, i); - var c = r[0]; - if (c > 0xFFFF) { - var h = Math.floor((c - 0x10000) / 0x400) + 0xD800; - var l = (c - 0x10000) % 0x400 + 0xDC00; - s += String.fromCharCode(h, l); - continue; - } - s += String.fromCharCode(c); - } - return s; - case $kindStruct: - var timePkg = $packages["time"]; - if (timePkg !== undefined && v.constructor === timePkg.Time.ptr) { - var milli = $div64(v.UnixNano(), new $Int64(0, 1000000)); - return new Date($flatten64(milli)); - } - - var noJsObject = {}; - var searchJsObject = function(v, t) { - if (t === $jsObjectPtr) { - return v; - } - switch (t.kind) { - case $kindPtr: - if (v === t.nil) { - return noJsObject; - } - return searchJsObject(v.$get(), t.elem); - case $kindStruct: - var f = t.fields[0]; - return searchJsObject(v[f.prop], f.typ); - case $kindInterface: - return searchJsObject(v.$val, v.constructor); - default: - return noJsObject; - } - }; - var o = searchJsObject(v, t); - if (o !== noJsObject) { - return o; - } - - o = {}; - for (var i = 0; i < t.fields.length; i++) { - var f = t.fields[i]; - if (!f.exported) { - continue; - } - o[f.name] = $externalize(v[f.prop], f.typ); - } - return o; - } - $throwRuntimeError("cannot externalize " + t.string); -}; - -var $externalizeFunction = function(v, t, passThis) { - if (v === $throwNilPointerError) { - return null; - } - if (v.$externalizeWrapper === undefined) { - $checkForDeadlock = false; - v.$externalizeWrapper = function() { - var args = []; - for (var i = 0; i < t.params.length; i++) { - if (t.variadic && i === t.params.length - 1) { - var vt = t.params[i].elem, varargs = []; - for (var j = i; j < arguments.length; j++) { - varargs.push($internalize(arguments[j], vt)); - } - args.push(new (t.params[i])(varargs)); - break; - } - args.push($internalize(arguments[i], t.params[i])); - } - var canBlock = $curGoroutine.canBlock; - $curGoroutine.canBlock = false; - try { - var result = v.apply(passThis ? this : undefined, args); - } finally { - $curGoroutine.canBlock = canBlock; - } - switch (t.results.length) { - case 0: - return; - case 1: - return $externalize(result, t.results[0]); - default: - for (var i = 0; i < t.results.length; i++) { - result[i] = $externalize(result[i], t.results[i]); - } - return result; - } - }; - } - return v.$externalizeWrapper; -}; - -var $internalize = function(v, t, recv) { - if (t === $jsObjectPtr) { - return v; - } - if (t === $jsObjectPtr.elem) { - $throwRuntimeError("cannot internalize js.Object, use *js.Object instead"); - } - if (v && v.__internal_object__ !== undefined) { - return $assertType(v.__internal_object__, t, false); - } - var timePkg = $packages["time"]; - if (timePkg !== undefined && t === timePkg.Time) { - if (!(v !== null && v !== undefined && v.constructor === Date)) { - $throwRuntimeError("cannot internalize time.Time from " + typeof v + ", must be Date"); - } - return timePkg.Unix(new $Int64(0, 0), new $Int64(0, v.getTime() * 1000000)); - } - switch (t.kind) { - case $kindBool: - return !!v; - case $kindInt: - return parseInt(v); - case $kindInt8: - return parseInt(v) << 24 >> 24; - case $kindInt16: - return parseInt(v) << 16 >> 16; - case $kindInt32: - return parseInt(v) >> 0; - case $kindUint: - return parseInt(v); - case $kindUint8: - return parseInt(v) << 24 >>> 24; - case $kindUint16: - return parseInt(v) << 16 >>> 16; - case $kindUint32: - case $kindUintptr: - return parseInt(v) >>> 0; - case $kindInt64: - case $kindUint64: - return new t(0, v); - case $kindFloat32: - case $kindFloat64: - return parseFloat(v); - case $kindArray: - if (v.length !== t.len) { - $throwRuntimeError("got array with wrong size from JavaScript native"); - } - return $mapArray(v, function(e) { return $internalize(e, t.elem); }); - case $kindFunc: - return function() { - var args = []; - for (var i = 0; i < t.params.length; i++) { - if (t.variadic && i === t.params.length - 1) { - var vt = t.params[i].elem, varargs = arguments[i]; - for (var j = 0; j < varargs.$length; j++) { - args.push($externalize(varargs.$array[varargs.$offset + j], vt)); - } - break; - } - args.push($externalize(arguments[i], t.params[i])); - } - var result = v.apply(recv, args); - switch (t.results.length) { - case 0: - return; - case 1: - return $internalize(result, t.results[0]); - default: - for (var i = 0; i < t.results.length; i++) { - result[i] = $internalize(result[i], t.results[i]); - } - return result; - } - }; - case $kindInterface: - if (t.methods.length !== 0) { - $throwRuntimeError("cannot internalize " + t.string); - } - if (v === null) { - return $ifaceNil; - } - if (v === undefined) { - return new $jsObjectPtr(undefined); - } - switch (v.constructor) { - case Int8Array: - return new ($sliceType($Int8))(v); - case Int16Array: - return new ($sliceType($Int16))(v); - case Int32Array: - return new ($sliceType($Int))(v); - case Uint8Array: - return new ($sliceType($Uint8))(v); - case Uint16Array: - return new ($sliceType($Uint16))(v); - case Uint32Array: - return new ($sliceType($Uint))(v); - case Float32Array: - return new ($sliceType($Float32))(v); - case Float64Array: - return new ($sliceType($Float64))(v); - case Array: - return $internalize(v, $sliceType($emptyInterface)); - case Boolean: - return new $Bool(!!v); - case Date: - if (timePkg === undefined) { - /* time package is not present, internalize as &js.Object{Date} so it can be externalized into original Date. */ - return new $jsObjectPtr(v); - } - return new timePkg.Time($internalize(v, timePkg.Time)); - case Function: - var funcType = $funcType([$sliceType($emptyInterface)], [$jsObjectPtr], true); - return new funcType($internalize(v, funcType)); - case Number: - return new $Float64(parseFloat(v)); - case String: - return new $String($internalize(v, $String)); - default: - if ($global.Node && v instanceof $global.Node) { - return new $jsObjectPtr(v); - } - var mapType = $mapType($String, $emptyInterface); - return new mapType($internalize(v, mapType)); - } - case $kindMap: - var m = {}; - var keys = $keys(v); - for (var i = 0; i < keys.length; i++) { - var k = $internalize(keys[i], t.key); - m[t.key.keyFor(k)] = { k: k, v: $internalize(v[keys[i]], t.elem) }; - } - return m; - case $kindPtr: - if (t.elem.kind === $kindStruct) { - return $internalize(v, t.elem); - } - case $kindSlice: - return new t($mapArray(v, function(e) { return $internalize(e, t.elem); })); - case $kindString: - v = String(v); - if ($isASCII(v)) { - return v; - } - var s = ""; - var i = 0; - while (i < v.length) { - var h = v.charCodeAt(i); - if (0xD800 <= h && h <= 0xDBFF) { - var l = v.charCodeAt(i + 1); - var c = (h - 0xD800) * 0x400 + l - 0xDC00 + 0x10000; - s += $encodeRune(c); - i += 2; - continue; - } - s += $encodeRune(h); - i++; - } - return s; - case $kindStruct: - var noJsObject = {}; - var searchJsObject = function(t) { - if (t === $jsObjectPtr) { - return v; - } - if (t === $jsObjectPtr.elem) { - $throwRuntimeError("cannot internalize js.Object, use *js.Object instead"); - } - switch (t.kind) { - case $kindPtr: - return searchJsObject(t.elem); - case $kindStruct: - var f = t.fields[0]; - var o = searchJsObject(f.typ); - if (o !== noJsObject) { - var n = new t.ptr(); - n[f.prop] = o; - return n; - } - return noJsObject; - default: - return noJsObject; - } - }; - var o = searchJsObject(t); - if (o !== noJsObject) { - return o; - } - } - $throwRuntimeError("cannot internalize " + t.string); -}; - -/* $isASCII reports whether string s contains only ASCII characters. */ -var $isASCII = function(s) { - for (var i = 0; i < s.length; i++) { - if (s.charCodeAt(i) >= 128) { - return false; - } - } - return true; -}; -` diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/prelude/numeric.go b/vendor/github.com/gopherjs/gopherjs/compiler/prelude/numeric.go deleted file mode 100644 index 063d09f46..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/prelude/numeric.go +++ /dev/null @@ -1,196 +0,0 @@ -package prelude - -const numeric = ` -var $min = Math.min; -var $mod = function(x, y) { return x % y; }; -var $parseInt = parseInt; -var $parseFloat = function(f) { - if (f !== undefined && f !== null && f.constructor === Number) { - return f; - } - return parseFloat(f); -}; - -var $froundBuf = new Float32Array(1); -var $fround = Math.fround || function(f) { - $froundBuf[0] = f; - return $froundBuf[0]; -}; - -var $imul = Math.imul || function(a, b) { - var ah = (a >>> 16) & 0xffff; - var al = a & 0xffff; - var bh = (b >>> 16) & 0xffff; - var bl = b & 0xffff; - return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) >> 0); -}; - -var $floatKey = function(f) { - if (f !== f) { - $idCounter++; - return "NaN$" + $idCounter; - } - return String(f); -}; - -var $flatten64 = function(x) { - return x.$high * 4294967296 + x.$low; -}; - -var $shiftLeft64 = function(x, y) { - if (y === 0) { - return x; - } - if (y < 32) { - return new x.constructor(x.$high << y | x.$low >>> (32 - y), (x.$low << y) >>> 0); - } - if (y < 64) { - return new x.constructor(x.$low << (y - 32), 0); - } - return new x.constructor(0, 0); -}; - -var $shiftRightInt64 = function(x, y) { - if (y === 0) { - return x; - } - if (y < 32) { - return new x.constructor(x.$high >> y, (x.$low >>> y | x.$high << (32 - y)) >>> 0); - } - if (y < 64) { - return new x.constructor(x.$high >> 31, (x.$high >> (y - 32)) >>> 0); - } - if (x.$high < 0) { - return new x.constructor(-1, 4294967295); - } - return new x.constructor(0, 0); -}; - -var $shiftRightUint64 = function(x, y) { - if (y === 0) { - return x; - } - if (y < 32) { - return new x.constructor(x.$high >>> y, (x.$low >>> y | x.$high << (32 - y)) >>> 0); - } - if (y < 64) { - return new x.constructor(0, x.$high >>> (y - 32)); - } - return new x.constructor(0, 0); -}; - -var $mul64 = function(x, y) { - var high = 0, low = 0; - if ((y.$low & 1) !== 0) { - high = x.$high; - low = x.$low; - } - for (var i = 1; i < 32; i++) { - if ((y.$low & 1<>> (32 - i); - low += (x.$low << i) >>> 0; - } - } - for (var i = 0; i < 32; i++) { - if ((y.$high & 1< yHigh) || (xHigh === yHigh && xLow > yLow))) { - yHigh = (yHigh << 1 | yLow >>> 31) >>> 0; - yLow = (yLow << 1) >>> 0; - n++; - } - for (var i = 0; i <= n; i++) { - high = high << 1 | low >>> 31; - low = (low << 1) >>> 0; - if ((xHigh > yHigh) || (xHigh === yHigh && xLow >= yLow)) { - xHigh = xHigh - yHigh; - xLow = xLow - yLow; - if (xLow < 0) { - xHigh--; - xLow += 4294967296; - } - low++; - if (low === 4294967296) { - high++; - low = 0; - } - } - yLow = (yLow >>> 1 | yHigh << (32 - 1)) >>> 0; - yHigh = yHigh >>> 1; - } - - if (returnRemainder) { - return new x.constructor(xHigh * rs, xLow * rs); - } - return new x.constructor(high * s, low * s); -}; - -var $divComplex = function(n, d) { - var ninf = n.$real === Infinity || n.$real === -Infinity || n.$imag === Infinity || n.$imag === -Infinity; - var dinf = d.$real === Infinity || d.$real === -Infinity || d.$imag === Infinity || d.$imag === -Infinity; - var nnan = !ninf && (n.$real !== n.$real || n.$imag !== n.$imag); - var dnan = !dinf && (d.$real !== d.$real || d.$imag !== d.$imag); - if(nnan || dnan) { - return new n.constructor(NaN, NaN); - } - if (ninf && !dinf) { - return new n.constructor(Infinity, Infinity); - } - if (!ninf && dinf) { - return new n.constructor(0, 0); - } - if (d.$real === 0 && d.$imag === 0) { - if (n.$real === 0 && n.$imag === 0) { - return new n.constructor(NaN, NaN); - } - return new n.constructor(Infinity, Infinity); - } - var a = Math.abs(d.$real); - var b = Math.abs(d.$imag); - if (a <= b) { - var ratio = d.$real / d.$imag; - var denom = d.$real * ratio + d.$imag; - return new n.constructor((n.$real * ratio + n.$imag) / denom, (n.$imag * ratio - n.$real) / denom); - } - var ratio = d.$imag / d.$real; - var denom = d.$imag * ratio + d.$real; - return new n.constructor((n.$imag * ratio + n.$real) / denom, (n.$imag - n.$real * ratio) / denom); -}; -` diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/prelude/prelude.go b/vendor/github.com/gopherjs/gopherjs/compiler/prelude/prelude.go deleted file mode 100644 index 8ee4ea5bf..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/prelude/prelude.go +++ /dev/null @@ -1,419 +0,0 @@ -package prelude - -const Prelude = prelude + numeric + types + goroutines + jsmapping - -const prelude = `Error.stackTraceLimit = Infinity; - -var $global, $module; -if (typeof window !== "undefined") { /* web page */ - $global = window; -} else if (typeof self !== "undefined") { /* web worker */ - $global = self; -} else if (typeof global !== "undefined") { /* Node.js */ - $global = global; - $global.require = require; -} else { /* others (e.g. Nashorn) */ - $global = this; -} - -if ($global === undefined || $global.Array === undefined) { - throw new Error("no global object found"); -} -if (typeof module !== "undefined") { - $module = module; -} - -var $packages = {}, $idCounter = 0; -var $keys = function(m) { return m ? Object.keys(m) : []; }; -var $flushConsole = function() {}; -var $throwRuntimeError; /* set by package "runtime" */ -var $throwNilPointerError = function() { $throwRuntimeError("invalid memory address or nil pointer dereference"); }; -var $call = function(fn, rcvr, args) { return fn.apply(rcvr, args); }; -var $makeFunc = function(fn) { return function() { return $externalize(fn(this, new ($sliceType($jsObjectPtr))($global.Array.prototype.slice.call(arguments, []))), $emptyInterface); }; }; -var $unused = function(v) {}; - -var $mapArray = function(array, f) { - var newArray = new array.constructor(array.length); - for (var i = 0; i < array.length; i++) { - newArray[i] = f(array[i]); - } - return newArray; -}; - -var $methodVal = function(recv, name) { - var vals = recv.$methodVals || {}; - recv.$methodVals = vals; /* noop for primitives */ - var f = vals[name]; - if (f !== undefined) { - return f; - } - var method = recv[name]; - f = function() { - $stackDepthOffset--; - try { - return method.apply(recv, arguments); - } finally { - $stackDepthOffset++; - } - }; - vals[name] = f; - return f; -}; - -var $methodExpr = function(typ, name) { - var method = typ.prototype[name]; - if (method.$expr === undefined) { - method.$expr = function() { - $stackDepthOffset--; - try { - if (typ.wrapped) { - arguments[0] = new typ(arguments[0]); - } - return Function.call.apply(method, arguments); - } finally { - $stackDepthOffset++; - } - }; - } - return method.$expr; -}; - -var $ifaceMethodExprs = {}; -var $ifaceMethodExpr = function(name) { - var expr = $ifaceMethodExprs["$" + name]; - if (expr === undefined) { - expr = $ifaceMethodExprs["$" + name] = function() { - $stackDepthOffset--; - try { - return Function.call.apply(arguments[0][name], arguments); - } finally { - $stackDepthOffset++; - } - }; - } - return expr; -}; - -var $subslice = function(slice, low, high, max) { - if (low < 0 || high < low || max < high || high > slice.$capacity || max > slice.$capacity) { - $throwRuntimeError("slice bounds out of range"); - } - var s = new slice.constructor(slice.$array); - s.$offset = slice.$offset + low; - s.$length = slice.$length - low; - s.$capacity = slice.$capacity - low; - if (high !== undefined) { - s.$length = high - low; - } - if (max !== undefined) { - s.$capacity = max - low; - } - return s; -}; - -var $substring = function(str, low, high) { - if (low < 0 || high < low || high > str.length) { - $throwRuntimeError("slice bounds out of range"); - } - return str.substring(low, high); -}; - -var $sliceToArray = function(slice) { - if (slice.$array.constructor !== Array) { - return slice.$array.subarray(slice.$offset, slice.$offset + slice.$length); - } - return slice.$array.slice(slice.$offset, slice.$offset + slice.$length); -}; - -var $decodeRune = function(str, pos) { - var c0 = str.charCodeAt(pos); - - if (c0 < 0x80) { - return [c0, 1]; - } - - if (c0 !== c0 || c0 < 0xC0) { - return [0xFFFD, 1]; - } - - var c1 = str.charCodeAt(pos + 1); - if (c1 !== c1 || c1 < 0x80 || 0xC0 <= c1) { - return [0xFFFD, 1]; - } - - if (c0 < 0xE0) { - var r = (c0 & 0x1F) << 6 | (c1 & 0x3F); - if (r <= 0x7F) { - return [0xFFFD, 1]; - } - return [r, 2]; - } - - var c2 = str.charCodeAt(pos + 2); - if (c2 !== c2 || c2 < 0x80 || 0xC0 <= c2) { - return [0xFFFD, 1]; - } - - if (c0 < 0xF0) { - var r = (c0 & 0x0F) << 12 | (c1 & 0x3F) << 6 | (c2 & 0x3F); - if (r <= 0x7FF) { - return [0xFFFD, 1]; - } - if (0xD800 <= r && r <= 0xDFFF) { - return [0xFFFD, 1]; - } - return [r, 3]; - } - - var c3 = str.charCodeAt(pos + 3); - if (c3 !== c3 || c3 < 0x80 || 0xC0 <= c3) { - return [0xFFFD, 1]; - } - - if (c0 < 0xF8) { - var r = (c0 & 0x07) << 18 | (c1 & 0x3F) << 12 | (c2 & 0x3F) << 6 | (c3 & 0x3F); - if (r <= 0xFFFF || 0x10FFFF < r) { - return [0xFFFD, 1]; - } - return [r, 4]; - } - - return [0xFFFD, 1]; -}; - -var $encodeRune = function(r) { - if (r < 0 || r > 0x10FFFF || (0xD800 <= r && r <= 0xDFFF)) { - r = 0xFFFD; - } - if (r <= 0x7F) { - return String.fromCharCode(r); - } - if (r <= 0x7FF) { - return String.fromCharCode(0xC0 | r >> 6, 0x80 | (r & 0x3F)); - } - if (r <= 0xFFFF) { - return String.fromCharCode(0xE0 | r >> 12, 0x80 | (r >> 6 & 0x3F), 0x80 | (r & 0x3F)); - } - return String.fromCharCode(0xF0 | r >> 18, 0x80 | (r >> 12 & 0x3F), 0x80 | (r >> 6 & 0x3F), 0x80 | (r & 0x3F)); -}; - -var $stringToBytes = function(str) { - var array = new Uint8Array(str.length); - for (var i = 0; i < str.length; i++) { - array[i] = str.charCodeAt(i); - } - return array; -}; - -var $bytesToString = function(slice) { - if (slice.$length === 0) { - return ""; - } - var str = ""; - for (var i = 0; i < slice.$length; i += 10000) { - str += String.fromCharCode.apply(undefined, slice.$array.subarray(slice.$offset + i, slice.$offset + Math.min(slice.$length, i + 10000))); - } - return str; -}; - -var $stringToRunes = function(str) { - var array = new Int32Array(str.length); - var rune, j = 0; - for (var i = 0; i < str.length; i += rune[1], j++) { - rune = $decodeRune(str, i); - array[j] = rune[0]; - } - return array.subarray(0, j); -}; - -var $runesToString = function(slice) { - if (slice.$length === 0) { - return ""; - } - var str = ""; - for (var i = 0; i < slice.$length; i++) { - str += $encodeRune(slice.$array[slice.$offset + i]); - } - return str; -}; - -var $copyString = function(dst, src) { - var n = Math.min(src.length, dst.$length); - for (var i = 0; i < n; i++) { - dst.$array[dst.$offset + i] = src.charCodeAt(i); - } - return n; -}; - -var $copySlice = function(dst, src) { - var n = Math.min(src.$length, dst.$length); - $copyArray(dst.$array, src.$array, dst.$offset, src.$offset, n, dst.constructor.elem); - return n; -}; - -var $copyArray = function(dst, src, dstOffset, srcOffset, n, elem) { - if (n === 0 || (dst === src && dstOffset === srcOffset)) { - return; - } - - if (src.subarray) { - dst.set(src.subarray(srcOffset, srcOffset + n), dstOffset); - return; - } - - switch (elem.kind) { - case $kindArray: - case $kindStruct: - if (dst === src && dstOffset > srcOffset) { - for (var i = n - 1; i >= 0; i--) { - elem.copy(dst[dstOffset + i], src[srcOffset + i]); - } - return; - } - for (var i = 0; i < n; i++) { - elem.copy(dst[dstOffset + i], src[srcOffset + i]); - } - return; - } - - if (dst === src && dstOffset > srcOffset) { - for (var i = n - 1; i >= 0; i--) { - dst[dstOffset + i] = src[srcOffset + i]; - } - return; - } - for (var i = 0; i < n; i++) { - dst[dstOffset + i] = src[srcOffset + i]; - } -}; - -var $clone = function(src, type) { - var clone = type.zero(); - type.copy(clone, src); - return clone; -}; - -var $pointerOfStructConversion = function(obj, type) { - if(obj.$proxies === undefined) { - obj.$proxies = {}; - obj.$proxies[obj.constructor.string] = obj; - } - var proxy = obj.$proxies[type.string]; - if (proxy === undefined) { - var properties = {}; - for (var i = 0; i < type.elem.fields.length; i++) { - (function(fieldProp) { - properties[fieldProp] = { - get: function() { return obj[fieldProp]; }, - set: function(value) { obj[fieldProp] = value; } - }; - })(type.elem.fields[i].prop); - } - proxy = Object.create(type.prototype, properties); - proxy.$val = proxy; - obj.$proxies[type.string] = proxy; - proxy.$proxies = obj.$proxies; - } - return proxy; -}; - -var $append = function(slice) { - return $internalAppend(slice, arguments, 1, arguments.length - 1); -}; - -var $appendSlice = function(slice, toAppend) { - if (toAppend.constructor === String) { - var bytes = $stringToBytes(toAppend); - return $internalAppend(slice, bytes, 0, bytes.length); - } - return $internalAppend(slice, toAppend.$array, toAppend.$offset, toAppend.$length); -}; - -var $internalAppend = function(slice, array, offset, length) { - if (length === 0) { - return slice; - } - - var newArray = slice.$array; - var newOffset = slice.$offset; - var newLength = slice.$length + length; - var newCapacity = slice.$capacity; - - if (newLength > newCapacity) { - newOffset = 0; - newCapacity = Math.max(newLength, slice.$capacity < 1024 ? slice.$capacity * 2 : Math.floor(slice.$capacity * 5 / 4)); - - if (slice.$array.constructor === Array) { - newArray = slice.$array.slice(slice.$offset, slice.$offset + slice.$length); - newArray.length = newCapacity; - var zero = slice.constructor.elem.zero; - for (var i = slice.$length; i < newCapacity; i++) { - newArray[i] = zero(); - } - } else { - newArray = new slice.$array.constructor(newCapacity); - newArray.set(slice.$array.subarray(slice.$offset, slice.$offset + slice.$length)); - } - } - - $copyArray(newArray, array, newOffset + slice.$length, offset, length, slice.constructor.elem); - - var newSlice = new slice.constructor(newArray); - newSlice.$offset = newOffset; - newSlice.$length = newLength; - newSlice.$capacity = newCapacity; - return newSlice; -}; - -var $equal = function(a, b, type) { - if (type === $jsObjectPtr) { - return a === b; - } - switch (type.kind) { - case $kindComplex64: - case $kindComplex128: - return a.$real === b.$real && a.$imag === b.$imag; - case $kindInt64: - case $kindUint64: - return a.$high === b.$high && a.$low === b.$low; - case $kindArray: - if (a.length !== b.length) { - return false; - } - for (var i = 0; i < a.length; i++) { - if (!$equal(a[i], b[i], type.elem)) { - return false; - } - } - return true; - case $kindStruct: - for (var i = 0; i < type.fields.length; i++) { - var f = type.fields[i]; - if (!$equal(a[f.prop], b[f.prop], f.typ)) { - return false; - } - } - return true; - case $kindInterface: - return $interfaceIsEqual(a, b); - default: - return a === b; - } -}; - -var $interfaceIsEqual = function(a, b) { - if (a === $ifaceNil || b === $ifaceNil) { - return a === b; - } - if (a.constructor !== b.constructor) { - return false; - } - if (a.constructor === $jsObjectPtr) { - return a.object === b.object; - } - if (!a.constructor.comparable) { - $throwRuntimeError("comparing uncomparable type " + a.constructor.string); - } - return $equal(a.$val, b.$val, a.constructor); -}; -` diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/prelude/types.go b/vendor/github.com/gopherjs/gopherjs/compiler/prelude/types.go deleted file mode 100644 index 1e9dc43d0..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/prelude/types.go +++ /dev/null @@ -1,743 +0,0 @@ -package prelude - -const types = ` -var $kindBool = 1; -var $kindInt = 2; -var $kindInt8 = 3; -var $kindInt16 = 4; -var $kindInt32 = 5; -var $kindInt64 = 6; -var $kindUint = 7; -var $kindUint8 = 8; -var $kindUint16 = 9; -var $kindUint32 = 10; -var $kindUint64 = 11; -var $kindUintptr = 12; -var $kindFloat32 = 13; -var $kindFloat64 = 14; -var $kindComplex64 = 15; -var $kindComplex128 = 16; -var $kindArray = 17; -var $kindChan = 18; -var $kindFunc = 19; -var $kindInterface = 20; -var $kindMap = 21; -var $kindPtr = 22; -var $kindSlice = 23; -var $kindString = 24; -var $kindStruct = 25; -var $kindUnsafePointer = 26; - -var $methodSynthesizers = []; -var $addMethodSynthesizer = function(f) { - if ($methodSynthesizers === null) { - f(); - return; - } - $methodSynthesizers.push(f); -}; -var $synthesizeMethods = function() { - $methodSynthesizers.forEach(function(f) { f(); }); - $methodSynthesizers = null; -}; - -var $ifaceKeyFor = function(x) { - if (x === $ifaceNil) { - return 'nil'; - } - var c = x.constructor; - return c.string + '$' + c.keyFor(x.$val); -}; - -var $identity = function(x) { return x; }; - -var $typeIDCounter = 0; - -var $idKey = function(x) { - if (x.$id === undefined) { - $idCounter++; - x.$id = $idCounter; - } - return String(x.$id); -}; - -var $newType = function(size, kind, string, named, pkg, exported, constructor) { - var typ; - switch(kind) { - case $kindBool: - case $kindInt: - case $kindInt8: - case $kindInt16: - case $kindInt32: - case $kindUint: - case $kindUint8: - case $kindUint16: - case $kindUint32: - case $kindUintptr: - case $kindUnsafePointer: - typ = function(v) { this.$val = v; }; - typ.wrapped = true; - typ.keyFor = $identity; - break; - - case $kindString: - typ = function(v) { this.$val = v; }; - typ.wrapped = true; - typ.keyFor = function(x) { return "$" + x; }; - break; - - case $kindFloat32: - case $kindFloat64: - typ = function(v) { this.$val = v; }; - typ.wrapped = true; - typ.keyFor = function(x) { return $floatKey(x); }; - break; - - case $kindInt64: - typ = function(high, low) { - this.$high = (high + Math.floor(Math.ceil(low) / 4294967296)) >> 0; - this.$low = low >>> 0; - this.$val = this; - }; - typ.keyFor = function(x) { return x.$high + "$" + x.$low; }; - break; - - case $kindUint64: - typ = function(high, low) { - this.$high = (high + Math.floor(Math.ceil(low) / 4294967296)) >>> 0; - this.$low = low >>> 0; - this.$val = this; - }; - typ.keyFor = function(x) { return x.$high + "$" + x.$low; }; - break; - - case $kindComplex64: - typ = function(real, imag) { - this.$real = $fround(real); - this.$imag = $fround(imag); - this.$val = this; - }; - typ.keyFor = function(x) { return x.$real + "$" + x.$imag; }; - break; - - case $kindComplex128: - typ = function(real, imag) { - this.$real = real; - this.$imag = imag; - this.$val = this; - }; - typ.keyFor = function(x) { return x.$real + "$" + x.$imag; }; - break; - - case $kindArray: - typ = function(v) { this.$val = v; }; - typ.wrapped = true; - typ.ptr = $newType(4, $kindPtr, "*" + string, false, "", false, function(array) { - this.$get = function() { return array; }; - this.$set = function(v) { typ.copy(this, v); }; - this.$val = array; - }); - typ.init = function(elem, len) { - typ.elem = elem; - typ.len = len; - typ.comparable = elem.comparable; - typ.keyFor = function(x) { - return Array.prototype.join.call($mapArray(x, function(e) { - return String(elem.keyFor(e)).replace(/\\/g, "\\\\").replace(/\$/g, "\\$"); - }), "$"); - }; - typ.copy = function(dst, src) { - $copyArray(dst, src, 0, 0, src.length, elem); - }; - typ.ptr.init(typ); - Object.defineProperty(typ.ptr.nil, "nilCheck", { get: $throwNilPointerError }); - }; - break; - - case $kindChan: - typ = function(v) { this.$val = v; }; - typ.wrapped = true; - typ.keyFor = $idKey; - typ.init = function(elem, sendOnly, recvOnly) { - typ.elem = elem; - typ.sendOnly = sendOnly; - typ.recvOnly = recvOnly; - }; - break; - - case $kindFunc: - typ = function(v) { this.$val = v; }; - typ.wrapped = true; - typ.init = function(params, results, variadic) { - typ.params = params; - typ.results = results; - typ.variadic = variadic; - typ.comparable = false; - }; - break; - - case $kindInterface: - typ = { implementedBy: {}, missingMethodFor: {} }; - typ.keyFor = $ifaceKeyFor; - typ.init = function(methods) { - typ.methods = methods; - methods.forEach(function(m) { - $ifaceNil[m.prop] = $throwNilPointerError; - }); - }; - break; - - case $kindMap: - typ = function(v) { this.$val = v; }; - typ.wrapped = true; - typ.init = function(key, elem) { - typ.key = key; - typ.elem = elem; - typ.comparable = false; - }; - break; - - case $kindPtr: - typ = constructor || function(getter, setter, target) { - this.$get = getter; - this.$set = setter; - this.$target = target; - this.$val = this; - }; - typ.keyFor = $idKey; - typ.init = function(elem) { - typ.elem = elem; - typ.wrapped = (elem.kind === $kindArray); - typ.nil = new typ($throwNilPointerError, $throwNilPointerError); - }; - break; - - case $kindSlice: - typ = function(array) { - if (array.constructor !== typ.nativeArray) { - array = new typ.nativeArray(array); - } - this.$array = array; - this.$offset = 0; - this.$length = array.length; - this.$capacity = array.length; - this.$val = this; - }; - typ.init = function(elem) { - typ.elem = elem; - typ.comparable = false; - typ.nativeArray = $nativeArray(elem.kind); - typ.nil = new typ([]); - }; - break; - - case $kindStruct: - typ = function(v) { this.$val = v; }; - typ.wrapped = true; - typ.ptr = $newType(4, $kindPtr, "*" + string, false, "", exported, constructor); - typ.ptr.elem = typ; - typ.ptr.prototype.$get = function() { return this; }; - typ.ptr.prototype.$set = function(v) { typ.copy(this, v); }; - typ.init = function(pkgPath, fields) { - typ.pkgPath = pkgPath; - typ.fields = fields; - fields.forEach(function(f) { - if (!f.typ.comparable) { - typ.comparable = false; - } - }); - typ.keyFor = function(x) { - var val = x.$val; - return $mapArray(fields, function(f) { - return String(f.typ.keyFor(val[f.prop])).replace(/\\/g, "\\\\").replace(/\$/g, "\\$"); - }).join("$"); - }; - typ.copy = function(dst, src) { - for (var i = 0; i < fields.length; i++) { - var f = fields[i]; - switch (f.typ.kind) { - case $kindArray: - case $kindStruct: - f.typ.copy(dst[f.prop], src[f.prop]); - continue; - default: - dst[f.prop] = src[f.prop]; - continue; - } - } - }; - /* nil value */ - var properties = {}; - fields.forEach(function(f) { - properties[f.prop] = { get: $throwNilPointerError, set: $throwNilPointerError }; - }); - typ.ptr.nil = Object.create(constructor.prototype, properties); - typ.ptr.nil.$val = typ.ptr.nil; - /* methods for embedded fields */ - $addMethodSynthesizer(function() { - var synthesizeMethod = function(target, m, f) { - if (target.prototype[m.prop] !== undefined) { return; } - target.prototype[m.prop] = function() { - var v = this.$val[f.prop]; - if (f.typ === $jsObjectPtr) { - v = new $jsObjectPtr(v); - } - if (v.$val === undefined) { - v = new f.typ(v); - } - return v[m.prop].apply(v, arguments); - }; - }; - fields.forEach(function(f) { - if (f.name === "") { - $methodSet(f.typ).forEach(function(m) { - synthesizeMethod(typ, m, f); - synthesizeMethod(typ.ptr, m, f); - }); - $methodSet($ptrType(f.typ)).forEach(function(m) { - synthesizeMethod(typ.ptr, m, f); - }); - } - }); - }); - }; - break; - - default: - $panic(new $String("invalid kind: " + kind)); - } - - switch (kind) { - case $kindBool: - case $kindMap: - typ.zero = function() { return false; }; - break; - - case $kindInt: - case $kindInt8: - case $kindInt16: - case $kindInt32: - case $kindUint: - case $kindUint8 : - case $kindUint16: - case $kindUint32: - case $kindUintptr: - case $kindUnsafePointer: - case $kindFloat32: - case $kindFloat64: - typ.zero = function() { return 0; }; - break; - - case $kindString: - typ.zero = function() { return ""; }; - break; - - case $kindInt64: - case $kindUint64: - case $kindComplex64: - case $kindComplex128: - var zero = new typ(0, 0); - typ.zero = function() { return zero; }; - break; - - case $kindPtr: - case $kindSlice: - typ.zero = function() { return typ.nil; }; - break; - - case $kindChan: - typ.zero = function() { return $chanNil; }; - break; - - case $kindFunc: - typ.zero = function() { return $throwNilPointerError; }; - break; - - case $kindInterface: - typ.zero = function() { return $ifaceNil; }; - break; - - case $kindArray: - typ.zero = function() { - var arrayClass = $nativeArray(typ.elem.kind); - if (arrayClass !== Array) { - return new arrayClass(typ.len); - } - var array = new Array(typ.len); - for (var i = 0; i < typ.len; i++) { - array[i] = typ.elem.zero(); - } - return array; - }; - break; - - case $kindStruct: - typ.zero = function() { return new typ.ptr(); }; - break; - - default: - $panic(new $String("invalid kind: " + kind)); - } - - typ.id = $typeIDCounter; - $typeIDCounter++; - typ.size = size; - typ.kind = kind; - typ.string = string; - typ.named = named; - typ.pkg = pkg; - typ.exported = exported; - typ.methods = []; - typ.methodSetCache = null; - typ.comparable = true; - return typ; -}; - -var $methodSet = function(typ) { - if (typ.methodSetCache !== null) { - return typ.methodSetCache; - } - var base = {}; - - var isPtr = (typ.kind === $kindPtr); - if (isPtr && typ.elem.kind === $kindInterface) { - typ.methodSetCache = []; - return []; - } - - var current = [{typ: isPtr ? typ.elem : typ, indirect: isPtr}]; - - var seen = {}; - - while (current.length > 0) { - var next = []; - var mset = []; - - current.forEach(function(e) { - if (seen[e.typ.string]) { - return; - } - seen[e.typ.string] = true; - - if (e.typ.named) { - mset = mset.concat(e.typ.methods); - if (e.indirect) { - mset = mset.concat($ptrType(e.typ).methods); - } - } - - switch (e.typ.kind) { - case $kindStruct: - e.typ.fields.forEach(function(f) { - if (f.name === "") { - var fTyp = f.typ; - var fIsPtr = (fTyp.kind === $kindPtr); - next.push({typ: fIsPtr ? fTyp.elem : fTyp, indirect: e.indirect || fIsPtr}); - } - }); - break; - - case $kindInterface: - mset = mset.concat(e.typ.methods); - break; - } - }); - - mset.forEach(function(m) { - if (base[m.name] === undefined) { - base[m.name] = m; - } - }); - - current = next; - } - - typ.methodSetCache = []; - Object.keys(base).sort().forEach(function(name) { - typ.methodSetCache.push(base[name]); - }); - return typ.methodSetCache; -}; - -var $Bool = $newType( 1, $kindBool, "bool", true, "", false, null); -var $Int = $newType( 4, $kindInt, "int", true, "", false, null); -var $Int8 = $newType( 1, $kindInt8, "int8", true, "", false, null); -var $Int16 = $newType( 2, $kindInt16, "int16", true, "", false, null); -var $Int32 = $newType( 4, $kindInt32, "int32", true, "", false, null); -var $Int64 = $newType( 8, $kindInt64, "int64", true, "", false, null); -var $Uint = $newType( 4, $kindUint, "uint", true, "", false, null); -var $Uint8 = $newType( 1, $kindUint8, "uint8", true, "", false, null); -var $Uint16 = $newType( 2, $kindUint16, "uint16", true, "", false, null); -var $Uint32 = $newType( 4, $kindUint32, "uint32", true, "", false, null); -var $Uint64 = $newType( 8, $kindUint64, "uint64", true, "", false, null); -var $Uintptr = $newType( 4, $kindUintptr, "uintptr", true, "", false, null); -var $Float32 = $newType( 4, $kindFloat32, "float32", true, "", false, null); -var $Float64 = $newType( 8, $kindFloat64, "float64", true, "", false, null); -var $Complex64 = $newType( 8, $kindComplex64, "complex64", true, "", false, null); -var $Complex128 = $newType(16, $kindComplex128, "complex128", true, "", false, null); -var $String = $newType( 8, $kindString, "string", true, "", false, null); -var $UnsafePointer = $newType( 4, $kindUnsafePointer, "unsafe.Pointer", true, "", false, null); - -var $nativeArray = function(elemKind) { - switch (elemKind) { - case $kindInt: - return Int32Array; - case $kindInt8: - return Int8Array; - case $kindInt16: - return Int16Array; - case $kindInt32: - return Int32Array; - case $kindUint: - return Uint32Array; - case $kindUint8: - return Uint8Array; - case $kindUint16: - return Uint16Array; - case $kindUint32: - return Uint32Array; - case $kindUintptr: - return Uint32Array; - case $kindFloat32: - return Float32Array; - case $kindFloat64: - return Float64Array; - default: - return Array; - } -}; -var $toNativeArray = function(elemKind, array) { - var nativeArray = $nativeArray(elemKind); - if (nativeArray === Array) { - return array; - } - return new nativeArray(array); -}; -var $arrayTypes = {}; -var $arrayType = function(elem, len) { - var typeKey = elem.id + "$" + len; - var typ = $arrayTypes[typeKey]; - if (typ === undefined) { - typ = $newType(12, $kindArray, "[" + len + "]" + elem.string, false, "", false, null); - $arrayTypes[typeKey] = typ; - typ.init(elem, len); - } - return typ; -}; - -var $chanType = function(elem, sendOnly, recvOnly) { - var string = (recvOnly ? "<-" : "") + "chan" + (sendOnly ? "<- " : " ") + elem.string; - var field = sendOnly ? "SendChan" : (recvOnly ? "RecvChan" : "Chan"); - var typ = elem[field]; - if (typ === undefined) { - typ = $newType(4, $kindChan, string, false, "", false, null); - elem[field] = typ; - typ.init(elem, sendOnly, recvOnly); - } - return typ; -}; -var $Chan = function(elem, capacity) { - if (capacity < 0 || capacity > 2147483647) { - $throwRuntimeError("makechan: size out of range"); - } - this.$elem = elem; - this.$capacity = capacity; - this.$buffer = []; - this.$sendQueue = []; - this.$recvQueue = []; - this.$closed = false; -}; -var $chanNil = new $Chan(null, 0); -$chanNil.$sendQueue = $chanNil.$recvQueue = { length: 0, push: function() {}, shift: function() { return undefined; }, indexOf: function() { return -1; } }; - -var $funcTypes = {}; -var $funcType = function(params, results, variadic) { - var typeKey = $mapArray(params, function(p) { return p.id; }).join(",") + "$" + $mapArray(results, function(r) { return r.id; }).join(",") + "$" + variadic; - var typ = $funcTypes[typeKey]; - if (typ === undefined) { - var paramTypes = $mapArray(params, function(p) { return p.string; }); - if (variadic) { - paramTypes[paramTypes.length - 1] = "..." + paramTypes[paramTypes.length - 1].substr(2); - } - var string = "func(" + paramTypes.join(", ") + ")"; - if (results.length === 1) { - string += " " + results[0].string; - } else if (results.length > 1) { - string += " (" + $mapArray(results, function(r) { return r.string; }).join(", ") + ")"; - } - typ = $newType(4, $kindFunc, string, false, "", false, null); - $funcTypes[typeKey] = typ; - typ.init(params, results, variadic); - } - return typ; -}; - -var $interfaceTypes = {}; -var $interfaceType = function(methods) { - var typeKey = $mapArray(methods, function(m) { return m.pkg + "," + m.name + "," + m.typ.id; }).join("$"); - var typ = $interfaceTypes[typeKey]; - if (typ === undefined) { - var string = "interface {}"; - if (methods.length !== 0) { - string = "interface { " + $mapArray(methods, function(m) { - return (m.pkg !== "" ? m.pkg + "." : "") + m.name + m.typ.string.substr(4); - }).join("; ") + " }"; - } - typ = $newType(8, $kindInterface, string, false, "", false, null); - $interfaceTypes[typeKey] = typ; - typ.init(methods); - } - return typ; -}; -var $emptyInterface = $interfaceType([]); -var $ifaceNil = {}; -var $error = $newType(8, $kindInterface, "error", true, "", false, null); -$error.init([{prop: "Error", name: "Error", pkg: "", typ: $funcType([], [$String], false)}]); - -var $mapTypes = {}; -var $mapType = function(key, elem) { - var typeKey = key.id + "$" + elem.id; - var typ = $mapTypes[typeKey]; - if (typ === undefined) { - typ = $newType(4, $kindMap, "map[" + key.string + "]" + elem.string, false, "", false, null); - $mapTypes[typeKey] = typ; - typ.init(key, elem); - } - return typ; -}; -var $makeMap = function(keyForFunc, entries) { - var m = {}; - for (var i = 0; i < entries.length; i++) { - var e = entries[i]; - m[keyForFunc(e.k)] = e; - } - return m; -}; - -var $ptrType = function(elem) { - var typ = elem.ptr; - if (typ === undefined) { - typ = $newType(4, $kindPtr, "*" + elem.string, false, "", elem.exported, null); - elem.ptr = typ; - typ.init(elem); - } - return typ; -}; - -var $newDataPointer = function(data, constructor) { - if (constructor.elem.kind === $kindStruct) { - return data; - } - return new constructor(function() { return data; }, function(v) { data = v; }); -}; - -var $indexPtr = function(array, index, constructor) { - array.$ptr = array.$ptr || {}; - return array.$ptr[index] || (array.$ptr[index] = new constructor(function() { return array[index]; }, function(v) { array[index] = v; })); -}; - -var $sliceType = function(elem) { - var typ = elem.slice; - if (typ === undefined) { - typ = $newType(12, $kindSlice, "[]" + elem.string, false, "", false, null); - elem.slice = typ; - typ.init(elem); - } - return typ; -}; -var $makeSlice = function(typ, length, capacity) { - capacity = capacity || length; - if (length < 0 || length > 2147483647) { - $throwRuntimeError("makeslice: len out of range"); - } - if (capacity < 0 || capacity < length || capacity > 2147483647) { - $throwRuntimeError("makeslice: cap out of range"); - } - var array = new typ.nativeArray(capacity); - if (typ.nativeArray === Array) { - for (var i = 0; i < capacity; i++) { - array[i] = typ.elem.zero(); - } - } - var slice = new typ(array); - slice.$length = length; - return slice; -}; - -var $structTypes = {}; -var $structType = function(pkgPath, fields) { - var typeKey = $mapArray(fields, function(f) { return f.name + "," + f.typ.id + "," + f.tag; }).join("$"); - var typ = $structTypes[typeKey]; - if (typ === undefined) { - var string = "struct { " + $mapArray(fields, function(f) { - return f.name + " " + f.typ.string + (f.tag !== "" ? (" \"" + f.tag.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"") : ""); - }).join("; ") + " }"; - if (fields.length === 0) { - string = "struct {}"; - } - typ = $newType(0, $kindStruct, string, false, "", false, function() { - this.$val = this; - for (var i = 0; i < fields.length; i++) { - var f = fields[i]; - var arg = arguments[i]; - this[f.prop] = arg !== undefined ? arg : f.typ.zero(); - } - }); - $structTypes[typeKey] = typ; - typ.init(pkgPath, fields); - } - return typ; -}; - -var $assertType = function(value, type, returnTuple) { - var isInterface = (type.kind === $kindInterface), ok, missingMethod = ""; - if (value === $ifaceNil) { - ok = false; - } else if (!isInterface) { - ok = value.constructor === type; - } else { - var valueTypeString = value.constructor.string; - ok = type.implementedBy[valueTypeString]; - if (ok === undefined) { - ok = true; - var valueMethodSet = $methodSet(value.constructor); - var interfaceMethods = type.methods; - for (var i = 0; i < interfaceMethods.length; i++) { - var tm = interfaceMethods[i]; - var found = false; - for (var j = 0; j < valueMethodSet.length; j++) { - var vm = valueMethodSet[j]; - if (vm.name === tm.name && vm.pkg === tm.pkg && vm.typ === tm.typ) { - found = true; - break; - } - } - if (!found) { - ok = false; - type.missingMethodFor[valueTypeString] = tm.name; - break; - } - } - type.implementedBy[valueTypeString] = ok; - } - if (!ok) { - missingMethod = type.missingMethodFor[valueTypeString]; - } - } - - if (!ok) { - if (returnTuple) { - return [type.zero(), false]; - } - $panic(new $packages["runtime"].TypeAssertionError.ptr("", (value === $ifaceNil ? "" : value.constructor.string), type.string, missingMethod)); - } - - if (!isInterface) { - value = value.$val; - } - if (type === $jsObjectPtr) { - value = value.object; - } - return returnTuple ? [value, true] : value; -}; -` diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/statements.go b/vendor/github.com/gopherjs/gopherjs/compiler/statements.go deleted file mode 100644 index 529f40a39..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/statements.go +++ /dev/null @@ -1,784 +0,0 @@ -package compiler - -import ( - "fmt" - "go/ast" - "go/constant" - "go/token" - "go/types" - "strings" - - "github.com/gopherjs/gopherjs/compiler/analysis" - "github.com/gopherjs/gopherjs/compiler/astutil" - "github.com/gopherjs/gopherjs/compiler/filter" - "github.com/gopherjs/gopherjs/compiler/typesutil" -) - -func (c *funcContext) translateStmtList(stmts []ast.Stmt) { - for _, stmt := range stmts { - c.translateStmt(stmt, nil) - } - c.SetPos(token.NoPos) -} - -func (c *funcContext) translateStmt(stmt ast.Stmt, label *types.Label) { - c.SetPos(stmt.Pos()) - - stmt = filter.IncDecStmt(stmt, c.p.Info.Info) - stmt = filter.Assign(stmt, c.p.Info.Info, c.p.Info.Pkg) - - switch s := stmt.(type) { - case *ast.BlockStmt: - c.translateStmtList(s.List) - - case *ast.IfStmt: - var caseClauses []*ast.CaseClause - ifStmt := s - for { - if ifStmt.Init != nil { - panic("simplification error") - } - caseClauses = append(caseClauses, &ast.CaseClause{List: []ast.Expr{ifStmt.Cond}, Body: ifStmt.Body.List}) - elseStmt, ok := ifStmt.Else.(*ast.IfStmt) - if !ok { - break - } - ifStmt = elseStmt - } - var defaultClause *ast.CaseClause - if block, ok := ifStmt.Else.(*ast.BlockStmt); ok { - defaultClause = &ast.CaseClause{Body: block.List} - } - c.translateBranchingStmt(caseClauses, defaultClause, false, c.translateExpr, nil, c.Flattened[s]) - - case *ast.SwitchStmt: - if s.Init != nil || s.Tag != nil || len(s.Body.List) != 1 { - panic("simplification error") - } - clause := s.Body.List[0].(*ast.CaseClause) - if len(clause.List) != 0 { - panic("simplification error") - } - - prevFlowData := c.flowDatas[nil] - data := &flowData{ - postStmt: prevFlowData.postStmt, // for "continue" of outer loop - beginCase: prevFlowData.beginCase, // same - } - c.flowDatas[nil] = data - c.flowDatas[label] = data - defer func() { - delete(c.flowDatas, label) - c.flowDatas[nil] = prevFlowData - }() - - if c.Flattened[s] { - data.endCase = c.caseCounter - c.caseCounter++ - - c.Indent(func() { - c.translateStmtList(clause.Body) - }) - c.Printf("case %d:", data.endCase) - return - } - - if label != nil || analysis.HasBreak(clause) { - if label != nil { - c.Printf("%s:", label.Name()) - } - c.Printf("switch (0) { default:") - c.Indent(func() { - c.translateStmtList(clause.Body) - }) - c.Printf("}") - return - } - - c.translateStmtList(clause.Body) - - case *ast.TypeSwitchStmt: - if s.Init != nil { - c.translateStmt(s.Init, nil) - } - refVar := c.newVariable("_ref") - var expr ast.Expr - switch a := s.Assign.(type) { - case *ast.AssignStmt: - expr = a.Rhs[0].(*ast.TypeAssertExpr).X - case *ast.ExprStmt: - expr = a.X.(*ast.TypeAssertExpr).X - } - c.Printf("%s = %s;", refVar, c.translateExpr(expr)) - translateCond := func(cond ast.Expr) *expression { - if types.Identical(c.p.TypeOf(cond), types.Typ[types.UntypedNil]) { - return c.formatExpr("%s === $ifaceNil", refVar) - } - return c.formatExpr("$assertType(%s, %s, true)[1]", refVar, c.typeName(c.p.TypeOf(cond))) - } - var caseClauses []*ast.CaseClause - var defaultClause *ast.CaseClause - for _, cc := range s.Body.List { - clause := cc.(*ast.CaseClause) - var bodyPrefix []ast.Stmt - if implicit := c.p.Implicits[clause]; implicit != nil { - value := refVar - if _, isInterface := implicit.Type().Underlying().(*types.Interface); !isInterface { - value += ".$val" - } - bodyPrefix = []ast.Stmt{&ast.AssignStmt{ - Lhs: []ast.Expr{c.newIdent(c.objectName(implicit), implicit.Type())}, - Tok: token.DEFINE, - Rhs: []ast.Expr{c.newIdent(value, implicit.Type())}, - }} - } - c := &ast.CaseClause{ - List: clause.List, - Body: append(bodyPrefix, clause.Body...), - } - if len(c.List) == 0 { - defaultClause = c - continue - } - caseClauses = append(caseClauses, c) - } - c.translateBranchingStmt(caseClauses, defaultClause, true, translateCond, label, c.Flattened[s]) - - case *ast.ForStmt: - if s.Init != nil { - c.translateStmt(s.Init, nil) - } - cond := func() string { - if s.Cond == nil { - return "true" - } - return c.translateExpr(s.Cond).String() - } - c.translateLoopingStmt(cond, s.Body, nil, func() { - if s.Post != nil { - c.translateStmt(s.Post, nil) - } - }, label, c.Flattened[s]) - - case *ast.RangeStmt: - refVar := c.newVariable("_ref") - c.Printf("%s = %s;", refVar, c.translateExpr(s.X)) - - switch t := c.p.TypeOf(s.X).Underlying().(type) { - case *types.Basic: - iVar := c.newVariable("_i") - c.Printf("%s = 0;", iVar) - runeVar := c.newVariable("_rune") - c.translateLoopingStmt(func() string { return iVar + " < " + refVar + ".length" }, s.Body, func() { - c.Printf("%s = $decodeRune(%s, %s);", runeVar, refVar, iVar) - if !isBlank(s.Key) { - c.Printf("%s", c.translateAssign(s.Key, c.newIdent(iVar, types.Typ[types.Int]), s.Tok == token.DEFINE)) - } - if !isBlank(s.Value) { - c.Printf("%s", c.translateAssign(s.Value, c.newIdent(runeVar+"[0]", types.Typ[types.Rune]), s.Tok == token.DEFINE)) - } - }, func() { - c.Printf("%s += %s[1];", iVar, runeVar) - }, label, c.Flattened[s]) - - case *types.Map: - iVar := c.newVariable("_i") - c.Printf("%s = 0;", iVar) - keysVar := c.newVariable("_keys") - c.Printf("%s = $keys(%s);", keysVar, refVar) - c.translateLoopingStmt(func() string { return iVar + " < " + keysVar + ".length" }, s.Body, func() { - entryVar := c.newVariable("_entry") - c.Printf("%s = %s[%s[%s]];", entryVar, refVar, keysVar, iVar) - c.translateStmt(&ast.IfStmt{ - Cond: c.newIdent(entryVar+" === undefined", types.Typ[types.Bool]), - Body: &ast.BlockStmt{List: []ast.Stmt{&ast.BranchStmt{Tok: token.CONTINUE}}}, - }, nil) - if !isBlank(s.Key) { - c.Printf("%s", c.translateAssign(s.Key, c.newIdent(entryVar+".k", t.Key()), s.Tok == token.DEFINE)) - } - if !isBlank(s.Value) { - c.Printf("%s", c.translateAssign(s.Value, c.newIdent(entryVar+".v", t.Elem()), s.Tok == token.DEFINE)) - } - }, func() { - c.Printf("%s++;", iVar) - }, label, c.Flattened[s]) - - case *types.Array, *types.Pointer, *types.Slice: - var length string - var elemType types.Type - switch t2 := t.(type) { - case *types.Array: - length = fmt.Sprintf("%d", t2.Len()) - elemType = t2.Elem() - case *types.Pointer: - length = fmt.Sprintf("%d", t2.Elem().Underlying().(*types.Array).Len()) - elemType = t2.Elem().Underlying().(*types.Array).Elem() - case *types.Slice: - length = refVar + ".$length" - elemType = t2.Elem() - } - iVar := c.newVariable("_i") - c.Printf("%s = 0;", iVar) - c.translateLoopingStmt(func() string { return iVar + " < " + length }, s.Body, func() { - if !isBlank(s.Key) { - c.Printf("%s", c.translateAssign(s.Key, c.newIdent(iVar, types.Typ[types.Int]), s.Tok == token.DEFINE)) - } - if !isBlank(s.Value) { - c.Printf("%s", c.translateAssign(s.Value, c.setType(&ast.IndexExpr{ - X: c.newIdent(refVar, t), - Index: c.newIdent(iVar, types.Typ[types.Int]), - }, elemType), s.Tok == token.DEFINE)) - } - }, func() { - c.Printf("%s++;", iVar) - }, label, c.Flattened[s]) - - case *types.Chan: - okVar := c.newIdent(c.newVariable("_ok"), types.Typ[types.Bool]) - key := s.Key - tok := s.Tok - if key == nil { - key = ast.NewIdent("_") - tok = token.ASSIGN - } - forStmt := &ast.ForStmt{ - Body: &ast.BlockStmt{ - List: []ast.Stmt{ - &ast.AssignStmt{ - Lhs: []ast.Expr{ - key, - okVar, - }, - Rhs: []ast.Expr{ - c.setType(&ast.UnaryExpr{X: c.newIdent(refVar, t), Op: token.ARROW}, types.NewTuple(types.NewVar(0, nil, "", t.Elem()), types.NewVar(0, nil, "", types.Typ[types.Bool]))), - }, - Tok: tok, - }, - &ast.IfStmt{ - Cond: &ast.UnaryExpr{X: okVar, Op: token.NOT}, - Body: &ast.BlockStmt{List: []ast.Stmt{&ast.BranchStmt{Tok: token.BREAK}}}, - }, - s.Body, - }, - }, - } - c.Flattened[forStmt] = true - c.translateStmt(forStmt, label) - - default: - panic("") - } - - case *ast.BranchStmt: - normalLabel := "" - blockingLabel := "" - data := c.flowDatas[nil] - if s.Label != nil { - normalLabel = " " + s.Label.Name - blockingLabel = " s" // use explicit label "s", because surrounding loop may not be flattened - data = c.flowDatas[c.p.Uses[s.Label].(*types.Label)] - } - switch s.Tok { - case token.BREAK: - c.PrintCond(data.endCase == 0, fmt.Sprintf("break%s;", normalLabel), fmt.Sprintf("$s = %d; continue%s;", data.endCase, blockingLabel)) - case token.CONTINUE: - data.postStmt() - c.PrintCond(data.beginCase == 0, fmt.Sprintf("continue%s;", normalLabel), fmt.Sprintf("$s = %d; continue%s;", data.beginCase, blockingLabel)) - case token.GOTO: - c.PrintCond(false, "goto "+s.Label.Name, fmt.Sprintf("$s = %d; continue;", c.labelCase(c.p.Uses[s.Label].(*types.Label)))) - case token.FALLTHROUGH: - // handled in CaseClause - default: - panic("Unhandled branch statment: " + s.Tok.String()) - } - - case *ast.ReturnStmt: - results := s.Results - if c.resultNames != nil { - if len(s.Results) != 0 { - c.translateStmt(&ast.AssignStmt{ - Lhs: c.resultNames, - Tok: token.ASSIGN, - Rhs: s.Results, - }, nil) - } - results = c.resultNames - } - rVal := c.translateResults(results) - if len(c.Flattened) != 0 { - c.Printf("$s = -1; return%s;", rVal) - return - } - c.Printf("return%s;", rVal) - - case *ast.DeferStmt: - isBuiltin := false - isJs := false - switch fun := s.Call.Fun.(type) { - case *ast.Ident: - var builtin *types.Builtin - builtin, isBuiltin = c.p.Uses[fun].(*types.Builtin) - if isBuiltin && builtin.Name() == "recover" { - c.Printf("$deferred.push([$recover, []]);") - return - } - case *ast.SelectorExpr: - isJs = typesutil.IsJsPackage(c.p.Uses[fun.Sel].Pkg()) - } - sig := c.p.TypeOf(s.Call.Fun).Underlying().(*types.Signature) - args := c.translateArgs(sig, s.Call.Args, s.Call.Ellipsis.IsValid()) - if isBuiltin || isJs { - vars := make([]string, len(s.Call.Args)) - callArgs := make([]ast.Expr, len(s.Call.Args)) - for i, arg := range s.Call.Args { - v := c.newVariable("_arg") - vars[i] = v - callArgs[i] = c.newIdent(v, c.p.TypeOf(arg)) - } - call := c.translateExpr(&ast.CallExpr{ - Fun: s.Call.Fun, - Args: callArgs, - Ellipsis: s.Call.Ellipsis, - }) - c.Printf("$deferred.push([function(%s) { %s; }, [%s]]);", strings.Join(vars, ", "), call, strings.Join(args, ", ")) - return - } - c.Printf("$deferred.push([%s, [%s]]);", c.translateExpr(s.Call.Fun), strings.Join(args, ", ")) - - case *ast.AssignStmt: - if s.Tok != token.ASSIGN && s.Tok != token.DEFINE { - panic(s.Tok) - } - - switch { - case len(s.Lhs) == 1 && len(s.Rhs) == 1: - lhs := astutil.RemoveParens(s.Lhs[0]) - if isBlank(lhs) { - c.Printf("$unused(%s);", c.translateExpr(s.Rhs[0])) - return - } - c.Printf("%s", c.translateAssign(lhs, s.Rhs[0], s.Tok == token.DEFINE)) - - case len(s.Lhs) > 1 && len(s.Rhs) == 1: - tupleVar := c.newVariable("_tuple") - c.Printf("%s = %s;", tupleVar, c.translateExpr(s.Rhs[0])) - tuple := c.p.TypeOf(s.Rhs[0]).(*types.Tuple) - for i, lhs := range s.Lhs { - lhs = astutil.RemoveParens(lhs) - if !isBlank(lhs) { - c.Printf("%s", c.translateAssign(lhs, c.newIdent(fmt.Sprintf("%s[%d]", tupleVar, i), tuple.At(i).Type()), s.Tok == token.DEFINE)) - } - } - case len(s.Lhs) == len(s.Rhs): - tmpVars := make([]string, len(s.Rhs)) - for i, rhs := range s.Rhs { - tmpVars[i] = c.newVariable("_tmp") - if isBlank(astutil.RemoveParens(s.Lhs[i])) { - c.Printf("$unused(%s);", c.translateExpr(rhs)) - continue - } - c.Printf("%s", c.translateAssign(c.newIdent(tmpVars[i], c.p.TypeOf(s.Lhs[i])), rhs, true)) - } - for i, lhs := range s.Lhs { - lhs = astutil.RemoveParens(lhs) - if !isBlank(lhs) { - c.Printf("%s", c.translateAssign(lhs, c.newIdent(tmpVars[i], c.p.TypeOf(lhs)), s.Tok == token.DEFINE)) - } - } - - default: - panic("Invalid arity of AssignStmt.") - - } - - case *ast.DeclStmt: - decl := s.Decl.(*ast.GenDecl) - switch decl.Tok { - case token.VAR: - for _, spec := range s.Decl.(*ast.GenDecl).Specs { - valueSpec := spec.(*ast.ValueSpec) - lhs := make([]ast.Expr, len(valueSpec.Names)) - for i, name := range valueSpec.Names { - lhs[i] = name - } - rhs := valueSpec.Values - if len(rhs) == 0 { - rhs = make([]ast.Expr, len(lhs)) - for i, e := range lhs { - rhs[i] = c.zeroValue(c.p.TypeOf(e)) - } - } - c.translateStmt(&ast.AssignStmt{ - Lhs: lhs, - Tok: token.DEFINE, - Rhs: rhs, - }, nil) - } - case token.TYPE: - for _, spec := range decl.Specs { - o := c.p.Defs[spec.(*ast.TypeSpec).Name].(*types.TypeName) - c.p.typeNames = append(c.p.typeNames, o) - c.p.objectNames[o] = c.newVariableWithLevel(o.Name(), true) - c.p.dependencies[o] = true - } - case token.CONST: - // skip, constants are inlined - } - - case *ast.ExprStmt: - expr := c.translateExpr(s.X) - if expr != nil && expr.String() != "" { - c.Printf("%s;", expr) - } - - case *ast.LabeledStmt: - label := c.p.Defs[s.Label].(*types.Label) - if c.GotoLabel[label] { - c.PrintCond(false, s.Label.Name+":", fmt.Sprintf("case %d:", c.labelCase(label))) - } - c.translateStmt(s.Stmt, label) - - case *ast.GoStmt: - c.Printf("$go(%s, [%s]);", c.translateExpr(s.Call.Fun), strings.Join(c.translateArgs(c.p.TypeOf(s.Call.Fun).Underlying().(*types.Signature), s.Call.Args, s.Call.Ellipsis.IsValid()), ", ")) - - case *ast.SendStmt: - chanType := c.p.TypeOf(s.Chan).Underlying().(*types.Chan) - call := &ast.CallExpr{ - Fun: c.newIdent("$send", types.NewSignature(nil, types.NewTuple(types.NewVar(0, nil, "", chanType), types.NewVar(0, nil, "", chanType.Elem())), nil, false)), - Args: []ast.Expr{s.Chan, c.newIdent(c.translateImplicitConversionWithCloning(s.Value, chanType.Elem()).String(), chanType.Elem())}, - } - c.Blocking[call] = true - c.translateStmt(&ast.ExprStmt{X: call}, label) - - case *ast.SelectStmt: - selectionVar := c.newVariable("_selection") - var channels []string - var caseClauses []*ast.CaseClause - flattened := false - hasDefault := false - for i, cc := range s.Body.List { - clause := cc.(*ast.CommClause) - switch comm := clause.Comm.(type) { - case nil: - channels = append(channels, "[]") - hasDefault = true - case *ast.ExprStmt: - channels = append(channels, c.formatExpr("[%e]", astutil.RemoveParens(comm.X).(*ast.UnaryExpr).X).String()) - case *ast.AssignStmt: - channels = append(channels, c.formatExpr("[%e]", astutil.RemoveParens(comm.Rhs[0]).(*ast.UnaryExpr).X).String()) - case *ast.SendStmt: - chanType := c.p.TypeOf(comm.Chan).Underlying().(*types.Chan) - channels = append(channels, c.formatExpr("[%e, %s]", comm.Chan, c.translateImplicitConversionWithCloning(comm.Value, chanType.Elem())).String()) - default: - panic(fmt.Sprintf("unhandled: %T", comm)) - } - - indexLit := &ast.BasicLit{Kind: token.INT} - c.p.Types[indexLit] = types.TypeAndValue{Type: types.Typ[types.Int], Value: constant.MakeInt64(int64(i))} - - var bodyPrefix []ast.Stmt - if assign, ok := clause.Comm.(*ast.AssignStmt); ok { - switch rhsType := c.p.TypeOf(assign.Rhs[0]).(type) { - case *types.Tuple: - bodyPrefix = []ast.Stmt{&ast.AssignStmt{Lhs: assign.Lhs, Rhs: []ast.Expr{c.newIdent(selectionVar+"[1]", rhsType)}, Tok: assign.Tok}} - default: - bodyPrefix = []ast.Stmt{&ast.AssignStmt{Lhs: assign.Lhs, Rhs: []ast.Expr{c.newIdent(selectionVar+"[1][0]", rhsType)}, Tok: assign.Tok}} - } - } - - caseClauses = append(caseClauses, &ast.CaseClause{ - List: []ast.Expr{indexLit}, - Body: append(bodyPrefix, clause.Body...), - }) - - flattened = flattened || c.Flattened[clause] - } - - selectCall := c.setType(&ast.CallExpr{ - Fun: c.newIdent("$select", types.NewSignature(nil, types.NewTuple(types.NewVar(0, nil, "", types.NewInterface(nil, nil))), types.NewTuple(types.NewVar(0, nil, "", types.Typ[types.Int])), false)), - Args: []ast.Expr{c.newIdent(fmt.Sprintf("[%s]", strings.Join(channels, ", ")), types.NewInterface(nil, nil))}, - }, types.Typ[types.Int]) - c.Blocking[selectCall] = !hasDefault - c.Printf("%s = %s;", selectionVar, c.translateExpr(selectCall)) - - if len(caseClauses) != 0 { - translateCond := func(cond ast.Expr) *expression { - return c.formatExpr("%s[0] === %e", selectionVar, cond) - } - c.translateBranchingStmt(caseClauses, nil, true, translateCond, label, flattened) - } - - case *ast.EmptyStmt: - // skip - - default: - panic(fmt.Sprintf("Unhandled statement: %T\n", s)) - - } -} - -func (c *funcContext) translateBranchingStmt(caseClauses []*ast.CaseClause, defaultClause *ast.CaseClause, canBreak bool, translateCond func(ast.Expr) *expression, label *types.Label, flatten bool) { - var caseOffset, defaultCase, endCase int - if flatten { - caseOffset = c.caseCounter - defaultCase = caseOffset + len(caseClauses) - endCase = defaultCase - if defaultClause != nil { - endCase++ - } - c.caseCounter = endCase + 1 - } - - hasBreak := false - if canBreak { - prevFlowData := c.flowDatas[nil] - data := &flowData{ - postStmt: prevFlowData.postStmt, // for "continue" of outer loop - beginCase: prevFlowData.beginCase, // same - endCase: endCase, - } - c.flowDatas[nil] = data - c.flowDatas[label] = data - defer func() { - delete(c.flowDatas, label) - c.flowDatas[nil] = prevFlowData - }() - - for _, child := range caseClauses { - if analysis.HasBreak(child) { - hasBreak = true - break - } - } - if defaultClause != nil && analysis.HasBreak(defaultClause) { - hasBreak = true - } - } - - if label != nil && !flatten { - c.Printf("%s:", label.Name()) - } - - condStrs := make([]string, len(caseClauses)) - for i, clause := range caseClauses { - conds := make([]string, len(clause.List)) - for j, cond := range clause.List { - conds[j] = translateCond(cond).String() - } - condStrs[i] = strings.Join(conds, " || ") - if flatten { - c.Printf("/* */ if (%s) { $s = %d; continue; }", condStrs[i], caseOffset+i) - } - } - - if flatten { - c.Printf("/* */ $s = %d; continue;", defaultCase) - } - - prefix := "" - suffix := "" - if label != nil || hasBreak { - prefix = "switch (0) { default: " - suffix = " }" - } - - for i, clause := range caseClauses { - c.SetPos(clause.Pos()) - c.PrintCond(!flatten, fmt.Sprintf("%sif (%s) {", prefix, condStrs[i]), fmt.Sprintf("case %d:", caseOffset+i)) - c.Indent(func() { - c.translateStmtList(clause.Body) - if flatten && (i < len(caseClauses)-1 || defaultClause != nil) && !endsWithReturn(clause.Body) { - c.Printf("$s = %d; continue;", endCase) - } - }) - prefix = "} else " - } - - if defaultClause != nil { - c.PrintCond(!flatten, prefix+"{", fmt.Sprintf("case %d:", caseOffset+len(caseClauses))) - c.Indent(func() { - c.translateStmtList(defaultClause.Body) - }) - } - - c.PrintCond(!flatten, "}"+suffix, fmt.Sprintf("case %d:", endCase)) -} - -func (c *funcContext) translateLoopingStmt(cond func() string, body *ast.BlockStmt, bodyPrefix, post func(), label *types.Label, flatten bool) { - prevFlowData := c.flowDatas[nil] - data := &flowData{ - postStmt: post, - } - if flatten { - data.beginCase = c.caseCounter - data.endCase = c.caseCounter + 1 - c.caseCounter += 2 - } - c.flowDatas[nil] = data - c.flowDatas[label] = data - defer func() { - delete(c.flowDatas, label) - c.flowDatas[nil] = prevFlowData - }() - - if !flatten && label != nil { - c.Printf("%s:", label.Name()) - } - c.PrintCond(!flatten, "while (true) {", fmt.Sprintf("case %d:", data.beginCase)) - c.Indent(func() { - condStr := cond() - if condStr != "true" { - c.PrintCond(!flatten, fmt.Sprintf("if (!(%s)) { break; }", condStr), fmt.Sprintf("if(!(%s)) { $s = %d; continue; }", condStr, data.endCase)) - } - - prevEV := c.p.escapingVars - c.handleEscapingVars(body) - - if bodyPrefix != nil { - bodyPrefix() - } - c.translateStmtList(body.List) - isTerminated := false - if len(body.List) != 0 { - switch body.List[len(body.List)-1].(type) { - case *ast.ReturnStmt, *ast.BranchStmt: - isTerminated = true - } - } - if !isTerminated { - post() - } - - c.p.escapingVars = prevEV - }) - c.PrintCond(!flatten, "}", fmt.Sprintf("$s = %d; continue; case %d:", data.beginCase, data.endCase)) -} - -func (c *funcContext) translateAssign(lhs, rhs ast.Expr, define bool) string { - lhs = astutil.RemoveParens(lhs) - if isBlank(lhs) { - panic("translateAssign with blank lhs") - } - - if l, ok := lhs.(*ast.IndexExpr); ok { - if t, ok := c.p.TypeOf(l.X).Underlying().(*types.Map); ok { - if typesutil.IsJsObject(c.p.TypeOf(l.Index)) { - c.p.errList = append(c.p.errList, types.Error{Fset: c.p.fileSet, Pos: l.Index.Pos(), Msg: "cannot use js.Object as map key"}) - } - keyVar := c.newVariable("_key") - return fmt.Sprintf(`%s = %s; (%s || $throwRuntimeError("assignment to entry in nil map"))[%s.keyFor(%s)] = { k: %s, v: %s };`, keyVar, c.translateImplicitConversionWithCloning(l.Index, t.Key()), c.translateExpr(l.X), c.typeName(t.Key()), keyVar, keyVar, c.translateImplicitConversionWithCloning(rhs, t.Elem())) - } - } - - lhsType := c.p.TypeOf(lhs) - rhsExpr := c.translateImplicitConversion(rhs, lhsType) - if _, ok := rhs.(*ast.CompositeLit); ok && define { - return fmt.Sprintf("%s = %s;", c.translateExpr(lhs), rhsExpr) // skip $copy - } - - isReflectValue := false - if named, ok := lhsType.(*types.Named); ok && named.Obj().Pkg() != nil && named.Obj().Pkg().Path() == "reflect" && named.Obj().Name() == "Value" { - isReflectValue = true - } - if !isReflectValue { // this is a performance hack, but it is safe since reflect.Value has no exported fields and the reflect package does not violate this assumption - switch lhsType.Underlying().(type) { - case *types.Array, *types.Struct: - if define { - return fmt.Sprintf("%s = $clone(%s, %s);", c.translateExpr(lhs), rhsExpr, c.typeName(lhsType)) - } - return fmt.Sprintf("%s.copy(%s, %s);", c.typeName(lhsType), c.translateExpr(lhs), rhsExpr) - } - } - - switch l := lhs.(type) { - case *ast.Ident: - return fmt.Sprintf("%s = %s;", c.objectName(c.p.ObjectOf(l)), rhsExpr) - case *ast.SelectorExpr: - sel, ok := c.p.SelectionOf(l) - if !ok { - // qualified identifier - return fmt.Sprintf("%s = %s;", c.objectName(c.p.Uses[l.Sel]), rhsExpr) - } - fields, jsTag := c.translateSelection(sel, l.Pos()) - if jsTag != "" { - return fmt.Sprintf("%s.%s.%s = %s;", c.translateExpr(l.X), strings.Join(fields, "."), jsTag, c.externalize(rhsExpr.String(), sel.Type())) - } - return fmt.Sprintf("%s.%s = %s;", c.translateExpr(l.X), strings.Join(fields, "."), rhsExpr) - case *ast.StarExpr: - return fmt.Sprintf("%s.$set(%s);", c.translateExpr(l.X), rhsExpr) - case *ast.IndexExpr: - switch t := c.p.TypeOf(l.X).Underlying().(type) { - case *types.Array, *types.Pointer: - pattern := rangeCheck("%1e[%2f] = %3s", c.p.Types[l.Index].Value != nil, true) - if _, ok := t.(*types.Pointer); ok { // check pointer for nil (attribute getter causes a panic) - pattern = `%1e.nilCheck, ` + pattern - } - return c.formatExpr(pattern, l.X, l.Index, rhsExpr).String() + ";" - case *types.Slice: - return c.formatExpr(rangeCheck("%1e.$array[%1e.$offset + %2f] = %3s", c.p.Types[l.Index].Value != nil, false), l.X, l.Index, rhsExpr).String() + ";" - default: - panic(fmt.Sprintf("Unhandled lhs type: %T\n", t)) - } - default: - panic(fmt.Sprintf("Unhandled lhs type: %T\n", l)) - } -} - -func (c *funcContext) translateResults(results []ast.Expr) string { - tuple := c.sig.Results() - switch tuple.Len() { - case 0: - return "" - case 1: - result := c.zeroValue(tuple.At(0).Type()) - if results != nil { - result = results[0] - } - v := c.translateImplicitConversion(result, tuple.At(0).Type()) - c.delayedOutput = nil - return " " + v.String() - default: - if len(results) == 1 { - resultTuple := c.p.TypeOf(results[0]).(*types.Tuple) - - if resultTuple.Len() != tuple.Len() { - panic("invalid tuple return assignment") - } - - resultExpr := c.translateExpr(results[0]).String() - - if types.Identical(resultTuple, tuple) { - return " " + resultExpr - } - - tmpVar := c.newVariable("_returncast") - c.Printf("%s = %s;", tmpVar, resultExpr) - - // Not all the return types matched, map everything out for implicit casting - results = make([]ast.Expr, resultTuple.Len()) - for i := range results { - results[i] = c.newIdent(fmt.Sprintf("%s[%d]", tmpVar, i), resultTuple.At(i).Type()) - } - } - values := make([]string, tuple.Len()) - for i := range values { - result := c.zeroValue(tuple.At(i).Type()) - if results != nil { - result = results[i] - } - values[i] = c.translateImplicitConversion(result, tuple.At(i).Type()).String() - } - c.delayedOutput = nil - return " [" + strings.Join(values, ", ") + "]" - } -} - -func (c *funcContext) labelCase(label *types.Label) int { - labelCase, ok := c.labelCases[label] - if !ok { - labelCase = c.caseCounter - c.caseCounter++ - c.labelCases[label] = labelCase - } - return labelCase -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/typesutil/typesutil.go b/vendor/github.com/gopherjs/gopherjs/compiler/typesutil/typesutil.go deleted file mode 100644 index fccb71f77..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/typesutil/typesutil.go +++ /dev/null @@ -1,19 +0,0 @@ -package typesutil - -import ( - "go/types" - "strings" -) - -func IsJsPackage(pkg *types.Package) bool { - return pkg != nil && (pkg.Path() == "github.com/gopherjs/gopherjs/js" || strings.HasSuffix(pkg.Path(), "/vendor/github.com/gopherjs/gopherjs/js")) -} - -func IsJsObject(t types.Type) bool { - ptr, isPtr := t.(*types.Pointer) - if !isPtr { - return false - } - named, isNamed := ptr.Elem().(*types.Named) - return isNamed && IsJsPackage(named.Obj().Pkg()) && named.Obj().Name() == "Object" -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/utils.go b/vendor/github.com/gopherjs/gopherjs/compiler/utils.go deleted file mode 100644 index a03e1449d..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/utils.go +++ /dev/null @@ -1,654 +0,0 @@ -package compiler - -import ( - "bytes" - "encoding/binary" - "fmt" - "go/ast" - "go/constant" - "go/token" - "go/types" - "net/url" - "sort" - "strconv" - "strings" - - "github.com/gopherjs/gopherjs/compiler/analysis" - "github.com/gopherjs/gopherjs/compiler/typesutil" -) - -func (c *funcContext) Write(b []byte) (int, error) { - c.writePos() - c.output = append(c.output, b...) - return len(b), nil -} - -func (c *funcContext) Printf(format string, values ...interface{}) { - c.Write([]byte(strings.Repeat("\t", c.p.indentation))) - fmt.Fprintf(c, format, values...) - c.Write([]byte{'\n'}) - c.Write(c.delayedOutput) - c.delayedOutput = nil -} - -func (c *funcContext) PrintCond(cond bool, onTrue, onFalse string) { - if !cond { - c.Printf("/* %s */ %s", strings.Replace(onTrue, "*/", "/", -1), onFalse) - return - } - c.Printf("%s", onTrue) -} - -func (c *funcContext) SetPos(pos token.Pos) { - c.posAvailable = true - c.pos = pos -} - -func (c *funcContext) writePos() { - if c.posAvailable { - c.posAvailable = false - c.Write([]byte{'\b'}) - binary.Write(c, binary.BigEndian, uint32(c.pos)) - } -} - -func (c *funcContext) Indent(f func()) { - c.p.indentation++ - f() - c.p.indentation-- -} - -func (c *funcContext) CatchOutput(indent int, f func()) []byte { - origoutput := c.output - c.output = nil - c.p.indentation += indent - f() - c.writePos() - catched := c.output - c.output = origoutput - c.p.indentation -= indent - return catched -} - -func (c *funcContext) Delayed(f func()) { - c.delayedOutput = c.CatchOutput(0, f) -} - -func (c *funcContext) translateArgs(sig *types.Signature, argExprs []ast.Expr, ellipsis bool) []string { - if len(argExprs) == 1 { - if tuple, isTuple := c.p.TypeOf(argExprs[0]).(*types.Tuple); isTuple { - tupleVar := c.newVariable("_tuple") - c.Printf("%s = %s;", tupleVar, c.translateExpr(argExprs[0])) - argExprs = make([]ast.Expr, tuple.Len()) - for i := range argExprs { - argExprs[i] = c.newIdent(c.formatExpr("%s[%d]", tupleVar, i).String(), tuple.At(i).Type()) - } - } - } - - paramsLen := sig.Params().Len() - - var varargType *types.Slice - if sig.Variadic() && !ellipsis { - varargType = sig.Params().At(paramsLen - 1).Type().(*types.Slice) - } - - preserveOrder := false - for i := 1; i < len(argExprs); i++ { - preserveOrder = preserveOrder || c.Blocking[argExprs[i]] - } - - args := make([]string, len(argExprs)) - for i, argExpr := range argExprs { - var argType types.Type - switch { - case varargType != nil && i >= paramsLen-1: - argType = varargType.Elem() - default: - argType = sig.Params().At(i).Type() - } - - arg := c.translateImplicitConversionWithCloning(argExpr, argType).String() - - if preserveOrder && c.p.Types[argExpr].Value == nil { - argVar := c.newVariable("_arg") - c.Printf("%s = %s;", argVar, arg) - arg = argVar - } - - args[i] = arg - } - - if varargType != nil { - return append(args[:paramsLen-1], fmt.Sprintf("new %s([%s])", c.typeName(varargType), strings.Join(args[paramsLen-1:], ", "))) - } - return args -} - -func (c *funcContext) translateSelection(sel selection, pos token.Pos) ([]string, string) { - var fields []string - t := sel.Recv() - for _, index := range sel.Index() { - if ptr, isPtr := t.(*types.Pointer); isPtr { - t = ptr.Elem() - } - s := t.Underlying().(*types.Struct) - if jsTag := getJsTag(s.Tag(index)); jsTag != "" { - jsFieldName := s.Field(index).Name() - for { - fields = append(fields, fieldName(s, 0)) - ft := s.Field(0).Type() - if typesutil.IsJsObject(ft) { - return fields, jsTag - } - ft = ft.Underlying() - if ptr, ok := ft.(*types.Pointer); ok { - ft = ptr.Elem().Underlying() - } - var ok bool - s, ok = ft.(*types.Struct) - if !ok || s.NumFields() == 0 { - c.p.errList = append(c.p.errList, types.Error{Fset: c.p.fileSet, Pos: pos, Msg: fmt.Sprintf("could not find field with type *js.Object for 'js' tag of field '%s'", jsFieldName), Soft: true}) - return nil, "" - } - } - } - fields = append(fields, fieldName(s, index)) - t = s.Field(index).Type() - } - return fields, "" -} - -var nilObj = types.Universe.Lookup("nil") - -func (c *funcContext) zeroValue(ty types.Type) ast.Expr { - switch t := ty.Underlying().(type) { - case *types.Basic: - switch { - case isBoolean(t): - return c.newConst(ty, constant.MakeBool(false)) - case isNumeric(t): - return c.newConst(ty, constant.MakeInt64(0)) - case isString(t): - return c.newConst(ty, constant.MakeString("")) - case t.Kind() == types.UnsafePointer: - // fall through to "nil" - case t.Kind() == types.UntypedNil: - panic("Zero value for untyped nil.") - default: - panic(fmt.Sprintf("Unhandled basic type: %v\n", t)) - } - case *types.Array, *types.Struct: - return c.setType(&ast.CompositeLit{}, ty) - case *types.Chan, *types.Interface, *types.Map, *types.Signature, *types.Slice, *types.Pointer: - // fall through to "nil" - default: - panic(fmt.Sprintf("Unhandled type: %T\n", t)) - } - id := c.newIdent("nil", ty) - c.p.Uses[id] = nilObj - return id -} - -func (c *funcContext) newConst(t types.Type, value constant.Value) ast.Expr { - id := &ast.Ident{} - c.p.Types[id] = types.TypeAndValue{Type: t, Value: value} - return id -} - -func (c *funcContext) newVariable(name string) string { - return c.newVariableWithLevel(name, false) -} - -func (c *funcContext) newVariableWithLevel(name string, pkgLevel bool) string { - if name == "" { - panic("newVariable: empty name") - } - name = encodeIdent(name) - if c.p.minify { - i := 0 - for { - offset := int('a') - if pkgLevel { - offset = int('A') - } - j := i - name = "" - for { - name = string(offset+(j%26)) + name - j = j/26 - 1 - if j == -1 { - break - } - } - if c.allVars[name] == 0 { - break - } - i++ - } - } - n := c.allVars[name] - c.allVars[name] = n + 1 - varName := name - if n > 0 { - varName = fmt.Sprintf("%s$%d", name, n) - } - - if pkgLevel { - for c2 := c.parent; c2 != nil; c2 = c2.parent { - c2.allVars[name] = n + 1 - } - return varName - } - - c.localVars = append(c.localVars, varName) - return varName -} - -func (c *funcContext) newIdent(name string, t types.Type) *ast.Ident { - ident := ast.NewIdent(name) - c.setType(ident, t) - obj := types.NewVar(0, c.p.Pkg, name, t) - c.p.Uses[ident] = obj - c.p.objectNames[obj] = name - return ident -} - -func (c *funcContext) setType(e ast.Expr, t types.Type) ast.Expr { - c.p.Types[e] = types.TypeAndValue{Type: t} - return e -} - -func (c *funcContext) pkgVar(pkg *types.Package) string { - if pkg == c.p.Pkg { - return "$pkg" - } - - pkgVar, found := c.p.pkgVars[pkg.Path()] - if !found { - pkgVar = fmt.Sprintf(`$packages["%s"]`, pkg.Path()) - } - return pkgVar -} - -func isVarOrConst(o types.Object) bool { - switch o.(type) { - case *types.Var, *types.Const: - return true - } - return false -} - -func isPkgLevel(o types.Object) bool { - return o.Parent() != nil && o.Parent().Parent() == types.Universe -} - -func (c *funcContext) objectName(o types.Object) string { - if isPkgLevel(o) { - c.p.dependencies[o] = true - - if o.Pkg() != c.p.Pkg || (isVarOrConst(o) && o.Exported()) { - return c.pkgVar(o.Pkg()) + "." + o.Name() - } - } - - name, ok := c.p.objectNames[o] - if !ok { - name = c.newVariableWithLevel(o.Name(), isPkgLevel(o)) - c.p.objectNames[o] = name - } - - if v, ok := o.(*types.Var); ok && c.p.escapingVars[v] { - return name + "[0]" - } - return name -} - -func (c *funcContext) varPtrName(o *types.Var) string { - if isPkgLevel(o) && o.Exported() { - return c.pkgVar(o.Pkg()) + "." + o.Name() + "$ptr" - } - - name, ok := c.p.varPtrNames[o] - if !ok { - name = c.newVariableWithLevel(o.Name()+"$ptr", isPkgLevel(o)) - c.p.varPtrNames[o] = name - } - return name -} - -func (c *funcContext) typeName(ty types.Type) string { - switch t := ty.(type) { - case *types.Basic: - return "$" + toJavaScriptType(t) - case *types.Named: - if t.Obj().Name() == "error" { - return "$error" - } - return c.objectName(t.Obj()) - case *types.Interface: - if t.Empty() { - return "$emptyInterface" - } - } - - anonType, ok := c.p.anonTypeMap.At(ty).(*types.TypeName) - if !ok { - c.initArgs(ty) // cause all embedded types to be registered - varName := c.newVariableWithLevel(strings.ToLower(typeKind(ty)[5:])+"Type", true) - anonType = types.NewTypeName(token.NoPos, c.p.Pkg, varName, ty) // fake types.TypeName - c.p.anonTypes = append(c.p.anonTypes, anonType) - c.p.anonTypeMap.Set(ty, anonType) - } - c.p.dependencies[anonType] = true - return anonType.Name() -} - -func (c *funcContext) externalize(s string, t types.Type) string { - if typesutil.IsJsObject(t) { - return s - } - switch u := t.Underlying().(type) { - case *types.Basic: - if isNumeric(u) && !is64Bit(u) && !isComplex(u) { - return s - } - if u.Kind() == types.UntypedNil { - return "null" - } - } - return fmt.Sprintf("$externalize(%s, %s)", s, c.typeName(t)) -} - -func (c *funcContext) handleEscapingVars(n ast.Node) { - newEscapingVars := make(map[*types.Var]bool) - for escaping := range c.p.escapingVars { - newEscapingVars[escaping] = true - } - c.p.escapingVars = newEscapingVars - - var names []string - objs := analysis.EscapingObjects(n, c.p.Info.Info) - sort.Sort(varsByName(objs)) - for _, obj := range objs { - names = append(names, c.objectName(obj)) - c.p.escapingVars[obj] = true - } - sort.Strings(names) - for _, name := range names { - c.Printf("%s = [%s];", name, name) - } -} - -func fieldName(t *types.Struct, i int) string { - name := t.Field(i).Name() - if name == "_" || reservedKeywords[name] { - return fmt.Sprintf("%s$%d", name, i) - } - return name -} - -func typeKind(ty types.Type) string { - switch t := ty.Underlying().(type) { - case *types.Basic: - return "$kind" + toJavaScriptType(t) - case *types.Array: - return "$kindArray" - case *types.Chan: - return "$kindChan" - case *types.Interface: - return "$kindInterface" - case *types.Map: - return "$kindMap" - case *types.Signature: - return "$kindFunc" - case *types.Slice: - return "$kindSlice" - case *types.Struct: - return "$kindStruct" - case *types.Pointer: - return "$kindPtr" - default: - panic(fmt.Sprintf("Unhandled type: %T\n", t)) - } -} - -func toJavaScriptType(t *types.Basic) string { - switch t.Kind() { - case types.UntypedInt: - return "Int" - case types.Byte: - return "Uint8" - case types.Rune: - return "Int32" - case types.UnsafePointer: - return "UnsafePointer" - default: - name := t.String() - return strings.ToUpper(name[:1]) + name[1:] - } -} - -func is64Bit(t *types.Basic) bool { - return t.Kind() == types.Int64 || t.Kind() == types.Uint64 -} - -func isBoolean(t *types.Basic) bool { - return t.Info()&types.IsBoolean != 0 -} - -func isComplex(t *types.Basic) bool { - return t.Info()&types.IsComplex != 0 -} - -func isFloat(t *types.Basic) bool { - return t.Info()&types.IsFloat != 0 -} - -func isInteger(t *types.Basic) bool { - return t.Info()&types.IsInteger != 0 -} - -func isNumeric(t *types.Basic) bool { - return t.Info()&types.IsNumeric != 0 -} - -func isString(t *types.Basic) bool { - return t.Info()&types.IsString != 0 -} - -func isUnsigned(t *types.Basic) bool { - return t.Info()&types.IsUnsigned != 0 -} - -func isBlank(expr ast.Expr) bool { - if expr == nil { - return true - } - if id, isIdent := expr.(*ast.Ident); isIdent { - return id.Name == "_" - } - return false -} - -func isWrapped(ty types.Type) bool { - switch t := ty.Underlying().(type) { - case *types.Basic: - return !is64Bit(t) && !isComplex(t) && t.Kind() != types.UntypedNil - case *types.Array, *types.Chan, *types.Map, *types.Signature: - return true - case *types.Pointer: - _, isArray := t.Elem().Underlying().(*types.Array) - return isArray - } - return false -} - -func encodeString(s string) string { - buffer := bytes.NewBuffer(nil) - for _, r := range []byte(s) { - switch r { - case '\b': - buffer.WriteString(`\b`) - case '\f': - buffer.WriteString(`\f`) - case '\n': - buffer.WriteString(`\n`) - case '\r': - buffer.WriteString(`\r`) - case '\t': - buffer.WriteString(`\t`) - case '\v': - buffer.WriteString(`\v`) - case '"': - buffer.WriteString(`\"`) - case '\\': - buffer.WriteString(`\\`) - default: - if r < 0x20 || r > 0x7E { - fmt.Fprintf(buffer, `\x%02X`, r) - continue - } - buffer.WriteByte(r) - } - } - return `"` + buffer.String() + `"` -} - -func getJsTag(tag string) string { - for tag != "" { - // skip leading space - i := 0 - for i < len(tag) && tag[i] == ' ' { - i++ - } - tag = tag[i:] - if tag == "" { - break - } - - // scan to colon. - // a space or a quote is a syntax error - i = 0 - for i < len(tag) && tag[i] != ' ' && tag[i] != ':' && tag[i] != '"' { - i++ - } - if i+1 >= len(tag) || tag[i] != ':' || tag[i+1] != '"' { - break - } - name := string(tag[:i]) - tag = tag[i+1:] - - // scan quoted string to find value - i = 1 - for i < len(tag) && tag[i] != '"' { - if tag[i] == '\\' { - i++ - } - i++ - } - if i >= len(tag) { - break - } - qvalue := string(tag[:i+1]) - tag = tag[i+1:] - - if name == "js" { - value, _ := strconv.Unquote(qvalue) - return value - } - } - return "" -} - -func needsSpace(c byte) bool { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' || c == '$' -} - -func removeWhitespace(b []byte, minify bool) []byte { - if !minify { - return b - } - - var out []byte - var previous byte - for len(b) > 0 { - switch b[0] { - case '\b': - out = append(out, b[:5]...) - b = b[5:] - continue - case ' ', '\t', '\n': - if (!needsSpace(previous) || !needsSpace(b[1])) && !(previous == '-' && b[1] == '-') { - b = b[1:] - continue - } - case '"': - out = append(out, '"') - b = b[1:] - for { - i := bytes.IndexAny(b, "\"\\") - out = append(out, b[:i]...) - b = b[i:] - if b[0] == '"' { - break - } - // backslash - out = append(out, b[:2]...) - b = b[2:] - } - case '/': - if b[1] == '*' { - i := bytes.Index(b[2:], []byte("*/")) - b = b[i+4:] - continue - } - } - out = append(out, b[0]) - previous = b[0] - b = b[1:] - } - return out -} - -func rangeCheck(pattern string, constantIndex, array bool) string { - if constantIndex && array { - return pattern - } - lengthProp := "$length" - if array { - lengthProp = "length" - } - check := "%2f >= %1e." + lengthProp - if !constantIndex { - check = "(%2f < 0 || " + check + ")" - } - return "(" + check + ` ? ($throwRuntimeError("index out of range"), undefined) : ` + pattern + ")" -} - -func endsWithReturn(stmts []ast.Stmt) bool { - if len(stmts) > 0 { - if _, ok := stmts[len(stmts)-1].(*ast.ReturnStmt); ok { - return true - } - } - return false -} - -func encodeIdent(name string) string { - return strings.Replace(url.QueryEscape(name), "%", "$", -1) -} - -type varsByName []*types.Var - -func (s varsByName) Len() int { - return len(s) -} - -func (s varsByName) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} - -func (s varsByName) Less(i, j int) bool { - return s[i].Name() < s[j].Name() -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/vendor/github.com/neelance/astrewrite/LICENSE b/vendor/github.com/gopherjs/gopherjs/compiler/vendor/github.com/neelance/astrewrite/LICENSE deleted file mode 100644 index ce7f487d2..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/vendor/github.com/neelance/astrewrite/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2016 Richard Musiol. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/vendor/github.com/neelance/astrewrite/simplify.go b/vendor/github.com/gopherjs/gopherjs/compiler/vendor/github.com/neelance/astrewrite/simplify.go deleted file mode 100644 index a4fcc51ea..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/vendor/github.com/neelance/astrewrite/simplify.go +++ /dev/null @@ -1,835 +0,0 @@ -package astrewrite - -import ( - "fmt" - "go/ast" - "go/constant" - "go/token" - "go/types" -) - -type simplifyContext struct { - info *types.Info - varCounter int - simplifyCalls bool -} - -func Simplify(file *ast.File, info *types.Info, simplifyCalls bool) *ast.File { - c := &simplifyContext{info: info, simplifyCalls: simplifyCalls} - - decls := make([]ast.Decl, len(file.Decls)) - for i, decl := range file.Decls { - c.varCounter = 0 - switch decl := decl.(type) { - case *ast.GenDecl: - decls[i] = c.simplifyGenDecl(nil, decl) - - case *ast.FuncDecl: - decls[i] = &ast.FuncDecl{ - Doc: decl.Doc, - Recv: decl.Recv, - Name: decl.Name, - Type: decl.Type, - Body: c.simplifyBlock(decl.Body), - } - } - } - - newFile := &ast.File{ - Doc: file.Doc, - Package: file.Package, - Name: file.Name, - Decls: decls, - Scope: file.Scope, - Imports: file.Imports, - Unresolved: file.Unresolved, - Comments: file.Comments, - } - c.info.Scopes[newFile] = c.info.Scopes[file] - return newFile -} - -func (c *simplifyContext) simplifyStmtList(stmts []ast.Stmt) []ast.Stmt { - var newStmts []ast.Stmt - for _, s := range stmts { - c.simplifyStmt(&newStmts, s) - } - return newStmts -} - -func (c *simplifyContext) simplifyGenDecl(stmts *[]ast.Stmt, decl *ast.GenDecl) *ast.GenDecl { - if decl.Tok != token.VAR { - return decl - } - - specs := make([]ast.Spec, len(decl.Specs)) - for j, spec := range decl.Specs { - switch spec := spec.(type) { - case *ast.ValueSpec: - var values []ast.Expr - if spec.Values != nil { - values = make([]ast.Expr, len(spec.Values)) - for i, v := range spec.Values { - v2 := c.simplifyExpr(stmts, v) - for _, initializer := range c.info.InitOrder { - if initializer.Rhs == v { - initializer.Rhs = v2 - } - } - values[i] = v2 - } - } - specs[j] = &ast.ValueSpec{ - Doc: spec.Doc, - Names: spec.Names, - Type: spec.Type, - Values: values, - Comment: spec.Comment, - } - default: - specs[j] = spec - } - } - - return &ast.GenDecl{ - Doc: decl.Doc, - TokPos: decl.TokPos, - Tok: token.VAR, - Lparen: decl.Lparen, - Specs: specs, - Rparen: decl.Rparen, - } -} - -func (c *simplifyContext) simplifyStmt(stmts *[]ast.Stmt, s ast.Stmt) { - if s == nil { - return - } - - switch s := s.(type) { - case *ast.ExprStmt: - *stmts = append(*stmts, &ast.ExprStmt{ - X: c.simplifyExpr2(stmts, s.X, true), - }) - - case *ast.BlockStmt: - *stmts = append(*stmts, c.simplifyBlock(s)) - - case *ast.LabeledStmt: - c.simplifyStmt(stmts, s.Stmt) - (*stmts)[len(*stmts)-1] = &ast.LabeledStmt{ - Label: s.Label, - Colon: s.Colon, - Stmt: (*stmts)[len(*stmts)-1], - } - - case *ast.AssignStmt: - lhs := make([]ast.Expr, len(s.Lhs)) - for i, x := range s.Lhs { - lhs[i] = c.simplifyExpr(stmts, x) - } - rhs := make([]ast.Expr, len(s.Rhs)) - for i, x := range s.Rhs { - rhs[i] = c.simplifyExpr2(stmts, x, true) - } - *stmts = append(*stmts, &ast.AssignStmt{ - Lhs: lhs, - Tok: s.Tok, - TokPos: s.TokPos, - Rhs: rhs, - }) - - case *ast.DeclStmt: - *stmts = append(*stmts, &ast.DeclStmt{ - Decl: c.simplifyGenDecl(stmts, s.Decl.(*ast.GenDecl)), - }) - - case *ast.IfStmt: - if s.Init != nil { - block := &ast.BlockStmt{} - *stmts = append(*stmts, block) - stmts = &block.List - c.simplifyStmt(stmts, s.Init) - } - newS := &ast.IfStmt{ - If: s.If, - Cond: c.simplifyExpr(stmts, s.Cond), - Body: c.simplifyBlock(s.Body), - Else: c.toElseBranch(c.simplifyToStmtList(s.Else), c.info.Scopes[s.Else]), - } - c.info.Scopes[newS] = c.info.Scopes[s] - *stmts = append(*stmts, newS) - - case *ast.SwitchStmt: - c.simplifySwitch(stmts, s) - - case *ast.TypeSwitchStmt: - if s.Init != nil { - block := &ast.BlockStmt{} - *stmts = append(*stmts, block) - stmts = &block.List - c.simplifyStmt(stmts, s.Init) - } - var assign ast.Stmt - switch a := s.Assign.(type) { - case *ast.ExprStmt: - ta := a.X.(*ast.TypeAssertExpr) - assign = &ast.ExprStmt{ - X: &ast.TypeAssertExpr{ - X: c.simplifyExpr(stmts, ta.X), - Lparen: ta.Lparen, - Type: ta.Type, - Rparen: ta.Rparen, - }, - } - case *ast.AssignStmt: - ta := a.Rhs[0].(*ast.TypeAssertExpr) - assign = &ast.AssignStmt{ - Lhs: a.Lhs, - Tok: a.Tok, - TokPos: a.TokPos, - Rhs: []ast.Expr{ - &ast.TypeAssertExpr{ - X: c.simplifyExpr(stmts, ta.X), - Lparen: ta.Lparen, - Type: ta.Type, - Rparen: ta.Rparen, - }, - }, - } - default: - panic("unexpected type switch assign") - } - clauses := make([]ast.Stmt, len(s.Body.List)) - for i, ccs := range s.Body.List { - cc := ccs.(*ast.CaseClause) - newClause := &ast.CaseClause{ - Case: cc.Case, - List: cc.List, - Colon: cc.Colon, - Body: c.simplifyStmtList(cc.Body), - } - if implicit, ok := c.info.Implicits[cc]; ok { - c.info.Implicits[newClause] = implicit - } - clauses[i] = newClause - } - newS := &ast.TypeSwitchStmt{ - Switch: s.Switch, - Assign: assign, - Body: &ast.BlockStmt{ - List: clauses, - }, - } - c.info.Scopes[newS] = c.info.Scopes[s] - *stmts = append(*stmts, newS) - - case *ast.ForStmt: - newS := &ast.ForStmt{ - For: s.For, - Init: s.Init, - Cond: s.Cond, - Post: s.Post, - Body: c.simplifyBlock(s.Body), - } - c.info.Scopes[newS] = c.info.Scopes[s] - *stmts = append(*stmts, newS) - - // case *ast.ForStmt: - // c.simplifyStmt(stmts, s.Init) - // var condStmts []ast.Stmt - // cond := c.newVar(&condStmts, s.Cond) - // bodyStmts := s.Body.List - // if len(condStmts) != 0 { - // bodyStmts = append(append(condStmts, &ast.IfStmt{ - // Cond: &ast.UnaryExpr{ - // Op: token.NOT, - // X: cond, - // }, - // Body: &ast.BlockStmt{ - // List: []ast.Stmt{&ast.BranchStmt{ - // Tok: token.BREAK, - // }}, - // }, - // }), bodyStmts...) - // cond = nil - // } - // *stmts = append(*stmts, &ast.ForStmt{ - // For: s.For, - // Cond: cond, - // Post: s.Post, - // Body: &ast.BlockStmt{ - // List: bodyStmts, - // }, - // }) - - case *ast.RangeStmt: - var newS ast.Stmt - switch t := c.info.TypeOf(s.X).Underlying().(type) { - case *types.Chan: - key := s.Key - tok := s.Tok - if key == nil { - key = ast.NewIdent("_") - tok = token.DEFINE - } - okVar := c.newIdent(types.Typ[types.Bool]) - if s.Tok == token.ASSIGN { - *stmts = append(*stmts, &ast.DeclStmt{ - Decl: &ast.GenDecl{ - Tok: token.VAR, - Specs: []ast.Spec{&ast.ValueSpec{ - Names: []*ast.Ident{okVar}, - Type: ast.NewIdent("bool"), - }}, - }, - }) - } - newS = &ast.ForStmt{ - For: s.For, - Body: &ast.BlockStmt{ - Lbrace: s.Body.Lbrace, - List: append([]ast.Stmt{ - &ast.AssignStmt{ - Lhs: []ast.Expr{key, okVar}, - TokPos: s.TokPos, - Tok: tok, - Rhs: []ast.Expr{c.setType(&ast.UnaryExpr{ - Op: token.ARROW, - X: c.newVar(stmts, s.X), - }, types.NewTuple( - types.NewVar(token.NoPos, nil, "", t.Elem()), - types.NewVar(token.NoPos, nil, "", types.Typ[types.Bool]), - ))}, - }, - &ast.IfStmt{ - Cond: c.setType(&ast.UnaryExpr{ - Op: token.NOT, - X: okVar, - }, types.Typ[types.Bool]), - Body: &ast.BlockStmt{ - List: []ast.Stmt{ - &ast.BranchStmt{Tok: token.BREAK}, - }, - }, - }, - }, c.simplifyStmtList(s.Body.List)...), - Rbrace: s.Body.Rbrace, - }, - } - - default: - newS = &ast.RangeStmt{ - For: s.For, - Key: s.Key, - Value: s.Value, - TokPos: s.TokPos, - Tok: s.Tok, - X: s.X, - Body: c.simplifyBlock(s.Body), - } - } - c.info.Scopes[newS] = c.info.Scopes[s] - *stmts = append(*stmts, newS) - - case *ast.IncDecStmt: - *stmts = append(*stmts, &ast.IncDecStmt{ - X: c.simplifyExpr(stmts, s.X), - TokPos: s.TokPos, - Tok: s.Tok, - }) - - case *ast.GoStmt: - *stmts = append(*stmts, &ast.GoStmt{ - Go: s.Go, - Call: c.simplifyCall(stmts, s.Call), - }) - - case *ast.SelectStmt: - clauses := make([]ast.Stmt, len(s.Body.List)) - for i, entry := range s.Body.List { - cc := entry.(*ast.CommClause) - var newComm ast.Stmt - var bodyPrefix []ast.Stmt - switch comm := cc.Comm.(type) { - case *ast.ExprStmt: - recv := comm.X.(*ast.UnaryExpr) - if recv.Op != token.ARROW { - panic("unexpected comm clause") - } - newComm = &ast.ExprStmt{ - X: &ast.UnaryExpr{ - Op: token.ARROW, - OpPos: recv.OpPos, - X: c.simplifyExpr(stmts, recv.X), - }, - } - case *ast.AssignStmt: - recv := comm.Rhs[0].(*ast.UnaryExpr) - if recv.Op != token.ARROW { - panic("unexpected comm clause") - } - simplifyLhs := false - for _, x := range comm.Lhs { - if c.simplifyCalls && ContainsCall(x) { - simplifyLhs = true - } - } - lhs := comm.Lhs - tok := comm.Tok - if simplifyLhs { - for i, x := range lhs { - id := c.newIdent(c.info.TypeOf(x)) - bodyPrefix = append(bodyPrefix, simpleAssign(c.simplifyExpr(&bodyPrefix, x), comm.Tok, id)) - lhs[i] = id - } - tok = token.DEFINE - } - newComm = &ast.AssignStmt{ - Lhs: lhs, - Tok: tok, - Rhs: []ast.Expr{c.simplifyExpr(stmts, recv)}, - } - case *ast.SendStmt: - newComm = &ast.SendStmt{ - Chan: c.simplifyExpr(stmts, comm.Chan), - Arrow: comm.Arrow, - Value: c.simplifyExpr(stmts, comm.Value), - } - case nil: - newComm = nil - default: - panic("unexpected comm clause") - } - newCC := &ast.CommClause{ - Case: cc.Case, - Comm: newComm, - Colon: cc.Colon, - Body: append(bodyPrefix, c.simplifyStmtList(cc.Body)...), - } - c.info.Scopes[newCC] = c.info.Scopes[cc] - clauses[i] = newCC - } - *stmts = append(*stmts, &ast.SelectStmt{ - Select: s.Select, - Body: &ast.BlockStmt{ - List: clauses, - }, - }) - - case *ast.DeferStmt: - *stmts = append(*stmts, &ast.DeferStmt{ - Defer: s.Defer, - Call: c.simplifyCall(stmts, s.Call), - }) - - case *ast.SendStmt: - *stmts = append(*stmts, &ast.SendStmt{ - Chan: c.simplifyExpr(stmts, s.Chan), - Arrow: s.Arrow, - Value: c.simplifyExpr(stmts, s.Value), - }) - - case *ast.ReturnStmt: - *stmts = append(*stmts, &ast.ReturnStmt{ - Return: s.Return, - Results: c.simplifyExprList(stmts, s.Results), - }) - - default: - *stmts = append(*stmts, s) - } -} - -func (c *simplifyContext) simplifyBlock(s *ast.BlockStmt) *ast.BlockStmt { - if s == nil { - return nil - } - newS := &ast.BlockStmt{ - Lbrace: s.Lbrace, - List: c.simplifyStmtList(s.List), - Rbrace: s.Rbrace, - } - c.info.Scopes[newS] = c.info.Scopes[s] - return newS -} - -func (c *simplifyContext) simplifySwitch(stmts *[]ast.Stmt, s *ast.SwitchStmt) { - wrapClause := &ast.CaseClause{} - newS := &ast.SwitchStmt{ - Switch: s.Switch, - Body: &ast.BlockStmt{List: []ast.Stmt{wrapClause}}, - } - c.info.Scopes[newS] = c.info.Scopes[s] - c.info.Scopes[wrapClause] = c.info.Scopes[s] - *stmts = append(*stmts, newS) - stmts = &wrapClause.Body - - c.simplifyStmt(stmts, s.Init) - - nonDefaultClauses, defaultClause := c.simplifyCaseClauses(s.Body.List) - tag := c.makeTag(stmts, s.Tag, len(nonDefaultClauses) != 0) - *stmts = append(*stmts, unwrapBlock(c.switchToIfElse(tag, nonDefaultClauses, defaultClause))...) -} - -func (c *simplifyContext) makeTag(stmts *[]ast.Stmt, tag ast.Expr, needsTag bool) ast.Expr { - if tag == nil { - id := ast.NewIdent("true") - c.info.Types[id] = types.TypeAndValue{Type: types.Typ[types.Bool], Value: constant.MakeBool(true)} - return id - } - if !needsTag { - *stmts = append(*stmts, simpleAssign(ast.NewIdent("_"), token.ASSIGN, tag)) - return nil - } - return c.newVar(stmts, tag) -} - -func (c *simplifyContext) simplifyCaseClauses(clauses []ast.Stmt) (nonDefaultClauses []*ast.CaseClause, defaultClause *ast.CaseClause) { - var openClauses []*ast.CaseClause - for _, cc := range clauses { - clause := cc.(*ast.CaseClause) - newClause := &ast.CaseClause{ - Case: clause.Case, - List: clause.List, - Colon: clause.Colon, - } - c.info.Scopes[newClause] = c.info.Scopes[clause] - - body := clause.Body - hasFallthrough := false - if len(body) != 0 { - if b, isBranchStmt := body[len(body)-1].(*ast.BranchStmt); isBranchStmt && b.Tok == token.FALLTHROUGH { - body = body[:len(body)-1] - hasFallthrough = true - } - } - openClauses = append(openClauses, newClause) - for _, openClause := range openClauses { - openClause.Body = append(openClause.Body, body...) - } - if !hasFallthrough { - openClauses = nil - } - - if len(clause.List) == 0 { - defaultClause = newClause - continue - } - nonDefaultClauses = append(nonDefaultClauses, newClause) - } - return -} - -func (c *simplifyContext) switchToIfElse(tag ast.Expr, nonDefaultClauses []*ast.CaseClause, defaultClause *ast.CaseClause) ast.Stmt { - if len(nonDefaultClauses) == 0 { - if defaultClause != nil { - return c.toElseBranch(c.simplifyStmtList(defaultClause.Body), c.info.Scopes[defaultClause]) - } - return nil - } - - clause := nonDefaultClauses[0] - conds := make([]ast.Expr, len(clause.List)) - for i, cond := range clause.List { - conds[i] = c.setType(&ast.BinaryExpr{ - X: tag, - Op: token.EQL, - Y: c.setType(&ast.ParenExpr{X: cond}, c.info.TypeOf(cond)), - }, types.Typ[types.Bool]) - } - - var stmts []ast.Stmt - ifStmt := &ast.IfStmt{ - If: clause.Case, - Cond: c.simplifyExpr(&stmts, c.disjunction(conds)), - Body: &ast.BlockStmt{List: c.simplifyStmtList(clause.Body)}, - Else: c.switchToIfElse(tag, nonDefaultClauses[1:], defaultClause), - } - c.info.Scopes[ifStmt] = c.info.Scopes[clause] - stmts = append(stmts, ifStmt) - return c.toElseBranch(stmts, c.info.Scopes[clause]) -} - -func (c *simplifyContext) disjunction(conds []ast.Expr) ast.Expr { - if len(conds) == 1 { - return conds[0] - } - return c.setType(&ast.BinaryExpr{ - X: conds[0], - Op: token.LOR, - Y: c.disjunction(conds[1:]), - }, types.Typ[types.Bool]) -} - -func (c *simplifyContext) simplifyToStmtList(s ast.Stmt) (stmts []ast.Stmt) { - c.simplifyStmt(&stmts, s) - return -} - -func (c *simplifyContext) toElseBranch(stmts []ast.Stmt, scope *types.Scope) ast.Stmt { - if len(stmts) == 0 { - return nil - } - if len(stmts) == 1 { - switch stmt := stmts[0].(type) { - case *ast.IfStmt, *ast.BlockStmt: - c.info.Scopes[stmt] = scope - return stmt - } - } - block := &ast.BlockStmt{ - List: stmts, - } - c.info.Scopes[block] = scope - return block -} - -func unwrapBlock(s ast.Stmt) []ast.Stmt { - if s == nil { - return nil - } - if block, ok := s.(*ast.BlockStmt); ok { - return block.List - } - return []ast.Stmt{s} -} - -func (c *simplifyContext) simplifyExpr(stmts *[]ast.Stmt, x ast.Expr) ast.Expr { - return c.simplifyExpr2(stmts, x, false) -} - -func (c *simplifyContext) simplifyExpr2(stmts *[]ast.Stmt, x ast.Expr, callOK bool) ast.Expr { - x2 := c.simplifyExpr3(stmts, x, callOK) - if t, ok := c.info.Types[x]; ok { - c.info.Types[x2] = t - } - return x2 -} - -func (c *simplifyContext) simplifyExpr3(stmts *[]ast.Stmt, x ast.Expr, callOK bool) ast.Expr { - switch x := x.(type) { - case *ast.FuncLit: - return &ast.FuncLit{ - Type: x.Type, - Body: &ast.BlockStmt{ - List: c.simplifyStmtList(x.Body.List), - }, - } - - case *ast.CompositeLit: - elts := make([]ast.Expr, len(x.Elts)) - for i, elt := range x.Elts { - if kv, ok := elt.(*ast.KeyValueExpr); ok { - elts[i] = &ast.KeyValueExpr{ - Key: kv.Key, - Colon: kv.Colon, - Value: c.simplifyExpr(stmts, kv.Value), - } - continue - } - elts[i] = c.simplifyExpr(stmts, elt) - } - return &ast.CompositeLit{ - Type: x.Type, - Lbrace: x.Lbrace, - Elts: elts, - Rbrace: x.Rbrace, - } - - case *ast.ParenExpr: - return &ast.ParenExpr{ - Lparen: x.Lparen, - X: c.simplifyExpr(stmts, x.X), - Rparen: x.Rparen, - } - - case *ast.SelectorExpr: - selExpr := &ast.SelectorExpr{ - X: c.simplifyExpr(stmts, x.X), - Sel: x.Sel, - } - if sel, ok := c.info.Selections[x]; ok { - c.info.Selections[selExpr] = sel - } - return selExpr - - case *ast.IndexExpr: - return &ast.IndexExpr{ - X: c.simplifyExpr(stmts, x.X), - Lbrack: x.Lbrack, - Index: c.simplifyExpr(stmts, x.Index), - Rbrack: x.Rbrack, - } - - case *ast.SliceExpr: - return &ast.SliceExpr{ - X: c.simplifyExpr(stmts, x.X), - Lbrack: x.Lbrack, - Low: c.simplifyExpr(stmts, x.Low), - High: c.simplifyExpr(stmts, x.High), - Max: c.simplifyExpr(stmts, x.Max), - Slice3: x.Slice3, - Rbrack: x.Rbrack, - } - - case *ast.TypeAssertExpr: - return &ast.TypeAssertExpr{ - X: c.simplifyExpr(stmts, x.X), - Lparen: x.Lparen, - Type: x.Type, - Rparen: x.Rparen, - } - - case *ast.CallExpr: - call := c.simplifyCall(stmts, x) - if callOK || !c.simplifyCalls { - return call - } - return c.newVar(stmts, call) - - case *ast.StarExpr: - return &ast.StarExpr{ - Star: x.Star, - X: c.simplifyExpr(stmts, x.X), - } - - case *ast.UnaryExpr: - return &ast.UnaryExpr{ - OpPos: x.OpPos, - Op: x.Op, - X: c.simplifyExpr(stmts, x.X), - } - - case *ast.BinaryExpr: - if (x.Op == token.LAND || x.Op == token.LOR) && c.simplifyCalls && ContainsCall(x.Y) { - v := c.newVar(stmts, x.X) - cond := v - if x.Op == token.LOR { - cond = &ast.UnaryExpr{ - Op: token.NOT, - X: cond, - } - } - var ifBody []ast.Stmt - ifBody = append(ifBody, simpleAssign(v, token.ASSIGN, c.simplifyExpr2(&ifBody, x.Y, true))) - *stmts = append(*stmts, &ast.IfStmt{ - Cond: cond, - Body: &ast.BlockStmt{ - List: ifBody, - }, - }) - return v - } - return &ast.BinaryExpr{ - X: c.simplifyExpr(stmts, x.X), - OpPos: x.OpPos, - Op: x.Op, - Y: c.simplifyExpr(stmts, x.Y), - } - - default: - return x - } -} - -func (c *simplifyContext) simplifyCall(stmts *[]ast.Stmt, x *ast.CallExpr) *ast.CallExpr { - return &ast.CallExpr{ - Fun: c.simplifyExpr(stmts, x.Fun), - Lparen: x.Lparen, - Args: c.simplifyArgs(stmts, x.Args), - Ellipsis: x.Ellipsis, - Rparen: x.Rparen, - } -} - -func (c *simplifyContext) simplifyArgs(stmts *[]ast.Stmt, args []ast.Expr) []ast.Expr { - if len(args) == 1 { - if tuple, ok := c.info.TypeOf(args[0]).(*types.Tuple); ok && c.simplifyCalls { - call := c.simplifyExpr2(stmts, args[0], true) - vars := make([]ast.Expr, tuple.Len()) - for i := range vars { - vars[i] = c.newIdent(tuple.At(i).Type()) - } - *stmts = append(*stmts, &ast.AssignStmt{ - Lhs: vars, - Tok: token.DEFINE, - Rhs: []ast.Expr{call}, - }) - return vars - } - } - return c.simplifyExprList(stmts, args) -} - -func (c *simplifyContext) simplifyExprList(stmts *[]ast.Stmt, exprs []ast.Expr) []ast.Expr { - if exprs == nil { - return nil - } - simplifiedExprs := make([]ast.Expr, len(exprs)) - for i, expr := range exprs { - simplifiedExprs[i] = c.simplifyExpr(stmts, expr) - } - return simplifiedExprs -} - -func (c *simplifyContext) newVar(stmts *[]ast.Stmt, x ast.Expr) ast.Expr { - id := c.newIdent(c.info.TypeOf(x)) - *stmts = append(*stmts, simpleAssign(id, token.DEFINE, x)) - return id -} - -func (c *simplifyContext) newIdent(t types.Type) *ast.Ident { - c.varCounter++ - id := ast.NewIdent(fmt.Sprintf("_%d", c.varCounter)) - c.info.Types[id] = types.TypeAndValue{Type: t} // TODO remove? - c.info.Uses[id] = types.NewVar(token.NoPos, nil, id.Name, t) - return id -} - -func (c *simplifyContext) setType(x ast.Expr, t types.Type) ast.Expr { - c.info.Types[x] = types.TypeAndValue{Type: t} - return x -} - -func simpleAssign(lhs ast.Expr, tok token.Token, rhs ast.Expr) *ast.AssignStmt { - return &ast.AssignStmt{ - Lhs: []ast.Expr{lhs}, - Tok: tok, - Rhs: []ast.Expr{rhs}, - } -} - -func ContainsCall(x ast.Expr) bool { - switch x := x.(type) { - case *ast.CallExpr: - return true - case *ast.CompositeLit: - for _, elt := range x.Elts { - if ContainsCall(elt) { - return true - } - } - return false - case *ast.KeyValueExpr: - return ContainsCall(x.Key) || ContainsCall(x.Value) - case *ast.ParenExpr: - return ContainsCall(x.X) - case *ast.SelectorExpr: - return ContainsCall(x.X) - case *ast.IndexExpr: - return ContainsCall(x.X) || ContainsCall(x.Index) - case *ast.SliceExpr: - return ContainsCall(x.X) || ContainsCall(x.Low) || ContainsCall(x.High) || ContainsCall(x.Max) - case *ast.TypeAssertExpr: - return ContainsCall(x.X) - case *ast.StarExpr: - return ContainsCall(x.X) - case *ast.UnaryExpr: - return ContainsCall(x.X) - case *ast.BinaryExpr: - return ContainsCall(x.X) || ContainsCall(x.Y) - default: - return false - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/vendor/vendor.json b/vendor/github.com/gopherjs/gopherjs/compiler/vendor/vendor.json deleted file mode 100644 index e9add8eb3..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/vendor/vendor.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "comment": "", - "ignore": "test", - "package": [ - { - "checksumSHA1": "CaUaJLLnql96d2JGRgCpYsKomxw=", - "path": "github.com/neelance/astrewrite", - "revision": "99348263ae862cc230986ce88deaddbf7edcc034", - "revisionTime": "2016-05-11T09:36:45Z" - } - ], - "rootPath": "github.com/gopherjs/gopherjs/compiler" -} diff --git a/vendor/github.com/gopherjs/gopherjs/compiler/version_check.go b/vendor/github.com/gopherjs/gopherjs/compiler/version_check.go deleted file mode 100644 index 66c9cf322..000000000 --- a/vendor/github.com/gopherjs/gopherjs/compiler/version_check.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build !go1.9 -// +build go1.8 - -package compiler - -const ___GOPHERJS_REQUIRES_GO_VERSION_1_8___ = true - -// Version is the GopherJS compiler version string. -const Version = "1.8-2" diff --git a/vendor/github.com/gopherjs/gopherjs/doc/packages.md b/vendor/github.com/gopherjs/gopherjs/doc/packages.md deleted file mode 100644 index 750d64636..000000000 --- a/vendor/github.com/gopherjs/gopherjs/doc/packages.md +++ /dev/null @@ -1,155 +0,0 @@ -# Supported Packages - -On each commit, Circle CI automatically compiles all supported packages with GopherJS and runs their tests: - -[![Circle CI](https://circleci.com/gh/gopherjs/gopherjs.svg?style=svg)](https://circleci.com/gh/gopherjs/gopherjs) - -Name | Supported | Comment ------------------- | ------------ | ---------------------------------------------------------------------------------- -archive | | --- tar | ✅ yes | --- zip | ✅ yes | -bufio | ✅ yes | -builtin | ✅ yes | -bytes | ✅ yes | -compress | | --- bzip2 | ✅ yes | --- flate | ✅ yes | --- gzip | ✅ yes | --- lzw | ✅ yes | --- zlib | ✅ yes | -container | | --- heap | ✅ yes | --- list | ✅ yes | --- ring | ✅ yes | -crypto | | --- aes | ✅ yes | --- cipher | ✅ yes | --- des | ✅ yes | --- dsa | ✅ yes | --- ecdsa | ✅ yes | --- elliptic | ✅ yes | --- hmac | ✅ yes | --- md5 | ✅ yes | --- rand | ✅ yes | --- rc4 | ✅ yes | --- rsa | ✅ yes | --- sha1 | ✅ yes | --- sha256 | ✅ yes | --- sha512 | ✅ yes | --- subtle | ✅ yes | --- tls | ❌ no | --- x509 | ✅ yes | --- -- pkix | ✅ yes | -database | | --- sql | ✅ yes | --- -- driver | ✅ yes | -debug | | --- dwarf | ✅ yes | --- elf | ✅ yes | --- gosym | ☑️ partially | on binaries generated by gc --- macho | ✅ yes | --- pe | ✅ yes | -encoding | | --- ascii85 | ✅ yes | --- asn1 | ✅ yes | --- base32 | ✅ yes | --- base64 | ✅ yes | --- binary | ✅ yes | --- csv | ✅ yes | --- gob | ✅ yes | --- hex | ✅ yes | --- json | ✅ yes | --- pem | ✅ yes | --- xml | ✅ yes | -errors | ✅ yes | -expvar | ✅ yes | -flag | ✅ yes | -fmt | ✅ yes | -go | | --- ast | ✅ yes | --- build | ❌ no | --- constant | ✅ yes | --- doc | ✅ yes | --- format | ✅ yes | --- importer | ❌ no | --- parser | ✅ yes | --- printer | ✅ yes | --- scanner | ✅ yes | --- token | ✅ yes | --- types | ❌ no | -hash | | --- adler32 | ✅ yes | --- crc32 | ✅ yes | --- crc64 | ✅ yes | --- fnv | ✅ yes | -html | ✅ yes | --- template | ✅ yes | -image | ✅ yes | --- color | ✅ yes | --- -- palette | ✅ yes | --- draw | ✅ yes | --- gif | ✅ yes | --- jpeg | ✅ yes | --- png | ✅ yes | -index | | --- suffixarray | ✅ yes | -io | ✅ yes | --- ioutil | ✅ yes | -log | ✅ yes | --- syslog | ❌ no | -math | ✅ yes | --- big | ✅ yes | --- cmplx | ✅ yes | --- rand | ✅ yes | -mime | ✅ yes | --- multipart | ✅ yes | --- quotedprintable | ✅ yes | -net | ❌ no | --- http | ☑️ partially | client only, emulated via Fetch/XMLHttpRequest APIs;
node.js requires polyfill --- -- cgi | ❌ no | --- -- cookiejar | ✅ yes | --- -- fcgi | ✅ yes | --- -- httptest | ☑️ partially | --- -- httputil | ☑️ partially | --- -- pprof | ❌ no | --- mail | ✅ yes | --- rpc | ☑️ partially | data structures only (no net) --- -- jsonrpc | ✅ yes | --- smtp | ☑️ partially | data structures only (no net) --- textproto | ✅ yes | --- url | ✅ yes | -os | ☑️ partially | node.js only --- exec | ☑️ partially | node.js only --- signal | ☑️ partially | node.js only --- user | ☑️ partially | node.js only -path | ✅ yes | --- filepath | ✅ yes | -reflect | ✅ yes | except StructOf (pending) -regexp | ✅ yes | --- syntax | ✅ yes | -runtime | ☑️ partially | SetMutexProfileFraction, SetFinalizer unsupported --- cgo | ❌ no | --- debug | ❌ no | --- pprof | ❌ no | --- race | ❌ no | --- trace | ❌ no | -sort | ✅ yes | -strconv | ✅ yes | -strings | ✅ yes | -sync | ✅ yes | --- atomic | ✅ yes | -syscall | ☑️ partially | node.js only -testing | ✅ yes | --- iotest | ✅ yes | --- quick | ✅ yes | -text | | --- scanner | ✅ yes | --- tabwriter | ✅ yes | --- template | ✅ yes | --- -- parse | ✅ yes | -time | ✅ yes | UTC and Local only (see [issue](https://github.com/gopherjs/gopherjs/issues/64)) -unicode | ✅ yes | --- utf16 | ✅ yes | --- utf8 | ✅ yes | -unsafe | ❌ no | diff --git a/vendor/github.com/gopherjs/gopherjs/doc/syscalls.md b/vendor/github.com/gopherjs/gopherjs/doc/syscalls.md deleted file mode 100644 index 2ac55d314..000000000 --- a/vendor/github.com/gopherjs/gopherjs/doc/syscalls.md +++ /dev/null @@ -1,33 +0,0 @@ -System Calls ------------- - -System calls are the bridge between your application and your operating system. They are used whenever you access something outside of your application's memory, for example when you write to the console, when you read or write files or when you access the network. In Go, system calls are mostly used by the `os` package, hence the name. When using GopherJS you need to consider if system calls are available or not. - -### Output redirection to console - -If system calls are not available in your environment (see below), then a special redirection of `os.Stdout` and `os.Stderr` is applied. It buffers a line until it is terminated by a line break and then prints it via JavaScript's `console.log` to your browser's JavaScript console or your system console. That way, `fmt.Println` etc. work as expected, even if system calls are not available. - -### In Browser - -The JavaScript environment of a web browser is completely isolated from your operating system to protect your machine. You don't want any web page to read or write files on your disk without your consent. That is why system calls are not and will never be available when running your code in a web browser. - -### Node.js on Windows - -When running your code with Node.js on Windows, it is theoretically possible to use system calls. To do so, you would need a special Node.js module that provides direct access to system calls. However, since the interface is quite different from the one used on OS X and Linux, the system calls module included in GopherJS currently does not support Windows. Sorry. Get in contact if you feel like you want to change this situation. - -### Node.js on OS X and Linux - -GopherJS has support for system calls on OS X and Linux. Before running your code with Node.js, you need to install the system calls module. The module is compatible with Node.js version 0.12 and above. If you want to use an older version you can opt to not install the module, but then system calls are not available. - -Compile and install the module with: -``` -cd $GOPATH/src/github.com/gopherjs/gopherjs/node-syscall/ -npm install --global node-gyp -node-gyp rebuild -mkdir -p ~/.node_libraries/ -cp build/Release/syscall.node ~/.node_libraries/syscall.node -``` - -### Caveats - -Note that even with syscalls enabled in Node.js, some programs may not behave as expected due to the fact that the current implementation blocks other goroutines during a syscall, which can lead to a deadlock in some situations. This is not considered a bug, as it is considered sufficient for most test cases (which is all Node.js should be used for). Get in contact if you feel like you want to change this situation. diff --git a/vendor/github.com/gopherjs/gopherjs/js/js.go b/vendor/github.com/gopherjs/gopherjs/js/js.go deleted file mode 100644 index 3fbf1d88c..000000000 --- a/vendor/github.com/gopherjs/gopherjs/js/js.go +++ /dev/null @@ -1,168 +0,0 @@ -// Package js provides functions for interacting with native JavaScript APIs. Calls to these functions are treated specially by GopherJS and translated directly to their corresponding JavaScript syntax. -// -// Use MakeWrapper to expose methods to JavaScript. When passing values directly, the following type conversions are performed: -// -// | Go type | JavaScript type | Conversions back to interface{} | -// | --------------------- | --------------------- | ------------------------------- | -// | bool | Boolean | bool | -// | integers and floats | Number | float64 | -// | string | String | string | -// | []int8 | Int8Array | []int8 | -// | []int16 | Int16Array | []int16 | -// | []int32, []int | Int32Array | []int | -// | []uint8 | Uint8Array | []uint8 | -// | []uint16 | Uint16Array | []uint16 | -// | []uint32, []uint | Uint32Array | []uint | -// | []float32 | Float32Array | []float32 | -// | []float64 | Float64Array | []float64 | -// | all other slices | Array | []interface{} | -// | arrays | see slice type | see slice type | -// | functions | Function | func(...interface{}) *js.Object | -// | time.Time | Date | time.Time | -// | - | instanceof Node | *js.Object | -// | maps, structs | instanceof Object | map[string]interface{} | -// -// Additionally, for a struct containing a *js.Object field, only the content of the field will be passed to JavaScript and vice versa. -package js - -// Object is a container for a native JavaScript object. Calls to its methods are treated specially by GopherJS and translated directly to their JavaScript syntax. A nil pointer to Object is equal to JavaScript's "null". Object can not be used as a map key. -type Object struct{ object *Object } - -// Get returns the object's property with the given key. -func (o *Object) Get(key string) *Object { return o.object.Get(key) } - -// Set assigns the value to the object's property with the given key. -func (o *Object) Set(key string, value interface{}) { o.object.Set(key, value) } - -// Delete removes the object's property with the given key. -func (o *Object) Delete(key string) { o.object.Delete(key) } - -// Length returns the object's "length" property, converted to int. -func (o *Object) Length() int { return o.object.Length() } - -// Index returns the i'th element of an array. -func (o *Object) Index(i int) *Object { return o.object.Index(i) } - -// SetIndex sets the i'th element of an array. -func (o *Object) SetIndex(i int, value interface{}) { o.object.SetIndex(i, value) } - -// Call calls the object's method with the given name. -func (o *Object) Call(name string, args ...interface{}) *Object { return o.object.Call(name, args...) } - -// Invoke calls the object itself. This will fail if it is not a function. -func (o *Object) Invoke(args ...interface{}) *Object { return o.object.Invoke(args...) } - -// New creates a new instance of this type object. This will fail if it not a function (constructor). -func (o *Object) New(args ...interface{}) *Object { return o.object.New(args...) } - -// Bool returns the object converted to bool according to JavaScript type conversions. -func (o *Object) Bool() bool { return o.object.Bool() } - -// String returns the object converted to string according to JavaScript type conversions. -func (o *Object) String() string { return o.object.String() } - -// Int returns the object converted to int according to JavaScript type conversions (parseInt). -func (o *Object) Int() int { return o.object.Int() } - -// Int64 returns the object converted to int64 according to JavaScript type conversions (parseInt). -func (o *Object) Int64() int64 { return o.object.Int64() } - -// Uint64 returns the object converted to uint64 according to JavaScript type conversions (parseInt). -func (o *Object) Uint64() uint64 { return o.object.Uint64() } - -// Float returns the object converted to float64 according to JavaScript type conversions (parseFloat). -func (o *Object) Float() float64 { return o.object.Float() } - -// Interface returns the object converted to interface{}. See table in package comment for details. -func (o *Object) Interface() interface{} { return o.object.Interface() } - -// Unsafe returns the object as an uintptr, which can be converted via unsafe.Pointer. Not intended for public use. -func (o *Object) Unsafe() uintptr { return o.object.Unsafe() } - -// Error encapsulates JavaScript errors. Those are turned into a Go panic and may be recovered, giving an *Error that holds the JavaScript error object. -type Error struct { - *Object -} - -// Error returns the message of the encapsulated JavaScript error object. -func (err *Error) Error() string { - return "JavaScript error: " + err.Get("message").String() -} - -// Stack returns the stack property of the encapsulated JavaScript error object. -func (err *Error) Stack() string { - return err.Get("stack").String() -} - -// Global gives JavaScript's global object ("window" for browsers and "GLOBAL" for Node.js). -var Global *Object - -// Module gives the value of the "module" variable set by Node.js. Hint: Set a module export with 'js.Module.Get("exports").Set("exportName", ...)'. -var Module *Object - -// Undefined gives the JavaScript value "undefined". -var Undefined *Object - -// Debugger gets compiled to JavaScript's "debugger;" statement. -func Debugger() {} - -// InternalObject returns the internal JavaScript object that represents i. Not intended for public use. -func InternalObject(i interface{}) *Object { - return nil -} - -// MakeFunc wraps a function and gives access to the values of JavaScript's "this" and "arguments" keywords. -func MakeFunc(fn func(this *Object, arguments []*Object) interface{}) *Object { - return Global.Call("$makeFunc", InternalObject(fn)) -} - -// Keys returns the keys of the given JavaScript object. -func Keys(o *Object) []string { - if o == nil || o == Undefined { - return nil - } - a := Global.Get("Object").Call("keys", o) - s := make([]string, a.Length()) - for i := 0; i < a.Length(); i++ { - s[i] = a.Index(i).String() - } - return s -} - -// MakeWrapper creates a JavaScript object which has wrappers for the exported methods of i. Use explicit getter and setter methods to expose struct fields to JavaScript. -func MakeWrapper(i interface{}) *Object { - v := InternalObject(i) - o := Global.Get("Object").New() - o.Set("__internal_object__", v) - methods := v.Get("constructor").Get("methods") - for i := 0; i < methods.Length(); i++ { - m := methods.Index(i) - if m.Get("pkg").String() != "" { // not exported - continue - } - o.Set(m.Get("name").String(), func(args ...*Object) *Object { - return Global.Call("$externalizeFunction", v.Get(m.Get("prop").String()), m.Get("typ"), true).Call("apply", v, args) - }) - } - return o -} - -// NewArrayBuffer creates a JavaScript ArrayBuffer from a byte slice. -func NewArrayBuffer(b []byte) *Object { - slice := InternalObject(b) - offset := slice.Get("$offset").Int() - length := slice.Get("$length").Int() - return slice.Get("$array").Get("buffer").Call("slice", offset, offset+length) -} - -// M is a simple map type. It is intended as a shorthand for JavaScript objects (before conversion). -type M map[string]interface{} - -// S is a simple slice type. It is intended as a shorthand for JavaScript arrays (before conversion). -type S []interface{} - -func init() { - // avoid dead code elimination - e := Error{} - _ = e -} diff --git a/vendor/github.com/gopherjs/gopherjs/js/js_test.go b/vendor/github.com/gopherjs/gopherjs/js/js_test.go deleted file mode 100644 index f96cac143..000000000 --- a/vendor/github.com/gopherjs/gopherjs/js/js_test.go +++ /dev/null @@ -1,573 +0,0 @@ -// +build js - -package js_test - -import ( - "fmt" - "reflect" - "strings" - "testing" - "time" - - "github.com/gopherjs/gopherjs/js" -) - -var dummys = js.Global.Call("eval", `({ - someBool: true, - someString: "abc\u1234", - someInt: 42, - someFloat: 42.123, - someArray: [41, 42, 43], - add: function(a, b) { - return a + b; - }, - mapArray: function(array, f) { - var newArray = new Array(array.length); - for (var i = 0; i < array.length; i++) { - newArray[i] = f(array[i]); - } - return newArray; - }, - toUnixTimestamp: function(d) { - return d.getTime() / 1000; - }, - testField: function(o) { - return o.Field; - }, - testMethod: function(o) { - return o.Method(42); - }, - isEqual: function(a, b) { - return a === b; - }, - call: function(f, a) { - f(a); - }, - return: function(x) { - return x; - }, -})`) - -func TestBool(t *testing.T) { - e := true - o := dummys.Get("someBool") - if v := o.Bool(); v != e { - t.Errorf("expected %#v, got %#v", e, v) - } - if i := o.Interface().(bool); i != e { - t.Errorf("expected %#v, got %#v", e, i) - } - if dummys.Set("otherBool", e); dummys.Get("otherBool").Bool() != e { - t.Fail() - } -} - -func TestStr(t *testing.T) { - e := "abc\u1234" - o := dummys.Get("someString") - if v := o.String(); v != e { - t.Errorf("expected %#v, got %#v", e, v) - } - if i := o.Interface().(string); i != e { - t.Errorf("expected %#v, got %#v", e, i) - } - if dummys.Set("otherString", e); dummys.Get("otherString").String() != e { - t.Fail() - } -} - -func TestInt(t *testing.T) { - e := 42 - o := dummys.Get("someInt") - if v := o.Int(); v != e { - t.Errorf("expected %#v, got %#v", e, v) - } - if i := int(o.Interface().(float64)); i != e { - t.Errorf("expected %#v, got %#v", e, i) - } - if dummys.Set("otherInt", e); dummys.Get("otherInt").Int() != e { - t.Fail() - } -} - -func TestFloat(t *testing.T) { - e := 42.123 - o := dummys.Get("someFloat") - if v := o.Float(); v != e { - t.Errorf("expected %#v, got %#v", e, v) - } - if i := o.Interface().(float64); i != e { - t.Errorf("expected %#v, got %#v", e, i) - } - if dummys.Set("otherFloat", e); dummys.Get("otherFloat").Float() != e { - t.Fail() - } -} - -func TestUndefined(t *testing.T) { - if dummys == js.Undefined || dummys.Get("xyz") != js.Undefined { - t.Fail() - } -} - -func TestNull(t *testing.T) { - var null *js.Object - dummys.Set("test", nil) - if null != nil || dummys == nil || dummys.Get("test") != nil { - t.Fail() - } -} - -func TestLength(t *testing.T) { - if dummys.Get("someArray").Length() != 3 { - t.Fail() - } -} - -func TestIndex(t *testing.T) { - if dummys.Get("someArray").Index(1).Int() != 42 { - t.Fail() - } -} - -func TestSetIndex(t *testing.T) { - dummys.Get("someArray").SetIndex(2, 99) - if dummys.Get("someArray").Index(2).Int() != 99 { - t.Fail() - } -} - -func TestCall(t *testing.T) { - var i int64 = 40 - if dummys.Call("add", i, 2).Int() != 42 { - t.Fail() - } - if dummys.Call("add", js.Global.Call("eval", "40"), 2).Int() != 42 { - t.Fail() - } -} - -func TestInvoke(t *testing.T) { - var i int64 = 40 - if dummys.Get("add").Invoke(i, 2).Int() != 42 { - t.Fail() - } -} - -func TestNew(t *testing.T) { - if js.Global.Get("Array").New(42).Length() != 42 { - t.Fail() - } -} - -type StructWithJsField1 struct { - *js.Object - Length int `js:"length"` - Slice func(int, int) []int `js:"slice"` -} - -type StructWithJsField2 struct { - object *js.Object // to hide members from public API - Length int `js:"length"` - Slice func(int, int) []int `js:"slice"` -} - -type Wrapper1 struct { - StructWithJsField1 - WrapperLength int `js:"length"` -} - -type Wrapper2 struct { - innerStruct *StructWithJsField2 - WrapperLength int `js:"length"` -} - -func TestReadingJsField(t *testing.T) { - a := StructWithJsField1{Object: js.Global.Get("Array").New(42)} - b := &StructWithJsField2{object: js.Global.Get("Array").New(42)} - wa := Wrapper1{StructWithJsField1: a} - wb := Wrapper2{innerStruct: b} - if a.Length != 42 || b.Length != 42 || wa.Length != 42 || wa.WrapperLength != 42 || wb.WrapperLength != 42 { - t.Fail() - } -} - -func TestWritingJsField(t *testing.T) { - a := StructWithJsField1{Object: js.Global.Get("Object").New()} - b := &StructWithJsField2{object: js.Global.Get("Object").New()} - a.Length = 42 - b.Length = 42 - if a.Get("length").Int() != 42 || b.object.Get("length").Int() != 42 { - t.Fail() - } -} - -func TestCallingJsField(t *testing.T) { - a := &StructWithJsField1{Object: js.Global.Get("Array").New(100)} - b := &StructWithJsField2{object: js.Global.Get("Array").New(100)} - a.SetIndex(3, 123) - b.object.SetIndex(3, 123) - f := a.Slice - a2 := a.Slice(2, 44) - b2 := b.Slice(2, 44) - c2 := f(2, 44) - if len(a2) != 42 || len(b2) != 42 || len(c2) != 42 || a2[1] != 123 || b2[1] != 123 || c2[1] != 123 { - t.Fail() - } -} - -func TestReflectionOnJsField(t *testing.T) { - a := StructWithJsField1{Object: js.Global.Get("Array").New(42)} - wa := Wrapper1{StructWithJsField1: a} - if reflect.ValueOf(a).FieldByName("Length").Int() != 42 || reflect.ValueOf(&wa).Elem().FieldByName("WrapperLength").Int() != 42 { - t.Fail() - } - reflect.ValueOf(&wa).Elem().FieldByName("WrapperLength").Set(reflect.ValueOf(10)) - if a.Length != 10 { - t.Fail() - } -} - -func TestUnboxing(t *testing.T) { - a := StructWithJsField1{Object: js.Global.Get("Object").New()} - b := &StructWithJsField2{object: js.Global.Get("Object").New()} - if !dummys.Call("isEqual", a, a.Object).Bool() || !dummys.Call("isEqual", b, b.object).Bool() { - t.Fail() - } - wa := Wrapper1{StructWithJsField1: a} - wb := Wrapper2{innerStruct: b} - if !dummys.Call("isEqual", wa, a.Object).Bool() || !dummys.Call("isEqual", wb, b.object).Bool() { - t.Fail() - } -} - -func TestBoxing(t *testing.T) { - o := js.Global.Get("Object").New() - dummys.Call("call", func(a StructWithJsField1) { - if a.Object != o { - t.Fail() - } - }, o) - dummys.Call("call", func(a *StructWithJsField2) { - if a.object != o { - t.Fail() - } - }, o) - dummys.Call("call", func(a Wrapper1) { - if a.Object != o { - t.Fail() - } - }, o) - dummys.Call("call", func(a Wrapper2) { - if a.innerStruct.object != o { - t.Fail() - } - }, o) -} - -func TestFunc(t *testing.T) { - a := dummys.Call("mapArray", []int{1, 2, 3}, func(e int64) int64 { return e + 40 }) - b := dummys.Call("mapArray", []int{1, 2, 3}, func(e ...int64) int64 { return e[0] + 40 }) - if a.Index(1).Int() != 42 || b.Index(1).Int() != 42 { - t.Fail() - } - - add := dummys.Get("add").Interface().(func(...interface{}) *js.Object) - var i int64 = 40 - if add(i, 2).Int() != 42 { - t.Fail() - } -} - -func TestDate(t *testing.T) { - d := time.Date(2013, time.August, 27, 22, 25, 11, 0, time.UTC) - if dummys.Call("toUnixTimestamp", d).Int() != int(d.Unix()) { - t.Fail() - } - - d2 := js.Global.Get("Date").New(d.UnixNano() / 1000000).Interface().(time.Time) - if !d2.Equal(d) { - t.Fail() - } -} - -// https://github.com/gopherjs/gopherjs/issues/287 -func TestInternalizeDate(t *testing.T) { - var a = time.Unix(0, (123 * time.Millisecond).Nanoseconds()) - var b time.Time - js.Global.Set("internalizeDate", func(t time.Time) { b = t }) - js.Global.Call("eval", "(internalizeDate(new Date(123)))") - if a != b { - t.Fail() - } -} - -func TestEquality(t *testing.T) { - if js.Global.Get("Array") != js.Global.Get("Array") || js.Global.Get("Array") == js.Global.Get("String") { - t.Fail() - } - type S struct{ *js.Object } - o1 := js.Global.Get("Object").New() - o2 := js.Global.Get("Object").New() - a := S{o1} - b := S{o1} - c := S{o2} - if a != b || a == c { - t.Fail() - } -} - -func TestUndefinedEquality(t *testing.T) { - var ui interface{} = js.Undefined - if ui != js.Undefined { - t.Fail() - } -} - -func TestInterfaceEquality(t *testing.T) { - o := js.Global.Get("Object").New() - var i interface{} = o - if i != o { - t.Fail() - } -} - -func TestUndefinedInternalization(t *testing.T) { - undefinedEqualsJsUndefined := func(i interface{}) bool { - return i == js.Undefined - } - js.Global.Set("undefinedEqualsJsUndefined", undefinedEqualsJsUndefined) - if !js.Global.Call("eval", "(undefinedEqualsJsUndefined(undefined))").Bool() { - t.Fail() - } -} - -func TestSameFuncWrapper(t *testing.T) { - a := func(_ string) {} // string argument to force wrapping - b := func(_ string) {} // string argument to force wrapping - if !dummys.Call("isEqual", a, a).Bool() || dummys.Call("isEqual", a, b).Bool() { - t.Fail() - } - if !dummys.Call("isEqual", somePackageFunction, somePackageFunction).Bool() { - t.Fail() - } - if !dummys.Call("isEqual", (*T).someMethod, (*T).someMethod).Bool() { - t.Fail() - } - t1 := &T{} - t2 := &T{} - if !dummys.Call("isEqual", t1.someMethod, t1.someMethod).Bool() || dummys.Call("isEqual", t1.someMethod, t2.someMethod).Bool() { - t.Fail() - } -} - -func somePackageFunction(_ string) { -} - -type T struct{} - -func (t *T) someMethod() { - println(42) -} - -func TestError(t *testing.T) { - defer func() { - err := recover() - if err == nil { - t.Fail() - } - if _, ok := err.(error); !ok { - t.Fail() - } - jsErr, ok := err.(*js.Error) - if !ok || !strings.Contains(jsErr.Error(), "throwsError") { - t.Fail() - } - }() - js.Global.Get("notExisting").Call("throwsError") -} - -type F struct { - Field int -} - -func TestExternalizeField(t *testing.T) { - if dummys.Call("testField", map[string]int{"Field": 42}).Int() != 42 { - t.Fail() - } - if dummys.Call("testField", F{42}).Int() != 42 { - t.Fail() - } -} - -func TestMakeFunc(t *testing.T) { - o := js.Global.Get("Object").New() - for i := 3; i < 5; i++ { - x := i - if i == 4 { - break - } - o.Set("f", js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} { - if this != o { - t.Fail() - } - if len(arguments) != 2 || arguments[0].Int() != 1 || arguments[1].Int() != 2 { - t.Fail() - } - return x - })) - } - if o.Call("f", 1, 2).Int() != 3 { - t.Fail() - } -} - -type M struct { - f int -} - -func (m *M) Method(a interface{}) map[string]string { - if a.(map[string]interface{})["x"].(float64) != 1 || m.f != 42 { - return nil - } - return map[string]string{ - "y": "z", - } -} - -func TestMakeWrapper(t *testing.T) { - m := &M{42} - if !js.Global.Call("eval", `(function(m) { return m.Method({x: 1})["y"] === "z"; })`).Invoke(js.MakeWrapper(m)).Bool() { - t.Fail() - } - - if js.MakeWrapper(m).Interface() != m { - t.Fail() - } - - f := func(m *M) { - if m.f != 42 { - t.Fail() - } - } - js.Global.Call("eval", `(function(f, m) { f(m); })`).Invoke(f, js.MakeWrapper(m)) -} - -func TestCallWithNull(t *testing.T) { - c := make(chan int, 1) - js.Global.Set("test", func() { - c <- 42 - }) - js.Global.Get("test").Call("call", nil) - if <-c != 42 { - t.Fail() - } -} - -func TestReflection(t *testing.T) { - o := js.Global.Call("eval", "({ answer: 42 })") - if reflect.ValueOf(o).Interface().(*js.Object) != o { - t.Fail() - } - - type S struct { - Field *js.Object - } - s := S{o} - - v := reflect.ValueOf(&s).Elem() - if v.Field(0).Interface().(*js.Object).Get("answer").Int() != 42 { - t.Fail() - } - if v.Field(0).MethodByName("Get").Call([]reflect.Value{reflect.ValueOf("answer")})[0].Interface().(*js.Object).Int() != 42 { - t.Fail() - } - v.Field(0).Set(reflect.ValueOf(js.Global.Call("eval", "({ answer: 100 })"))) - if s.Field.Get("answer").Int() != 100 { - t.Fail() - } - - if fmt.Sprintf("%+v", s) != "{Field:[object Object]}" { - t.Fail() - } -} - -func TestNil(t *testing.T) { - type S struct{ X int } - var s *S - if !dummys.Call("isEqual", s, nil).Bool() { - t.Fail() - } - - type T struct{ Field *S } - if dummys.Call("testField", T{}) != nil { - t.Fail() - } -} - -func TestNewArrayBuffer(t *testing.T) { - b := []byte("abcd") - a := js.NewArrayBuffer(b[1:3]) - if a.Get("byteLength").Int() != 2 { - t.Fail() - } -} - -func TestInternalizeExternalizeNull(t *testing.T) { - type S struct { - *js.Object - } - r := js.Global.Call("eval", "(function(f) { return f(null); })").Invoke(func(s S) S { - if s.Object != nil { - t.Fail() - } - return s - }) - if r != nil { - t.Fail() - } -} - -func TestInternalizeExternalizeUndefined(t *testing.T) { - type S struct { - *js.Object - } - r := js.Global.Call("eval", "(function(f) { return f(undefined); })").Invoke(func(s S) S { - if s.Object != js.Undefined { - t.Fail() - } - return s - }) - if r != js.Undefined { - t.Fail() - } -} - -func TestDereference(t *testing.T) { - s := *dummys - p := &s - if p != dummys { - t.Fail() - } -} - -func TestSurrogatePairs(t *testing.T) { - js.Global.Set("str", "\U0001F600") - str := js.Global.Get("str") - if str.Get("length").Int() != 2 || str.Call("charCodeAt", 0).Int() != 55357 || str.Call("charCodeAt", 1).Int() != 56832 { - t.Fail() - } - if str.String() != "\U0001F600" { - t.Fail() - } -} - -func TestUint8Array(t *testing.T) { - uint8Array := js.Global.Get("Uint8Array") - if dummys.Call("return", []byte{}).Get("constructor") != uint8Array { - t.Errorf("Empty byte array is not externalized as a Uint8Array") - } - if dummys.Call("return", []byte{0x01}).Get("constructor") != uint8Array { - t.Errorf("Non-empty byte array is not externalized as a Uint8Array") - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/node-syscall/binding.gyp b/vendor/github.com/gopherjs/gopherjs/node-syscall/binding.gyp deleted file mode 100644 index 9f3211d12..000000000 --- a/vendor/github.com/gopherjs/gopherjs/node-syscall/binding.gyp +++ /dev/null @@ -1,8 +0,0 @@ -{ - 'targets': [ - { - 'target_name': 'syscall', - 'sources': [ 'syscall.cc' ] - } - ] -} \ No newline at end of file diff --git a/vendor/github.com/gopherjs/gopherjs/node-syscall/syscall.cc b/vendor/github.com/gopherjs/gopherjs/node-syscall/syscall.cc deleted file mode 100644 index 71aa4371b..000000000 --- a/vendor/github.com/gopherjs/gopherjs/node-syscall/syscall.cc +++ /dev/null @@ -1,98 +0,0 @@ -#include -#include -#include -#include -#include -#include - -using namespace v8; - -#if NODE_MAJOR_VERSION == 0 -#define ARRAY_BUFFER_DATA_OFFSET 23 -#else -#define ARRAY_BUFFER_DATA_OFFSET 31 -#endif - -intptr_t toNative(Local value) { - if (value.IsEmpty()) { - return 0; - } - if (value->IsArrayBufferView()) { - Local view = Local::Cast(value); - return *reinterpret_cast(*reinterpret_cast(*view->Buffer()) + ARRAY_BUFFER_DATA_OFFSET) + view->ByteOffset(); // ugly hack, because of https://codereview.chromium.org/25221002 - } - if (value->IsArray()) { - Local array = Local::Cast(value); - intptr_t* native = reinterpret_cast(malloc(array->Length() * sizeof(intptr_t))); // TODO memory leak - for (uint32_t i = 0; i < array->Length(); i++) { - native[i] = toNative(array->CloneElementAt(i)); - } - return reinterpret_cast(native); - } - return static_cast(static_cast(value->ToInteger()->Value())); -} - -void Syscall(const FunctionCallbackInfo& info) { - int trap = info[0]->ToInteger()->Value(); - int r1 = 0, r2 = 0; - switch (trap) { - case SYS_fork: - r1 = fork(); - break; - case SYS_pipe: - int fd[2]; - r1 = pipe(fd); - if (r1 == 0) { - r1 = fd[0]; - r2 = fd[1]; - } - break; - default: - r1 = syscall( - trap, - toNative(info[1]), - toNative(info[2]), - toNative(info[3]) - ); - break; - } - int err = 0; - if (r1 < 0) { - err = errno; - } - Isolate* isolate = info.GetIsolate(); - Local res = Array::New(isolate, 3); - res->Set(0, Integer::New(isolate, r1)); - res->Set(1, Integer::New(isolate, r2)); - res->Set(2, Integer::New(isolate, err)); - info.GetReturnValue().Set(res); -} - -void Syscall6(const FunctionCallbackInfo& info) { - int r = syscall( - info[0]->ToInteger()->Value(), - toNative(info[1]), - toNative(info[2]), - toNative(info[3]), - toNative(info[4]), - toNative(info[5]), - toNative(info[6]) - ); - int err = 0; - if (r < 0) { - err = errno; - } - Isolate* isolate = info.GetIsolate(); - Local res = Array::New(isolate, 3); - res->Set(0, Integer::New(isolate, r)); - res->Set(1, Integer::New(isolate, 0)); - res->Set(2, Integer::New(isolate, err)); - info.GetReturnValue().Set(res); -} - -void init(Handle target) { - NODE_SET_METHOD(target, "Syscall", Syscall); - NODE_SET_METHOD(target, "Syscall6", Syscall6); -} - -NODE_MODULE(syscall, init); diff --git a/vendor/github.com/gopherjs/gopherjs/nosync/mutex.go b/vendor/github.com/gopherjs/gopherjs/nosync/mutex.go deleted file mode 100644 index 03f20dc40..000000000 --- a/vendor/github.com/gopherjs/gopherjs/nosync/mutex.go +++ /dev/null @@ -1,85 +0,0 @@ -package nosync - -// Mutex is a dummy which is non-blocking. -type Mutex struct { - locked bool -} - -// Lock locks m. It is a run-time error if m is already locked. -func (m *Mutex) Lock() { - if m.locked { - panic("nosync: mutex is already locked") - } - m.locked = true -} - -// Unlock unlocks m. It is a run-time error if m is not locked. -func (m *Mutex) Unlock() { - if !m.locked { - panic("nosync: unlock of unlocked mutex") - } - m.locked = false -} - -// RWMutex is a dummy which is non-blocking. -type RWMutex struct { - writeLocked bool - readLockCounter int -} - -// Lock locks m for writing. It is a run-time error if rw is already locked for reading or writing. -func (rw *RWMutex) Lock() { - if rw.readLockCounter != 0 || rw.writeLocked { - panic("nosync: mutex is already locked") - } - rw.writeLocked = true -} - -// Unlock unlocks rw for writing. It is a run-time error if rw is not locked for writing. -func (rw *RWMutex) Unlock() { - if !rw.writeLocked { - panic("nosync: unlock of unlocked mutex") - } - rw.writeLocked = false -} - -// RLock locks m for reading. It is a run-time error if rw is already locked for reading or writing. -func (rw *RWMutex) RLock() { - if rw.writeLocked { - panic("nosync: mutex is already locked") - } - rw.readLockCounter++ -} - -// RUnlock undoes a single RLock call; it does not affect other simultaneous readers. It is a run-time error if rw is not locked for reading. -func (rw *RWMutex) RUnlock() { - if rw.readLockCounter == 0 { - panic("nosync: unlock of unlocked mutex") - } - rw.readLockCounter-- -} - -// WaitGroup is a dummy which is non-blocking. -type WaitGroup struct { - counter int -} - -// Add adds delta, which may be negative, to the WaitGroup If the counter goes negative, Add panics. -func (wg *WaitGroup) Add(delta int) { - wg.counter += delta - if wg.counter < 0 { - panic("sync: negative WaitGroup counter") - } -} - -// Done decrements the WaitGroup counter. -func (wg *WaitGroup) Done() { - wg.Add(-1) -} - -// Wait panics if the WaitGroup counter is not zero. -func (wg *WaitGroup) Wait() { - if wg.counter != 0 { - panic("sync: WaitGroup counter not zero") - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/nosync/once.go b/vendor/github.com/gopherjs/gopherjs/nosync/once.go deleted file mode 100644 index f4cb69540..000000000 --- a/vendor/github.com/gopherjs/gopherjs/nosync/once.go +++ /dev/null @@ -1,39 +0,0 @@ -package nosync - -// Once is an object that will perform exactly one action. -type Once struct { - doing bool - done bool -} - -// Do calls the function f if and only if Do is being called for the -// first time for this instance of Once. In other words, given -// var once Once -// if once.Do(f) is called multiple times, only the first call will invoke f, -// even if f has a different value in each invocation. A new instance of -// Once is required for each function to execute. -// -// Do is intended for initialization that must be run exactly once. Since f -// is niladic, it may be necessary to use a function literal to capture the -// arguments to a function to be invoked by Do: -// config.once.Do(func() { config.init(filename) }) -// -// If f causes Do to be called, it will panic. -// -// If f panics, Do considers it to have returned; future calls of Do return -// without calling f. -// -func (o *Once) Do(f func()) { - if o.done { - return - } - if o.doing { - panic("nosync: Do called within f") - } - o.doing = true - defer func() { - o.doing = false - o.done = true - }() - f() -} diff --git a/vendor/github.com/gopherjs/gopherjs/nosync/pool.go b/vendor/github.com/gopherjs/gopherjs/nosync/pool.go deleted file mode 100644 index 3d448e0fc..000000000 --- a/vendor/github.com/gopherjs/gopherjs/nosync/pool.go +++ /dev/null @@ -1,63 +0,0 @@ -package nosync - -// A Pool is a set of temporary objects that may be individually saved and -// retrieved. -// -// Any item stored in the Pool may be removed automatically at any time without -// notification. If the Pool holds the only reference when this happens, the -// item might be deallocated. -// -// A Pool is safe for use by multiple goroutines simultaneously. -// -// Pool's purpose is to cache allocated but unused items for later reuse, -// relieving pressure on the garbage collector. That is, it makes it easy to -// build efficient, thread-safe free lists. However, it is not suitable for all -// free lists. -// -// An appropriate use of a Pool is to manage a group of temporary items -// silently shared among and potentially reused by concurrent independent -// clients of a package. Pool provides a way to amortize allocation overhead -// across many clients. -// -// An example of good use of a Pool is in the fmt package, which maintains a -// dynamically-sized store of temporary output buffers. The store scales under -// load (when many goroutines are actively printing) and shrinks when -// quiescent. -// -// On the other hand, a free list maintained as part of a short-lived object is -// not a suitable use for a Pool, since the overhead does not amortize well in -// that scenario. It is more efficient to have such objects implement their own -// free list. -// -type Pool struct { - store []interface{} - New func() interface{} -} - -// Get selects an arbitrary item from the Pool, removes it from the -// Pool, and returns it to the caller. -// Get may choose to ignore the pool and treat it as empty. -// Callers should not assume any relation between values passed to Put and -// the values returned by Get. -// -// If Get would otherwise return nil and p.New is non-nil, Get returns -// the result of calling p.New. -func (p *Pool) Get() interface{} { - if len(p.store) == 0 { - if p.New != nil { - return p.New() - } - return nil - } - x := p.store[len(p.store)-1] - p.store = p.store[:len(p.store)-1] - return x -} - -// Put adds x to the pool. -func (p *Pool) Put(x interface{}) { - if x == nil { - return - } - p.store = append(p.store, x) -} diff --git a/vendor/github.com/gopherjs/gopherjs/tests/alias_test.go b/vendor/github.com/gopherjs/gopherjs/tests/alias_test.go deleted file mode 100644 index 9e791856e..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/alias_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package tests - -import ( - "testing" -) - -type foo struct { - a int -} - -func Test1(t *testing.T) { - calls := 0 - bar := func() *foo { - calls++ - return &foo{42} - } - q := &bar().a - if calls != 1 { - t.Error("Should've been a call") - } - *q = 40 - if calls != 1 { - t.Error("Wrong number of calls: ", calls, ", should be 1") - } - if *q != 40 { - t.Error("*q != 40") - } -} - -func Test2(t *testing.T) { - f := foo{} - p := &f.a - f = foo{} - f.a = 4 - if *p != 4 { - t.Error("*p != 4") - } -} - -func Test3(t *testing.T) { - f := foo{} - p := &f - f = foo{4} - if p.a != 4 { - t.Error("p.a != 4") - } -} - -func Test4(t *testing.T) { - f := struct { - a struct { - b int - } - }{} - p := &f.a - q := &p.b - r := &(*p).b - *r = 4 - p = nil - if *r != 4 { - t.Error("*r != 4") - } - if *q != 4 { - t.Error("*q != 4") - } -} - -func Test5(t *testing.T) { - f := struct { - a [3]int - }{[3]int{6, 6, 6}} - s := f.a[:] - f.a = [3]int{4, 4, 4} - if s[1] != 4 { - t.Error("s[1] != 4") - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/tests/copy_test.go b/vendor/github.com/gopherjs/gopherjs/tests/copy_test.go deleted file mode 100644 index c03a3a83c..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/copy_test.go +++ /dev/null @@ -1,133 +0,0 @@ -package tests - -import ( - "testing" -) - -type S struct { - x int -} - -func (a S) test(b S) { - a.x = 0 - b.x = 0 -} - -type A [1]int - -func (a A) test(b A) { - a[0] = 0 - b[0] = 0 -} - -func TestCopyOnCall(t *testing.T) { - { - a := S{1} - b := S{2} - - a.test(b) - func() { - defer a.test(b) - }() - - if a.x != 1 { - t.Error("a.x != 1") - } - if b.x != 2 { - t.Error("b.x != 2") - } - } - { - a := A{1} - b := A{2} - - a.test(b) - func() { - defer a.test(b) - }() - - if a[0] != 1 { - t.Error("a[0] != 1") - } - if b[0] != 2 { - t.Error("b[0] != 2") - } - } -} - -func TestSwap(t *testing.T) { - { - a := S{1} - b := S{2} - a, b = b, a - if a.x != 2 || b.x != 1 { - t.Fail() - } - } - { - a := A{1} - b := A{2} - a, b = b, a - if a[0] != 2 || b[0] != 1 { - t.Fail() - } - } -} - -func TestComposite(t *testing.T) { - { - a := S{1} - s := []S{a} - s[0].x = 0 - if a.x != 1 { - t.Fail() - } - } - { - a := A{1} - s := []A{a} - s[0][0] = 0 - if a[0] != 1 { - t.Fail() - } - } -} - -func TestAppend(t *testing.T) { - { - s := append(make([]S, 3), S{}) // cap(s) == 6 - s = s[:6] - if s[5].x != 0 { - t.Fail() - } - } - - { - a := S{1} - b := []S{{2}} - s := append([]S{}, b...) - s[0].x = 0 - if a.x != 1 || b[0].x != 2 { - t.Fail() - } - } -} - -type I interface { - M() int -} - -type T S - -func (t T) M() int { - return t.x -} - -func TestExplicitConversion(t *testing.T) { - var coolGuy = S{x: 42} - var i I - i = T(coolGuy) - if i.M() != 42 { - t.Fail() - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/tests/deferblock_test.go b/vendor/github.com/gopherjs/gopherjs/tests/deferblock_test.go deleted file mode 100644 index 89fe0c9c6..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/deferblock_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package tests - -import ( - "testing" - "time" -) - -func inner(ch chan struct{}, b bool) ([]byte, error) { - // ensure gopherjs thinks that this inner function can block - if b { - <-ch - } - return []byte{}, nil -} - -// this function's call to inner never blocks, but the deferred -// statement does. -func outer(ch chan struct{}, b bool) ([]byte, error) { - defer func() { - <-ch - }() - - return inner(ch, b) -} - -func TestBlockingInDefer(t *testing.T) { - defer func() { - if x := recover(); x != nil { - t.Errorf("run time panic: %v", x) - } - }() - - ch := make(chan struct{}) - b := false - - go func() { - time.Sleep(5 * time.Millisecond) - ch <- struct{}{} - }() - - outer(ch, b) -} diff --git a/vendor/github.com/gopherjs/gopherjs/tests/doc.go b/vendor/github.com/gopherjs/gopherjs/tests/doc.go deleted file mode 100644 index e33eea887..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package tests contains tests for GopherJS. -package tests diff --git a/vendor/github.com/gopherjs/gopherjs/tests/gorepo_test.go b/vendor/github.com/gopherjs/gopherjs/tests/gorepo_test.go deleted file mode 100644 index 5496cd32e..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/gorepo_test.go +++ /dev/null @@ -1,24 +0,0 @@ -// +build !js - -package tests_test - -import ( - "os" - "os/exec" - "testing" -) - -// Go repository basic compiler tests, and regression tests for fixed compiler bugs. -func TestGoRepositoryCompilerTests(t *testing.T) { - args := []string{"go", "run", "run.go", "-summary"} - if testing.Verbose() { - args = append(args, "-v") - } - cmd := exec.Command(args[0], args[1:]...) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stdout - err := cmd.Run() - if err != nil { - t.Fatal(err) - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/tests/goroutine_test.go b/vendor/github.com/gopherjs/gopherjs/tests/goroutine_test.go deleted file mode 100644 index 962a6456a..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/goroutine_test.go +++ /dev/null @@ -1,142 +0,0 @@ -package tests - -import ( - "fmt" - "testing" - "time" -) - -var expectedI int - -func checkI(t *testing.T, i int) { - if i != expectedI { - t.Errorf("expected %d, got %d", expectedI, i) - } - expectedI++ -} - -func TestDefer(t *testing.T) { - expectedI = 1 - defer func() { - checkI(t, 2) - testDefer1(t) - checkI(t, 6) - }() - checkI(t, 1) -} - -func testDefer1(t *testing.T) { - defer func() { - checkI(t, 4) - time.Sleep(0) - checkI(t, 5) - }() - checkI(t, 3) -} - -func TestPanic(t *testing.T) { - expectedI = 1 - defer func() { - checkI(t, 8) - err := recover() - time.Sleep(0) - checkI(t, err.(int)) - }() - checkI(t, 1) - testPanic1(t) - checkI(t, -1) -} - -func testPanic1(t *testing.T) { - defer func() { - checkI(t, 6) - time.Sleep(0) - err := recover() - checkI(t, err.(int)) - panic(9) - }() - checkI(t, 2) - testPanic2(t) - checkI(t, -2) -} - -func testPanic2(t *testing.T) { - defer func() { - checkI(t, 5) - }() - checkI(t, 3) - time.Sleep(0) - checkI(t, 4) - panic(7) - checkI(t, -3) -} - -func TestPanicAdvanced(t *testing.T) { - expectedI = 1 - defer func() { - recover() - checkI(t, 3) - testPanicAdvanced2(t) - checkI(t, 6) - }() - testPanicAdvanced1(t) - checkI(t, -1) -} - -func testPanicAdvanced1(t *testing.T) { - defer func() { - checkI(t, 2) - }() - checkI(t, 1) - panic("") -} - -func testPanicAdvanced2(t *testing.T) { - defer func() { - checkI(t, 5) - }() - checkI(t, 4) -} - -func TestSelect(t *testing.T) { - expectedI = 1 - a := make(chan int) - b := make(chan int) - c := make(chan int) - go func() { - select { - case <-a: - case <-b: - } - }() - go func() { - checkI(t, 1) - a <- 1 - select { - case b <- 1: - checkI(t, -1) - default: - checkI(t, 2) - } - c <- 1 - }() - <-c - checkI(t, 3) -} - -func TestCloseAfterReceiving(t *testing.T) { - ch := make(chan struct{}) - go func() { - <-ch - close(ch) - }() - ch <- struct{}{} -} - -func TestDeferWithBlocking(t *testing.T) { - ch := make(chan struct{}) - go func() { ch <- struct{}{} }() - defer func() { <-ch }() - fmt.Print("") - return -} diff --git a/vendor/github.com/gopherjs/gopherjs/tests/lowlevel_test.go b/vendor/github.com/gopherjs/gopherjs/tests/lowlevel_test.go deleted file mode 100644 index cc4a7d4b2..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/lowlevel_test.go +++ /dev/null @@ -1,31 +0,0 @@ -// +build !js - -package tests_test - -import ( - "bytes" - "io/ioutil" - "os/exec" - "path/filepath" - "testing" -) - -// Test for internalization/externalization of time.Time/Date when time package is imported -// but time.Time is unused, causing it to be DCEed (or time package not imported at all). -// -// See https://github.com/gopherjs/gopherjs/issues/279. -func TestTimeInternalizationExternalization(t *testing.T) { - got, err := exec.Command("gopherjs", "run", filepath.Join("testdata", "time_inexternalization.go")).Output() - if err != nil { - t.Fatalf("%v:\n%s", err, got) - } - - want, err := ioutil.ReadFile(filepath.Join("testdata", "time_inexternalization.out")) - if err != nil { - t.Fatalf("error reading .out file: %v", err) - } - - if !bytes.Equal(got, want) { - t.Fatalf("got != want:\ngot:\n%s\nwant:\n%s", got, want) - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/tests/main/main.go b/vendor/github.com/gopherjs/gopherjs/tests/main/main.go deleted file mode 100644 index f1f39609e..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/main/main.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -var mainDidRun = false - -func main() { - mainDidRun = true -} diff --git a/vendor/github.com/gopherjs/gopherjs/tests/main/main_test.go b/vendor/github.com/gopherjs/gopherjs/tests/main/main_test.go deleted file mode 100644 index 02f0de736..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/main/main_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package main - -import "testing" - -func TestNotRunMain(t *testing.T) { - if mainDidRun { - t.Error("main function did run") - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/tests/misc_test.go b/vendor/github.com/gopherjs/gopherjs/tests/misc_test.go deleted file mode 100644 index edbc890ce..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/misc_test.go +++ /dev/null @@ -1,625 +0,0 @@ -package tests - -import ( - "math" - "reflect" - "runtime" - "strings" - "testing" - "time" - "vendored" - - "github.com/gopherjs/gopherjs/tests/otherpkg" -) - -func TestSyntax1(t *testing.T) { - a := 42 - if *&*&a != 42 { - t.Fail() - } -} - -func TestPointerEquality(t *testing.T) { - a := 1 - b := 1 - if &a != &a || &a == &b { - t.Fail() - } - m := make(map[*int]int) - m[&a] = 2 - m[&b] = 3 - if m[&a] != 2 || m[&b] != 3 { - t.Fail() - } - - for { - c := 1 - d := 1 - if &c != &c || &c == &d { - t.Fail() - } - break - } - - s := struct { - e int - f int - }{1, 1} - if &s.e != &s.e || &s.e == &s.f { - t.Fail() - } - - g := [3]int{1, 2, 3} - if &g[0] != &g[0] || &g[:][0] != &g[0] || &g[:][0] != &g[:][0] { - t.Fail() - } -} - -type SingleValue struct { - Value uint16 -} - -type OtherSingleValue struct { - Value uint16 -} - -func TestStructKey(t *testing.T) { - m := make(map[SingleValue]int) - m[SingleValue{Value: 1}] = 42 - m[SingleValue{Value: 2}] = 43 - if m[SingleValue{Value: 1}] != 42 || m[SingleValue{Value: 2}] != 43 || reflect.ValueOf(m).MapIndex(reflect.ValueOf(SingleValue{Value: 1})).Interface() != 42 { - t.Fail() - } - - m2 := make(map[interface{}]int) - m2[SingleValue{Value: 1}] = 42 - m2[SingleValue{Value: 2}] = 43 - m2[OtherSingleValue{Value: 1}] = 44 - if m2[SingleValue{Value: 1}] != 42 || m2[SingleValue{Value: 2}] != 43 || m2[OtherSingleValue{Value: 1}] != 44 || reflect.ValueOf(m2).MapIndex(reflect.ValueOf(SingleValue{Value: 1})).Interface() != 42 { - t.Fail() - } -} - -func TestSelectOnNilChan(t *testing.T) { - var c1 chan bool - c2 := make(chan bool) - - go func() { - close(c2) - }() - - select { - case <-c1: - t.Fail() - case <-c2: - // ok - } -} - -type StructA struct { - x int -} - -type StructB struct { - StructA -} - -func TestEmbeddedStruct(t *testing.T) { - a := StructA{ - 42, - } - b := StructB{ - StructA: a, - } - b.x = 0 - if a.x != 42 { - t.Fail() - } -} - -func TestMapStruct(t *testing.T) { - a := StructA{ - 42, - } - m := map[int]StructA{ - 1: a, - } - m[2] = a - a.x = 0 - if m[1].x != 42 || m[2].x != 42 { - t.Fail() - } -} - -func TestUnnamedParameters(t *testing.T) { - ok := false - defer func() { - if !ok { - t.Fail() - } - }() - blockingWithUnnamedParameter(false) // used to cause non-blocking call error, which is ignored by testing - ok = true -} - -func blockingWithUnnamedParameter(bool) { - c := make(chan int, 1) - c <- 42 -} - -func TestGotoLoop(t *testing.T) { - goto loop -loop: - for i := 42; ; { - if i != 42 { - t.Fail() - } - break - } -} - -func TestMaxUint64(t *testing.T) { - if math.MaxUint64 != 18446744073709551615 { - t.Fail() - } -} - -func TestCopyBuiltin(t *testing.T) { - { - s := []string{"a", "b", "c"} - copy(s, s[1:]) - if s[0] != "b" || s[1] != "c" || s[2] != "c" { - t.Fail() - } - } - { - s := []string{"a", "b", "c"} - copy(s[1:], s) - if s[0] != "a" || s[1] != "a" || s[2] != "b" { - t.Fail() - } - } -} - -func TestPointerOfStructConversion(t *testing.T) { - type A struct { - Value int - } - - type B A - - a1 := &A{Value: 1} - b1 := (*B)(a1) - b1.Value = 2 - a2 := (*A)(b1) - a2.Value = 3 - b2 := (*B)(a2) - b2.Value = 4 - if a1 != a2 || b1 != b2 || a1.Value != 4 || a2.Value != 4 || b1.Value != 4 || b2.Value != 4 { - t.Fail() - } -} - -func TestCompareStruct(t *testing.T) { - type A struct { - Value int - } - - a := A{42} - var b interface{} = a - x := A{0} - - if a != b || a == x || b == x { - t.Fail() - } -} - -func TestLoopClosure(t *testing.T) { - type S struct{ fn func() int } - var fns []*S - for i := 0; i < 2; i++ { - z := i - fns = append(fns, &S{ - fn: func() int { - return z - }, - }) - } - for i, f := range fns { - if f.fn() != i { - t.Fail() - } - } -} - -func TestLoopClosureWithStruct(t *testing.T) { - type T struct{ A int } - ts := []T{{0}, {1}, {2}} - fns := make([]func() T, 3) - for i, t := range ts { - t := t - fns[i] = func() T { - return t - } - } - for i := range fns { - if fns[i]().A != i { - t.Fail() - } - } -} - -func TestNilInterfaceError(t *testing.T) { - defer func() { - if err := recover(); err == nil || !strings.Contains(err.(error).Error(), "nil pointer dereference") { - t.Fail() - } - }() - var err error - _ = err.Error() -} - -func TestIndexOutOfRangeError(t *testing.T) { - defer func() { - if err := recover(); err == nil || !strings.Contains(err.(error).Error(), "index out of range") { - t.Fail() - } - }() - x := []int{1, 2, 3}[10] - _ = x -} - -func TestNilAtLhs(t *testing.T) { - type F func(string) string - var f F - if nil != f { - t.Fail() - } -} - -func TestZeroResultByPanic(t *testing.T) { - if zero() != 0 { - t.Fail() - } -} - -func zero() int { - defer func() { - recover() - }() - panic("") -} - -func TestNumGoroutine(t *testing.T) { - n := runtime.NumGoroutine() - c := make(chan bool) - go func() { - <-c - <-c - <-c - <-c - }() - c <- true - c <- true - c <- true - if got, want := runtime.NumGoroutine(), n+1; got != want { - t.Errorf("runtime.NumGoroutine(): Got %d, want %d.", got, want) - } - c <- true -} - -func TestMapAssign(t *testing.T) { - x := 0 - m := map[string]string{} - x, m["foo"] = 5, "bar" - if x != 5 || m["foo"] != "bar" { - t.Fail() - } -} - -func TestSwitchStatement(t *testing.T) { - zero := 0 - var interfaceZero interface{} = zero - switch { - case interfaceZero: - t.Fail() - default: - // ok - } -} - -func TestAddAssignOnPackageVar(t *testing.T) { - otherpkg.Test = 0 - otherpkg.Test += 42 - if otherpkg.Test != 42 { - t.Fail() - } -} - -func TestPointerOfPackageVar(t *testing.T) { - otherpkg.Test = 42 - p := &otherpkg.Test - if *p != 42 { - t.Fail() - } -} - -func TestFuncInSelect(t *testing.T) { - f := func(_ func()) chan int { - return make(chan int, 1) - } - select { - case <-f(func() {}): - case _ = <-f(func() {}): - case f(func() {}) <- 42: - } -} - -func TestEscapeAnalysisOnForLoopVariableScope(t *testing.T) { - for i := 0; ; { - p := &i - time.Sleep(0) - i = 42 - if *p != 42 { - t.Fail() - } - break - } -} - -func TestGoStmtWithStructArg(t *testing.T) { - type S struct { - i int - } - - f := func(s S, c chan int) { - c <- s.i - c <- s.i - } - - c := make(chan int) - s := S{42} - go f(s, c) - s.i = 0 - if <-c != 42 { - t.Fail() - } - if <-c != 42 { - t.Fail() - } -} - -type methodExprCallType int - -func (i methodExprCallType) test() int { - return int(i) + 2 -} - -func TestMethodExprCall(t *testing.T) { - if methodExprCallType.test(40) != 42 { - t.Fail() - } -} - -func TestCopyOnSend(t *testing.T) { - type S struct{ i int } - c := make(chan S, 2) - go func() { - var s S - s.i = 42 - c <- s - select { - case c <- s: - } - s.i = 10 - }() - if (<-c).i != 42 { - t.Fail() - } - if (<-c).i != 42 { - t.Fail() - } -} - -func TestEmptySelectCase(t *testing.T) { - ch := make(chan int, 1) - ch <- 42 - - var v = 0 - select { - case v = <-ch: - } - if v != 42 { - t.Fail() - } -} - -var a int -var b int -var C int -var D int - -var a1 = &a -var a2 = &a -var b1 = &b -var C1 = &C -var C2 = &C -var D1 = &D - -func TestPkgVarPointers(t *testing.T) { - if a1 != a2 || a1 == b1 || C1 != C2 || C1 == D1 { - t.Fail() - } -} - -func TestStringMap(t *testing.T) { - m := make(map[string]interface{}) - if m["__proto__"] != nil { - t.Fail() - } - m["__proto__"] = 42 - if m["__proto__"] != 42 { - t.Fail() - } -} - -type Int int - -func (i Int) Value() int { - return int(i) -} - -func (i *Int) ValueByPtr() int { - return int(*i) -} - -func TestWrappedTypeMethod(t *testing.T) { - i := Int(42) - p := &i - if p.Value() != 42 { - t.Fail() - } -} - -type EmbeddedInt struct { - Int -} - -func TestEmbeddedMethod(t *testing.T) { - e := EmbeddedInt{42} - if e.ValueByPtr() != 42 { - t.Fail() - } -} - -func TestBoolConvert(t *testing.T) { - if !reflect.ValueOf(true).Convert(reflect.TypeOf(true)).Bool() { - t.Fail() - } -} - -func TestGoexit(t *testing.T) { - go func() { - runtime.Goexit() - }() -} - -func TestVendoring(t *testing.T) { - if vendored.Answer != 42 { - t.Fail() - } -} - -func TestShift(t *testing.T) { - if x := uint(32); uint32(1)<>32 != 0 { - t.Fail() - } - if x := uint(4294967295); x>>35 != 0 { - t.Fail() - } -} - -func TestTrivialSwitch(t *testing.T) { - for { - switch { - default: - break - } - return - } - t.Fail() -} - -func TestTupleFnReturnImplicitCast(t *testing.T) { - var ycalled int = 0 - x := func(fn func() (int, error)) (interface{}, error) { - return fn() - } - y, _ := x(func() (int, error) { - ycalled++ - return 14, nil - }) - if y != 14 || ycalled != 1 { - t.Fail() - } -} - -var tuple2called = 0 - -func tuple1() (interface{}, error) { - return tuple2() -} -func tuple2() (int, error) { - tuple2called++ - return 14, nil -} -func TestTupleReturnImplicitCast(t *testing.T) { - x, _ := tuple1() - if x != 14 || tuple2called != 1 { - t.Fail() - } -} - -func TestDeferNamedTupleReturnImplicitCast(t *testing.T) { - var ycalled int = 0 - var zcalled int = 0 - z := func() { - zcalled++ - } - x := func(fn func() (int, error)) (i interface{}, e error) { - defer z() - i, e = fn() - return - } - y, _ := x(func() (int, error) { - ycalled++ - return 14, nil - }) - if y != 14 || ycalled != 1 || zcalled != 1 { - t.Fail() - } -} - -func TestSliceOfString(t *testing.T) { - defer func() { - if err := recover(); err == nil || !strings.Contains(err.(error).Error(), "slice bounds out of range") { - t.Fail() - } - }() - - str := "foo" - print(str[0:10]) -} - -type R struct{ v int } - -func (r R) Val() int { - return r.v -} - -func TestReceiverCapture(t *testing.T) { - r := R{1} - f1 := r.Val - r = R{2} - f2 := r.Val - if f1() != 1 || f2() != 2 { - t.Fail() - } -} - -func TestTypeConversion(t *testing.T) { - i1, i2, i3 := 4, 2, 2 - if (i1-i2)/i3 != int(i1-i2)/int(i3) { - t.Fail() - } - f1, f2, f3 := 4.0, 2.0, 2.0 - if (f1-f2)/f3 != float64(f1-f2)/float64(f3) { - t.Fail() - } -} diff --git a/vendor/github.com/gopherjs/gopherjs/tests/otherpkg/otherpkg.go b/vendor/github.com/gopherjs/gopherjs/tests/otherpkg/otherpkg.go deleted file mode 100644 index 2b413e5f1..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/otherpkg/otherpkg.go +++ /dev/null @@ -1,3 +0,0 @@ -package otherpkg - -var Test float32 diff --git a/vendor/github.com/gopherjs/gopherjs/tests/run.go b/vendor/github.com/gopherjs/gopherjs/tests/run.go deleted file mode 100644 index 8a7134d67..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/run.go +++ /dev/null @@ -1,1189 +0,0 @@ -// +build ignore - -// skip - -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Run runs tests in the test directory. -// -// To run manually with summary, verbose output, and full stack traces of of known failures: -// -// go run run.go -summary -v -show_known_fails -// -// TODO(bradfitz): docs of some sort, once we figure out how we're changing -// headers of files -package main - -import ( - "bytes" - "errors" - "flag" - "fmt" - "hash/fnv" - "io" - "io/ioutil" - "log" - "os" - "os/exec" - "path" - "path/filepath" - "regexp" - "runtime" - "sort" - "strconv" - "strings" - "time" - "unicode" -) - -// ----------------------------------------------------------------------------- -// GOPHERJS: Known test fails for GopherJS compiler. -// -// TODO: Reduce these to zero or as close as possible. -// -var knownFails = map[string]failReason{ - "fixedbugs/bug114.go": {desc: "fixedbugs/bug114.go:15:27: B32 (untyped int constant 4294967295) overflows int"}, - "fixedbugs/bug242.go": {desc: "bad map check 13 false false Error: fail"}, - "fixedbugs/bug260.go": {desc: "maybe unsupportedFeature, pointer arithm"}, - "fixedbugs/bug262.go": {desc: "Error: fail"}, - "fixedbugs/bug273.go": {desc: "BUG: didn't crash: badcap1"}, - "fixedbugs/bug328.go": {desc: "incorrect output"}, - "fixedbugs/bug347.go": {desc: "BUG: bug347: cannot find caller"}, - "fixedbugs/bug348.go": {desc: "BUG: bug348: cannot find caller"}, - "fixedbugs/bug352.go": {desc: "BUG: bug352 struct{}"}, - "fixedbugs/bug409.go": {desc: "1 2 3 4"}, - "fixedbugs/bug433.go": {desc: "Error: [object Object]"}, - "fixedbugs/issue10353.go": {desc: "incorrect output"}, - "fixedbugs/issue11656.go": {desc: "Error: Native function not implemented: runtime/debug.setPanicOnFault"}, - "fixedbugs/issue4085b.go": {desc: "Error: got panic JavaScript error: Invalid typed array length, want len out of range"}, - "fixedbugs/issue4316.go": {desc: "Error: runtime error: invalid memory address or nil pointer dereference"}, - "fixedbugs/issue4388.go": {desc: "Error: expected :1 have anonymous function:0"}, - "fixedbugs/issue4562.go": {desc: "Error: cannot find issue4562.go on stack"}, - "fixedbugs/issue4620.go": {desc: "map[0:1 1:2], Error: m[i] != 2"}, - "fixedbugs/issue5856.go": {category: requiresSourceMapSupport}, - "fixedbugs/issue6899.go": {desc: "incorrect output -0"}, - "fixedbugs/issue7550.go": {desc: "FATAL ERROR: invalid table size Allocation failed - process out of memory"}, - "fixedbugs/issue7690.go": {desc: "Error: runtime error: slice bounds out of range"}, - "fixedbugs/issue8047.go": {desc: "null"}, - "fixedbugs/issue8047b.go": {desc: "Error: [object Object]"}, - - // Failing due to use of os/exec.Command, which is unsupported. Now skipped via !nacl build tag. - /*"fixedbugs/bug248.go": {desc: "os/exec.Command unsupported"}, - "fixedbugs/bug302.go": {desc: "os/exec.Command unsupported"}, - "fixedbugs/bug345.go": {desc: "os/exec.Command unsupported"}, - "fixedbugs/bug369.go": {desc: "os/exec.Command unsupported"}, - "fixedbugs/bug429_run.go": {desc: "os/exec.Command unsupported"}, - "fixedbugs/issue9862_run.go": {desc: "os/exec.Command unsupported"},*/ - "fixedbugs/issue10607.go": {desc: "os/exec.Command unsupported"}, - "fixedbugs/issue13268.go": {desc: "os/exec.Command unsupported"}, - "fixedbugs/issue14636.go": {desc: "os/exec.Command unsupported"}, - - // These are new tests in Go 1.7. - "fixedbugs/issue14646.go": {category: unsureIfGopherJSSupportsThisFeature, desc: "tests runtime.Caller behavior in a deferred func in SSA backend... does GopherJS even support runtime.Caller?"}, - "fixedbugs/issue15039.go": {category: validButDealWithAfterGo17SinceNew, desc: "valid bug but deal with after Go 1.7 support is out? it's likely not a regression"}, - "fixedbugs/issue15281.go": {category: validButDealWithAfterGo17SinceNew, desc: "also looks valid but deal with after Go 1.7 support is out? it's likely not a regression"}, - "fixedbugs/issue15975.go": {category: validButDealWithAfterGo17SinceNew, desc: "also looks valid but deal with after Go 1.7 support is out?"}, - - // These are new tests in Go 1.8. - "fixedbugs/issue15528.go": {category: usesUnsupportedPackage, desc: `imports "unsafe" package and gets: Error: reflect: call of reflect.Value.IsNil on unsafe.Pointer Value`}, // See https://github.com/golang/go/commit/dfc56a4cd313c9c5de37f4fadb14912286edc42f for relevant commit. - "fixedbugs/issue17381.go": {category: unsureIfGopherJSSupportsThisFeature, desc: "tests runtime.{Callers,FuncForPC} behavior in a deferred func with garbage on stack... does GopherJS even support runtime.{Callers,FuncForPC}?"}, - "fixedbugs/issue18149.go": {desc: "//line directives with filenames are not correctly parsed, see https://github.com/gopherjs/gopherjs/issues/553."}, -} - -type failCategory uint8 - -const ( - other failCategory = iota - usesUnsupportedPackage // Test fails because it imports an unsupported package, e.g., "unsafe". - requiresSourceMapSupport // Test fails without source map support (as configured in CI), because it tries to check filename/line number via runtime.Caller. - compilerPanic - unsureIfGopherJSSupportsThisFeature - validButDealWithAfterGo17SinceNew // TODO: After Go 1.7 support is out, this category should be re-triaged and removed. -) - -type failReason struct { - category failCategory - desc string -} - -// ----------------------------------------------------------------------------- - -var ( - verbose = flag.Bool("v", false, "verbose. if set, parallelism is set to 1.") - numParallel = flag.Int("n", runtime.NumCPU(), "number of parallel tests to run") - summary = flag.Bool("summary", false, "show summary of results") - showSkips = flag.Bool("show_skips", false, "show skipped tests") - showKnownFails = flag.Bool("show_known_fails", false, "show full error output of known fails") - updateErrors = flag.Bool("update_errors", false, "update error messages in test file based on compiler output") - runoutputLimit = flag.Int("l", defaultRunOutputLimit(), "number of parallel runoutput tests to run") - - shard = flag.Int("shard", 0, "shard index to run. Only applicable if -shards is non-zero.") - shards = flag.Int("shards", 0, "number of shards. If 0, all tests are run. This is used by the continuous build.") -) - -var ( - goos, goarch string - - // dirs are the directories to look for *.go files in. - // TODO(bradfitz): just use all directories? - dirs = []string{".", "ken", "chan", "interface", "syntax", "dwarf", "fixedbugs"} - - // ratec controls the max number of tests running at a time. - ratec chan bool - - // toRun is the channel of tests to run. - // It is nil until the first test is started. - toRun chan *test - - // rungatec controls the max number of runoutput tests - // executed in parallel as they can each consume a lot of memory. - rungatec chan bool -) - -// maxTests is an upper bound on the total number of tests. -// It is used as a channel buffer size to make sure sends don't block. -const maxTests = 5000 - -func main() { - flag.Parse() - - // GOPHERJS. - err := os.Chdir(filepath.Join(runtime.GOROOT(), "test")) - if err != nil { - log.Fatalln(err) - } - - goos = getenv("GOOS", runtime.GOOS) - //goarch = getenv("GOARCH", runtime.GOARCH) - // GOPHERJS. - goarch = getenv("GOARCH", "js") // We're running this script natively, but the tests are executed with js architecture. - - if *verbose { - fmt.Printf("goos: %q, goarch: %q\n", goos, goarch) - } - - findExecCmd() - - // Disable parallelism if printing or if using a simulator. - if *verbose || len(findExecCmd()) > 0 { - *numParallel = 1 - } - - ratec = make(chan bool, *numParallel) - rungatec = make(chan bool, *runoutputLimit) - - var tests []*test - if flag.NArg() > 0 { - for _, arg := range flag.Args() { - if arg == "-" || arg == "--" { - // Permit running: - // $ go run run.go - env.go - // $ go run run.go -- env.go - // $ go run run.go - ./fixedbugs - // $ go run run.go -- ./fixedbugs - continue - } - if fi, err := os.Stat(arg); err == nil && fi.IsDir() { - for _, baseGoFile := range goFiles(arg) { - tests = append(tests, startTest(arg, baseGoFile)) - } - } else if strings.HasSuffix(arg, ".go") { - dir, file := filepath.Split(arg) - tests = append(tests, startTest(dir, file)) - } else { - log.Fatalf("can't yet deal with non-directory and non-go file %q", arg) - } - } - } else { - for _, dir := range dirs { - for _, baseGoFile := range goFiles(dir) { - tests = append(tests, startTest(dir, baseGoFile)) - } - } - } - - failed := false - resCount := map[string]int{} - for _, test := range tests { - <-test.donec - // GOPHERJS. - if test.action == "skip" && !*showSkips { - continue - } - status := "ok " - errStr := "" - if _, isSkip := test.err.(skipError); isSkip { - test.err = nil - errStr = "unexpected skip for " + path.Join(test.dir, test.gofile) + ": " + errStr - status = "FAIL" - } - // GOPHERJS. - if _, ok := knownFails[filepath.ToSlash(test.goFileName())]; ok && test.err != nil { - errStr = test.err.Error() - test.err = nil - status = "knfl" // knfl means known failure. Expect test to fail. - } else if ok && test.err == nil { - // unok means unexpected okay. Test was expected to fail, but it unexpectedly succeeded. - // If this is not an accident, it should be removed from knownFails map. - status = "unok" - } - if test.err != nil { - status = "FAIL" - errStr = test.err.Error() - } - if status == "FAIL" { - failed = true - } - // GOPHERJS. - if status == "unok" { - failed = true - } - resCount[status]++ - if status == "skip" && !*verbose && !*showSkips { - continue - } - dt := fmt.Sprintf("%.3fs", test.dt.Seconds()) - if status == "FAIL" { - fmt.Printf("# go run run.go -- %s\n%s\nFAIL\t%s\t%s\n", - path.Join(test.dir, test.gofile), - errStr, test.goFileName(), dt) - continue - } - // GOPHERJS. - if status == "knfl" && *showKnownFails { - fmt.Printf("# go run run.go -show_known_fails -- %s\n%s\nknfl\t%s\t%s\n", - path.Join(test.dir, test.gofile), - errStr, test.goFileName(), dt) - continue - } - if !*verbose && status != "unok" { - continue - } - fmt.Printf("%s\t%s\t%s\n", status, test.goFileName(), dt) - } - - if *summary { - for k, v := range resCount { - fmt.Printf("%5d %s\n", v, k) - } - } - - if failed { - os.Exit(1) - } -} - -func toolPath(name string) string { - p := filepath.Join(os.Getenv("GOROOT"), "bin", "tool", name) - if _, err := os.Stat(p); err != nil { - log.Fatalf("didn't find binary at %s", p) - } - return p -} - -func shardMatch(name string) bool { - if *shards == 0 { - return true - } - h := fnv.New32() - io.WriteString(h, name) - return int(h.Sum32()%uint32(*shards)) == *shard -} - -func goFiles(dir string) []string { - f, err := os.Open(dir) - check(err) - dirnames, err := f.Readdirnames(-1) - check(err) - names := []string{} - for _, name := range dirnames { - if !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".go") && shardMatch(name) { - names = append(names, name) - } - } - sort.Strings(names) - return names -} - -type runCmd func(...string) ([]byte, error) - -func compileFile(runcmd runCmd, longname string) (out []byte, err error) { - return runcmd("go", "tool", "compile", "-e", longname) -} - -func compileInDir(runcmd runCmd, dir string, names ...string) (out []byte, err error) { - cmd := []string{"go", "tool", "compile", "-e", "-D", ".", "-I", "."} - for _, name := range names { - cmd = append(cmd, filepath.Join(dir, name)) - } - return runcmd(cmd...) -} - -func linkFile(runcmd runCmd, goname string) (err error) { - pfile := strings.Replace(goname, ".go", ".o", -1) - _, err = runcmd("go", "tool", "link", "-w", "-o", "a.exe", "-L", ".", pfile) - return -} - -// skipError describes why a test was skipped. -type skipError string - -func (s skipError) Error() string { return string(s) } - -func check(err error) { - if err != nil { - log.Fatal(err) - } -} - -// test holds the state of a test. -type test struct { - dir, gofile string - donec chan bool // closed when done - dt time.Duration - - src string - action string // "compile", "build", etc. - - tempDir string - err error -} - -// startTest -func startTest(dir, gofile string) *test { - t := &test{ - dir: dir, - gofile: gofile, - donec: make(chan bool, 1), - } - if toRun == nil { - toRun = make(chan *test, maxTests) - go runTests() - } - select { - case toRun <- t: - default: - panic("toRun buffer size (maxTests) is too small") - } - return t -} - -// runTests runs tests in parallel, but respecting the order they -// were enqueued on the toRun channel. -func runTests() { - for { - ratec <- true - t := <-toRun - go func() { - t.run() - <-ratec - }() - } -} - -var cwd, _ = os.Getwd() - -func (t *test) goFileName() string { - return filepath.Join(t.dir, t.gofile) -} - -func (t *test) goDirName() string { - return filepath.Join(t.dir, strings.Replace(t.gofile, ".go", ".dir", -1)) -} - -func goDirFiles(longdir string) (filter []os.FileInfo, err error) { - files, dirErr := ioutil.ReadDir(longdir) - if dirErr != nil { - return nil, dirErr - } - for _, gofile := range files { - if filepath.Ext(gofile.Name()) == ".go" { - filter = append(filter, gofile) - } - } - return -} - -var packageRE = regexp.MustCompile(`(?m)^package (\w+)`) - -func goDirPackages(longdir string) ([][]string, error) { - files, err := goDirFiles(longdir) - if err != nil { - return nil, err - } - var pkgs [][]string - m := make(map[string]int) - for _, file := range files { - name := file.Name() - data, err := ioutil.ReadFile(filepath.Join(longdir, name)) - if err != nil { - return nil, err - } - pkgname := packageRE.FindStringSubmatch(string(data)) - if pkgname == nil { - return nil, fmt.Errorf("cannot find package name in %s", name) - } - i, ok := m[pkgname[1]] - if !ok { - i = len(pkgs) - pkgs = append(pkgs, nil) - m[pkgname[1]] = i - } - pkgs[i] = append(pkgs[i], name) - } - return pkgs, nil -} - -type context struct { - GOOS string - GOARCH string -} - -// shouldTest looks for build tags in a source file and returns -// whether the file should be used according to the tags. -func shouldTest(src string, goos, goarch string) (ok bool, whyNot string) { - // Custom rule, treat js as equivalent to nacl. - if goarch == "js" { - goarch = "nacl" - } - - for _, line := range strings.Split(src, "\n") { - line = strings.TrimSpace(line) - if strings.HasPrefix(line, "//") { - line = line[2:] - } else { - continue - } - line = strings.TrimSpace(line) - if len(line) == 0 || line[0] != '+' { - continue - } - ctxt := &context{ - GOOS: goos, - GOARCH: goarch, - } - words := strings.Fields(line) - if words[0] == "+build" { - ok := false - for _, word := range words[1:] { - if ctxt.match(word) { - ok = true - break - } - } - if !ok { - // no matching tag found. - return false, line - } - } - } - // no build tags - return true, "" -} - -func (ctxt *context) match(name string) bool { - if name == "" { - return false - } - if i := strings.Index(name, ","); i >= 0 { - // comma-separated list - return ctxt.match(name[:i]) && ctxt.match(name[i+1:]) - } - if strings.HasPrefix(name, "!!") { // bad syntax, reject always - return false - } - if strings.HasPrefix(name, "!") { // negation - return len(name) > 1 && !ctxt.match(name[1:]) - } - - // Tags must be letters, digits, underscores or dots. - // Unlike in Go identifiers, all digits are fine (e.g., "386"). - for _, c := range name { - if !unicode.IsLetter(c) && !unicode.IsDigit(c) && c != '_' && c != '.' { - return false - } - } - - if name == ctxt.GOOS || name == ctxt.GOARCH { - return true - } - - return false -} - -func init() { checkShouldTest() } - -// run runs a test. -func (t *test) run() { - start := time.Now() - defer func() { - t.dt = time.Since(start) - close(t.donec) - }() - - srcBytes, err := ioutil.ReadFile(t.goFileName()) - if err != nil { - t.err = err - return - } - t.src = string(srcBytes) - if t.src[0] == '\n' { - t.err = skipError("starts with newline") - return - } - - // Execution recipe stops at first blank line. - pos := strings.Index(t.src, "\n\n") - if pos == -1 { - t.err = errors.New("double newline not found") - return - } - action := t.src[:pos] - if nl := strings.Index(action, "\n"); nl >= 0 && strings.Contains(action[:nl], "+build") { - // skip first line - action = action[nl+1:] - } - if strings.HasPrefix(action, "//") { - action = action[2:] - } - - // Check for build constraints only up to the actual code. - pkgPos := strings.Index(t.src, "\npackage") - if pkgPos == -1 { - pkgPos = pos // some files are intentionally malformed - } - if ok, why := shouldTest(t.src[:pkgPos], goos, goarch); !ok { - t.action = "skip" - if *showSkips { - fmt.Printf("%-20s %-20s: %s\n", t.action, t.goFileName(), why) - } - return - } - - var args, flags []string - wantError := false - f := strings.Fields(action) - if len(f) > 0 { - action = f[0] - args = f[1:] - } - - // GOPHERJS: For now, only run with "run", "cmpout" actions, in "fixedbugs" dir. Skip all others. - switch action { - case "run", "cmpout": - if filepath.Clean(t.dir) != "fixedbugs" { - action = "skip" - } - default: - action = "skip" - } - - switch action { - case "rundircmpout": - action = "rundir" - t.action = "rundir" - case "cmpout": - action = "run" // the run case already looks for /.out files - fallthrough - case "compile", "compiledir", "build", "run", "runoutput", "rundir": - t.action = action - case "errorcheck", "errorcheckdir", "errorcheckoutput": - t.action = action - wantError = true - for len(args) > 0 && strings.HasPrefix(args[0], "-") { - if args[0] == "-0" { - wantError = false - } else { - flags = append(flags, args[0]) - } - args = args[1:] - } - case "skip": - t.action = "skip" - return - default: - t.err = skipError("skipped; unknown pattern: " + action) - t.action = "??" - return - } - - t.makeTempDir() - defer os.RemoveAll(t.tempDir) - - err = ioutil.WriteFile(filepath.Join(t.tempDir, t.gofile), srcBytes, 0644) - check(err) - - // A few tests (of things like the environment) require these to be set. - if os.Getenv("GOOS") == "" { - os.Setenv("GOOS", runtime.GOOS) - } - if os.Getenv("GOARCH") == "" { - os.Setenv("GOARCH", runtime.GOARCH) - } - - useTmp := true - runcmd := func(args ...string) ([]byte, error) { - cmd := exec.Command(args[0], args[1:]...) - var buf bytes.Buffer - cmd.Stdout = &buf - cmd.Stderr = &buf - if useTmp { - cmd.Dir = t.tempDir - cmd.Env = envForDir(cmd.Dir) - } - err := cmd.Run() - if err != nil { - err = fmt.Errorf("%s\n%s", err, buf.Bytes()) - } - return buf.Bytes(), err - } - - long := filepath.Join(cwd, t.goFileName()) - switch action { - default: - t.err = fmt.Errorf("unimplemented action %q", action) - - case "errorcheck": - cmdline := []string{"go", "tool", "compile", "-e", "-o", "a.o"} - cmdline = append(cmdline, flags...) - cmdline = append(cmdline, long) - out, err := runcmd(cmdline...) - if wantError { - if err == nil { - t.err = fmt.Errorf("compilation succeeded unexpectedly\n%s", out) - return - } - } else { - if err != nil { - t.err = err - return - } - } - if *updateErrors { - t.updateErrors(string(out), long) - } - t.err = t.errorCheck(string(out), long, t.gofile) - return - - case "compile": - _, t.err = compileFile(runcmd, long) - - case "compiledir": - // Compile all files in the directory in lexicographic order. - longdir := filepath.Join(cwd, t.goDirName()) - pkgs, err := goDirPackages(longdir) - if err != nil { - t.err = err - return - } - for _, gofiles := range pkgs { - _, t.err = compileInDir(runcmd, longdir, gofiles...) - if t.err != nil { - return - } - } - - case "errorcheckdir": - // errorcheck all files in lexicographic order - // useful for finding importing errors - longdir := filepath.Join(cwd, t.goDirName()) - pkgs, err := goDirPackages(longdir) - if err != nil { - t.err = err - return - } - for i, gofiles := range pkgs { - out, err := compileInDir(runcmd, longdir, gofiles...) - if i == len(pkgs)-1 { - if wantError && err == nil { - t.err = fmt.Errorf("compilation succeeded unexpectedly\n%s", out) - return - } else if !wantError && err != nil { - t.err = err - return - } - } else if err != nil { - t.err = err - return - } - var fullshort []string - for _, name := range gofiles { - fullshort = append(fullshort, filepath.Join(longdir, name), name) - } - t.err = t.errorCheck(string(out), fullshort...) - if t.err != nil { - break - } - } - - case "rundir": - // Compile all files in the directory in lexicographic order. - // then link as if the last file is the main package and run it - longdir := filepath.Join(cwd, t.goDirName()) - pkgs, err := goDirPackages(longdir) - if err != nil { - t.err = err - return - } - for i, gofiles := range pkgs { - _, err := compileInDir(runcmd, longdir, gofiles...) - if err != nil { - t.err = err - return - } - if i == len(pkgs)-1 { - err = linkFile(runcmd, gofiles[0]) - if err != nil { - t.err = err - return - } - var cmd []string - cmd = append(cmd, findExecCmd()...) - cmd = append(cmd, filepath.Join(t.tempDir, "a.exe")) - cmd = append(cmd, args...) - out, err := runcmd(cmd...) - if err != nil { - t.err = err - return - } - if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() { - t.err = fmt.Errorf("incorrect output\n%s", out) - } - } - } - - case "build": - _, err := runcmd("go", "build", "-o", "a.exe", long) - if err != nil { - t.err = err - } - - case "run": - useTmp = false - // GOPHERJS. - out, err := runcmd(append([]string{"gopherjs", "run", "-q", t.goFileName()}, args...)...) - if err != nil { - t.err = err - return - } - if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() { - t.err = fmt.Errorf("incorrect output\n%s", out) - } - - case "runoutput": - rungatec <- true - defer func() { - <-rungatec - }() - useTmp = false - out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...) - if err != nil { - t.err = err - return - } - tfile := filepath.Join(t.tempDir, "tmp__.go") - if err := ioutil.WriteFile(tfile, out, 0666); err != nil { - t.err = fmt.Errorf("write tempfile:%s", err) - return - } - out, err = runcmd("go", "run", tfile) - if err != nil { - t.err = err - return - } - if string(out) != t.expectedOutput() { - t.err = fmt.Errorf("incorrect output\n%s", out) - } - - case "errorcheckoutput": - useTmp = false - out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...) - if err != nil { - t.err = err - return - } - tfile := filepath.Join(t.tempDir, "tmp__.go") - err = ioutil.WriteFile(tfile, out, 0666) - if err != nil { - t.err = fmt.Errorf("write tempfile:%s", err) - return - } - cmdline := []string{"go", "tool", "compile", "-e", "-o", "a.o"} - cmdline = append(cmdline, flags...) - cmdline = append(cmdline, tfile) - out, err = runcmd(cmdline...) - if wantError { - if err == nil { - t.err = fmt.Errorf("compilation succeeded unexpectedly\n%s", out) - return - } - } else { - if err != nil { - t.err = err - return - } - } - t.err = t.errorCheck(string(out), tfile, "tmp__.go") - return - } -} - -var execCmd []string - -func findExecCmd() []string { - if execCmd != nil { - return execCmd - } - execCmd = []string{} // avoid work the second time - if goos == runtime.GOOS && goarch == runtime.GOARCH { - return execCmd - } - path, err := exec.LookPath(fmt.Sprintf("go_%s_%s_exec", goos, goarch)) - if err == nil { - execCmd = []string{path} - } - return execCmd -} - -func (t *test) String() string { - return filepath.Join(t.dir, t.gofile) -} - -func (t *test) makeTempDir() { - var err error - t.tempDir, err = ioutil.TempDir("", "") - check(err) -} - -func (t *test) expectedOutput() string { - filename := filepath.Join(t.dir, t.gofile) - filename = filename[:len(filename)-len(".go")] - filename += ".out" - b, _ := ioutil.ReadFile(filename) - return string(b) -} - -func splitOutput(out string) []string { - // gc error messages continue onto additional lines with leading tabs. - // Split the output at the beginning of each line that doesn't begin with a tab. - // lines are impossible to match so those are filtered out. - var res []string - for _, line := range strings.Split(out, "\n") { - if strings.HasSuffix(line, "\r") { // remove '\r', output by compiler on windows - line = line[:len(line)-1] - } - if strings.HasPrefix(line, "\t") { - res[len(res)-1] += "\n" + line - } else if strings.HasPrefix(line, "go tool") || strings.HasPrefix(line, "") { - continue - } else if strings.TrimSpace(line) != "" { - res = append(res, line) - } - } - return res -} - -func (t *test) errorCheck(outStr string, fullshort ...string) (err error) { - defer func() { - if *verbose && err != nil { - log.Printf("%s gc output:\n%s", t, outStr) - } - }() - var errs []error - out := splitOutput(outStr) - - // Cut directory name. - for i := range out { - for j := 0; j < len(fullshort); j += 2 { - full, short := fullshort[j], fullshort[j+1] - out[i] = strings.Replace(out[i], full, short, -1) - } - } - - var want []wantedError - for j := 0; j < len(fullshort); j += 2 { - full, short := fullshort[j], fullshort[j+1] - want = append(want, t.wantedErrors(full, short)...) - } - - for _, we := range want { - var errmsgs []string - errmsgs, out = partitionStrings(we.prefix, out) - if len(errmsgs) == 0 { - errs = append(errs, fmt.Errorf("%s:%d: missing error %q", we.file, we.lineNum, we.reStr)) - continue - } - matched := false - n := len(out) - for _, errmsg := range errmsgs { - if we.re.MatchString(errmsg) { - matched = true - } else { - out = append(out, errmsg) - } - } - if !matched { - errs = append(errs, fmt.Errorf("%s:%d: no match for %#q in:\n\t%s", we.file, we.lineNum, we.reStr, strings.Join(out[n:], "\n\t"))) - continue - } - } - - if len(out) > 0 { - errs = append(errs, fmt.Errorf("Unmatched Errors:")) - for _, errLine := range out { - errs = append(errs, fmt.Errorf("%s", errLine)) - } - } - - if len(errs) == 0 { - return nil - } - if len(errs) == 1 { - return errs[0] - } - var buf bytes.Buffer - fmt.Fprintf(&buf, "\n") - for _, err := range errs { - fmt.Fprintf(&buf, "%s\n", err.Error()) - } - return errors.New(buf.String()) -} - -func (t *test) updateErrors(out string, file string) { - // Read in source file. - src, err := ioutil.ReadFile(file) - if err != nil { - fmt.Fprintln(os.Stderr, err) - return - } - lines := strings.Split(string(src), "\n") - // Remove old errors. - for i, ln := range lines { - pos := strings.Index(ln, " // ERROR ") - if pos >= 0 { - lines[i] = ln[:pos] - } - } - // Parse new errors. - errors := make(map[int]map[string]bool) - tmpRe := regexp.MustCompile(`autotmp_[0-9]+`) - for _, errStr := range splitOutput(out) { - colon1 := strings.Index(errStr, ":") - if colon1 < 0 || errStr[:colon1] != file { - continue - } - colon2 := strings.Index(errStr[colon1+1:], ":") - if colon2 < 0 { - continue - } - colon2 += colon1 + 1 - line, err := strconv.Atoi(errStr[colon1+1 : colon2]) - line-- - if err != nil || line < 0 || line >= len(lines) { - continue - } - msg := errStr[colon2+2:] - for _, r := range []string{`\`, `*`, `+`, `[`, `]`, `(`, `)`} { - msg = strings.Replace(msg, r, `\`+r, -1) - } - msg = strings.Replace(msg, `"`, `.`, -1) - msg = tmpRe.ReplaceAllLiteralString(msg, `autotmp_[0-9]+`) - if errors[line] == nil { - errors[line] = make(map[string]bool) - } - errors[line][msg] = true - } - // Add new errors. - for line, errs := range errors { - var sorted []string - for e := range errs { - sorted = append(sorted, e) - } - sort.Strings(sorted) - lines[line] += " // ERROR" - for _, e := range sorted { - lines[line] += fmt.Sprintf(` "%s$"`, e) - } - } - // Write new file. - err = ioutil.WriteFile(file, []byte(strings.Join(lines, "\n")), 0640) - if err != nil { - fmt.Fprintln(os.Stderr, err) - return - } - // Polish. - exec.Command("go", "fmt", file).CombinedOutput() -} - -// matchPrefix reports whether s is of the form ^(.*/)?prefix(:|[), -// That is, it needs the file name prefix followed by a : or a [, -// and possibly preceded by a directory name. -func matchPrefix(s, prefix string) bool { - i := strings.Index(s, ":") - if i < 0 { - return false - } - j := strings.LastIndex(s[:i], "/") - s = s[j+1:] - if len(s) <= len(prefix) || s[:len(prefix)] != prefix { - return false - } - switch s[len(prefix)] { - case '[', ':': - return true - } - return false -} - -func partitionStrings(prefix string, strs []string) (matched, unmatched []string) { - for _, s := range strs { - if matchPrefix(s, prefix) { - matched = append(matched, s) - } else { - unmatched = append(unmatched, s) - } - } - return -} - -type wantedError struct { - reStr string - re *regexp.Regexp - lineNum int - file string - prefix string -} - -var ( - errRx = regexp.MustCompile(`// (?:GC_)?ERROR (.*)`) - errQuotesRx = regexp.MustCompile(`"([^"]*)"`) - lineRx = regexp.MustCompile(`LINE(([+-])([0-9]+))?`) -) - -func (t *test) wantedErrors(file, short string) (errs []wantedError) { - cache := make(map[string]*regexp.Regexp) - - src, _ := ioutil.ReadFile(file) - for i, line := range strings.Split(string(src), "\n") { - lineNum := i + 1 - if strings.Contains(line, "////") { - // double comment disables ERROR - continue - } - m := errRx.FindStringSubmatch(line) - if m == nil { - continue - } - all := m[1] - mm := errQuotesRx.FindAllStringSubmatch(all, -1) - if mm == nil { - log.Fatalf("%s:%d: invalid errchk line: %s", t.goFileName(), lineNum, line) - } - for _, m := range mm { - rx := lineRx.ReplaceAllStringFunc(m[1], func(m string) string { - n := lineNum - if strings.HasPrefix(m, "LINE+") { - delta, _ := strconv.Atoi(m[5:]) - n += delta - } else if strings.HasPrefix(m, "LINE-") { - delta, _ := strconv.Atoi(m[5:]) - n -= delta - } - return fmt.Sprintf("%s:%d", short, n) - }) - re := cache[rx] - if re == nil { - var err error - re, err = regexp.Compile(rx) - if err != nil { - log.Fatalf("%s:%d: invalid regexp \"%s\" in ERROR line: %v", t.goFileName(), lineNum, rx, err) - } - cache[rx] = re - } - prefix := fmt.Sprintf("%s:%d", short, lineNum) - errs = append(errs, wantedError{ - reStr: rx, - re: re, - prefix: prefix, - lineNum: lineNum, - file: short, - }) - } - } - - return -} - -// defaultRunOutputLimit returns the number of runoutput tests that -// can be executed in parallel. -func defaultRunOutputLimit() int { - const maxArmCPU = 2 - - cpu := runtime.NumCPU() - if runtime.GOARCH == "arm" && cpu > maxArmCPU { - cpu = maxArmCPU - } - return cpu -} - -// checkShouldTest runs sanity checks on the shouldTest function. -func checkShouldTest() { - assert := func(ok bool, _ string) { - if !ok { - panic("fail") - } - } - assertNot := func(ok bool, _ string) { assert(!ok, "") } - - // Simple tests. - assert(shouldTest("// +build linux", "linux", "arm")) - assert(shouldTest("// +build !windows", "linux", "arm")) - assertNot(shouldTest("// +build !windows", "windows", "amd64")) - - // A file with no build tags will always be tested. - assert(shouldTest("// This is a test.", "os", "arch")) - - // Build tags separated by a space are OR-ed together. - assertNot(shouldTest("// +build arm 386", "linux", "amd64")) - - // Build tags separated by a comma are AND-ed together. - assertNot(shouldTest("// +build !windows,!plan9", "windows", "amd64")) - assertNot(shouldTest("// +build !windows,!plan9", "plan9", "386")) - - // Build tags on multiple lines are AND-ed together. - assert(shouldTest("// +build !windows\n// +build amd64", "linux", "amd64")) - assertNot(shouldTest("// +build !windows\n// +build amd64", "windows", "amd64")) - - // Test that (!a OR !b) matches anything. - assert(shouldTest("// +build !windows !plan9", "windows", "amd64")) - - // GOPHERJS: Custom rule, test that don't run on nacl should also not run on js. - assertNot(shouldTest("// +build !nacl,!plan9,!windows", "darwin", "js")) -} - -// envForDir returns a copy of the environment -// suitable for running in the given directory. -// The environment is the current process's environment -// but with an updated $PWD, so that an os.Getwd in the -// child will be faster. -func envForDir(dir string) []string { - env := os.Environ() - for i, kv := range env { - if strings.HasPrefix(kv, "PWD=") { - env[i] = "PWD=" + dir - return env - } - } - env = append(env, "PWD="+dir) - return env -} - -func getenv(key, def string) string { - value := os.Getenv(key) - if value != "" { - return value - } - return def -} diff --git a/vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.go b/vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.go deleted file mode 100644 index fe7c064f8..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.go +++ /dev/null @@ -1,19 +0,0 @@ -package main - -import ( - "time" - - "github.com/gopherjs/gopherjs/js" -) - -var _ = time.Sleep // Force "time" package to be imported but let time.Time and time.Unix be DCEed since they're not used. - -func main() { - // Excercise externalization of Go struct (with its special handling of time.Time). - js.Global.Get("console").Call("log", struct{ S string }{"externalization ok"}) - - // Excercise internalization of JavaScript Date object (with its special handling of time.Time). - date := js.Global.Get("Date").New("2015-08-29T20:56:00.869Z").Interface() - js.Global.Set("myDate", date) - js.Global.Get("console").Call("log", js.Global.Get("myDate").Call("toUTCString")) -} diff --git a/vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.out b/vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.out deleted file mode 100644 index 471c023ad..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.out +++ /dev/null @@ -1,2 +0,0 @@ -{ S: 'externalization ok' } -Sat, 29 Aug 2015 20:56:00 GMT diff --git a/vendor/github.com/gopherjs/gopherjs/tests/vendor/vendored/vendored.go b/vendor/github.com/gopherjs/gopherjs/tests/vendor/vendored/vendored.go deleted file mode 100644 index f1e32d227..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tests/vendor/vendored/vendored.go +++ /dev/null @@ -1,3 +0,0 @@ -package vendored - -var Answer = 42 diff --git a/vendor/github.com/gopherjs/gopherjs/third_party/importer/export.go b/vendor/github.com/gopherjs/gopherjs/third_party/importer/export.go deleted file mode 100644 index f0777f1ba..000000000 --- a/vendor/github.com/gopherjs/gopherjs/third_party/importer/export.go +++ /dev/null @@ -1,461 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package importer - -import ( - "bytes" - "encoding/binary" - "fmt" - "go/ast" - "go/constant" - "go/types" - "strings" -) - -// debugging support -const ( - debug = false // emit debugging data - trace = false // print emitted data -) - -// format returns a byte indicating the low-level encoding/decoding format -// (debug vs product). -func format() byte { - if debug { - return 'd' - } - return 'p' -} - -// ExportData serializes the interface (exported package objects) -// of package pkg and returns the corresponding data. The export -// format is described elsewhere (TODO). -func ExportData(pkg *types.Package) []byte { - p := exporter{ - data: append([]byte(magic), format()), - pkgIndex: make(map[*types.Package]int), - typIndex: make(map[types.Type]int), - } - - // populate typIndex with predeclared types - for _, t := range predeclared { - p.typIndex[t] = len(p.typIndex) - } - - if trace { - p.tracef("export %s\n", pkg.Name()) - defer p.tracef("\n") - } - - p.string(version) - - p.pkg(pkg) - - // collect exported objects from package scope - var list []types.Object - scope := pkg.Scope() - for _, name := range scope.Names() { - if exported(name) { - list = append(list, scope.Lookup(name)) - } - } - - // write objects - p.int(len(list)) - for _, obj := range list { - p.obj(obj) - } - - return p.data -} - -type exporter struct { - data []byte - pkgIndex map[*types.Package]int - typIndex map[types.Type]int - - // tracing support - indent string -} - -func (p *exporter) pkg(pkg *types.Package) { - if trace { - p.tracef("package { ") - defer p.tracef("} ") - } - - if pkg == nil { - panic("unexpected nil pkg") - } - - // if the package was seen before, write its index (>= 0) - if i, ok := p.pkgIndex[pkg]; ok { - p.int(i) - return - } - p.pkgIndex[pkg] = len(p.pkgIndex) - - // otherwise, write the package tag (< 0) and package data - p.int(packageTag) - p.string(pkg.Name()) - p.string(pkg.Path()) -} - -func (p *exporter) obj(obj types.Object) { - if trace { - p.tracef("object %s {\n", obj.Name()) - defer p.tracef("}\n") - } - - switch obj := obj.(type) { - case *types.Const: - p.int(constTag) - p.string(obj.Name()) - p.typ(obj.Type()) - p.value(obj.Val()) - case *types.TypeName: - p.int(typeTag) - // name is written by corresponding named type - p.typ(obj.Type().(*types.Named)) - case *types.Var: - p.int(varTag) - p.string(obj.Name()) - p.typ(obj.Type()) - case *types.Func: - p.int(funcTag) - p.string(obj.Name()) - p.typ(obj.Type()) - default: - panic(fmt.Sprintf("unexpected object type %T", obj)) - } -} - -func (p *exporter) value(x constant.Value) { - if trace { - p.tracef("value { ") - defer p.tracef("} ") - } - - switch kind := x.Kind(); kind { - case constant.Bool: - tag := falseTag - if constant.BoolVal(x) { - tag = trueTag - } - p.int(tag) - case constant.Int: - if i, ok := constant.Int64Val(x); ok { - p.int(int64Tag) - p.int64(i) - return - } - p.int(floatTag) - p.float(x) - case constant.Float: - p.int(fractionTag) - p.fraction(x) - case constant.Complex: - p.int(complexTag) - p.fraction(constant.Real(x)) - p.fraction(constant.Imag(x)) - case constant.String: - p.int(stringTag) - p.string(constant.StringVal(x)) - default: - panic(fmt.Sprintf("unexpected value kind %d", kind)) - } -} - -func (p *exporter) float(x constant.Value) { - sign := constant.Sign(x) - p.int(sign) - if sign == 0 { - return - } - - p.ufloat(x) -} - -func (p *exporter) fraction(x constant.Value) { - sign := constant.Sign(x) - p.int(sign) - if sign == 0 { - return - } - - p.ufloat(constant.Num(x)) - p.ufloat(constant.Denom(x)) -} - -// ufloat writes abs(x) in form of a binary exponent -// followed by its mantissa bytes; x must be != 0. -func (p *exporter) ufloat(x constant.Value) { - mant := constant.Bytes(x) - exp8 := -1 - for i, b := range mant { - if b != 0 { - exp8 = i - break - } - } - if exp8 < 0 { - panic(fmt.Sprintf("%s has no mantissa", x)) - } - p.int(exp8 * 8) - p.bytes(mant[exp8:]) -} - -func (p *exporter) typ(typ types.Type) { - if trace { - p.tracef("type {\n") - defer p.tracef("}\n") - } - - // if the type was seen before, write its index (>= 0) - if i, ok := p.typIndex[typ]; ok { - p.int(i) - return - } - p.typIndex[typ] = len(p.typIndex) - - // otherwise, write the type tag (< 0) and type data - switch t := typ.(type) { - case *types.Array: - p.int(arrayTag) - p.int64(t.Len()) - p.typ(t.Elem()) - - case *types.Slice: - p.int(sliceTag) - p.typ(t.Elem()) - - case *types.Struct: - p.int(structTag) - n := t.NumFields() - p.int(n) - for i := 0; i < n; i++ { - p.field(t.Field(i)) - p.string(t.Tag(i)) - } - - case *types.Pointer: - p.int(pointerTag) - p.typ(t.Elem()) - - case *types.Signature: - p.int(signatureTag) - p.signature(t) - - case *types.Interface: - p.int(interfaceTag) - - // write embedded interfaces - m := t.NumEmbeddeds() - p.int(m) - for i := 0; i < m; i++ { - p.typ(t.Embedded(i)) - } - - // write methods - n := t.NumExplicitMethods() - p.int(n) - for i := 0; i < n; i++ { - m := t.ExplicitMethod(i) - p.qualifiedName(m.Pkg(), m.Name()) - p.typ(m.Type()) - } - - case *types.Map: - p.int(mapTag) - p.typ(t.Key()) - p.typ(t.Elem()) - - case *types.Chan: - p.int(chanTag) - p.int(int(t.Dir())) - p.typ(t.Elem()) - - case *types.Named: - p.int(namedTag) - - // write type object - obj := t.Obj() - p.string(obj.Name()) - p.pkg(obj.Pkg()) - - // write underlying type - p.typ(t.Underlying()) - - // write associated methods - n := t.NumMethods() - p.int(n) - for i := 0; i < n; i++ { - m := t.Method(i) - p.string(m.Name()) - p.typ(m.Type()) - } - - default: - panic("unreachable") - } -} - -func (p *exporter) field(f *types.Var) { - // anonymous fields have "" name - name := "" - if !f.Anonymous() { - name = f.Name() - } - - // qualifiedName will always emit the field package for - // anonymous fields because "" is not an exported name. - p.qualifiedName(f.Pkg(), name) - p.typ(f.Type()) -} - -func (p *exporter) qualifiedName(pkg *types.Package, name string) { - p.string(name) - // exported names don't need package - if !exported(name) { - if pkg == nil { - panic(fmt.Sprintf("nil package for unexported qualified name %s", name)) - } - p.pkg(pkg) - } -} - -func (p *exporter) signature(sig *types.Signature) { - // We need the receiver information (T vs *T) - // for methods associated with named types. - // We do not record interface receiver types in the - // export data because 1) the importer can derive them - // from the interface type and 2) they create cycles - // in the type graph. - if recv := sig.Recv(); recv != nil { - if _, ok := recv.Type().Underlying().(*types.Interface); !ok { - // 1-element tuple - p.int(1) - p.param(recv) - } else { - // 0-element tuple - p.int(0) - } - } else { - // 0-element tuple - p.int(0) - } - p.tuple(sig.Params()) - p.tuple(sig.Results()) - if sig.Variadic() { - p.int(1) - } else { - p.int(0) - } -} - -func (p *exporter) param(v *types.Var) { - p.string(v.Name()) - p.typ(v.Type()) -} - -func (p *exporter) tuple(t *types.Tuple) { - n := t.Len() - p.int(n) - for i := 0; i < n; i++ { - p.param(t.At(i)) - } -} - -// ---------------------------------------------------------------------------- -// encoders - -func (p *exporter) string(s string) { - p.bytes([]byte(s)) // (could be inlined if extra allocation matters) -} - -func (p *exporter) int(x int) { - p.int64(int64(x)) -} - -func (p *exporter) int64(x int64) { - if debug { - p.marker('i') - } - - if trace { - p.tracef("%d ", x) - } - - p.rawInt64(x) -} - -func (p *exporter) bytes(b []byte) { - if debug { - p.marker('b') - } - - if trace { - p.tracef("%q ", b) - } - - p.rawInt64(int64(len(b))) - if len(b) > 0 { - p.data = append(p.data, b...) - } -} - -// marker emits a marker byte and position information which makes -// it easy for a reader to detect if it is "out of sync". Used for -// debug format only. -func (p *exporter) marker(m byte) { - if debug { - p.data = append(p.data, m) - p.rawInt64(int64(len(p.data))) - } -} - -// rawInt64 should only be used by low-level encoders -func (p *exporter) rawInt64(x int64) { - var tmp [binary.MaxVarintLen64]byte - n := binary.PutVarint(tmp[:], x) - p.data = append(p.data, tmp[:n]...) -} - -// utility functions - -func (p *exporter) tracef(format string, args ...interface{}) { - // rewrite format string to take care of indentation - const indent = ". " - if strings.ContainsAny(format, "{}\n") { - var buf bytes.Buffer - for i := 0; i < len(format); i++ { - // no need to deal with runes - ch := format[i] - switch ch { - case '{': - p.indent += indent - case '}': - p.indent = p.indent[:len(p.indent)-len(indent)] - if i+1 < len(format) && format[i+1] == '\n' { - buf.WriteByte('\n') - buf.WriteString(p.indent) - buf.WriteString("} ") - i++ - continue - } - } - buf.WriteByte(ch) - if ch == '\n' { - buf.WriteString(p.indent) - } - } - format = buf.String() - } - fmt.Printf(format, args...) -} - -func exported(name string) bool { - return ast.IsExported(name) -} diff --git a/vendor/github.com/gopherjs/gopherjs/third_party/importer/import.go b/vendor/github.com/gopherjs/gopherjs/third_party/importer/import.go deleted file mode 100644 index 51470bd1b..000000000 --- a/vendor/github.com/gopherjs/gopherjs/third_party/importer/import.go +++ /dev/null @@ -1,453 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This implementation is loosely based on the algorithm described -// in: "On the linearization of graphs and writing symbol files", -// by R. Griesemer, Technical Report 156, ETH Zürich, 1991. - -// package importer implements an exporter and importer for Go export data. -package importer - -import ( - "encoding/binary" - "fmt" - "go/constant" - "go/token" - "go/types" -) - -// ImportData imports a package from the serialized package data -// and returns the number of bytes consumed and a reference to the package. -// If data is obviously malformed, an error is returned but in -// general it is not recommended to call ImportData on untrusted -// data. -func ImportData(imports map[string]*types.Package, data []byte) (int, *types.Package, error) { - datalen := len(data) - - // check magic string - var s string - if len(data) >= len(magic) { - s = string(data[:len(magic)]) - data = data[len(magic):] - } - if s != magic { - return 0, nil, fmt.Errorf("incorrect magic string: got %q; want %q", s, magic) - } - - // check low-level encoding format - var m byte = 'm' // missing format - if len(data) > 0 { - m = data[0] - data = data[1:] - } - if m != format() { - return 0, nil, fmt.Errorf("incorrect low-level encoding format: got %c; want %c", m, format()) - } - - p := importer{ - data: data, - datalen: datalen, - imports: imports, - } - - // populate typList with predeclared types - p.typList = append(p.typList, predeclared...) - - if v := p.string(); v != version { - return 0, nil, fmt.Errorf("unknown version: got %s; want %s", v, version) - } - - pkg := p.pkg() - if debug && p.pkgList[0] != pkg { - panic("imported packaged not found in pkgList[0]") - } - - // read objects - n := p.int() - for i := 0; i < n; i++ { - p.obj(pkg) - } - - // complete interfaces - for _, typ := range p.typList { - if it, ok := typ.(*types.Interface); ok { - it.Complete() - } - } - - // package was imported completely and without errors - pkg.MarkComplete() - - return p.consumed(), pkg, nil -} - -type importer struct { - data []byte - datalen int - imports map[string]*types.Package - pkgList []*types.Package - typList []types.Type -} - -func (p *importer) pkg() *types.Package { - // if the package was seen before, i is its index (>= 0) - i := p.int() - if i >= 0 { - return p.pkgList[i] - } - - // otherwise, i is the package tag (< 0) - if i != packageTag { - panic(fmt.Sprintf("unexpected package tag %d", i)) - } - - // read package data - name := p.string() - path := p.string() - - // if the package was imported before, use that one; otherwise create a new one - pkg := p.imports[path] - if pkg == nil { - pkg = types.NewPackage(path, name) - p.imports[path] = pkg - } - p.pkgList = append(p.pkgList, pkg) - - return pkg -} - -func (p *importer) obj(pkg *types.Package) { - var obj types.Object - switch tag := p.int(); tag { - case constTag: - obj = types.NewConst(token.NoPos, pkg, p.string(), p.typ(), p.value()) - case typeTag: - // type object is added to scope via respective named type - _ = p.typ().(*types.Named) - return - case varTag: - obj = types.NewVar(token.NoPos, pkg, p.string(), p.typ()) - case funcTag: - obj = types.NewFunc(token.NoPos, pkg, p.string(), p.typ().(*types.Signature)) - default: - panic(fmt.Sprintf("unexpected object tag %d", tag)) - } - - if alt := pkg.Scope().Insert(obj); alt != nil { - panic(fmt.Sprintf("%s already declared", alt.Name())) - } -} - -func (p *importer) value() constant.Value { - switch kind := constant.Kind(p.int()); kind { - case falseTag: - return constant.MakeBool(false) - case trueTag: - return constant.MakeBool(true) - case int64Tag: - return constant.MakeInt64(p.int64()) - case floatTag: - return p.float() - case fractionTag: - return p.fraction() - case complexTag: - re := p.fraction() - im := p.fraction() - return constant.BinaryOp(re, token.ADD, constant.MakeImag(im)) - case stringTag: - return constant.MakeString(p.string()) - default: - panic(fmt.Sprintf("unexpected value kind %d", kind)) - } -} - -func (p *importer) float() constant.Value { - sign := p.int() - if sign == 0 { - return constant.MakeInt64(0) - } - - x := p.ufloat() - if sign < 0 { - x = constant.UnaryOp(token.SUB, x, 0) - } - return x -} - -func (p *importer) fraction() constant.Value { - sign := p.int() - if sign == 0 { - return constant.MakeInt64(0) - } - - x := constant.BinaryOp(p.ufloat(), token.QUO, p.ufloat()) - if sign < 0 { - x = constant.UnaryOp(token.SUB, x, 0) - } - return x -} - -func (p *importer) ufloat() constant.Value { - exp := p.int() - x := constant.MakeFromBytes(p.bytes()) - switch { - case exp < 0: - d := constant.Shift(constant.MakeInt64(1), token.SHL, uint(-exp)) - x = constant.BinaryOp(x, token.QUO, d) - case exp > 0: - x = constant.Shift(x, token.SHL, uint(exp)) - } - return x -} - -func (p *importer) record(t types.Type) { - p.typList = append(p.typList, t) -} - -func (p *importer) typ() types.Type { - // if the type was seen before, i is its index (>= 0) - i := p.int() - if i >= 0 { - return p.typList[i] - } - - // otherwise, i is the type tag (< 0) - switch i { - case arrayTag: - t := new(types.Array) - p.record(t) - - n := p.int64() - *t = *types.NewArray(p.typ(), n) - return t - - case sliceTag: - t := new(types.Slice) - p.record(t) - - *t = *types.NewSlice(p.typ()) - return t - - case structTag: - t := new(types.Struct) - p.record(t) - - n := p.int() - fields := make([]*types.Var, n) - tags := make([]string, n) - for i := range fields { - fields[i] = p.field() - tags[i] = p.string() - } - *t = *types.NewStruct(fields, tags) - return t - - case pointerTag: - t := new(types.Pointer) - p.record(t) - - *t = *types.NewPointer(p.typ()) - return t - - case signatureTag: - t := new(types.Signature) - p.record(t) - - *t = *p.signature() - return t - - case interfaceTag: - // Create a dummy entry in the type list. This is safe because we - // cannot expect the interface type to appear in a cycle, as any - // such cycle must contain a named type which would have been - // first defined earlier. - n := len(p.typList) - p.record(nil) - - // read embedded interfaces - embeddeds := make([]*types.Named, p.int()) - for i := range embeddeds { - embeddeds[i] = p.typ().(*types.Named) - } - - // read methods - methods := make([]*types.Func, p.int()) - for i := range methods { - pkg, name := p.qualifiedName() - methods[i] = types.NewFunc(token.NoPos, pkg, name, p.typ().(*types.Signature)) - } - - t := types.NewInterface(methods, embeddeds) - p.typList[n] = t - return t - - case mapTag: - t := new(types.Map) - p.record(t) - - *t = *types.NewMap(p.typ(), p.typ()) - return t - - case chanTag: - t := new(types.Chan) - p.record(t) - - *t = *types.NewChan(types.ChanDir(p.int()), p.typ()) - return t - - case namedTag: - // read type object - name := p.string() - pkg := p.pkg() - scope := pkg.Scope() - obj := scope.Lookup(name) - - // if the object doesn't exist yet, create and insert it - if obj == nil { - obj = types.NewTypeName(token.NoPos, pkg, name, nil) - scope.Insert(obj) - } - - // associate new named type with obj if it doesn't exist yet - t0 := types.NewNamed(obj.(*types.TypeName), nil, nil) - - // but record the existing type, if any - t := obj.Type().(*types.Named) - p.record(t) - - // read underlying type - t0.SetUnderlying(p.typ()) - - // read associated methods - for i, n := 0, p.int(); i < n; i++ { - t0.AddMethod(types.NewFunc(token.NoPos, pkg, p.string(), p.typ().(*types.Signature))) - } - - return t - - default: - panic(fmt.Sprintf("unexpected type tag %d", i)) - } -} - -func deref(typ types.Type) types.Type { - if p, _ := typ.(*types.Pointer); p != nil { - return p.Elem() - } - return typ -} - -func (p *importer) field() *types.Var { - pkg, name := p.qualifiedName() - typ := p.typ() - - anonymous := false - if name == "" { - // anonymous field - typ must be T or *T and T must be a type name - switch typ := deref(typ).(type) { - case *types.Basic: // basic types are named types - pkg = nil - name = typ.Name() - case *types.Named: - obj := typ.Obj() - name = obj.Name() - // correct the field package for anonymous fields - if exported(name) { - pkg = p.pkgList[0] - } - default: - panic("anonymous field expected") - } - anonymous = true - } - - return types.NewField(token.NoPos, pkg, name, typ, anonymous) -} - -func (p *importer) qualifiedName() (*types.Package, string) { - name := p.string() - pkg := p.pkgList[0] // exported names assume current package - if !exported(name) { - pkg = p.pkg() - } - return pkg, name -} - -func (p *importer) signature() *types.Signature { - var recv *types.Var - if p.int() != 0 { - recv = p.param() - } - return types.NewSignature(recv, p.tuple(), p.tuple(), p.int() != 0) -} - -func (p *importer) param() *types.Var { - return types.NewVar(token.NoPos, nil, p.string(), p.typ()) -} - -func (p *importer) tuple() *types.Tuple { - vars := make([]*types.Var, p.int()) - for i := range vars { - vars[i] = p.param() - } - return types.NewTuple(vars...) -} - -// ---------------------------------------------------------------------------- -// decoders - -func (p *importer) string() string { - return string(p.bytes()) -} - -func (p *importer) int() int { - return int(p.int64()) -} - -func (p *importer) int64() int64 { - if debug { - p.marker('i') - } - - return p.rawInt64() -} - -// Note: bytes() returns the respective byte slice w/o copy. -func (p *importer) bytes() []byte { - if debug { - p.marker('b') - } - - var b []byte - if n := int(p.rawInt64()); n > 0 { - b = p.data[:n] - p.data = p.data[n:] - } - return b -} - -func (p *importer) marker(want byte) { - if debug { - if got := p.data[0]; got != want { - panic(fmt.Sprintf("incorrect marker: got %c; want %c (pos = %d)", got, want, p.consumed())) - } - p.data = p.data[1:] - - pos := p.consumed() - if n := int(p.rawInt64()); n != pos { - panic(fmt.Sprintf("incorrect position: got %d; want %d", n, pos)) - } - } -} - -// rawInt64 should only be used by low-level decoders -func (p *importer) rawInt64() int64 { - i, n := binary.Varint(p.data) - p.data = p.data[n:] - return i -} - -func (p *importer) consumed() int { - return p.datalen - len(p.data) -} diff --git a/vendor/github.com/gopherjs/gopherjs/third_party/importer/predefined.go b/vendor/github.com/gopherjs/gopherjs/third_party/importer/predefined.go deleted file mode 100644 index 69c38b76e..000000000 --- a/vendor/github.com/gopherjs/gopherjs/third_party/importer/predefined.go +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package importer - -import "go/types" - -const ( - magic = "\n$$ exports $$\n" - version = "v0" -) - -// Tags. Must be < 0. -const ( - // Packages - packageTag = -(iota + 1) - - // Objects - constTag - typeTag - varTag - funcTag - - // Types - arrayTag - sliceTag - structTag - pointerTag - signatureTag - interfaceTag - mapTag - chanTag - namedTag - - // Values - falseTag - trueTag - int64Tag - floatTag - fractionTag - complexTag - stringTag -) - -var predeclared = []types.Type{ - // basic types - types.Typ[types.Bool], - types.Typ[types.Int], - types.Typ[types.Int8], - types.Typ[types.Int16], - types.Typ[types.Int32], - types.Typ[types.Int64], - types.Typ[types.Uint], - types.Typ[types.Uint8], - types.Typ[types.Uint16], - types.Typ[types.Uint32], - types.Typ[types.Uint64], - types.Typ[types.Uintptr], - types.Typ[types.Float32], - types.Typ[types.Float64], - types.Typ[types.Complex64], - types.Typ[types.Complex128], - types.Typ[types.String], - - // untyped types - types.Typ[types.UntypedBool], - types.Typ[types.UntypedInt], - types.Typ[types.UntypedRune], - types.Typ[types.UntypedFloat], - types.Typ[types.UntypedComplex], - types.Typ[types.UntypedString], - types.Typ[types.UntypedNil], - - // package unsafe - types.Typ[types.UnsafePointer], - - // aliases - types.Universe.Lookup("byte").Type(), - types.Universe.Lookup("rune").Type(), - - // error - types.Universe.Lookup("error").Type(), -} diff --git a/vendor/github.com/gopherjs/gopherjs/tool.go b/vendor/github.com/gopherjs/gopherjs/tool.go deleted file mode 100644 index f129262c3..000000000 --- a/vendor/github.com/gopherjs/gopherjs/tool.go +++ /dev/null @@ -1,925 +0,0 @@ -package main - -import ( - "bytes" - "errors" - "fmt" - "go/ast" - "go/build" - "go/doc" - "go/parser" - "go/scanner" - "go/token" - "go/types" - "io" - "io/ioutil" - "net" - "net/http" - "os" - "os/exec" - "path" - "path/filepath" - "runtime" - "sort" - "strconv" - "strings" - "syscall" - "text/template" - "time" - "unicode" - "unicode/utf8" - - gbuild "github.com/gopherjs/gopherjs/build" - "github.com/gopherjs/gopherjs/compiler" - "github.com/kisielk/gotool" - "github.com/neelance/sourcemap" - "github.com/spf13/cobra" - "github.com/spf13/pflag" - "golang.org/x/crypto/ssh/terminal" -) - -var currentDirectory string - -func init() { - var err error - currentDirectory, err = os.Getwd() - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - currentDirectory, err = filepath.EvalSymlinks(currentDirectory) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - gopaths := filepath.SplitList(build.Default.GOPATH) - if len(gopaths) == 0 { - fmt.Fprintf(os.Stderr, "$GOPATH not set. For more details see: go help gopath\n") - os.Exit(1) - } -} - -func main() { - var ( - options = &gbuild.Options{CreateMapFile: true} - pkgObj string - tags string - ) - - flagVerbose := pflag.NewFlagSet("", 0) - flagVerbose.BoolVarP(&options.Verbose, "verbose", "v", false, "print the names of packages as they are compiled") - flagQuiet := pflag.NewFlagSet("", 0) - flagQuiet.BoolVarP(&options.Quiet, "quiet", "q", false, "suppress non-fatal warnings") - - compilerFlags := pflag.NewFlagSet("", 0) - compilerFlags.BoolVarP(&options.Minify, "minify", "m", false, "minify generated code") - compilerFlags.BoolVar(&options.Color, "color", terminal.IsTerminal(int(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb", "colored output") - compilerFlags.StringVar(&tags, "tags", "", "a list of build tags to consider satisfied during the build") - compilerFlags.BoolVar(&options.MapToLocalDisk, "localmap", false, "use local paths for sourcemap") - - flagWatch := pflag.NewFlagSet("", 0) - flagWatch.BoolVarP(&options.Watch, "watch", "w", false, "watch for changes to the source files") - - cmdBuild := &cobra.Command{ - Use: "build [packages]", - Short: "compile packages and dependencies", - } - cmdBuild.Flags().StringVarP(&pkgObj, "output", "o", "", "output file") - cmdBuild.Flags().AddFlagSet(flagVerbose) - cmdBuild.Flags().AddFlagSet(flagQuiet) - cmdBuild.Flags().AddFlagSet(compilerFlags) - cmdBuild.Flags().AddFlagSet(flagWatch) - cmdBuild.Run = func(cmd *cobra.Command, args []string) { - options.BuildTags = strings.Fields(tags) - for { - s := gbuild.NewSession(options) - - err := func() error { - // Handle "gopherjs build [files]" ad-hoc package mode. - if len(args) > 0 && (strings.HasSuffix(args[0], ".go") || strings.HasSuffix(args[0], ".inc.js")) { - for _, arg := range args { - if !strings.HasSuffix(arg, ".go") && !strings.HasSuffix(arg, ".inc.js") { - return fmt.Errorf("named files must be .go or .inc.js files") - } - } - if pkgObj == "" { - basename := filepath.Base(args[0]) - pkgObj = basename[:len(basename)-3] + ".js" - } - names := make([]string, len(args)) - for i, name := range args { - name = filepath.ToSlash(name) - names[i] = name - if s.Watcher != nil { - s.Watcher.Add(name) - } - } - if err := s.BuildFiles(args, pkgObj, currentDirectory); err != nil { - return err - } - return nil - } - - // Expand import path patterns. - patternContext := gbuild.NewBuildContext("", options.BuildTags) - pkgs := (&gotool.Context{BuildContext: *patternContext}).ImportPaths(args) - - for _, pkgPath := range pkgs { - if s.Watcher != nil { - pkg, err := gbuild.NewBuildContext(s.InstallSuffix(), options.BuildTags).Import(pkgPath, "", build.FindOnly) - if err != nil { - return err - } - s.Watcher.Add(pkg.Dir) - } - pkg, err := gbuild.Import(pkgPath, 0, s.InstallSuffix(), options.BuildTags) - if err != nil { - return err - } - archive, err := s.BuildPackage(pkg) - if err != nil { - return err - } - if len(pkgs) == 1 { // Only consider writing output if single package specified. - if pkgObj == "" { - pkgObj = filepath.Base(pkg.ImportPath) + ".js" - } - if pkg.IsCommand() && !pkg.UpToDate { - if err := s.WriteCommandPackage(archive, pkgObj); err != nil { - return err - } - } - } - } - return nil - }() - exitCode := handleError(err, options, nil) - - if s.Watcher == nil { - os.Exit(exitCode) - } - s.WaitForChange() - } - } - - cmdInstall := &cobra.Command{ - Use: "install [packages]", - Short: "compile and install packages and dependencies", - } - cmdInstall.Flags().AddFlagSet(flagVerbose) - cmdInstall.Flags().AddFlagSet(flagQuiet) - cmdInstall.Flags().AddFlagSet(compilerFlags) - cmdInstall.Flags().AddFlagSet(flagWatch) - cmdInstall.Run = func(cmd *cobra.Command, args []string) { - options.BuildTags = strings.Fields(tags) - for { - s := gbuild.NewSession(options) - - err := func() error { - // Expand import path patterns. - patternContext := gbuild.NewBuildContext("", options.BuildTags) - pkgs := (&gotool.Context{BuildContext: *patternContext}).ImportPaths(args) - - if cmd.Name() == "get" { - goGet := exec.Command("go", append([]string{"get", "-d", "-tags=js"}, pkgs...)...) - goGet.Stdout = os.Stdout - goGet.Stderr = os.Stderr - if err := goGet.Run(); err != nil { - return err - } - } - for _, pkgPath := range pkgs { - pkg, err := gbuild.Import(pkgPath, 0, s.InstallSuffix(), options.BuildTags) - if s.Watcher != nil && pkg != nil { // add watch even on error - s.Watcher.Add(pkg.Dir) - } - if err != nil { - return err - } - - archive, err := s.BuildPackage(pkg) - if err != nil { - return err - } - - if pkg.IsCommand() && !pkg.UpToDate { - if err := s.WriteCommandPackage(archive, pkg.PkgObj); err != nil { - return err - } - } - } - return nil - }() - exitCode := handleError(err, options, nil) - - if s.Watcher == nil { - os.Exit(exitCode) - } - s.WaitForChange() - } - } - - cmdDoc := &cobra.Command{ - Use: "doc [arguments]", - Short: "display documentation for the requested, package, method or symbol", - } - cmdDoc.Run = func(cmd *cobra.Command, args []string) { - goDoc := exec.Command("go", append([]string{"doc"}, args...)...) - goDoc.Stdout = os.Stdout - goDoc.Stderr = os.Stderr - goDoc.Env = append(os.Environ(), "GOARCH=js") - err := goDoc.Run() - exitCode := handleError(err, options, nil) - os.Exit(exitCode) - } - - cmdGet := &cobra.Command{ - Use: "get [packages]", - Short: "download and install packages and dependencies", - } - cmdGet.Flags().AddFlagSet(flagVerbose) - cmdGet.Flags().AddFlagSet(flagQuiet) - cmdGet.Flags().AddFlagSet(compilerFlags) - cmdGet.Run = cmdInstall.Run - - cmdRun := &cobra.Command{ - Use: "run [gofiles...] [arguments...]", - Short: "compile and run Go program", - } - cmdRun.Flags().AddFlagSet(flagVerbose) - cmdRun.Flags().AddFlagSet(flagQuiet) - cmdRun.Flags().AddFlagSet(compilerFlags) - cmdRun.Run = func(cmd *cobra.Command, args []string) { - err := func() error { - lastSourceArg := 0 - for { - if lastSourceArg == len(args) || !(strings.HasSuffix(args[lastSourceArg], ".go") || strings.HasSuffix(args[lastSourceArg], ".inc.js")) { - break - } - lastSourceArg++ - } - if lastSourceArg == 0 { - return fmt.Errorf("gopherjs run: no go files listed") - } - - tempfile, err := ioutil.TempFile(currentDirectory, filepath.Base(args[0])+".") - if err != nil && strings.HasPrefix(currentDirectory, runtime.GOROOT()) { - tempfile, err = ioutil.TempFile("", filepath.Base(args[0])+".") - } - if err != nil { - return err - } - defer func() { - tempfile.Close() - os.Remove(tempfile.Name()) - os.Remove(tempfile.Name() + ".map") - }() - s := gbuild.NewSession(options) - if err := s.BuildFiles(args[:lastSourceArg], tempfile.Name(), currentDirectory); err != nil { - return err - } - if err := runNode(tempfile.Name(), args[lastSourceArg:], "", options.Quiet); err != nil { - return err - } - return nil - }() - exitCode := handleError(err, options, nil) - - os.Exit(exitCode) - } - - cmdTest := &cobra.Command{ - Use: "test [packages]", - Short: "test packages", - } - bench := cmdTest.Flags().String("bench", "", "Run benchmarks matching the regular expression. By default, no benchmarks run. To run all benchmarks, use '--bench=.'.") - benchtime := cmdTest.Flags().String("benchtime", "", "Run enough iterations of each benchmark to take t, specified as a time.Duration (for example, -benchtime 1h30s). The default is 1 second (1s).") - count := cmdTest.Flags().String("count", "", "Run each test and benchmark n times (default 1). Examples are always run once.") - run := cmdTest.Flags().String("run", "", "Run only those tests and examples matching the regular expression.") - short := cmdTest.Flags().Bool("short", false, "Tell long-running tests to shorten their run time.") - verbose := cmdTest.Flags().BoolP("verbose", "v", false, "Log all tests as they are run. Also print all text from Log and Logf calls even if the test succeeds.") - compileOnly := cmdTest.Flags().BoolP("compileonly", "c", false, "Compile the test binary to pkg.test.js but do not run it (where pkg is the last element of the package's import path). The file name can be changed with the -o flag.") - outputFilename := cmdTest.Flags().StringP("output", "o", "", "Compile the test binary to the named file. The test still runs (unless -c is specified).") - cmdTest.Flags().AddFlagSet(compilerFlags) - cmdTest.Run = func(cmd *cobra.Command, args []string) { - options.BuildTags = strings.Fields(tags) - err := func() error { - // Expand import path patterns. - patternContext := gbuild.NewBuildContext("", options.BuildTags) - args = (&gotool.Context{BuildContext: *patternContext}).ImportPaths(args) - - pkgs := make([]*gbuild.PackageData, len(args)) - for i, pkgPath := range args { - var err error - pkgs[i], err = gbuild.Import(pkgPath, 0, "", options.BuildTags) - if err != nil { - return err - } - } - - var exitErr error - for _, pkg := range pkgs { - if len(pkg.TestGoFiles) == 0 && len(pkg.XTestGoFiles) == 0 { - fmt.Printf("? \t%s\t[no test files]\n", pkg.ImportPath) - continue - } - s := gbuild.NewSession(options) - - tests := &testFuncs{Package: pkg.Package} - collectTests := func(testPkg *gbuild.PackageData, testPkgName string, needVar *bool) error { - if testPkgName == "_test" { - for _, file := range pkg.TestGoFiles { - if err := tests.load(filepath.Join(pkg.Package.Dir, file), testPkgName, &tests.ImportTest, &tests.NeedTest); err != nil { - return err - } - } - } else { - for _, file := range pkg.XTestGoFiles { - if err := tests.load(filepath.Join(pkg.Package.Dir, file), "_xtest", &tests.ImportXtest, &tests.NeedXtest); err != nil { - return err - } - } - } - _, err := s.BuildPackage(testPkg) - if err != nil { - return err - } - return nil - } - - if err := collectTests(&gbuild.PackageData{ - Package: &build.Package{ - ImportPath: pkg.ImportPath, - Dir: pkg.Dir, - GoFiles: append(pkg.GoFiles, pkg.TestGoFiles...), - Imports: append(pkg.Imports, pkg.TestImports...), - }, - IsTest: true, - JSFiles: pkg.JSFiles, - }, "_test", &tests.NeedTest); err != nil { - return err - } - - if err := collectTests(&gbuild.PackageData{ - Package: &build.Package{ - ImportPath: pkg.ImportPath + "_test", - Dir: pkg.Dir, - GoFiles: pkg.XTestGoFiles, - Imports: pkg.XTestImports, - }, - IsTest: true, - }, "_xtest", &tests.NeedXtest); err != nil { - return err - } - - buf := new(bytes.Buffer) - if err := testmainTmpl.Execute(buf, tests); err != nil { - return err - } - - fset := token.NewFileSet() - mainFile, err := parser.ParseFile(fset, "_testmain.go", buf, 0) - if err != nil { - return err - } - - importContext := &compiler.ImportContext{ - Packages: s.Types, - Import: func(path string) (*compiler.Archive, error) { - if path == pkg.ImportPath || path == pkg.ImportPath+"_test" { - return s.Archives[path], nil - } - return s.BuildImportPath(path) - }, - } - mainPkgArchive, err := compiler.Compile("main", []*ast.File{mainFile}, fset, importContext, options.Minify) - if err != nil { - return err - } - - if *compileOnly && *outputFilename == "" { - *outputFilename = pkg.Package.Name + "_test.js" - } - - var outfile *os.File - if *outputFilename != "" { - outfile, err = os.Create(*outputFilename) - if err != nil { - return err - } - } else { - outfile, err = ioutil.TempFile(currentDirectory, "test.") - if err != nil { - return err - } - } - defer func() { - outfile.Close() - if *outputFilename == "" { - os.Remove(outfile.Name()) - os.Remove(outfile.Name() + ".map") - } - }() - - if err := s.WriteCommandPackage(mainPkgArchive, outfile.Name()); err != nil { - return err - } - - if *compileOnly { - continue - } - - var args []string - if *bench != "" { - args = append(args, "-test.bench", *bench) - } - if *benchtime != "" { - args = append(args, "-test.benchtime", *benchtime) - } - if *count != "" { - args = append(args, "-test.count", *count) - } - if *run != "" { - args = append(args, "-test.run", *run) - } - if *short { - args = append(args, "-test.short") - } - if *verbose { - args = append(args, "-test.v") - } - status := "ok " - start := time.Now() - if err := runNode(outfile.Name(), args, pkg.Dir, options.Quiet); err != nil { - if _, ok := err.(*exec.ExitError); !ok { - return err - } - exitErr = err - status = "FAIL" - } - fmt.Printf("%s\t%s\t%.3fs\n", status, pkg.ImportPath, time.Since(start).Seconds()) - } - return exitErr - }() - exitCode := handleError(err, options, nil) - - os.Exit(exitCode) - } - - cmdServe := &cobra.Command{ - Use: "serve [root]", - Short: "compile on-the-fly and serve", - } - cmdServe.Flags().AddFlagSet(flagVerbose) - cmdServe.Flags().AddFlagSet(flagQuiet) - cmdServe.Flags().AddFlagSet(compilerFlags) - var addr string - cmdServe.Flags().StringVarP(&addr, "http", "", ":8080", "HTTP bind address to serve") - cmdServe.Run = func(cmd *cobra.Command, args []string) { - options.BuildTags = strings.Fields(tags) - dirs := append(filepath.SplitList(build.Default.GOPATH), build.Default.GOROOT) - var root string - - if len(args) > 1 { - cmdServe.HelpFunc()(cmd, args) - os.Exit(1) - } - - if len(args) == 1 { - root = args[0] - } - - sourceFiles := http.FileServer(serveCommandFileSystem{ - serveRoot: root, - options: options, - dirs: dirs, - sourceMaps: make(map[string][]byte), - }) - - ln, err := net.Listen("tcp", addr) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - if tcpAddr := ln.Addr().(*net.TCPAddr); tcpAddr.IP.Equal(net.IPv4zero) || tcpAddr.IP.Equal(net.IPv6zero) { // Any available addresses. - fmt.Printf("serving at http://localhost:%d and on port %d of any available addresses\n", tcpAddr.Port, tcpAddr.Port) - } else { // Specific address. - fmt.Printf("serving at http://%s\n", tcpAddr) - } - fmt.Fprintln(os.Stderr, http.Serve(tcpKeepAliveListener{ln.(*net.TCPListener)}, sourceFiles)) - } - - cmdVersion := &cobra.Command{ - Use: "version", - Short: "print GopherJS compiler version", - } - cmdVersion.Run = func(cmd *cobra.Command, args []string) { - if len(args) > 0 { - cmdServe.HelpFunc()(cmd, args) - os.Exit(1) - } - - fmt.Printf("GopherJS %s\n", compiler.Version) - } - - rootCmd := &cobra.Command{ - Use: "gopherjs", - Long: "GopherJS is a tool for compiling Go source code to JavaScript.", - } - rootCmd.AddCommand(cmdBuild, cmdGet, cmdInstall, cmdRun, cmdTest, cmdServe, cmdVersion, cmdDoc) - err := rootCmd.Execute() - if err != nil { - os.Exit(2) - } -} - -// tcpKeepAliveListener sets TCP keep-alive timeouts on accepted -// connections. It's used by ListenAndServe and ListenAndServeTLS so -// dead TCP connections (e.g. closing laptop mid-download) eventually -// go away. -type tcpKeepAliveListener struct { - *net.TCPListener -} - -func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) { - tc, err := ln.AcceptTCP() - if err != nil { - return - } - tc.SetKeepAlive(true) - tc.SetKeepAlivePeriod(3 * time.Minute) - return tc, nil -} - -type serveCommandFileSystem struct { - serveRoot string - options *gbuild.Options - dirs []string - sourceMaps map[string][]byte -} - -func (fs serveCommandFileSystem) Open(requestName string) (http.File, error) { - name := path.Join(fs.serveRoot, requestName[1:]) // requestName[0] == '/' - - dir, file := path.Split(name) - base := path.Base(dir) // base is parent folder name, which becomes the output file name. - - isPkg := file == base+".js" - isMap := file == base+".js.map" - isIndex := file == "index.html" - - if isPkg || isMap || isIndex { - // If we're going to be serving our special files, make sure there's a Go command in this folder. - s := gbuild.NewSession(fs.options) - pkg, err := gbuild.Import(path.Dir(name), 0, s.InstallSuffix(), fs.options.BuildTags) - if err != nil || pkg.Name != "main" { - isPkg = false - isMap = false - isIndex = false - } - - switch { - case isPkg: - buf := new(bytes.Buffer) - browserErrors := new(bytes.Buffer) - err := func() error { - archive, err := s.BuildPackage(pkg) - if err != nil { - return err - } - - sourceMapFilter := &compiler.SourceMapFilter{Writer: buf} - m := &sourcemap.Map{File: base + ".js"} - sourceMapFilter.MappingCallback = gbuild.NewMappingCallback(m, fs.options.GOROOT, fs.options.GOPATH, fs.options.MapToLocalDisk) - - deps, err := compiler.ImportDependencies(archive, s.BuildImportPath) - if err != nil { - return err - } - if err := compiler.WriteProgramCode(deps, sourceMapFilter); err != nil { - return err - } - - mapBuf := new(bytes.Buffer) - m.WriteTo(mapBuf) - buf.WriteString("//# sourceMappingURL=" + base + ".js.map\n") - fs.sourceMaps[name+".map"] = mapBuf.Bytes() - - return nil - }() - handleError(err, fs.options, browserErrors) - if err != nil { - buf = browserErrors - } - return newFakeFile(base+".js", buf.Bytes()), nil - - case isMap: - if content, ok := fs.sourceMaps[name]; ok { - return newFakeFile(base+".js.map", content), nil - } - } - } - - for _, d := range fs.dirs { - dir := http.Dir(filepath.Join(d, "src")) - - f, err := dir.Open(name) - if err == nil { - return f, nil - } - - // source maps are served outside of serveRoot - f, err = dir.Open(requestName) - if err == nil { - return f, nil - } - } - - if isIndex { - // If there was no index.html file in any dirs, supply our own. - return newFakeFile("index.html", []byte(``)), nil - } - - return nil, os.ErrNotExist -} - -type fakeFile struct { - name string - size int - io.ReadSeeker -} - -func newFakeFile(name string, content []byte) *fakeFile { - return &fakeFile{name: name, size: len(content), ReadSeeker: bytes.NewReader(content)} -} - -func (f *fakeFile) Close() error { - return nil -} - -func (f *fakeFile) Readdir(count int) ([]os.FileInfo, error) { - return nil, os.ErrInvalid -} - -func (f *fakeFile) Stat() (os.FileInfo, error) { - return f, nil -} - -func (f *fakeFile) Name() string { - return f.name -} - -func (f *fakeFile) Size() int64 { - return int64(f.size) -} - -func (f *fakeFile) Mode() os.FileMode { - return 0 -} - -func (f *fakeFile) ModTime() time.Time { - return time.Time{} -} - -func (f *fakeFile) IsDir() bool { - return false -} - -func (f *fakeFile) Sys() interface{} { - return nil -} - -// handleError handles err and returns an appropriate exit code. -// If browserErrors is non-nil, errors are written for presentation in browser. -func handleError(err error, options *gbuild.Options, browserErrors *bytes.Buffer) int { - switch err := err.(type) { - case nil: - return 0 - case compiler.ErrorList: - for _, entry := range err { - printError(entry, options, browserErrors) - } - return 1 - case *exec.ExitError: - return err.Sys().(syscall.WaitStatus).ExitStatus() - default: - printError(err, options, browserErrors) - return 1 - } -} - -// printError prints err to Stderr with options. If browserErrors is non-nil, errors are also written for presentation in browser. -func printError(err error, options *gbuild.Options, browserErrors *bytes.Buffer) { - e := sprintError(err) - options.PrintError("%s\n", e) - if browserErrors != nil { - fmt.Fprintln(browserErrors, `console.error("`+template.JSEscapeString(e)+`");`) - } -} - -// sprintError returns an annotated error string without trailing newline. -func sprintError(err error) string { - makeRel := func(name string) string { - if relname, err := filepath.Rel(currentDirectory, name); err == nil { - return relname - } - return name - } - - switch e := err.(type) { - case *scanner.Error: - return fmt.Sprintf("%s:%d:%d: %s", makeRel(e.Pos.Filename), e.Pos.Line, e.Pos.Column, e.Msg) - case types.Error: - pos := e.Fset.Position(e.Pos) - return fmt.Sprintf("%s:%d:%d: %s", makeRel(pos.Filename), pos.Line, pos.Column, e.Msg) - default: - return fmt.Sprintf("%s", e) - } -} - -func runNode(script string, args []string, dir string, quiet bool) error { - var allArgs []string - if b, _ := strconv.ParseBool(os.Getenv("SOURCE_MAP_SUPPORT")); os.Getenv("SOURCE_MAP_SUPPORT") == "" || b { - allArgs = []string{"--require", "source-map-support/register"} - if err := exec.Command("node", "--require", "source-map-support/register", "--eval", "").Run(); err != nil { - if !quiet { - fmt.Fprintln(os.Stderr, "gopherjs: Source maps disabled. Install source-map-support module for nice stack traces. See https://github.com/gopherjs/gopherjs#gopherjs-run-gopherjs-test.") - } - allArgs = []string{} - } - } - - if runtime.GOOS != "windows" { - allArgs = append(allArgs, "--stack_size=10000", script) - } - - allArgs = append(allArgs, args...) - - node := exec.Command("node", allArgs...) - node.Dir = dir - node.Stdin = os.Stdin - node.Stdout = os.Stdout - node.Stderr = os.Stderr - err := node.Run() - if _, ok := err.(*exec.ExitError); err != nil && !ok { - err = fmt.Errorf("could not run Node.js: %s", err.Error()) - } - return err -} - -type testFuncs struct { - Tests []testFunc - Benchmarks []testFunc - Examples []testFunc - TestMain *testFunc - Package *build.Package - ImportTest bool - NeedTest bool - ImportXtest bool - NeedXtest bool -} - -type testFunc struct { - Package string // imported package name (_test or _xtest) - Name string // function name - Output string // output, for examples - Unordered bool // output is allowed to be unordered. -} - -var testFileSet = token.NewFileSet() - -func (t *testFuncs) load(filename, pkg string, doImport, seen *bool) error { - f, err := parser.ParseFile(testFileSet, filename, nil, parser.ParseComments) - if err != nil { - return err - } - for _, d := range f.Decls { - n, ok := d.(*ast.FuncDecl) - if !ok { - continue - } - if n.Recv != nil { - continue - } - name := n.Name.String() - switch { - case isTestMain(n): - if t.TestMain != nil { - return errors.New("multiple definitions of TestMain") - } - t.TestMain = &testFunc{pkg, name, "", false} - *doImport, *seen = true, true - case isTest(name, "Test"): - t.Tests = append(t.Tests, testFunc{pkg, name, "", false}) - *doImport, *seen = true, true - case isTest(name, "Benchmark"): - t.Benchmarks = append(t.Benchmarks, testFunc{pkg, name, "", false}) - *doImport, *seen = true, true - } - } - ex := doc.Examples(f) - sort.Sort(byOrder(ex)) - for _, e := range ex { - *doImport = true // import test file whether executed or not - if e.Output == "" && !e.EmptyOutput { - // Don't run examples with no output. - continue - } - t.Examples = append(t.Examples, testFunc{pkg, "Example" + e.Name, e.Output, e.Unordered}) - *seen = true - } - - return nil -} - -type byOrder []*doc.Example - -func (x byOrder) Len() int { return len(x) } -func (x byOrder) Swap(i, j int) { x[i], x[j] = x[j], x[i] } -func (x byOrder) Less(i, j int) bool { return x[i].Order < x[j].Order } - -// isTestMain tells whether fn is a TestMain(m *testing.M) function. -func isTestMain(fn *ast.FuncDecl) bool { - if fn.Name.String() != "TestMain" || - fn.Type.Results != nil && len(fn.Type.Results.List) > 0 || - fn.Type.Params == nil || - len(fn.Type.Params.List) != 1 || - len(fn.Type.Params.List[0].Names) > 1 { - return false - } - ptr, ok := fn.Type.Params.List[0].Type.(*ast.StarExpr) - if !ok { - return false - } - // We can't easily check that the type is *testing.M - // because we don't know how testing has been imported, - // but at least check that it's *M or *something.M. - if name, ok := ptr.X.(*ast.Ident); ok && name.Name == "M" { - return true - } - if sel, ok := ptr.X.(*ast.SelectorExpr); ok && sel.Sel.Name == "M" { - return true - } - return false -} - -// isTest tells whether name looks like a test (or benchmark, according to prefix). -// It is a Test (say) if there is a character after Test that is not a lower-case letter. -// We don't want TesticularCancer. -func isTest(name, prefix string) bool { - if !strings.HasPrefix(name, prefix) { - return false - } - if len(name) == len(prefix) { // "Test" is ok - return true - } - rune, _ := utf8.DecodeRuneInString(name[len(prefix):]) - return !unicode.IsLower(rune) -} - -var testmainTmpl = template.Must(template.New("main").Parse(` -package main - -import ( -{{if not .TestMain}} - "os" -{{end}} - "testing" - "testing/internal/testdeps" - -{{if .ImportTest}} - {{if .NeedTest}}_test{{else}}_{{end}} {{.Package.ImportPath | printf "%q"}} -{{end}} -{{if .ImportXtest}} - {{if .NeedXtest}}_xtest{{else}}_{{end}} {{.Package.ImportPath | printf "%s_test" | printf "%q"}} -{{end}} -) - -var tests = []testing.InternalTest{ -{{range .Tests}} - {"{{.Name}}", {{.Package}}.{{.Name}}}, -{{end}} -} - -var benchmarks = []testing.InternalBenchmark{ -{{range .Benchmarks}} - {"{{.Name}}", {{.Package}}.{{.Name}}}, -{{end}} -} - -var examples = []testing.InternalExample{ -{{range .Examples}} - {"{{.Name}}", {{.Package}}.{{.Name}}, {{.Output | printf "%q"}}, {{.Unordered}}}, -{{end}} -} - -func main() { - m := testing.MainStart(testdeps.TestDeps{}, tests, benchmarks, examples) -{{with .TestMain}} - {{.Package}}.{{.Name}}(m) -{{else}} - os.Exit(m.Run()) -{{end}} -} - -`)) diff --git a/vendor/github.com/huandu/xstrings/convert.go b/vendor/github.com/huandu/xstrings/convert.go index 78ca34d49..783e73b67 100644 --- a/vendor/github.com/huandu/xstrings/convert.go +++ b/vendor/github.com/huandu/xstrings/convert.go @@ -43,19 +43,26 @@ func ToCamelCase(str string) string { if len(str) == 0 { return buf.String() } - - buf.WriteRune(unicode.ToUpper(r0)) - r0, size = utf8.DecodeRuneInString(str) - str = str[size:] + + r0 = unicode.ToUpper(r0) for len(str) > 0 { r1 = r0 r0, size = utf8.DecodeRuneInString(str) str = str[size:] - if r1 == '_' && r0 != '_' { + if r1 == '_' && r0 == '_' { + buf.WriteRune(r1) + continue + } + + if r1 == '_' { r0 = unicode.ToUpper(r0) } else { + r0 = unicode.ToLower(r0) + } + + if r1 != '_' { buf.WriteRune(r1) } } diff --git a/vendor/github.com/huandu/xstrings/convert_test.go b/vendor/github.com/huandu/xstrings/convert_test.go index b65b989fe..30707a98a 100644 --- a/vendor/github.com/huandu/xstrings/convert_test.go +++ b/vendor/github.com/huandu/xstrings/convert_test.go @@ -35,6 +35,8 @@ func TestToCamelCase(t *testing.T) { "no_https": "NoHttps", "_complex__case_": "_Complex_Case_", "all": "All", + "GOLANG_IS_GREAT": "GolangIsGreat", + "GOLANG": "Golang", }) } diff --git a/vendor/github.com/json-iterator/go/.travis.yml b/vendor/github.com/json-iterator/go/.travis.yml index 945b9c594..449e67cd0 100644 --- a/vendor/github.com/json-iterator/go/.travis.yml +++ b/vendor/github.com/json-iterator/go/.travis.yml @@ -2,6 +2,7 @@ language: go go: - 1.8.x + - 1.x before_install: - go get -t -v ./... diff --git a/vendor/github.com/json-iterator/go/README.md b/vendor/github.com/json-iterator/go/README.md index 23a4b57c8..bff7544ce 100644 --- a/vendor/github.com/json-iterator/go/README.md +++ b/vendor/github.com/json-iterator/go/README.md @@ -76,5 +76,7 @@ Contributors * [thockin](https://github.com/thockin) * [mattn](https://github.com/mattn) * [cch123](https://github.com/cch123) +* [Oleg Shaldybin](https://github.com/olegshaldybin) +* [Jason Toffaletti](https://github.com/toffaletti) Report issue or pull request, or email taowen@gmail.com, or [![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/json-iterator/Lobby) diff --git a/vendor/github.com/json-iterator/go/extra/fuzzy_decoder.go b/vendor/github.com/json-iterator/go/extra/fuzzy_decoder.go index df602f342..9b63c277f 100644 --- a/vendor/github.com/json-iterator/go/extra/fuzzy_decoder.go +++ b/vendor/github.com/json-iterator/go/extra/fuzzy_decoder.go @@ -2,11 +2,13 @@ package extra import ( "encoding/json" - "github.com/json-iterator/go" + "io" "math" "reflect" "strings" "unsafe" + + "github.com/json-iterator/go" ) const maxUint = ^uint(0) @@ -199,6 +201,12 @@ func (decoder *fuzzyIntegerDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.It str = string(number) case jsoniter.StringValue: str = iter.ReadString() + case jsoniter.BoolValue: + if iter.ReadBool() { + str = "1" + } else { + str = "0" + } default: iter.ReportError("fuzzyIntegerDecoder", "not number or string") } @@ -206,7 +214,7 @@ func (decoder *fuzzyIntegerDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.It defer iter.Pool().ReturnIterator(newIter) isFloat := strings.IndexByte(str, '.') != -1 decoder.fun(isFloat, ptr, newIter) - if newIter.Error != nil { + if newIter.Error != nil && newIter.Error != io.EOF { iter.Error = newIter.Error } } @@ -225,9 +233,16 @@ func (decoder *fuzzyFloat32Decoder) Decode(ptr unsafe.Pointer, iter *jsoniter.It newIter := iter.Pool().BorrowIterator([]byte(str)) defer iter.Pool().ReturnIterator(newIter) *((*float32)(ptr)) = newIter.ReadFloat32() - if newIter.Error != nil { + if newIter.Error != nil && newIter.Error != io.EOF { iter.Error = newIter.Error } + case jsoniter.BoolValue: + // support bool to float32 + if iter.ReadBool() { + *((*float32)(ptr)) = 1 + } else { + *((*float32)(ptr)) = 0 + } default: iter.ReportError("fuzzyFloat32Decoder", "not number or string") } @@ -247,9 +262,16 @@ func (decoder *fuzzyFloat64Decoder) Decode(ptr unsafe.Pointer, iter *jsoniter.It newIter := iter.Pool().BorrowIterator([]byte(str)) defer iter.Pool().ReturnIterator(newIter) *((*float64)(ptr)) = newIter.ReadFloat64() - if newIter.Error != nil { + if newIter.Error != nil && newIter.Error != io.EOF { iter.Error = newIter.Error } + case jsoniter.BoolValue: + // support bool to float64 + if iter.ReadBool() { + *((*float64)(ptr)) = 1 + } else { + *((*float64)(ptr)) = 0 + } default: iter.ReportError("fuzzyFloat32Decoder", "not number or string") } diff --git a/vendor/github.com/json-iterator/go/extra/fuzzy_decoder_test.go b/vendor/github.com/json-iterator/go/extra/fuzzy_decoder_test.go index c4aad6807..b6a15596d 100644 --- a/vendor/github.com/json-iterator/go/extra/fuzzy_decoder_test.go +++ b/vendor/github.com/json-iterator/go/extra/fuzzy_decoder_test.go @@ -38,6 +38,12 @@ func Test_any_to_int64(t *testing.T) { should.Nil(jsoniter.UnmarshalFromString(`10`, &val)) should.Equal(int64(10), val) + // bool part + should.Nil(jsoniter.UnmarshalFromString(`false`, &val)) + should.Equal(int64(0), val) + should.Nil(jsoniter.UnmarshalFromString(`true`, &val)) + should.Equal(int64(1), val) + should.Nil(jsoniter.UnmarshalFromString(`-10`, &val)) should.Equal(int64(-10), val) should.NotNil(jsoniter.UnmarshalFromString("{}", &val)) @@ -57,6 +63,13 @@ func Test_any_to_int(t *testing.T) { should.Equal(10, val) should.Nil(jsoniter.UnmarshalFromString(`10`, &val)) should.Equal(10, val) + + // bool part + should.Nil(jsoniter.UnmarshalFromString(`false`, &val)) + should.Equal(0, val) + should.Nil(jsoniter.UnmarshalFromString(`true`, &val)) + should.Equal(1, val) + should.NotNil(jsoniter.UnmarshalFromString("{}", &val)) should.NotNil(jsoniter.UnmarshalFromString("[]", &val)) // large float to int @@ -74,6 +87,13 @@ func Test_any_to_int16(t *testing.T) { should.Equal(int16(10), val) should.Nil(jsoniter.UnmarshalFromString(`10`, &val)) should.Equal(int16(10), val) + + // bool part + should.Nil(jsoniter.UnmarshalFromString(`false`, &val)) + should.Equal(int16(0), val) + should.Nil(jsoniter.UnmarshalFromString(`true`, &val)) + should.Equal(int16(1), val) + should.NotNil(jsoniter.UnmarshalFromString("{}", &val)) should.NotNil(jsoniter.UnmarshalFromString("[]", &val)) // large float to int @@ -91,6 +111,13 @@ func Test_any_to_int32(t *testing.T) { should.Equal(int32(10), val) should.Nil(jsoniter.UnmarshalFromString(`10`, &val)) should.Equal(int32(10), val) + + // bool part + should.Nil(jsoniter.UnmarshalFromString(`false`, &val)) + should.Equal(int32(0), val) + should.Nil(jsoniter.UnmarshalFromString(`true`, &val)) + should.Equal(int32(1), val) + should.NotNil(jsoniter.UnmarshalFromString("{}", &val)) should.NotNil(jsoniter.UnmarshalFromString("[]", &val)) // large float to int @@ -108,6 +135,13 @@ func Test_any_to_int8(t *testing.T) { should.Equal(int8(10), val) should.Nil(jsoniter.UnmarshalFromString(`10`, &val)) should.Equal(int8(10), val) + + // bool part + should.Nil(jsoniter.UnmarshalFromString(`false`, &val)) + should.Equal(int8(0), val) + should.Nil(jsoniter.UnmarshalFromString(`true`, &val)) + should.Equal(int8(1), val) + should.NotNil(jsoniter.UnmarshalFromString("{}", &val)) should.NotNil(jsoniter.UnmarshalFromString("[]", &val)) // large float to int @@ -125,6 +159,13 @@ func Test_any_to_uint8(t *testing.T) { should.Equal(uint8(10), val) should.Nil(jsoniter.UnmarshalFromString(`10`, &val)) should.Equal(uint8(10), val) + + // bool part + should.Nil(jsoniter.UnmarshalFromString(`false`, &val)) + should.Equal(uint8(0), val) + should.Nil(jsoniter.UnmarshalFromString(`true`, &val)) + should.Equal(uint8(1), val) + should.NotNil(jsoniter.UnmarshalFromString("{}", &val)) should.NotNil(jsoniter.UnmarshalFromString("[]", &val)) // large float to int @@ -144,6 +185,12 @@ func Test_any_to_uint64(t *testing.T) { should.Nil(jsoniter.UnmarshalFromString(`10`, &val)) should.Equal(uint64(10), val) + // bool part + should.Nil(jsoniter.UnmarshalFromString(`false`, &val)) + should.Equal(uint64(0), val) + should.Nil(jsoniter.UnmarshalFromString(`true`, &val)) + should.Equal(uint64(1), val) + // TODO fix? should.NotNil(jsoniter.UnmarshalFromString(`-10`, &val)) should.Equal(uint64(0), val) @@ -165,6 +212,12 @@ func Test_any_to_uint32(t *testing.T) { should.Nil(jsoniter.UnmarshalFromString(`10`, &val)) should.Equal(uint32(10), val) + // bool part + should.Nil(jsoniter.UnmarshalFromString(`false`, &val)) + should.Equal(uint32(0), val) + should.Nil(jsoniter.UnmarshalFromString(`true`, &val)) + should.Equal(uint32(1), val) + // TODO fix? should.NotNil(jsoniter.UnmarshalFromString(`-10`, &val)) should.Equal(uint32(0), val) @@ -186,6 +239,12 @@ func Test_any_to_uint16(t *testing.T) { should.Nil(jsoniter.UnmarshalFromString(`10`, &val)) should.Equal(uint16(10), val) + // bool part + should.Nil(jsoniter.UnmarshalFromString(`false`, &val)) + should.Equal(uint16(0), val) + should.Nil(jsoniter.UnmarshalFromString(`true`, &val)) + should.Equal(uint16(1), val) + // TODO fix? should.NotNil(jsoniter.UnmarshalFromString(`-10`, &val)) should.Equal(uint16(0), val) @@ -205,6 +264,12 @@ func Test_any_to_uint(t *testing.T) { should.Equal(uint(10), val) should.Nil(jsoniter.UnmarshalFromString(`10`, &val)) should.Equal(uint(10), val) + + should.Nil(jsoniter.UnmarshalFromString(`false`, &val)) + should.Equal(uint(0), val) + should.Nil(jsoniter.UnmarshalFromString(`true`, &val)) + should.Equal(uint(1), val) + should.NotNil(jsoniter.UnmarshalFromString("{}", &val)) should.NotNil(jsoniter.UnmarshalFromString("[]", &val)) // large float to int @@ -223,6 +288,13 @@ func Test_any_to_float32(t *testing.T) { should.Equal(float32(10.1), val) should.Nil(jsoniter.UnmarshalFromString(`10`, &val)) should.Equal(float32(10), val) + + // bool part + should.Nil(jsoniter.UnmarshalFromString(`false`, &val)) + should.Equal(float32(0), val) + should.Nil(jsoniter.UnmarshalFromString(`true`, &val)) + should.Equal(float32(1), val) + should.NotNil(jsoniter.UnmarshalFromString("{}", &val)) should.NotNil(jsoniter.UnmarshalFromString("[]", &val)) } @@ -240,6 +312,13 @@ func Test_any_to_float64(t *testing.T) { should.Equal(float64(10.1), val) should.Nil(jsoniter.UnmarshalFromString(`10`, &val)) should.Equal(float64(10), val) + + // bool part + should.Nil(jsoniter.UnmarshalFromString(`false`, &val)) + should.Equal(float64(0), val) + should.Nil(jsoniter.UnmarshalFromString(`true`, &val)) + should.Equal(float64(1), val) + should.NotNil(jsoniter.UnmarshalFromString("{}", &val)) should.NotNil(jsoniter.UnmarshalFromString("[]", &val)) } @@ -257,3 +336,24 @@ func Test_empty_array_as_object(t *testing.T) { should.Nil(jsoniter.UnmarshalFromString(`[]`, &val)) should.Equal(struct{}{}, val) } + +func Test_bad_case(t *testing.T) { + var jsonstr = ` +{ + "extra_type": 181760, + "combo_type": 0, + "trigger_time_ms": 1498800398000, + "_create_time": "2017-06-16 11:21:39", + "_msg_type": 41000 +} +` + + type OrderEventRequestParams struct { + ExtraType uint64 `json:"extra_type"` + } + + var a OrderEventRequestParams + err := jsoniter.UnmarshalFromString(jsonstr, &a) + should := require.New(t) + should.Nil(err) +} diff --git a/vendor/github.com/json-iterator/go/feature_config.go b/vendor/github.com/json-iterator/go/feature_config.go index 3c64b6bb3..3201bcdcd 100644 --- a/vendor/github.com/json-iterator/go/feature_config.go +++ b/vendor/github.com/json-iterator/go/feature_config.go @@ -17,6 +17,8 @@ type Config struct { EscapeHTML bool SortMapKeys bool UseNumber bool + TagKey string + ValidateJsonRawMessage bool } type frozenConfig struct { @@ -52,8 +54,9 @@ var ConfigDefault = Config{ // ConfigCompatibleWithStandardLibrary tries to be 100% compatible with standard library behavior var ConfigCompatibleWithStandardLibrary = Config{ - EscapeHTML: true, - SortMapKeys: true, + EscapeHTML: true, + SortMapKeys: true, + ValidateJsonRawMessage: true, }.Froze() // ConfigFastest marshals float with only 6 digits precision @@ -82,10 +85,31 @@ func (cfg Config) Froze() API { if cfg.UseNumber { frozenConfig.useNumber() } + if cfg.ValidateJsonRawMessage { + frozenConfig.validateJsonRawMessage() + } frozenConfig.configBeforeFrozen = cfg return frozenConfig } +func (cfg *frozenConfig) validateJsonRawMessage() { + encoder := &funcEncoder{func(ptr unsafe.Pointer, stream *Stream) { + rawMessage := *(*json.RawMessage)(ptr) + iter := cfg.BorrowIterator([]byte(rawMessage)) + iter.Read() + if iter.Error != nil { + stream.WriteRaw("null") + } else { + cfg.ReturnIterator(iter) + stream.WriteRaw(string(rawMessage)) + } + }, func(ptr unsafe.Pointer) bool { + return false + }} + cfg.addEncoderToCache(reflect.TypeOf((*json.RawMessage)(nil)).Elem(), encoder) + cfg.addEncoderToCache(reflect.TypeOf((*RawMessage)(nil)).Elem(), encoder) +} + func (cfg *frozenConfig) useNumber() { cfg.addDecoderToCache(reflect.TypeOf((*interface{})(nil)).Elem(), &funcDecoder{func(ptr unsafe.Pointer, iter *Iterator) { if iter.WhatIsNext() == NumberValue { @@ -95,6 +119,13 @@ func (cfg *frozenConfig) useNumber() { } }}) } +func (cfg *frozenConfig) getTagKey() string { + tagKey := cfg.configBeforeFrozen.TagKey + if tagKey == "" { + return "json" + } + return tagKey +} func (cfg *frozenConfig) registerExtension(extension Extension) { cfg.extensions = append(cfg.extensions, extension) diff --git a/vendor/github.com/json-iterator/go/feature_iter.go b/vendor/github.com/json-iterator/go/feature_iter.go index 82e49da5c..4357d69ba 100644 --- a/vendor/github.com/json-iterator/go/feature_iter.go +++ b/vendor/github.com/json-iterator/go/feature_iter.go @@ -285,14 +285,18 @@ func (iter *Iterator) Read() interface{} { case ArrayValue: arr := []interface{}{} iter.ReadArrayCB(func(iter *Iterator) bool { - arr = append(arr, iter.Read()) + var elem interface{} + iter.ReadVal(&elem) + arr = append(arr, elem) return true }) return arr case ObjectValue: obj := map[string]interface{}{} iter.ReadMapCB(func(Iter *Iterator, field string) bool { - obj[field] = iter.Read() + var elem interface{} + iter.ReadVal(&elem) + obj[field] = elem return true }) return obj diff --git a/vendor/github.com/json-iterator/go/feature_iter_skip_strict.go b/vendor/github.com/json-iterator/go/feature_iter_skip_strict.go index d26763825..cc1933de2 100644 --- a/vendor/github.com/json-iterator/go/feature_iter_skip_strict.go +++ b/vendor/github.com/json-iterator/go/feature_iter_skip_strict.go @@ -64,7 +64,7 @@ func (iter *Iterator) trySkipString() bool { } else if c == '\\' { return false } else if c < ' ' { - iter.ReportError("ReadString", + iter.ReportError("trySkipString", fmt.Sprintf(`invalid control character found: %d`, c)) return true // already failed } diff --git a/vendor/github.com/json-iterator/go/feature_iter_string.go b/vendor/github.com/json-iterator/go/feature_iter_string.go index b76460046..59174ea4b 100644 --- a/vendor/github.com/json-iterator/go/feature_iter_string.go +++ b/vendor/github.com/json-iterator/go/feature_iter_string.go @@ -47,7 +47,7 @@ func (iter *Iterator) readStringSlowPath() (ret string) { str = append(str, c) } } - iter.ReportError("ReadString", "unexpected end of input") + iter.ReportError("readStringSlowPath", "unexpected end of input") return } @@ -104,7 +104,7 @@ func (iter *Iterator) readEscapedChar(c byte, str []byte) []byte { case 't': str = append(str, '\t') default: - iter.ReportError("ReadString", + iter.ReportError("readEscapedChar", `invalid escape char after \`) return nil } @@ -139,7 +139,7 @@ func (iter *Iterator) ReadStringAsSlice() (ret []byte) { } return copied } - iter.ReportError("ReadString", `expects " or n`) + iter.ReportError("ReadStringAsSlice", `expects " or n`) return } diff --git a/vendor/github.com/json-iterator/go/feature_json_number.go b/vendor/github.com/json-iterator/go/feature_json_number.go index aba538499..0439f6725 100644 --- a/vendor/github.com/json-iterator/go/feature_json_number.go +++ b/vendor/github.com/json-iterator/go/feature_json_number.go @@ -12,4 +12,4 @@ func CastJsonNumber(val interface{}) (string, bool) { return string(typedVal), true } return "", false -} \ No newline at end of file +} diff --git a/vendor/github.com/json-iterator/go/feature_reflect.go b/vendor/github.com/json-iterator/go/feature_reflect.go index 8e4134dc8..4483e34b8 100644 --- a/vendor/github.com/json-iterator/go/feature_reflect.go +++ b/vendor/github.com/json-iterator/go/feature_reflect.go @@ -154,11 +154,11 @@ func (encoder *placeholderEncoder) IsEmpty(ptr unsafe.Pointer) bool { } func (encoder *placeholderEncoder) getRealEncoder() ValEncoder { - for i := 0; i < 30; i++ { + for i := 0; i < 500; i++ { realDecoder := encoder.cfg.getEncoderFromCache(encoder.cacheKey) _, isPlaceholder := realDecoder.(*placeholderEncoder) if isPlaceholder { - time.Sleep(time.Second) + time.Sleep(10 * time.Millisecond) } else { return realDecoder } @@ -172,11 +172,11 @@ type placeholderDecoder struct { } func (decoder *placeholderDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) { - for i := 0; i < 30; i++ { + for i := 0; i < 500; i++ { realDecoder := decoder.cfg.getDecoderFromCache(decoder.cacheKey) _, isPlaceholder := realDecoder.(*placeholderDecoder) if isPlaceholder { - time.Sleep(time.Second) + time.Sleep(10 * time.Millisecond) } else { realDecoder.Decode(ptr, iter) return @@ -285,13 +285,6 @@ func createDecoderOfType(cfg *frozenConfig, typ reflect.Type) (ValDecoder, error if typ.AssignableTo(jsoniterNumberType) { return &jsoniterNumberCodec{}, nil } - if typ.Kind() == reflect.Slice && typ.Elem().Kind() == reflect.Uint8 { - sliceDecoder, err := prefix("[slice]").addToDecoder(decoderOfSlice(cfg, typ)) - if err != nil { - return nil, err - } - return &base64Codec{sliceDecoder: sliceDecoder}, nil - } if typ.Implements(unmarshalerType) { templateInterface := reflect.New(typ).Elem().Interface() var decoder ValDecoder = &unmarshalerDecoder{extractInterface(templateInterface)} @@ -318,6 +311,13 @@ func createDecoderOfType(cfg *frozenConfig, typ reflect.Type) (ValDecoder, error var decoder ValDecoder = &textUnmarshalerDecoder{extractInterface(templateInterface)} return decoder, nil } + if typ.Kind() == reflect.Slice && typ.Elem().Kind() == reflect.Uint8 { + sliceDecoder, err := prefix("[slice]").addToDecoder(decoderOfSlice(cfg, typ)) + if err != nil { + return nil, err + } + return &base64Codec{sliceDecoder: sliceDecoder}, nil + } if typ.Implements(anyType) { return &anyCodec{}, nil } @@ -451,9 +451,6 @@ func createEncoderOfType(cfg *frozenConfig, typ reflect.Type) (ValEncoder, error if typ.AssignableTo(jsoniterNumberType) { return &jsoniterNumberCodec{}, nil } - if typ.Kind() == reflect.Slice && typ.Elem().Kind() == reflect.Uint8 { - return &base64Codec{}, nil - } if typ.Implements(marshalerType) { checkIsEmpty, err := createCheckIsEmpty(typ) if err != nil { @@ -469,6 +466,18 @@ func createEncoderOfType(cfg *frozenConfig, typ reflect.Type) (ValEncoder, error } return encoder, nil } + if reflect.PtrTo(typ).Implements(marshalerType) { + checkIsEmpty, err := createCheckIsEmpty(reflect.PtrTo(typ)) + if err != nil { + return nil, err + } + templateInterface := reflect.New(typ).Interface() + var encoder ValEncoder = &marshalerEncoder{ + templateInterface: extractInterface(templateInterface), + checkIsEmpty: checkIsEmpty, + } + return encoder, nil + } if typ.Implements(textMarshalerType) { checkIsEmpty, err := createCheckIsEmpty(typ) if err != nil { @@ -484,6 +493,9 @@ func createEncoderOfType(cfg *frozenConfig, typ reflect.Type) (ValEncoder, error } return encoder, nil } + if typ.Kind() == reflect.Slice && typ.Elem().Kind() == reflect.Uint8 { + return &base64Codec{}, nil + } if typ.Implements(anyType) { return &anyCodec{}, nil } diff --git a/vendor/github.com/json-iterator/go/feature_reflect_extension.go b/vendor/github.com/json-iterator/go/feature_reflect_extension.go index 7321566b6..74f4b8bab 100644 --- a/vendor/github.com/json-iterator/go/feature_reflect_extension.go +++ b/vendor/github.com/json-iterator/go/feature_reflect_extension.go @@ -227,7 +227,7 @@ func describeStruct(cfg *frozenConfig, typ reflect.Type) (*StructDescriptor, err bindings := []*Binding{} for i := 0; i < typ.NumField(); i++ { field := typ.Field(i) - tag := field.Tag.Get("json") + tag := field.Tag.Get(cfg.getTagKey()) tagParts := strings.Split(tag, ",") if tag == "-" { continue @@ -269,7 +269,7 @@ func describeStruct(cfg *frozenConfig, typ reflect.Type) (*StructDescriptor, err if decoder == nil { var err error decoder, err = decoderOfType(cfg, field.Type) - if err != nil { + if len(fieldNames) > 0 && err != nil { return nil, err } } @@ -277,11 +277,11 @@ func describeStruct(cfg *frozenConfig, typ reflect.Type) (*StructDescriptor, err if encoder == nil { var err error encoder, err = encoderOfType(cfg, field.Type) - if err != nil { + if len(fieldNames) > 0 && err != nil { return nil, err } // map is stored as pointer in the struct - if field.Type.Kind() == reflect.Map { + if encoder != nil && field.Type.Kind() == reflect.Map { encoder = &optionalEncoder{encoder} } } @@ -373,7 +373,7 @@ func (bindings sortableBindings) Swap(i, j int) { func processTags(structDescriptor *StructDescriptor, cfg *frozenConfig) { for _, binding := range structDescriptor.Fields { shouldOmitEmpty := false - tagParts := strings.Split(binding.Field.Tag.Get("json"), ",") + tagParts := strings.Split(binding.Field.Tag.Get(cfg.getTagKey()), ",") for _, tagPart := range tagParts[1:] { if tagPart == "omitempty" { shouldOmitEmpty = true diff --git a/vendor/github.com/json-iterator/go/feature_reflect_native.go b/vendor/github.com/json-iterator/go/feature_reflect_native.go index b37dab3d8..332b9e013 100644 --- a/vendor/github.com/json-iterator/go/feature_reflect_native.go +++ b/vendor/github.com/json-iterator/go/feature_reflect_native.go @@ -4,6 +4,7 @@ import ( "encoding" "encoding/base64" "encoding/json" + "reflect" "unsafe" ) @@ -31,7 +32,9 @@ type intCodec struct { } func (codec *intCodec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*int)(ptr)) = iter.ReadInt() + if !iter.ReadNil() { + *((*int)(ptr)) = iter.ReadInt() + } } func (codec *intCodec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -50,7 +53,9 @@ type uintptrCodec struct { } func (codec *uintptrCodec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*uintptr)(ptr)) = uintptr(iter.ReadUint64()) + if !iter.ReadNil() { + *((*uintptr)(ptr)) = uintptr(iter.ReadUint64()) + } } func (codec *uintptrCodec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -69,7 +74,9 @@ type int8Codec struct { } func (codec *int8Codec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*int8)(ptr)) = iter.ReadInt8() + if !iter.ReadNil() { + *((*int8)(ptr)) = iter.ReadInt8() + } } func (codec *int8Codec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -88,7 +95,9 @@ type int16Codec struct { } func (codec *int16Codec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*int16)(ptr)) = iter.ReadInt16() + if !iter.ReadNil() { + *((*int16)(ptr)) = iter.ReadInt16() + } } func (codec *int16Codec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -107,7 +116,9 @@ type int32Codec struct { } func (codec *int32Codec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*int32)(ptr)) = iter.ReadInt32() + if !iter.ReadNil() { + *((*int32)(ptr)) = iter.ReadInt32() + } } func (codec *int32Codec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -126,7 +137,9 @@ type int64Codec struct { } func (codec *int64Codec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*int64)(ptr)) = iter.ReadInt64() + if !iter.ReadNil() { + *((*int64)(ptr)) = iter.ReadInt64() + } } func (codec *int64Codec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -145,7 +158,10 @@ type uintCodec struct { } func (codec *uintCodec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*uint)(ptr)) = iter.ReadUint() + if !iter.ReadNil() { + *((*uint)(ptr)) = iter.ReadUint() + return + } } func (codec *uintCodec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -164,7 +180,9 @@ type uint8Codec struct { } func (codec *uint8Codec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*uint8)(ptr)) = iter.ReadUint8() + if !iter.ReadNil() { + *((*uint8)(ptr)) = iter.ReadUint8() + } } func (codec *uint8Codec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -183,7 +201,9 @@ type uint16Codec struct { } func (codec *uint16Codec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*uint16)(ptr)) = iter.ReadUint16() + if !iter.ReadNil() { + *((*uint16)(ptr)) = iter.ReadUint16() + } } func (codec *uint16Codec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -202,7 +222,9 @@ type uint32Codec struct { } func (codec *uint32Codec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*uint32)(ptr)) = iter.ReadUint32() + if !iter.ReadNil() { + *((*uint32)(ptr)) = iter.ReadUint32() + } } func (codec *uint32Codec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -221,7 +243,9 @@ type uint64Codec struct { } func (codec *uint64Codec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*uint64)(ptr)) = iter.ReadUint64() + if !iter.ReadNil() { + *((*uint64)(ptr)) = iter.ReadUint64() + } } func (codec *uint64Codec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -240,7 +264,9 @@ type float32Codec struct { } func (codec *float32Codec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*float32)(ptr)) = iter.ReadFloat32() + if !iter.ReadNil() { + *((*float32)(ptr)) = iter.ReadFloat32() + } } func (codec *float32Codec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -259,7 +285,9 @@ type float64Codec struct { } func (codec *float64Codec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*float64)(ptr)) = iter.ReadFloat64() + if !iter.ReadNil() { + *((*float64)(ptr)) = iter.ReadFloat64() + } } func (codec *float64Codec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -278,7 +306,9 @@ type boolCodec struct { } func (codec *boolCodec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*bool)(ptr)) = iter.ReadBool() + if !iter.ReadNil() { + *((*bool)(ptr)) = iter.ReadBool() + } } func (codec *boolCodec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -297,7 +327,42 @@ type emptyInterfaceCodec struct { } func (codec *emptyInterfaceCodec) Decode(ptr unsafe.Pointer, iter *Iterator) { - *((*interface{})(ptr)) = iter.Read() + existing := *((*interface{})(ptr)) + + // Checking for both typed and untyped nil pointers. + if existing != nil && + reflect.TypeOf(existing).Kind() == reflect.Ptr && + !reflect.ValueOf(existing).IsNil() { + + var ptrToExisting interface{} + for { + elem := reflect.ValueOf(existing).Elem() + if elem.Kind() != reflect.Ptr || elem.IsNil() { + break + } + ptrToExisting = existing + existing = elem.Interface() + } + + if iter.ReadNil() { + if ptrToExisting != nil { + nilPtr := reflect.Zero(reflect.TypeOf(ptrToExisting).Elem()) + reflect.ValueOf(ptrToExisting).Elem().Set(nilPtr) + } else { + *((*interface{})(ptr)) = nil + } + } else { + iter.ReadVal(existing) + } + + return + } + + if iter.ReadNil() { + *((*interface{})(ptr)) = nil + } else { + *((*interface{})(ptr)) = iter.Read() + } } func (codec *emptyInterfaceCodec) Encode(ptr unsafe.Pointer, stream *Stream) { @@ -309,7 +374,8 @@ func (codec *emptyInterfaceCodec) EncodeInterface(val interface{}, stream *Strea } func (codec *emptyInterfaceCodec) IsEmpty(ptr unsafe.Pointer) bool { - return ptr == nil + emptyInterface := (*emptyInterface)(ptr) + return emptyInterface.typ == nil } type nonEmptyInterfaceCodec struct { @@ -326,15 +392,20 @@ func (codec *nonEmptyInterfaceCodec) Decode(ptr unsafe.Pointer, iter *Iterator) e.typ = nonEmptyInterface.itab.typ e.word = nonEmptyInterface.word iter.ReadVal(&i) + if e.word == nil { + nonEmptyInterface.itab = nil + } nonEmptyInterface.word = e.word } func (codec *nonEmptyInterfaceCodec) Encode(ptr unsafe.Pointer, stream *Stream) { nonEmptyInterface := (*nonEmptyInterface)(ptr) var i interface{} - e := (*emptyInterface)(unsafe.Pointer(&i)) - e.typ = nonEmptyInterface.itab.typ - e.word = nonEmptyInterface.word + if nonEmptyInterface.itab != nil { + e := (*emptyInterface)(unsafe.Pointer(&i)) + e.typ = nonEmptyInterface.itab.typ + e.word = nonEmptyInterface.word + } stream.WriteVal(i) } @@ -595,7 +666,12 @@ func (encoder *marshalerEncoder) Encode(ptr unsafe.Pointer, stream *Stream) { templateInterface := encoder.templateInterface templateInterface.word = ptr realInterface := (*interface{})(unsafe.Pointer(&templateInterface)) - marshaler := (*realInterface).(json.Marshaler) + marshaler, ok := (*realInterface).(json.Marshaler) + if !ok { + stream.WriteVal(nil) + return + } + bytes, err := marshaler.MarshalJSON() if err != nil { stream.Error = err diff --git a/vendor/github.com/json-iterator/go/feature_reflect_object.go b/vendor/github.com/json-iterator/go/feature_reflect_object.go index 2a4283c1c..59b1235c0 100644 --- a/vendor/github.com/json-iterator/go/feature_reflect_object.go +++ b/vendor/github.com/json-iterator/go/feature_reflect_object.go @@ -4,8 +4,8 @@ import ( "fmt" "io" "reflect" - "unsafe" "strings" + "unsafe" ) func encoderOfStruct(cfg *frozenConfig, typ reflect.Type) (ValEncoder, error) { @@ -29,7 +29,7 @@ func encoderOfStruct(cfg *frozenConfig, typ reflect.Type) (ValEncoder, error) { if old.toName != toName { continue } - old.ignored, new.ignored = resolveConflictBinding(old.binding, new.binding) + old.ignored, new.ignored = resolveConflictBinding(cfg, old.binding, new.binding) } orderedBindings = append(orderedBindings, new) } @@ -49,9 +49,9 @@ func encoderOfStruct(cfg *frozenConfig, typ reflect.Type) (ValEncoder, error) { return &structEncoder{structDescriptor.onePtrEmbedded, structDescriptor.onePtrOptimization, finalOrderedFields}, nil } -func resolveConflictBinding(old, new *Binding) (ignoreOld, ignoreNew bool) { - newTagged := new.Field.Tag.Get("json") != "" - oldTagged := old.Field.Tag.Get("json") != "" +func resolveConflictBinding(cfg *frozenConfig, old, new *Binding) (ignoreOld, ignoreNew bool) { + newTagged := new.Field.Tag.Get(cfg.getTagKey()) != "" + oldTagged := old.Field.Tag.Get(cfg.getTagKey()) != "" if newTagged { if oldTagged { if len(old.levels) > len(new.levels) { @@ -91,7 +91,7 @@ func decoderOfStruct(cfg *frozenConfig, typ reflect.Type) (ValDecoder, error) { bindings[fromName] = binding continue } - ignoreOld, ignoreNew := resolveConflictBinding(old, binding) + ignoreOld, ignoreNew := resolveConflictBinding(cfg, old, binding) if ignoreOld { delete(bindings, fromName) } diff --git a/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go b/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go index 797b143a2..b3417fd73 100644 --- a/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go +++ b/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go @@ -4,8 +4,8 @@ import ( "fmt" "io" "reflect" - "unsafe" "strings" + "unsafe" ) func createStructDecoder(typ reflect.Type, fields map[string]*structFieldDecoder) (ValDecoder, error) { diff --git a/vendor/github.com/json-iterator/go/feature_stream_string.go b/vendor/github.com/json-iterator/go/feature_stream_string.go index 2856836f7..334282f05 100644 --- a/vendor/github.com/json-iterator/go/feature_stream_string.go +++ b/vendor/github.com/json-iterator/go/feature_stream_string.go @@ -289,6 +289,8 @@ func writeStringSlowPathWithHTMLEscaped(stream *Stream, i int, s string, valLen if start < i { stream.WriteRaw(s[start:i]) } + stream.WriteRaw(`\ufffd`) + i++ start = i continue } diff --git a/vendor/github.com/json-iterator/go/jsoniter_bool_test.go b/vendor/github.com/json-iterator/go/jsoniter_bool_test.go index 5f6a824d1..461b88ba3 100644 --- a/vendor/github.com/json-iterator/go/jsoniter_bool_test.go +++ b/vendor/github.com/json-iterator/go/jsoniter_bool_test.go @@ -82,3 +82,32 @@ func Test_decode_string_bool(t *testing.T) { err = Unmarshal([]byte(`{"Field":true}`), &obj) should.NotNil(err) } + +func Test_bool_can_be_null(t *testing.T) { + type TestData struct { + Field bool `json:"field"` + } + should := require.New(t) + + obj := TestData{} + data1 := []byte(`{"field": true}`) + err := Unmarshal(data1, &obj) + should.NoError(err) + should.Equal(true, obj.Field) + + data2 := []byte(`{"field": null}`) + err = Unmarshal(data2, &obj) + should.NoError(err) + // Same behavior as stdlib, not touching the existing value. + should.Equal(true, obj.Field) + + // Checking stdlib behavior as well + obj2 := TestData{} + err = json.Unmarshal(data1, &obj2) + should.NoError(err) + should.Equal(true, obj2.Field) + + err = json.Unmarshal(data2, &obj2) + should.NoError(err) + should.Equal(true, obj2.Field) +} diff --git a/vendor/github.com/json-iterator/go/jsoniter_customize_test.go b/vendor/github.com/json-iterator/go/jsoniter_customize_test.go index d625f6e33..628f89e45 100644 --- a/vendor/github.com/json-iterator/go/jsoniter_customize_test.go +++ b/vendor/github.com/json-iterator/go/jsoniter_customize_test.go @@ -2,11 +2,12 @@ package jsoniter import ( "encoding/json" - "github.com/stretchr/testify/require" "strconv" "testing" "time" "unsafe" + + "github.com/stretchr/testify/require" ) func Test_customize_type_decoder(t *testing.T) { @@ -82,7 +83,7 @@ func Test_customize_field_decoder(t *testing.T) { } type TestObject1 struct { - field1 string + Field1 string } type testExtension struct { @@ -93,7 +94,7 @@ func (extension *testExtension) UpdateStructDescriptor(structDescriptor *StructD if structDescriptor.Type.String() != "jsoniter.TestObject1" { return } - binding := structDescriptor.GetField("field1") + binding := structDescriptor.GetField("Field1") binding.Encoder = &funcEncoder{fun: func(ptr unsafe.Pointer, stream *Stream) { str := *((*string)(ptr)) val, _ := strconv.Atoi(str) @@ -112,7 +113,7 @@ func Test_customize_field_by_extension(t *testing.T) { obj := TestObject1{} err := UnmarshalFromString(`{"field-1": 100}`, &obj) should.Nil(err) - should.Equal("100", obj.field1) + should.Equal("100", obj.Field1) str, err := MarshalToString(obj) should.Nil(err) should.Equal(`{"field-1":100}`, str) @@ -285,3 +286,56 @@ func Test_marshal_json_with_time(t *testing.T) { should.Nil(Unmarshal([]byte(`{"TF1":{"F1":"fake","F2":"fake"}}`), &obj)) should.NotNil(obj.TF1.F2) } + +func Test_customize_tag_key(t *testing.T) { + + type TestObject struct { + Field string `orm:"field"` + } + + should := require.New(t) + json := Config{TagKey: "orm"}.Froze() + str, err := json.MarshalToString(TestObject{"hello"}) + should.Nil(err) + should.Equal(`{"field":"hello"}`, str) +} + +func Test_recursive_empty_interface_customization(t *testing.T) { + t.Skip() + var obj interface{} + RegisterTypeDecoderFunc("interface {}", func(ptr unsafe.Pointer, iter *Iterator) { + switch iter.WhatIsNext() { + case NumberValue: + *(*interface{})(ptr) = iter.ReadInt64() + default: + *(*interface{})(ptr) = iter.Read() + } + }) + should := require.New(t) + Unmarshal([]byte("[100]"), &obj) + should.Equal([]interface{}{int64(100)}, obj) +} + +type GeoLocation struct { + Id string `json:"id,omitempty" db:"id"` +} + +func (p *GeoLocation) MarshalJSON() ([]byte, error) { + return []byte(`{}`), nil +} + +func (p *GeoLocation) UnmarshalJSON(input []byte) error { + p.Id = "hello" + return nil +} + +func Test_marshal_and_unmarshal_on_non_pointer(t *testing.T) { + should := require.New(t) + locations := []GeoLocation{{"000"}} + bytes, err := Marshal(locations) + should.Nil(err) + should.Equal("[{}]", string(bytes)) + err = Unmarshal([]byte("[1]"), &locations) + should.Nil(err) + should.Equal("hello", locations[0].Id) +} diff --git a/vendor/github.com/json-iterator/go/jsoniter_enum_marshaler_test.go b/vendor/github.com/json-iterator/go/jsoniter_enum_marshaler_test.go new file mode 100644 index 000000000..69e1e8cd3 --- /dev/null +++ b/vendor/github.com/json-iterator/go/jsoniter_enum_marshaler_test.go @@ -0,0 +1,50 @@ +package jsoniter + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" +) + +type MyEnum int64 + +const ( + MyEnumA MyEnum = iota + MyEnumB +) + +func (m *MyEnum) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf(`"foo-%d"`, int(*m))), nil +} + +func (m *MyEnum) UnmarshalJSON(jb []byte) error { + switch string(jb) { + case `"foo-1"`: + *m = MyEnumB + default: + *m = MyEnumA + } + return nil +} + +func Test_custom_marshaler_on_enum(t *testing.T) { + type Wrapper struct { + Payload interface{} + } + type Wrapper2 struct { + Payload MyEnum + } + should := require.New(t) + + w := Wrapper{Payload: MyEnumB} + + jb, err := Marshal(w) + should.NoError(err) + should.Equal(`{"Payload":"foo-1"}`, string(jb)) + + var w2 Wrapper2 + err = Unmarshal(jb, &w2) + should.NoError(err) + should.Equal(MyEnumB, w2.Payload) +} diff --git a/vendor/github.com/json-iterator/go/jsoniter_int_test.go b/vendor/github.com/json-iterator/go/jsoniter_int_test.go index 9d639d70b..79670c77c 100644 --- a/vendor/github.com/json-iterator/go/jsoniter_int_test.go +++ b/vendor/github.com/json-iterator/go/jsoniter_int_test.go @@ -20,7 +20,45 @@ func Test_read_uint64_invalid(t *testing.T) { should.NotNil(iter.Error) } -func Test_read_int8(t *testing.T) { +func Test_read_int_from_null(t *testing.T) { + + type TestObject struct { + F1 int8 + F2 int16 + F3 int32 + F4 int64 + F5 int + F6 uint8 + F7 uint16 + F8 uint32 + F9 uint64 + F10 uint + F11 float32 + F12 float64 + F13 uintptr + } + + should := require.New(t) + obj := TestObject{} + err := Unmarshal([]byte(`{ + "f1":null, + "f2":null, + "f3":null, + "f4":null, + "f5":null, + "f6":null, + "f7":null, + "f8":null, + "f9":null, + "f10":null, + "f11":null, + "f12":null, + "f13":null + }`), &obj) + should.Nil(err) +} + +func _int8(t *testing.T) { inputs := []string{`127`, `-128`} for _, input := range inputs { t.Run(fmt.Sprintf("%v", input), func(t *testing.T) { diff --git a/vendor/github.com/json-iterator/go/jsoniter_interface_test.go b/vendor/github.com/json-iterator/go/jsoniter_interface_test.go index c037049e7..5a0528865 100644 --- a/vendor/github.com/json-iterator/go/jsoniter_interface_test.go +++ b/vendor/github.com/json-iterator/go/jsoniter_interface_test.go @@ -2,9 +2,11 @@ package jsoniter import ( "encoding/json" - "github.com/stretchr/testify/require" + "fmt" "testing" "unsafe" + + "github.com/stretchr/testify/require" ) func Test_write_array_of_interface(t *testing.T) { @@ -297,3 +299,262 @@ func Test_array_with_nothing(t *testing.T) { should.Nil(err) should.Equal(`[null,null]`, output) } + +func Test_unmarshal_ptr_to_interface(t *testing.T) { + type TestData struct { + Name string `json:"name"` + } + should := require.New(t) + var obj interface{} = &TestData{} + err := json.Unmarshal([]byte(`{"name":"value"}`), &obj) + should.Nil(err) + should.Equal("&{value}", fmt.Sprintf("%v", obj)) + obj = interface{}(&TestData{}) + err = Unmarshal([]byte(`{"name":"value"}`), &obj) + should.Nil(err) + should.Equal("&{value}", fmt.Sprintf("%v", obj)) +} + +func Test_nil_out_null_interface(t *testing.T) { + type TestData struct { + Field interface{} `json:"field"` + } + should := require.New(t) + + var boolVar bool + obj := TestData{ + Field: &boolVar, + } + + data1 := []byte(`{"field": true}`) + + err := Unmarshal(data1, &obj) + should.NoError(err) + should.Equal(true, *(obj.Field.(*bool))) + + data2 := []byte(`{"field": null}`) + + err = Unmarshal(data2, &obj) + should.NoError(err) + should.Equal(nil, obj.Field) + + // Checking stdlib behavior matches. + obj2 := TestData{ + Field: &boolVar, + } + + err = json.Unmarshal(data1, &obj2) + should.NoError(err) + should.Equal(true, *(obj2.Field.(*bool))) + + err = json.Unmarshal(data2, &obj2) + should.NoError(err) + should.Equal(nil, obj2.Field) +} + +func Test_omitempty_nil_interface(t *testing.T) { + type TestData struct { + Field interface{} `json:"field,omitempty"` + } + should := require.New(t) + + obj := TestData{ + Field: nil, + } + + js, err := json.Marshal(obj) + should.NoError(err) + should.Equal("{}", string(js)) + + str, err := MarshalToString(obj) + should.NoError(err) + should.Equal(string(js), str) +} + +func Test_omitempty_nil_nonempty_interface(t *testing.T) { + type TestData struct { + Field MyInterface `json:"field,omitempty"` + } + should := require.New(t) + + obj := TestData{ + Field: nil, + } + + js, err := json.Marshal(obj) + should.NoError(err) + should.Equal("{}", string(js)) + + str, err := MarshalToString(obj) + should.NoError(err) + should.Equal(string(js), str) + + obj.Field = MyString("hello") + err = UnmarshalFromString(`{"field":null}`, &obj) + should.NoError(err) + should.Equal(nil, obj.Field) +} + +func Test_marshal_nil_marshaler_interface(t *testing.T) { + type TestData struct { + Field json.Marshaler `json:"field"` + } + should := require.New(t) + + obj := TestData{ + Field: nil, + } + + js, err := json.Marshal(obj) + should.NoError(err) + should.Equal(`{"field":null}`, string(js)) + + str, err := MarshalToString(obj) + should.NoError(err) + should.Equal(string(js), str) +} + +func Test_marshal_nil_nonempty_interface(t *testing.T) { + type TestData struct { + Field MyInterface `json:"field"` + } + should := require.New(t) + + obj := TestData{ + Field: nil, + } + + js, err := json.Marshal(obj) + should.NoError(err) + should.Equal(`{"field":null}`, string(js)) + + str, err := MarshalToString(obj) + should.NoError(err) + should.Equal(string(js), str) + + obj.Field = MyString("hello") + err = Unmarshal(js, &obj) + should.NoError(err) + should.Equal(nil, obj.Field) +} + +func Test_overwrite_interface_ptr_value_with_nil(t *testing.T) { + type Wrapper struct { + Payload interface{} `json:"payload,omitempty"` + } + type Payload struct { + Value int `json:"val,omitempty"` + } + + should := require.New(t) + + payload := &Payload{} + wrapper := &Wrapper{ + Payload: &payload, + } + + err := json.Unmarshal([]byte(`{"payload": {"val": 42}}`), &wrapper) + should.Equal(nil, err) + should.Equal(&payload, wrapper.Payload) + should.Equal(42, (*(wrapper.Payload.(**Payload))).Value) + + err = json.Unmarshal([]byte(`{"payload": null}`), &wrapper) + should.Equal(nil, err) + should.Equal(&payload, wrapper.Payload) + should.Equal((*Payload)(nil), payload) + + payload = &Payload{} + wrapper = &Wrapper{ + Payload: &payload, + } + + err = Unmarshal([]byte(`{"payload": {"val": 42}}`), &wrapper) + should.Equal(nil, err) + should.Equal(&payload, wrapper.Payload) + should.Equal(42, (*(wrapper.Payload.(**Payload))).Value) + + err = Unmarshal([]byte(`{"payload": null}`), &wrapper) + should.Equal(nil, err) + should.Equal(&payload, wrapper.Payload) + should.Equal((*Payload)(nil), payload) +} + +func Test_overwrite_interface_value_with_nil(t *testing.T) { + type Wrapper struct { + Payload interface{} `json:"payload,omitempty"` + } + type Payload struct { + Value int `json:"val,omitempty"` + } + + should := require.New(t) + + payload := &Payload{} + wrapper := &Wrapper{ + Payload: payload, + } + + err := json.Unmarshal([]byte(`{"payload": {"val": 42}}`), &wrapper) + should.Equal(nil, err) + should.Equal(42, (*(wrapper.Payload.(*Payload))).Value) + + err = json.Unmarshal([]byte(`{"payload": null}`), &wrapper) + should.Equal(nil, err) + should.Equal(nil, wrapper.Payload) + should.Equal(42, payload.Value) + + payload = &Payload{} + wrapper = &Wrapper{ + Payload: payload, + } + + err = Unmarshal([]byte(`{"payload": {"val": 42}}`), &wrapper) + should.Equal(nil, err) + should.Equal(42, (*(wrapper.Payload.(*Payload))).Value) + + err = Unmarshal([]byte(`{"payload": null}`), &wrapper) + should.Equal(nil, err) + should.Equal(nil, wrapper.Payload) + should.Equal(42, payload.Value) +} + +func Test_unmarshal_into_nil(t *testing.T) { + type Payload struct { + Value int `json:"val,omitempty"` + } + type Wrapper struct { + Payload interface{} `json:"payload,omitempty"` + } + + should := require.New(t) + + var payload *Payload + wrapper := &Wrapper{ + Payload: payload, + } + + err := json.Unmarshal([]byte(`{"payload": {"val": 42}}`), &wrapper) + should.Nil(err) + should.NotNil(wrapper.Payload) + should.Nil(payload) + + err = json.Unmarshal([]byte(`{"payload": null}`), &wrapper) + should.Nil(err) + should.Nil(wrapper.Payload) + should.Nil(payload) + + payload = nil + wrapper = &Wrapper{ + Payload: payload, + } + + err = Unmarshal([]byte(`{"payload": {"val": 42}}`), &wrapper) + should.Nil(err) + should.NotNil(wrapper.Payload) + should.Nil(payload) + + err = Unmarshal([]byte(`{"payload": null}`), &wrapper) + should.Nil(err) + should.Nil(wrapper.Payload) + should.Nil(payload) +} diff --git a/vendor/github.com/json-iterator/go/jsoniter_invalid_test.go b/vendor/github.com/json-iterator/go/jsoniter_invalid_test.go index 358c19a7b..9f30bf5d8 100644 --- a/vendor/github.com/json-iterator/go/jsoniter_invalid_test.go +++ b/vendor/github.com/json-iterator/go/jsoniter_invalid_test.go @@ -1,6 +1,7 @@ package jsoniter import ( + "bytes" "encoding/json" "github.com/stretchr/testify/require" "io" @@ -98,3 +99,34 @@ func Test_invalid_float(t *testing.T) { }) } } + +func Test_chan(t *testing.T) { + t.Skip("do not support chan") + + type TestObject struct { + MyChan chan bool + MyField int + } + + should := require.New(t) + obj := TestObject{} + str, err := json.Marshal(obj) + should.Nil(err) + should.Equal(``, str) +} + +func Test_invalid_number(t *testing.T) { + type Message struct { + Number int `json:"number"` + } + obj := Message{} + decoder := ConfigCompatibleWithStandardLibrary.NewDecoder(bytes.NewBufferString(`{"number":"5"}`)) + err := decoder.Decode(&obj) + invalidStr := err.Error() + result, err := ConfigCompatibleWithStandardLibrary.Marshal(invalidStr) + should := require.New(t) + should.Nil(err) + result2, err := json.Marshal(invalidStr) + should.Nil(err) + should.Equal(string(result2), string(result)) +} diff --git a/vendor/github.com/json-iterator/go/jsoniter_null_test.go b/vendor/github.com/json-iterator/go/jsoniter_null_test.go index df71bf2f1..8c891470f 100644 --- a/vendor/github.com/json-iterator/go/jsoniter_null_test.go +++ b/vendor/github.com/json-iterator/go/jsoniter_null_test.go @@ -3,9 +3,10 @@ package jsoniter import ( "bytes" "encoding/json" - "github.com/stretchr/testify/require" "io" "testing" + + "github.com/stretchr/testify/require" ) func Test_read_null(t *testing.T) { @@ -135,3 +136,33 @@ func Test_encode_nil_array(t *testing.T) { should.Nil(err) should.Equal("null", string(output)) } + +func Test_decode_nil_num(t *testing.T) { + type TestData struct { + Field int `json:"field"` + } + should := require.New(t) + + data1 := []byte(`{"field": 42}`) + data2 := []byte(`{"field": null}`) + + // Checking stdlib behavior as well + obj2 := TestData{} + err := json.Unmarshal(data1, &obj2) + should.Equal(nil, err) + should.Equal(42, obj2.Field) + + err = json.Unmarshal(data2, &obj2) + should.Equal(nil, err) + should.Equal(42, obj2.Field) + + obj := TestData{} + + err = Unmarshal(data1, &obj) + should.Equal(nil, err) + should.Equal(42, obj.Field) + + err = Unmarshal(data2, &obj) + should.Equal(nil, err) + should.Equal(42, obj.Field) +} diff --git a/vendor/github.com/json-iterator/go/jsoniter_raw_message_test.go b/vendor/github.com/json-iterator/go/jsoniter_raw_message_test.go index d7b65b2c7..a3c67d001 100644 --- a/vendor/github.com/json-iterator/go/jsoniter_raw_message_test.go +++ b/vendor/github.com/json-iterator/go/jsoniter_raw_message_test.go @@ -72,3 +72,17 @@ func Test_encode_map_of_jsoniter_raw_message(t *testing.T) { should.Nil(err) should.Equal(`{"hello":[]}`, output) } + +func Test_marshal_invalid_json_raw_message(t *testing.T) { + type A struct { + Raw json.RawMessage `json:"raw"` + } + message := []byte(`{}`) + + a := A{} + should := require.New(t) + should.Nil(ConfigCompatibleWithStandardLibrary.Unmarshal(message, &a)) + aout, aouterr := ConfigCompatibleWithStandardLibrary.Marshal(&a) + should.Equal(`{"raw":null}`, string(aout)) + should.Nil(aouterr) +} diff --git a/vendor/github.com/json-iterator/go/jsoniter_struct_decoder_test.go b/vendor/github.com/json-iterator/go/jsoniter_struct_decoder_test.go index 93ab4813f..257bbdb65 100644 --- a/vendor/github.com/json-iterator/go/jsoniter_struct_decoder_test.go +++ b/vendor/github.com/json-iterator/go/jsoniter_struct_decoder_test.go @@ -1,8 +1,8 @@ package jsoniter import ( - "testing" "github.com/stretchr/testify/require" + "testing" ) func Test_decode_one_field_struct(t *testing.T) { diff --git a/vendor/github.com/json-iterator/go/jsoniter_struct_encoder_test.go b/vendor/github.com/json-iterator/go/jsoniter_struct_encoder_test.go new file mode 100644 index 000000000..0e3e54188 --- /dev/null +++ b/vendor/github.com/json-iterator/go/jsoniter_struct_encoder_test.go @@ -0,0 +1,52 @@ +package jsoniter + +import ( + "encoding/json" + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +func Test_encode_unexported_field(t *testing.T) { + type TestData struct { + a int + b <-chan int + C int + d *time.Timer + } + + should := require.New(t) + + testChan := make(<-chan int, 10) + testTimer := time.NewTimer(10 * time.Second) + + obj := &TestData{ + a: 42, + b: testChan, + C: 21, + d: testTimer, + } + + jb, err := json.Marshal(obj) + should.NoError(err) + should.Equal([]byte(`{"C":21}`), jb) + + err = json.Unmarshal([]byte(`{"a": 444, "b":"bad", "C":55, "d":{"not": "a timer"}}`), obj) + should.NoError(err) + should.Equal(42, obj.a) + should.Equal(testChan, obj.b) + should.Equal(55, obj.C) + should.Equal(testTimer, obj.d) + + jb, err = Marshal(obj) + should.NoError(err) + should.Equal(jb, []byte(`{"C":55}`)) + + err = Unmarshal([]byte(`{"a": 444, "b":"bad", "C":256, "d":{"not":"a timer"}}`), obj) + should.NoError(err) + should.Equal(42, obj.a) + should.Equal(testChan, obj.b) + should.Equal(256, obj.C) + should.Equal(testTimer, obj.d) +} diff --git a/vendor/github.com/json-iterator/go/output_tests/builtins/int64/json_test.go b/vendor/github.com/json-iterator/go/output_tests/builtins/int64/json_test.go new file mode 100644 index 000000000..3c35ffe5f --- /dev/null +++ b/vendor/github.com/json-iterator/go/output_tests/builtins/int64/json_test.go @@ -0,0 +1,152 @@ +package test + +import ( + "bytes" + "encoding/json" + "fmt" + "strings" + "testing" + + "github.com/davecgh/go-spew/spew" + fuzz "github.com/google/gofuzz" + jsoniter "github.com/json-iterator/go" +) + +func Test_Roundtrip(t *testing.T) { + fz := fuzz.New().MaxDepth(10).NilChance(0.3) + for i := 0; i < 100; i++ { + var before typeForTest + fz.Fuzz(&before) + + jbStd, err := json.Marshal(before) + if err != nil { + t.Fatalf("failed to marshal with stdlib: %v", err) + } + if len(strings.TrimSpace(string(jbStd))) == 0 { + t.Fatal("stdlib marshal produced empty result and no error") + } + jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before) + if err != nil { + t.Fatalf("failed to marshal with jsoniter: %v", err) + } + if len(strings.TrimSpace(string(jbIter))) == 0 { + t.Fatal("jsoniter marshal produced empty result and no error") + } + if string(jbStd) != string(jbIter) { + t.Fatalf("marshal expected:\n %s\ngot:\n %s\nobj:\n %s", + indent(jbStd, " "), indent(jbIter, " "), dump(before)) + } + + var afterStd typeForTest + err = json.Unmarshal(jbIter, &afterStd) + if err != nil { + t.Fatalf("failed to unmarshal with stdlib: %v\nvia:\n %s", + err, indent(jbIter, " ")) + } + var afterIter typeForTest + err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter) + if err != nil { + t.Fatalf("failed to unmarshal with jsoniter: %v\nvia:\n %s", + err, indent(jbIter, " ")) + } + if fingerprint(afterStd) != fingerprint(afterIter) { + t.Fatalf("unmarshal expected:\n %s\ngot:\n %s\nvia:\n %s", + dump(afterStd), dump(afterIter), indent(jbIter, " ")) + } + } +} + +const indentStr = "> " + +func fingerprint(obj interface{}) string { + c := spew.ConfigState{ + SortKeys: true, + SpewKeys: true, + } + return c.Sprintf("%v", obj) +} + +func dump(obj interface{}) string { + cfg := spew.ConfigState{ + Indent: indentStr, + } + return cfg.Sdump(obj) +} + +func indent(src []byte, prefix string) string { + var buf bytes.Buffer + err := json.Indent(&buf, src, prefix, indentStr) + if err != nil { + return fmt.Sprintf("!!! %v", err) + } + return buf.String() +} + +func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) { + t.ReportAllocs() + t.ResetTimer() + + var obj typeForTest + fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3) + fz.Fuzz(&obj) + for i := 0; i < t.N; i++ { + jb, err := fn(obj) + if err != nil { + t.Fatalf("%s failed to marshal:\n input: %s\n error: %v", name, dump(obj), err) + } + _ = jb + } +} + +func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) { + t.ReportAllocs() + t.ResetTimer() + + var before typeForTest + fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3) + fz.Fuzz(&before) + jb, err := json.Marshal(before) + if err != nil { + t.Fatalf("failed to marshal: %v", err) + } + + for i := 0; i < t.N; i++ { + var after typeForTest + err = fn(jb, &after) + if err != nil { + t.Fatalf("%s failed to unmarshal:\n input: %q\n error: %v", name, string(jb), err) + } + } +} + +func BenchmarkStandardMarshal(t *testing.B) { + benchmarkMarshal(t, "stdlib", json.Marshal) +} + +func BenchmarkStandardUnmarshal(t *testing.B) { + benchmarkUnmarshal(t, "stdlib", json.Unmarshal) +} + +func BenchmarkJSONIterMarshalFastest(t *testing.B) { + benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal) +} + +func BenchmarkJSONIterUnmarshalFastest(t *testing.B) { + benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal) +} + +func BenchmarkJSONIterMarshalDefault(t *testing.B) { + benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal) +} + +func BenchmarkJSONIterUnmarshalDefault(t *testing.B) { + benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal) +} + +func BenchmarkJSONIterMarshalCompatible(t *testing.B) { + benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal) +} + +func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) { + benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal) +} diff --git a/vendor/github.com/json-iterator/go/output_tests/builtins/int64/types.go b/vendor/github.com/json-iterator/go/output_tests/builtins/int64/types.go new file mode 100644 index 000000000..063f5acc8 --- /dev/null +++ b/vendor/github.com/json-iterator/go/output_tests/builtins/int64/types.go @@ -0,0 +1,3 @@ +package test + +type typeForTest int64 diff --git a/vendor/github.com/json-iterator/go/output_tests/map/int64/string/json_test.go b/vendor/github.com/json-iterator/go/output_tests/map/int64/string/json_test.go new file mode 100644 index 000000000..3c35ffe5f --- /dev/null +++ b/vendor/github.com/json-iterator/go/output_tests/map/int64/string/json_test.go @@ -0,0 +1,152 @@ +package test + +import ( + "bytes" + "encoding/json" + "fmt" + "strings" + "testing" + + "github.com/davecgh/go-spew/spew" + fuzz "github.com/google/gofuzz" + jsoniter "github.com/json-iterator/go" +) + +func Test_Roundtrip(t *testing.T) { + fz := fuzz.New().MaxDepth(10).NilChance(0.3) + for i := 0; i < 100; i++ { + var before typeForTest + fz.Fuzz(&before) + + jbStd, err := json.Marshal(before) + if err != nil { + t.Fatalf("failed to marshal with stdlib: %v", err) + } + if len(strings.TrimSpace(string(jbStd))) == 0 { + t.Fatal("stdlib marshal produced empty result and no error") + } + jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before) + if err != nil { + t.Fatalf("failed to marshal with jsoniter: %v", err) + } + if len(strings.TrimSpace(string(jbIter))) == 0 { + t.Fatal("jsoniter marshal produced empty result and no error") + } + if string(jbStd) != string(jbIter) { + t.Fatalf("marshal expected:\n %s\ngot:\n %s\nobj:\n %s", + indent(jbStd, " "), indent(jbIter, " "), dump(before)) + } + + var afterStd typeForTest + err = json.Unmarshal(jbIter, &afterStd) + if err != nil { + t.Fatalf("failed to unmarshal with stdlib: %v\nvia:\n %s", + err, indent(jbIter, " ")) + } + var afterIter typeForTest + err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter) + if err != nil { + t.Fatalf("failed to unmarshal with jsoniter: %v\nvia:\n %s", + err, indent(jbIter, " ")) + } + if fingerprint(afterStd) != fingerprint(afterIter) { + t.Fatalf("unmarshal expected:\n %s\ngot:\n %s\nvia:\n %s", + dump(afterStd), dump(afterIter), indent(jbIter, " ")) + } + } +} + +const indentStr = "> " + +func fingerprint(obj interface{}) string { + c := spew.ConfigState{ + SortKeys: true, + SpewKeys: true, + } + return c.Sprintf("%v", obj) +} + +func dump(obj interface{}) string { + cfg := spew.ConfigState{ + Indent: indentStr, + } + return cfg.Sdump(obj) +} + +func indent(src []byte, prefix string) string { + var buf bytes.Buffer + err := json.Indent(&buf, src, prefix, indentStr) + if err != nil { + return fmt.Sprintf("!!! %v", err) + } + return buf.String() +} + +func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) { + t.ReportAllocs() + t.ResetTimer() + + var obj typeForTest + fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3) + fz.Fuzz(&obj) + for i := 0; i < t.N; i++ { + jb, err := fn(obj) + if err != nil { + t.Fatalf("%s failed to marshal:\n input: %s\n error: %v", name, dump(obj), err) + } + _ = jb + } +} + +func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) { + t.ReportAllocs() + t.ResetTimer() + + var before typeForTest + fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3) + fz.Fuzz(&before) + jb, err := json.Marshal(before) + if err != nil { + t.Fatalf("failed to marshal: %v", err) + } + + for i := 0; i < t.N; i++ { + var after typeForTest + err = fn(jb, &after) + if err != nil { + t.Fatalf("%s failed to unmarshal:\n input: %q\n error: %v", name, string(jb), err) + } + } +} + +func BenchmarkStandardMarshal(t *testing.B) { + benchmarkMarshal(t, "stdlib", json.Marshal) +} + +func BenchmarkStandardUnmarshal(t *testing.B) { + benchmarkUnmarshal(t, "stdlib", json.Unmarshal) +} + +func BenchmarkJSONIterMarshalFastest(t *testing.B) { + benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal) +} + +func BenchmarkJSONIterUnmarshalFastest(t *testing.B) { + benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal) +} + +func BenchmarkJSONIterMarshalDefault(t *testing.B) { + benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal) +} + +func BenchmarkJSONIterUnmarshalDefault(t *testing.B) { + benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal) +} + +func BenchmarkJSONIterMarshalCompatible(t *testing.B) { + benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal) +} + +func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) { + benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal) +} diff --git a/vendor/github.com/json-iterator/go/output_tests/map/int64/string/types.go b/vendor/github.com/json-iterator/go/output_tests/map/int64/string/types.go new file mode 100644 index 000000000..c5e915d23 --- /dev/null +++ b/vendor/github.com/json-iterator/go/output_tests/map/int64/string/types.go @@ -0,0 +1,3 @@ +package test + +type typeForTest map[int64]string diff --git a/vendor/github.com/json-iterator/go/output_tests/slice/int64/json_test.go b/vendor/github.com/json-iterator/go/output_tests/slice/int64/json_test.go new file mode 100644 index 000000000..3c35ffe5f --- /dev/null +++ b/vendor/github.com/json-iterator/go/output_tests/slice/int64/json_test.go @@ -0,0 +1,152 @@ +package test + +import ( + "bytes" + "encoding/json" + "fmt" + "strings" + "testing" + + "github.com/davecgh/go-spew/spew" + fuzz "github.com/google/gofuzz" + jsoniter "github.com/json-iterator/go" +) + +func Test_Roundtrip(t *testing.T) { + fz := fuzz.New().MaxDepth(10).NilChance(0.3) + for i := 0; i < 100; i++ { + var before typeForTest + fz.Fuzz(&before) + + jbStd, err := json.Marshal(before) + if err != nil { + t.Fatalf("failed to marshal with stdlib: %v", err) + } + if len(strings.TrimSpace(string(jbStd))) == 0 { + t.Fatal("stdlib marshal produced empty result and no error") + } + jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before) + if err != nil { + t.Fatalf("failed to marshal with jsoniter: %v", err) + } + if len(strings.TrimSpace(string(jbIter))) == 0 { + t.Fatal("jsoniter marshal produced empty result and no error") + } + if string(jbStd) != string(jbIter) { + t.Fatalf("marshal expected:\n %s\ngot:\n %s\nobj:\n %s", + indent(jbStd, " "), indent(jbIter, " "), dump(before)) + } + + var afterStd typeForTest + err = json.Unmarshal(jbIter, &afterStd) + if err != nil { + t.Fatalf("failed to unmarshal with stdlib: %v\nvia:\n %s", + err, indent(jbIter, " ")) + } + var afterIter typeForTest + err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter) + if err != nil { + t.Fatalf("failed to unmarshal with jsoniter: %v\nvia:\n %s", + err, indent(jbIter, " ")) + } + if fingerprint(afterStd) != fingerprint(afterIter) { + t.Fatalf("unmarshal expected:\n %s\ngot:\n %s\nvia:\n %s", + dump(afterStd), dump(afterIter), indent(jbIter, " ")) + } + } +} + +const indentStr = "> " + +func fingerprint(obj interface{}) string { + c := spew.ConfigState{ + SortKeys: true, + SpewKeys: true, + } + return c.Sprintf("%v", obj) +} + +func dump(obj interface{}) string { + cfg := spew.ConfigState{ + Indent: indentStr, + } + return cfg.Sdump(obj) +} + +func indent(src []byte, prefix string) string { + var buf bytes.Buffer + err := json.Indent(&buf, src, prefix, indentStr) + if err != nil { + return fmt.Sprintf("!!! %v", err) + } + return buf.String() +} + +func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) { + t.ReportAllocs() + t.ResetTimer() + + var obj typeForTest + fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3) + fz.Fuzz(&obj) + for i := 0; i < t.N; i++ { + jb, err := fn(obj) + if err != nil { + t.Fatalf("%s failed to marshal:\n input: %s\n error: %v", name, dump(obj), err) + } + _ = jb + } +} + +func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) { + t.ReportAllocs() + t.ResetTimer() + + var before typeForTest + fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3) + fz.Fuzz(&before) + jb, err := json.Marshal(before) + if err != nil { + t.Fatalf("failed to marshal: %v", err) + } + + for i := 0; i < t.N; i++ { + var after typeForTest + err = fn(jb, &after) + if err != nil { + t.Fatalf("%s failed to unmarshal:\n input: %q\n error: %v", name, string(jb), err) + } + } +} + +func BenchmarkStandardMarshal(t *testing.B) { + benchmarkMarshal(t, "stdlib", json.Marshal) +} + +func BenchmarkStandardUnmarshal(t *testing.B) { + benchmarkUnmarshal(t, "stdlib", json.Unmarshal) +} + +func BenchmarkJSONIterMarshalFastest(t *testing.B) { + benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal) +} + +func BenchmarkJSONIterUnmarshalFastest(t *testing.B) { + benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal) +} + +func BenchmarkJSONIterMarshalDefault(t *testing.B) { + benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal) +} + +func BenchmarkJSONIterUnmarshalDefault(t *testing.B) { + benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal) +} + +func BenchmarkJSONIterMarshalCompatible(t *testing.B) { + benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal) +} + +func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) { + benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal) +} diff --git a/vendor/github.com/json-iterator/go/output_tests/slice/int64/types.go b/vendor/github.com/json-iterator/go/output_tests/slice/int64/types.go new file mode 100644 index 000000000..335616cad --- /dev/null +++ b/vendor/github.com/json-iterator/go/output_tests/slice/int64/types.go @@ -0,0 +1,3 @@ +package test + +type typeForTest []int64 diff --git a/vendor/github.com/json-iterator/go/output_tests/struct/everything/types.go b/vendor/github.com/json-iterator/go/output_tests/struct/everything/types.go index 14a71d2b9..c287fa40e 100644 --- a/vendor/github.com/json-iterator/go/output_tests/struct/everything/types.go +++ b/vendor/github.com/json-iterator/go/output_tests/struct/everything/types.go @@ -8,9 +8,11 @@ type typeForTest struct { Int8 int8 Int16 int16 Int32 int32 + Int64 int64 Uint8 uint8 Uint16 uint16 Uint32 uint32 + Uint64 uint64 Float32 float32 Float64 float64 String1 string diff --git a/vendor/github.com/json-iterator/go/output_tests/struct/int64/json_test.go b/vendor/github.com/json-iterator/go/output_tests/struct/int64/json_test.go new file mode 100644 index 000000000..3c35ffe5f --- /dev/null +++ b/vendor/github.com/json-iterator/go/output_tests/struct/int64/json_test.go @@ -0,0 +1,152 @@ +package test + +import ( + "bytes" + "encoding/json" + "fmt" + "strings" + "testing" + + "github.com/davecgh/go-spew/spew" + fuzz "github.com/google/gofuzz" + jsoniter "github.com/json-iterator/go" +) + +func Test_Roundtrip(t *testing.T) { + fz := fuzz.New().MaxDepth(10).NilChance(0.3) + for i := 0; i < 100; i++ { + var before typeForTest + fz.Fuzz(&before) + + jbStd, err := json.Marshal(before) + if err != nil { + t.Fatalf("failed to marshal with stdlib: %v", err) + } + if len(strings.TrimSpace(string(jbStd))) == 0 { + t.Fatal("stdlib marshal produced empty result and no error") + } + jbIter, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(before) + if err != nil { + t.Fatalf("failed to marshal with jsoniter: %v", err) + } + if len(strings.TrimSpace(string(jbIter))) == 0 { + t.Fatal("jsoniter marshal produced empty result and no error") + } + if string(jbStd) != string(jbIter) { + t.Fatalf("marshal expected:\n %s\ngot:\n %s\nobj:\n %s", + indent(jbStd, " "), indent(jbIter, " "), dump(before)) + } + + var afterStd typeForTest + err = json.Unmarshal(jbIter, &afterStd) + if err != nil { + t.Fatalf("failed to unmarshal with stdlib: %v\nvia:\n %s", + err, indent(jbIter, " ")) + } + var afterIter typeForTest + err = jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(jbIter, &afterIter) + if err != nil { + t.Fatalf("failed to unmarshal with jsoniter: %v\nvia:\n %s", + err, indent(jbIter, " ")) + } + if fingerprint(afterStd) != fingerprint(afterIter) { + t.Fatalf("unmarshal expected:\n %s\ngot:\n %s\nvia:\n %s", + dump(afterStd), dump(afterIter), indent(jbIter, " ")) + } + } +} + +const indentStr = "> " + +func fingerprint(obj interface{}) string { + c := spew.ConfigState{ + SortKeys: true, + SpewKeys: true, + } + return c.Sprintf("%v", obj) +} + +func dump(obj interface{}) string { + cfg := spew.ConfigState{ + Indent: indentStr, + } + return cfg.Sdump(obj) +} + +func indent(src []byte, prefix string) string { + var buf bytes.Buffer + err := json.Indent(&buf, src, prefix, indentStr) + if err != nil { + return fmt.Sprintf("!!! %v", err) + } + return buf.String() +} + +func benchmarkMarshal(t *testing.B, name string, fn func(interface{}) ([]byte, error)) { + t.ReportAllocs() + t.ResetTimer() + + var obj typeForTest + fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3) + fz.Fuzz(&obj) + for i := 0; i < t.N; i++ { + jb, err := fn(obj) + if err != nil { + t.Fatalf("%s failed to marshal:\n input: %s\n error: %v", name, dump(obj), err) + } + _ = jb + } +} + +func benchmarkUnmarshal(t *testing.B, name string, fn func(data []byte, v interface{}) error) { + t.ReportAllocs() + t.ResetTimer() + + var before typeForTest + fz := fuzz.NewWithSeed(0).MaxDepth(10).NilChance(0.3) + fz.Fuzz(&before) + jb, err := json.Marshal(before) + if err != nil { + t.Fatalf("failed to marshal: %v", err) + } + + for i := 0; i < t.N; i++ { + var after typeForTest + err = fn(jb, &after) + if err != nil { + t.Fatalf("%s failed to unmarshal:\n input: %q\n error: %v", name, string(jb), err) + } + } +} + +func BenchmarkStandardMarshal(t *testing.B) { + benchmarkMarshal(t, "stdlib", json.Marshal) +} + +func BenchmarkStandardUnmarshal(t *testing.B) { + benchmarkUnmarshal(t, "stdlib", json.Unmarshal) +} + +func BenchmarkJSONIterMarshalFastest(t *testing.B) { + benchmarkMarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Marshal) +} + +func BenchmarkJSONIterUnmarshalFastest(t *testing.B) { + benchmarkUnmarshal(t, "jsoniter-fastest", jsoniter.ConfigFastest.Unmarshal) +} + +func BenchmarkJSONIterMarshalDefault(t *testing.B) { + benchmarkMarshal(t, "jsoniter-default", jsoniter.Marshal) +} + +func BenchmarkJSONIterUnmarshalDefault(t *testing.B) { + benchmarkUnmarshal(t, "jsoniter-default", jsoniter.Unmarshal) +} + +func BenchmarkJSONIterMarshalCompatible(t *testing.B) { + benchmarkMarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal) +} + +func BenchmarkJSONIterUnmarshalCompatible(t *testing.B) { + benchmarkUnmarshal(t, "jsoniter-compat", jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal) +} diff --git a/vendor/github.com/json-iterator/go/output_tests/struct/int64/types.go b/vendor/github.com/json-iterator/go/output_tests/struct/int64/types.go new file mode 100644 index 000000000..cf7701629 --- /dev/null +++ b/vendor/github.com/json-iterator/go/output_tests/struct/int64/types.go @@ -0,0 +1,5 @@ +package test + +type typeForTest struct { + F int64 +} diff --git a/vendor/github.com/jtolds/gls/context.go b/vendor/github.com/jtolds/gls/context.go index 618a17106..94d7fbb7f 100644 --- a/vendor/github.com/jtolds/gls/context.go +++ b/vendor/github.com/jtolds/gls/context.go @@ -2,10 +2,16 @@ package gls import ( + "runtime" "sync" ) +const ( + maxCallers = 64 +) + var ( + stackTagPool = &idPool{} mgrRegistry = make(map[*ContextManager]bool) mgrRegistryMtx sync.RWMutex ) @@ -14,13 +20,18 @@ var ( // set multiple values at once. type Values map[interface{}]interface{} +func currentStack(skip int) []uintptr { + stack := make([]uintptr, maxCallers) + return stack[:runtime.Callers(2+skip, stack)] +} + // ContextManager is the main entrypoint for interacting with // Goroutine-local-storage. You can have multiple independent ContextManagers // at any given time. ContextManagers are usually declared globally for a given // class of context variables. You should use NewContextManager for // construction. type ContextManager struct { - mtx sync.Mutex + mtx sync.RWMutex values map[uint]Values } @@ -57,77 +68,63 @@ func (m *ContextManager) SetValues(new_values Values, context_call func()) { return } - mutated_keys := make([]interface{}, 0, len(new_values)) - mutated_vals := make(Values, len(new_values)) - - EnsureGoroutineId(func(gid uint) { - m.mtx.Lock() - state, found := m.values[gid] - if !found { - state = make(Values, len(new_values)) - m.values[gid] = state - } - m.mtx.Unlock() - - for key, new_val := range new_values { - mutated_keys = append(mutated_keys, key) - if old_val, ok := state[key]; ok { - mutated_vals[key] = old_val - } - state[key] = new_val - } + tags := readStackTags(currentStack(1)) - defer func() { - if !found { - m.mtx.Lock() - delete(m.values, gid) - m.mtx.Unlock() - return + m.mtx.Lock() + values := new_values + for _, tag := range tags { + if existing_values, ok := m.values[tag]; ok { + // oh, we found existing values, let's make a copy + values = make(Values, len(existing_values)+len(new_values)) + for key, val := range existing_values { + values[key] = val } - - for _, key := range mutated_keys { - if val, ok := mutated_vals[key]; ok { - state[key] = val - } else { - delete(state, key) - } + for key, val := range new_values { + values[key] = val } - }() + break + } + } + new_tag := stackTagPool.Acquire() + m.values[new_tag] = values + m.mtx.Unlock() + defer func() { + m.mtx.Lock() + delete(m.values, new_tag) + m.mtx.Unlock() + stackTagPool.Release(new_tag) + }() - context_call() - }) + addStackTag(new_tag, context_call) } // GetValue will return a previously set value, provided that the value was set // by SetValues somewhere higher up the stack. If the value is not found, ok // will be false. -func (m *ContextManager) GetValue(key interface{}) ( - value interface{}, ok bool) { - gid, ok := GetGoroutineId() - if !ok { - return nil, false - } - - m.mtx.Lock() - state, found := m.values[gid] - m.mtx.Unlock() - - if !found { - return nil, false +func (m *ContextManager) GetValue(key interface{}) (value interface{}, ok bool) { + + tags := readStackTags(currentStack(1)) + m.mtx.RLock() + defer m.mtx.RUnlock() + for _, tag := range tags { + if values, ok := m.values[tag]; ok { + value, ok := values[key] + return value, ok + } } - value, ok = state[key] - return value, ok + return "", false } func (m *ContextManager) getValues() Values { - gid, ok := GetGoroutineId() - if !ok { - return nil + tags := readStackTags(currentStack(2)) + m.mtx.RLock() + defer m.mtx.RUnlock() + for _, tag := range tags { + if values, ok := m.values[tag]; ok { + return values + } } - m.mtx.Lock() - state, _ := m.values[gid] - m.mtx.Unlock() - return state + return nil } // Go preserves ContextManager values and Goroutine-local-storage across new @@ -140,12 +137,12 @@ func Go(cb func()) { mgrRegistryMtx.RLock() defer mgrRegistryMtx.RUnlock() - for mgr := range mgrRegistry { + for mgr, _ := range mgrRegistry { values := mgr.getValues() if len(values) > 0 { - cb = func(mgr *ContextManager, cb func()) func() { - return func() { mgr.SetValues(values, cb) } - }(mgr, cb) + mgr_copy := mgr + cb_copy := cb + cb = func() { mgr_copy.SetValues(values, cb_copy) } } } diff --git a/vendor/github.com/jtolds/gls/context_test.go b/vendor/github.com/jtolds/gls/context_test.go index 2fa426cb5..ae5bde4ae 100644 --- a/vendor/github.com/jtolds/gls/context_test.go +++ b/vendor/github.com/jtolds/gls/context_test.go @@ -1,18 +1,16 @@ -package gls_test +package gls import ( "fmt" "sync" "testing" - - "github.com/jtolds/gls" ) func TestContexts(t *testing.T) { - mgr1 := gls.NewContextManager() - mgr2 := gls.NewContextManager() + mgr1 := NewContextManager() + mgr2 := NewContextManager() - CheckVal := func(mgr *gls.ContextManager, key, exp_val string) { + CheckVal := func(mgr *ContextManager, key, exp_val string) { val, ok := mgr.GetValue(key) if len(exp_val) == 0 { if ok { @@ -39,11 +37,11 @@ func TestContexts(t *testing.T) { } Check("", "", "", "") - mgr2.SetValues(gls.Values{"key1": "val1c"}, func() { + mgr2.SetValues(Values{"key1": "val1c"}, func() { Check("", "", "val1c", "") - mgr1.SetValues(gls.Values{"key1": "val1a"}, func() { + mgr1.SetValues(Values{"key1": "val1a"}, func() { Check("val1a", "", "val1c", "") - mgr1.SetValues(gls.Values{"key2": "val1b"}, func() { + mgr1.SetValues(Values{"key2": "val1b"}, func() { Check("val1a", "val1b", "val1c", "") var wg sync.WaitGroup wg.Add(2) @@ -51,24 +49,20 @@ func TestContexts(t *testing.T) { defer wg.Done() Check("", "", "", "") }() - gls.Go(func() { + Go(func() { defer wg.Done() Check("val1a", "val1b", "val1c", "") }) wg.Wait() - Check("val1a", "val1b", "val1c", "") }) - Check("val1a", "", "val1c", "") }) - Check("", "", "val1c", "") }) - Check("", "", "", "") } func ExampleContextManager_SetValues() { var ( - mgr = gls.NewContextManager() - request_id_key = gls.GenSym() + mgr = NewContextManager() + request_id_key = GenSym() ) MyLog := func() { @@ -79,7 +73,7 @@ func ExampleContextManager_SetValues() { } } - mgr.SetValues(gls.Values{request_id_key: "12345"}, func() { + mgr.SetValues(Values{request_id_key: "12345"}, func() { MyLog() }) MyLog() @@ -90,8 +84,8 @@ func ExampleContextManager_SetValues() { func ExampleGo() { var ( - mgr = gls.NewContextManager() - request_id_key = gls.GenSym() + mgr = NewContextManager() + request_id_key = GenSym() ) MyLog := func() { @@ -102,7 +96,7 @@ func ExampleGo() { } } - mgr.SetValues(gls.Values{request_id_key: "12345"}, func() { + mgr.SetValues(Values{request_id_key: "12345"}, func() { var wg sync.WaitGroup wg.Add(1) go func() { @@ -111,7 +105,7 @@ func ExampleGo() { }() wg.Wait() wg.Add(1) - gls.Go(func() { + Go(func() { defer wg.Done() MyLog() }) @@ -123,8 +117,8 @@ func ExampleGo() { } func BenchmarkGetValue(b *testing.B) { - mgr := gls.NewContextManager() - mgr.SetValues(gls.Values{"test_key": "test_val"}, func() { + mgr := NewContextManager() + mgr.SetValues(Values{"test_key": "test_val"}, func() { b.ResetTimer() for i := 0; i < b.N; i++ { val, ok := mgr.GetValue("test_key") @@ -136,10 +130,10 @@ func BenchmarkGetValue(b *testing.B) { } func BenchmarkSetValues(b *testing.B) { - mgr := gls.NewContextManager() + mgr := NewContextManager() for i := 0; i < b.N/2; i++ { - mgr.SetValues(gls.Values{"test_key": "test_val"}, func() { - mgr.SetValues(gls.Values{"test_key2": "test_val2"}, func() {}) + mgr.SetValues(Values{"test_key": "test_val"}, func() { + mgr.SetValues(Values{"test_key2": "test_val2"}, func() {}) }) } } diff --git a/vendor/github.com/jtolds/gls/gen_sym.go b/vendor/github.com/jtolds/gls/gen_sym.go index 7f615cce9..8d5fc24d4 100644 --- a/vendor/github.com/jtolds/gls/gen_sym.go +++ b/vendor/github.com/jtolds/gls/gen_sym.go @@ -1,21 +1,13 @@ package gls -import ( - "sync" -) - var ( - keyMtx sync.Mutex - keyCounter uint64 + symPool = &idPool{} ) // ContextKey is a throwaway value you can use as a key to a ContextManager -type ContextKey struct{ id uint64 } +type ContextKey struct{ id uint } // GenSym will return a brand new, never-before-used ContextKey func GenSym() ContextKey { - keyMtx.Lock() - defer keyMtx.Unlock() - keyCounter += 1 - return ContextKey{id: keyCounter} + return ContextKey{id: symPool.Acquire()} } diff --git a/vendor/github.com/jtolds/gls/gid.go b/vendor/github.com/jtolds/gls/gid.go deleted file mode 100644 index c16bf3a55..000000000 --- a/vendor/github.com/jtolds/gls/gid.go +++ /dev/null @@ -1,25 +0,0 @@ -package gls - -var ( - stackTagPool = &idPool{} -) - -// Will return this goroutine's identifier if set. If you always need a -// goroutine identifier, you should use EnsureGoroutineId which will make one -// if there isn't one already. -func GetGoroutineId() (gid uint, ok bool) { - return readStackTag() -} - -// Will call cb with the current goroutine identifier. If one hasn't already -// been generated, one will be created and set first. The goroutine identifier -// might be invalid after cb returns. -func EnsureGoroutineId(cb func(gid uint)) { - if gid, ok := readStackTag(); ok { - cb(gid) - return - } - gid := stackTagPool.Acquire() - defer stackTagPool.Release(gid) - addStackTag(gid, func() { cb(gid) }) -} diff --git a/vendor/github.com/jtolds/gls/stack_tags.go b/vendor/github.com/jtolds/gls/stack_tags.go index cc95dcd8e..562a2fab7 100644 --- a/vendor/github.com/jtolds/gls/stack_tags.go +++ b/vendor/github.com/jtolds/gls/stack_tags.go @@ -2,73 +2,69 @@ package gls // so, basically, we're going to encode integer tags in base-16 on the stack -const ( - bitWidth = 4 - stackBatchSize = 16 +import ( + "reflect" + "runtime" ) -var ( - pc_lookup = make(map[uintptr]int8, 17) - mark_lookup [16]func(uint, func()) +const ( + bitWidth = 4 ) +func addStackTag(tag uint, context_call func()) { + if context_call == nil { + return + } + markS(tag, context_call) +} + +func markS(tag uint, cb func()) { _m(tag, cb) } +func mark0(tag uint, cb func()) { _m(tag, cb) } +func mark1(tag uint, cb func()) { _m(tag, cb) } +func mark2(tag uint, cb func()) { _m(tag, cb) } +func mark3(tag uint, cb func()) { _m(tag, cb) } +func mark4(tag uint, cb func()) { _m(tag, cb) } +func mark5(tag uint, cb func()) { _m(tag, cb) } +func mark6(tag uint, cb func()) { _m(tag, cb) } +func mark7(tag uint, cb func()) { _m(tag, cb) } +func mark8(tag uint, cb func()) { _m(tag, cb) } +func mark9(tag uint, cb func()) { _m(tag, cb) } +func markA(tag uint, cb func()) { _m(tag, cb) } +func markB(tag uint, cb func()) { _m(tag, cb) } +func markC(tag uint, cb func()) { _m(tag, cb) } +func markD(tag uint, cb func()) { _m(tag, cb) } +func markE(tag uint, cb func()) { _m(tag, cb) } +func markF(tag uint, cb func()) { _m(tag, cb) } + +var pc_lookup = make(map[uintptr]int8, 17) +var mark_lookup [16]func(uint, func()) + func init() { setEntries := func(f func(uint, func()), v int8) { - var ptr uintptr - f(0, func() { - ptr = findPtr() - }) - pc_lookup[ptr] = v + pc_lookup[reflect.ValueOf(f).Pointer()] = v if v >= 0 { mark_lookup[v] = f } } - setEntries(github_com_jtolds_gls_markS, -0x1) - setEntries(github_com_jtolds_gls_mark0, 0x0) - setEntries(github_com_jtolds_gls_mark1, 0x1) - setEntries(github_com_jtolds_gls_mark2, 0x2) - setEntries(github_com_jtolds_gls_mark3, 0x3) - setEntries(github_com_jtolds_gls_mark4, 0x4) - setEntries(github_com_jtolds_gls_mark5, 0x5) - setEntries(github_com_jtolds_gls_mark6, 0x6) - setEntries(github_com_jtolds_gls_mark7, 0x7) - setEntries(github_com_jtolds_gls_mark8, 0x8) - setEntries(github_com_jtolds_gls_mark9, 0x9) - setEntries(github_com_jtolds_gls_markA, 0xa) - setEntries(github_com_jtolds_gls_markB, 0xb) - setEntries(github_com_jtolds_gls_markC, 0xc) - setEntries(github_com_jtolds_gls_markD, 0xd) - setEntries(github_com_jtolds_gls_markE, 0xe) - setEntries(github_com_jtolds_gls_markF, 0xf) + setEntries(markS, -0x1) + setEntries(mark0, 0x0) + setEntries(mark1, 0x1) + setEntries(mark2, 0x2) + setEntries(mark3, 0x3) + setEntries(mark4, 0x4) + setEntries(mark5, 0x5) + setEntries(mark6, 0x6) + setEntries(mark7, 0x7) + setEntries(mark8, 0x8) + setEntries(mark9, 0x9) + setEntries(markA, 0xa) + setEntries(markB, 0xb) + setEntries(markC, 0xc) + setEntries(markD, 0xd) + setEntries(markE, 0xe) + setEntries(markF, 0xf) } -func addStackTag(tag uint, context_call func()) { - if context_call == nil { - return - } - github_com_jtolds_gls_markS(tag, context_call) -} - -// these private methods are named this horrendous name so gopherjs support -// is easier. it shouldn't add any runtime cost in non-js builds. -func github_com_jtolds_gls_markS(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_mark0(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_mark1(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_mark2(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_mark3(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_mark4(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_mark5(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_mark6(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_mark7(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_mark8(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_mark9(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_markA(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_markB(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_markC(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_markD(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_markE(tag uint, cb func()) { _m(tag, cb) } -func github_com_jtolds_gls_markF(tag uint, cb func()) { _m(tag, cb) } - func _m(tag_remainder uint, cb func()) { if tag_remainder == 0 { cb() @@ -77,37 +73,21 @@ func _m(tag_remainder uint, cb func()) { } } -func readStackTag() (tag uint, ok bool) { +func readStackTags(stack []uintptr) (tags []uint) { var current_tag uint - offset := 0 - for { - batch, next_offset := getStack(offset, stackBatchSize) - for _, pc := range batch { - val, ok := pc_lookup[pc] - if !ok { - continue - } - if val < 0 { - return current_tag, true - } - current_tag <<= bitWidth - current_tag += uint(val) + for _, pc := range stack { + pc = runtime.FuncForPC(pc).Entry() + val, ok := pc_lookup[pc] + if !ok { + continue } - if next_offset == 0 { - break + if val < 0 { + tags = append(tags, current_tag) + current_tag = 0 + continue } - offset = next_offset + current_tag <<= bitWidth + current_tag += uint(val) } - return 0, false -} - -func (m *ContextManager) preventInlining() { - // dunno if findPtr or getStack are likely to get inlined in a future release - // of go, but if they are inlined and their callers are inlined, that could - // hork some things. let's do our best to explain to the compiler that we - // really don't want those two functions inlined by saying they could change - // at any time. assumes preventInlining doesn't get compiled out. - // this whole thing is probably overkill. - findPtr = m.values[0][0].(func() uintptr) - getStack = m.values[0][1].(func(int, int) ([]uintptr, int)) + return } diff --git a/vendor/github.com/jtolds/gls/stack_tags_js.go b/vendor/github.com/jtolds/gls/stack_tags_js.go deleted file mode 100644 index c4e8b801d..000000000 --- a/vendor/github.com/jtolds/gls/stack_tags_js.go +++ /dev/null @@ -1,75 +0,0 @@ -// +build js - -package gls - -// This file is used for GopherJS builds, which don't have normal runtime -// stack trace support - -import ( - "strconv" - "strings" - - "github.com/gopherjs/gopherjs/js" -) - -const ( - jsFuncNamePrefix = "github_com_jtolds_gls_mark" -) - -func jsMarkStack() (f []uintptr) { - lines := strings.Split( - js.Global.Get("Error").New().Get("stack").String(), "\n") - f = make([]uintptr, 0, len(lines)) - for i, line := range lines { - line = strings.TrimSpace(line) - if line == "" { - continue - } - if i == 0 { - if line != "Error" { - panic("didn't understand js stack trace") - } - continue - } - fields := strings.Fields(line) - if len(fields) < 2 || fields[0] != "at" { - panic("didn't understand js stack trace") - } - - pos := strings.Index(fields[1], jsFuncNamePrefix) - if pos < 0 { - continue - } - pos += len(jsFuncNamePrefix) - if pos >= len(fields[1]) { - panic("didn't understand js stack trace") - } - char := string(fields[1][pos]) - switch char { - case "S": - f = append(f, uintptr(0)) - default: - val, err := strconv.ParseUint(char, 16, 8) - if err != nil { - panic("didn't understand js stack trace") - } - f = append(f, uintptr(val)+1) - } - } - return f -} - -// variables to prevent inlining -var ( - findPtr = func() uintptr { - funcs := jsMarkStack() - if len(funcs) == 0 { - panic("failed to find function pointer") - } - return funcs[0] - } - - getStack = func(offset, amount int) (stack []uintptr, next_offset int) { - return jsMarkStack(), 0 - } -) diff --git a/vendor/github.com/jtolds/gls/stack_tags_main.go b/vendor/github.com/jtolds/gls/stack_tags_main.go deleted file mode 100644 index 4da89e44f..000000000 --- a/vendor/github.com/jtolds/gls/stack_tags_main.go +++ /dev/null @@ -1,30 +0,0 @@ -// +build !js - -package gls - -// This file is used for standard Go builds, which have the expected runtime -// support - -import ( - "runtime" -) - -var ( - findPtr = func() uintptr { - var pc [1]uintptr - n := runtime.Callers(4, pc[:]) - if n != 1 { - panic("failed to find function pointer") - } - return pc[0] - } - - getStack = func(offset, amount int) (stack []uintptr, next_offset int) { - stack = make([]uintptr, amount) - stack = stack[:runtime.Callers(offset, stack)] - if len(stack) < amount { - return stack, 0 - } - return stack, offset + len(stack) - } -) diff --git a/vendor/github.com/mattn/go-colorable/.travis.yml b/vendor/github.com/mattn/go-colorable/.travis.yml deleted file mode 100644 index 98db8f060..000000000 --- a/vendor/github.com/mattn/go-colorable/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: go -go: - - tip - -before_install: - - go get github.com/mattn/goveralls - - go get golang.org/x/tools/cmd/cover -script: - - $HOME/gopath/bin/goveralls -repotoken xnXqRGwgW3SXIguzxf90ZSK1GPYZPaGrw diff --git a/vendor/github.com/mattn/go-colorable/README.md b/vendor/github.com/mattn/go-colorable/README.md deleted file mode 100644 index 56729a92c..000000000 --- a/vendor/github.com/mattn/go-colorable/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# go-colorable - -[![Godoc Reference](https://godoc.org/github.com/mattn/go-colorable?status.svg)](http://godoc.org/github.com/mattn/go-colorable) -[![Build Status](https://travis-ci.org/mattn/go-colorable.svg?branch=master)](https://travis-ci.org/mattn/go-colorable) -[![Coverage Status](https://coveralls.io/repos/github/mattn/go-colorable/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-colorable?branch=master) -[![Go Report Card](https://goreportcard.com/badge/mattn/go-colorable)](https://goreportcard.com/report/mattn/go-colorable) - -Colorable writer for windows. - -For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.) -This package is possible to handle escape sequence for ansi color on windows. - -## Too Bad! - -![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/bad.png) - - -## So Good! - -![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/good.png) - -## Usage - -```go -logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true}) -logrus.SetOutput(colorable.NewColorableStdout()) - -logrus.Info("succeeded") -logrus.Warn("not correct") -logrus.Error("something error") -logrus.Fatal("panic") -``` - -You can compile above code on non-windows OSs. - -## Installation - -``` -$ go get github.com/mattn/go-colorable -``` - -# License - -MIT - -# Author - -Yasuhiro Matsumoto (a.k.a mattn) diff --git a/vendor/github.com/mattn/go-colorable/_example/escape-seq/main.go b/vendor/github.com/mattn/go-colorable/_example/escape-seq/main.go deleted file mode 100644 index 8cbcb9097..000000000 --- a/vendor/github.com/mattn/go-colorable/_example/escape-seq/main.go +++ /dev/null @@ -1,16 +0,0 @@ -package main - -import ( - "bufio" - "fmt" - - "github.com/mattn/go-colorable" -) - -func main() { - stdOut := bufio.NewWriter(colorable.NewColorableStdout()) - - fmt.Fprint(stdOut, "\x1B[3GMove to 3rd Column\n") - fmt.Fprint(stdOut, "\x1B[1;2HMove to 2nd Column on 1st Line\n") - stdOut.Flush() -} diff --git a/vendor/github.com/mattn/go-colorable/_example/logrus/main.go b/vendor/github.com/mattn/go-colorable/_example/logrus/main.go deleted file mode 100644 index c569164b2..000000000 --- a/vendor/github.com/mattn/go-colorable/_example/logrus/main.go +++ /dev/null @@ -1,16 +0,0 @@ -package main - -import ( - "github.com/mattn/go-colorable" - "github.com/sirupsen/logrus" -) - -func main() { - logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true}) - logrus.SetOutput(colorable.NewColorableStdout()) - - logrus.Info("succeeded") - logrus.Warn("not correct") - logrus.Error("something error") - logrus.Fatal("panic") -} diff --git a/vendor/github.com/mattn/go-colorable/_example/title/main.go b/vendor/github.com/mattn/go-colorable/_example/title/main.go deleted file mode 100644 index e208870e7..000000000 --- a/vendor/github.com/mattn/go-colorable/_example/title/main.go +++ /dev/null @@ -1,14 +0,0 @@ -package main - -import ( - "fmt" - "os" - . "github.com/mattn/go-colorable" -) - -func main() { - out := NewColorableStdout() - fmt.Fprint(out, "\x1B]0;TITLE Changed\007(See title and hit any key)") - var c [1]byte - os.Stdin.Read(c[:]) -} diff --git a/vendor/github.com/mattn/go-colorable/cmd/colorable/colorable.go b/vendor/github.com/mattn/go-colorable/cmd/colorable/colorable.go deleted file mode 100644 index 87904774c..000000000 --- a/vendor/github.com/mattn/go-colorable/cmd/colorable/colorable.go +++ /dev/null @@ -1,12 +0,0 @@ -package main - -import ( - "io" - "os" - - "github.com/mattn/go-colorable" -) - -func main() { - io.Copy(colorable.NewColorableStdout(), os.Stdin) -} diff --git a/vendor/github.com/mattn/go-colorable/colorable_appengine.go b/vendor/github.com/mattn/go-colorable/colorable_appengine.go deleted file mode 100644 index 1f28d773d..000000000 --- a/vendor/github.com/mattn/go-colorable/colorable_appengine.go +++ /dev/null @@ -1,29 +0,0 @@ -// +build appengine - -package colorable - -import ( - "io" - "os" - - _ "github.com/mattn/go-isatty" -) - -// NewColorable return new instance of Writer which handle escape sequence. -func NewColorable(file *os.File) io.Writer { - if file == nil { - panic("nil passed instead of *os.File to NewColorable()") - } - - return file -} - -// NewColorableStdout return new instance of Writer which handle escape sequence for stdout. -func NewColorableStdout() io.Writer { - return os.Stdout -} - -// NewColorableStderr return new instance of Writer which handle escape sequence for stderr. -func NewColorableStderr() io.Writer { - return os.Stderr -} diff --git a/vendor/github.com/mattn/go-colorable/colorable_others.go b/vendor/github.com/mattn/go-colorable/colorable_others.go deleted file mode 100644 index 887f203dc..000000000 --- a/vendor/github.com/mattn/go-colorable/colorable_others.go +++ /dev/null @@ -1,30 +0,0 @@ -// +build !windows -// +build !appengine - -package colorable - -import ( - "io" - "os" - - _ "github.com/mattn/go-isatty" -) - -// NewColorable return new instance of Writer which handle escape sequence. -func NewColorable(file *os.File) io.Writer { - if file == nil { - panic("nil passed instead of *os.File to NewColorable()") - } - - return file -} - -// NewColorableStdout return new instance of Writer which handle escape sequence for stdout. -func NewColorableStdout() io.Writer { - return os.Stdout -} - -// NewColorableStderr return new instance of Writer which handle escape sequence for stderr. -func NewColorableStderr() io.Writer { - return os.Stderr -} diff --git a/vendor/github.com/mattn/go-colorable/colorable_test.go b/vendor/github.com/mattn/go-colorable/colorable_test.go deleted file mode 100644 index 3069869a3..000000000 --- a/vendor/github.com/mattn/go-colorable/colorable_test.go +++ /dev/null @@ -1,83 +0,0 @@ -package colorable - -import ( - "bytes" - "os" - "runtime" - "testing" -) - -// checkEncoding checks that colorable is output encoding agnostic as long as -// the encoding is a superset of ASCII. This implies that one byte not part of -// an ANSI sequence must give exactly one byte in output -func checkEncoding(t *testing.T, data []byte) { - // Send non-UTF8 data to colorable - b := bytes.NewBuffer(make([]byte, 0, 10)) - if b.Len() != 0 { - t.FailNow() - } - // TODO move colorable wrapping outside the test - c := NewNonColorable(b) - c.Write(data) - if b.Len() != len(data) { - t.Fatalf("%d bytes expected, got %d", len(data), b.Len()) - } -} - -func TestEncoding(t *testing.T) { - checkEncoding(t, []byte{}) // Empty - checkEncoding(t, []byte(`abc`)) // "abc" - checkEncoding(t, []byte(`é`)) // "é" in UTF-8 - checkEncoding(t, []byte{233}) // 'é' in Latin-1 -} - -func TestNonColorable(t *testing.T) { - var buf bytes.Buffer - want := "hello" - NewNonColorable(&buf).Write([]byte("\x1b[0m" + want + "\x1b[2J")) - got := buf.String() - if got != "hello" { - t.Fatalf("want %q but %q", want, got) - } - - buf.Reset() - NewNonColorable(&buf).Write([]byte("\x1b[")) - got = buf.String() - if got != "" { - t.Fatalf("want %q but %q", "", got) - } -} - -func TestNonColorableNil(t *testing.T) { - paniced := false - func() { - defer func() { - recover() - paniced = true - }() - NewNonColorable(nil) - NewColorable(nil) - }() - - if !paniced { - t.Fatalf("should panic") - } -} - -func TestColorable(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skipf("skip this test on windows") - } - _, ok := NewColorableStdout().(*os.File) - if !ok { - t.Fatalf("should os.Stdout on UNIX") - } - _, ok = NewColorableStderr().(*os.File) - if !ok { - t.Fatalf("should os.Stdout on UNIX") - } - _, ok = NewColorable(os.Stdout).(*os.File) - if !ok { - t.Fatalf("should os.Stdout on UNIX") - } -} diff --git a/vendor/github.com/mattn/go-colorable/colorable_windows.go b/vendor/github.com/mattn/go-colorable/colorable_windows.go deleted file mode 100644 index d18bf7528..000000000 --- a/vendor/github.com/mattn/go-colorable/colorable_windows.go +++ /dev/null @@ -1,914 +0,0 @@ -// +build windows -// +build !appengine - -package colorable - -import ( - "bytes" - "io" - "math" - "os" - "strconv" - "strings" - "syscall" - "unsafe" - - "github.com/mattn/go-isatty" -) - -const ( - foregroundBlue = 0x1 - foregroundGreen = 0x2 - foregroundRed = 0x4 - foregroundIntensity = 0x8 - foregroundMask = (foregroundRed | foregroundBlue | foregroundGreen | foregroundIntensity) - backgroundBlue = 0x10 - backgroundGreen = 0x20 - backgroundRed = 0x40 - backgroundIntensity = 0x80 - backgroundMask = (backgroundRed | backgroundBlue | backgroundGreen | backgroundIntensity) -) - -type wchar uint16 -type short int16 -type dword uint32 -type word uint16 - -type coord struct { - x short - y short -} - -type smallRect struct { - left short - top short - right short - bottom short -} - -type consoleScreenBufferInfo struct { - size coord - cursorPosition coord - attributes word - window smallRect - maximumWindowSize coord -} - -type consoleCursorInfo struct { - size dword - visible int32 -} - -var ( - kernel32 = syscall.NewLazyDLL("kernel32.dll") - procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") - procSetConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute") - procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition") - procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW") - procFillConsoleOutputAttribute = kernel32.NewProc("FillConsoleOutputAttribute") - procGetConsoleCursorInfo = kernel32.NewProc("GetConsoleCursorInfo") - procSetConsoleCursorInfo = kernel32.NewProc("SetConsoleCursorInfo") - procSetConsoleTitle = kernel32.NewProc("SetConsoleTitleW") -) - -// Writer provide colorable Writer to the console -type Writer struct { - out io.Writer - handle syscall.Handle - oldattr word - oldpos coord -} - -// NewColorable return new instance of Writer which handle escape sequence from File. -func NewColorable(file *os.File) io.Writer { - if file == nil { - panic("nil passed instead of *os.File to NewColorable()") - } - - if isatty.IsTerminal(file.Fd()) { - var csbi consoleScreenBufferInfo - handle := syscall.Handle(file.Fd()) - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - return &Writer{out: file, handle: handle, oldattr: csbi.attributes, oldpos: coord{0, 0}} - } - return file -} - -// NewColorableStdout return new instance of Writer which handle escape sequence for stdout. -func NewColorableStdout() io.Writer { - return NewColorable(os.Stdout) -} - -// NewColorableStderr return new instance of Writer which handle escape sequence for stderr. -func NewColorableStderr() io.Writer { - return NewColorable(os.Stderr) -} - -var color256 = map[int]int{ - 0: 0x000000, - 1: 0x800000, - 2: 0x008000, - 3: 0x808000, - 4: 0x000080, - 5: 0x800080, - 6: 0x008080, - 7: 0xc0c0c0, - 8: 0x808080, - 9: 0xff0000, - 10: 0x00ff00, - 11: 0xffff00, - 12: 0x0000ff, - 13: 0xff00ff, - 14: 0x00ffff, - 15: 0xffffff, - 16: 0x000000, - 17: 0x00005f, - 18: 0x000087, - 19: 0x0000af, - 20: 0x0000d7, - 21: 0x0000ff, - 22: 0x005f00, - 23: 0x005f5f, - 24: 0x005f87, - 25: 0x005faf, - 26: 0x005fd7, - 27: 0x005fff, - 28: 0x008700, - 29: 0x00875f, - 30: 0x008787, - 31: 0x0087af, - 32: 0x0087d7, - 33: 0x0087ff, - 34: 0x00af00, - 35: 0x00af5f, - 36: 0x00af87, - 37: 0x00afaf, - 38: 0x00afd7, - 39: 0x00afff, - 40: 0x00d700, - 41: 0x00d75f, - 42: 0x00d787, - 43: 0x00d7af, - 44: 0x00d7d7, - 45: 0x00d7ff, - 46: 0x00ff00, - 47: 0x00ff5f, - 48: 0x00ff87, - 49: 0x00ffaf, - 50: 0x00ffd7, - 51: 0x00ffff, - 52: 0x5f0000, - 53: 0x5f005f, - 54: 0x5f0087, - 55: 0x5f00af, - 56: 0x5f00d7, - 57: 0x5f00ff, - 58: 0x5f5f00, - 59: 0x5f5f5f, - 60: 0x5f5f87, - 61: 0x5f5faf, - 62: 0x5f5fd7, - 63: 0x5f5fff, - 64: 0x5f8700, - 65: 0x5f875f, - 66: 0x5f8787, - 67: 0x5f87af, - 68: 0x5f87d7, - 69: 0x5f87ff, - 70: 0x5faf00, - 71: 0x5faf5f, - 72: 0x5faf87, - 73: 0x5fafaf, - 74: 0x5fafd7, - 75: 0x5fafff, - 76: 0x5fd700, - 77: 0x5fd75f, - 78: 0x5fd787, - 79: 0x5fd7af, - 80: 0x5fd7d7, - 81: 0x5fd7ff, - 82: 0x5fff00, - 83: 0x5fff5f, - 84: 0x5fff87, - 85: 0x5fffaf, - 86: 0x5fffd7, - 87: 0x5fffff, - 88: 0x870000, - 89: 0x87005f, - 90: 0x870087, - 91: 0x8700af, - 92: 0x8700d7, - 93: 0x8700ff, - 94: 0x875f00, - 95: 0x875f5f, - 96: 0x875f87, - 97: 0x875faf, - 98: 0x875fd7, - 99: 0x875fff, - 100: 0x878700, - 101: 0x87875f, - 102: 0x878787, - 103: 0x8787af, - 104: 0x8787d7, - 105: 0x8787ff, - 106: 0x87af00, - 107: 0x87af5f, - 108: 0x87af87, - 109: 0x87afaf, - 110: 0x87afd7, - 111: 0x87afff, - 112: 0x87d700, - 113: 0x87d75f, - 114: 0x87d787, - 115: 0x87d7af, - 116: 0x87d7d7, - 117: 0x87d7ff, - 118: 0x87ff00, - 119: 0x87ff5f, - 120: 0x87ff87, - 121: 0x87ffaf, - 122: 0x87ffd7, - 123: 0x87ffff, - 124: 0xaf0000, - 125: 0xaf005f, - 126: 0xaf0087, - 127: 0xaf00af, - 128: 0xaf00d7, - 129: 0xaf00ff, - 130: 0xaf5f00, - 131: 0xaf5f5f, - 132: 0xaf5f87, - 133: 0xaf5faf, - 134: 0xaf5fd7, - 135: 0xaf5fff, - 136: 0xaf8700, - 137: 0xaf875f, - 138: 0xaf8787, - 139: 0xaf87af, - 140: 0xaf87d7, - 141: 0xaf87ff, - 142: 0xafaf00, - 143: 0xafaf5f, - 144: 0xafaf87, - 145: 0xafafaf, - 146: 0xafafd7, - 147: 0xafafff, - 148: 0xafd700, - 149: 0xafd75f, - 150: 0xafd787, - 151: 0xafd7af, - 152: 0xafd7d7, - 153: 0xafd7ff, - 154: 0xafff00, - 155: 0xafff5f, - 156: 0xafff87, - 157: 0xafffaf, - 158: 0xafffd7, - 159: 0xafffff, - 160: 0xd70000, - 161: 0xd7005f, - 162: 0xd70087, - 163: 0xd700af, - 164: 0xd700d7, - 165: 0xd700ff, - 166: 0xd75f00, - 167: 0xd75f5f, - 168: 0xd75f87, - 169: 0xd75faf, - 170: 0xd75fd7, - 171: 0xd75fff, - 172: 0xd78700, - 173: 0xd7875f, - 174: 0xd78787, - 175: 0xd787af, - 176: 0xd787d7, - 177: 0xd787ff, - 178: 0xd7af00, - 179: 0xd7af5f, - 180: 0xd7af87, - 181: 0xd7afaf, - 182: 0xd7afd7, - 183: 0xd7afff, - 184: 0xd7d700, - 185: 0xd7d75f, - 186: 0xd7d787, - 187: 0xd7d7af, - 188: 0xd7d7d7, - 189: 0xd7d7ff, - 190: 0xd7ff00, - 191: 0xd7ff5f, - 192: 0xd7ff87, - 193: 0xd7ffaf, - 194: 0xd7ffd7, - 195: 0xd7ffff, - 196: 0xff0000, - 197: 0xff005f, - 198: 0xff0087, - 199: 0xff00af, - 200: 0xff00d7, - 201: 0xff00ff, - 202: 0xff5f00, - 203: 0xff5f5f, - 204: 0xff5f87, - 205: 0xff5faf, - 206: 0xff5fd7, - 207: 0xff5fff, - 208: 0xff8700, - 209: 0xff875f, - 210: 0xff8787, - 211: 0xff87af, - 212: 0xff87d7, - 213: 0xff87ff, - 214: 0xffaf00, - 215: 0xffaf5f, - 216: 0xffaf87, - 217: 0xffafaf, - 218: 0xffafd7, - 219: 0xffafff, - 220: 0xffd700, - 221: 0xffd75f, - 222: 0xffd787, - 223: 0xffd7af, - 224: 0xffd7d7, - 225: 0xffd7ff, - 226: 0xffff00, - 227: 0xffff5f, - 228: 0xffff87, - 229: 0xffffaf, - 230: 0xffffd7, - 231: 0xffffff, - 232: 0x080808, - 233: 0x121212, - 234: 0x1c1c1c, - 235: 0x262626, - 236: 0x303030, - 237: 0x3a3a3a, - 238: 0x444444, - 239: 0x4e4e4e, - 240: 0x585858, - 241: 0x626262, - 242: 0x6c6c6c, - 243: 0x767676, - 244: 0x808080, - 245: 0x8a8a8a, - 246: 0x949494, - 247: 0x9e9e9e, - 248: 0xa8a8a8, - 249: 0xb2b2b2, - 250: 0xbcbcbc, - 251: 0xc6c6c6, - 252: 0xd0d0d0, - 253: 0xdadada, - 254: 0xe4e4e4, - 255: 0xeeeeee, -} - -// `\033]0;TITLESTR\007` -func doTitleSequence(er *bytes.Reader) error { - var c byte - var err error - - c, err = er.ReadByte() - if err != nil { - return err - } - if c != '0' && c != '2' { - return nil - } - c, err = er.ReadByte() - if err != nil { - return err - } - if c != ';' { - return nil - } - title := make([]byte, 0, 80) - for { - c, err = er.ReadByte() - if err != nil { - return err - } - if c == 0x07 || c == '\n' { - break - } - title = append(title, c) - } - if len(title) > 0 { - title8, err := syscall.UTF16PtrFromString(string(title)) - if err == nil { - procSetConsoleTitle.Call(uintptr(unsafe.Pointer(title8))) - } - } - return nil -} - -// Write write data on console -func (w *Writer) Write(data []byte) (n int, err error) { - var csbi consoleScreenBufferInfo - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - - er := bytes.NewReader(data) - var bw [1]byte -loop: - for { - c1, err := er.ReadByte() - if err != nil { - break loop - } - if c1 != 0x1b { - bw[0] = c1 - w.out.Write(bw[:]) - continue - } - c2, err := er.ReadByte() - if err != nil { - break loop - } - - if c2 == ']' { - if err := doTitleSequence(er); err != nil { - break loop - } - continue - } - if c2 != 0x5b { - continue - } - - var buf bytes.Buffer - var m byte - for { - c, err := er.ReadByte() - if err != nil { - break loop - } - if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { - m = c - break - } - buf.Write([]byte(string(c))) - } - - switch m { - case 'A': - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.y -= short(n) - procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'B': - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.y += short(n) - procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'C': - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.x += short(n) - procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'D': - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.x -= short(n) - procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'E': - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.x = 0 - csbi.cursorPosition.y += short(n) - procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'F': - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.x = 0 - csbi.cursorPosition.y -= short(n) - procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'G': - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.x = short(n - 1) - procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'H', 'f': - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - if buf.Len() > 0 { - token := strings.Split(buf.String(), ";") - switch len(token) { - case 1: - n1, err := strconv.Atoi(token[0]) - if err != nil { - continue - } - csbi.cursorPosition.y = short(n1 - 1) - case 2: - n1, err := strconv.Atoi(token[0]) - if err != nil { - continue - } - n2, err := strconv.Atoi(token[1]) - if err != nil { - continue - } - csbi.cursorPosition.x = short(n2 - 1) - csbi.cursorPosition.y = short(n1 - 1) - } - } else { - csbi.cursorPosition.y = 0 - } - procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'J': - n := 0 - if buf.Len() > 0 { - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - } - var count, written dword - var cursor coord - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - switch n { - case 0: - cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y} - count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.size.y-csbi.cursorPosition.y)*csbi.size.x) - case 1: - cursor = coord{x: csbi.window.left, y: csbi.window.top} - count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.window.top-csbi.cursorPosition.y)*csbi.size.x) - case 2: - cursor = coord{x: csbi.window.left, y: csbi.window.top} - count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.size.y-csbi.cursorPosition.y)*csbi.size.x) - } - procFillConsoleOutputCharacter.Call(uintptr(w.handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) - procFillConsoleOutputAttribute.Call(uintptr(w.handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) - case 'K': - n := 0 - if buf.Len() > 0 { - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - } - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - var cursor coord - var count, written dword - switch n { - case 0: - cursor = coord{x: csbi.cursorPosition.x + 1, y: csbi.cursorPosition.y} - count = dword(csbi.size.x - csbi.cursorPosition.x - 1) - case 1: - cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y} - count = dword(csbi.size.x - csbi.cursorPosition.x) - case 2: - cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y} - count = dword(csbi.size.x) - } - procFillConsoleOutputCharacter.Call(uintptr(w.handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) - procFillConsoleOutputAttribute.Call(uintptr(w.handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) - case 'm': - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - attr := csbi.attributes - cs := buf.String() - if cs == "" { - procSetConsoleTextAttribute.Call(uintptr(w.handle), uintptr(w.oldattr)) - continue - } - token := strings.Split(cs, ";") - for i := 0; i < len(token); i++ { - ns := token[i] - if n, err = strconv.Atoi(ns); err == nil { - switch { - case n == 0 || n == 100: - attr = w.oldattr - case 1 <= n && n <= 5: - attr |= foregroundIntensity - case n == 7: - attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4) - case n == 22 || n == 25: - attr |= foregroundIntensity - case n == 27: - attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4) - case 30 <= n && n <= 37: - attr &= backgroundMask - if (n-30)&1 != 0 { - attr |= foregroundRed - } - if (n-30)&2 != 0 { - attr |= foregroundGreen - } - if (n-30)&4 != 0 { - attr |= foregroundBlue - } - case n == 38: // set foreground color. - if i < len(token)-2 && (token[i+1] == "5" || token[i+1] == "05") { - if n256, err := strconv.Atoi(token[i+2]); err == nil { - if n256foreAttr == nil { - n256setup() - } - attr &= backgroundMask - attr |= n256foreAttr[n256] - i += 2 - } - } else if len(token) == 5 && token[i+1] == "2" { - var r, g, b int - r, _ = strconv.Atoi(token[i+2]) - g, _ = strconv.Atoi(token[i+3]) - b, _ = strconv.Atoi(token[i+4]) - i += 4 - if r > 127 { - attr |= foregroundRed - } - if g > 127 { - attr |= foregroundGreen - } - if b > 127 { - attr |= foregroundBlue - } - } else { - attr = attr & (w.oldattr & backgroundMask) - } - case n == 39: // reset foreground color. - attr &= backgroundMask - attr |= w.oldattr & foregroundMask - case 40 <= n && n <= 47: - attr &= foregroundMask - if (n-40)&1 != 0 { - attr |= backgroundRed - } - if (n-40)&2 != 0 { - attr |= backgroundGreen - } - if (n-40)&4 != 0 { - attr |= backgroundBlue - } - case n == 48: // set background color. - if i < len(token)-2 && token[i+1] == "5" { - if n256, err := strconv.Atoi(token[i+2]); err == nil { - if n256backAttr == nil { - n256setup() - } - attr &= foregroundMask - attr |= n256backAttr[n256] - i += 2 - } - } else if len(token) == 5 && token[i+1] == "2" { - var r, g, b int - r, _ = strconv.Atoi(token[i+2]) - g, _ = strconv.Atoi(token[i+3]) - b, _ = strconv.Atoi(token[i+4]) - i += 4 - if r > 127 { - attr |= backgroundRed - } - if g > 127 { - attr |= backgroundGreen - } - if b > 127 { - attr |= backgroundBlue - } - } else { - attr = attr & (w.oldattr & foregroundMask) - } - case n == 49: // reset foreground color. - attr &= foregroundMask - attr |= w.oldattr & backgroundMask - case 90 <= n && n <= 97: - attr = (attr & backgroundMask) - attr |= foregroundIntensity - if (n-90)&1 != 0 { - attr |= foregroundRed - } - if (n-90)&2 != 0 { - attr |= foregroundGreen - } - if (n-90)&4 != 0 { - attr |= foregroundBlue - } - case 100 <= n && n <= 107: - attr = (attr & foregroundMask) - attr |= backgroundIntensity - if (n-100)&1 != 0 { - attr |= backgroundRed - } - if (n-100)&2 != 0 { - attr |= backgroundGreen - } - if (n-100)&4 != 0 { - attr |= backgroundBlue - } - } - procSetConsoleTextAttribute.Call(uintptr(w.handle), uintptr(attr)) - } - } - case 'h': - var ci consoleCursorInfo - cs := buf.String() - if cs == "5>" { - procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci))) - ci.visible = 0 - procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci))) - } else if cs == "?25" { - procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci))) - ci.visible = 1 - procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci))) - } - case 'l': - var ci consoleCursorInfo - cs := buf.String() - if cs == "5>" { - procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci))) - ci.visible = 1 - procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci))) - } else if cs == "?25" { - procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci))) - ci.visible = 0 - procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci))) - } - case 's': - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - w.oldpos = csbi.cursorPosition - case 'u': - procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&w.oldpos))) - } - } - - return len(data), nil -} - -type consoleColor struct { - rgb int - red bool - green bool - blue bool - intensity bool -} - -func (c consoleColor) foregroundAttr() (attr word) { - if c.red { - attr |= foregroundRed - } - if c.green { - attr |= foregroundGreen - } - if c.blue { - attr |= foregroundBlue - } - if c.intensity { - attr |= foregroundIntensity - } - return -} - -func (c consoleColor) backgroundAttr() (attr word) { - if c.red { - attr |= backgroundRed - } - if c.green { - attr |= backgroundGreen - } - if c.blue { - attr |= backgroundBlue - } - if c.intensity { - attr |= backgroundIntensity - } - return -} - -var color16 = []consoleColor{ - {0x000000, false, false, false, false}, - {0x000080, false, false, true, false}, - {0x008000, false, true, false, false}, - {0x008080, false, true, true, false}, - {0x800000, true, false, false, false}, - {0x800080, true, false, true, false}, - {0x808000, true, true, false, false}, - {0xc0c0c0, true, true, true, false}, - {0x808080, false, false, false, true}, - {0x0000ff, false, false, true, true}, - {0x00ff00, false, true, false, true}, - {0x00ffff, false, true, true, true}, - {0xff0000, true, false, false, true}, - {0xff00ff, true, false, true, true}, - {0xffff00, true, true, false, true}, - {0xffffff, true, true, true, true}, -} - -type hsv struct { - h, s, v float32 -} - -func (a hsv) dist(b hsv) float32 { - dh := a.h - b.h - switch { - case dh > 0.5: - dh = 1 - dh - case dh < -0.5: - dh = -1 - dh - } - ds := a.s - b.s - dv := a.v - b.v - return float32(math.Sqrt(float64(dh*dh + ds*ds + dv*dv))) -} - -func toHSV(rgb int) hsv { - r, g, b := float32((rgb&0xFF0000)>>16)/256.0, - float32((rgb&0x00FF00)>>8)/256.0, - float32(rgb&0x0000FF)/256.0 - min, max := minmax3f(r, g, b) - h := max - min - if h > 0 { - if max == r { - h = (g - b) / h - if h < 0 { - h += 6 - } - } else if max == g { - h = 2 + (b-r)/h - } else { - h = 4 + (r-g)/h - } - } - h /= 6.0 - s := max - min - if max != 0 { - s /= max - } - v := max - return hsv{h: h, s: s, v: v} -} - -type hsvTable []hsv - -func toHSVTable(rgbTable []consoleColor) hsvTable { - t := make(hsvTable, len(rgbTable)) - for i, c := range rgbTable { - t[i] = toHSV(c.rgb) - } - return t -} - -func (t hsvTable) find(rgb int) consoleColor { - hsv := toHSV(rgb) - n := 7 - l := float32(5.0) - for i, p := range t { - d := hsv.dist(p) - if d < l { - l, n = d, i - } - } - return color16[n] -} - -func minmax3f(a, b, c float32) (min, max float32) { - if a < b { - if b < c { - return a, c - } else if a < c { - return a, b - } else { - return c, b - } - } else { - if a < c { - return b, c - } else if b < c { - return b, a - } else { - return c, a - } - } -} - -var n256foreAttr []word -var n256backAttr []word - -func n256setup() { - n256foreAttr = make([]word, 256) - n256backAttr = make([]word, 256) - t := toHSVTable(color16) - for i, rgb := range color256 { - c := t.find(rgb) - n256foreAttr[i] = c.foregroundAttr() - n256backAttr[i] = c.backgroundAttr() - } -} diff --git a/vendor/github.com/mattn/go-colorable/noncolorable.go b/vendor/github.com/mattn/go-colorable/noncolorable.go deleted file mode 100644 index 9721e16f4..000000000 --- a/vendor/github.com/mattn/go-colorable/noncolorable.go +++ /dev/null @@ -1,55 +0,0 @@ -package colorable - -import ( - "bytes" - "io" -) - -// NonColorable hold writer but remove escape sequence. -type NonColorable struct { - out io.Writer -} - -// NewNonColorable return new instance of Writer which remove escape sequence from Writer. -func NewNonColorable(w io.Writer) io.Writer { - return &NonColorable{out: w} -} - -// Write write data on console -func (w *NonColorable) Write(data []byte) (n int, err error) { - er := bytes.NewReader(data) - var bw [1]byte -loop: - for { - c1, err := er.ReadByte() - if err != nil { - break loop - } - if c1 != 0x1b { - bw[0] = c1 - w.out.Write(bw[:]) - continue - } - c2, err := er.ReadByte() - if err != nil { - break loop - } - if c2 != 0x5b { - continue - } - - var buf bytes.Buffer - for { - c, err := er.ReadByte() - if err != nil { - break loop - } - if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { - break - } - buf.Write([]byte(string(c))) - } - } - - return len(data), nil -} diff --git a/vendor/github.com/mattn/go-colorable/LICENSE b/vendor/github.com/mattn/go-zglob/LICENSE similarity index 96% rename from vendor/github.com/mattn/go-colorable/LICENSE rename to vendor/github.com/mattn/go-zglob/LICENSE index 91b5cef30..740fa9313 100644 --- a/vendor/github.com/mattn/go-colorable/LICENSE +++ b/vendor/github.com/mattn/go-zglob/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 Yasuhiro Matsumoto +Copyright (c) 2017 Yasuhiro Matsumoto Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/github.com/mgutz/ansi/README.md b/vendor/github.com/mgutz/ansi/README.md index 8f8e20b7e..5fb3f2227 100644 --- a/vendor/github.com/mgutz/ansi/README.md +++ b/vendor/github.com/mgutz/ansi/README.md @@ -4,10 +4,10 @@ Package ansi is a small, fast library to create ANSI colored strings and codes. ## Install -Get it +This install the color viewer and the package itself ```sh -go get -u github.com/mgutz/ansi +go get -u github.com/mgutz/ansi/cmd/ansi-mgutz ``` ## Example @@ -18,7 +18,7 @@ import "github.com/mgutz/ansi" // colorize a string, SLOW msg := ansi.Color("foo", "red+b:white") -// create a FAST closure function to avoid computation of ANSI code +// create a closure to avoid recalculating ANSI code compilation phosphorize := ansi.ColorFunc("green+h:black") msg = phosphorize("Bring back the 80s!") msg2 := phospohorize("Look, I'm a CRT!") @@ -44,10 +44,10 @@ Color(s, "red+B:white+h") // red blink on white bright Color(s, "off") // turn off ansi codes ``` -To view color combinations, from project directory in terminal. +To view color combinations, from terminal. ```sh -go test +ansi-mgutz ``` ## Style format @@ -68,18 +68,15 @@ Colors * white * 0...255 (256 colors) -Foreground Attributes +Attributes -* B = Blink -* b = bold -* h = high intensity (bright) -* i = inverse -* s = strikethrough -* u = underline +* b = bold foreground +* B = Blink foreground +* u = underline foreground +* i = inverse +* h = high intensity (bright) foreground, background -Background Attributes - -* h = high intensity (bright) + does not work with 256 colors ## Constants @@ -103,6 +100,7 @@ Background Attributes * ansi.LightCyan * ansi.LightWhite + ## References Wikipedia ANSI escape codes [Colors](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) diff --git a/vendor/github.com/mgutz/ansi/ansi.go b/vendor/github.com/mgutz/ansi/ansi.go index dc0413649..099aee3c5 100644 --- a/vendor/github.com/mgutz/ansi/ansi.go +++ b/vendor/github.com/mgutz/ansi/ansi.go @@ -23,12 +23,11 @@ const ( normalIntensityBG = 40 highIntensityBG = 100 - start = "\033[" - bold = "1;" - blink = "5;" - underline = "4;" - inverse = "7;" - strikethrough = "9;" + start = "\033[" + bold = "1;" + blink = "5;" + underline = "4;" + inverse = "7;" // Reset is the ANSI reset escape sequence Reset = "\033[0m" @@ -177,9 +176,6 @@ func colorCode(style string) *bytes.Buffer { if strings.Contains(fgStyle, "i") { buf.WriteString(inverse) } - if strings.Contains(fgStyle, "s") { - buf.WriteString(strikethrough) - } if strings.Contains(fgStyle, "h") { base = highIntensityFG } @@ -224,7 +220,7 @@ func Color(s, style string) string { return buf.String() } -// ColorFunc creates a closure to avoid computation ANSI color code. +// ColorFunc creates a closureto avoid ANSI color code calculation. func ColorFunc(style string) func(string) string { if style == "" { return func(s string) string { @@ -244,42 +240,7 @@ func ColorFunc(style string) func(string) string { } } -// DisableColors disables ANSI color codes. The default is false (colors are on). +// DisableColors disables ANSI color codes. On by default. func DisableColors(disable bool) { plain = disable - if plain { - Black = "" - Red = "" - Green = "" - Yellow = "" - Blue = "" - Magenta = "" - Cyan = "" - White = "" - LightBlack = "" - LightRed = "" - LightGreen = "" - LightYellow = "" - LightBlue = "" - LightMagenta = "" - LightCyan = "" - LightWhite = "" - } else { - Black = ColorCode("black") - Red = ColorCode("red") - Green = ColorCode("green") - Yellow = ColorCode("yellow") - Blue = ColorCode("blue") - Magenta = ColorCode("magenta") - Cyan = ColorCode("cyan") - White = ColorCode("white") - LightBlack = ColorCode("black+h") - LightRed = ColorCode("red+h") - LightGreen = ColorCode("green+h") - LightYellow = ColorCode("yellow+h") - LightBlue = ColorCode("blue+h") - LightMagenta = ColorCode("magenta+h") - LightCyan = ColorCode("cyan+h") - LightWhite = ColorCode("white+h") - } } diff --git a/vendor/github.com/mgutz/ansi/ansi_test.go b/vendor/github.com/mgutz/ansi/ansi_test.go index 1630dc57c..d601e1163 100644 --- a/vendor/github.com/mgutz/ansi/ansi_test.go +++ b/vendor/github.com/mgutz/ansi/ansi_test.go @@ -1,52 +1,42 @@ package ansi import ( - "strings" + "fmt" "testing" ) func TestPlain(t *testing.T) { DisableColors(true) - PrintStyles() + bgColors := []string{ + "", + ":black", + ":red", + ":green", + ":yellow", + ":blue", + ":magenta", + ":cyan", + ":white", + } + for fg := range Colors { + for _, bg := range bgColors { + println(padColor(fg, []string{"" + bg, "+b" + bg, "+bh" + bg, "+u" + bg})) + println(padColor(fg, []string{"+uh" + bg, "+B" + bg, "+Bb" + bg /* backgrounds */, "" + bg + "+h"})) + println(padColor(fg, []string{"+b" + bg + "+h", "+bh" + bg + "+h", "+u" + bg + "+h", "+uh" + bg + "+h"})) + } + } } func TestStyles(t *testing.T) { - DisableColors(false) PrintStyles() -} - -func TestDisableColors(t *testing.T) { - fn := ColorFunc("red") - + DisableColors(false) buf := colorCode("off") if buf.String() != "" { t.Fail() } +} - DisableColors(true) - if Black != "" { - t.Fail() - } - code := ColorCode("red") - if code != "" { - t.Fail() - } - s := fn("foo") - if s != "foo" { - t.Fail() - } - - DisableColors(false) - if Black == "" { - t.Fail() - } - code = ColorCode("red") - if code == "" { - t.Fail() - } - // will have escape codes around it - index := strings.Index(fn("foo"), "foo") - if index <= 0 { - t.Fail() - } +func ExampleColorFunc() { + brightGreen := ColorFunc("green+h") + fmt.Println(brightGreen("lime")) } diff --git a/vendor/github.com/mgutz/ansi/cmd/ansi-mgutz/main.go b/vendor/github.com/mgutz/ansi/cmd/ansi-mgutz/main.go index 736b45dd7..66ab77979 100644 --- a/vendor/github.com/mgutz/ansi/cmd/ansi-mgutz/main.go +++ b/vendor/github.com/mgutz/ansi/cmd/ansi-mgutz/main.go @@ -80,7 +80,7 @@ func printColors() { for _, fg := range keys { for _, bg := range bgColors { fmt.Fprintln(stdout, padColor(fg, []string{"" + bg, "+b" + bg, "+bh" + bg, "+u" + bg})) - fmt.Fprintln(stdout, padColor(fg, []string{"+uh" + bg, "+B" + bg, "+Bb" + bg /* backgrounds */, "" + bg + "+h", "+s" + bg})) + fmt.Fprintln(stdout, padColor(fg, []string{"+uh" + bg, "+B" + bg, "+Bb" + bg /* backgrounds */, "" + bg + "+h"})) fmt.Fprintln(stdout, padColor(fg, []string{"+b" + bg + "+h", "+bh" + bg + "+h", "+u" + bg + "+h", "+uh" + bg + "+h"})) } } @@ -108,7 +108,7 @@ func print256Colors() { for _, fg := range keys { for _, bg := range bgColors { fmt.Fprintln(stdout, padColor(fg, []string{"" + bg, "+b" + bg, "+u" + bg})) - fmt.Fprintln(stdout, padColor(fg, []string{"+B" + bg, "+Bb" + bg, "+s" + bg})) + fmt.Fprintln(stdout, padColor(fg, []string{"+B" + bg, "+Bb" + bg})) } } } diff --git a/vendor/github.com/mgutz/ansi/print.go b/vendor/github.com/mgutz/ansi/print.go index 806f436bb..044c9a684 100644 --- a/vendor/github.com/mgutz/ansi/print.go +++ b/vendor/github.com/mgutz/ansi/print.go @@ -1,16 +1,9 @@ package ansi -import ( - "fmt" - "sort" - - colorable "github.com/mattn/go-colorable" -) - // PrintStyles prints all style combinations to the terminal. func PrintStyles() { - // for compatibility with Windows, not needed for *nix - stdout := colorable.NewColorableStdout() + oldPlain := plain + plain = false bgColors := []string{ "", @@ -23,22 +16,14 @@ func PrintStyles() { ":cyan", ":white", } - - keys := make([]string, 0, len(Colors)) - for k := range Colors { - keys = append(keys, k) - } - - sort.Sort(sort.StringSlice(keys)) - - for _, fg := range keys { + for fg := range Colors { for _, bg := range bgColors { - fmt.Fprintln(stdout, padColor(fg, []string{"" + bg, "+b" + bg, "+bh" + bg, "+u" + bg})) - fmt.Fprintln(stdout, padColor(fg, []string{"+s" + bg, "+i" + bg})) - fmt.Fprintln(stdout, padColor(fg, []string{"+uh" + bg, "+B" + bg, "+Bb" + bg /* backgrounds */, "" + bg + "+h"})) - fmt.Fprintln(stdout, padColor(fg, []string{"+b" + bg + "+h", "+bh" + bg + "+h", "+u" + bg + "+h", "+uh" + bg + "+h"})) + println(padColor(fg, []string{"" + bg, "+b" + bg, "+bh" + bg, "+u" + bg})) + println(padColor(fg, []string{"+uh" + bg, "+B" + bg, "+Bb" + bg /* backgrounds */, "" + bg + "+h"})) + println(padColor(fg, []string{"+b" + bg + "+h", "+bh" + bg + "+h", "+u" + bg + "+h", "+uh" + bg + "+h"})) } } + plain = oldPlain } func pad(s string, length int) string { @@ -48,10 +33,10 @@ func pad(s string, length int) string { return s } -func padColor(color string, styles []string) string { +func padColor(s string, styles []string) string { buffer := "" for _, style := range styles { - buffer += Color(pad(color+style, 20), color+style) + buffer += Color(pad(s+style, 20), s+style) } return buffer } diff --git a/vendor/github.com/shirou/gopsutil/README.rst b/vendor/github.com/shirou/gopsutil/README.rst index 18ee9bacc..eba2654dd 100644 --- a/vendor/github.com/shirou/gopsutil/README.rst +++ b/vendor/github.com/shirou/gopsutil/README.rst @@ -95,7 +95,7 @@ see http://godoc.org/github.com/shirou/gopsutil Requirements ----------------- -- go1.5 or above is required. +- go1.7 or above is required. More Info diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_linux_test.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_linux_test.go new file mode 100644 index 000000000..53cfcb7c7 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/cpu/cpu_linux_test.go @@ -0,0 +1,40 @@ +package cpu + +import ( + "os" + "testing" +) + +func TestTimesEmpty(t *testing.T) { + orig := os.Getenv("HOST_PROC") + os.Setenv("HOST_PROC", "testdata/linux/times_empty") + _, err := Times(true) + if err != nil { + t.Error("Times(true) failed") + } + _, err = Times(false) + if err != nil { + t.Error("Times(false) failed") + } + os.Setenv("HOST_PROC", orig) +} + +func TestCPUparseStatLine_424(t *testing.T) { + orig := os.Getenv("HOST_PROC") + os.Setenv("HOST_PROC", "testdata/linux/424/proc") + { + l, err := Times(true) + if err != nil || len(l) == 0 { + t.Error("Times(true) failed") + } + t.Logf("Times(true): %#v", l) + } + { + l, err := Times(false) + if err != nil || len(l) == 0 { + t.Error("Times(false) failed") + } + t.Logf("Times(false): %#v", l) + } + os.Setenv("HOST_PROC", orig) +} diff --git a/vendor/github.com/shirou/gopsutil/cpu/testdata/linux/424/proc/stat b/vendor/github.com/shirou/gopsutil/cpu/testdata/linux/424/proc/stat new file mode 100644 index 000000000..cb7610c69 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/cpu/testdata/linux/424/proc/stat @@ -0,0 +1,12 @@ +cpu 23644 6695 4764 134931750 22115 0 473 5892 0 0 +cpu0 6418 888 1230 33730755 5043 0 4 1046 0 0 +cpu1 6858 4870 1632 33716510 12327 0 235 1765 0 0 +cpu2 4859 622 915 33742072 2312 0 25 1546 0 0 +cpu3 5507 314 986 33742411 2432 0 208 1534 0 0 +intr 32552791 35 9 0 0 2335 0 3 0 2 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3107077 2985327 15704 0 6672 0 3218027 3063711 11558 0 6151 0 2160633 2194945 15838 0 6565 0 1595129 2134446 15337 0 5715 0 157 112837 717318 710764 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +ctxt 41317767 +btime 1505515383 +processes 41562 +procs_running 1 +procs_blocked 0 +softirq 5433315 0 1644387 67542 1428221 0 0 12270 1573783 0 707112 \ No newline at end of file diff --git a/vendor/github.com/shirou/gopsutil/cpu/testdata/linux/times_empty/proc/stat b/vendor/github.com/shirou/gopsutil/cpu/testdata/linux/times_empty/proc/stat new file mode 100755 index 000000000..e69de29bb diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux_mips.go b/vendor/github.com/shirou/gopsutil/host/host_linux_mips.go new file mode 100644 index 000000000..b0fca0939 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/host/host_linux_mips.go @@ -0,0 +1,43 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package host + +const ( + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 + sizeOfUtmp = 0x180 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int32 + _C_long_long int64 +) + +type utmp struct { + Type int16 + Pad_cgo_0 [2]byte + Pid int32 + Line [32]int8 + Id [4]int8 + User [32]int8 + Host [256]int8 + Exit exit_status + Session int32 + Tv timeval + Addr_v6 [4]int32 + X__unused [20]int8 +} +type exit_status struct { + Termination int16 + Exit int16 +} +type timeval struct { + Sec int32 + Usec int32 +} diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux_mipsle.go b/vendor/github.com/shirou/gopsutil/host/host_linux_mipsle.go new file mode 100644 index 000000000..b0fca0939 --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/host/host_linux_mipsle.go @@ -0,0 +1,43 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package host + +const ( + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 + sizeOfUtmp = 0x180 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int32 + _C_long_long int64 +) + +type utmp struct { + Type int16 + Pad_cgo_0 [2]byte + Pid int32 + Line [32]int8 + Id [4]int8 + User [32]int8 + Host [256]int8 + Exit exit_status + Session int32 + Tv timeval + Addr_v6 [4]int32 + X__unused [20]int8 +} +type exit_status struct { + Termination int16 + Exit int16 +} +type timeval struct { + Sec int32 + Usec int32 +} diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common.go b/vendor/github.com/shirou/gopsutil/internal/common/common.go index df71688b5..1ef9e2741 100644 --- a/vendor/github.com/shirou/gopsutil/internal/common/common.go +++ b/vendor/github.com/shirou/gopsutil/internal/common/common.go @@ -358,3 +358,19 @@ func Pipeline(cmds ...*exec.Cmd) ([]byte, []byte, error) { // Return the pipeline output and the collected standard error return output.Bytes(), stderr.Bytes(), nil } + +// getSysctrlEnv sets LC_ALL=C in a list of env vars for use when running +// sysctl commands (see DoSysctrl). +func getSysctrlEnv(env []string) []string { + foundLC := false + for i, line := range env { + if strings.HasPrefix(line, "LC_ALL") { + env[i] = "LC_ALL=C" + foundLC = true + } + } + if !foundLC { + env = append(env, "LC_ALL=C") + } + return env +} diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go b/vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go index b236da1d8..2b6d4c149 100644 --- a/vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go +++ b/vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go @@ -12,16 +12,13 @@ import ( ) func DoSysctrl(mib string) ([]string, error) { - err := os.Setenv("LC_ALL", "C") - if err != nil { - return []string{}, err - } - sysctl, err := exec.LookPath("/usr/sbin/sysctl") if err != nil { return []string{}, err } - out, err := exec.Command(sysctl, "-n", mib).Output() + cmd := exec.Command(sysctl, "-n", mib) + cmd.Env = getSysctrlEnv(os.Environ()) + out, err := cmd.Output() if err != nil { return []string{}, err } diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_freebsd.go b/vendor/github.com/shirou/gopsutil/internal/common/common_freebsd.go index 668bdc40f..107e2c9cf 100644 --- a/vendor/github.com/shirou/gopsutil/internal/common/common_freebsd.go +++ b/vendor/github.com/shirou/gopsutil/internal/common/common_freebsd.go @@ -12,15 +12,13 @@ import ( ) func DoSysctrl(mib string) ([]string, error) { - err := os.Setenv("LC_ALL", "C") - if err != nil { - return []string{}, err - } sysctl, err := exec.LookPath("/sbin/sysctl") if err != nil { return []string{}, err } - out, err := exec.Command(sysctl, "-n", mib).Output() + cmd := exec.Command(sysctl, "-n", mib) + cmd.Env = getSysctrlEnv(os.Environ()) + out, err := cmd.Output() if err != nil { return []string{}, err } diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_linux.go b/vendor/github.com/shirou/gopsutil/internal/common/common_linux.go index c0aa9c78e..4e829e057 100644 --- a/vendor/github.com/shirou/gopsutil/internal/common/common_linux.go +++ b/vendor/github.com/shirou/gopsutil/internal/common/common_linux.go @@ -9,15 +9,13 @@ import ( ) func DoSysctrl(mib string) ([]string, error) { - err := os.Setenv("LC_ALL", "C") - if err != nil { - return []string{}, err - } sysctl, err := exec.LookPath("/sbin/sysctl") if err != nil { return []string{}, err } - out, err := exec.Command(sysctl, "-n", mib).Output() + cmd := exec.Command(sysctl, "-n", mib) + cmd.Env = getSysctrlEnv(os.Environ()) + out, err := cmd.Output() if err != nil { return []string{}, err } diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_openbsd.go b/vendor/github.com/shirou/gopsutil/internal/common/common_openbsd.go index 8625e1fa9..398f78542 100644 --- a/vendor/github.com/shirou/gopsutil/internal/common/common_openbsd.go +++ b/vendor/github.com/shirou/gopsutil/internal/common/common_openbsd.go @@ -12,15 +12,13 @@ import ( ) func DoSysctrl(mib string) ([]string, error) { - err := os.Setenv("LC_ALL", "C") - if err != nil { - return []string{}, err - } sysctl, err := exec.LookPath("/sbin/sysctl") if err != nil { return []string{}, err } - out, err := exec.Command(sysctl, "-n", mib).Output() + cmd := exec.Command(sysctl, "-n", mib) + cmd.Env = getSysctrlEnv(os.Environ()) + out, err := cmd.Output() if err != nil { return []string{}, err } diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_test.go b/vendor/github.com/shirou/gopsutil/internal/common/common_test.go index b7bda8b74..3b05d5356 100644 --- a/vendor/github.com/shirou/gopsutil/internal/common/common_test.go +++ b/vendor/github.com/shirou/gopsutil/internal/common/common_test.go @@ -2,6 +2,8 @@ package common import ( "fmt" + "os" + "reflect" "strings" "testing" ) @@ -95,3 +97,33 @@ func TestHostEtc(t *testing.T) { t.Errorf("invalid HostEtc, %s", p) } } + +func TestGetSysctrlEnv(t *testing.T) { + // Append case + env := getSysctrlEnv([]string{"FOO=bar"}) + if !reflect.DeepEqual(env, []string{"FOO=bar", "LC_ALL=C"}) { + t.Errorf("unexpected append result from getSysctrlEnv: %q", env) + } + + // Replace case + env = getSysctrlEnv([]string{"FOO=bar", "LC_ALL=en_US.UTF-8"}) + if !reflect.DeepEqual(env, []string{"FOO=bar", "LC_ALL=C"}) { + t.Errorf("unexpected replace result from getSysctrlEnv: %q", env) + } + + // Test against real env + env = getSysctrlEnv(os.Environ()) + found := false + for _, v := range env { + if v == "LC_ALL=C" { + found = true + continue + } + if strings.HasPrefix(v, "LC_ALL") { + t.Fatalf("unexpected LC_ALL value: %q", v) + } + } + if !found { + t.Errorf("unexpected real result from getSysctrlEnv: %q", env) + } +} diff --git a/vendor/github.com/shirou/gopsutil/process/process.go b/vendor/github.com/shirou/gopsutil/process/process.go index f740e42c9..83930494d 100644 --- a/vendor/github.com/shirou/gopsutil/process/process.go +++ b/vendor/github.com/shirou/gopsutil/process/process.go @@ -26,6 +26,7 @@ type Process struct { gids []int32 numThreads int32 memInfo *MemoryInfoStat + sigInfo *SignalInfoStat lastCPUTimes *cpu.TimesStat lastCPUTime time.Time @@ -37,15 +38,27 @@ type OpenFilesStat struct { } type MemoryInfoStat struct { - RSS uint64 `json:"rss"` // bytes - VMS uint64 `json:"vms"` // bytes - Swap uint64 `json:"swap"` // bytes + RSS uint64 `json:"rss"` // bytes + VMS uint64 `json:"vms"` // bytes + Data uint64 `json:"data"` // bytes + Stack uint64 `json:"stack"` // bytes + Locked uint64 `json:"locked"` // bytes + Swap uint64 `json:"swap"` // bytes +} + +type SignalInfoStat struct { + PendingProcess uint64 `json:"pending_process"` + PendingThread uint64 `json:"pending_thread"` + Blocked uint64 `json:"blocked"` + Ignored uint64 `json:"ignored"` + Caught uint64 `json:"caught"` } type RlimitStat struct { - Resource int32 `json:"resource"` - Soft int32 `json:"soft"` - Hard int32 `json:"hard"` + Resource int32 `json:"resource"` + Soft int32 `json:"soft"` //TODO too small. needs to be uint64 + Hard int32 `json:"hard"` //TODO too small. needs to be uint64 + Used uint64 `json:"used"` } type IOCountersStat struct { diff --git a/vendor/github.com/shirou/gopsutil/process/process_darwin.go b/vendor/github.com/shirou/gopsutil/process/process_darwin.go index 63b64f6ca..7de9add3f 100644 --- a/vendor/github.com/shirou/gopsutil/process/process_darwin.go +++ b/vendor/github.com/shirou/gopsutil/process/process_darwin.go @@ -248,6 +248,10 @@ func (p *Process) Rlimit() ([]RlimitStat, error) { var rlimit []RlimitStat return rlimit, common.ErrNotImplementedError } +func (p *Process) RlimitUsage(_ bool) ([]RlimitStat, error) { + var rlimit []RlimitStat + return rlimit, common.ErrNotImplementedError +} func (p *Process) IOCounters() (*IOCountersStat, error) { return nil, common.ErrNotImplementedError } diff --git a/vendor/github.com/shirou/gopsutil/process/process_fallback.go b/vendor/github.com/shirou/gopsutil/process/process_fallback.go index ed622a81d..bf09875a1 100644 --- a/vendor/github.com/shirou/gopsutil/process/process_fallback.go +++ b/vendor/github.com/shirou/gopsutil/process/process_fallback.go @@ -80,6 +80,9 @@ func (p *Process) IOnice() (int32, error) { func (p *Process) Rlimit() ([]RlimitStat, error) { return nil, common.ErrNotImplementedError } +func (p *Process) RlimitUsage(_ bool) ([]RlimitStat, error) { + return nil, common.ErrNotImplementedError +} func (p *Process) IOCounters() (*IOCountersStat, error) { return nil, common.ErrNotImplementedError } diff --git a/vendor/github.com/shirou/gopsutil/process/process_freebsd.go b/vendor/github.com/shirou/gopsutil/process/process_freebsd.go index 47c14f4c8..4f40e1250 100644 --- a/vendor/github.com/shirou/gopsutil/process/process_freebsd.go +++ b/vendor/github.com/shirou/gopsutil/process/process_freebsd.go @@ -176,6 +176,10 @@ func (p *Process) Rlimit() ([]RlimitStat, error) { var rlimit []RlimitStat return rlimit, common.ErrNotImplementedError } +func (p *Process) RlimitUsage(_ bool) ([]RlimitStat, error) { + var rlimit []RlimitStat + return rlimit, common.ErrNotImplementedError +} func (p *Process) IOCounters() (*IOCountersStat, error) { k, err := p.getKProc() if err != nil { diff --git a/vendor/github.com/shirou/gopsutil/process/process_linux.go b/vendor/github.com/shirou/gopsutil/process/process_linux.go index b090dd9c8..65cc41b9c 100644 --- a/vendor/github.com/shirou/gopsutil/process/process_linux.go +++ b/vendor/github.com/shirou/gopsutil/process/process_linux.go @@ -83,7 +83,7 @@ func NewProcess(pid int32) (*Process, error) { // Ppid returns Parent Process ID of the process. func (p *Process) Ppid() (int32, error) { - _, ppid, _, _, _, err := p.fillFromStat() + _, ppid, _, _, _, _, err := p.fillFromStat() if err != nil { return -1, err } @@ -119,7 +119,7 @@ func (p *Process) CmdlineSlice() ([]string, error) { // CreateTime returns created time of the process in milliseconds since the epoch, in UTC. func (p *Process) CreateTime() (int64, error) { - _, _, _, createTime, _, err := p.fillFromStat() + _, _, _, createTime, _, _, err := p.fillFromStat() if err != nil { return 0, err } @@ -176,7 +176,7 @@ func (p *Process) Gids() ([]int32, error) { // Terminal returns a terminal which is associated with the process. func (p *Process) Terminal() (string, error) { - terminal, _, _, _, _, err := p.fillFromStat() + terminal, _, _, _, _, _, err := p.fillFromStat() if err != nil { return "", err } @@ -186,7 +186,7 @@ func (p *Process) Terminal() (string, error) { // Nice returns a nice value (priority). // Notice: gopsutil can not set nice value. func (p *Process) Nice() (int32, error) { - _, _, _, _, nice, err := p.fillFromStat() + _, _, _, _, _, nice, err := p.fillFromStat() if err != nil { return 0, err } @@ -200,7 +200,65 @@ func (p *Process) IOnice() (int32, error) { // Rlimit returns Resource Limits. func (p *Process) Rlimit() ([]RlimitStat, error) { - return p.fillFromLimits() + return p.RlimitUsage(false) +} + +// RlimitUsage returns Resource Limits. +// If gatherUsed is true, the currently used value will be gathered and added +// to the resulting RlimitStat. +func (p *Process) RlimitUsage(gatherUsed bool) ([]RlimitStat, error) { + rlimits, err := p.fillFromLimits() + if !gatherUsed || err != nil { + return rlimits, err + } + + _, _, _, _, rtprio, nice, err := p.fillFromStat() + if err != nil { + return nil, err + } + if err := p.fillFromStatus(); err != nil { + return nil, err + } + + for i := range rlimits { + rs := &rlimits[i] + switch rs.Resource { + case RLIMIT_CPU: + times, err := p.Times() + if err != nil { + return nil, err + } + rs.Used = uint64(times.User + times.System) + case RLIMIT_DATA: + rs.Used = uint64(p.memInfo.Data) + case RLIMIT_STACK: + rs.Used = uint64(p.memInfo.Stack) + case RLIMIT_RSS: + rs.Used = uint64(p.memInfo.RSS) + case RLIMIT_NOFILE: + n, err := p.NumFDs() + if err != nil { + return nil, err + } + rs.Used = uint64(n) + case RLIMIT_MEMLOCK: + rs.Used = uint64(p.memInfo.Locked) + case RLIMIT_AS: + rs.Used = uint64(p.memInfo.VMS) + case RLIMIT_LOCKS: + //TODO we can get the used value from /proc/$pid/locks. But linux doesn't enforce it, so not a high priority. + case RLIMIT_SIGPENDING: + rs.Used = p.sigInfo.PendingProcess + case RLIMIT_NICE: + // The rlimit for nice is a little unusual, in that 0 means the niceness cannot be decreased beyond the current value, but it can be increased. + // So effectively: if rs.Soft == 0 { rs.Soft = rs.Used } + rs.Used = uint64(nice) + case RLIMIT_RTPRIO: + rs.Used = uint64(rtprio) + } + } + + return rlimits, err } // IOCounters returns IO Counters. @@ -242,7 +300,7 @@ func (p *Process) Threads() (map[string]string, error) { // Times returns CPU times of the process. func (p *Process) Times() (*cpu.TimesStat, error) { - _, _, cpuTimes, _, _, err := p.fillFromStat() + _, _, cpuTimes, _, _, _, err := p.fillFromStat() if err != nil { return nil, err } @@ -720,6 +778,7 @@ func (p *Process) fillFromStatus() error { lines := strings.Split(string(contents), "\n") p.numCtxSwitches = &NumCtxSwitchesStat{} p.memInfo = &MemoryInfoStat{} + p.sigInfo = &SignalInfoStat{} for _, line := range lines { tabParts := strings.SplitN(line, "\t", 2) if len(tabParts) < 2 { @@ -806,18 +865,69 @@ func (p *Process) fillFromStatus() error { return err } p.memInfo.Swap = v * 1024 + case "VmData": + value := strings.Trim(value, " kB") // remove last "kB" + v, err := strconv.ParseUint(value, 10, 64) + if err != nil { + return err + } + p.memInfo.Data = v * 1024 + case "VmStk": + value := strings.Trim(value, " kB") // remove last "kB" + v, err := strconv.ParseUint(value, 10, 64) + if err != nil { + return err + } + p.memInfo.Stack = v * 1024 + case "VmLck": + value := strings.Trim(value, " kB") // remove last "kB" + v, err := strconv.ParseUint(value, 10, 64) + if err != nil { + return err + } + p.memInfo.Locked = v * 1024 + case "SigPnd": + v, err := strconv.ParseUint(value, 16, 64) + if err != nil { + return err + } + p.sigInfo.PendingThread = v + case "ShdPnd": + v, err := strconv.ParseUint(value, 16, 64) + if err != nil { + return err + } + p.sigInfo.PendingProcess = v + case "SigBlk": + v, err := strconv.ParseUint(value, 16, 64) + if err != nil { + return err + } + p.sigInfo.Blocked = v + case "SigIgn": + v, err := strconv.ParseUint(value, 16, 64) + if err != nil { + return err + } + p.sigInfo.Ignored = v + case "SigCgt": + v, err := strconv.ParseUint(value, 16, 64) + if err != nil { + return err + } + p.sigInfo.Caught = v } } return nil } -func (p *Process) fillFromStat() (string, int32, *cpu.TimesStat, int64, int32, error) { +func (p *Process) fillFromStat() (string, int32, *cpu.TimesStat, int64, uint32, int32, error) { pid := p.Pid statPath := common.HostProc(strconv.Itoa(int(pid)), "stat") contents, err := ioutil.ReadFile(statPath) if err != nil { - return "", 0, nil, 0, 0, err + return "", 0, nil, 0, 0, 0, err } fields := strings.Fields(string(contents)) @@ -831,23 +941,23 @@ func (p *Process) fillFromStat() (string, int32, *cpu.TimesStat, int64, int32, e if err == nil { t, err := strconv.ParseUint(fields[i+5], 10, 64) if err != nil { - return "", 0, nil, 0, 0, err + return "", 0, nil, 0, 0, 0, err } terminal = termmap[t] } ppid, err := strconv.ParseInt(fields[i+2], 10, 32) if err != nil { - return "", 0, nil, 0, 0, err + return "", 0, nil, 0, 0, 0, err } utime, err := strconv.ParseFloat(fields[i+12], 64) if err != nil { - return "", 0, nil, 0, 0, err + return "", 0, nil, 0, 0, 0, err } stime, err := strconv.ParseFloat(fields[i+13], 64) if err != nil { - return "", 0, nil, 0, 0, err + return "", 0, nil, 0, 0, 0, err } cpuTimes := &cpu.TimesStat{ @@ -859,17 +969,24 @@ func (p *Process) fillFromStat() (string, int32, *cpu.TimesStat, int64, int32, e bootTime, _ := host.BootTime() t, err := strconv.ParseUint(fields[i+20], 10, 64) if err != nil { - return "", 0, nil, 0, 0, err + return "", 0, nil, 0, 0, 0, err } ctime := (t / uint64(ClockTicks)) + uint64(bootTime) createTime := int64(ctime * 1000) + rtpriority, err := strconv.ParseInt(fields[i+16], 10, 32) + if rtpriority < 0 { + rtpriority = rtpriority*-1 - 1 + } else { + rtpriority = 0 + } + // p.Nice = mustParseInt32(fields[18]) // use syscall instead of parse Stat file snice, _ := unix.Getpriority(PrioProcess, int(pid)) nice := int32(snice) // FIXME: is this true? - return terminal, int32(ppid), cpuTimes, createTime, nice, nil + return terminal, int32(ppid), cpuTimes, createTime, uint32(rtpriority), nice, nil } // Pids returns a slice of process ID list which are running now. diff --git a/vendor/github.com/shirou/gopsutil/process/process_openbsd.go b/vendor/github.com/shirou/gopsutil/process/process_openbsd.go index 47a6e377c..3ca3857c6 100644 --- a/vendor/github.com/shirou/gopsutil/process/process_openbsd.go +++ b/vendor/github.com/shirou/gopsutil/process/process_openbsd.go @@ -170,6 +170,10 @@ func (p *Process) Rlimit() ([]RlimitStat, error) { var rlimit []RlimitStat return rlimit, common.ErrNotImplementedError } +func (p *Process) RlimitUsage(_ bool) ([]RlimitStat, error) { + var rlimit []RlimitStat + return rlimit, common.ErrNotImplementedError +} func (p *Process) IOCounters() (*IOCountersStat, error) { k, err := p.getKProc() if err != nil { diff --git a/vendor/github.com/shirou/gopsutil/process/process_windows.go b/vendor/github.com/shirou/gopsutil/process/process_windows.go index b13a5af9e..d94dcbc27 100644 --- a/vendor/github.com/shirou/gopsutil/process/process_windows.go +++ b/vendor/github.com/shirou/gopsutil/process/process_windows.go @@ -240,6 +240,11 @@ func (p *Process) Rlimit() ([]RlimitStat, error) { return rlimit, common.ErrNotImplementedError } +func (p *Process) RlimitUsage(_ bool) ([]RlimitStat, error) { + var rlimit []RlimitStat + + return rlimit, common.ErrNotImplementedError +} func (p *Process) IOCounters() (*IOCountersStat, error) { dst, err := GetWin32Proc(p.Pid) diff --git a/vendor/github.com/smartystreets/assertions/.gitignore b/vendor/github.com/smartystreets/assertions/.gitignore index 07d3c71ce..fafff2e8d 100644 --- a/vendor/github.com/smartystreets/assertions/.gitignore +++ b/vendor/github.com/smartystreets/assertions/.gitignore @@ -1,5 +1,2 @@ .DS_Store Thumbs.db -*.iml -/.idea -coverage.out diff --git a/vendor/github.com/smartystreets/assertions/.travis.yml b/vendor/github.com/smartystreets/assertions/.travis.yml index 1065ceb05..44217c973 100644 --- a/vendor/github.com/smartystreets/assertions/.travis.yml +++ b/vendor/github.com/smartystreets/assertions/.travis.yml @@ -1,8 +1,10 @@ language: go go: - - 1.x - - master + - 1.2 + - 1.3 + - 1.4 + - 1.5 install: - go get -t ./... diff --git a/vendor/github.com/smartystreets/assertions/CONTRIBUTING.md b/vendor/github.com/smartystreets/assertions/CONTRIBUTING.md deleted file mode 100644 index 1820ecb33..000000000 --- a/vendor/github.com/smartystreets/assertions/CONTRIBUTING.md +++ /dev/null @@ -1,12 +0,0 @@ -# Contributing - -In general, the code posted to the [SmartyStreets github organization](https://github.com/smartystreets) is created to solve specific problems at SmartyStreets that are ancillary to our core products in the address verification industry and may or may not be useful to other organizations or developers. Our reason for posting said code isn't necessarily to solicit feedback or contributions from the community but more as a showcase of some of the approaches to solving problems we have adopted. - -Having stated that, we do consider issues raised by other githubbers as well as contributions submitted via pull requests. When submitting such a pull request, please follow these guidelines: - -- _Look before you leap:_ If the changes you plan to make are significant, it's in everyone's best interest for you to discuss them with a SmartyStreets team member prior to opening a pull request. -- _License and ownership:_ If modifying the `LICENSE.md` file, limit your changes to fixing typographical mistakes. Do NOT modify the actual terms in the license or the copyright by **SmartyStreets, LLC**. Code submitted to SmartyStreets projects becomes property of SmartyStreets and must be compatible with the associated license. -- _Testing:_ If the code you are submitting resides in packages/modules covered by automated tests, be sure to add passing tests that cover your changes and assert expected behavior and state. Submit the additional test cases as part of your change set. -- _Style:_ Match your approach to **naming** and **formatting** with the surrounding code. Basically, the code you submit shouldn't stand out. - - "Naming" refers to such constructs as variables, methods, functions, classes, structs, interfaces, packages, modules, directories, files, etc... - - "Formatting" refers to such constructs as whitespace, horizontal line length, vertical function length, vertical file length, indentation, curly braces, etc... diff --git a/vendor/github.com/smartystreets/assertions/LICENSE.md b/vendor/github.com/smartystreets/assertions/LICENSE.md index 8ea6f9455..48a3731c0 100644 --- a/vendor/github.com/smartystreets/assertions/LICENSE.md +++ b/vendor/github.com/smartystreets/assertions/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2016 SmartyStreets, LLC +Copyright (c) 2015 SmartyStreets, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/github.com/smartystreets/assertions/README.md b/vendor/github.com/smartystreets/assertions/README.md index 58383bb00..19a66320e 100644 --- a/vendor/github.com/smartystreets/assertions/README.md +++ b/vendor/github.com/smartystreets/assertions/README.md @@ -4,14 +4,8 @@ Package assertions contains the implementations for all assertions which are referenced in goconvey's `convey` package -(github.com/smartystreets/goconvey/convey) and gunit -(github.com/smartystreets/gunit) for use with the So(...) method. They can also -be used in traditional Go test functions and even in applications. - -Many of the assertions lean heavily on work done by Aaron Jacobs in his -excellent oglematchers library. (https://github.com/jacobsa/oglematchers) The -ShouldResemble assertion leans heavily on work done by Daniel Jacques in his -very helpful go-render library. (https://github.com/luci/go-render) +(github.com/smartystreets/goconvey/convey) for use with the So(...) method. They +can also be used in traditional Go test functions and even in applicaitons. ## Usage @@ -269,9 +263,8 @@ duration specified relative to the other time.Time. ```go func ShouldHaveLength(actual interface{}, expected ...interface{}) string ``` -ShouldHaveLength receives 2 parameters. The first is a collection to check the -length of, the second being the expected length. It obeys the rules specified by -the len function for determining length: http://golang.org/pkg/builtin/#len +ShouldHaveLength receives a collection and a positive integer and asserts that +the length of the collection is equal to the integer provided. #### func ShouldHaveSameTypeAs @@ -552,20 +545,6 @@ func (this *Assertion) So(actual interface{}, assert assertion, expected ...inte So calls the standalone So function and additionally, calls t.Error in failure scenarios. -#### type FailureView - -```go -type FailureView struct { - Message string `json:"Message"` - Expected string `json:"Expected"` - Actual string `json:"Actual"` -} -``` - -This struct is also declared in -github.com/smartystreets/goconvey/convey/reporting. The json struct tags should -be equal in both declarations. - #### type Serializer ```go diff --git a/vendor/github.com/smartystreets/assertions/assertions.goconvey b/vendor/github.com/smartystreets/assertions/assertions.goconvey new file mode 100644 index 000000000..e76cf275d --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/assertions.goconvey @@ -0,0 +1,3 @@ +#ignore +-timeout=1s +-coverpkg=github.com/smartystreets/assertions,github.com/smartystreets/assertions/internal/oglematchers \ No newline at end of file diff --git a/vendor/github.com/smartystreets/assertions/collections.go b/vendor/github.com/smartystreets/assertions/collections.go index d7f407e91..de0f4426c 100644 --- a/vendor/github.com/smartystreets/assertions/collections.go +++ b/vendor/github.com/smartystreets/assertions/collections.go @@ -220,25 +220,31 @@ func ShouldHaveLength(actual interface{}, expected ...interface{}) string { value := reflect.ValueOf(actual) switch value.Kind() { - case reflect.Slice, - reflect.Chan, - reflect.Map, - reflect.String: + case reflect.Slice: + if int64(value.Len()) == expectedLen { + return success + } + case reflect.Chan: + if int64(value.Len()) == expectedLen { + return success + } + case reflect.Map: + if int64(value.Len()) == expectedLen { + return success + } + case reflect.String: if int64(value.Len()) == expectedLen { return success - } else { - return fmt.Sprintf(shouldHaveHadLength, actual, value.Len(), expectedLen) } case reflect.Ptr: elem := value.Elem() kind := elem.Kind() - if kind == reflect.Slice || kind == reflect.Array { - if int64(elem.Len()) == expectedLen { - return success - } else { - return fmt.Sprintf(shouldHaveHadLength, actual, elem.Len(), expectedLen) - } + if (kind == reflect.Slice || kind == reflect.Array) && int64(elem.Len()) == expectedLen { + return success } + default: + return fmt.Sprintf(shouldHaveBeenAValidCollection, reflect.TypeOf(actual)) } - return fmt.Sprintf(shouldHaveBeenAValidCollection, reflect.TypeOf(actual)) + + return fmt.Sprintf(shouldHaveHadLength, actual, expectedLen) } diff --git a/vendor/github.com/smartystreets/assertions/collections_test.go b/vendor/github.com/smartystreets/assertions/collections_test.go index e3679d302..9433ef24b 100644 --- a/vendor/github.com/smartystreets/assertions/collections_test.go +++ b/vendor/github.com/smartystreets/assertions/collections_test.go @@ -2,170 +2,156 @@ package assertions import ( "fmt" + "testing" "time" ) -func (this *AssertionsFixture) TestShouldContainKey() { - this.fail(so(map[int]int{}, ShouldContainKey), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(map[int]int{}, ShouldContainKey, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldContainKey(t *testing.T) { + fail(t, so(map[int]int{}, ShouldContainKey), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(map[int]int{}, ShouldContainKey, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(Thing1{}, ShouldContainKey, 1), "You must provide a valid map type (was assertions.Thing1)!") - this.fail(so(nil, ShouldContainKey, 1), "You must provide a valid map type (was )!") - this.fail(so(map[int]int{1: 41}, ShouldContainKey, 2), "Expected the map[int]int to contain the key: [2] (but it didn't)!") + fail(t, so(Thing1{}, ShouldContainKey, 1), "You must provide a valid map type (was assertions.Thing1)!") + fail(t, so(nil, ShouldContainKey, 1), "You must provide a valid map type (was )!") + fail(t, so(map[int]int{1: 41}, ShouldContainKey, 2), "Expected the map[int]int to contain the key: [2] (but it didn't)!") - this.pass(so(map[int]int{1: 41}, ShouldContainKey, 1)) - this.pass(so(map[int]int{1: 41, 2: 42, 3: 43}, ShouldContainKey, 2)) + pass(t, so(map[int]int{1: 41}, ShouldContainKey, 1)) + pass(t, so(map[int]int{1: 41, 2: 42, 3: 43}, ShouldContainKey, 2)) } -func (this *AssertionsFixture) TestShouldNotContainKey() { - this.fail(so(map[int]int{}, ShouldNotContainKey), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(map[int]int{}, ShouldNotContainKey, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldNotContainKey(t *testing.T) { + fail(t, so(map[int]int{}, ShouldNotContainKey), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(map[int]int{}, ShouldNotContainKey, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(Thing1{}, ShouldNotContainKey, 1), "You must provide a valid map type (was assertions.Thing1)!") - this.fail(so(nil, ShouldNotContainKey, 1), "You must provide a valid map type (was )!") - this.fail(so(map[int]int{1: 41}, ShouldNotContainKey, 1), "Expected the map[int]int NOT to contain the key: [1] (but it did)!") - this.pass(so(map[int]int{1: 41}, ShouldNotContainKey, 2)) + fail(t, so(Thing1{}, ShouldNotContainKey, 1), "You must provide a valid map type (was assertions.Thing1)!") + fail(t, so(nil, ShouldNotContainKey, 1), "You must provide a valid map type (was )!") + fail(t, so(map[int]int{1: 41}, ShouldNotContainKey, 1), "Expected the map[int]int NOT to contain the key: [1] (but it did)!") + pass(t, so(map[int]int{1: 41}, ShouldNotContainKey, 2)) } -func (this *AssertionsFixture) TestShouldContain() { - this.fail(so([]int{}, ShouldContain), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so([]int{}, ShouldContain, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldContain(t *testing.T) { + fail(t, so([]int{}, ShouldContain), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so([]int{}, ShouldContain, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(Thing1{}, ShouldContain, 1), "You must provide a valid container (was assertions.Thing1)!") - this.fail(so(nil, ShouldContain, 1), "You must provide a valid container (was )!") - this.fail(so([]int{1}, ShouldContain, 2), "Expected the container ([]int) to contain: '2' (but it didn't)!") - this.fail(so([][]int{{1}}, ShouldContain, []int{2}), "Expected the container ([][]int) to contain: '[2]' (but it didn't)!") + fail(t, so(Thing1{}, ShouldContain, 1), "You must provide a valid container (was assertions.Thing1)!") + fail(t, so(nil, ShouldContain, 1), "You must provide a valid container (was )!") + fail(t, so([]int{1}, ShouldContain, 2), "Expected the container ([]int) to contain: '2' (but it didn't)!") - this.pass(so([]int{1}, ShouldContain, 1)) - this.pass(so([]int{1, 2, 3}, ShouldContain, 2)) - this.pass(so([][]int{{1}, {2}, {3}}, ShouldContain, []int{2})) + pass(t, so([]int{1}, ShouldContain, 1)) + pass(t, so([]int{1, 2, 3}, ShouldContain, 2)) } -func (this *AssertionsFixture) TestShouldNotContain() { - this.fail(so([]int{}, ShouldNotContain), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so([]int{}, ShouldNotContain, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldNotContain(t *testing.T) { + fail(t, so([]int{}, ShouldNotContain), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so([]int{}, ShouldNotContain, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(Thing1{}, ShouldNotContain, 1), "You must provide a valid container (was assertions.Thing1)!") - this.fail(so(nil, ShouldNotContain, 1), "You must provide a valid container (was )!") + fail(t, so(Thing1{}, ShouldNotContain, 1), "You must provide a valid container (was assertions.Thing1)!") + fail(t, so(nil, ShouldNotContain, 1), "You must provide a valid container (was )!") - this.fail(so([]int{1}, ShouldNotContain, 1), "Expected the container ([]int) NOT to contain: '1' (but it did)!") - this.fail(so([]int{1, 2, 3}, ShouldNotContain, 2), "Expected the container ([]int) NOT to contain: '2' (but it did)!") - this.fail(so([][]int{{1}, {2}, {3}}, ShouldNotContain, []int{2}), "Expected the container ([][]int) NOT to contain: '[2]' (but it did)!") + fail(t, so([]int{1}, ShouldNotContain, 1), "Expected the container ([]int) NOT to contain: '1' (but it did)!") + fail(t, so([]int{1, 2, 3}, ShouldNotContain, 2), "Expected the container ([]int) NOT to contain: '2' (but it did)!") - this.pass(so([]int{1}, ShouldNotContain, 2)) - this.pass(so([][]int{{1}, {2}, {3}}, ShouldNotContain, []int{4})) + pass(t, so([]int{1}, ShouldNotContain, 2)) } -func (this *AssertionsFixture) TestShouldBeIn() { - this.fail(so(4, ShouldBeIn), needNonEmptyCollection) +func TestShouldBeIn(t *testing.T) { + fail(t, so(4, ShouldBeIn), needNonEmptyCollection) container := []int{1, 2, 3, 4} - this.pass(so(4, ShouldBeIn, container)) - this.pass(so(4, ShouldBeIn, 1, 2, 3, 4)) - this.pass(so([]int{4}, ShouldBeIn, [][]int{{1}, {2}, {3}, {4}})) - this.pass(so([]int{4}, ShouldBeIn, []int{1}, []int{2}, []int{3}, []int{4})) - - this.fail(so(4, ShouldBeIn, 1, 2, 3), "Expected '4' to be in the container ([]interface {}), but it wasn't!") - this.fail(so(4, ShouldBeIn, []int{1, 2, 3}), "Expected '4' to be in the container ([]int), but it wasn't!") - this.fail(so([]int{4}, ShouldBeIn, []int{1}, []int{2}, []int{3}), "Expected '[4]' to be in the container ([]interface {}), but it wasn't!") - this.fail(so([]int{4}, ShouldBeIn, [][]int{{1}, {2}, {3}}), "Expected '[4]' to be in the container ([][]int), but it wasn't!") + pass(t, so(4, ShouldBeIn, container)) + pass(t, so(4, ShouldBeIn, 1, 2, 3, 4)) + + fail(t, so(4, ShouldBeIn, 1, 2, 3), "Expected '4' to be in the container ([]interface {}), but it wasn't!") + fail(t, so(4, ShouldBeIn, []int{1, 2, 3}), "Expected '4' to be in the container ([]int), but it wasn't!") } -func (this *AssertionsFixture) TestShouldNotBeIn() { - this.fail(so(4, ShouldNotBeIn), needNonEmptyCollection) +func TestShouldNotBeIn(t *testing.T) { + fail(t, so(4, ShouldNotBeIn), needNonEmptyCollection) container := []int{1, 2, 3, 4} - this.pass(so(42, ShouldNotBeIn, container)) - this.pass(so(42, ShouldNotBeIn, 1, 2, 3, 4)) - this.pass(so([]int{42}, ShouldNotBeIn, []int{1}, []int{2}, []int{3}, []int{4})) - this.pass(so([]int{42}, ShouldNotBeIn, [][]int{{1}, {2}, {3}, {4}})) - - this.fail(so(2, ShouldNotBeIn, 1, 2, 3), "Expected '2' NOT to be in the container ([]interface {}), but it was!") - this.fail(so(2, ShouldNotBeIn, []int{1, 2, 3}), "Expected '2' NOT to be in the container ([]int), but it was!") - this.fail(so([]int{2}, ShouldNotBeIn, []int{1}, []int{2}, []int{3}), "Expected '[2]' NOT to be in the container ([]interface {}), but it was!") - this.fail(so([]int{2}, ShouldNotBeIn, [][]int{{1}, {2}, {3}}), "Expected '[2]' NOT to be in the container ([][]int), but it was!") + pass(t, so(42, ShouldNotBeIn, container)) + pass(t, so(42, ShouldNotBeIn, 1, 2, 3, 4)) + + fail(t, so(2, ShouldNotBeIn, 1, 2, 3), "Expected '2' NOT to be in the container ([]interface {}), but it was!") + fail(t, so(2, ShouldNotBeIn, []int{1, 2, 3}), "Expected '2' NOT to be in the container ([]int), but it was!") } -func (this *AssertionsFixture) TestShouldBeEmpty() { - this.fail(so(1, ShouldBeEmpty, 2, 3), "This assertion requires exactly 0 comparison values (you provided 2).") - - this.pass(so([]int{}, ShouldBeEmpty)) // empty slice - this.pass(so([][]int{}, ShouldBeEmpty)) // empty slice - this.pass(so([]interface{}{}, ShouldBeEmpty)) // empty slice - this.pass(so(map[string]int{}, ShouldBeEmpty)) // empty map - this.pass(so("", ShouldBeEmpty)) // empty string - this.pass(so(&[]int{}, ShouldBeEmpty)) // pointer to empty slice - this.pass(so(&[0]int{}, ShouldBeEmpty)) // pointer to empty array - this.pass(so(nil, ShouldBeEmpty)) // nil - this.pass(so(make(chan string), ShouldBeEmpty)) // empty channel - - this.fail(so([]int{1}, ShouldBeEmpty), "Expected [1] to be empty (but it wasn't)!") // non-empty slice - this.fail(so([][]int{{1}}, ShouldBeEmpty), "Expected [[1]] to be empty (but it wasn't)!") // non-empty slice - this.fail(so([]interface{}{1}, ShouldBeEmpty), "Expected [1] to be empty (but it wasn't)!") // non-empty slice - this.fail(so(map[string]int{"hi": 0}, ShouldBeEmpty), "Expected map[hi:0] to be empty (but it wasn't)!") // non-empty map - this.fail(so("hi", ShouldBeEmpty), "Expected hi to be empty (but it wasn't)!") // non-empty string - this.fail(so(&[]int{1}, ShouldBeEmpty), "Expected &[1] to be empty (but it wasn't)!") // pointer to non-empty slice - this.fail(so(&[1]int{1}, ShouldBeEmpty), "Expected &[1] to be empty (but it wasn't)!") // pointer to non-empty array - c := make(chan int, 1) // non-empty channel +func TestShouldBeEmpty(t *testing.T) { + fail(t, so(1, ShouldBeEmpty, 2, 3), "This assertion requires exactly 0 comparison values (you provided 2).") + + pass(t, so([]int{}, ShouldBeEmpty)) // empty slice + pass(t, so([]interface{}{}, ShouldBeEmpty)) // empty slice + pass(t, so(map[string]int{}, ShouldBeEmpty)) // empty map + pass(t, so("", ShouldBeEmpty)) // empty string + pass(t, so(&[]int{}, ShouldBeEmpty)) // pointer to empty slice + pass(t, so(&[0]int{}, ShouldBeEmpty)) // pointer to empty array + pass(t, so(nil, ShouldBeEmpty)) // nil + pass(t, so(make(chan string), ShouldBeEmpty)) // empty channel + + fail(t, so([]int{1}, ShouldBeEmpty), "Expected [1] to be empty (but it wasn't)!") // non-empty slice + fail(t, so([]interface{}{1}, ShouldBeEmpty), "Expected [1] to be empty (but it wasn't)!") // non-empty slice + fail(t, so(map[string]int{"hi": 0}, ShouldBeEmpty), "Expected map[hi:0] to be empty (but it wasn't)!") // non-empty map + fail(t, so("hi", ShouldBeEmpty), "Expected hi to be empty (but it wasn't)!") // non-empty string + fail(t, so(&[]int{1}, ShouldBeEmpty), "Expected &[1] to be empty (but it wasn't)!") // pointer to non-empty slice + fail(t, so(&[1]int{1}, ShouldBeEmpty), "Expected &[1] to be empty (but it wasn't)!") // pointer to non-empty array + c := make(chan int, 1) // non-empty channel go func() { c <- 1 }() time.Sleep(time.Millisecond) - this.fail(so(c, ShouldBeEmpty), fmt.Sprintf("Expected %+v to be empty (but it wasn't)!", c)) + fail(t, so(c, ShouldBeEmpty), fmt.Sprintf("Expected %+v to be empty (but it wasn't)!", c)) } -func (this *AssertionsFixture) TestShouldNotBeEmpty() { - this.fail(so(1, ShouldNotBeEmpty, 2, 3), "This assertion requires exactly 0 comparison values (you provided 2).") - - this.fail(so([]int{}, ShouldNotBeEmpty), "Expected [] to NOT be empty (but it was)!") // empty slice - this.fail(so([]interface{}{}, ShouldNotBeEmpty), "Expected [] to NOT be empty (but it was)!") // empty slice - this.fail(so(map[string]int{}, ShouldNotBeEmpty), "Expected map[] to NOT be empty (but it was)!") // empty map - this.fail(so("", ShouldNotBeEmpty), "Expected to NOT be empty (but it was)!") // empty string - this.fail(so(&[]int{}, ShouldNotBeEmpty), "Expected &[] to NOT be empty (but it was)!") // pointer to empty slice - this.fail(so(&[0]int{}, ShouldNotBeEmpty), "Expected &[] to NOT be empty (but it was)!") // pointer to empty array - this.fail(so(nil, ShouldNotBeEmpty), "Expected to NOT be empty (but it was)!") // nil - c := make(chan int, 0) // non-empty channel - this.fail(so(c, ShouldNotBeEmpty), fmt.Sprintf("Expected %+v to NOT be empty (but it was)!", c)) // empty channel - - this.pass(so([]int{1}, ShouldNotBeEmpty)) // non-empty slice - this.pass(so([]interface{}{1}, ShouldNotBeEmpty)) // non-empty slice - this.pass(so(map[string]int{"hi": 0}, ShouldNotBeEmpty)) // non-empty map - this.pass(so("hi", ShouldNotBeEmpty)) // non-empty string - this.pass(so(&[]int{1}, ShouldNotBeEmpty)) // pointer to non-empty slice - this.pass(so(&[1]int{1}, ShouldNotBeEmpty)) // pointer to non-empty array +func TestShouldNotBeEmpty(t *testing.T) { + fail(t, so(1, ShouldNotBeEmpty, 2, 3), "This assertion requires exactly 0 comparison values (you provided 2).") + + fail(t, so([]int{}, ShouldNotBeEmpty), "Expected [] to NOT be empty (but it was)!") // empty slice + fail(t, so([]interface{}{}, ShouldNotBeEmpty), "Expected [] to NOT be empty (but it was)!") // empty slice + fail(t, so(map[string]int{}, ShouldNotBeEmpty), "Expected map[] to NOT be empty (but it was)!") // empty map + fail(t, so("", ShouldNotBeEmpty), "Expected to NOT be empty (but it was)!") // empty string + fail(t, so(&[]int{}, ShouldNotBeEmpty), "Expected &[] to NOT be empty (but it was)!") // pointer to empty slice + fail(t, so(&[0]int{}, ShouldNotBeEmpty), "Expected &[] to NOT be empty (but it was)!") // pointer to empty array + fail(t, so(nil, ShouldNotBeEmpty), "Expected to NOT be empty (but it was)!") // nil + c := make(chan int, 0) // non-empty channel + fail(t, so(c, ShouldNotBeEmpty), fmt.Sprintf("Expected %+v to NOT be empty (but it was)!", c)) // empty channel + + pass(t, so([]int{1}, ShouldNotBeEmpty)) // non-empty slice + pass(t, so([]interface{}{1}, ShouldNotBeEmpty)) // non-empty slice + pass(t, so(map[string]int{"hi": 0}, ShouldNotBeEmpty)) // non-empty map + pass(t, so("hi", ShouldNotBeEmpty)) // non-empty string + pass(t, so(&[]int{1}, ShouldNotBeEmpty)) // pointer to non-empty slice + pass(t, so(&[1]int{1}, ShouldNotBeEmpty)) // pointer to non-empty array c = make(chan int, 1) go func() { c <- 1 }() time.Sleep(time.Millisecond) - this.pass(so(c, ShouldNotBeEmpty)) + pass(t, so(c, ShouldNotBeEmpty)) } -func (this *AssertionsFixture) TestShouldHaveLength() { - this.fail(so(1, ShouldHaveLength, 2), "You must provide a valid container (was int)!") - this.fail(so(nil, ShouldHaveLength, 1), "You must provide a valid container (was )!") - this.fail(so("hi", ShouldHaveLength, float64(1.0)), "You must provide a valid integer (was float64)!") - this.fail(so([]string{}, ShouldHaveLength), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so([]string{}, ShouldHaveLength, 1, 2), "This assertion requires exactly 1 comparison values (you provided 2).") - this.fail(so([]string{}, ShouldHaveLength, -10), "You must provide a valid positive integer (was -10)!") - - this.fail(so([]int{}, ShouldHaveLength, 1), "Expected [] (length: 0) to have length equal to '1', but it wasn't!") // empty slice - this.fail(so([]interface{}{}, ShouldHaveLength, 1), "Expected [] (length: 0) to have length equal to '1', but it wasn't!") // empty slice - this.fail(so(map[string]int{}, ShouldHaveLength, 1), "Expected map[] (length: 0) to have length equal to '1', but it wasn't!") // empty map - this.fail(so("", ShouldHaveLength, 1), "Expected (length: 0) to have length equal to '1', but it wasn't!") // empty string - this.fail(so(&[]int{}, ShouldHaveLength, 1), "Expected &[] (length: 0) to have length equal to '1', but it wasn't!") // pointer to empty slice - this.fail(so(&[0]int{}, ShouldHaveLength, 1), "Expected &[] (length: 0) to have length equal to '1', but it wasn't!") // pointer to empty array - c := make(chan int, 0) // non-empty channel - this.fail(so(c, ShouldHaveLength, 1), fmt.Sprintf("Expected %+v (length: 0) to have length equal to '1', but it wasn't!", c)) +func TestShouldHaveLength(t *testing.T) { + fail(t, so(1, ShouldHaveLength, 2), "You must provide a valid container (was int)!") + fail(t, so(nil, ShouldHaveLength, 1), "You must provide a valid container (was )!") + fail(t, so("hi", ShouldHaveLength, float64(1.0)), "You must provide a valid integer (was float64)!") + fail(t, so([]string{}, ShouldHaveLength), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so([]string{}, ShouldHaveLength, 1, 2), "This assertion requires exactly 1 comparison values (you provided 2).") + fail(t, so([]string{}, ShouldHaveLength, -10), "You must provide a valid positive integer (was -10)!") + + fail(t, so([]int{}, ShouldHaveLength, 1), "Expected [] to have length equal to '1', but it wasn't!") // empty slice + fail(t, so([]interface{}{}, ShouldHaveLength, 1), "Expected [] to have length equal to '1', but it wasn't!") // empty slice + fail(t, so(map[string]int{}, ShouldHaveLength, 1), "Expected map[] to have length equal to '1', but it wasn't!") // empty map + fail(t, so("", ShouldHaveLength, 1), "Expected to have length equal to '1', but it wasn't!") // empty string + fail(t, so(&[]int{}, ShouldHaveLength, 1), "Expected &[] to have length equal to '1', but it wasn't!") // pointer to empty slice + fail(t, so(&[0]int{}, ShouldHaveLength, 1), "Expected &[] to have length equal to '1', but it wasn't!") // pointer to empty array + c := make(chan int, 0) // non-empty channel + fail(t, so(c, ShouldHaveLength, 1), fmt.Sprintf("Expected %+v to have length equal to '1', but it wasn't!", c)) c = make(chan int) // empty channel - this.fail(so(c, ShouldHaveLength, 1), fmt.Sprintf("Expected %+v (length: 0) to have length equal to '1', but it wasn't!", c)) - - this.pass(so([]int{1}, ShouldHaveLength, 1)) // non-empty slice - this.pass(so([]interface{}{1}, ShouldHaveLength, 1)) // non-empty slice - this.pass(so(map[string]int{"hi": 0}, ShouldHaveLength, 1)) // non-empty map - this.pass(so("hi", ShouldHaveLength, 2)) // non-empty string - this.pass(so(&[]int{1}, ShouldHaveLength, 1)) // pointer to non-empty slice - this.pass(so(&[1]int{1}, ShouldHaveLength, 1)) // pointer to non-empty array + fail(t, so(c, ShouldHaveLength, 1), fmt.Sprintf("Expected %+v to have length equal to '1', but it wasn't!", c)) + + pass(t, so([]int{1}, ShouldHaveLength, 1)) // non-empty slice + pass(t, so([]interface{}{1}, ShouldHaveLength, 1)) // non-empty slice + pass(t, so(map[string]int{"hi": 0}, ShouldHaveLength, 1)) // non-empty map + pass(t, so("hi", ShouldHaveLength, 2)) // non-empty string + pass(t, so(&[]int{1}, ShouldHaveLength, 1)) // pointer to non-empty slice + pass(t, so(&[1]int{1}, ShouldHaveLength, 1)) // pointer to non-empty array c = make(chan int, 1) go func() { c <- 1 }() time.Sleep(time.Millisecond) - this.pass(so(c, ShouldHaveLength, 1)) - this.pass(so(c, ShouldHaveLength, uint(1))) + pass(t, so(c, ShouldHaveLength, 1)) } diff --git a/vendor/github.com/smartystreets/assertions/doc.go b/vendor/github.com/smartystreets/assertions/doc.go index 43ceb6e9a..d3d116c41 100644 --- a/vendor/github.com/smartystreets/assertions/doc.go +++ b/vendor/github.com/smartystreets/assertions/doc.go @@ -1,14 +1,8 @@ // Package assertions contains the implementations for all assertions which // are referenced in goconvey's `convey` package -// (github.com/smartystreets/goconvey/convey) and gunit (github.com/smartystreets/gunit) -// for use with the So(...) method. +// (github.com/smartystreets/goconvey/convey) for use with the So(...) method. // They can also be used in traditional Go test functions and even in -// applications. -// -// Many of the assertions lean heavily on work done by Aaron Jacobs in his excellent oglematchers library. -// (https://github.com/jacobsa/oglematchers) -// The ShouldResemble assertion leans heavily on work done by Daniel Jacques in his very helpful go-render library. -// (https://github.com/luci/go-render) +// applicaitons. package assertions import ( @@ -26,7 +20,7 @@ var serializer Serializer = new(noopSerializer) // are very helpful and can be rendered in a DIFF view. In that case, this function // will be called with a true value to enable the JSON serialization. By default, // the assertions in this package will not serializer a JSON result, making -// standalone usage more convenient. +// standalone ussage more convenient. func GoConveyMode(yes bool) { if yes { serializer = newSerializer() diff --git a/vendor/github.com/smartystreets/assertions/doc_test.go b/vendor/github.com/smartystreets/assertions/doc_test.go index faaaf9314..041faaffc 100644 --- a/vendor/github.com/smartystreets/assertions/doc_test.go +++ b/vendor/github.com/smartystreets/assertions/doc_test.go @@ -3,26 +3,9 @@ package assertions import ( "bytes" "fmt" - "reflect" "testing" ) -func TestGoConveyModeAffectsSerializer(t *testing.T) { - if reflect.TypeOf(serializer) != reflect.TypeOf(new(noopSerializer)) { - t.Error("Expected noop serializer as default") - } - - GoConveyMode(true) - if reflect.TypeOf(serializer) != reflect.TypeOf(new(failureSerializer)) { - t.Error("Expected failure serializer") - } - - GoConveyMode(false) - if reflect.TypeOf(serializer) != reflect.TypeOf(new(noopSerializer)) { - t.Error("Expected noop serializer") - } -} - func TestPassingAssertion(t *testing.T) { fake := &FakeT{buffer: new(bytes.Buffer)} assertion := New(fake) diff --git a/vendor/github.com/smartystreets/assertions/equal_method.go b/vendor/github.com/smartystreets/assertions/equal_method.go deleted file mode 100644 index 54efa3ee6..000000000 --- a/vendor/github.com/smartystreets/assertions/equal_method.go +++ /dev/null @@ -1,79 +0,0 @@ -package assertions - -import ( - "reflect" - - "github.com/smartystreets/logging" -) - -type equalityMethodSpecification struct { - a interface{} - b interface{} - - aType reflect.Type - bType reflect.Type - - equalMethod reflect.Value - - log *logging.Logger -} - -func newEqualityMethodSpecification(a, b interface{}) *equalityMethodSpecification { - return &equalityMethodSpecification{ - a: a, - b: b, - log: logging.Capture(), - } -} - -func (this *equalityMethodSpecification) IsSatisfied() bool { - if !this.bothAreSameType() { - return false - } - if !this.typeHasEqualMethod() { - return false - } - if !this.equalMethodReceivesSameTypeForComparison() { - return false - } - if !this.equalMethodReturnsBool() { - return false - } - return true -} - -func (this *equalityMethodSpecification) bothAreSameType() bool { - this.aType = reflect.TypeOf(this.a) - if this.aType.Kind() == reflect.Ptr { - this.aType = this.aType.Elem() - } - this.bType = reflect.TypeOf(this.b) - return this.aType == this.bType -} -func (this *equalityMethodSpecification) typeHasEqualMethod() bool { - aInstance := reflect.ValueOf(this.a) - this.equalMethod = aInstance.MethodByName("Equal") - return this.equalMethod != reflect.Value{} -} - -func (this *equalityMethodSpecification) equalMethodReceivesSameTypeForComparison() bool { - signature := this.equalMethod.Type() - return signature.NumIn() == 1 && signature.In(0) == this.aType -} - -func (this *equalityMethodSpecification) equalMethodReturnsBool() bool { - signature := this.equalMethod.Type() - return signature.NumOut() == 1 && signature.Out(0) == reflect.TypeOf(true) -} - -func (this *equalityMethodSpecification) AreEqual() bool { - a := reflect.ValueOf(this.a) - b := reflect.ValueOf(this.b) - return areEqual(a, b) && areEqual(b, a) -} -func areEqual(receiver reflect.Value, argument reflect.Value) bool { - equalMethod := receiver.MethodByName("Equal") - argumentList := []reflect.Value{argument} - result := equalMethod.Call(argumentList) - return result[0].Bool() -} diff --git a/vendor/github.com/smartystreets/assertions/equal_method_test.go b/vendor/github.com/smartystreets/assertions/equal_method_test.go deleted file mode 100644 index 3c8b329ac..000000000 --- a/vendor/github.com/smartystreets/assertions/equal_method_test.go +++ /dev/null @@ -1,151 +0,0 @@ -package assertions - -import ( - "testing" - - "github.com/smartystreets/gunit" -) - -func TestEqualityFixture(t *testing.T) { - gunit.Run(new(EqualityFixture), t) -} - -type EqualityFixture struct { - *gunit.Fixture -} - -func (this *EqualityFixture) TestEligible1() { - a := Eligible1{"hi"} - b := Eligible1{"hi"} - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeTrue) - this.So(specification.AreEqual(), ShouldBeTrue) -} - -func (this *EqualityFixture) TestAreEqual() { - a := Eligible1{"hi"} - b := Eligible1{"hi"} - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeTrue) - this.So(specification.AreEqual(), ShouldBeTrue) -} - -func (this *EqualityFixture) TestAreNotEqual() { - a := Eligible1{"hi"} - b := Eligible1{"bye"} - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeTrue) - this.So(specification.AreEqual(), ShouldBeFalse) -} - -func (this *EqualityFixture) TestEligible2() { - a := Eligible2{"hi"} - b := Eligible2{"hi"} - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeTrue) -} - -func (this *EqualityFixture) TestEligible1_PointerReceiver() { - a := &Eligible1{"hi"} - b := Eligible1{"hi"} - this.So(a.Equal(b), ShouldBeTrue) - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeTrue) - this.Println(specification.log.Log) -} - -func (this *EqualityFixture) TestIneligible_PrimitiveTypes() { - specification := newEqualityMethodSpecification(1, 1) - this.So(specification.IsSatisfied(), ShouldBeFalse) -} - -func (this *EqualityFixture) TestIneligible_DisparateTypes() { - a := Eligible1{"hi"} - b := Eligible2{"hi"} - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeFalse) -} - -func (this *EqualityFixture) TestIneligible_NoEqualMethod() { - a := Ineligible_NoEqualMethod{} - b := Ineligible_NoEqualMethod{} - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeFalse) -} - -func (this *EqualityFixture) TestIneligible_EqualMethodReceivesNoInput() { - a := Ineligible_EqualMethodNoInputs{} - b := Ineligible_EqualMethodNoInputs{} - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeFalse) -} - -func (this *EqualityFixture) TestIneligible_EqualMethodReceivesTooManyInputs() { - a := Ineligible_EqualMethodTooManyInputs{} - b := Ineligible_EqualMethodTooManyInputs{} - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeFalse) -} - -func (this *EqualityFixture) TestIneligible_EqualMethodReceivesWrongInput() { - a := Ineligible_EqualMethodWrongInput{} - b := Ineligible_EqualMethodWrongInput{} - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeFalse) -} - -func (this *EqualityFixture) TestIneligible_EqualMethodReturnsNoOutputs() { - a := Ineligible_EqualMethodNoOutputs{} - b := Ineligible_EqualMethodNoOutputs{} - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeFalse) -} - -func (this *EqualityFixture) TestIneligible_EqualMethodReturnsTooManyOutputs() { - a := Ineligible_EqualMethodTooManyOutputs{} - b := Ineligible_EqualMethodTooManyOutputs{} - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeFalse) -} - -func (this *EqualityFixture) TestIneligible_EqualMethodReturnsWrongOutputs() { - a := Ineligible_EqualMethodWrongOutput{} - b := Ineligible_EqualMethodWrongOutput{} - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeFalse) -} - -func (this *EqualityFixture) TestEligibleAsymmetric_EqualMethodResultDiffersWhenArgumentsInverted() { - a := EligibleAsymmetric{a: 0} - b := EligibleAsymmetric{a: 1} - specification := newEqualityMethodSpecification(a, b) - this.So(specification.IsSatisfied(), ShouldBeTrue) - this.So(specification.AreEqual(), ShouldBeFalse) -} - -/**************************************************************************/ - -type ( - Eligible1 struct{ a string } - Eligible2 struct{ a string } - EligibleAsymmetric struct{ a int } - Ineligible_NoEqualMethod struct{} - Ineligible_EqualMethodNoInputs struct{} - Ineligible_EqualMethodNoOutputs struct{} - Ineligible_EqualMethodTooManyInputs struct{} - Ineligible_EqualMethodTooManyOutputs struct{} - Ineligible_EqualMethodWrongInput struct{} - Ineligible_EqualMethodWrongOutput struct{} -) - -func (this Eligible1) Equal(that Eligible1) bool { return this.a == that.a } -func (this Eligible2) Equal(that Eligible2) bool { return this.a == that.a } -func (this EligibleAsymmetric) Equal(that EligibleAsymmetric) bool { - return this.a == 0 -} -func (this Ineligible_EqualMethodNoInputs) Equal() bool { return true } -func (this Ineligible_EqualMethodNoOutputs) Equal(that Ineligible_EqualMethodNoOutputs) {} -func (this Ineligible_EqualMethodTooManyInputs) Equal(a, b bool) bool { return true } -func (this Ineligible_EqualMethodTooManyOutputs) Equal(bool) (bool, bool) { return true, true } -func (this Ineligible_EqualMethodWrongInput) Equal(a string) bool { return true } -func (this Ineligible_EqualMethodWrongOutput) Equal(Ineligible_EqualMethodWrongOutput) int { return 0 } diff --git a/vendor/github.com/smartystreets/assertions/equality.go b/vendor/github.com/smartystreets/assertions/equality.go index 0a4b1f3dd..95cd3473a 100644 --- a/vendor/github.com/smartystreets/assertions/equality.go +++ b/vendor/github.com/smartystreets/assertions/equality.go @@ -7,15 +7,13 @@ import ( "reflect" "strings" - "github.com/smartystreets/assertions/internal/go-render/render" "github.com/smartystreets/assertions/internal/oglematchers" ) -// ShouldEqual receives exactly two parameters and does an equality check -// using the following semantics: -// 1. If the expected and actual values implement an Equal method in the form -// `func (this T) Equal(that T) bool` then call the method. If true, they are equal. -// 2. The expected and actual values are judged equal or not by oglematchers.Equals. +// default acceptable delta for ShouldAlmostEqual +const defaultDelta = 0.0000000001 + +// ShouldEqual receives exactly two parameters and does an equality check. func ShouldEqual(actual interface{}, expected ...interface{}) string { if message := need(1, expected); message != success { return message @@ -26,17 +24,10 @@ func shouldEqual(actual, expected interface{}) (message string) { defer func() { if r := recover(); r != nil { message = serializer.serialize(expected, actual, fmt.Sprintf(shouldHaveBeenEqual, expected, actual)) + return } }() - if specification := newEqualityMethodSpecification(expected, actual); specification.IsSatisfied() { - if specification.AreEqual() { - return success - } else { - message = fmt.Sprintf(shouldHaveBeenEqual, expected, actual) - return serializer.serialize(expected, actual, message) - } - } if matchError := oglematchers.Equals(expected).Matches(actual); matchError != nil { expectedSyntax := fmt.Sprintf("%v", expected) actualSyntax := fmt.Sprintf("%v", actual) @@ -45,14 +36,14 @@ func shouldEqual(actual, expected interface{}) (message string) { } else { message = fmt.Sprintf(shouldHaveBeenEqual, expected, actual) } - return serializer.serialize(expected, actual, message) + message = serializer.serialize(expected, actual, message) + return } return success } // ShouldNotEqual receives exactly two parameters and does an inequality check. -// See ShouldEqual for details on how equality is determined. func ShouldNotEqual(actual interface{}, expected ...interface{}) string { if fail := need(1, expected); fail != success { return fail @@ -103,7 +94,7 @@ func cleanAlmostEqualInput(actual interface{}, expected ...interface{}) (float64 delta, err := getFloat(expected[1]) if err != nil { - return 0.0, 0.0, 0.0, "The delta value " + err.Error() + return 0.0, 0.0, 0.0, "delta must be a numerical type" } deltaFloat = delta @@ -112,13 +103,15 @@ func cleanAlmostEqualInput(actual interface{}, expected ...interface{}) (float64 } actualFloat, err := getFloat(actual) + if err != nil { - return 0.0, 0.0, 0.0, "The actual value " + err.Error() + return 0.0, 0.0, 0.0, err.Error() } expectedFloat, err := getFloat(expected[0]) + if err != nil { - return 0.0, 0.0, 0.0, "The comparison value " + err.Error() + return 0.0, 0.0, 0.0, err.Error() } return actualFloat, expectedFloat, deltaFloat, "" @@ -145,7 +138,7 @@ func getFloat(num interface{}) (float64, error) { numKind == reflect.Float64 { return numValue.Float(), nil } else { - return 0.0, errors.New("must be a numerical type, but was: " + numKind.String()) + return 0.0, errors.New("must be a numerical type, but was " + numKind.String()) } } @@ -156,8 +149,15 @@ func ShouldResemble(actual interface{}, expected ...interface{}) string { } if matchError := oglematchers.DeepEquals(expected[0]).Matches(actual); matchError != nil { - return serializer.serializeDetailed(expected[0], actual, - fmt.Sprintf(shouldHaveResembled, render.Render(expected[0]), render.Render(actual))) + expectedSyntax := fmt.Sprintf("%#v", expected[0]) + actualSyntax := fmt.Sprintf("%#v", actual) + var message string + if expectedSyntax == actualSyntax { + message = fmt.Sprintf(shouldHaveResembledTypeMismatch, expected[0], expected[0], actual, actual) + } else { + message = fmt.Sprintf(shouldHaveResembled, expected[0], actual) + } + return serializer.serializeDetailed(expected[0], actual, message) } return success @@ -168,7 +168,7 @@ func ShouldNotResemble(actual interface{}, expected ...interface{}) string { if message := need(1, expected); message != success { return message } else if ShouldResemble(actual, expected[0]) == success { - return fmt.Sprintf(shouldNotHaveResembled, render.Render(actual), render.Render(expected[0])) + return fmt.Sprintf(shouldNotHaveResembled, actual, expected[0]) } return success } diff --git a/vendor/github.com/smartystreets/assertions/equality_test.go b/vendor/github.com/smartystreets/assertions/equality_test.go index 23fc78568..dde0c5494 100644 --- a/vendor/github.com/smartystreets/assertions/equality_test.go +++ b/vendor/github.com/smartystreets/assertions/equality_test.go @@ -3,173 +3,145 @@ package assertions import ( "fmt" "reflect" - "time" + "testing" ) -func (this *AssertionsFixture) TestShouldEqual() { - this.fail(so(1, ShouldEqual), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(1, ShouldEqual, 1, 2), "This assertion requires exactly 1 comparison values (you provided 2).") - this.fail(so(1, ShouldEqual, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldEqual(t *testing.T) { + serializer = newFakeSerializer() - this.pass(so(1, ShouldEqual, 1)) - this.fail(so(1, ShouldEqual, 2), "2|1|Expected: '2' Actual: '1' (Should be equal)") - this.fail(so(1, ShouldEqual, "1"), "1|1|Expected: '1' (string) Actual: '1' (int) (Should be equal, type mismatch)") + fail(t, so(1, ShouldEqual), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(1, ShouldEqual, 1, 2), "This assertion requires exactly 1 comparison values (you provided 2).") + fail(t, so(1, ShouldEqual, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.pass(so(true, ShouldEqual, true)) - this.fail(so(true, ShouldEqual, false), "false|true|Expected: 'false' Actual: 'true' (Should be equal)") + pass(t, so(1, ShouldEqual, 1)) + fail(t, so(1, ShouldEqual, 2), "2|1|Expected: '2' Actual: '1' (Should be equal)") + fail(t, so(1, ShouldEqual, "1"), "1|1|Expected: '1' (string) Actual: '1' (int) (Should be equal, type mismatch)") - this.pass(so("hi", ShouldEqual, "hi")) - this.fail(so("hi", ShouldEqual, "bye"), "bye|hi|Expected: 'bye' Actual: 'hi' (Should be equal)") + pass(t, so(true, ShouldEqual, true)) + fail(t, so(true, ShouldEqual, false), "false|true|Expected: 'false' Actual: 'true' (Should be equal)") - this.pass(so(42, ShouldEqual, uint(42))) + pass(t, so("hi", ShouldEqual, "hi")) + fail(t, so("hi", ShouldEqual, "bye"), "bye|hi|Expected: 'bye' Actual: 'hi' (Should be equal)") - this.fail(so(Thing1{"hi"}, ShouldEqual, Thing1{}), "{}|{hi}|Expected: '{}' Actual: '{hi}' (Should be equal)") - this.fail(so(Thing1{"hi"}, ShouldEqual, Thing1{"hi"}), "{hi}|{hi}|Expected: '{hi}' Actual: '{hi}' (Should be equal)") - this.fail(so(&Thing1{"hi"}, ShouldEqual, &Thing1{"hi"}), "&{hi}|&{hi}|Expected: '&{hi}' Actual: '&{hi}' (Should be equal)") + pass(t, so(42, ShouldEqual, uint(42))) - this.fail(so(Thing1{}, ShouldEqual, Thing2{}), "{}|{}|Expected: '{}' Actual: '{}' (Should be equal)") + fail(t, so(Thing1{"hi"}, ShouldEqual, Thing1{}), "{}|{hi}|Expected: '{}' Actual: '{hi}' (Should be equal)") + fail(t, so(Thing1{"hi"}, ShouldEqual, Thing1{"hi"}), "{hi}|{hi}|Expected: '{hi}' Actual: '{hi}' (Should be equal)") + fail(t, so(&Thing1{"hi"}, ShouldEqual, &Thing1{"hi"}), "&{hi}|&{hi}|Expected: '&{hi}' Actual: '&{hi}' (Should be equal)") - this.pass(so(ThingWithEqualMethod{"hi"}, ShouldEqual, ThingWithEqualMethod{"hi"})) - this.fail(so(ThingWithEqualMethod{"hi"}, ShouldEqual, ThingWithEqualMethod{"bye"}), - "{bye}|{hi}|Expected: '{bye}' Actual: '{hi}' (Should be equal)") - -} -func (this *AssertionsFixture) TestTimeEqual() { - var ( - gopherCon, _ = time.LoadLocation("America/Denver") - elsewhere, _ = time.LoadLocation("America/New_York") - - timeNow = time.Now().In(gopherCon) - timeNowElsewhere = timeNow.In(elsewhere) - timeLater = timeNow.Add(time.Nanosecond) - ) - - this.pass(so(timeNow, ShouldNotResemble, timeNowElsewhere)) // Differing *Location field prevents ShouldResemble! - this.pass(so(timeNow, ShouldEqual, timeNowElsewhere)) // Time.Equal method used to determine exact instant. - this.pass(so(timeNow, ShouldNotEqual, timeLater)) + fail(t, so(Thing1{}, ShouldEqual, Thing2{}), "{}|{}|Expected: '{}' Actual: '{}' (Should be equal)") } -func (this *AssertionsFixture) TestShouldNotEqual() { - this.fail(so(1, ShouldNotEqual), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(1, ShouldNotEqual, 1, 2), "This assertion requires exactly 1 comparison values (you provided 2).") - this.fail(so(1, ShouldNotEqual, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldNotEqual(t *testing.T) { + fail(t, so(1, ShouldNotEqual), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(1, ShouldNotEqual, 1, 2), "This assertion requires exactly 1 comparison values (you provided 2).") + fail(t, so(1, ShouldNotEqual, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.pass(so(1, ShouldNotEqual, 2)) - this.pass(so(1, ShouldNotEqual, "1")) - this.fail(so(1, ShouldNotEqual, 1), "Expected '1' to NOT equal '1' (but it did)!") + pass(t, so(1, ShouldNotEqual, 2)) + pass(t, so(1, ShouldNotEqual, "1")) + fail(t, so(1, ShouldNotEqual, 1), "Expected '1' to NOT equal '1' (but it did)!") - this.pass(so(true, ShouldNotEqual, false)) - this.fail(so(true, ShouldNotEqual, true), "Expected 'true' to NOT equal 'true' (but it did)!") + pass(t, so(true, ShouldNotEqual, false)) + fail(t, so(true, ShouldNotEqual, true), "Expected 'true' to NOT equal 'true' (but it did)!") - this.pass(so("hi", ShouldNotEqual, "bye")) - this.fail(so("hi", ShouldNotEqual, "hi"), "Expected 'hi' to NOT equal 'hi' (but it did)!") + pass(t, so("hi", ShouldNotEqual, "bye")) + fail(t, so("hi", ShouldNotEqual, "hi"), "Expected 'hi' to NOT equal 'hi' (but it did)!") - this.pass(so(&Thing1{"hi"}, ShouldNotEqual, &Thing1{"hi"})) - this.pass(so(Thing1{"hi"}, ShouldNotEqual, Thing1{"hi"})) - this.pass(so(Thing1{}, ShouldNotEqual, Thing1{})) - this.pass(so(Thing1{}, ShouldNotEqual, Thing2{})) + pass(t, so(&Thing1{"hi"}, ShouldNotEqual, &Thing1{"hi"})) + pass(t, so(Thing1{"hi"}, ShouldNotEqual, Thing1{"hi"})) + pass(t, so(Thing1{}, ShouldNotEqual, Thing1{})) + pass(t, so(Thing1{}, ShouldNotEqual, Thing2{})) } -func (this *AssertionsFixture) TestShouldAlmostEqual() { - this.fail(so(1, ShouldAlmostEqual), "This assertion requires exactly one comparison value and an optional delta (you provided neither)") - this.fail(so(1, ShouldAlmostEqual, 1, 2, 3), "This assertion requires exactly one comparison value and an optional delta (you provided more values)") - this.fail(so(1, ShouldAlmostEqual, "1"), "The comparison value must be a numerical type, but was: string") - this.fail(so(1, ShouldAlmostEqual, 1, "1"), "The delta value must be a numerical type, but was: string") - this.fail(so("1", ShouldAlmostEqual, 1), "The actual value must be a numerical type, but was: string") +func TestShouldAlmostEqual(t *testing.T) { + fail(t, so(1, ShouldAlmostEqual), "This assertion requires exactly one comparison value and an optional delta (you provided neither)") + fail(t, so(1, ShouldAlmostEqual, 1, 2, 3), "This assertion requires exactly one comparison value and an optional delta (you provided more values)") // with the default delta - this.pass(so(.99999999999999, ShouldAlmostEqual, uint(1))) - this.pass(so(1, ShouldAlmostEqual, .99999999999999)) - this.pass(so(1.3612499999999996, ShouldAlmostEqual, 1.36125)) - this.pass(so(0.7285312499999999, ShouldAlmostEqual, 0.72853125)) - this.fail(so(1, ShouldAlmostEqual, .99), "Expected '1' to almost equal '0.99' (but it didn't)!") + pass(t, so(1, ShouldAlmostEqual, .99999999999999)) + pass(t, so(1.3612499999999996, ShouldAlmostEqual, 1.36125)) + pass(t, so(0.7285312499999999, ShouldAlmostEqual, 0.72853125)) + fail(t, so(1, ShouldAlmostEqual, .99), "Expected '1' to almost equal '0.99' (but it didn't)!") // with a different delta - this.pass(so(100.0, ShouldAlmostEqual, 110.0, 10.0)) - this.fail(so(100.0, ShouldAlmostEqual, 111.0, 10.5), "Expected '100' to almost equal '111' (but it didn't)!") - - // various ints should work - this.pass(so(100, ShouldAlmostEqual, 100.0)) - this.pass(so(int(100), ShouldAlmostEqual, 100.0)) - this.pass(so(int8(100), ShouldAlmostEqual, 100.0)) - this.pass(so(int16(100), ShouldAlmostEqual, 100.0)) - this.pass(so(int32(100), ShouldAlmostEqual, 100.0)) - this.pass(so(int64(100), ShouldAlmostEqual, 100.0)) - this.pass(so(uint(100), ShouldAlmostEqual, 100.0)) - this.pass(so(uint8(100), ShouldAlmostEqual, 100.0)) - this.pass(so(uint16(100), ShouldAlmostEqual, 100.0)) - this.pass(so(uint32(100), ShouldAlmostEqual, 100.0)) - this.pass(so(uint64(100), ShouldAlmostEqual, 100.0)) - this.pass(so(100, ShouldAlmostEqual, 100.0)) - this.fail(so(100, ShouldAlmostEqual, 99.0), "Expected '100' to almost equal '99' (but it didn't)!") - - // floats should work - this.pass(so(float64(100.0), ShouldAlmostEqual, float32(100.0))) - this.fail(so(float32(100.0), ShouldAlmostEqual, 99.0, float32(0.1)), "Expected '100' to almost equal '99' (but it didn't)!") + pass(t, so(100.0, ShouldAlmostEqual, 110.0, 10.0)) + fail(t, so(100.0, ShouldAlmostEqual, 111.0, 10.5), "Expected '100' to almost equal '111' (but it didn't)!") + + // ints should work + pass(t, so(100, ShouldAlmostEqual, 100.0)) + fail(t, so(100, ShouldAlmostEqual, 99.0), "Expected '100' to almost equal '99' (but it didn't)!") + + // float32 should work + pass(t, so(float64(100.0), ShouldAlmostEqual, float32(100.0))) + fail(t, so(float32(100.0), ShouldAlmostEqual, 99.0, float32(0.1)), "Expected '100' to almost equal '99' (but it didn't)!") } -func (this *AssertionsFixture) TestShouldNotAlmostEqual() { - this.fail(so(1, ShouldNotAlmostEqual), "This assertion requires exactly one comparison value and an optional delta (you provided neither)") - this.fail(so(1, ShouldNotAlmostEqual, 1, 2, 3), "This assertion requires exactly one comparison value and an optional delta (you provided more values)") +func TestShouldNotAlmostEqual(t *testing.T) { + fail(t, so(1, ShouldNotAlmostEqual), "This assertion requires exactly one comparison value and an optional delta (you provided neither)") + fail(t, so(1, ShouldNotAlmostEqual, 1, 2, 3), "This assertion requires exactly one comparison value and an optional delta (you provided more values)") // with the default delta - this.fail(so(1, ShouldNotAlmostEqual, .99999999999999), "Expected '1' to NOT almost equal '0.99999999999999' (but it did)!") - this.fail(so(1.3612499999999996, ShouldNotAlmostEqual, 1.36125), "Expected '1.3612499999999996' to NOT almost equal '1.36125' (but it did)!") - this.pass(so(1, ShouldNotAlmostEqual, .99)) + fail(t, so(1, ShouldNotAlmostEqual, .99999999999999), "Expected '1' to NOT almost equal '0.99999999999999' (but it did)!") + fail(t, so(1.3612499999999996, ShouldNotAlmostEqual, 1.36125), "Expected '1.3612499999999996' to NOT almost equal '1.36125' (but it did)!") + pass(t, so(1, ShouldNotAlmostEqual, .99)) // with a different delta - this.fail(so(100.0, ShouldNotAlmostEqual, 110.0, 10.0), "Expected '100' to NOT almost equal '110' (but it did)!") - this.pass(so(100.0, ShouldNotAlmostEqual, 111.0, 10.5)) + fail(t, so(100.0, ShouldNotAlmostEqual, 110.0, 10.0), "Expected '100' to NOT almost equal '110' (but it did)!") + pass(t, so(100.0, ShouldNotAlmostEqual, 111.0, 10.5)) // ints should work - this.fail(so(100, ShouldNotAlmostEqual, 100.0), "Expected '100' to NOT almost equal '100' (but it did)!") - this.pass(so(100, ShouldNotAlmostEqual, 99.0)) + fail(t, so(100, ShouldNotAlmostEqual, 100.0), "Expected '100' to NOT almost equal '100' (but it did)!") + pass(t, so(100, ShouldNotAlmostEqual, 99.0)) // float32 should work - this.fail(so(float64(100.0), ShouldNotAlmostEqual, float32(100.0)), "Expected '100' to NOT almost equal '100' (but it did)!") - this.pass(so(float32(100.0), ShouldNotAlmostEqual, 99.0, float32(0.1))) + fail(t, so(float64(100.0), ShouldNotAlmostEqual, float32(100.0)), "Expected '100' to NOT almost equal '100' (but it did)!") + pass(t, so(float32(100.0), ShouldNotAlmostEqual, 99.0, float32(0.1))) } -func (this *AssertionsFixture) TestShouldResemble() { - this.fail(so(Thing1{"hi"}, ShouldResemble), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(Thing1{"hi"}, ShouldResemble, Thing1{"hi"}, Thing1{"hi"}), "This assertion requires exactly 1 comparison values (you provided 2).") +func TestShouldResemble(t *testing.T) { + serializer = newFakeSerializer() + + fail(t, so(Thing1{"hi"}, ShouldResemble), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(Thing1{"hi"}, ShouldResemble, Thing1{"hi"}, Thing1{"hi"}), "This assertion requires exactly 1 comparison values (you provided 2).") - this.pass(so(Thing1{"hi"}, ShouldResemble, Thing1{"hi"})) - this.fail(so(Thing1{"hi"}, ShouldResemble, Thing1{"bye"}), `{bye}|{hi}|Expected: 'assertions.Thing1{a:"bye"}' Actual: 'assertions.Thing1{a:"hi"}' (Should resemble)!`) + pass(t, so(Thing1{"hi"}, ShouldResemble, Thing1{"hi"})) + fail(t, so(Thing1{"hi"}, ShouldResemble, Thing1{"bye"}), "{bye}|{hi}|Expected: 'assertions.Thing1{a:\"bye\"}' Actual: 'assertions.Thing1{a:\"hi\"}' (Should resemble)!") var ( a []int b []int = []int{} ) - this.fail(so(a, ShouldResemble, b), `[]|[]|Expected: '[]int{}' Actual: '[]int(nil)' (Should resemble)!`) - this.fail(so(2, ShouldResemble, 1), `1|2|Expected: '1' Actual: '2' (Should resemble)!`) + fail(t, so(a, ShouldResemble, b), "[]|[]|Expected: '[]int{}' Actual: '[]int(nil)' (Should resemble)!") + fail(t, so(2, ShouldResemble, 1), "1|2|Expected: '1' Actual: '2' (Should resemble)!") - this.fail(so(StringStringMapAlias{"hi": "bye"}, ShouldResemble, map[string]string{"hi": "bye"}), - `map[hi:bye]|map[hi:bye]|Expected: 'map[string]string{"hi":"bye"}' Actual: 'assertions.StringStringMapAlias{"hi":"bye"}' (Should resemble)!`) - this.fail(so(StringSliceAlias{"hi", "bye"}, ShouldResemble, []string{"hi", "bye"}), - `[hi bye]|[hi bye]|Expected: '[]string{"hi", "bye"}' Actual: 'assertions.StringSliceAlias{"hi", "bye"}' (Should resemble)!`) + fail(t, so(StringStringMapAlias{"hi": "bye"}, ShouldResemble, map[string]string{"hi": "bye"}), + "map[hi:bye]|map[hi:bye]|Expected: 'map[string]string{\"hi\":\"bye\"}' Actual: 'assertions.StringStringMapAlias{\"hi\":\"bye\"}' (Should resemble)!") + fail(t, so(StringSliceAlias{"hi", "bye"}, ShouldResemble, []string{"hi", "bye"}), + "[hi bye]|[hi bye]|Expected: '[]string{\"hi\", \"bye\"}' Actual: 'assertions.StringSliceAlias{\"hi\", \"bye\"}' (Should resemble)!") // some types come out looking the same when represented with "%#v" so we show type mismatch info: - this.fail(so(StringAlias("hi"), ShouldResemble, "hi"), `hi|hi|Expected: '"hi"' Actual: 'assertions.StringAlias("hi")' (Should resemble)!`) - this.fail(so(IntAlias(42), ShouldResemble, 42), `42|42|Expected: '42' Actual: 'assertions.IntAlias(42)' (Should resemble)!`) + fail(t, so(StringAlias("hi"), ShouldResemble, "hi"), "hi|hi|Expected: '\"hi\"' (string) Actual: '\"hi\"' (assertions.StringAlias) (Should resemble, type mismatch)") + fail(t, so(IntAlias(42), ShouldResemble, 42), "42|42|Expected: '42' (int) Actual: '42' (assertions.IntAlias) (Should resemble, type mismatch)") } -func (this *AssertionsFixture) TestShouldNotResemble() { - this.fail(so(Thing1{"hi"}, ShouldNotResemble), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(Thing1{"hi"}, ShouldNotResemble, Thing1{"hi"}, Thing1{"hi"}), "This assertion requires exactly 1 comparison values (you provided 2).") +func TestShouldNotResemble(t *testing.T) { + fail(t, so(Thing1{"hi"}, ShouldNotResemble), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(Thing1{"hi"}, ShouldNotResemble, Thing1{"hi"}, Thing1{"hi"}), "This assertion requires exactly 1 comparison values (you provided 2).") - this.pass(so(Thing1{"hi"}, ShouldNotResemble, Thing1{"bye"})) - this.fail(so(Thing1{"hi"}, ShouldNotResemble, Thing1{"hi"}), - `Expected '"assertions.Thing1{a:\"hi\"}"' to NOT resemble '"assertions.Thing1{a:\"hi\"}"' (but it did)!`) + pass(t, so(Thing1{"hi"}, ShouldNotResemble, Thing1{"bye"})) + fail(t, so(Thing1{"hi"}, ShouldNotResemble, Thing1{"hi"}), + "Expected 'assertions.Thing1{a:\"hi\"}' to NOT resemble 'assertions.Thing1{a:\"hi\"}' (but it did)!") - this.pass(so(map[string]string{"hi": "bye"}, ShouldResemble, map[string]string{"hi": "bye"})) - this.pass(so(IntAlias(42), ShouldNotResemble, 42)) + pass(t, so(map[string]string{"hi": "bye"}, ShouldResemble, map[string]string{"hi": "bye"})) + pass(t, so(IntAlias(42), ShouldNotResemble, 42)) - this.pass(so(StringSliceAlias{"hi", "bye"}, ShouldNotResemble, []string{"hi", "bye"})) + pass(t, so(StringSliceAlias{"hi", "bye"}, ShouldNotResemble, []string{"hi", "bye"})) } -func (this *AssertionsFixture) TestShouldPointTo() { +func TestShouldPointTo(t *testing.T) { + serializer = newFakeSerializer() + t1 := &Thing1{} t2 := t1 t3 := &Thing1{} @@ -177,119 +149,121 @@ func (this *AssertionsFixture) TestShouldPointTo() { pointer1 := reflect.ValueOf(t1).Pointer() pointer3 := reflect.ValueOf(t3).Pointer() - this.fail(so(t1, ShouldPointTo), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(t1, ShouldPointTo, t2, t3), "This assertion requires exactly 1 comparison values (you provided 2).") + fail(t, so(t1, ShouldPointTo), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(t1, ShouldPointTo, t2, t3), "This assertion requires exactly 1 comparison values (you provided 2).") - this.pass(so(t1, ShouldPointTo, t2)) - this.fail(so(t1, ShouldPointTo, t3), fmt.Sprintf( + pass(t, so(t1, ShouldPointTo, t2)) + fail(t, so(t1, ShouldPointTo, t3), fmt.Sprintf( "%v|%v|Expected '&{a:}' (address: '%v') and '&{a:}' (address: '%v') to be the same address (but their weren't)!", pointer3, pointer1, pointer1, pointer3)) t4 := Thing1{} t5 := t4 - this.fail(so(t4, ShouldPointTo, t5), "Both arguments should be pointers (the first was not)!") - this.fail(so(&t4, ShouldPointTo, t5), "Both arguments should be pointers (the second was not)!") - this.fail(so(nil, ShouldPointTo, nil), "Both arguments should be pointers (the first was nil)!") - this.fail(so(&t4, ShouldPointTo, nil), "Both arguments should be pointers (the second was nil)!") + fail(t, so(t4, ShouldPointTo, t5), "Both arguments should be pointers (the first was not)!") + fail(t, so(&t4, ShouldPointTo, t5), "Both arguments should be pointers (the second was not)!") + fail(t, so(nil, ShouldPointTo, nil), "Both arguments should be pointers (the first was nil)!") + fail(t, so(&t4, ShouldPointTo, nil), "Both arguments should be pointers (the second was nil)!") } -func (this *AssertionsFixture) TestShouldNotPointTo() { +func TestShouldNotPointTo(t *testing.T) { t1 := &Thing1{} t2 := t1 t3 := &Thing1{} pointer1 := reflect.ValueOf(t1).Pointer() - this.fail(so(t1, ShouldNotPointTo), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(t1, ShouldNotPointTo, t2, t3), "This assertion requires exactly 1 comparison values (you provided 2).") + fail(t, so(t1, ShouldNotPointTo), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(t1, ShouldNotPointTo, t2, t3), "This assertion requires exactly 1 comparison values (you provided 2).") - this.pass(so(t1, ShouldNotPointTo, t3)) - this.fail(so(t1, ShouldNotPointTo, t2), fmt.Sprintf("Expected '&{a:}' and '&{a:}' to be different references (but they matched: '%v')!", pointer1)) + pass(t, so(t1, ShouldNotPointTo, t3)) + fail(t, so(t1, ShouldNotPointTo, t2), fmt.Sprintf("Expected '&{a:}' and '&{a:}' to be different references (but they matched: '%v')!", pointer1)) t4 := Thing1{} t5 := t4 - this.fail(so(t4, ShouldNotPointTo, t5), "Both arguments should be pointers (the first was not)!") - this.fail(so(&t4, ShouldNotPointTo, t5), "Both arguments should be pointers (the second was not)!") - this.fail(so(nil, ShouldNotPointTo, nil), "Both arguments should be pointers (the first was nil)!") - this.fail(so(&t4, ShouldNotPointTo, nil), "Both arguments should be pointers (the second was nil)!") + fail(t, so(t4, ShouldNotPointTo, t5), "Both arguments should be pointers (the first was not)!") + fail(t, so(&t4, ShouldNotPointTo, t5), "Both arguments should be pointers (the second was not)!") + fail(t, so(nil, ShouldNotPointTo, nil), "Both arguments should be pointers (the first was nil)!") + fail(t, so(&t4, ShouldNotPointTo, nil), "Both arguments should be pointers (the second was nil)!") } -func (this *AssertionsFixture) TestShouldBeNil() { - this.fail(so(nil, ShouldBeNil, nil, nil, nil), "This assertion requires exactly 0 comparison values (you provided 3).") - this.fail(so(nil, ShouldBeNil, nil), "This assertion requires exactly 0 comparison values (you provided 1).") +func TestShouldBeNil(t *testing.T) { + fail(t, so(nil, ShouldBeNil, nil, nil, nil), "This assertion requires exactly 0 comparison values (you provided 3).") + fail(t, so(nil, ShouldBeNil, nil), "This assertion requires exactly 0 comparison values (you provided 1).") - this.pass(so(nil, ShouldBeNil)) - this.fail(so(1, ShouldBeNil), "Expected: nil Actual: '1'") + pass(t, so(nil, ShouldBeNil)) + fail(t, so(1, ShouldBeNil), "Expected: nil Actual: '1'") - var thing ThingInterface - this.pass(so(thing, ShouldBeNil)) - thing = &ThingImplementation{} - this.fail(so(thing, ShouldBeNil), "Expected: nil Actual: '&{}'") + var thing Thinger + pass(t, so(thing, ShouldBeNil)) + thing = &Thing{} + fail(t, so(thing, ShouldBeNil), "Expected: nil Actual: '&{}'") var thingOne *Thing1 - this.pass(so(thingOne, ShouldBeNil)) + pass(t, so(thingOne, ShouldBeNil)) var nilSlice []int = nil - this.pass(so(nilSlice, ShouldBeNil)) + pass(t, so(nilSlice, ShouldBeNil)) var nilMap map[string]string = nil - this.pass(so(nilMap, ShouldBeNil)) + pass(t, so(nilMap, ShouldBeNil)) var nilChannel chan int = nil - this.pass(so(nilChannel, ShouldBeNil)) + pass(t, so(nilChannel, ShouldBeNil)) var nilFunc func() = nil - this.pass(so(nilFunc, ShouldBeNil)) + pass(t, so(nilFunc, ShouldBeNil)) var nilInterface interface{} = nil - this.pass(so(nilInterface, ShouldBeNil)) + pass(t, so(nilInterface, ShouldBeNil)) } -func (this *AssertionsFixture) TestShouldNotBeNil() { - this.fail(so(nil, ShouldNotBeNil, nil, nil, nil), "This assertion requires exactly 0 comparison values (you provided 3).") - this.fail(so(nil, ShouldNotBeNil, nil), "This assertion requires exactly 0 comparison values (you provided 1).") +func TestShouldNotBeNil(t *testing.T) { + fail(t, so(nil, ShouldNotBeNil, nil, nil, nil), "This assertion requires exactly 0 comparison values (you provided 3).") + fail(t, so(nil, ShouldNotBeNil, nil), "This assertion requires exactly 0 comparison values (you provided 1).") - this.fail(so(nil, ShouldNotBeNil), "Expected '' to NOT be nil (but it was)!") - this.pass(so(1, ShouldNotBeNil)) + fail(t, so(nil, ShouldNotBeNil), "Expected '' to NOT be nil (but it was)!") + pass(t, so(1, ShouldNotBeNil)) - var thing ThingInterface - this.fail(so(thing, ShouldNotBeNil), "Expected '' to NOT be nil (but it was)!") - thing = &ThingImplementation{} - this.pass(so(thing, ShouldNotBeNil)) + var thing Thinger + fail(t, so(thing, ShouldNotBeNil), "Expected '' to NOT be nil (but it was)!") + thing = &Thing{} + pass(t, so(thing, ShouldNotBeNil)) } -func (this *AssertionsFixture) TestShouldBeTrue() { - this.fail(so(true, ShouldBeTrue, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") - this.fail(so(true, ShouldBeTrue, 1), "This assertion requires exactly 0 comparison values (you provided 1).") +func TestShouldBeTrue(t *testing.T) { + fail(t, so(true, ShouldBeTrue, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") + fail(t, so(true, ShouldBeTrue, 1), "This assertion requires exactly 0 comparison values (you provided 1).") - this.fail(so(false, ShouldBeTrue), "Expected: true Actual: false") - this.fail(so(1, ShouldBeTrue), "Expected: true Actual: 1") - this.pass(so(true, ShouldBeTrue)) + fail(t, so(false, ShouldBeTrue), "Expected: true Actual: false") + fail(t, so(1, ShouldBeTrue), "Expected: true Actual: 1") + pass(t, so(true, ShouldBeTrue)) } -func (this *AssertionsFixture) TestShouldBeFalse() { - this.fail(so(false, ShouldBeFalse, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") - this.fail(so(false, ShouldBeFalse, 1), "This assertion requires exactly 0 comparison values (you provided 1).") +func TestShouldBeFalse(t *testing.T) { + fail(t, so(false, ShouldBeFalse, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") + fail(t, so(false, ShouldBeFalse, 1), "This assertion requires exactly 0 comparison values (you provided 1).") - this.fail(so(true, ShouldBeFalse), "Expected: false Actual: true") - this.fail(so(1, ShouldBeFalse), "Expected: false Actual: 1") - this.pass(so(false, ShouldBeFalse)) + fail(t, so(true, ShouldBeFalse), "Expected: false Actual: true") + fail(t, so(1, ShouldBeFalse), "Expected: false Actual: 1") + pass(t, so(false, ShouldBeFalse)) } -func (this *AssertionsFixture) TestShouldBeZeroValue() { - this.fail(so(0, ShouldBeZeroValue, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") - this.fail(so(false, ShouldBeZeroValue, true), "This assertion requires exactly 0 comparison values (you provided 1).") - - this.fail(so(1, ShouldBeZeroValue), "0|1|'1' should have been the zero value") //"Expected: (zero value) Actual: 1") - this.fail(so(true, ShouldBeZeroValue), "false|true|'true' should have been the zero value") //"Expected: (zero value) Actual: true") - this.fail(so("123", ShouldBeZeroValue), "|123|'123' should have been the zero value") //"Expected: (zero value) Actual: 123") - this.fail(so(" ", ShouldBeZeroValue), "| |' ' should have been the zero value") //"Expected: (zero value) Actual: ") - this.fail(so([]string{"Nonempty"}, ShouldBeZeroValue), "[]|[Nonempty]|'[Nonempty]' should have been the zero value") //"Expected: (zero value) Actual: [Nonempty]") - this.fail(so(struct{ a string }{a: "asdf"}, ShouldBeZeroValue), "{}|{asdf}|'{a:asdf}' should have been the zero value") - this.pass(so(0, ShouldBeZeroValue)) - this.pass(so(false, ShouldBeZeroValue)) - this.pass(so("", ShouldBeZeroValue)) - this.pass(so(struct{}{}, ShouldBeZeroValue)) +func TestShouldBeZeroValue(t *testing.T) { + serializer = newFakeSerializer() + + fail(t, so(0, ShouldBeZeroValue, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") + fail(t, so(false, ShouldBeZeroValue, true), "This assertion requires exactly 0 comparison values (you provided 1).") + + fail(t, so(1, ShouldBeZeroValue), "0|1|'1' should have been the zero value") //"Expected: (zero value) Actual: 1") + fail(t, so(true, ShouldBeZeroValue), "false|true|'true' should have been the zero value") //"Expected: (zero value) Actual: true") + fail(t, so("123", ShouldBeZeroValue), "|123|'123' should have been the zero value") //"Expected: (zero value) Actual: 123") + fail(t, so(" ", ShouldBeZeroValue), "| |' ' should have been the zero value") //"Expected: (zero value) Actual: ") + fail(t, so([]string{"Nonempty"}, ShouldBeZeroValue), "[]|[Nonempty]|'[Nonempty]' should have been the zero value") //"Expected: (zero value) Actual: [Nonempty]") + fail(t, so(struct{ a string }{a: "asdf"}, ShouldBeZeroValue), "{}|{asdf}|'{a:asdf}' should have been the zero value") + pass(t, so(0, ShouldBeZeroValue)) + pass(t, so(false, ShouldBeZeroValue)) + pass(t, so("", ShouldBeZeroValue)) + pass(t, so(struct{}{}, ShouldBeZeroValue)) } diff --git a/vendor/github.com/smartystreets/assertions/filter.go b/vendor/github.com/smartystreets/assertions/filter.go index 7c46ab8e3..ee368a97e 100644 --- a/vendor/github.com/smartystreets/assertions/filter.go +++ b/vendor/github.com/smartystreets/assertions/filter.go @@ -6,7 +6,6 @@ const ( success = "" needExactValues = "This assertion requires exactly %d comparison values (you provided %d)." needNonEmptyCollection = "This assertion requires at least 1 comparison value (you provided 0)." - needFewerValues = "This assertion allows %d or fewer comparison values (you provided %d)." ) func need(needed int, expected []interface{}) string { @@ -22,10 +21,3 @@ func atLeast(minimum int, expected []interface{}) string { } return success } - -func atMost(max int, expected []interface{}) string { - if len(expected) > max { - return fmt.Sprintf(needFewerValues, max, len(expected)) - } - return success -} diff --git a/vendor/github.com/smartystreets/assertions/internal/Makefile b/vendor/github.com/smartystreets/assertions/internal/Makefile index be7dec553..714768027 100644 --- a/vendor/github.com/smartystreets/assertions/internal/Makefile +++ b/vendor/github.com/smartystreets/assertions/internal/Makefile @@ -1,37 +1,21 @@ # This Makefile pulls the latest oglematchers (with dependencies), # rewrites the imports to match this location, # and ensures that all the tests pass. -# BTW, things used from oglematchers: Contains, Equals, DeepEquals, GreaterThan, LessThan, GreaterOrEqual, LessOrEqual -test: - go test github.com/smartystreets/assertions/... - -update: clear clone rewrite trim +go: clean clone rewrite test -clear: +clean: rm -rf ogle* rm -rf reqtrace - rm -rf go-render clone: + git clone https://github.com/jacobsa/ogletest.git && rm -rf ogletest/.git + git clone https://github.com/jacobsa/oglemock.git && rm -rf oglemock/.git git clone https://github.com/jacobsa/oglematchers.git && rm -rf oglematchers/.git - git clone https://github.com/luci/go-render.git && rm -rf go-render/.git + git clone https://github.com/jacobsa/reqtrace.git && rm -rf reqtrace/.git rewrite: grep -rl --exclude Makefile 'github.com/jacobsa' . | xargs sed -i '' 's#github.com/jacobsa#github.com/smartystreets/assertions/internal#g' -trim: - git checkout oglematchers/contains.go # This file diverged at 6acd0337 - rm oglematchers/*_test.go - rm oglematchers/any.go - rm oglematchers/all_of.go - rm oglematchers/elements_are.go - rm oglematchers/error.go - rm oglematchers/has_same_type_as.go - rm oglematchers/has_substr.go - rm oglematchers/identical_to.go - rm oglematchers/matches_regexp.go - rm oglematchers/new_matcher.go - rm oglematchers/panics.go - rm oglematchers/pointee.go - rm go-render/render/*_test.go +test: + go test github.com/smartystreets/assertions/... diff --git a/vendor/github.com/smartystreets/assertions/internal/go-render/.travis.yml b/vendor/github.com/smartystreets/assertions/internal/go-render/.travis.yml deleted file mode 100644 index 5a19a5faf..000000000 --- a/vendor/github.com/smartystreets/assertions/internal/go-render/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2015 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# {sudo: required, dist: trusty} is the magic incantation to pick the trusty -# beta environment, which is the only environment we can get that has >4GB -# memory. Currently the `go test -race` tests that we run will peak at just -# over 4GB, which results in everything getting OOM-killed. -sudo: required -dist: trusty - -language: go - -go: -- 1.4.2 - -before_install: - - go get github.com/maruel/pre-commit-go/cmd/pcg - -script: - - pcg diff --git a/vendor/github.com/smartystreets/assertions/internal/go-render/LICENSE b/vendor/github.com/smartystreets/assertions/internal/go-render/LICENSE deleted file mode 100644 index 6280ff0e0..000000000 --- a/vendor/github.com/smartystreets/assertions/internal/go-render/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2015 The Chromium Authors. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/smartystreets/assertions/internal/go-render/PRESUBMIT.py b/vendor/github.com/smartystreets/assertions/internal/go-render/PRESUBMIT.py deleted file mode 100644 index d05f0cd87..000000000 --- a/vendor/github.com/smartystreets/assertions/internal/go-render/PRESUBMIT.py +++ /dev/null @@ -1,109 +0,0 @@ -# Copyright 2015 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Top-level presubmit script. - -See https://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for -details on the presubmit API built into depot_tools. -""" - -import os -import sys - - -def PreCommitGo(input_api, output_api, pcg_mode): - """Run go-specific checks via pre-commit-go (pcg) if it's in PATH.""" - if input_api.is_committing: - error_type = output_api.PresubmitError - else: - error_type = output_api.PresubmitPromptWarning - - exe = 'pcg.exe' if sys.platform == 'win32' else 'pcg' - pcg = None - for p in os.environ['PATH'].split(os.pathsep): - pcg = os.path.join(p, exe) - if os.access(pcg, os.X_OK): - break - else: - return [ - error_type( - 'pre-commit-go executable (pcg) could not be found in PATH. All Go ' - 'checks are skipped. See https://github.com/maruel/pre-commit-go.') - ] - - cmd = [pcg, 'run', '-m', ','.join(pcg_mode)] - if input_api.verbose: - cmd.append('-v') - # pcg can figure out what files to check on its own based on upstream ref, - # but on PRESUBMIT try builder upsteram isn't set, and it's just 1 commit. - if os.getenv('PRESUBMIT_BUILDER', ''): - cmd.extend(['-r', 'HEAD~1']) - return input_api.RunTests([ - input_api.Command( - name='pre-commit-go: %s' % ', '.join(pcg_mode), - cmd=cmd, - kwargs={}, - message=error_type), - ]) - - -def header(input_api): - """Returns the expected license header regexp for this project.""" - current_year = int(input_api.time.strftime('%Y')) - allowed_years = (str(s) for s in reversed(xrange(2011, current_year + 1))) - years_re = '(' + '|'.join(allowed_years) + ')' - license_header = ( - r'.*? Copyright %(year)s The Chromium Authors\. ' - r'All rights reserved\.\n' - r'.*? Use of this source code is governed by a BSD-style license ' - r'that can be\n' - r'.*? found in the LICENSE file\.(?: \*/)?\n' - ) % { - 'year': years_re, - } - return license_header - - -def source_file_filter(input_api): - """Returns filter that selects source code files only.""" - bl = list(input_api.DEFAULT_BLACK_LIST) + [ - r'.+\.pb\.go$', - r'.+_string\.go$', - ] - wl = list(input_api.DEFAULT_WHITE_LIST) + [ - r'.+\.go$', - ] - return lambda x: input_api.FilterSourceFile(x, white_list=wl, black_list=bl) - - -def CommonChecks(input_api, output_api): - results = [] - results.extend( - input_api.canned_checks.CheckChangeHasNoStrayWhitespace( - input_api, output_api, - source_file_filter=source_file_filter(input_api))) - results.extend( - input_api.canned_checks.CheckLicense( - input_api, output_api, header(input_api), - source_file_filter=source_file_filter(input_api))) - return results - - -def CheckChangeOnUpload(input_api, output_api): - results = CommonChecks(input_api, output_api) - results.extend(PreCommitGo(input_api, output_api, ['lint', 'pre-commit'])) - return results - - -def CheckChangeOnCommit(input_api, output_api): - results = CommonChecks(input_api, output_api) - results.extend(input_api.canned_checks.CheckChangeHasDescription( - input_api, output_api)) - results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( - input_api, output_api)) - results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( - input_api, output_api)) - results.extend(PreCommitGo( - input_api, output_api, ['continuous-integration'])) - return results diff --git a/vendor/github.com/smartystreets/assertions/internal/go-render/README.md b/vendor/github.com/smartystreets/assertions/internal/go-render/README.md deleted file mode 100644 index a85380c42..000000000 --- a/vendor/github.com/smartystreets/assertions/internal/go-render/README.md +++ /dev/null @@ -1,78 +0,0 @@ -go-render: A verbose recursive Go type-to-string conversion library. -==================================================================== - -[![GoDoc](https://godoc.org/github.com/luci/go-render?status.svg)](https://godoc.org/github.com/luci/go-render) -[![Build Status](https://travis-ci.org/luci/go-render.svg)](https://travis-ci.org/luci/go-render) - -This is not an official Google product. - -## Overview - -The *render* package implements a more verbose form of the standard Go string -formatter, `fmt.Sprintf("%#v", value)`, adding: - - Pointer recursion. Normally, Go stops at the first pointer and prints its - address. The *render* package will recurse and continue to render pointer - values. - - Recursion loop detection. Recursion is nice, but if a recursion path detects - a loop, *render* will note this and move on. - - Custom type name rendering. - - Deterministic key sorting for `string`- and `int`-keyed maps. - - Testing! - -Call `render.Render` and pass it an `interface{}`. - -For example: - -```Go -type customType int -type testStruct struct { - S string - V *map[string]int - I interface{} -} - -a := testStruct{ - S: "hello", - V: &map[string]int{"foo": 0, "bar": 1}, - I: customType(42), -} - -fmt.Println("Render test:") -fmt.Printf("fmt.Printf: %#v\n", a))) -fmt.Printf("render.Render: %s\n", Render(a)) -``` - -Yields: -``` -fmt.Printf: render.testStruct{S:"hello", V:(*map[string]int)(0x600dd065), I:42} -render.Render: render.testStruct{S:"hello", V:(*map[string]int){"bar":1, "foo":0}, I:render.customType(42)} -``` - -This is not intended to be a high-performance library, but it's not terrible -either. - -Contributing ------------- - - * Sign the [Google CLA](https://cla.developers.google.com/clas). - * Make sure your `user.email` and `user.name` are configured in `git config`. - * Install the [pcg](https://github.com/maruel/pre-commit-go) git hook: - `go get -u github.com/maruel/pre-commit-go/cmd/... && pcg` - -Run the following to setup the code review tool and create your first review: - - git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $HOME/src/depot_tools - export PATH="$PATH:$HOME/src/depot_tools" - cd $GOROOT/github.com/luci/go-render - git checkout -b work origin/master - - # hack hack - - git commit -a -m "This is awesome\nR=joe@example.com" - # This will ask for your Google Account credentials. - git cl upload -s - # Wait for LGTM over email. - # Check the commit queue box in codereview website. - # Wait for the change to be tested and landed automatically. - -Use `git cl help` and `git cl help ` for more details. diff --git a/vendor/github.com/smartystreets/assertions/internal/go-render/WATCHLISTS b/vendor/github.com/smartystreets/assertions/internal/go-render/WATCHLISTS deleted file mode 100644 index e4172088d..000000000 --- a/vendor/github.com/smartystreets/assertions/internal/go-render/WATCHLISTS +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2015 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Watchlist Rules -# Refer: http://dev.chromium.org/developers/contributing-code/watchlists - -{ - - 'WATCHLIST_DEFINITIONS': { - 'all': { - 'filepath': '.+', - }, - }, - - 'WATCHLISTS': { - 'all': [ - # Add yourself here to get explicitly spammed. - 'maruel@chromium.org', - 'tandrii+luci-go@chromium.org', - 'todd@cloudera.com', - 'andrew.wang@cloudera.com', - ], - }, - -} diff --git a/vendor/github.com/smartystreets/assertions/internal/go-render/pre-commit-go.yml b/vendor/github.com/smartystreets/assertions/internal/go-render/pre-commit-go.yml deleted file mode 100644 index 074ee1f84..000000000 --- a/vendor/github.com/smartystreets/assertions/internal/go-render/pre-commit-go.yml +++ /dev/null @@ -1,78 +0,0 @@ -# https://github.com/maruel/pre-commit-go configuration file to run checks -# automatically on commit, on push and on continuous integration service after -# a push or on merge of a pull request. -# -# See https://godoc.org/github.com/maruel/pre-commit-go/checks for more -# information. - -min_version: 0.4.7 -modes: - continuous-integration: - checks: - build: - - build_all: false - extra_args: [] - coverage: - - use_global_inference: false - use_coveralls: true - global: - min_coverage: 50 - max_coverage: 100 - per_dir_default: - min_coverage: 1 - max_coverage: 100 - per_dir: {} - gofmt: - - {} - goimports: - - {} - test: - - extra_args: - - -v - - -race - max_duration: 600 - lint: - checks: - golint: - - blacklist: [] - govet: - - blacklist: - - ' composite literal uses unkeyed fields' - max_duration: 15 - pre-commit: - checks: - build: - - build_all: false - extra_args: [] - gofmt: - - {} - test: - - extra_args: - - -short - max_duration: 35 - pre-push: - checks: - coverage: - - use_global_inference: false - use_coveralls: false - global: - min_coverage: 50 - max_coverage: 100 - per_dir_default: - min_coverage: 1 - max_coverage: 100 - per_dir: {} - goimports: - - {} - test: - - extra_args: - - -v - - -race - max_duration: 35 - -ignore_patterns: -- .* -- _* -- '*.pb.go' -- '*_string.go' -- '*-gen.go' diff --git a/vendor/github.com/smartystreets/assertions/internal/go-render/render/render.go b/vendor/github.com/smartystreets/assertions/internal/go-render/render/render.go deleted file mode 100644 index 23b7a5867..000000000 --- a/vendor/github.com/smartystreets/assertions/internal/go-render/render/render.go +++ /dev/null @@ -1,477 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package render - -import ( - "bytes" - "fmt" - "reflect" - "sort" - "strconv" -) - -var builtinTypeMap = map[reflect.Kind]string{ - reflect.Bool: "bool", - reflect.Complex128: "complex128", - reflect.Complex64: "complex64", - reflect.Float32: "float32", - reflect.Float64: "float64", - reflect.Int16: "int16", - reflect.Int32: "int32", - reflect.Int64: "int64", - reflect.Int8: "int8", - reflect.Int: "int", - reflect.String: "string", - reflect.Uint16: "uint16", - reflect.Uint32: "uint32", - reflect.Uint64: "uint64", - reflect.Uint8: "uint8", - reflect.Uint: "uint", - reflect.Uintptr: "uintptr", -} - -var builtinTypeSet = map[string]struct{}{} - -func init() { - for _, v := range builtinTypeMap { - builtinTypeSet[v] = struct{}{} - } -} - -var typeOfString = reflect.TypeOf("") -var typeOfInt = reflect.TypeOf(int(1)) -var typeOfUint = reflect.TypeOf(uint(1)) -var typeOfFloat = reflect.TypeOf(10.1) - -// Render converts a structure to a string representation. Unline the "%#v" -// format string, this resolves pointer types' contents in structs, maps, and -// slices/arrays and prints their field values. -func Render(v interface{}) string { - buf := bytes.Buffer{} - s := (*traverseState)(nil) - s.render(&buf, 0, reflect.ValueOf(v), false) - return buf.String() -} - -// renderPointer is called to render a pointer value. -// -// This is overridable so that the test suite can have deterministic pointer -// values in its expectations. -var renderPointer = func(buf *bytes.Buffer, p uintptr) { - fmt.Fprintf(buf, "0x%016x", p) -} - -// traverseState is used to note and avoid recursion as struct members are being -// traversed. -// -// traverseState is allowed to be nil. Specifically, the root state is nil. -type traverseState struct { - parent *traverseState - ptr uintptr -} - -func (s *traverseState) forkFor(ptr uintptr) *traverseState { - for cur := s; cur != nil; cur = cur.parent { - if ptr == cur.ptr { - return nil - } - } - - fs := &traverseState{ - parent: s, - ptr: ptr, - } - return fs -} - -func (s *traverseState) render(buf *bytes.Buffer, ptrs int, v reflect.Value, implicit bool) { - if v.Kind() == reflect.Invalid { - buf.WriteString("nil") - return - } - vt := v.Type() - - // If the type being rendered is a potentially recursive type (a type that - // can contain itself as a member), we need to avoid recursion. - // - // If we've already seen this type before, mark that this is the case and - // write a recursion placeholder instead of actually rendering it. - // - // If we haven't seen it before, fork our `seen` tracking so any higher-up - // renderers will also render it at least once, then mark that we've seen it - // to avoid recursing on lower layers. - pe := uintptr(0) - vk := vt.Kind() - switch vk { - case reflect.Ptr: - // Since structs and arrays aren't pointers, they can't directly be - // recursed, but they can contain pointers to themselves. Record their - // pointer to avoid this. - switch v.Elem().Kind() { - case reflect.Struct, reflect.Array: - pe = v.Pointer() - } - - case reflect.Slice, reflect.Map: - pe = v.Pointer() - } - if pe != 0 { - s = s.forkFor(pe) - if s == nil { - buf.WriteString("") - return - } - } - - isAnon := func(t reflect.Type) bool { - if t.Name() != "" { - if _, ok := builtinTypeSet[t.Name()]; !ok { - return false - } - } - return t.Kind() != reflect.Interface - } - - switch vk { - case reflect.Struct: - if !implicit { - writeType(buf, ptrs, vt) - } - structAnon := vt.Name() == "" - buf.WriteRune('{') - for i := 0; i < vt.NumField(); i++ { - if i > 0 { - buf.WriteString(", ") - } - anon := structAnon && isAnon(vt.Field(i).Type) - - if !anon { - buf.WriteString(vt.Field(i).Name) - buf.WriteRune(':') - } - - s.render(buf, 0, v.Field(i), anon) - } - buf.WriteRune('}') - - case reflect.Slice: - if v.IsNil() { - if !implicit { - writeType(buf, ptrs, vt) - buf.WriteString("(nil)") - } else { - buf.WriteString("nil") - } - return - } - fallthrough - - case reflect.Array: - if !implicit { - writeType(buf, ptrs, vt) - } - anon := vt.Name() == "" && isAnon(vt.Elem()) - buf.WriteString("{") - for i := 0; i < v.Len(); i++ { - if i > 0 { - buf.WriteString(", ") - } - - s.render(buf, 0, v.Index(i), anon) - } - buf.WriteRune('}') - - case reflect.Map: - if !implicit { - writeType(buf, ptrs, vt) - } - if v.IsNil() { - buf.WriteString("(nil)") - } else { - buf.WriteString("{") - - mkeys := v.MapKeys() - tryAndSortMapKeys(vt, mkeys) - - kt := vt.Key() - keyAnon := typeOfString.ConvertibleTo(kt) || typeOfInt.ConvertibleTo(kt) || typeOfUint.ConvertibleTo(kt) || typeOfFloat.ConvertibleTo(kt) - valAnon := vt.Name() == "" && isAnon(vt.Elem()) - for i, mk := range mkeys { - if i > 0 { - buf.WriteString(", ") - } - - s.render(buf, 0, mk, keyAnon) - buf.WriteString(":") - s.render(buf, 0, v.MapIndex(mk), valAnon) - } - buf.WriteRune('}') - } - - case reflect.Ptr: - ptrs++ - fallthrough - case reflect.Interface: - if v.IsNil() { - writeType(buf, ptrs, v.Type()) - buf.WriteString("(nil)") - } else { - s.render(buf, ptrs, v.Elem(), false) - } - - case reflect.Chan, reflect.Func, reflect.UnsafePointer: - writeType(buf, ptrs, vt) - buf.WriteRune('(') - renderPointer(buf, v.Pointer()) - buf.WriteRune(')') - - default: - tstr := vt.String() - implicit = implicit || (ptrs == 0 && builtinTypeMap[vk] == tstr) - if !implicit { - writeType(buf, ptrs, vt) - buf.WriteRune('(') - } - - switch vk { - case reflect.String: - fmt.Fprintf(buf, "%q", v.String()) - case reflect.Bool: - fmt.Fprintf(buf, "%v", v.Bool()) - - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - fmt.Fprintf(buf, "%d", v.Int()) - - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - fmt.Fprintf(buf, "%d", v.Uint()) - - case reflect.Float32, reflect.Float64: - fmt.Fprintf(buf, "%g", v.Float()) - - case reflect.Complex64, reflect.Complex128: - fmt.Fprintf(buf, "%g", v.Complex()) - } - - if !implicit { - buf.WriteRune(')') - } - } -} - -func writeType(buf *bytes.Buffer, ptrs int, t reflect.Type) { - parens := ptrs > 0 - switch t.Kind() { - case reflect.Chan, reflect.Func, reflect.UnsafePointer: - parens = true - } - - if parens { - buf.WriteRune('(') - for i := 0; i < ptrs; i++ { - buf.WriteRune('*') - } - } - - switch t.Kind() { - case reflect.Ptr: - if ptrs == 0 { - // This pointer was referenced from within writeType (e.g., as part of - // rendering a list), and so hasn't had its pointer asterisk accounted - // for. - buf.WriteRune('*') - } - writeType(buf, 0, t.Elem()) - - case reflect.Interface: - if n := t.Name(); n != "" { - buf.WriteString(t.String()) - } else { - buf.WriteString("interface{}") - } - - case reflect.Array: - buf.WriteRune('[') - buf.WriteString(strconv.FormatInt(int64(t.Len()), 10)) - buf.WriteRune(']') - writeType(buf, 0, t.Elem()) - - case reflect.Slice: - if t == reflect.SliceOf(t.Elem()) { - buf.WriteString("[]") - writeType(buf, 0, t.Elem()) - } else { - // Custom slice type, use type name. - buf.WriteString(t.String()) - } - - case reflect.Map: - if t == reflect.MapOf(t.Key(), t.Elem()) { - buf.WriteString("map[") - writeType(buf, 0, t.Key()) - buf.WriteRune(']') - writeType(buf, 0, t.Elem()) - } else { - // Custom map type, use type name. - buf.WriteString(t.String()) - } - - default: - buf.WriteString(t.String()) - } - - if parens { - buf.WriteRune(')') - } -} - -type cmpFn func(a, b reflect.Value) int - -type sortableValueSlice struct { - cmp cmpFn - elements []reflect.Value -} - -func (s sortableValueSlice) Len() int { - return len(s.elements) -} - -func (s sortableValueSlice) Less(i, j int) bool { - return s.cmp(s.elements[i], s.elements[j]) < 0 -} - -func (s sortableValueSlice) Swap(i, j int) { - s.elements[i], s.elements[j] = s.elements[j], s.elements[i] -} - -// cmpForType returns a cmpFn which sorts the data for some type t in the same -// order that a go-native map key is compared for equality. -func cmpForType(t reflect.Type) cmpFn { - switch t.Kind() { - case reflect.String: - return func(av, bv reflect.Value) int { - a, b := av.String(), bv.String() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Bool: - return func(av, bv reflect.Value) int { - a, b := av.Bool(), bv.Bool() - if !a && b { - return -1 - } else if a && !b { - return 1 - } - return 0 - } - - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return func(av, bv reflect.Value) int { - a, b := av.Int(), bv.Int() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, - reflect.Uint64, reflect.Uintptr, reflect.UnsafePointer: - return func(av, bv reflect.Value) int { - a, b := av.Uint(), bv.Uint() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Float32, reflect.Float64: - return func(av, bv reflect.Value) int { - a, b := av.Float(), bv.Float() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Interface: - return func(av, bv reflect.Value) int { - a, b := av.InterfaceData(), bv.InterfaceData() - if a[0] < b[0] { - return -1 - } else if a[0] > b[0] { - return 1 - } - if a[1] < b[1] { - return -1 - } else if a[1] > b[1] { - return 1 - } - return 0 - } - - case reflect.Complex64, reflect.Complex128: - return func(av, bv reflect.Value) int { - a, b := av.Complex(), bv.Complex() - if real(a) < real(b) { - return -1 - } else if real(a) > real(b) { - return 1 - } - if imag(a) < imag(b) { - return -1 - } else if imag(a) > imag(b) { - return 1 - } - return 0 - } - - case reflect.Ptr, reflect.Chan: - return func(av, bv reflect.Value) int { - a, b := av.Pointer(), bv.Pointer() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Struct: - cmpLst := make([]cmpFn, t.NumField()) - for i := range cmpLst { - cmpLst[i] = cmpForType(t.Field(i).Type) - } - return func(a, b reflect.Value) int { - for i, cmp := range cmpLst { - if rslt := cmp(a.Field(i), b.Field(i)); rslt != 0 { - return rslt - } - } - return 0 - } - } - - return nil -} - -func tryAndSortMapKeys(mt reflect.Type, k []reflect.Value) { - if cmp := cmpForType(mt.Key()); cmp != nil { - sort.Sort(sortableValueSlice{cmp, k}) - } -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of.go new file mode 100644 index 000000000..d93a97404 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of.go @@ -0,0 +1,70 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers + +import ( + "strings" +) + +// AllOf accepts a set of matchers S and returns a matcher that follows the +// algorithm below when considering a candidate c: +// +// 1. Return true if for every Matcher m in S, m matches c. +// +// 2. Otherwise, if there is a matcher m in S such that m returns a fatal +// error for c, return that matcher's error message. +// +// 3. Otherwise, return false with the error from some wrapped matcher. +// +// This is akin to a logical AND operation for matchers. +func AllOf(matchers ...Matcher) Matcher { + return &allOfMatcher{matchers} +} + +type allOfMatcher struct { + wrappedMatchers []Matcher +} + +func (m *allOfMatcher) Description() string { + // Special case: the empty set. + if len(m.wrappedMatchers) == 0 { + return "is anything" + } + + // Join the descriptions for the wrapped matchers. + wrappedDescs := make([]string, len(m.wrappedMatchers)) + for i, wrappedMatcher := range m.wrappedMatchers { + wrappedDescs[i] = wrappedMatcher.Description() + } + + return strings.Join(wrappedDescs, ", and ") +} + +func (m *allOfMatcher) Matches(c interface{}) (err error) { + for _, wrappedMatcher := range m.wrappedMatchers { + if wrappedErr := wrappedMatcher.Matches(c); wrappedErr != nil { + err = wrappedErr + + // If the error is fatal, return immediately with this error. + _, ok := wrappedErr.(*FatalError) + if ok { + return + } + } + } + + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of_test.go new file mode 100644 index 000000000..0f9d198fc --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of_test.go @@ -0,0 +1,110 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" + "errors" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type allOfFakeMatcher struct { + desc string + err error +} + +func (m *allOfFakeMatcher) Matches(c interface{}) error { + return m.err +} + +func (m *allOfFakeMatcher) Description() string { + return m.desc +} + +type AllOfTest struct { +} + +func init() { RegisterTestSuite(&AllOfTest{}) } + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *AllOfTest) DescriptionWithEmptySet() { + m := AllOf() + ExpectEq("is anything", m.Description()) +} + +func (t *AllOfTest) DescriptionWithOneMatcher() { + m := AllOf(&allOfFakeMatcher{"taco", errors.New("")}) + ExpectEq("taco", m.Description()) +} + +func (t *AllOfTest) DescriptionWithMultipleMatchers() { + m := AllOf( + &allOfFakeMatcher{"taco", errors.New("")}, + &allOfFakeMatcher{"burrito", errors.New("")}, + &allOfFakeMatcher{"enchilada", errors.New("")}) + + ExpectEq("taco, and burrito, and enchilada", m.Description()) +} + +func (t *AllOfTest) EmptySet() { + m := AllOf() + err := m.Matches(17) + + ExpectEq(nil, err) +} + +func (t *AllOfTest) OneMatcherReturnsFatalErrorAndSomeOthersFail() { + m := AllOf( + &allOfFakeMatcher{"", errors.New("")}, + &allOfFakeMatcher{"", NewFatalError("taco")}, + &allOfFakeMatcher{"", errors.New("")}, + &allOfFakeMatcher{"", nil}) + + err := m.Matches(17) + + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("taco"))) +} + +func (t *AllOfTest) OneMatcherReturnsNonFatalAndOthersSayTrue() { + m := AllOf( + &allOfFakeMatcher{"", nil}, + &allOfFakeMatcher{"", errors.New("taco")}, + &allOfFakeMatcher{"", nil}) + + err := m.Matches(17) + + ExpectFalse(isFatal(err)) + ExpectThat(err, Error(Equals("taco"))) +} + +func (t *AllOfTest) AllMatchersSayTrue() { + m := AllOf( + &allOfFakeMatcher{"", nil}, + &allOfFakeMatcher{"", nil}, + &allOfFakeMatcher{"", nil}) + + err := m.Matches(17) + + ExpectEq(nil, err) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/any.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/any.go new file mode 100644 index 000000000..f6991ec10 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/any.go @@ -0,0 +1,32 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers + +// Any returns a matcher that matches any value. +func Any() Matcher { + return &anyMatcher{} +} + +type anyMatcher struct { +} + +func (m *anyMatcher) Description() string { + return "is anything" +} + +func (m *anyMatcher) Matches(c interface{}) error { + return nil +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_of_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_of_test.go new file mode 100644 index 000000000..f0b502540 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_of_test.go @@ -0,0 +1,139 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "errors" + + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type fakeAnyOfMatcher struct { + desc string + err error +} + +func (m *fakeAnyOfMatcher) Matches(c interface{}) error { + return m.err +} + +func (m *fakeAnyOfMatcher) Description() string { + return m.desc +} + +type AnyOfTest struct { +} + +func init() { RegisterTestSuite(&AnyOfTest{}) } + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *AnyOfTest) EmptySet() { + matcher := AnyOf() + + err := matcher.Matches(0) + ExpectThat(err, Error(Equals(""))) +} + +func (t *AnyOfTest) OneTrue() { + matcher := AnyOf( + &fakeAnyOfMatcher{"", NewFatalError("foo")}, + 17, + &fakeAnyOfMatcher{"", errors.New("foo")}, + &fakeAnyOfMatcher{"", nil}, + &fakeAnyOfMatcher{"", errors.New("foo")}, + ) + + err := matcher.Matches(0) + ExpectEq(nil, err) +} + +func (t *AnyOfTest) OneEqual() { + matcher := AnyOf( + &fakeAnyOfMatcher{"", NewFatalError("foo")}, + &fakeAnyOfMatcher{"", errors.New("foo")}, + 13, + "taco", + 19, + &fakeAnyOfMatcher{"", errors.New("foo")}, + ) + + err := matcher.Matches("taco") + ExpectEq(nil, err) +} + +func (t *AnyOfTest) OneFatal() { + matcher := AnyOf( + &fakeAnyOfMatcher{"", errors.New("foo")}, + 17, + &fakeAnyOfMatcher{"", NewFatalError("taco")}, + &fakeAnyOfMatcher{"", errors.New("foo")}, + ) + + err := matcher.Matches(0) + ExpectThat(err, Error(Equals("taco"))) +} + +func (t *AnyOfTest) OneNil() { + var err error + matcher := AnyOf( + 13, + nil, + 19, + ) + + // No match + err = matcher.Matches(14) + ExpectNe(nil, err) + + // Match + err = matcher.Matches(nil) + ExpectEq(nil, err) +} + +func (t *AnyOfTest) AllFalseAndNotEqual() { + matcher := AnyOf( + &fakeAnyOfMatcher{"", errors.New("foo")}, + 17, + &fakeAnyOfMatcher{"", errors.New("foo")}, + 19, + ) + + err := matcher.Matches(0) + ExpectThat(err, Error(Equals(""))) +} + +func (t *AnyOfTest) DescriptionForEmptySet() { + matcher := AnyOf() + ExpectEq("or()", matcher.Description()) +} + +func (t *AnyOfTest) DescriptionForNonEmptySet() { + matcher := AnyOf( + &fakeAnyOfMatcher{"taco", nil}, + "burrito", + &fakeAnyOfMatcher{"enchilada", nil}, + ) + + ExpectEq("or(taco, burrito, enchilada)", matcher.Description()) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_test.go new file mode 100644 index 000000000..410cc1282 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_test.go @@ -0,0 +1,53 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type AnyTest struct { +} + +func init() { RegisterTestSuite(&AnyTest{}) } + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *AnyTest) Description() { + m := Any() + ExpectEq("is anything", m.Description()) +} + +func (t *AnyTest) Matches() { + var err error + m := Any() + + err = m.Matches(nil) + ExpectEq(nil, err) + + err = m.Matches(17) + ExpectEq(nil, err) + + err = m.Matches("taco") + ExpectEq(nil, err) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go index 87f107d39..2f326dbc5 100644 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go @@ -28,7 +28,7 @@ func Contains(x interface{}) Matcher { var ok bool if result.elementMatcher, ok = x.(Matcher); !ok { - result.elementMatcher = DeepEquals(x) + result.elementMatcher = Equals(x) } return &result diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains_test.go new file mode 100644 index 000000000..dfc981c14 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains_test.go @@ -0,0 +1,233 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type ContainsTest struct {} +func init() { RegisterTestSuite(&ContainsTest{}) } + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *ContainsTest) WrongTypeCandidates() { + m := Contains("") + ExpectEq("contains: ", m.Description()) + + var err error + + // Nil candidate + err = m.Matches(nil) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("array"))) + ExpectThat(err, Error(HasSubstr("slice"))) + + // String candidate + err = m.Matches("") + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("array"))) + ExpectThat(err, Error(HasSubstr("slice"))) + + // Map candidate + err = m.Matches(make(map[string]string)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("array"))) + ExpectThat(err, Error(HasSubstr("slice"))) +} + +func (t *ContainsTest) NilArgument() { + m := Contains(nil) + ExpectEq("contains: is nil", m.Description()) + + var c interface{} + var err error + + // Empty array of pointers + c = [...]*int{} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Empty slice of pointers + c = []*int{} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Non-empty array of integers + c = [...]int{17, 0, 19} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Non-empty slice of integers + c = []int{17, 0, 19} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Non-matching array of pointers + c = [...]*int{new(int), new(int)} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Non-matching slice of pointers + c = []*int{new(int), new(int)} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Matching array of pointers + c = [...]*int{new(int), nil, new(int)} + err = m.Matches(c) + ExpectEq(nil, err) + + // Matching slice of pointers + c = []*int{new(int), nil, new(int)} + err = m.Matches(c) + ExpectEq(nil, err) + + // Non-matching slice of pointers from matching array + someArray := [...]*int{new(int), nil, new(int)} + c = someArray[0:1] + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) +} + +func (t *ContainsTest) StringArgument() { + m := Contains("taco") + ExpectEq("contains: taco", m.Description()) + + var c interface{} + var err error + + // Non-matching array of strings + c = [...]string{"burrito", "enchilada"} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Non-matching slice of strings + c = []string{"burrito", "enchilada"} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Matching array of strings + c = [...]string{"burrito", "taco", "enchilada"} + err = m.Matches(c) + ExpectEq(nil, err) + + // Matching slice of strings + c = []string{"burrito", "taco", "enchilada"} + err = m.Matches(c) + ExpectEq(nil, err) + + // Non-matching slice of strings from matching array + someArray := [...]string{"burrito", "taco", "enchilada"} + c = someArray[0:1] + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) +} + +func (t *ContainsTest) IntegerArgument() { + m := Contains(int(17)) + ExpectEq("contains: 17", m.Description()) + + var c interface{} + var err error + + // Non-matching array of integers + c = [...]int{13, 19} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Non-matching slice of integers + c = []int{13, 19} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Matching array of integers + c = [...]int{13, 17, 19} + err = m.Matches(c) + ExpectEq(nil, err) + + // Matching slice of integers + c = []int{13, 17, 19} + err = m.Matches(c) + ExpectEq(nil, err) + + // Non-matching slice of integers from matching array + someArray := [...]int{13, 17, 19} + c = someArray[0:1] + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Non-matching array of floats + c = [...]float32{13, 17.5, 19} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Non-matching slice of floats + c = []float32{13, 17.5, 19} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Matching array of floats + c = [...]float32{13, 17, 19} + err = m.Matches(c) + ExpectEq(nil, err) + + // Matching slice of floats + c = []float32{13, 17, 19} + err = m.Matches(c) + ExpectEq(nil, err) +} + +func (t *ContainsTest) MatcherArgument() { + m := Contains(HasSubstr("ac")) + ExpectEq("contains: has substring \"ac\"", m.Description()) + + var c interface{} + var err error + + // Non-matching array of strings + c = [...]string{"burrito", "enchilada"} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Non-matching slice of strings + c = []string{"burrito", "enchilada"} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Matching array of strings + c = [...]string{"burrito", "taco", "enchilada"} + err = m.Matches(c) + ExpectEq(nil, err) + + // Matching slice of strings + c = []string{"burrito", "taco", "enchilada"} + err = m.Matches(c) + ExpectEq(nil, err) + + // Non-matching slice of strings from matching array + someArray := [...]string{"burrito", "taco", "enchilada"} + c = someArray[0:1] + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/deep_equals_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/deep_equals_test.go new file mode 100644 index 000000000..a28113aaa --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/deep_equals_test.go @@ -0,0 +1,343 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" + "bytes" + "testing" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type DeepEqualsTest struct {} +func init() { RegisterTestSuite(&DeepEqualsTest{}) } + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *DeepEqualsTest) WrongTypeCandidateWithScalarValue() { + var x int = 17 + m := DeepEquals(x) + + var err error + + // Nil candidate. + err = m.Matches(nil) + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr(""))) + + // Int alias candidate. + type intAlias int + err = m.Matches(intAlias(x)) + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr("intAlias"))) + + // String candidate. + err = m.Matches("taco") + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr("string"))) + + // Byte slice candidate. + err = m.Matches([]byte{}) + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr("[]uint8"))) + + // Other slice candidate. + err = m.Matches([]uint16{}) + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr("[]uint16"))) + + // Unsigned int candidate. + err = m.Matches(uint(17)) + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr("uint"))) +} + +func (t *DeepEqualsTest) WrongTypeCandidateWithByteSliceValue() { + x := []byte{} + m := DeepEquals(x) + + var err error + + // Nil candidate. + err = m.Matches(nil) + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr(""))) + + // String candidate. + err = m.Matches("taco") + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr("string"))) + + // Slice candidate with wrong value type. + err = m.Matches([]uint16{}) + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr("[]uint16"))) +} + +func (t *DeepEqualsTest) WrongTypeCandidateWithOtherSliceValue() { + x := []uint16{} + m := DeepEquals(x) + + var err error + + // Nil candidate. + err = m.Matches(nil) + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr(""))) + + // String candidate. + err = m.Matches("taco") + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr("string"))) + + // Byte slice candidate with wrong value type. + err = m.Matches([]byte{}) + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr("[]uint8"))) + + // Other slice candidate with wrong value type. + err = m.Matches([]uint32{}) + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr("[]uint32"))) +} + +func (t *DeepEqualsTest) WrongTypeCandidateWithNilLiteralValue() { + m := DeepEquals(nil) + + var err error + + // String candidate. + err = m.Matches("taco") + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr("string"))) + + // Nil byte slice candidate. + err = m.Matches([]byte(nil)) + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr("[]uint8"))) + + // Nil other slice candidate. + err = m.Matches([]uint16(nil)) + AssertNe(nil, err) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("type"))) + ExpectThat(err, Error(HasSubstr("[]uint16"))) +} + +func (t *DeepEqualsTest) NilLiteralValue() { + m := DeepEquals(nil) + ExpectEq("deep equals: ", m.Description()) + + var c interface{} + var err error + + // Nil literal candidate. + c = nil + err = m.Matches(c) + ExpectEq(nil, err) +} + +func (t *DeepEqualsTest) IntValue() { + m := DeepEquals(int(17)) + ExpectEq("deep equals: 17", m.Description()) + + var c interface{} + var err error + + // Matching int. + c = int(17) + err = m.Matches(c) + ExpectEq(nil, err) + + // Non-matching int. + c = int(18) + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) +} + +func (t *DeepEqualsTest) ByteSliceValue() { + x := []byte{17, 19} + m := DeepEquals(x) + ExpectEq("deep equals: [17 19]", m.Description()) + + var c []byte + var err error + + // Matching. + c = make([]byte, len(x)) + AssertEq(len(x), copy(c, x)) + + err = m.Matches(c) + ExpectEq(nil, err) + + // Nil slice. + c = []byte(nil) + err = m.Matches(c) + ExpectThat(err, Error(Equals("which is nil"))) + + // Prefix. + AssertGt(len(x), 1) + c = make([]byte, len(x)-1) + AssertEq(len(x)-1, copy(c, x)) + + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Suffix. + c = make([]byte, len(x)+1) + AssertEq(len(x), copy(c, x)) + + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) +} + +func (t *DeepEqualsTest) OtherSliceValue() { + x := []uint16{17, 19} + m := DeepEquals(x) + ExpectEq("deep equals: [17 19]", m.Description()) + + var c []uint16 + var err error + + // Matching. + c = make([]uint16, len(x)) + AssertEq(len(x), copy(c, x)) + + err = m.Matches(c) + ExpectEq(nil, err) + + // Nil slice. + c = []uint16(nil) + err = m.Matches(c) + ExpectThat(err, Error(Equals("which is nil"))) + + // Prefix. + AssertGt(len(x), 1) + c = make([]uint16, len(x)-1) + AssertEq(len(x)-1, copy(c, x)) + + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) + + // Suffix. + c = make([]uint16, len(x)+1) + AssertEq(len(x), copy(c, x)) + + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) +} + +func (t *DeepEqualsTest) NilByteSliceValue() { + x := []byte(nil) + m := DeepEquals(x) + ExpectEq("deep equals: ", m.Description()) + + var c []byte + var err error + + // Nil slice. + c = []byte(nil) + err = m.Matches(c) + ExpectEq(nil, err) + + // Non-nil slice. + c = []byte{} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) +} + +func (t *DeepEqualsTest) NilOtherSliceValue() { + x := []uint16(nil) + m := DeepEquals(x) + ExpectEq("deep equals: ", m.Description()) + + var c []uint16 + var err error + + // Nil slice. + c = []uint16(nil) + err = m.Matches(c) + ExpectEq(nil, err) + + // Non-nil slice. + c = []uint16{} + err = m.Matches(c) + ExpectThat(err, Error(Equals(""))) +} + +//////////////////////////////////////////////////////////////////////// +// Benchmarks +//////////////////////////////////////////////////////////////////////// + +func benchmarkWithSize(b *testing.B, size int) { + b.StopTimer() + buf := bytes.Repeat([]byte{0x01}, size) + bufCopy := make([]byte, size) + copy(bufCopy, buf) + + matcher := DeepEquals(buf) + b.StartTimer() + + for i := 0; i < b.N; i++ { + matcher.Matches(bufCopy) + } + + b.SetBytes(int64(size)) +} + +func BenchmarkShortByteSlice(b *testing.B) { + benchmarkWithSize(b, 256) +} + +func BenchmarkLongByteSlice(b *testing.B) { + benchmarkWithSize(b, 1<<24) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go new file mode 100644 index 000000000..2941847c7 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go @@ -0,0 +1,91 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers + +import ( + "errors" + "fmt" + "reflect" + "strings" +) + +// Given a list of arguments M, ElementsAre returns a matcher that matches +// arrays and slices A where all of the following hold: +// +// * A is the same length as M. +// +// * For each i < len(A) where M[i] is a matcher, A[i] matches M[i]. +// +// * For each i < len(A) where M[i] is not a matcher, A[i] matches +// Equals(M[i]). +// +func ElementsAre(M ...interface{}) Matcher { + // Copy over matchers, or convert to Equals(x) for non-matcher x. + subMatchers := make([]Matcher, len(M)) + for i, x := range M { + if matcher, ok := x.(Matcher); ok { + subMatchers[i] = matcher + continue + } + + subMatchers[i] = Equals(x) + } + + return &elementsAreMatcher{subMatchers} +} + +type elementsAreMatcher struct { + subMatchers []Matcher +} + +func (m *elementsAreMatcher) Description() string { + subDescs := make([]string, len(m.subMatchers)) + for i, sm := range m.subMatchers { + subDescs[i] = sm.Description() + } + + return fmt.Sprintf("elements are: [%s]", strings.Join(subDescs, ", ")) +} + +func (m *elementsAreMatcher) Matches(candidates interface{}) error { + // The candidate must be a slice or an array. + v := reflect.ValueOf(candidates) + if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { + return NewFatalError("which is not a slice or array") + } + + // The length must be correct. + if v.Len() != len(m.subMatchers) { + return errors.New(fmt.Sprintf("which is of length %d", v.Len())) + } + + // Check each element. + for i, subMatcher := range m.subMatchers { + c := v.Index(i) + if matchErr := subMatcher.Matches(c.Interface()); matchErr != nil { + // Return an errors indicating which element doesn't match. If the + // matcher error was fatal, make this one fatal too. + err := errors.New(fmt.Sprintf("whose element %d doesn't match", i)) + if _, isFatal := matchErr.(*FatalError); isFatal { + err = NewFatalError(err.Error()) + } + + return err + } + } + + return nil +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are_test.go new file mode 100644 index 000000000..172584fa1 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are_test.go @@ -0,0 +1,208 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type ElementsAreTest struct { +} + +func init() { RegisterTestSuite(&ElementsAreTest{}) } + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *ElementsAreTest) EmptySet() { + m := ElementsAre() + ExpectEq("elements are: []", m.Description()) + + var c []interface{} + var err error + + // No candidates. + c = []interface{}{} + err = m.Matches(c) + ExpectEq(nil, err) + + // One candidate. + c = []interface{}{17} + err = m.Matches(c) + ExpectThat(err, Error(HasSubstr("length 1"))) +} + +func (t *ElementsAreTest) OneMatcher() { + m := ElementsAre(LessThan(17)) + ExpectEq("elements are: [less than 17]", m.Description()) + + var c []interface{} + var err error + + // No candidates. + c = []interface{}{} + err = m.Matches(c) + ExpectThat(err, Error(HasSubstr("length 0"))) + + // Matching candidate. + c = []interface{}{16} + err = m.Matches(c) + ExpectEq(nil, err) + + // Non-matching candidate. + c = []interface{}{19} + err = m.Matches(c) + ExpectNe(nil, err) + + // Two candidates. + c = []interface{}{17, 19} + err = m.Matches(c) + ExpectThat(err, Error(HasSubstr("length 2"))) +} + +func (t *ElementsAreTest) OneValue() { + m := ElementsAre(17) + ExpectEq("elements are: [17]", m.Description()) + + var c []interface{} + var err error + + // No candidates. + c = []interface{}{} + err = m.Matches(c) + ExpectThat(err, Error(HasSubstr("length 0"))) + + // Matching int. + c = []interface{}{int(17)} + err = m.Matches(c) + ExpectEq(nil, err) + + // Matching float. + c = []interface{}{float32(17)} + err = m.Matches(c) + ExpectEq(nil, err) + + // Non-matching candidate. + c = []interface{}{19} + err = m.Matches(c) + ExpectNe(nil, err) + + // Two candidates. + c = []interface{}{17, 19} + err = m.Matches(c) + ExpectThat(err, Error(HasSubstr("length 2"))) +} + +func (t *ElementsAreTest) MultipleElements() { + m := ElementsAre("taco", LessThan(17)) + ExpectEq("elements are: [taco, less than 17]", m.Description()) + + var c []interface{} + var err error + + // One candidate. + c = []interface{}{17} + err = m.Matches(c) + ExpectThat(err, Error(HasSubstr("length 1"))) + + // Both matching. + c = []interface{}{"taco", 16} + err = m.Matches(c) + ExpectEq(nil, err) + + // First non-matching. + c = []interface{}{"burrito", 16} + err = m.Matches(c) + ExpectThat(err, Error(Equals("whose element 0 doesn't match"))) + + // Second non-matching. + c = []interface{}{"taco", 17} + err = m.Matches(c) + ExpectThat(err, Error(Equals("whose element 1 doesn't match"))) + + // Three candidates. + c = []interface{}{"taco", 17, 19} + err = m.Matches(c) + ExpectThat(err, Error(HasSubstr("length 3"))) +} + +func (t *ElementsAreTest) ArrayCandidates() { + m := ElementsAre("taco", LessThan(17)) + + var err error + + // One candidate. + err = m.Matches([1]interface{}{"taco"}) + ExpectThat(err, Error(HasSubstr("length 1"))) + + // Both matching. + err = m.Matches([2]interface{}{"taco", 16}) + ExpectEq(nil, err) + + // First non-matching. + err = m.Matches([2]interface{}{"burrito", 16}) + ExpectThat(err, Error(Equals("whose element 0 doesn't match"))) +} + +func (t *ElementsAreTest) WrongTypeCandidate() { + m := ElementsAre("taco") + + var err error + + // String candidate. + err = m.Matches("taco") + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("array"))) + ExpectThat(err, Error(HasSubstr("slice"))) + + // Map candidate. + err = m.Matches(map[string]string{}) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("array"))) + ExpectThat(err, Error(HasSubstr("slice"))) + + // Nil candidate. + err = m.Matches(nil) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("array"))) + ExpectThat(err, Error(HasSubstr("slice"))) +} + +func (t *ElementsAreTest) PropagatesFatality() { + m := ElementsAre(LessThan(17)) + ExpectEq("elements are: [less than 17]", m.Description()) + + var c []interface{} + var err error + + // Non-fatal error. + c = []interface{}{19} + err = m.Matches(c) + AssertNe(nil, err) + ExpectFalse(isFatal(err)) + + // Fatal error. + c = []interface{}{"taco"} + err = m.Matches(c) + AssertNe(nil, err) + ExpectTrue(isFatal(err)) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/equals_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/equals_test.go new file mode 100644 index 000000000..6ac5df273 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/equals_test.go @@ -0,0 +1,3864 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "fmt" + "math" + "unsafe" + + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +var someInt int = -17 + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type EqualsTest struct { +} + +func init() { RegisterTestSuite(&EqualsTest{}) } + +type equalsTestCase struct { + candidate interface{} + expectedResult bool + shouldBeFatal bool + expectedError string +} + +func (t *EqualsTest) checkTestCases(matcher Matcher, cases []equalsTestCase) { + for i, c := range cases { + err := matcher.Matches(c.candidate) + ExpectEq( + c.expectedResult, + (err == nil), + "Result for case %d: %v (Error: %v)", i, c, err) + + if err == nil { + continue + } + + _, isFatal := err.(*FatalError) + ExpectEq(c.shouldBeFatal, isFatal, "Fatality for case %d: %v", i, c) + + ExpectThat(err, Error(Equals(c.expectedError)), "Case %d: %v", i, c) + } +} + +//////////////////////////////////////////////////////////////////////// +// nil +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) EqualsNil() { + matcher := Equals(nil) + ExpectEq("is nil", matcher.Description()) + + cases := []equalsTestCase{ + // Legal types + equalsTestCase{nil, true, false, ""}, + equalsTestCase{chan int(nil), true, false, ""}, + equalsTestCase{(func())(nil), true, false, ""}, + equalsTestCase{interface{}(nil), true, false, ""}, + equalsTestCase{map[int]int(nil), true, false, ""}, + equalsTestCase{(*int)(nil), true, false, ""}, + equalsTestCase{[]int(nil), true, false, ""}, + + equalsTestCase{make(chan int), false, false, ""}, + equalsTestCase{func() {}, false, false, ""}, + equalsTestCase{map[int]int{}, false, false, ""}, + equalsTestCase{&someInt, false, false, ""}, + equalsTestCase{[]int{}, false, false, ""}, + + // Illegal types + equalsTestCase{17, false, true, "which cannot be compared to nil"}, + equalsTestCase{int8(17), false, true, "which cannot be compared to nil"}, + equalsTestCase{uintptr(17), false, true, "which cannot be compared to nil"}, + equalsTestCase{[...]int{}, false, true, "which cannot be compared to nil"}, + equalsTestCase{"taco", false, true, "which cannot be compared to nil"}, + equalsTestCase{equalsTestCase{}, false, true, "which cannot be compared to nil"}, + equalsTestCase{unsafe.Pointer(&someInt), false, true, "which cannot be compared to nil"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// Integer literals +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NegativeIntegerLiteral() { + // -2^30 + matcher := Equals(-1073741824) + ExpectEq("-1073741824", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of -1073741824. + equalsTestCase{-1073741824, true, false, ""}, + equalsTestCase{-1073741824.0, true, false, ""}, + equalsTestCase{-1073741824 + 0i, true, false, ""}, + equalsTestCase{int(-1073741824), true, false, ""}, + equalsTestCase{int32(-1073741824), true, false, ""}, + equalsTestCase{int64(-1073741824), true, false, ""}, + equalsTestCase{float32(-1073741824), true, false, ""}, + equalsTestCase{float64(-1073741824), true, false, ""}, + equalsTestCase{complex64(-1073741824), true, false, ""}, + equalsTestCase{complex128(-1073741824), true, false, ""}, + equalsTestCase{interface{}(int(-1073741824)), true, false, ""}, + + // Values that would be -1073741824 in two's complement. + equalsTestCase{uint((1 << 32) - 1073741824), false, false, ""}, + equalsTestCase{uint32((1 << 32) - 1073741824), false, false, ""}, + equalsTestCase{uint64((1 << 64) - 1073741824), false, false, ""}, + equalsTestCase{uintptr((1 << 64) - 1073741824), false, false, ""}, + + // Non-equal values of signed integer type. + equalsTestCase{int(-1073741823), false, false, ""}, + equalsTestCase{int32(-1073741823), false, false, ""}, + equalsTestCase{int64(-1073741823), false, false, ""}, + + // Non-equal values of other numeric types. + equalsTestCase{float64(-1073741824.1), false, false, ""}, + equalsTestCase{float64(-1073741823.9), false, false, ""}, + equalsTestCase{complex128(-1073741823), false, false, ""}, + equalsTestCase{complex128(-1073741824 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveIntegerLiteral() { + // 2^30 + matcher := Equals(1073741824) + ExpectEq("1073741824", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 1073741824. + equalsTestCase{1073741824, true, false, ""}, + equalsTestCase{1073741824.0, true, false, ""}, + equalsTestCase{1073741824 + 0i, true, false, ""}, + equalsTestCase{int(1073741824), true, false, ""}, + equalsTestCase{uint(1073741824), true, false, ""}, + equalsTestCase{int32(1073741824), true, false, ""}, + equalsTestCase{int64(1073741824), true, false, ""}, + equalsTestCase{uint32(1073741824), true, false, ""}, + equalsTestCase{uint64(1073741824), true, false, ""}, + equalsTestCase{uintptr(1073741824), true, false, ""}, + equalsTestCase{float32(1073741824), true, false, ""}, + equalsTestCase{float64(1073741824), true, false, ""}, + equalsTestCase{complex64(1073741824), true, false, ""}, + equalsTestCase{complex128(1073741824), true, false, ""}, + equalsTestCase{interface{}(int(1073741824)), true, false, ""}, + equalsTestCase{interface{}(uint(1073741824)), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(1073741823), false, false, ""}, + equalsTestCase{int32(1073741823), false, false, ""}, + equalsTestCase{int64(1073741823), false, false, ""}, + equalsTestCase{float64(1073741824.1), false, false, ""}, + equalsTestCase{float64(1073741823.9), false, false, ""}, + equalsTestCase{complex128(1073741823), false, false, ""}, + equalsTestCase{complex128(1073741824 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// Floating point literals +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NegativeIntegralFloatingPointLiteral() { + // -2^30 + matcher := Equals(-1073741824.0) + ExpectEq("-1.073741824e+09", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of -1073741824. + equalsTestCase{-1073741824, true, false, ""}, + equalsTestCase{-1073741824.0, true, false, ""}, + equalsTestCase{-1073741824 + 0i, true, false, ""}, + equalsTestCase{int(-1073741824), true, false, ""}, + equalsTestCase{int32(-1073741824), true, false, ""}, + equalsTestCase{int64(-1073741824), true, false, ""}, + equalsTestCase{float32(-1073741824), true, false, ""}, + equalsTestCase{float64(-1073741824), true, false, ""}, + equalsTestCase{complex64(-1073741824), true, false, ""}, + equalsTestCase{complex128(-1073741824), true, false, ""}, + equalsTestCase{interface{}(int(-1073741824)), true, false, ""}, + equalsTestCase{interface{}(float64(-1073741824)), true, false, ""}, + + // Values that would be -1073741824 in two's complement. + equalsTestCase{uint((1 << 32) - 1073741824), false, false, ""}, + equalsTestCase{uint32((1 << 32) - 1073741824), false, false, ""}, + equalsTestCase{uint64((1 << 64) - 1073741824), false, false, ""}, + equalsTestCase{uintptr((1 << 64) - 1073741824), false, false, ""}, + + // Non-equal values of signed integer type. + equalsTestCase{int(-1073741823), false, false, ""}, + equalsTestCase{int32(-1073741823), false, false, ""}, + equalsTestCase{int64(-1073741823), false, false, ""}, + + // Non-equal values of other numeric types. + equalsTestCase{float64(-1073741824.1), false, false, ""}, + equalsTestCase{float64(-1073741823.9), false, false, ""}, + equalsTestCase{complex128(-1073741823), false, false, ""}, + equalsTestCase{complex128(-1073741824 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveIntegralFloatingPointLiteral() { + // 2^30 + matcher := Equals(1073741824.0) + ExpectEq("1.073741824e+09", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 1073741824. + equalsTestCase{1073741824, true, false, ""}, + equalsTestCase{1073741824.0, true, false, ""}, + equalsTestCase{1073741824 + 0i, true, false, ""}, + equalsTestCase{int(1073741824), true, false, ""}, + equalsTestCase{int32(1073741824), true, false, ""}, + equalsTestCase{int64(1073741824), true, false, ""}, + equalsTestCase{uint(1073741824), true, false, ""}, + equalsTestCase{uint32(1073741824), true, false, ""}, + equalsTestCase{uint64(1073741824), true, false, ""}, + equalsTestCase{float32(1073741824), true, false, ""}, + equalsTestCase{float64(1073741824), true, false, ""}, + equalsTestCase{complex64(1073741824), true, false, ""}, + equalsTestCase{complex128(1073741824), true, false, ""}, + equalsTestCase{interface{}(int(1073741824)), true, false, ""}, + equalsTestCase{interface{}(float64(1073741824)), true, false, ""}, + + // Values that would be 1073741824 in two's complement. + equalsTestCase{uint((1 << 32) - 1073741824), false, false, ""}, + equalsTestCase{uint32((1 << 32) - 1073741824), false, false, ""}, + equalsTestCase{uint64((1 << 64) - 1073741824), false, false, ""}, + equalsTestCase{uintptr((1 << 64) - 1073741824), false, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(1073741823), false, false, ""}, + equalsTestCase{int32(1073741823), false, false, ""}, + equalsTestCase{int64(1073741823), false, false, ""}, + equalsTestCase{uint(1073741823), false, false, ""}, + equalsTestCase{uint32(1073741823), false, false, ""}, + equalsTestCase{uint64(1073741823), false, false, ""}, + equalsTestCase{float64(1073741824.1), false, false, ""}, + equalsTestCase{float64(1073741823.9), false, false, ""}, + equalsTestCase{complex128(1073741823), false, false, ""}, + equalsTestCase{complex128(1073741824 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) NonIntegralFloatingPointLiteral() { + matcher := Equals(17.1) + ExpectEq("17.1", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 17.1. + equalsTestCase{17.1, true, false, ""}, + equalsTestCase{17.1, true, false, ""}, + equalsTestCase{17.1 + 0i, true, false, ""}, + equalsTestCase{float32(17.1), true, false, ""}, + equalsTestCase{float64(17.1), true, false, ""}, + equalsTestCase{complex64(17.1), true, false, ""}, + equalsTestCase{complex128(17.1), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{17, false, false, ""}, + equalsTestCase{17.2, false, false, ""}, + equalsTestCase{18, false, false, ""}, + equalsTestCase{int(17), false, false, ""}, + equalsTestCase{int(18), false, false, ""}, + equalsTestCase{int32(17), false, false, ""}, + equalsTestCase{int64(17), false, false, ""}, + equalsTestCase{uint(17), false, false, ""}, + equalsTestCase{uint32(17), false, false, ""}, + equalsTestCase{uint64(17), false, false, ""}, + equalsTestCase{uintptr(17), false, false, ""}, + equalsTestCase{complex128(17.1 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// bool +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) False() { + matcher := Equals(false) + ExpectEq("false", matcher.Description()) + + cases := []equalsTestCase{ + // bools + equalsTestCase{false, true, false, ""}, + equalsTestCase{bool(false), true, false, ""}, + + equalsTestCase{true, false, false, ""}, + equalsTestCase{bool(true), false, false, ""}, + + // Other types. + equalsTestCase{int(0), false, true, "which is not a bool"}, + equalsTestCase{int8(0), false, true, "which is not a bool"}, + equalsTestCase{int16(0), false, true, "which is not a bool"}, + equalsTestCase{int32(0), false, true, "which is not a bool"}, + equalsTestCase{int64(0), false, true, "which is not a bool"}, + equalsTestCase{uint(0), false, true, "which is not a bool"}, + equalsTestCase{uint8(0), false, true, "which is not a bool"}, + equalsTestCase{uint16(0), false, true, "which is not a bool"}, + equalsTestCase{uint32(0), false, true, "which is not a bool"}, + equalsTestCase{uint64(0), false, true, "which is not a bool"}, + equalsTestCase{uintptr(0), false, true, "which is not a bool"}, + equalsTestCase{[...]int{}, false, true, "which is not a bool"}, + equalsTestCase{make(chan int), false, true, "which is not a bool"}, + equalsTestCase{func() {}, false, true, "which is not a bool"}, + equalsTestCase{map[int]int{}, false, true, "which is not a bool"}, + equalsTestCase{&someInt, false, true, "which is not a bool"}, + equalsTestCase{[]int{}, false, true, "which is not a bool"}, + equalsTestCase{"taco", false, true, "which is not a bool"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not a bool"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) True() { + matcher := Equals(true) + ExpectEq("true", matcher.Description()) + + cases := []equalsTestCase{ + // bools + equalsTestCase{true, true, false, ""}, + equalsTestCase{bool(true), true, false, ""}, + + equalsTestCase{false, false, false, ""}, + equalsTestCase{bool(false), false, false, ""}, + + // Other types. + equalsTestCase{int(1), false, true, "which is not a bool"}, + equalsTestCase{int8(1), false, true, "which is not a bool"}, + equalsTestCase{int16(1), false, true, "which is not a bool"}, + equalsTestCase{int32(1), false, true, "which is not a bool"}, + equalsTestCase{int64(1), false, true, "which is not a bool"}, + equalsTestCase{uint(1), false, true, "which is not a bool"}, + equalsTestCase{uint8(1), false, true, "which is not a bool"}, + equalsTestCase{uint16(1), false, true, "which is not a bool"}, + equalsTestCase{uint32(1), false, true, "which is not a bool"}, + equalsTestCase{uint64(1), false, true, "which is not a bool"}, + equalsTestCase{uintptr(1), false, true, "which is not a bool"}, + equalsTestCase{[...]int{}, false, true, "which is not a bool"}, + equalsTestCase{make(chan int), false, true, "which is not a bool"}, + equalsTestCase{func() {}, false, true, "which is not a bool"}, + equalsTestCase{map[int]int{}, false, true, "which is not a bool"}, + equalsTestCase{&someInt, false, true, "which is not a bool"}, + equalsTestCase{[]int{}, false, true, "which is not a bool"}, + equalsTestCase{"taco", false, true, "which is not a bool"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not a bool"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// int +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NegativeInt() { + // -2^30 + matcher := Equals(int(-1073741824)) + ExpectEq("-1073741824", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of -1073741824. + equalsTestCase{-1073741824, true, false, ""}, + equalsTestCase{-1073741824.0, true, false, ""}, + equalsTestCase{-1073741824 + 0i, true, false, ""}, + equalsTestCase{int(-1073741824), true, false, ""}, + equalsTestCase{int32(-1073741824), true, false, ""}, + equalsTestCase{int64(-1073741824), true, false, ""}, + equalsTestCase{float32(-1073741824), true, false, ""}, + equalsTestCase{float64(-1073741824), true, false, ""}, + equalsTestCase{complex64(-1073741824), true, false, ""}, + equalsTestCase{complex128(-1073741824), true, false, ""}, + equalsTestCase{interface{}(int(-1073741824)), true, false, ""}, + + // Values that would be -1073741824 in two's complement. + equalsTestCase{uint((1 << 32) - 1073741824), false, false, ""}, + equalsTestCase{uint32((1 << 32) - 1073741824), false, false, ""}, + equalsTestCase{uint64((1 << 64) - 1073741824), false, false, ""}, + equalsTestCase{uintptr((1 << 64) - 1073741824), false, false, ""}, + + // Non-equal values of signed integer type. + equalsTestCase{int(-1073741823), false, false, ""}, + equalsTestCase{int32(-1073741823), false, false, ""}, + equalsTestCase{int64(-1073741823), false, false, ""}, + + // Non-equal values of other numeric types. + equalsTestCase{float64(-1073741824.1), false, false, ""}, + equalsTestCase{float64(-1073741823.9), false, false, ""}, + equalsTestCase{complex128(-1073741823), false, false, ""}, + equalsTestCase{complex128(-1073741824 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveInt() { + // 2^30 + matcher := Equals(int(1073741824)) + ExpectEq("1073741824", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 1073741824. + equalsTestCase{1073741824, true, false, ""}, + equalsTestCase{1073741824.0, true, false, ""}, + equalsTestCase{1073741824 + 0i, true, false, ""}, + equalsTestCase{int(1073741824), true, false, ""}, + equalsTestCase{uint(1073741824), true, false, ""}, + equalsTestCase{int32(1073741824), true, false, ""}, + equalsTestCase{int64(1073741824), true, false, ""}, + equalsTestCase{uint32(1073741824), true, false, ""}, + equalsTestCase{uint64(1073741824), true, false, ""}, + equalsTestCase{uintptr(1073741824), true, false, ""}, + equalsTestCase{float32(1073741824), true, false, ""}, + equalsTestCase{float64(1073741824), true, false, ""}, + equalsTestCase{complex64(1073741824), true, false, ""}, + equalsTestCase{complex128(1073741824), true, false, ""}, + equalsTestCase{interface{}(int(1073741824)), true, false, ""}, + equalsTestCase{interface{}(uint(1073741824)), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(1073741823), false, false, ""}, + equalsTestCase{int32(1073741823), false, false, ""}, + equalsTestCase{int64(1073741823), false, false, ""}, + equalsTestCase{float64(1073741824.1), false, false, ""}, + equalsTestCase{float64(1073741823.9), false, false, ""}, + equalsTestCase{complex128(1073741823), false, false, ""}, + equalsTestCase{complex128(1073741824 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// int8 +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NegativeInt8() { + matcher := Equals(int8(-17)) + ExpectEq("-17", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of -17. + equalsTestCase{-17, true, false, ""}, + equalsTestCase{-17.0, true, false, ""}, + equalsTestCase{-17 + 0i, true, false, ""}, + equalsTestCase{int(-17), true, false, ""}, + equalsTestCase{int8(-17), true, false, ""}, + equalsTestCase{int16(-17), true, false, ""}, + equalsTestCase{int32(-17), true, false, ""}, + equalsTestCase{int64(-17), true, false, ""}, + equalsTestCase{float32(-17), true, false, ""}, + equalsTestCase{float64(-17), true, false, ""}, + equalsTestCase{complex64(-17), true, false, ""}, + equalsTestCase{complex128(-17), true, false, ""}, + equalsTestCase{interface{}(int(-17)), true, false, ""}, + + // Values that would be -17 in two's complement. + equalsTestCase{uint((1 << 32) - 17), false, false, ""}, + equalsTestCase{uint8((1 << 8) - 17), false, false, ""}, + equalsTestCase{uint16((1 << 16) - 17), false, false, ""}, + equalsTestCase{uint32((1 << 32) - 17), false, false, ""}, + equalsTestCase{uint64((1 << 64) - 17), false, false, ""}, + equalsTestCase{uintptr((1 << 64) - 17), false, false, ""}, + + // Non-equal values of signed integer type. + equalsTestCase{int(-16), false, false, ""}, + equalsTestCase{int8(-16), false, false, ""}, + equalsTestCase{int16(-16), false, false, ""}, + equalsTestCase{int32(-16), false, false, ""}, + equalsTestCase{int64(-16), false, false, ""}, + + // Non-equal values of other numeric types. + equalsTestCase{float32(-17.1), false, false, ""}, + equalsTestCase{float32(-16.9), false, false, ""}, + equalsTestCase{complex64(-16), false, false, ""}, + equalsTestCase{complex64(-17 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{-17}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{-17}, false, true, "which is not numeric"}, + equalsTestCase{"-17", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) ZeroInt8() { + matcher := Equals(int8(0)) + ExpectEq("0", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 0. + equalsTestCase{0, true, false, ""}, + equalsTestCase{0.0, true, false, ""}, + equalsTestCase{0 + 0i, true, false, ""}, + equalsTestCase{int(0), true, false, ""}, + equalsTestCase{int8(0), true, false, ""}, + equalsTestCase{int16(0), true, false, ""}, + equalsTestCase{int32(0), true, false, ""}, + equalsTestCase{int64(0), true, false, ""}, + equalsTestCase{float32(0), true, false, ""}, + equalsTestCase{float64(0), true, false, ""}, + equalsTestCase{complex64(0), true, false, ""}, + equalsTestCase{complex128(0), true, false, ""}, + equalsTestCase{interface{}(int(0)), true, false, ""}, + equalsTestCase{uint(0), true, false, ""}, + equalsTestCase{uint8(0), true, false, ""}, + equalsTestCase{uint16(0), true, false, ""}, + equalsTestCase{uint32(0), true, false, ""}, + equalsTestCase{uint64(0), true, false, ""}, + equalsTestCase{uintptr(0), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(1), false, false, ""}, + equalsTestCase{int8(1), false, false, ""}, + equalsTestCase{int16(1), false, false, ""}, + equalsTestCase{int32(1), false, false, ""}, + equalsTestCase{int64(1), false, false, ""}, + equalsTestCase{float32(-0.1), false, false, ""}, + equalsTestCase{float32(0.1), false, false, ""}, + equalsTestCase{complex64(1), false, false, ""}, + equalsTestCase{complex64(0 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{0}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{0}, false, true, "which is not numeric"}, + equalsTestCase{"0", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveInt8() { + matcher := Equals(int8(17)) + ExpectEq("17", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 17. + equalsTestCase{17, true, false, ""}, + equalsTestCase{17.0, true, false, ""}, + equalsTestCase{17 + 0i, true, false, ""}, + equalsTestCase{int(17), true, false, ""}, + equalsTestCase{int8(17), true, false, ""}, + equalsTestCase{int16(17), true, false, ""}, + equalsTestCase{int32(17), true, false, ""}, + equalsTestCase{int64(17), true, false, ""}, + equalsTestCase{float32(17), true, false, ""}, + equalsTestCase{float64(17), true, false, ""}, + equalsTestCase{complex64(17), true, false, ""}, + equalsTestCase{complex128(17), true, false, ""}, + equalsTestCase{interface{}(int(17)), true, false, ""}, + equalsTestCase{uint(17), true, false, ""}, + equalsTestCase{uint8(17), true, false, ""}, + equalsTestCase{uint16(17), true, false, ""}, + equalsTestCase{uint32(17), true, false, ""}, + equalsTestCase{uint64(17), true, false, ""}, + equalsTestCase{uintptr(17), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(16), false, false, ""}, + equalsTestCase{int8(16), false, false, ""}, + equalsTestCase{int16(16), false, false, ""}, + equalsTestCase{int32(16), false, false, ""}, + equalsTestCase{int64(16), false, false, ""}, + equalsTestCase{float32(16.9), false, false, ""}, + equalsTestCase{float32(17.1), false, false, ""}, + equalsTestCase{complex64(16), false, false, ""}, + equalsTestCase{complex64(17 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{17}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{17}, false, true, "which is not numeric"}, + equalsTestCase{"17", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// int16 +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NegativeInt16() { + matcher := Equals(int16(-32766)) + ExpectEq("-32766", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of -32766. + equalsTestCase{-32766, true, false, ""}, + equalsTestCase{-32766.0, true, false, ""}, + equalsTestCase{-32766 + 0i, true, false, ""}, + equalsTestCase{int(-32766), true, false, ""}, + equalsTestCase{int16(-32766), true, false, ""}, + equalsTestCase{int32(-32766), true, false, ""}, + equalsTestCase{int64(-32766), true, false, ""}, + equalsTestCase{float32(-32766), true, false, ""}, + equalsTestCase{float64(-32766), true, false, ""}, + equalsTestCase{complex64(-32766), true, false, ""}, + equalsTestCase{complex128(-32766), true, false, ""}, + equalsTestCase{interface{}(int(-32766)), true, false, ""}, + + // Values that would be -32766 in two's complement. + equalsTestCase{uint((1 << 32) - 32766), false, false, ""}, + equalsTestCase{uint16((1 << 16) - 32766), false, false, ""}, + equalsTestCase{uint32((1 << 32) - 32766), false, false, ""}, + equalsTestCase{uint64((1 << 64) - 32766), false, false, ""}, + equalsTestCase{uintptr((1 << 64) - 32766), false, false, ""}, + + // Non-equal values of signed integer type. + equalsTestCase{int(-16), false, false, ""}, + equalsTestCase{int8(-16), false, false, ""}, + equalsTestCase{int16(-16), false, false, ""}, + equalsTestCase{int32(-16), false, false, ""}, + equalsTestCase{int64(-16), false, false, ""}, + + // Non-equal values of other numeric types. + equalsTestCase{float32(-32766.1), false, false, ""}, + equalsTestCase{float32(-32765.9), false, false, ""}, + equalsTestCase{complex64(-32766.1), false, false, ""}, + equalsTestCase{complex64(-32766 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{-32766}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{-32766}, false, true, "which is not numeric"}, + equalsTestCase{"-32766", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) ZeroInt16() { + matcher := Equals(int16(0)) + ExpectEq("0", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 0. + equalsTestCase{0, true, false, ""}, + equalsTestCase{0.0, true, false, ""}, + equalsTestCase{0 + 0i, true, false, ""}, + equalsTestCase{int(0), true, false, ""}, + equalsTestCase{int8(0), true, false, ""}, + equalsTestCase{int16(0), true, false, ""}, + equalsTestCase{int32(0), true, false, ""}, + equalsTestCase{int64(0), true, false, ""}, + equalsTestCase{float32(0), true, false, ""}, + equalsTestCase{float64(0), true, false, ""}, + equalsTestCase{complex64(0), true, false, ""}, + equalsTestCase{complex128(0), true, false, ""}, + equalsTestCase{interface{}(int(0)), true, false, ""}, + equalsTestCase{uint(0), true, false, ""}, + equalsTestCase{uint8(0), true, false, ""}, + equalsTestCase{uint16(0), true, false, ""}, + equalsTestCase{uint32(0), true, false, ""}, + equalsTestCase{uint64(0), true, false, ""}, + equalsTestCase{uintptr(0), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(1), false, false, ""}, + equalsTestCase{int8(1), false, false, ""}, + equalsTestCase{int16(1), false, false, ""}, + equalsTestCase{int32(1), false, false, ""}, + equalsTestCase{int64(1), false, false, ""}, + equalsTestCase{float32(-0.1), false, false, ""}, + equalsTestCase{float32(0.1), false, false, ""}, + equalsTestCase{complex64(1), false, false, ""}, + equalsTestCase{complex64(0 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{0}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{0}, false, true, "which is not numeric"}, + equalsTestCase{"0", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveInt16() { + matcher := Equals(int16(32765)) + ExpectEq("32765", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 32765. + equalsTestCase{32765, true, false, ""}, + equalsTestCase{32765.0, true, false, ""}, + equalsTestCase{32765 + 0i, true, false, ""}, + equalsTestCase{int(32765), true, false, ""}, + equalsTestCase{int16(32765), true, false, ""}, + equalsTestCase{int32(32765), true, false, ""}, + equalsTestCase{int64(32765), true, false, ""}, + equalsTestCase{float32(32765), true, false, ""}, + equalsTestCase{float64(32765), true, false, ""}, + equalsTestCase{complex64(32765), true, false, ""}, + equalsTestCase{complex128(32765), true, false, ""}, + equalsTestCase{interface{}(int(32765)), true, false, ""}, + equalsTestCase{uint(32765), true, false, ""}, + equalsTestCase{uint16(32765), true, false, ""}, + equalsTestCase{uint32(32765), true, false, ""}, + equalsTestCase{uint64(32765), true, false, ""}, + equalsTestCase{uintptr(32765), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(32764), false, false, ""}, + equalsTestCase{int16(32764), false, false, ""}, + equalsTestCase{int32(32764), false, false, ""}, + equalsTestCase{int64(32764), false, false, ""}, + equalsTestCase{float32(32764.9), false, false, ""}, + equalsTestCase{float32(32765.1), false, false, ""}, + equalsTestCase{complex64(32765.9), false, false, ""}, + equalsTestCase{complex64(32765 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{32765}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{32765}, false, true, "which is not numeric"}, + equalsTestCase{"32765", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// int32 +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NegativeInt32() { + // -2^30 + matcher := Equals(int32(-1073741824)) + ExpectEq("-1073741824", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of -1073741824. + equalsTestCase{-1073741824, true, false, ""}, + equalsTestCase{-1073741824.0, true, false, ""}, + equalsTestCase{-1073741824 + 0i, true, false, ""}, + equalsTestCase{int(-1073741824), true, false, ""}, + equalsTestCase{int32(-1073741824), true, false, ""}, + equalsTestCase{int64(-1073741824), true, false, ""}, + equalsTestCase{float32(-1073741824), true, false, ""}, + equalsTestCase{float64(-1073741824), true, false, ""}, + equalsTestCase{complex64(-1073741824), true, false, ""}, + equalsTestCase{complex128(-1073741824), true, false, ""}, + equalsTestCase{interface{}(int(-1073741824)), true, false, ""}, + + // Values that would be -1073741824 in two's complement. + equalsTestCase{uint((1 << 32) - 1073741824), false, false, ""}, + equalsTestCase{uint32((1 << 32) - 1073741824), false, false, ""}, + equalsTestCase{uint64((1 << 64) - 1073741824), false, false, ""}, + equalsTestCase{uintptr((1 << 64) - 1073741824), false, false, ""}, + + // Non-equal values of signed integer type. + equalsTestCase{int(-1073741823), false, false, ""}, + equalsTestCase{int32(-1073741823), false, false, ""}, + equalsTestCase{int64(-1073741823), false, false, ""}, + + // Non-equal values of other numeric types. + equalsTestCase{float64(-1073741824.1), false, false, ""}, + equalsTestCase{float64(-1073741823.9), false, false, ""}, + equalsTestCase{complex128(-1073741823), false, false, ""}, + equalsTestCase{complex128(-1073741824 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveInt32() { + // 2^30 + matcher := Equals(int32(1073741824)) + ExpectEq("1073741824", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 1073741824. + equalsTestCase{1073741824, true, false, ""}, + equalsTestCase{1073741824.0, true, false, ""}, + equalsTestCase{1073741824 + 0i, true, false, ""}, + equalsTestCase{int(1073741824), true, false, ""}, + equalsTestCase{uint(1073741824), true, false, ""}, + equalsTestCase{int32(1073741824), true, false, ""}, + equalsTestCase{int64(1073741824), true, false, ""}, + equalsTestCase{uint32(1073741824), true, false, ""}, + equalsTestCase{uint64(1073741824), true, false, ""}, + equalsTestCase{uintptr(1073741824), true, false, ""}, + equalsTestCase{float32(1073741824), true, false, ""}, + equalsTestCase{float64(1073741824), true, false, ""}, + equalsTestCase{complex64(1073741824), true, false, ""}, + equalsTestCase{complex128(1073741824), true, false, ""}, + equalsTestCase{interface{}(int(1073741824)), true, false, ""}, + equalsTestCase{interface{}(uint(1073741824)), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(1073741823), false, false, ""}, + equalsTestCase{int32(1073741823), false, false, ""}, + equalsTestCase{int64(1073741823), false, false, ""}, + equalsTestCase{float64(1073741824.1), false, false, ""}, + equalsTestCase{float64(1073741823.9), false, false, ""}, + equalsTestCase{complex128(1073741823), false, false, ""}, + equalsTestCase{complex128(1073741824 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// int64 +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NegativeInt64() { + // -2^40 + matcher := Equals(int64(-1099511627776)) + ExpectEq("-1099511627776", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of -1099511627776. + equalsTestCase{-1099511627776.0, true, false, ""}, + equalsTestCase{-1099511627776 + 0i, true, false, ""}, + equalsTestCase{int64(-1099511627776), true, false, ""}, + equalsTestCase{float32(-1099511627776), true, false, ""}, + equalsTestCase{float64(-1099511627776), true, false, ""}, + equalsTestCase{complex64(-1099511627776), true, false, ""}, + equalsTestCase{complex128(-1099511627776), true, false, ""}, + equalsTestCase{interface{}(int64(-1099511627776)), true, false, ""}, + + // Values that would be -1099511627776 in two's complement. + equalsTestCase{uint64((1 << 64) - 1099511627776), false, false, ""}, + + // Non-equal values of signed integer type. + equalsTestCase{int64(-1099511627775), false, false, ""}, + + // Non-equal values of other numeric types. + equalsTestCase{float64(-1099511627776.1), false, false, ""}, + equalsTestCase{float64(-1099511627775.9), false, false, ""}, + equalsTestCase{complex128(-1099511627775), false, false, ""}, + equalsTestCase{complex128(-1099511627776 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveInt64() { + // 2^40 + matcher := Equals(int64(1099511627776)) + ExpectEq("1099511627776", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 1099511627776. + equalsTestCase{1099511627776.0, true, false, ""}, + equalsTestCase{1099511627776 + 0i, true, false, ""}, + equalsTestCase{int64(1099511627776), true, false, ""}, + equalsTestCase{uint64(1099511627776), true, false, ""}, + equalsTestCase{uintptr(1099511627776), true, false, ""}, + equalsTestCase{float32(1099511627776), true, false, ""}, + equalsTestCase{float64(1099511627776), true, false, ""}, + equalsTestCase{complex64(1099511627776), true, false, ""}, + equalsTestCase{complex128(1099511627776), true, false, ""}, + equalsTestCase{interface{}(int64(1099511627776)), true, false, ""}, + equalsTestCase{interface{}(uint64(1099511627776)), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(1099511627775), false, false, ""}, + equalsTestCase{uint64(1099511627775), false, false, ""}, + equalsTestCase{float64(1099511627776.1), false, false, ""}, + equalsTestCase{float64(1099511627775.9), false, false, ""}, + equalsTestCase{complex128(1099511627775), false, false, ""}, + equalsTestCase{complex128(1099511627776 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) Int64NotExactlyRepresentableBySinglePrecision() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := Equals(int64(kTwoTo25 + 1)) + ExpectEq("33554433", matcher.Description()) + + cases := []equalsTestCase{ + // Integers. + equalsTestCase{int64(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{int64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{int64(kTwoTo25 + 2), false, false, ""}, + + equalsTestCase{uint64(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 2), false, false, ""}, + + // Single-precision floating point. + equalsTestCase{float32(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{float32(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 3), false, false, ""}, + + equalsTestCase{complex64(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{complex64(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 3), false, false, ""}, + + // Double-precision floating point. + equalsTestCase{float64(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{float64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{float64(kTwoTo25 + 2), false, false, ""}, + + equalsTestCase{complex128(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 2), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) Int64NotExactlyRepresentableByDoublePrecision() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := Equals(int64(kTwoTo54 + 1)) + ExpectEq("18014398509481985", matcher.Description()) + + cases := []equalsTestCase{ + // Integers. + equalsTestCase{int64(kTwoTo54 + 0), false, false, ""}, + equalsTestCase{int64(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{int64(kTwoTo54 + 2), false, false, ""}, + + equalsTestCase{uint64(kTwoTo54 + 0), false, false, ""}, + equalsTestCase{uint64(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo54 + 2), false, false, ""}, + + // Double-precision floating point. + equalsTestCase{float64(kTwoTo54 - 2), false, false, ""}, + equalsTestCase{float64(kTwoTo54 - 1), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 0), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 2), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 3), false, false, ""}, + + equalsTestCase{complex128(kTwoTo54 - 2), false, false, ""}, + equalsTestCase{complex128(kTwoTo54 - 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 0), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 2), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// uint +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) SmallUint() { + const kExpected = 17 + matcher := Equals(uint(kExpected)) + ExpectEq("17", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{17, true, false, ""}, + equalsTestCase{17.0, true, false, ""}, + equalsTestCase{17 + 0i, true, false, ""}, + equalsTestCase{int(kExpected), true, false, ""}, + equalsTestCase{int8(kExpected), true, false, ""}, + equalsTestCase{int16(kExpected), true, false, ""}, + equalsTestCase{int32(kExpected), true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint(kExpected), true, false, ""}, + equalsTestCase{uint8(kExpected), true, false, ""}, + equalsTestCase{uint16(kExpected), true, false, ""}, + equalsTestCase{uint32(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{uintptr(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric types. + equalsTestCase{kExpected + 1, false, false, ""}, + equalsTestCase{int(kExpected + 1), false, false, ""}, + equalsTestCase{int8(kExpected + 1), false, false, ""}, + equalsTestCase{int16(kExpected + 1), false, false, ""}, + equalsTestCase{int32(kExpected + 1), false, false, ""}, + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint(kExpected + 1), false, false, ""}, + equalsTestCase{uint8(kExpected + 1), false, false, ""}, + equalsTestCase{uint16(kExpected + 1), false, false, ""}, + equalsTestCase{uint32(kExpected + 1), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{uintptr(kExpected + 1), false, false, ""}, + equalsTestCase{float32(kExpected + 1), false, false, ""}, + equalsTestCase{float64(kExpected + 1), false, false, ""}, + equalsTestCase{complex64(kExpected + 2i), false, false, ""}, + equalsTestCase{complex64(kExpected + 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected + 1), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) LargeUint() { + const kExpected = (1 << 16) + 17 + matcher := Equals(uint(kExpected)) + ExpectEq("65553", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{65553, true, false, ""}, + equalsTestCase{65553.0, true, false, ""}, + equalsTestCase{65553 + 0i, true, false, ""}, + equalsTestCase{int32(kExpected), true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint32(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric types. + equalsTestCase{int16(17), false, false, ""}, + equalsTestCase{int32(kExpected + 1), false, false, ""}, + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint16(17), false, false, ""}, + equalsTestCase{uint32(kExpected + 1), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{float64(kExpected + 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected + 1), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) UintNotExactlyRepresentableBySinglePrecision() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := Equals(uint(kTwoTo25 + 1)) + ExpectEq("33554433", matcher.Description()) + + cases := []equalsTestCase{ + // Integers. + equalsTestCase{int64(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{int64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{int64(kTwoTo25 + 2), false, false, ""}, + + equalsTestCase{uint64(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 2), false, false, ""}, + + // Single-precision floating point. + equalsTestCase{float32(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{float32(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 3), false, false, ""}, + + equalsTestCase{complex64(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{complex64(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 3), false, false, ""}, + + // Double-precision floating point. + equalsTestCase{float64(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{float64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{float64(kTwoTo25 + 2), false, false, ""}, + + equalsTestCase{complex128(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 2), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// uint8 +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) SmallUint8() { + const kExpected = 17 + matcher := Equals(uint8(kExpected)) + ExpectEq("17", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{17, true, false, ""}, + equalsTestCase{17.0, true, false, ""}, + equalsTestCase{17 + 0i, true, false, ""}, + equalsTestCase{int(kExpected), true, false, ""}, + equalsTestCase{int8(kExpected), true, false, ""}, + equalsTestCase{int16(kExpected), true, false, ""}, + equalsTestCase{int32(kExpected), true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint(kExpected), true, false, ""}, + equalsTestCase{uint8(kExpected), true, false, ""}, + equalsTestCase{uint16(kExpected), true, false, ""}, + equalsTestCase{uint32(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{uintptr(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric types. + equalsTestCase{kExpected + 1, false, false, ""}, + equalsTestCase{int(kExpected + 1), false, false, ""}, + equalsTestCase{int8(kExpected + 1), false, false, ""}, + equalsTestCase{int16(kExpected + 1), false, false, ""}, + equalsTestCase{int32(kExpected + 1), false, false, ""}, + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint(kExpected + 1), false, false, ""}, + equalsTestCase{uint8(kExpected + 1), false, false, ""}, + equalsTestCase{uint16(kExpected + 1), false, false, ""}, + equalsTestCase{uint32(kExpected + 1), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{uintptr(kExpected + 1), false, false, ""}, + equalsTestCase{float32(kExpected + 1), false, false, ""}, + equalsTestCase{float64(kExpected + 1), false, false, ""}, + equalsTestCase{complex64(kExpected + 2i), false, false, ""}, + equalsTestCase{complex64(kExpected + 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected + 1), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// uint16 +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) SmallUint16() { + const kExpected = 17 + matcher := Equals(uint16(kExpected)) + ExpectEq("17", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{17, true, false, ""}, + equalsTestCase{17.0, true, false, ""}, + equalsTestCase{17 + 0i, true, false, ""}, + equalsTestCase{int(kExpected), true, false, ""}, + equalsTestCase{int8(kExpected), true, false, ""}, + equalsTestCase{int16(kExpected), true, false, ""}, + equalsTestCase{int32(kExpected), true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint(kExpected), true, false, ""}, + equalsTestCase{uint8(kExpected), true, false, ""}, + equalsTestCase{uint16(kExpected), true, false, ""}, + equalsTestCase{uint32(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{uintptr(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric types. + equalsTestCase{kExpected + 1, false, false, ""}, + equalsTestCase{int(kExpected + 1), false, false, ""}, + equalsTestCase{int8(kExpected + 1), false, false, ""}, + equalsTestCase{int16(kExpected + 1), false, false, ""}, + equalsTestCase{int32(kExpected + 1), false, false, ""}, + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint(kExpected + 1), false, false, ""}, + equalsTestCase{uint8(kExpected + 1), false, false, ""}, + equalsTestCase{uint16(kExpected + 1), false, false, ""}, + equalsTestCase{uint32(kExpected + 1), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{uintptr(kExpected + 1), false, false, ""}, + equalsTestCase{float32(kExpected + 1), false, false, ""}, + equalsTestCase{float64(kExpected + 1), false, false, ""}, + equalsTestCase{complex64(kExpected + 2i), false, false, ""}, + equalsTestCase{complex64(kExpected + 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected + 1), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) LargeUint16() { + const kExpected = (1 << 8) + 17 + matcher := Equals(uint16(kExpected)) + ExpectEq("273", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{273, true, false, ""}, + equalsTestCase{273.0, true, false, ""}, + equalsTestCase{273 + 0i, true, false, ""}, + equalsTestCase{int16(kExpected), true, false, ""}, + equalsTestCase{int32(kExpected), true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint16(kExpected), true, false, ""}, + equalsTestCase{uint32(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric types. + equalsTestCase{int8(17), false, false, ""}, + equalsTestCase{int16(kExpected + 1), false, false, ""}, + equalsTestCase{int32(kExpected + 1), false, false, ""}, + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint8(17), false, false, ""}, + equalsTestCase{uint16(kExpected + 1), false, false, ""}, + equalsTestCase{uint32(kExpected + 1), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{float64(kExpected + 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected + 1), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// uint32 +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) SmallUint32() { + const kExpected = 17 + matcher := Equals(uint32(kExpected)) + ExpectEq("17", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{17, true, false, ""}, + equalsTestCase{17.0, true, false, ""}, + equalsTestCase{17 + 0i, true, false, ""}, + equalsTestCase{int(kExpected), true, false, ""}, + equalsTestCase{int8(kExpected), true, false, ""}, + equalsTestCase{int16(kExpected), true, false, ""}, + equalsTestCase{int32(kExpected), true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint(kExpected), true, false, ""}, + equalsTestCase{uint8(kExpected), true, false, ""}, + equalsTestCase{uint16(kExpected), true, false, ""}, + equalsTestCase{uint32(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{uintptr(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric types. + equalsTestCase{kExpected + 1, false, false, ""}, + equalsTestCase{int(kExpected + 1), false, false, ""}, + equalsTestCase{int8(kExpected + 1), false, false, ""}, + equalsTestCase{int16(kExpected + 1), false, false, ""}, + equalsTestCase{int32(kExpected + 1), false, false, ""}, + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint(kExpected + 1), false, false, ""}, + equalsTestCase{uint8(kExpected + 1), false, false, ""}, + equalsTestCase{uint16(kExpected + 1), false, false, ""}, + equalsTestCase{uint32(kExpected + 1), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{uintptr(kExpected + 1), false, false, ""}, + equalsTestCase{float32(kExpected + 1), false, false, ""}, + equalsTestCase{float64(kExpected + 1), false, false, ""}, + equalsTestCase{complex64(kExpected + 2i), false, false, ""}, + equalsTestCase{complex64(kExpected + 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected + 1), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) LargeUint32() { + const kExpected = (1 << 16) + 17 + matcher := Equals(uint32(kExpected)) + ExpectEq("65553", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{65553, true, false, ""}, + equalsTestCase{65553.0, true, false, ""}, + equalsTestCase{65553 + 0i, true, false, ""}, + equalsTestCase{int32(kExpected), true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint32(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric types. + equalsTestCase{int16(17), false, false, ""}, + equalsTestCase{int32(kExpected + 1), false, false, ""}, + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint16(17), false, false, ""}, + equalsTestCase{uint32(kExpected + 1), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{float64(kExpected + 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected + 1), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) Uint32NotExactlyRepresentableBySinglePrecision() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := Equals(uint32(kTwoTo25 + 1)) + ExpectEq("33554433", matcher.Description()) + + cases := []equalsTestCase{ + // Integers. + equalsTestCase{int64(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{int64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{int64(kTwoTo25 + 2), false, false, ""}, + + equalsTestCase{uint64(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 2), false, false, ""}, + + // Single-precision floating point. + equalsTestCase{float32(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{float32(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 3), false, false, ""}, + + equalsTestCase{complex64(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{complex64(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 3), false, false, ""}, + + // Double-precision floating point. + equalsTestCase{float64(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{float64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{float64(kTwoTo25 + 2), false, false, ""}, + + equalsTestCase{complex128(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 2), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// uint64 +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) SmallUint64() { + const kExpected = 17 + matcher := Equals(uint64(kExpected)) + ExpectEq("17", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{17, true, false, ""}, + equalsTestCase{17.0, true, false, ""}, + equalsTestCase{17 + 0i, true, false, ""}, + equalsTestCase{int(kExpected), true, false, ""}, + equalsTestCase{int8(kExpected), true, false, ""}, + equalsTestCase{int16(kExpected), true, false, ""}, + equalsTestCase{int32(kExpected), true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint(kExpected), true, false, ""}, + equalsTestCase{uint8(kExpected), true, false, ""}, + equalsTestCase{uint16(kExpected), true, false, ""}, + equalsTestCase{uint32(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{uintptr(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric types. + equalsTestCase{kExpected + 1, false, false, ""}, + equalsTestCase{int(kExpected + 1), false, false, ""}, + equalsTestCase{int8(kExpected + 1), false, false, ""}, + equalsTestCase{int16(kExpected + 1), false, false, ""}, + equalsTestCase{int32(kExpected + 1), false, false, ""}, + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint(kExpected + 1), false, false, ""}, + equalsTestCase{uint8(kExpected + 1), false, false, ""}, + equalsTestCase{uint16(kExpected + 1), false, false, ""}, + equalsTestCase{uint32(kExpected + 1), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{uintptr(kExpected + 1), false, false, ""}, + equalsTestCase{float32(kExpected + 1), false, false, ""}, + equalsTestCase{float64(kExpected + 1), false, false, ""}, + equalsTestCase{complex64(kExpected + 2i), false, false, ""}, + equalsTestCase{complex64(kExpected + 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected + 1), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) LargeUint64() { + const kExpected = (1 << 32) + 17 + matcher := Equals(uint64(kExpected)) + ExpectEq("4294967313", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{4294967313.0, true, false, ""}, + equalsTestCase{4294967313 + 0i, true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric types. + equalsTestCase{int(17), false, false, ""}, + equalsTestCase{int32(17), false, false, ""}, + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint(17), false, false, ""}, + equalsTestCase{uint32(17), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{float64(kExpected + 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected + 1), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) Uint64NotExactlyRepresentableBySinglePrecision() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := Equals(uint64(kTwoTo25 + 1)) + ExpectEq("33554433", matcher.Description()) + + cases := []equalsTestCase{ + // Integers. + equalsTestCase{int64(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{int64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{int64(kTwoTo25 + 2), false, false, ""}, + + equalsTestCase{uint64(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 2), false, false, ""}, + + // Single-precision floating point. + equalsTestCase{float32(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{float32(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 3), false, false, ""}, + + equalsTestCase{complex64(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{complex64(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 3), false, false, ""}, + + // Double-precision floating point. + equalsTestCase{float64(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{float64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{float64(kTwoTo25 + 2), false, false, ""}, + + equalsTestCase{complex128(kTwoTo25 + 0), false, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 2), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) Uint64NotExactlyRepresentableByDoublePrecision() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := Equals(uint64(kTwoTo54 + 1)) + ExpectEq("18014398509481985", matcher.Description()) + + cases := []equalsTestCase{ + // Integers. + equalsTestCase{int64(kTwoTo54 + 0), false, false, ""}, + equalsTestCase{int64(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{int64(kTwoTo54 + 2), false, false, ""}, + + equalsTestCase{uint64(kTwoTo54 + 0), false, false, ""}, + equalsTestCase{uint64(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo54 + 2), false, false, ""}, + + // Double-precision floating point. + equalsTestCase{float64(kTwoTo54 - 2), false, false, ""}, + equalsTestCase{float64(kTwoTo54 - 1), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 0), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 2), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 3), false, false, ""}, + + equalsTestCase{complex128(kTwoTo54 - 2), false, false, ""}, + equalsTestCase{complex128(kTwoTo54 - 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 0), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 2), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// uintptr +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) SmallUintptr() { + const kExpected = 17 + matcher := Equals(uintptr(kExpected)) + ExpectEq("17", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{17, true, false, ""}, + equalsTestCase{17.0, true, false, ""}, + equalsTestCase{17 + 0i, true, false, ""}, + equalsTestCase{int(kExpected), true, false, ""}, + equalsTestCase{int8(kExpected), true, false, ""}, + equalsTestCase{int16(kExpected), true, false, ""}, + equalsTestCase{int32(kExpected), true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint(kExpected), true, false, ""}, + equalsTestCase{uint8(kExpected), true, false, ""}, + equalsTestCase{uint16(kExpected), true, false, ""}, + equalsTestCase{uint32(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{uintptr(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric types. + equalsTestCase{kExpected + 1, false, false, ""}, + equalsTestCase{int(kExpected + 1), false, false, ""}, + equalsTestCase{int8(kExpected + 1), false, false, ""}, + equalsTestCase{int16(kExpected + 1), false, false, ""}, + equalsTestCase{int32(kExpected + 1), false, false, ""}, + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint(kExpected + 1), false, false, ""}, + equalsTestCase{uint8(kExpected + 1), false, false, ""}, + equalsTestCase{uint16(kExpected + 1), false, false, ""}, + equalsTestCase{uint32(kExpected + 1), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{uintptr(kExpected + 1), false, false, ""}, + equalsTestCase{float32(kExpected + 1), false, false, ""}, + equalsTestCase{float64(kExpected + 1), false, false, ""}, + equalsTestCase{complex64(kExpected + 2i), false, false, ""}, + equalsTestCase{complex64(kExpected + 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected + 1), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) LargeUintptr() { + const kExpected = (1 << 32) + 17 + matcher := Equals(uintptr(kExpected)) + ExpectEq("4294967313", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{4294967313.0, true, false, ""}, + equalsTestCase{4294967313 + 0i, true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{uintptr(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric types. + equalsTestCase{int(17), false, false, ""}, + equalsTestCase{int32(17), false, false, ""}, + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint(17), false, false, ""}, + equalsTestCase{uint32(17), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{uintptr(kExpected + 1), false, false, ""}, + equalsTestCase{float64(kExpected + 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected + 1), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// float32 +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NegativeIntegralFloat32() { + matcher := Equals(float32(-32769)) + ExpectEq("-32769", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of -32769. + equalsTestCase{-32769.0, true, false, ""}, + equalsTestCase{-32769 + 0i, true, false, ""}, + equalsTestCase{int32(-32769), true, false, ""}, + equalsTestCase{int64(-32769), true, false, ""}, + equalsTestCase{float32(-32769), true, false, ""}, + equalsTestCase{float64(-32769), true, false, ""}, + equalsTestCase{complex64(-32769), true, false, ""}, + equalsTestCase{complex128(-32769), true, false, ""}, + equalsTestCase{interface{}(float32(-32769)), true, false, ""}, + equalsTestCase{interface{}(int64(-32769)), true, false, ""}, + + // Values that would be -32769 in two's complement. + equalsTestCase{uint64((1 << 64) - 32769), false, false, ""}, + equalsTestCase{uintptr((1 << 64) - 32769), false, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(-32770), false, false, ""}, + equalsTestCase{float32(-32769.1), false, false, ""}, + equalsTestCase{float32(-32768.9), false, false, ""}, + equalsTestCase{float64(-32769.1), false, false, ""}, + equalsTestCase{float64(-32768.9), false, false, ""}, + equalsTestCase{complex128(-32768), false, false, ""}, + equalsTestCase{complex128(-32769 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) NegativeNonIntegralFloat32() { + matcher := Equals(float32(-32769.1)) + ExpectEq("-32769.1", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of -32769.1. + equalsTestCase{-32769.1, true, false, ""}, + equalsTestCase{-32769.1 + 0i, true, false, ""}, + equalsTestCase{float32(-32769.1), true, false, ""}, + equalsTestCase{float64(-32769.1), true, false, ""}, + equalsTestCase{complex64(-32769.1), true, false, ""}, + equalsTestCase{complex128(-32769.1), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int32(-32769), false, false, ""}, + equalsTestCase{int32(-32770), false, false, ""}, + equalsTestCase{int64(-32769), false, false, ""}, + equalsTestCase{int64(-32770), false, false, ""}, + equalsTestCase{float32(-32769.2), false, false, ""}, + equalsTestCase{float32(-32769.0), false, false, ""}, + equalsTestCase{float64(-32769.2), false, false, ""}, + equalsTestCase{complex128(-32769.1 + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) LargeNegativeFloat32() { + const kExpected = -1 * (1 << 65) + matcher := Equals(float32(kExpected)) + ExpectEq("-3.689349e+19", matcher.Description()) + + floatExpected := float32(kExpected) + castedInt := int64(floatExpected) + + cases := []equalsTestCase{ + // Equal values of numeric type. + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{castedInt, false, false, ""}, + equalsTestCase{int64(0), false, false, ""}, + equalsTestCase{int64(math.MinInt64), false, false, ""}, + equalsTestCase{int64(math.MaxInt64), false, false, ""}, + equalsTestCase{float32(kExpected / 2), false, false, ""}, + equalsTestCase{float64(kExpected / 2), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) ZeroFloat32() { + matcher := Equals(float32(0)) + ExpectEq("0", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of zero. + equalsTestCase{0.0, true, false, ""}, + equalsTestCase{0 + 0i, true, false, ""}, + equalsTestCase{int(0), true, false, ""}, + equalsTestCase{int8(0), true, false, ""}, + equalsTestCase{int16(0), true, false, ""}, + equalsTestCase{int32(0), true, false, ""}, + equalsTestCase{int64(0), true, false, ""}, + equalsTestCase{uint(0), true, false, ""}, + equalsTestCase{uint8(0), true, false, ""}, + equalsTestCase{uint16(0), true, false, ""}, + equalsTestCase{uint32(0), true, false, ""}, + equalsTestCase{uint64(0), true, false, ""}, + equalsTestCase{uintptr(0), true, false, ""}, + equalsTestCase{float32(0), true, false, ""}, + equalsTestCase{float64(0), true, false, ""}, + equalsTestCase{complex64(0), true, false, ""}, + equalsTestCase{complex128(0), true, false, ""}, + equalsTestCase{interface{}(float32(0)), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(1), false, false, ""}, + equalsTestCase{int64(-1), false, false, ""}, + equalsTestCase{float32(1), false, false, ""}, + equalsTestCase{float32(-1), false, false, ""}, + equalsTestCase{complex128(0 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveIntegralFloat32() { + matcher := Equals(float32(32769)) + ExpectEq("32769", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 32769. + equalsTestCase{32769.0, true, false, ""}, + equalsTestCase{32769 + 0i, true, false, ""}, + equalsTestCase{int(32769), true, false, ""}, + equalsTestCase{int32(32769), true, false, ""}, + equalsTestCase{int64(32769), true, false, ""}, + equalsTestCase{uint(32769), true, false, ""}, + equalsTestCase{uint32(32769), true, false, ""}, + equalsTestCase{uint64(32769), true, false, ""}, + equalsTestCase{uintptr(32769), true, false, ""}, + equalsTestCase{float32(32769), true, false, ""}, + equalsTestCase{float64(32769), true, false, ""}, + equalsTestCase{complex64(32769), true, false, ""}, + equalsTestCase{complex128(32769), true, false, ""}, + equalsTestCase{interface{}(float32(32769)), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(32770), false, false, ""}, + equalsTestCase{uint64(32770), false, false, ""}, + equalsTestCase{float32(32769.1), false, false, ""}, + equalsTestCase{float32(32768.9), false, false, ""}, + equalsTestCase{float64(32769.1), false, false, ""}, + equalsTestCase{float64(32768.9), false, false, ""}, + equalsTestCase{complex128(32768), false, false, ""}, + equalsTestCase{complex128(32769 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveNonIntegralFloat32() { + matcher := Equals(float32(32769.1)) + ExpectEq("32769.1", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 32769.1. + equalsTestCase{32769.1, true, false, ""}, + equalsTestCase{32769.1 + 0i, true, false, ""}, + equalsTestCase{float32(32769.1), true, false, ""}, + equalsTestCase{float64(32769.1), true, false, ""}, + equalsTestCase{complex64(32769.1), true, false, ""}, + equalsTestCase{complex128(32769.1), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int32(32769), false, false, ""}, + equalsTestCase{int32(32770), false, false, ""}, + equalsTestCase{uint64(32769), false, false, ""}, + equalsTestCase{uint64(32770), false, false, ""}, + equalsTestCase{float32(32769.2), false, false, ""}, + equalsTestCase{float32(32769.0), false, false, ""}, + equalsTestCase{float64(32769.2), false, false, ""}, + equalsTestCase{complex128(32769.1 + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) LargePositiveFloat32() { + const kExpected = 1 << 65 + matcher := Equals(float32(kExpected)) + ExpectEq("3.689349e+19", matcher.Description()) + + floatExpected := float32(kExpected) + castedInt := uint64(floatExpected) + + cases := []equalsTestCase{ + // Equal values of numeric type. + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{castedInt, false, false, ""}, + equalsTestCase{int64(0), false, false, ""}, + equalsTestCase{int64(math.MinInt64), false, false, ""}, + equalsTestCase{int64(math.MaxInt64), false, false, ""}, + equalsTestCase{uint64(0), false, false, ""}, + equalsTestCase{uint64(math.MaxUint64), false, false, ""}, + equalsTestCase{float32(kExpected / 2), false, false, ""}, + equalsTestCase{float64(kExpected / 2), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) Float32AboveExactIntegerRange() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := Equals(float32(kTwoTo25 + 1)) + ExpectEq("3.3554432e+07", matcher.Description()) + + cases := []equalsTestCase{ + // Integers. + equalsTestCase{int64(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{int64(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{int64(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{int64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{int64(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{int64(kTwoTo25 + 3), false, false, ""}, + + equalsTestCase{uint64(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{uint64(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 3), false, false, ""}, + + // Single-precision floating point. + equalsTestCase{float32(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{float32(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 3), false, false, ""}, + + equalsTestCase{complex64(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{complex64(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 3), false, false, ""}, + + // Double-precision floating point. + equalsTestCase{float64(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{float64(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{float64(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{float64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{float64(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{float64(kTwoTo25 + 3), false, false, ""}, + + equalsTestCase{complex128(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{complex128(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// float64 +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NegativeIntegralFloat64() { + const kExpected = -(1 << 50) + matcher := Equals(float64(kExpected)) + ExpectEq("-1.125899906842624e+15", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{-1125899906842624.0, true, false, ""}, + equalsTestCase{-1125899906842624.0 + 0i, true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + equalsTestCase{interface{}(float64(kExpected)), true, false, ""}, + + // Values that would be kExpected in two's complement. + equalsTestCase{uint64((1 << 64) + kExpected), false, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, + equalsTestCase{float32(kExpected + (1 << 30)), false, false, ""}, + equalsTestCase{float64(kExpected - 0.5), false, false, ""}, + equalsTestCase{float64(kExpected + 0.5), false, false, ""}, + equalsTestCase{complex128(kExpected - 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) NegativeNonIntegralFloat64() { + const kTwoTo50 = 1 << 50 + const kExpected = -kTwoTo50 - 0.25 + + matcher := Equals(float64(kExpected)) + ExpectEq("-1.1258999068426242e+15", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{kExpected, true, false, ""}, + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(-kTwoTo50), false, false, ""}, + equalsTestCase{int64(-kTwoTo50 - 1), false, false, ""}, + equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, + equalsTestCase{float64(kExpected - 0.25), false, false, ""}, + equalsTestCase{float64(kExpected + 0.25), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) LargeNegativeFloat64() { + const kExpected = -1 * (1 << 65) + matcher := Equals(float64(kExpected)) + ExpectEq("-3.6893488147419103e+19", matcher.Description()) + + floatExpected := float64(kExpected) + castedInt := int64(floatExpected) + + cases := []equalsTestCase{ + // Equal values of numeric type. + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{castedInt, false, false, ""}, + equalsTestCase{int64(0), false, false, ""}, + equalsTestCase{int64(math.MinInt64), false, false, ""}, + equalsTestCase{int64(math.MaxInt64), false, false, ""}, + equalsTestCase{float32(kExpected / 2), false, false, ""}, + equalsTestCase{float64(kExpected / 2), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) ZeroFloat64() { + matcher := Equals(float64(0)) + ExpectEq("0", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of zero. + equalsTestCase{0.0, true, false, ""}, + equalsTestCase{0 + 0i, true, false, ""}, + equalsTestCase{int(0), true, false, ""}, + equalsTestCase{int8(0), true, false, ""}, + equalsTestCase{int16(0), true, false, ""}, + equalsTestCase{int32(0), true, false, ""}, + equalsTestCase{int64(0), true, false, ""}, + equalsTestCase{uint(0), true, false, ""}, + equalsTestCase{uint8(0), true, false, ""}, + equalsTestCase{uint16(0), true, false, ""}, + equalsTestCase{uint32(0), true, false, ""}, + equalsTestCase{uint64(0), true, false, ""}, + equalsTestCase{uintptr(0), true, false, ""}, + equalsTestCase{float32(0), true, false, ""}, + equalsTestCase{float64(0), true, false, ""}, + equalsTestCase{complex64(0), true, false, ""}, + equalsTestCase{complex128(0), true, false, ""}, + equalsTestCase{interface{}(float32(0)), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(1), false, false, ""}, + equalsTestCase{int64(-1), false, false, ""}, + equalsTestCase{float32(1), false, false, ""}, + equalsTestCase{float32(-1), false, false, ""}, + equalsTestCase{complex128(0 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveIntegralFloat64() { + const kExpected = 1 << 50 + matcher := Equals(float64(kExpected)) + ExpectEq("1.125899906842624e+15", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 32769. + equalsTestCase{1125899906842624.0, true, false, ""}, + equalsTestCase{1125899906842624.0 + 0i, true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{uintptr(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + equalsTestCase{interface{}(float64(kExpected)), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{uintptr(kExpected + 1), false, false, ""}, + equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, + equalsTestCase{float32(kExpected + (1 << 30)), false, false, ""}, + equalsTestCase{float64(kExpected - 0.5), false, false, ""}, + equalsTestCase{float64(kExpected + 0.5), false, false, ""}, + equalsTestCase{complex128(kExpected - 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveNonIntegralFloat64() { + const kTwoTo50 = 1 << 50 + const kExpected = kTwoTo50 + 0.25 + matcher := Equals(float64(kExpected)) + ExpectEq("1.1258999068426242e+15", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{kExpected, true, false, ""}, + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(kTwoTo50), false, false, ""}, + equalsTestCase{int64(kTwoTo50 - 1), false, false, ""}, + equalsTestCase{float64(kExpected - 0.25), false, false, ""}, + equalsTestCase{float64(kExpected + 0.25), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) LargePositiveFloat64() { + const kExpected = 1 << 65 + matcher := Equals(float64(kExpected)) + ExpectEq("3.6893488147419103e+19", matcher.Description()) + + floatExpected := float64(kExpected) + castedInt := uint64(floatExpected) + + cases := []equalsTestCase{ + // Equal values of numeric type. + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{castedInt, false, false, ""}, + equalsTestCase{int64(0), false, false, ""}, + equalsTestCase{int64(math.MinInt64), false, false, ""}, + equalsTestCase{int64(math.MaxInt64), false, false, ""}, + equalsTestCase{uint64(0), false, false, ""}, + equalsTestCase{uint64(math.MaxUint64), false, false, ""}, + equalsTestCase{float32(kExpected / 2), false, false, ""}, + equalsTestCase{float64(kExpected / 2), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) Float64AboveExactIntegerRange() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := Equals(float64(kTwoTo54 + 1)) + ExpectEq("1.8014398509481984e+16", matcher.Description()) + + cases := []equalsTestCase{ + // Integers. + equalsTestCase{int64(kTwoTo54 - 2), false, false, ""}, + equalsTestCase{int64(kTwoTo54 - 1), true, false, ""}, + equalsTestCase{int64(kTwoTo54 + 0), true, false, ""}, + equalsTestCase{int64(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{int64(kTwoTo54 + 2), true, false, ""}, + equalsTestCase{int64(kTwoTo54 + 3), false, false, ""}, + + equalsTestCase{uint64(kTwoTo54 - 2), false, false, ""}, + equalsTestCase{uint64(kTwoTo54 - 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo54 + 0), true, false, ""}, + equalsTestCase{uint64(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo54 + 2), true, false, ""}, + equalsTestCase{uint64(kTwoTo54 + 3), false, false, ""}, + + // Double-precision floating point. + equalsTestCase{float64(kTwoTo54 - 2), false, false, ""}, + equalsTestCase{float64(kTwoTo54 - 1), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 0), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 2), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 3), false, false, ""}, + + equalsTestCase{complex128(kTwoTo54 - 2), false, false, ""}, + equalsTestCase{complex128(kTwoTo54 - 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 0), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 2), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// complex64 +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NegativeIntegralComplex64() { + const kExpected = -32769 + matcher := Equals(complex64(kExpected)) + ExpectEq("(-32769+0i)", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{-32769.0, true, false, ""}, + equalsTestCase{-32769.0 + 0i, true, false, ""}, + equalsTestCase{int(kExpected), true, false, ""}, + equalsTestCase{int32(kExpected), true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + equalsTestCase{interface{}(float64(kExpected)), true, false, ""}, + + // Values that would be kExpected in two's complement. + equalsTestCase{uint32((1 << 32) + kExpected), false, false, ""}, + equalsTestCase{uint64((1 << 64) + kExpected), false, false, ""}, + equalsTestCase{uintptr((1 << 64) + kExpected), false, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, + equalsTestCase{float32(kExpected + (1 << 30)), false, false, ""}, + equalsTestCase{float64(kExpected - 0.5), false, false, ""}, + equalsTestCase{float64(kExpected + 0.5), false, false, ""}, + equalsTestCase{complex64(kExpected - 1), false, false, ""}, + equalsTestCase{complex64(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected - 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) NegativeNonIntegralComplex64() { + const kTwoTo20 = 1 << 20 + const kExpected = -kTwoTo20 - 0.25 + + matcher := Equals(complex64(kExpected)) + ExpectEq("(-1.0485762e+06+0i)", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{kExpected, true, false, ""}, + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(-kTwoTo20), false, false, ""}, + equalsTestCase{int(-kTwoTo20 - 1), false, false, ""}, + equalsTestCase{int32(-kTwoTo20), false, false, ""}, + equalsTestCase{int32(-kTwoTo20 - 1), false, false, ""}, + equalsTestCase{int64(-kTwoTo20), false, false, ""}, + equalsTestCase{int64(-kTwoTo20 - 1), false, false, ""}, + equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, + equalsTestCase{float64(kExpected - 0.25), false, false, ""}, + equalsTestCase{float64(kExpected + 0.25), false, false, ""}, + equalsTestCase{complex64(kExpected - 0.75), false, false, ""}, + equalsTestCase{complex64(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected - 0.75), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) LargeNegativeComplex64() { + const kExpected = -1 * (1 << 65) + matcher := Equals(complex64(kExpected)) + ExpectEq("(-3.689349e+19+0i)", matcher.Description()) + + floatExpected := float64(kExpected) + castedInt := int64(floatExpected) + + cases := []equalsTestCase{ + // Equal values of numeric type. + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{castedInt, false, false, ""}, + equalsTestCase{int64(0), false, false, ""}, + equalsTestCase{int64(math.MinInt64), false, false, ""}, + equalsTestCase{int64(math.MaxInt64), false, false, ""}, + equalsTestCase{float32(kExpected / 2), false, false, ""}, + equalsTestCase{float64(kExpected / 2), false, false, ""}, + equalsTestCase{complex64(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) ZeroComplex64() { + matcher := Equals(complex64(0)) + ExpectEq("(0+0i)", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of zero. + equalsTestCase{0.0, true, false, ""}, + equalsTestCase{0 + 0i, true, false, ""}, + equalsTestCase{int(0), true, false, ""}, + equalsTestCase{int8(0), true, false, ""}, + equalsTestCase{int16(0), true, false, ""}, + equalsTestCase{int32(0), true, false, ""}, + equalsTestCase{int64(0), true, false, ""}, + equalsTestCase{uint(0), true, false, ""}, + equalsTestCase{uint8(0), true, false, ""}, + equalsTestCase{uint16(0), true, false, ""}, + equalsTestCase{uint32(0), true, false, ""}, + equalsTestCase{uint64(0), true, false, ""}, + equalsTestCase{uintptr(0), true, false, ""}, + equalsTestCase{float32(0), true, false, ""}, + equalsTestCase{float64(0), true, false, ""}, + equalsTestCase{complex64(0), true, false, ""}, + equalsTestCase{complex128(0), true, false, ""}, + equalsTestCase{interface{}(float32(0)), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(1), false, false, ""}, + equalsTestCase{int64(-1), false, false, ""}, + equalsTestCase{float32(1), false, false, ""}, + equalsTestCase{float32(-1), false, false, ""}, + equalsTestCase{float64(1), false, false, ""}, + equalsTestCase{float64(-1), false, false, ""}, + equalsTestCase{complex64(0 + 2i), false, false, ""}, + equalsTestCase{complex128(0 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveIntegralComplex64() { + const kExpected = 1 << 20 + matcher := Equals(complex64(kExpected)) + ExpectEq("(1.048576e+06+0i)", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 32769. + equalsTestCase{1048576.0, true, false, ""}, + equalsTestCase{1048576.0 + 0i, true, false, ""}, + equalsTestCase{int(kExpected), true, false, ""}, + equalsTestCase{int32(kExpected), true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint(kExpected), true, false, ""}, + equalsTestCase{uint32(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{uintptr(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + equalsTestCase{interface{}(float64(kExpected)), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(kExpected + 1), false, false, ""}, + equalsTestCase{int32(kExpected + 1), false, false, ""}, + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint(kExpected + 1), false, false, ""}, + equalsTestCase{uint32(kExpected + 1), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{uintptr(kExpected + 1), false, false, ""}, + equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, + equalsTestCase{float32(kExpected + (1 << 30)), false, false, ""}, + equalsTestCase{float64(kExpected - 0.5), false, false, ""}, + equalsTestCase{float64(kExpected + 0.5), false, false, ""}, + equalsTestCase{complex128(kExpected - 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveNonIntegralComplex64() { + const kTwoTo20 = 1 << 20 + const kExpected = kTwoTo20 + 0.25 + matcher := Equals(complex64(kExpected)) + ExpectEq("(1.0485762e+06+0i)", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{kExpected, true, false, ""}, + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(kTwoTo20), false, false, ""}, + equalsTestCase{int64(kTwoTo20 - 1), false, false, ""}, + equalsTestCase{uint64(kTwoTo20), false, false, ""}, + equalsTestCase{uint64(kTwoTo20 - 1), false, false, ""}, + equalsTestCase{float32(kExpected - 1), false, false, ""}, + equalsTestCase{float32(kExpected + 1), false, false, ""}, + equalsTestCase{float64(kExpected - 0.25), false, false, ""}, + equalsTestCase{float64(kExpected + 0.25), false, false, ""}, + equalsTestCase{complex64(kExpected - 1), false, false, ""}, + equalsTestCase{complex64(kExpected - 1i), false, false, ""}, + equalsTestCase{complex128(kExpected - 1), false, false, ""}, + equalsTestCase{complex128(kExpected - 1i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) LargePositiveComplex64() { + const kExpected = 1 << 65 + matcher := Equals(complex64(kExpected)) + ExpectEq("(3.689349e+19+0i)", matcher.Description()) + + floatExpected := float64(kExpected) + castedInt := uint64(floatExpected) + + cases := []equalsTestCase{ + // Equal values of numeric type. + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{castedInt, false, false, ""}, + equalsTestCase{int64(0), false, false, ""}, + equalsTestCase{int64(math.MinInt64), false, false, ""}, + equalsTestCase{int64(math.MaxInt64), false, false, ""}, + equalsTestCase{uint64(0), false, false, ""}, + equalsTestCase{uint64(math.MaxUint64), false, false, ""}, + equalsTestCase{float32(kExpected / 2), false, false, ""}, + equalsTestCase{float64(kExpected / 2), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) Complex64AboveExactIntegerRange() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := Equals(complex64(kTwoTo25 + 1)) + ExpectEq("(3.3554432e+07+0i)", matcher.Description()) + + cases := []equalsTestCase{ + // Integers. + equalsTestCase{int64(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{int64(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{int64(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{int64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{int64(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{int64(kTwoTo25 + 3), false, false, ""}, + + equalsTestCase{uint64(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{uint64(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{uint64(kTwoTo25 + 3), false, false, ""}, + + // Single-precision floating point. + equalsTestCase{float32(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{float32(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{float32(kTwoTo25 + 3), false, false, ""}, + + equalsTestCase{complex64(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{complex64(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{complex64(kTwoTo25 + 3), false, false, ""}, + + // Double-precision floating point. + equalsTestCase{float64(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{float64(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{float64(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{float64(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{float64(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{float64(kTwoTo25 + 3), false, false, ""}, + + equalsTestCase{complex128(kTwoTo25 - 2), false, false, ""}, + equalsTestCase{complex128(kTwoTo25 - 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 0), true, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 2), true, false, ""}, + equalsTestCase{complex128(kTwoTo25 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) Complex64WithNonZeroImaginaryPart() { + const kRealPart = 17 + const kImagPart = 0.25i + const kExpected = kRealPart + kImagPart + matcher := Equals(complex64(kExpected)) + ExpectEq("(17+0.25i)", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{kExpected, true, false, ""}, + equalsTestCase{kRealPart + kImagPart, true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(kRealPart), false, false, ""}, + equalsTestCase{int8(kRealPart), false, false, ""}, + equalsTestCase{int16(kRealPart), false, false, ""}, + equalsTestCase{int32(kRealPart), false, false, ""}, + equalsTestCase{int64(kRealPart), false, false, ""}, + equalsTestCase{uint(kRealPart), false, false, ""}, + equalsTestCase{uint8(kRealPart), false, false, ""}, + equalsTestCase{uint16(kRealPart), false, false, ""}, + equalsTestCase{uint32(kRealPart), false, false, ""}, + equalsTestCase{uint64(kRealPart), false, false, ""}, + equalsTestCase{float32(kRealPart), false, false, ""}, + equalsTestCase{float64(kRealPart), false, false, ""}, + equalsTestCase{complex64(kRealPart), false, false, ""}, + equalsTestCase{complex64(kRealPart + kImagPart + 0.5), false, false, ""}, + equalsTestCase{complex64(kRealPart + kImagPart + 0.5i), false, false, ""}, + equalsTestCase{complex128(kRealPart), false, false, ""}, + equalsTestCase{complex128(kRealPart + kImagPart + 0.5), false, false, ""}, + equalsTestCase{complex128(kRealPart + kImagPart + 0.5i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// complex128 +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NegativeIntegralComplex128() { + const kExpected = -32769 + matcher := Equals(complex128(kExpected)) + ExpectEq("(-32769+0i)", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{-32769.0, true, false, ""}, + equalsTestCase{-32769.0 + 0i, true, false, ""}, + equalsTestCase{int(kExpected), true, false, ""}, + equalsTestCase{int32(kExpected), true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + equalsTestCase{interface{}(float64(kExpected)), true, false, ""}, + + // Values that would be kExpected in two's complement. + equalsTestCase{uint32((1 << 32) + kExpected), false, false, ""}, + equalsTestCase{uint64((1 << 64) + kExpected), false, false, ""}, + equalsTestCase{uintptr((1 << 64) + kExpected), false, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, + equalsTestCase{float32(kExpected + (1 << 30)), false, false, ""}, + equalsTestCase{float64(kExpected - 0.5), false, false, ""}, + equalsTestCase{float64(kExpected + 0.5), false, false, ""}, + equalsTestCase{complex64(kExpected - 1), false, false, ""}, + equalsTestCase{complex64(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected - 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) NegativeNonIntegralComplex128() { + const kTwoTo20 = 1 << 20 + const kExpected = -kTwoTo20 - 0.25 + + matcher := Equals(complex128(kExpected)) + ExpectEq("(-1.04857625e+06+0i)", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{kExpected, true, false, ""}, + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(-kTwoTo20), false, false, ""}, + equalsTestCase{int(-kTwoTo20 - 1), false, false, ""}, + equalsTestCase{int32(-kTwoTo20), false, false, ""}, + equalsTestCase{int32(-kTwoTo20 - 1), false, false, ""}, + equalsTestCase{int64(-kTwoTo20), false, false, ""}, + equalsTestCase{int64(-kTwoTo20 - 1), false, false, ""}, + equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, + equalsTestCase{float64(kExpected - 0.25), false, false, ""}, + equalsTestCase{float64(kExpected + 0.25), false, false, ""}, + equalsTestCase{complex64(kExpected - 0.75), false, false, ""}, + equalsTestCase{complex64(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected - 0.75), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) LargeNegativeComplex128() { + const kExpected = -1 * (1 << 65) + matcher := Equals(complex128(kExpected)) + ExpectEq("(-3.6893488147419103e+19+0i)", matcher.Description()) + + floatExpected := float64(kExpected) + castedInt := int64(floatExpected) + + cases := []equalsTestCase{ + // Equal values of numeric type. + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{castedInt, false, false, ""}, + equalsTestCase{int64(0), false, false, ""}, + equalsTestCase{int64(math.MinInt64), false, false, ""}, + equalsTestCase{int64(math.MaxInt64), false, false, ""}, + equalsTestCase{float32(kExpected / 2), false, false, ""}, + equalsTestCase{float64(kExpected / 2), false, false, ""}, + equalsTestCase{complex64(kExpected + 2i), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) ZeroComplex128() { + matcher := Equals(complex128(0)) + ExpectEq("(0+0i)", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of zero. + equalsTestCase{0.0, true, false, ""}, + equalsTestCase{0 + 0i, true, false, ""}, + equalsTestCase{int(0), true, false, ""}, + equalsTestCase{int8(0), true, false, ""}, + equalsTestCase{int16(0), true, false, ""}, + equalsTestCase{int32(0), true, false, ""}, + equalsTestCase{int64(0), true, false, ""}, + equalsTestCase{uint(0), true, false, ""}, + equalsTestCase{uint8(0), true, false, ""}, + equalsTestCase{uint16(0), true, false, ""}, + equalsTestCase{uint32(0), true, false, ""}, + equalsTestCase{uint64(0), true, false, ""}, + equalsTestCase{uintptr(0), true, false, ""}, + equalsTestCase{float32(0), true, false, ""}, + equalsTestCase{float64(0), true, false, ""}, + equalsTestCase{complex64(0), true, false, ""}, + equalsTestCase{complex128(0), true, false, ""}, + equalsTestCase{interface{}(float32(0)), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(1), false, false, ""}, + equalsTestCase{int64(-1), false, false, ""}, + equalsTestCase{float32(1), false, false, ""}, + equalsTestCase{float32(-1), false, false, ""}, + equalsTestCase{float64(1), false, false, ""}, + equalsTestCase{float64(-1), false, false, ""}, + equalsTestCase{complex64(0 + 2i), false, false, ""}, + equalsTestCase{complex128(0 + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveIntegralComplex128() { + const kExpected = 1 << 20 + matcher := Equals(complex128(kExpected)) + ExpectEq("(1.048576e+06+0i)", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of 32769. + equalsTestCase{1048576.0, true, false, ""}, + equalsTestCase{1048576.0 + 0i, true, false, ""}, + equalsTestCase{int(kExpected), true, false, ""}, + equalsTestCase{int32(kExpected), true, false, ""}, + equalsTestCase{int64(kExpected), true, false, ""}, + equalsTestCase{uint(kExpected), true, false, ""}, + equalsTestCase{uint32(kExpected), true, false, ""}, + equalsTestCase{uint64(kExpected), true, false, ""}, + equalsTestCase{uintptr(kExpected), true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + equalsTestCase{interface{}(float64(kExpected)), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(kExpected + 1), false, false, ""}, + equalsTestCase{int32(kExpected + 1), false, false, ""}, + equalsTestCase{int64(kExpected + 1), false, false, ""}, + equalsTestCase{uint(kExpected + 1), false, false, ""}, + equalsTestCase{uint32(kExpected + 1), false, false, ""}, + equalsTestCase{uint64(kExpected + 1), false, false, ""}, + equalsTestCase{uintptr(kExpected + 1), false, false, ""}, + equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, + equalsTestCase{float32(kExpected + (1 << 30)), false, false, ""}, + equalsTestCase{float64(kExpected - 0.5), false, false, ""}, + equalsTestCase{float64(kExpected + 0.5), false, false, ""}, + equalsTestCase{complex128(kExpected - 1), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + + // Non-numeric types. + equalsTestCase{true, false, true, "which is not numeric"}, + equalsTestCase{[...]int{}, false, true, "which is not numeric"}, + equalsTestCase{make(chan int), false, true, "which is not numeric"}, + equalsTestCase{func() {}, false, true, "which is not numeric"}, + equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, + equalsTestCase{&someInt, false, true, "which is not numeric"}, + equalsTestCase{[]int{}, false, true, "which is not numeric"}, + equalsTestCase{"taco", false, true, "which is not numeric"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) PositiveNonIntegralComplex128() { + const kTwoTo20 = 1 << 20 + const kExpected = kTwoTo20 + 0.25 + matcher := Equals(complex128(kExpected)) + ExpectEq("(1.04857625e+06+0i)", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{kExpected, true, false, ""}, + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int64(kTwoTo20), false, false, ""}, + equalsTestCase{int64(kTwoTo20 - 1), false, false, ""}, + equalsTestCase{uint64(kTwoTo20), false, false, ""}, + equalsTestCase{uint64(kTwoTo20 - 1), false, false, ""}, + equalsTestCase{float32(kExpected - 1), false, false, ""}, + equalsTestCase{float32(kExpected + 1), false, false, ""}, + equalsTestCase{float64(kExpected - 0.25), false, false, ""}, + equalsTestCase{float64(kExpected + 0.25), false, false, ""}, + equalsTestCase{complex64(kExpected - 1), false, false, ""}, + equalsTestCase{complex64(kExpected - 1i), false, false, ""}, + equalsTestCase{complex128(kExpected - 1), false, false, ""}, + equalsTestCase{complex128(kExpected - 1i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) LargePositiveComplex128() { + const kExpected = 1 << 65 + matcher := Equals(complex128(kExpected)) + ExpectEq("(3.6893488147419103e+19+0i)", matcher.Description()) + + floatExpected := float64(kExpected) + castedInt := uint64(floatExpected) + + cases := []equalsTestCase{ + // Equal values of numeric type. + equalsTestCase{kExpected + 0i, true, false, ""}, + equalsTestCase{float32(kExpected), true, false, ""}, + equalsTestCase{float64(kExpected), true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{castedInt, false, false, ""}, + equalsTestCase{int64(0), false, false, ""}, + equalsTestCase{int64(math.MinInt64), false, false, ""}, + equalsTestCase{int64(math.MaxInt64), false, false, ""}, + equalsTestCase{uint64(0), false, false, ""}, + equalsTestCase{uint64(math.MaxUint64), false, false, ""}, + equalsTestCase{float32(kExpected / 2), false, false, ""}, + equalsTestCase{float64(kExpected / 2), false, false, ""}, + equalsTestCase{complex128(kExpected + 2i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) Complex128AboveExactIntegerRange() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := Equals(complex128(kTwoTo54 + 1)) + ExpectEq("(1.8014398509481984e+16+0i)", matcher.Description()) + + cases := []equalsTestCase{ + // Integers. + equalsTestCase{int64(kTwoTo54 - 2), false, false, ""}, + equalsTestCase{int64(kTwoTo54 - 1), true, false, ""}, + equalsTestCase{int64(kTwoTo54 + 0), true, false, ""}, + equalsTestCase{int64(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{int64(kTwoTo54 + 2), true, false, ""}, + equalsTestCase{int64(kTwoTo54 + 3), false, false, ""}, + + equalsTestCase{uint64(kTwoTo54 - 2), false, false, ""}, + equalsTestCase{uint64(kTwoTo54 - 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo54 + 0), true, false, ""}, + equalsTestCase{uint64(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{uint64(kTwoTo54 + 2), true, false, ""}, + equalsTestCase{uint64(kTwoTo54 + 3), false, false, ""}, + + // Double-precision floating point. + equalsTestCase{float64(kTwoTo54 - 2), false, false, ""}, + equalsTestCase{float64(kTwoTo54 - 1), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 0), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 2), true, false, ""}, + equalsTestCase{float64(kTwoTo54 + 3), false, false, ""}, + + equalsTestCase{complex128(kTwoTo54 - 2), false, false, ""}, + equalsTestCase{complex128(kTwoTo54 - 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 0), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 1), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 2), true, false, ""}, + equalsTestCase{complex128(kTwoTo54 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) Complex128WithNonZeroImaginaryPart() { + const kRealPart = 17 + const kImagPart = 0.25i + const kExpected = kRealPart + kImagPart + matcher := Equals(complex128(kExpected)) + ExpectEq("(17+0.25i)", matcher.Description()) + + cases := []equalsTestCase{ + // Various types of the expected value. + equalsTestCase{kExpected, true, false, ""}, + equalsTestCase{kRealPart + kImagPart, true, false, ""}, + equalsTestCase{complex64(kExpected), true, false, ""}, + equalsTestCase{complex128(kExpected), true, false, ""}, + + // Non-equal values of numeric type. + equalsTestCase{int(kRealPart), false, false, ""}, + equalsTestCase{int8(kRealPart), false, false, ""}, + equalsTestCase{int16(kRealPart), false, false, ""}, + equalsTestCase{int32(kRealPart), false, false, ""}, + equalsTestCase{int64(kRealPart), false, false, ""}, + equalsTestCase{uint(kRealPart), false, false, ""}, + equalsTestCase{uint8(kRealPart), false, false, ""}, + equalsTestCase{uint16(kRealPart), false, false, ""}, + equalsTestCase{uint32(kRealPart), false, false, ""}, + equalsTestCase{uint64(kRealPart), false, false, ""}, + equalsTestCase{float32(kRealPart), false, false, ""}, + equalsTestCase{float64(kRealPart), false, false, ""}, + equalsTestCase{complex64(kRealPart), false, false, ""}, + equalsTestCase{complex64(kRealPart + kImagPart + 0.5), false, false, ""}, + equalsTestCase{complex64(kRealPart + kImagPart + 0.5i), false, false, ""}, + equalsTestCase{complex128(kRealPart), false, false, ""}, + equalsTestCase{complex128(kRealPart + kImagPart + 0.5), false, false, ""}, + equalsTestCase{complex128(kRealPart + kImagPart + 0.5i), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// Arrays +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) ArrayOfComparableType() { + expected := [3]uint{17, 19, 23} + + matcher := Equals(expected) + ExpectEq("[17 19 23]", matcher.Description()) + + // To defeat constant de-duping by the compiler. + makeArray := func(i, j, k uint) [3]uint { return [3]uint{i, j, k} } + + type arrayAlias [3]uint + type uintAlias uint + + cases := []equalsTestCase{ + // Correct types, equal. + equalsTestCase{expected, true, false, ""}, + equalsTestCase{[3]uint{17, 19, 23}, true, false, ""}, + equalsTestCase{makeArray(17, 19, 23), true, false, ""}, + + // Correct types, not equal. + equalsTestCase{[3]uint{0, 0, 0}, false, false, ""}, + equalsTestCase{[3]uint{18, 19, 23}, false, false, ""}, + equalsTestCase{[3]uint{17, 20, 23}, false, false, ""}, + equalsTestCase{[3]uint{17, 19, 22}, false, false, ""}, + + // Other types. + equalsTestCase{0, false, true, "which is not [3]uint"}, + equalsTestCase{bool(false), false, true, "which is not [3]uint"}, + equalsTestCase{int(0), false, true, "which is not [3]uint"}, + equalsTestCase{int8(0), false, true, "which is not [3]uint"}, + equalsTestCase{int16(0), false, true, "which is not [3]uint"}, + equalsTestCase{int32(0), false, true, "which is not [3]uint"}, + equalsTestCase{int64(0), false, true, "which is not [3]uint"}, + equalsTestCase{uint(0), false, true, "which is not [3]uint"}, + equalsTestCase{uint8(0), false, true, "which is not [3]uint"}, + equalsTestCase{uint16(0), false, true, "which is not [3]uint"}, + equalsTestCase{uint32(0), false, true, "which is not [3]uint"}, + equalsTestCase{uint64(0), false, true, "which is not [3]uint"}, + equalsTestCase{true, false, true, "which is not [3]uint"}, + equalsTestCase{[...]int{}, false, true, "which is not [3]uint"}, + equalsTestCase{func() {}, false, true, "which is not [3]uint"}, + equalsTestCase{map[int]int{}, false, true, "which is not [3]uint"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not [3]uint"}, + equalsTestCase{[2]uint{17, 19}, false, true, "which is not [3]uint"}, + equalsTestCase{[4]uint{17, 19, 23, 0}, false, true, "which is not [3]uint"}, + equalsTestCase{arrayAlias{17, 19, 23}, false, true, "which is not [3]uint"}, + equalsTestCase{[3]uintAlias{17, 19, 23}, false, true, "which is not [3]uint"}, + equalsTestCase{[3]int32{17, 19, 23}, false, true, "which is not [3]uint"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) ArrayOfNonComparableType() { + type nonComparableArray [2]map[string]string + f := func() { + ExpectEq(nonComparableArray{}, nonComparableArray{}) + } + + ExpectThat(f, Panics(MatchesRegexp("uncomparable.*nonComparableArray"))) +} + +//////////////////////////////////////////////////////////////////////// +// chan +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NilChan() { + var nilChan1 chan int + var nilChan2 chan int + var nilChan3 chan uint + var nonNilChan1 chan int = make(chan int) + var nonNilChan2 chan uint = make(chan uint) + + matcher := Equals(nilChan1) + ExpectEq("", matcher.Description()) + + cases := []equalsTestCase{ + // int channels + equalsTestCase{nilChan1, true, false, ""}, + equalsTestCase{nilChan2, true, false, ""}, + equalsTestCase{nonNilChan1, false, false, ""}, + + // uint channels + equalsTestCase{nilChan3, false, true, "which is not a chan int"}, + equalsTestCase{nonNilChan2, false, true, "which is not a chan int"}, + + // Other types. + equalsTestCase{0, false, true, "which is not a chan int"}, + equalsTestCase{bool(false), false, true, "which is not a chan int"}, + equalsTestCase{int(0), false, true, "which is not a chan int"}, + equalsTestCase{int8(0), false, true, "which is not a chan int"}, + equalsTestCase{int16(0), false, true, "which is not a chan int"}, + equalsTestCase{int32(0), false, true, "which is not a chan int"}, + equalsTestCase{int64(0), false, true, "which is not a chan int"}, + equalsTestCase{uint(0), false, true, "which is not a chan int"}, + equalsTestCase{uint8(0), false, true, "which is not a chan int"}, + equalsTestCase{uint16(0), false, true, "which is not a chan int"}, + equalsTestCase{uint32(0), false, true, "which is not a chan int"}, + equalsTestCase{uint64(0), false, true, "which is not a chan int"}, + equalsTestCase{true, false, true, "which is not a chan int"}, + equalsTestCase{[...]int{}, false, true, "which is not a chan int"}, + equalsTestCase{func() {}, false, true, "which is not a chan int"}, + equalsTestCase{map[int]int{}, false, true, "which is not a chan int"}, + equalsTestCase{&someInt, false, true, "which is not a chan int"}, + equalsTestCase{[]int{}, false, true, "which is not a chan int"}, + equalsTestCase{"taco", false, true, "which is not a chan int"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not a chan int"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) NonNilChan() { + var nilChan1 chan int + var nilChan2 chan uint + var nonNilChan1 chan int = make(chan int) + var nonNilChan2 chan int = make(chan int) + var nonNilChan3 chan uint = make(chan uint) + + matcher := Equals(nonNilChan1) + ExpectEq(fmt.Sprintf("%v", nonNilChan1), matcher.Description()) + + cases := []equalsTestCase{ + // int channels + equalsTestCase{nonNilChan1, true, false, ""}, + equalsTestCase{nonNilChan2, false, false, ""}, + equalsTestCase{nilChan1, false, false, ""}, + + // uint channels + equalsTestCase{nilChan2, false, true, "which is not a chan int"}, + equalsTestCase{nonNilChan3, false, true, "which is not a chan int"}, + + // Other types. + equalsTestCase{0, false, true, "which is not a chan int"}, + equalsTestCase{bool(false), false, true, "which is not a chan int"}, + equalsTestCase{int(0), false, true, "which is not a chan int"}, + equalsTestCase{int8(0), false, true, "which is not a chan int"}, + equalsTestCase{int16(0), false, true, "which is not a chan int"}, + equalsTestCase{int32(0), false, true, "which is not a chan int"}, + equalsTestCase{int64(0), false, true, "which is not a chan int"}, + equalsTestCase{uint(0), false, true, "which is not a chan int"}, + equalsTestCase{uint8(0), false, true, "which is not a chan int"}, + equalsTestCase{uint16(0), false, true, "which is not a chan int"}, + equalsTestCase{uint32(0), false, true, "which is not a chan int"}, + equalsTestCase{uint64(0), false, true, "which is not a chan int"}, + equalsTestCase{true, false, true, "which is not a chan int"}, + equalsTestCase{[...]int{}, false, true, "which is not a chan int"}, + equalsTestCase{func() {}, false, true, "which is not a chan int"}, + equalsTestCase{map[int]int{}, false, true, "which is not a chan int"}, + equalsTestCase{&someInt, false, true, "which is not a chan int"}, + equalsTestCase{[]int{}, false, true, "which is not a chan int"}, + equalsTestCase{"taco", false, true, "which is not a chan int"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not a chan int"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) ChanDirection() { + var chan1 chan<- int + var chan2 <-chan int + var chan3 chan int + + matcher := Equals(chan1) + ExpectEq(fmt.Sprintf("%v", chan1), matcher.Description()) + + cases := []equalsTestCase{ + equalsTestCase{chan1, true, false, ""}, + equalsTestCase{chan2, false, true, "which is not a chan<- int"}, + equalsTestCase{chan3, false, true, "which is not a chan<- int"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// func +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) Functions() { + func1 := func() {} + func2 := func() {} + func3 := func(x int) {} + + matcher := Equals(func1) + ExpectEq(fmt.Sprintf("%v", func1), matcher.Description()) + + cases := []equalsTestCase{ + // Functions. + equalsTestCase{func1, true, false, ""}, + equalsTestCase{func2, false, false, ""}, + equalsTestCase{func3, false, false, ""}, + + // Other types. + equalsTestCase{0, false, true, "which is not a function"}, + equalsTestCase{bool(false), false, true, "which is not a function"}, + equalsTestCase{int(0), false, true, "which is not a function"}, + equalsTestCase{int8(0), false, true, "which is not a function"}, + equalsTestCase{int16(0), false, true, "which is not a function"}, + equalsTestCase{int32(0), false, true, "which is not a function"}, + equalsTestCase{int64(0), false, true, "which is not a function"}, + equalsTestCase{uint(0), false, true, "which is not a function"}, + equalsTestCase{uint8(0), false, true, "which is not a function"}, + equalsTestCase{uint16(0), false, true, "which is not a function"}, + equalsTestCase{uint32(0), false, true, "which is not a function"}, + equalsTestCase{uint64(0), false, true, "which is not a function"}, + equalsTestCase{true, false, true, "which is not a function"}, + equalsTestCase{[...]int{}, false, true, "which is not a function"}, + equalsTestCase{map[int]int{}, false, true, "which is not a function"}, + equalsTestCase{&someInt, false, true, "which is not a function"}, + equalsTestCase{[]int{}, false, true, "which is not a function"}, + equalsTestCase{"taco", false, true, "which is not a function"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not a function"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// map +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NilMap() { + var nilMap1 map[int]int + var nilMap2 map[int]int + var nilMap3 map[int]uint + var nonNilMap1 map[int]int = make(map[int]int) + var nonNilMap2 map[int]uint = make(map[int]uint) + + matcher := Equals(nilMap1) + ExpectEq("map[]", matcher.Description()) + + cases := []equalsTestCase{ + // Correct type. + equalsTestCase{nilMap1, true, false, ""}, + equalsTestCase{nilMap2, true, false, ""}, + equalsTestCase{nilMap3, true, false, ""}, + equalsTestCase{nonNilMap1, false, false, ""}, + equalsTestCase{nonNilMap2, false, false, ""}, + + // Other types. + equalsTestCase{0, false, true, "which is not a map"}, + equalsTestCase{bool(false), false, true, "which is not a map"}, + equalsTestCase{int(0), false, true, "which is not a map"}, + equalsTestCase{int8(0), false, true, "which is not a map"}, + equalsTestCase{int16(0), false, true, "which is not a map"}, + equalsTestCase{int32(0), false, true, "which is not a map"}, + equalsTestCase{int64(0), false, true, "which is not a map"}, + equalsTestCase{uint(0), false, true, "which is not a map"}, + equalsTestCase{uint8(0), false, true, "which is not a map"}, + equalsTestCase{uint16(0), false, true, "which is not a map"}, + equalsTestCase{uint32(0), false, true, "which is not a map"}, + equalsTestCase{uint64(0), false, true, "which is not a map"}, + equalsTestCase{true, false, true, "which is not a map"}, + equalsTestCase{[...]int{}, false, true, "which is not a map"}, + equalsTestCase{func() {}, false, true, "which is not a map"}, + equalsTestCase{&someInt, false, true, "which is not a map"}, + equalsTestCase{[]int{}, false, true, "which is not a map"}, + equalsTestCase{"taco", false, true, "which is not a map"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not a map"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) NonNilMap() { + var nilMap1 map[int]int + var nilMap2 map[int]uint + var nonNilMap1 map[int]int = make(map[int]int) + var nonNilMap2 map[int]int = make(map[int]int) + var nonNilMap3 map[int]uint = make(map[int]uint) + + matcher := Equals(nonNilMap1) + ExpectEq("map[]", matcher.Description()) + + cases := []equalsTestCase{ + // Correct type. + equalsTestCase{nonNilMap1, true, false, ""}, + equalsTestCase{nonNilMap2, false, false, ""}, + equalsTestCase{nonNilMap3, false, false, ""}, + equalsTestCase{nilMap1, false, false, ""}, + equalsTestCase{nilMap2, false, false, ""}, + + // Other types. + equalsTestCase{0, false, true, "which is not a map"}, + equalsTestCase{bool(false), false, true, "which is not a map"}, + equalsTestCase{int(0), false, true, "which is not a map"}, + equalsTestCase{int8(0), false, true, "which is not a map"}, + equalsTestCase{int16(0), false, true, "which is not a map"}, + equalsTestCase{int32(0), false, true, "which is not a map"}, + equalsTestCase{int64(0), false, true, "which is not a map"}, + equalsTestCase{uint(0), false, true, "which is not a map"}, + equalsTestCase{uint8(0), false, true, "which is not a map"}, + equalsTestCase{uint16(0), false, true, "which is not a map"}, + equalsTestCase{uint32(0), false, true, "which is not a map"}, + equalsTestCase{uint64(0), false, true, "which is not a map"}, + equalsTestCase{true, false, true, "which is not a map"}, + equalsTestCase{[...]int{}, false, true, "which is not a map"}, + equalsTestCase{func() {}, false, true, "which is not a map"}, + equalsTestCase{&someInt, false, true, "which is not a map"}, + equalsTestCase{[]int{}, false, true, "which is not a map"}, + equalsTestCase{"taco", false, true, "which is not a map"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not a map"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// Pointers +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NilPointer() { + var someInt int = 17 + var someUint uint = 17 + + var nilInt1 *int + var nilInt2 *int + var nilUint *uint + var nonNilInt *int = &someInt + var nonNilUint *uint = &someUint + + matcher := Equals(nilInt1) + ExpectEq("", matcher.Description()) + + cases := []equalsTestCase{ + // Correct type. + equalsTestCase{nilInt1, true, false, ""}, + equalsTestCase{nilInt2, true, false, ""}, + equalsTestCase{nonNilInt, false, false, ""}, + + // Incorrect type. + equalsTestCase{nilUint, false, true, "which is not a *int"}, + equalsTestCase{nonNilUint, false, true, "which is not a *int"}, + + // Other types. + equalsTestCase{0, false, true, "which is not a *int"}, + equalsTestCase{bool(false), false, true, "which is not a *int"}, + equalsTestCase{int(0), false, true, "which is not a *int"}, + equalsTestCase{int8(0), false, true, "which is not a *int"}, + equalsTestCase{int16(0), false, true, "which is not a *int"}, + equalsTestCase{int32(0), false, true, "which is not a *int"}, + equalsTestCase{int64(0), false, true, "which is not a *int"}, + equalsTestCase{uint(0), false, true, "which is not a *int"}, + equalsTestCase{uint8(0), false, true, "which is not a *int"}, + equalsTestCase{uint16(0), false, true, "which is not a *int"}, + equalsTestCase{uint32(0), false, true, "which is not a *int"}, + equalsTestCase{uint64(0), false, true, "which is not a *int"}, + equalsTestCase{true, false, true, "which is not a *int"}, + equalsTestCase{[...]int{}, false, true, "which is not a *int"}, + equalsTestCase{func() {}, false, true, "which is not a *int"}, + equalsTestCase{map[int]int{}, false, true, "which is not a *int"}, + equalsTestCase{[]int{}, false, true, "which is not a *int"}, + equalsTestCase{"taco", false, true, "which is not a *int"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not a *int"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) NonNilPointer() { + var someInt int = 17 + var someOtherInt int = 17 + var someUint uint = 17 + + var nilInt *int + var nilUint *uint + var nonNilInt1 *int = &someInt + var nonNilInt2 *int = &someOtherInt + var nonNilUint *uint = &someUint + + matcher := Equals(nonNilInt1) + ExpectEq(fmt.Sprintf("%v", nonNilInt1), matcher.Description()) + + cases := []equalsTestCase{ + // Correct type. + equalsTestCase{nonNilInt1, true, false, ""}, + equalsTestCase{nonNilInt2, false, false, ""}, + equalsTestCase{nilInt, false, false, ""}, + + // Incorrect type. + equalsTestCase{nilUint, false, true, "which is not a *int"}, + equalsTestCase{nonNilUint, false, true, "which is not a *int"}, + + // Other types. + equalsTestCase{0, false, true, "which is not a *int"}, + equalsTestCase{bool(false), false, true, "which is not a *int"}, + equalsTestCase{int(0), false, true, "which is not a *int"}, + equalsTestCase{int8(0), false, true, "which is not a *int"}, + equalsTestCase{int16(0), false, true, "which is not a *int"}, + equalsTestCase{int32(0), false, true, "which is not a *int"}, + equalsTestCase{int64(0), false, true, "which is not a *int"}, + equalsTestCase{uint(0), false, true, "which is not a *int"}, + equalsTestCase{uint8(0), false, true, "which is not a *int"}, + equalsTestCase{uint16(0), false, true, "which is not a *int"}, + equalsTestCase{uint32(0), false, true, "which is not a *int"}, + equalsTestCase{uint64(0), false, true, "which is not a *int"}, + equalsTestCase{true, false, true, "which is not a *int"}, + equalsTestCase{[...]int{}, false, true, "which is not a *int"}, + equalsTestCase{func() {}, false, true, "which is not a *int"}, + equalsTestCase{map[int]int{}, false, true, "which is not a *int"}, + equalsTestCase{[]int{}, false, true, "which is not a *int"}, + equalsTestCase{"taco", false, true, "which is not a *int"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not a *int"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// Slices +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NilSlice() { + var nilInt1 []int + var nilInt2 []int + var nilUint []uint + + var nonNilInt []int = make([]int, 0) + var nonNilUint []uint = make([]uint, 0) + + matcher := Equals(nilInt1) + ExpectEq("[]", matcher.Description()) + + cases := []equalsTestCase{ + // Correct type. + equalsTestCase{nilInt1, true, false, ""}, + equalsTestCase{nilInt2, true, false, ""}, + equalsTestCase{nonNilInt, false, false, ""}, + + // Incorrect type. + equalsTestCase{nilUint, false, true, "which is not a []int"}, + equalsTestCase{nonNilUint, false, true, "which is not a []int"}, + + // Other types. + equalsTestCase{0, false, true, "which is not a []int"}, + equalsTestCase{bool(false), false, true, "which is not a []int"}, + equalsTestCase{int(0), false, true, "which is not a []int"}, + equalsTestCase{int8(0), false, true, "which is not a []int"}, + equalsTestCase{int16(0), false, true, "which is not a []int"}, + equalsTestCase{int32(0), false, true, "which is not a []int"}, + equalsTestCase{int64(0), false, true, "which is not a []int"}, + equalsTestCase{uint(0), false, true, "which is not a []int"}, + equalsTestCase{uint8(0), false, true, "which is not a []int"}, + equalsTestCase{uint16(0), false, true, "which is not a []int"}, + equalsTestCase{uint32(0), false, true, "which is not a []int"}, + equalsTestCase{uint64(0), false, true, "which is not a []int"}, + equalsTestCase{true, false, true, "which is not a []int"}, + equalsTestCase{[...]int{}, false, true, "which is not a []int"}, + equalsTestCase{func() {}, false, true, "which is not a []int"}, + equalsTestCase{map[int]int{}, false, true, "which is not a []int"}, + equalsTestCase{"taco", false, true, "which is not a []int"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not a []int"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) NonNilSlice() { + nonNil := make([]int, 0) + f := func() { Equals(nonNil) } + ExpectThat(f, Panics(HasSubstr("non-nil slice"))) +} + +//////////////////////////////////////////////////////////////////////// +// string +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) String() { + partial := "taco" + expected := fmt.Sprintf("%s%d", partial, 1) + + matcher := Equals(expected) + ExpectEq("taco1", matcher.Description()) + + type stringAlias string + + cases := []equalsTestCase{ + // Correct types. + equalsTestCase{"taco1", true, false, ""}, + equalsTestCase{"taco" + "1", true, false, ""}, + equalsTestCase{expected, true, false, ""}, + equalsTestCase{stringAlias("taco1"), true, false, ""}, + + equalsTestCase{"", false, false, ""}, + equalsTestCase{"taco", false, false, ""}, + equalsTestCase{"taco1\x00", false, false, ""}, + equalsTestCase{"taco2", false, false, ""}, + equalsTestCase{stringAlias("taco2"), false, false, ""}, + + // Other types. + equalsTestCase{0, false, true, "which is not a string"}, + equalsTestCase{bool(false), false, true, "which is not a string"}, + equalsTestCase{int(0), false, true, "which is not a string"}, + equalsTestCase{int8(0), false, true, "which is not a string"}, + equalsTestCase{int16(0), false, true, "which is not a string"}, + equalsTestCase{int32(0), false, true, "which is not a string"}, + equalsTestCase{int64(0), false, true, "which is not a string"}, + equalsTestCase{uint(0), false, true, "which is not a string"}, + equalsTestCase{uint8(0), false, true, "which is not a string"}, + equalsTestCase{uint16(0), false, true, "which is not a string"}, + equalsTestCase{uint32(0), false, true, "which is not a string"}, + equalsTestCase{uint64(0), false, true, "which is not a string"}, + equalsTestCase{true, false, true, "which is not a string"}, + equalsTestCase{[...]int{}, false, true, "which is not a string"}, + equalsTestCase{func() {}, false, true, "which is not a string"}, + equalsTestCase{map[int]int{}, false, true, "which is not a string"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not a string"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) StringAlias() { + type stringAlias string + + matcher := Equals(stringAlias("taco")) + ExpectEq("taco", matcher.Description()) + + cases := []equalsTestCase{ + // Correct types. + equalsTestCase{stringAlias("taco"), true, false, ""}, + equalsTestCase{"taco", true, false, ""}, + + equalsTestCase{"burrito", false, false, ""}, + equalsTestCase{stringAlias("burrito"), false, false, ""}, + + // Other types. + equalsTestCase{0, false, true, "which is not a string"}, + equalsTestCase{bool(false), false, true, "which is not a string"}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// struct +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) Struct() { + type someStruct struct{ foo uint } + f := func() { Equals(someStruct{17}) } + ExpectThat(f, Panics(HasSubstr("unsupported kind struct"))) +} + +//////////////////////////////////////////////////////////////////////// +// unsafe.Pointer +//////////////////////////////////////////////////////////////////////// + +func (t *EqualsTest) NilUnsafePointer() { + someInt := int(17) + + var nilPtr1 unsafe.Pointer + var nilPtr2 unsafe.Pointer + var nonNilPtr unsafe.Pointer = unsafe.Pointer(&someInt) + + matcher := Equals(nilPtr1) + ExpectEq("", matcher.Description()) + + cases := []equalsTestCase{ + // Correct type. + equalsTestCase{nilPtr1, true, false, ""}, + equalsTestCase{nilPtr2, true, false, ""}, + equalsTestCase{nonNilPtr, false, false, ""}, + + // Other types. + equalsTestCase{0, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{bool(false), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{int(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{int8(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{int16(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{int32(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{int64(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{uint(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{uint8(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{uint16(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{uint32(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{uint64(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{true, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{[...]int{}, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{make(chan int), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{func() {}, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{map[int]int{}, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{&someInt, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{[]int{}, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{"taco", false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not a unsafe.Pointer"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *EqualsTest) NonNilUnsafePointer() { + someInt := int(17) + someOtherInt := int(17) + + var nilPtr unsafe.Pointer + var nonNilPtr1 unsafe.Pointer = unsafe.Pointer(&someInt) + var nonNilPtr2 unsafe.Pointer = unsafe.Pointer(&someOtherInt) + + matcher := Equals(nonNilPtr1) + ExpectEq(fmt.Sprintf("%v", nonNilPtr1), matcher.Description()) + + cases := []equalsTestCase{ + // Correct type. + equalsTestCase{nonNilPtr1, true, false, ""}, + equalsTestCase{nonNilPtr2, false, false, ""}, + equalsTestCase{nilPtr, false, false, ""}, + + // Other types. + equalsTestCase{0, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{bool(false), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{int(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{int8(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{int16(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{int32(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{int64(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{uint(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{uint8(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{uint16(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{uint32(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{uint64(0), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{true, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{[...]int{}, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{make(chan int), false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{func() {}, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{map[int]int{}, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{&someInt, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{[]int{}, false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{"taco", false, true, "which is not a unsafe.Pointer"}, + equalsTestCase{equalsTestCase{}, false, true, "which is not a unsafe.Pointer"}, + } + + t.checkTestCases(matcher, cases) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/error.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/error.go new file mode 100644 index 000000000..8a078e36d --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/error.go @@ -0,0 +1,51 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers + +// Error returns a matcher that matches non-nil values implementing the +// built-in error interface for whom the return value of Error() matches the +// supplied matcher. +// +// For example: +// +// err := errors.New("taco burrito") +// +// Error(Equals("taco burrito")) // matches err +// Error(HasSubstr("taco")) // matches err +// Error(HasSubstr("enchilada")) // doesn't match err +// +func Error(m Matcher) Matcher { + return &errorMatcher{m} +} + +type errorMatcher struct { + wrappedMatcher Matcher +} + +func (m *errorMatcher) Description() string { + return "error " + m.wrappedMatcher.Description() +} + +func (m *errorMatcher) Matches(c interface{}) error { + // Make sure that c is an error. + e, ok := c.(error) + if !ok { + return NewFatalError("which is not an error") + } + + // Pass on the error text to the wrapped matcher. + return m.wrappedMatcher.Matches(e.Error()) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/error_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/error_test.go new file mode 100644 index 000000000..f92167cad --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/error_test.go @@ -0,0 +1,92 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "errors" + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type ErrorTest struct { + matcherCalled bool + suppliedCandidate interface{} + wrappedError error + + matcher Matcher +} + +func init() { RegisterTestSuite(&ErrorTest{}) } + +func (t *ErrorTest) SetUp(i *TestInfo) { + wrapped := &fakeMatcher{ + func(c interface{}) error { + t.matcherCalled = true + t.suppliedCandidate = c + return t.wrappedError + }, + "is foo", + } + + t.matcher = Error(wrapped) +} + +func isFatal(err error) bool { + _, isFatal := err.(*FatalError) + return isFatal +} + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *ErrorTest) Description() { + ExpectThat(t.matcher.Description(), Equals("error is foo")) +} + +func (t *ErrorTest) CandidateIsNil() { + err := t.matcher.Matches(nil) + + ExpectThat(t.matcherCalled, Equals(false)) + ExpectThat(err.Error(), Equals("which is not an error")) + ExpectTrue(isFatal(err)) +} + +func (t *ErrorTest) CandidateIsString() { + err := t.matcher.Matches("taco") + + ExpectThat(t.matcherCalled, Equals(false)) + ExpectThat(err.Error(), Equals("which is not an error")) + ExpectTrue(isFatal(err)) +} + +func (t *ErrorTest) CallsWrappedMatcher() { + candidate := errors.New("taco") + t.matcher.Matches(candidate) + + ExpectThat(t.matcherCalled, Equals(true)) + ExpectThat(t.suppliedCandidate, Equals("taco")) +} + +func (t *ErrorTest) ReturnsWrappedMatcherResult() { + t.wrappedError = errors.New("burrito") + err := t.matcher.Matches(errors.New("")) + ExpectThat(err, Equals(t.wrappedError)) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal_test.go new file mode 100644 index 000000000..f5e29d1ce --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal_test.go @@ -0,0 +1,1101 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "math" + + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type GreaterOrEqualTest struct { +} + +func init() { RegisterTestSuite(&GreaterOrEqualTest{}) } + +type geTestCase struct { + candidate interface{} + expectedResult bool + shouldBeFatal bool + expectedError string +} + +func (t *GreaterOrEqualTest) checkTestCases(matcher Matcher, cases []geTestCase) { + for i, c := range cases { + err := matcher.Matches(c.candidate) + + ExpectThat( + (err == nil), + Equals(c.expectedResult), + "Case %d (candidate %v)", + i, + c.candidate) + + if err == nil { + continue + } + + _, isFatal := err.(*FatalError) + ExpectEq( + c.shouldBeFatal, + isFatal, + "Case %d (candidate %v)", + i, + c.candidate) + + ExpectThat( + err, + Error(Equals(c.expectedError)), + "Case %d (candidate %v)", + i, + c.candidate) + } +} + +//////////////////////////////////////////////////////////////////////// +// Integer literals +//////////////////////////////////////////////////////////////////////// + +func (t *GreaterOrEqualTest) IntegerCandidateBadTypes() { + matcher := GreaterOrEqual(int(-150)) + + cases := []geTestCase{ + geTestCase{true, false, true, "which is not comparable"}, + geTestCase{complex64(-151), false, true, "which is not comparable"}, + geTestCase{complex128(-151), false, true, "which is not comparable"}, + geTestCase{[...]int{-151}, false, true, "which is not comparable"}, + geTestCase{make(chan int), false, true, "which is not comparable"}, + geTestCase{func() {}, false, true, "which is not comparable"}, + geTestCase{map[int]int{}, false, true, "which is not comparable"}, + geTestCase{&geTestCase{}, false, true, "which is not comparable"}, + geTestCase{make([]int, 0), false, true, "which is not comparable"}, + geTestCase{"-151", false, true, "which is not comparable"}, + geTestCase{geTestCase{}, false, true, "which is not comparable"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterOrEqualTest) FloatCandidateBadTypes() { + matcher := GreaterOrEqual(float32(-150)) + + cases := []geTestCase{ + geTestCase{true, false, true, "which is not comparable"}, + geTestCase{complex64(-151), false, true, "which is not comparable"}, + geTestCase{complex128(-151), false, true, "which is not comparable"}, + geTestCase{[...]int{-151}, false, true, "which is not comparable"}, + geTestCase{make(chan int), false, true, "which is not comparable"}, + geTestCase{func() {}, false, true, "which is not comparable"}, + geTestCase{map[int]int{}, false, true, "which is not comparable"}, + geTestCase{&geTestCase{}, false, true, "which is not comparable"}, + geTestCase{make([]int, 0), false, true, "which is not comparable"}, + geTestCase{"-151", false, true, "which is not comparable"}, + geTestCase{geTestCase{}, false, true, "which is not comparable"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterOrEqualTest) StringCandidateBadTypes() { + matcher := GreaterOrEqual("17") + + cases := []geTestCase{ + geTestCase{true, false, true, "which is not comparable"}, + geTestCase{int(0), false, true, "which is not comparable"}, + geTestCase{int8(0), false, true, "which is not comparable"}, + geTestCase{int16(0), false, true, "which is not comparable"}, + geTestCase{int32(0), false, true, "which is not comparable"}, + geTestCase{int64(0), false, true, "which is not comparable"}, + geTestCase{uint(0), false, true, "which is not comparable"}, + geTestCase{uint8(0), false, true, "which is not comparable"}, + geTestCase{uint16(0), false, true, "which is not comparable"}, + geTestCase{uint32(0), false, true, "which is not comparable"}, + geTestCase{uint64(0), false, true, "which is not comparable"}, + geTestCase{float32(0), false, true, "which is not comparable"}, + geTestCase{float64(0), false, true, "which is not comparable"}, + geTestCase{complex64(-151), false, true, "which is not comparable"}, + geTestCase{complex128(-151), false, true, "which is not comparable"}, + geTestCase{[...]int{-151}, false, true, "which is not comparable"}, + geTestCase{make(chan int), false, true, "which is not comparable"}, + geTestCase{func() {}, false, true, "which is not comparable"}, + geTestCase{map[int]int{}, false, true, "which is not comparable"}, + geTestCase{&geTestCase{}, false, true, "which is not comparable"}, + geTestCase{make([]int, 0), false, true, "which is not comparable"}, + geTestCase{geTestCase{}, false, true, "which is not comparable"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterOrEqualTest) BadArgument() { + panicked := false + + defer func() { + ExpectThat(panicked, Equals(true)) + }() + + defer func() { + if r := recover(); r != nil { + panicked = true + } + }() + + GreaterOrEqual(complex128(0)) +} + +//////////////////////////////////////////////////////////////////////// +// Integer literals +//////////////////////////////////////////////////////////////////////// + +func (t *GreaterOrEqualTest) NegativeIntegerLiteral() { + matcher := GreaterOrEqual(-150) + desc := matcher.Description() + expectedDesc := "greater than or equal to -150" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + // Signed integers. + geTestCase{-(1 << 30), false, false, ""}, + geTestCase{-151, false, false, ""}, + geTestCase{-150, true, false, ""}, + geTestCase{0, true, false, ""}, + geTestCase{17, true, false, ""}, + + geTestCase{int(-(1 << 30)), false, false, ""}, + geTestCase{int(-151), false, false, ""}, + geTestCase{int(-150), true, false, ""}, + geTestCase{int(0), true, false, ""}, + geTestCase{int(17), true, false, ""}, + + geTestCase{int8(-127), true, false, ""}, + geTestCase{int8(0), true, false, ""}, + geTestCase{int8(17), true, false, ""}, + + geTestCase{int16(-(1 << 14)), false, false, ""}, + geTestCase{int16(-151), false, false, ""}, + geTestCase{int16(-150), true, false, ""}, + geTestCase{int16(0), true, false, ""}, + geTestCase{int16(17), true, false, ""}, + + geTestCase{int32(-(1 << 30)), false, false, ""}, + geTestCase{int32(-151), false, false, ""}, + geTestCase{int32(-150), true, false, ""}, + geTestCase{int32(0), true, false, ""}, + geTestCase{int32(17), true, false, ""}, + + geTestCase{int64(-(1 << 30)), false, false, ""}, + geTestCase{int64(-151), false, false, ""}, + geTestCase{int64(-150), true, false, ""}, + geTestCase{int64(0), true, false, ""}, + geTestCase{int64(17), true, false, ""}, + + // Unsigned integers. + geTestCase{uint((1 << 32) - 151), true, false, ""}, + geTestCase{uint(0), true, false, ""}, + geTestCase{uint(17), true, false, ""}, + + geTestCase{uint8(0), true, false, ""}, + geTestCase{uint8(17), true, false, ""}, + geTestCase{uint8(253), true, false, ""}, + + geTestCase{uint16((1 << 16) - 151), true, false, ""}, + geTestCase{uint16(0), true, false, ""}, + geTestCase{uint16(17), true, false, ""}, + + geTestCase{uint32((1 << 32) - 151), true, false, ""}, + geTestCase{uint32(0), true, false, ""}, + geTestCase{uint32(17), true, false, ""}, + + geTestCase{uint64((1 << 64) - 151), true, false, ""}, + geTestCase{uint64(0), true, false, ""}, + geTestCase{uint64(17), true, false, ""}, + + geTestCase{uintptr((1 << 64) - 151), true, false, ""}, + geTestCase{uintptr(0), true, false, ""}, + geTestCase{uintptr(17), true, false, ""}, + + // Floating point. + geTestCase{float32(-(1 << 30)), false, false, ""}, + geTestCase{float32(-151), false, false, ""}, + geTestCase{float32(-150.1), false, false, ""}, + geTestCase{float32(-150), true, false, ""}, + geTestCase{float32(-149.9), true, false, ""}, + geTestCase{float32(0), true, false, ""}, + geTestCase{float32(17), true, false, ""}, + geTestCase{float32(160), true, false, ""}, + + geTestCase{float64(-(1 << 30)), false, false, ""}, + geTestCase{float64(-151), false, false, ""}, + geTestCase{float64(-150.1), false, false, ""}, + geTestCase{float64(-150), true, false, ""}, + geTestCase{float64(-149.9), true, false, ""}, + geTestCase{float64(0), true, false, ""}, + geTestCase{float64(17), true, false, ""}, + geTestCase{float64(160), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterOrEqualTest) ZeroIntegerLiteral() { + matcher := GreaterOrEqual(0) + desc := matcher.Description() + expectedDesc := "greater than or equal to 0" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + // Signed integers. + geTestCase{-(1 << 30), false, false, ""}, + geTestCase{-1, false, false, ""}, + geTestCase{0, true, false, ""}, + geTestCase{1, true, false, ""}, + geTestCase{17, true, false, ""}, + geTestCase{(1 << 30), true, false, ""}, + + geTestCase{int(-(1 << 30)), false, false, ""}, + geTestCase{int(-1), false, false, ""}, + geTestCase{int(0), true, false, ""}, + geTestCase{int(1), true, false, ""}, + geTestCase{int(17), true, false, ""}, + + geTestCase{int8(-1), false, false, ""}, + geTestCase{int8(0), true, false, ""}, + geTestCase{int8(1), true, false, ""}, + + geTestCase{int16(-(1 << 14)), false, false, ""}, + geTestCase{int16(-1), false, false, ""}, + geTestCase{int16(0), true, false, ""}, + geTestCase{int16(1), true, false, ""}, + geTestCase{int16(17), true, false, ""}, + + geTestCase{int32(-(1 << 30)), false, false, ""}, + geTestCase{int32(-1), false, false, ""}, + geTestCase{int32(0), true, false, ""}, + geTestCase{int32(1), true, false, ""}, + geTestCase{int32(17), true, false, ""}, + + geTestCase{int64(-(1 << 30)), false, false, ""}, + geTestCase{int64(-1), false, false, ""}, + geTestCase{int64(0), true, false, ""}, + geTestCase{int64(1), true, false, ""}, + geTestCase{int64(17), true, false, ""}, + + // Unsigned integers. + geTestCase{uint((1 << 32) - 1), true, false, ""}, + geTestCase{uint(0), true, false, ""}, + geTestCase{uint(17), true, false, ""}, + + geTestCase{uint8(0), true, false, ""}, + geTestCase{uint8(17), true, false, ""}, + geTestCase{uint8(253), true, false, ""}, + + geTestCase{uint16((1 << 16) - 1), true, false, ""}, + geTestCase{uint16(0), true, false, ""}, + geTestCase{uint16(17), true, false, ""}, + + geTestCase{uint32((1 << 32) - 1), true, false, ""}, + geTestCase{uint32(0), true, false, ""}, + geTestCase{uint32(17), true, false, ""}, + + geTestCase{uint64((1 << 64) - 1), true, false, ""}, + geTestCase{uint64(0), true, false, ""}, + geTestCase{uint64(17), true, false, ""}, + + geTestCase{uintptr((1 << 64) - 1), true, false, ""}, + geTestCase{uintptr(0), true, false, ""}, + geTestCase{uintptr(17), true, false, ""}, + + // Floating point. + geTestCase{float32(-(1 << 30)), false, false, ""}, + geTestCase{float32(-1), false, false, ""}, + geTestCase{float32(-0.1), false, false, ""}, + geTestCase{float32(-0.0), true, false, ""}, + geTestCase{float32(0), true, false, ""}, + geTestCase{float32(0.1), true, false, ""}, + geTestCase{float32(17), true, false, ""}, + geTestCase{float32(160), true, false, ""}, + + geTestCase{float64(-(1 << 30)), false, false, ""}, + geTestCase{float64(-1), false, false, ""}, + geTestCase{float64(-0.1), false, false, ""}, + geTestCase{float64(-0), true, false, ""}, + geTestCase{float64(0), true, false, ""}, + geTestCase{float64(17), true, false, ""}, + geTestCase{float64(160), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterOrEqualTest) PositiveIntegerLiteral() { + matcher := GreaterOrEqual(150) + desc := matcher.Description() + expectedDesc := "greater than or equal to 150" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + // Signed integers. + geTestCase{-1, false, false, ""}, + geTestCase{149, false, false, ""}, + geTestCase{150, true, false, ""}, + geTestCase{151, true, false, ""}, + + geTestCase{int(-1), false, false, ""}, + geTestCase{int(149), false, false, ""}, + geTestCase{int(150), true, false, ""}, + geTestCase{int(151), true, false, ""}, + + geTestCase{int8(-1), false, false, ""}, + geTestCase{int8(0), false, false, ""}, + geTestCase{int8(17), false, false, ""}, + geTestCase{int8(127), false, false, ""}, + + geTestCase{int16(-1), false, false, ""}, + geTestCase{int16(149), false, false, ""}, + geTestCase{int16(150), true, false, ""}, + geTestCase{int16(151), true, false, ""}, + + geTestCase{int32(-1), false, false, ""}, + geTestCase{int32(149), false, false, ""}, + geTestCase{int32(150), true, false, ""}, + geTestCase{int32(151), true, false, ""}, + + geTestCase{int64(-1), false, false, ""}, + geTestCase{int64(149), false, false, ""}, + geTestCase{int64(150), true, false, ""}, + geTestCase{int64(151), true, false, ""}, + + // Unsigned integers. + geTestCase{uint(0), false, false, ""}, + geTestCase{uint(149), false, false, ""}, + geTestCase{uint(150), true, false, ""}, + geTestCase{uint(151), true, false, ""}, + + geTestCase{uint8(0), false, false, ""}, + geTestCase{uint8(127), false, false, ""}, + + geTestCase{uint16(0), false, false, ""}, + geTestCase{uint16(149), false, false, ""}, + geTestCase{uint16(150), true, false, ""}, + geTestCase{uint16(151), true, false, ""}, + + geTestCase{uint32(0), false, false, ""}, + geTestCase{uint32(149), false, false, ""}, + geTestCase{uint32(150), true, false, ""}, + geTestCase{uint32(151), true, false, ""}, + + geTestCase{uint64(0), false, false, ""}, + geTestCase{uint64(149), false, false, ""}, + geTestCase{uint64(150), true, false, ""}, + geTestCase{uint64(151), true, false, ""}, + + geTestCase{uintptr(0), false, false, ""}, + geTestCase{uintptr(149), false, false, ""}, + geTestCase{uintptr(150), true, false, ""}, + geTestCase{uintptr(151), true, false, ""}, + + // Floating point. + geTestCase{float32(-1), false, false, ""}, + geTestCase{float32(149), false, false, ""}, + geTestCase{float32(149.9), false, false, ""}, + geTestCase{float32(150), true, false, ""}, + geTestCase{float32(150.1), true, false, ""}, + geTestCase{float32(151), true, false, ""}, + + geTestCase{float64(-1), false, false, ""}, + geTestCase{float64(149), false, false, ""}, + geTestCase{float64(149.9), false, false, ""}, + geTestCase{float64(150), true, false, ""}, + geTestCase{float64(150.1), true, false, ""}, + geTestCase{float64(151), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// Float literals +//////////////////////////////////////////////////////////////////////// + +func (t *GreaterOrEqualTest) NegativeFloatLiteral() { + matcher := GreaterOrEqual(-150.1) + desc := matcher.Description() + expectedDesc := "greater than or equal to -150.1" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + // Signed integers. + geTestCase{-(1 << 30), false, false, ""}, + geTestCase{-151, false, false, ""}, + geTestCase{-150, true, false, ""}, + geTestCase{0, true, false, ""}, + geTestCase{17, true, false, ""}, + + geTestCase{int(-(1 << 30)), false, false, ""}, + geTestCase{int(-151), false, false, ""}, + geTestCase{int(-150), true, false, ""}, + geTestCase{int(0), true, false, ""}, + geTestCase{int(17), true, false, ""}, + + geTestCase{int8(-127), true, false, ""}, + geTestCase{int8(0), true, false, ""}, + geTestCase{int8(17), true, false, ""}, + + geTestCase{int16(-(1 << 14)), false, false, ""}, + geTestCase{int16(-151), false, false, ""}, + geTestCase{int16(-150), true, false, ""}, + geTestCase{int16(0), true, false, ""}, + geTestCase{int16(17), true, false, ""}, + + geTestCase{int32(-(1 << 30)), false, false, ""}, + geTestCase{int32(-151), false, false, ""}, + geTestCase{int32(-150), true, false, ""}, + geTestCase{int32(0), true, false, ""}, + geTestCase{int32(17), true, false, ""}, + + geTestCase{int64(-(1 << 30)), false, false, ""}, + geTestCase{int64(-151), false, false, ""}, + geTestCase{int64(-150), true, false, ""}, + geTestCase{int64(0), true, false, ""}, + geTestCase{int64(17), true, false, ""}, + + // Unsigned integers. + geTestCase{uint((1 << 32) - 151), true, false, ""}, + geTestCase{uint(0), true, false, ""}, + geTestCase{uint(17), true, false, ""}, + + geTestCase{uint8(0), true, false, ""}, + geTestCase{uint8(17), true, false, ""}, + geTestCase{uint8(253), true, false, ""}, + + geTestCase{uint16((1 << 16) - 151), true, false, ""}, + geTestCase{uint16(0), true, false, ""}, + geTestCase{uint16(17), true, false, ""}, + + geTestCase{uint32((1 << 32) - 151), true, false, ""}, + geTestCase{uint32(0), true, false, ""}, + geTestCase{uint32(17), true, false, ""}, + + geTestCase{uint64((1 << 64) - 151), true, false, ""}, + geTestCase{uint64(0), true, false, ""}, + geTestCase{uint64(17), true, false, ""}, + + geTestCase{uintptr((1 << 64) - 151), true, false, ""}, + geTestCase{uintptr(0), true, false, ""}, + geTestCase{uintptr(17), true, false, ""}, + + // Floating point. + geTestCase{float32(-(1 << 30)), false, false, ""}, + geTestCase{float32(-151), false, false, ""}, + geTestCase{float32(-150.2), false, false, ""}, + geTestCase{float32(-150.1), true, false, ""}, + geTestCase{float32(-150), true, false, ""}, + geTestCase{float32(0), true, false, ""}, + geTestCase{float32(17), true, false, ""}, + geTestCase{float32(160), true, false, ""}, + + geTestCase{float64(-(1 << 30)), false, false, ""}, + geTestCase{float64(-151), false, false, ""}, + geTestCase{float64(-150.2), false, false, ""}, + geTestCase{float64(-150.1), true, false, ""}, + geTestCase{float64(-150), true, false, ""}, + geTestCase{float64(0), true, false, ""}, + geTestCase{float64(17), true, false, ""}, + geTestCase{float64(160), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterOrEqualTest) PositiveFloatLiteral() { + matcher := GreaterOrEqual(149.9) + desc := matcher.Description() + expectedDesc := "greater than or equal to 149.9" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + // Signed integers. + geTestCase{-1, false, false, ""}, + geTestCase{149, false, false, ""}, + geTestCase{150, true, false, ""}, + geTestCase{151, true, false, ""}, + + geTestCase{int(-1), false, false, ""}, + geTestCase{int(149), false, false, ""}, + geTestCase{int(150), true, false, ""}, + geTestCase{int(151), true, false, ""}, + + geTestCase{int8(-1), false, false, ""}, + geTestCase{int8(0), false, false, ""}, + geTestCase{int8(17), false, false, ""}, + geTestCase{int8(127), false, false, ""}, + + geTestCase{int16(-1), false, false, ""}, + geTestCase{int16(149), false, false, ""}, + geTestCase{int16(150), true, false, ""}, + geTestCase{int16(151), true, false, ""}, + + geTestCase{int32(-1), false, false, ""}, + geTestCase{int32(149), false, false, ""}, + geTestCase{int32(150), true, false, ""}, + geTestCase{int32(151), true, false, ""}, + + geTestCase{int64(-1), false, false, ""}, + geTestCase{int64(149), false, false, ""}, + geTestCase{int64(150), true, false, ""}, + geTestCase{int64(151), true, false, ""}, + + // Unsigned integers. + geTestCase{uint(0), false, false, ""}, + geTestCase{uint(149), false, false, ""}, + geTestCase{uint(150), true, false, ""}, + geTestCase{uint(151), true, false, ""}, + + geTestCase{uint8(0), false, false, ""}, + geTestCase{uint8(127), false, false, ""}, + + geTestCase{uint16(0), false, false, ""}, + geTestCase{uint16(149), false, false, ""}, + geTestCase{uint16(150), true, false, ""}, + geTestCase{uint16(151), true, false, ""}, + + geTestCase{uint32(0), false, false, ""}, + geTestCase{uint32(149), false, false, ""}, + geTestCase{uint32(150), true, false, ""}, + geTestCase{uint32(151), true, false, ""}, + + geTestCase{uint64(0), false, false, ""}, + geTestCase{uint64(149), false, false, ""}, + geTestCase{uint64(150), true, false, ""}, + geTestCase{uint64(151), true, false, ""}, + + geTestCase{uintptr(0), false, false, ""}, + geTestCase{uintptr(149), false, false, ""}, + geTestCase{uintptr(150), true, false, ""}, + geTestCase{uintptr(151), true, false, ""}, + + // Floating point. + geTestCase{float32(-1), false, false, ""}, + geTestCase{float32(149), false, false, ""}, + geTestCase{float32(149.8), false, false, ""}, + geTestCase{float32(149.9), true, false, ""}, + geTestCase{float32(150), true, false, ""}, + geTestCase{float32(151), true, false, ""}, + + geTestCase{float64(-1), false, false, ""}, + geTestCase{float64(149), false, false, ""}, + geTestCase{float64(149.8), false, false, ""}, + geTestCase{float64(149.9), true, false, ""}, + geTestCase{float64(150), true, false, ""}, + geTestCase{float64(151), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// Subtle cases +//////////////////////////////////////////////////////////////////////// + +func (t *GreaterOrEqualTest) Int64NotExactlyRepresentableBySinglePrecision() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := GreaterOrEqual(int64(kTwoTo25 + 1)) + + desc := matcher.Description() + expectedDesc := "greater than or equal to 33554433" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + // Signed integers. + geTestCase{-1, false, false, ""}, + geTestCase{kTwoTo25 + 0, false, false, ""}, + geTestCase{kTwoTo25 + 1, true, false, ""}, + geTestCase{kTwoTo25 + 2, true, false, ""}, + + geTestCase{int(-1), false, false, ""}, + geTestCase{int(kTwoTo25 + 0), false, false, ""}, + geTestCase{int(kTwoTo25 + 1), true, false, ""}, + geTestCase{int(kTwoTo25 + 2), true, false, ""}, + + geTestCase{int8(-1), false, false, ""}, + geTestCase{int8(127), false, false, ""}, + + geTestCase{int16(-1), false, false, ""}, + geTestCase{int16(0), false, false, ""}, + geTestCase{int16(32767), false, false, ""}, + + geTestCase{int32(-1), false, false, ""}, + geTestCase{int32(kTwoTo25 + 0), false, false, ""}, + geTestCase{int32(kTwoTo25 + 1), true, false, ""}, + geTestCase{int32(kTwoTo25 + 2), true, false, ""}, + + geTestCase{int64(-1), false, false, ""}, + geTestCase{int64(kTwoTo25 + 0), false, false, ""}, + geTestCase{int64(kTwoTo25 + 1), true, false, ""}, + geTestCase{int64(kTwoTo25 + 2), true, false, ""}, + + // Unsigned integers. + geTestCase{uint(0), false, false, ""}, + geTestCase{uint(kTwoTo25 + 0), false, false, ""}, + geTestCase{uint(kTwoTo25 + 1), true, false, ""}, + geTestCase{uint(kTwoTo25 + 2), true, false, ""}, + + geTestCase{uint8(0), false, false, ""}, + geTestCase{uint8(255), false, false, ""}, + + geTestCase{uint16(0), false, false, ""}, + geTestCase{uint16(65535), false, false, ""}, + + geTestCase{uint32(0), false, false, ""}, + geTestCase{uint32(kTwoTo25 + 0), false, false, ""}, + geTestCase{uint32(kTwoTo25 + 1), true, false, ""}, + geTestCase{uint32(kTwoTo25 + 2), true, false, ""}, + + geTestCase{uint64(0), false, false, ""}, + geTestCase{uint64(kTwoTo25 + 0), false, false, ""}, + geTestCase{uint64(kTwoTo25 + 1), true, false, ""}, + geTestCase{uint64(kTwoTo25 + 2), true, false, ""}, + + geTestCase{uintptr(0), false, false, ""}, + geTestCase{uintptr(kTwoTo25 + 0), false, false, ""}, + geTestCase{uintptr(kTwoTo25 + 1), true, false, ""}, + geTestCase{uintptr(kTwoTo25 + 2), true, false, ""}, + + // Floating point. + geTestCase{float32(-1), false, false, ""}, + geTestCase{float32(kTwoTo25 - 2), false, false, ""}, + geTestCase{float32(kTwoTo25 - 1), true, false, ""}, + geTestCase{float32(kTwoTo25 + 0), true, false, ""}, + geTestCase{float32(kTwoTo25 + 1), true, false, ""}, + geTestCase{float32(kTwoTo25 + 2), true, false, ""}, + geTestCase{float32(kTwoTo25 + 3), true, false, ""}, + + geTestCase{float64(-1), false, false, ""}, + geTestCase{float64(kTwoTo25 - 2), false, false, ""}, + geTestCase{float64(kTwoTo25 - 1), false, false, ""}, + geTestCase{float64(kTwoTo25 + 0), false, false, ""}, + geTestCase{float64(kTwoTo25 + 1), true, false, ""}, + geTestCase{float64(kTwoTo25 + 2), true, false, ""}, + geTestCase{float64(kTwoTo25 + 3), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterOrEqualTest) Int64NotExactlyRepresentableByDoublePrecision() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := GreaterOrEqual(int64(kTwoTo54 + 1)) + + desc := matcher.Description() + expectedDesc := "greater than or equal to 18014398509481985" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + // Signed integers. + geTestCase{-1, false, false, ""}, + geTestCase{1 << 30, false, false, ""}, + + geTestCase{int(-1), false, false, ""}, + geTestCase{int(math.MaxInt32), false, false, ""}, + + geTestCase{int8(-1), false, false, ""}, + geTestCase{int8(127), false, false, ""}, + + geTestCase{int16(-1), false, false, ""}, + geTestCase{int16(0), false, false, ""}, + geTestCase{int16(32767), false, false, ""}, + + geTestCase{int32(-1), false, false, ""}, + geTestCase{int32(math.MaxInt32), false, false, ""}, + + geTestCase{int64(-1), false, false, ""}, + geTestCase{int64(kTwoTo54 - 1), false, false, ""}, + geTestCase{int64(kTwoTo54 + 0), false, false, ""}, + geTestCase{int64(kTwoTo54 + 1), true, false, ""}, + geTestCase{int64(kTwoTo54 + 2), true, false, ""}, + + // Unsigned integers. + geTestCase{uint(0), false, false, ""}, + geTestCase{uint(math.MaxUint32), false, false, ""}, + + geTestCase{uint8(0), false, false, ""}, + geTestCase{uint8(255), false, false, ""}, + + geTestCase{uint16(0), false, false, ""}, + geTestCase{uint16(65535), false, false, ""}, + + geTestCase{uint32(0), false, false, ""}, + geTestCase{uint32(math.MaxUint32), false, false, ""}, + + geTestCase{uint64(0), false, false, ""}, + geTestCase{uint64(kTwoTo54 - 1), false, false, ""}, + geTestCase{uint64(kTwoTo54 + 0), false, false, ""}, + geTestCase{uint64(kTwoTo54 + 1), true, false, ""}, + geTestCase{uint64(kTwoTo54 + 2), true, false, ""}, + + geTestCase{uintptr(0), false, false, ""}, + geTestCase{uintptr(kTwoTo54 - 1), false, false, ""}, + geTestCase{uintptr(kTwoTo54 + 0), false, false, ""}, + geTestCase{uintptr(kTwoTo54 + 1), true, false, ""}, + geTestCase{uintptr(kTwoTo54 + 2), true, false, ""}, + + // Floating point. + geTestCase{float64(-1), false, false, ""}, + geTestCase{float64(kTwoTo54 - 2), false, false, ""}, + geTestCase{float64(kTwoTo54 - 1), true, false, ""}, + geTestCase{float64(kTwoTo54 + 0), true, false, ""}, + geTestCase{float64(kTwoTo54 + 1), true, false, ""}, + geTestCase{float64(kTwoTo54 + 2), true, false, ""}, + geTestCase{float64(kTwoTo54 + 3), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterOrEqualTest) Uint64NotExactlyRepresentableBySinglePrecision() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := GreaterOrEqual(uint64(kTwoTo25 + 1)) + + desc := matcher.Description() + expectedDesc := "greater than or equal to 33554433" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + // Signed integers. + geTestCase{-1, false, false, ""}, + geTestCase{kTwoTo25 + 0, false, false, ""}, + geTestCase{kTwoTo25 + 1, true, false, ""}, + geTestCase{kTwoTo25 + 2, true, false, ""}, + + geTestCase{int(-1), false, false, ""}, + geTestCase{int(kTwoTo25 + 0), false, false, ""}, + geTestCase{int(kTwoTo25 + 1), true, false, ""}, + geTestCase{int(kTwoTo25 + 2), true, false, ""}, + + geTestCase{int8(-1), false, false, ""}, + geTestCase{int8(127), false, false, ""}, + + geTestCase{int16(-1), false, false, ""}, + geTestCase{int16(0), false, false, ""}, + geTestCase{int16(32767), false, false, ""}, + + geTestCase{int32(-1), false, false, ""}, + geTestCase{int32(kTwoTo25 + 0), false, false, ""}, + geTestCase{int32(kTwoTo25 + 1), true, false, ""}, + geTestCase{int32(kTwoTo25 + 2), true, false, ""}, + + geTestCase{int64(-1), false, false, ""}, + geTestCase{int64(kTwoTo25 + 0), false, false, ""}, + geTestCase{int64(kTwoTo25 + 1), true, false, ""}, + geTestCase{int64(kTwoTo25 + 2), true, false, ""}, + + // Unsigned integers. + geTestCase{uint(0), false, false, ""}, + geTestCase{uint(kTwoTo25 + 0), false, false, ""}, + geTestCase{uint(kTwoTo25 + 1), true, false, ""}, + geTestCase{uint(kTwoTo25 + 2), true, false, ""}, + + geTestCase{uint8(0), false, false, ""}, + geTestCase{uint8(255), false, false, ""}, + + geTestCase{uint16(0), false, false, ""}, + geTestCase{uint16(65535), false, false, ""}, + + geTestCase{uint32(0), false, false, ""}, + geTestCase{uint32(kTwoTo25 + 0), false, false, ""}, + geTestCase{uint32(kTwoTo25 + 1), true, false, ""}, + geTestCase{uint32(kTwoTo25 + 2), true, false, ""}, + + geTestCase{uint64(0), false, false, ""}, + geTestCase{uint64(kTwoTo25 + 0), false, false, ""}, + geTestCase{uint64(kTwoTo25 + 1), true, false, ""}, + geTestCase{uint64(kTwoTo25 + 2), true, false, ""}, + + geTestCase{uintptr(0), false, false, ""}, + geTestCase{uintptr(kTwoTo25 + 0), false, false, ""}, + geTestCase{uintptr(kTwoTo25 + 1), true, false, ""}, + geTestCase{uintptr(kTwoTo25 + 2), true, false, ""}, + + // Floating point. + geTestCase{float32(-1), false, false, ""}, + geTestCase{float32(kTwoTo25 - 2), false, false, ""}, + geTestCase{float32(kTwoTo25 - 1), true, false, ""}, + geTestCase{float32(kTwoTo25 + 0), true, false, ""}, + geTestCase{float32(kTwoTo25 + 1), true, false, ""}, + geTestCase{float32(kTwoTo25 + 2), true, false, ""}, + geTestCase{float32(kTwoTo25 + 3), true, false, ""}, + + geTestCase{float64(-1), false, false, ""}, + geTestCase{float64(kTwoTo25 - 2), false, false, ""}, + geTestCase{float64(kTwoTo25 - 1), false, false, ""}, + geTestCase{float64(kTwoTo25 + 0), false, false, ""}, + geTestCase{float64(kTwoTo25 + 1), true, false, ""}, + geTestCase{float64(kTwoTo25 + 2), true, false, ""}, + geTestCase{float64(kTwoTo25 + 3), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterOrEqualTest) Uint64NotExactlyRepresentableByDoublePrecision() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := GreaterOrEqual(uint64(kTwoTo54 + 1)) + + desc := matcher.Description() + expectedDesc := "greater than or equal to 18014398509481985" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + // Signed integers. + geTestCase{-1, false, false, ""}, + geTestCase{1 << 30, false, false, ""}, + + geTestCase{int(-1), false, false, ""}, + geTestCase{int(math.MaxInt32), false, false, ""}, + + geTestCase{int8(-1), false, false, ""}, + geTestCase{int8(127), false, false, ""}, + + geTestCase{int16(-1), false, false, ""}, + geTestCase{int16(0), false, false, ""}, + geTestCase{int16(32767), false, false, ""}, + + geTestCase{int32(-1), false, false, ""}, + geTestCase{int32(math.MaxInt32), false, false, ""}, + + geTestCase{int64(-1), false, false, ""}, + geTestCase{int64(kTwoTo54 - 1), false, false, ""}, + geTestCase{int64(kTwoTo54 + 0), false, false, ""}, + geTestCase{int64(kTwoTo54 + 1), true, false, ""}, + geTestCase{int64(kTwoTo54 + 2), true, false, ""}, + + // Unsigned integers. + geTestCase{uint(0), false, false, ""}, + geTestCase{uint(math.MaxUint32), false, false, ""}, + + geTestCase{uint8(0), false, false, ""}, + geTestCase{uint8(255), false, false, ""}, + + geTestCase{uint16(0), false, false, ""}, + geTestCase{uint16(65535), false, false, ""}, + + geTestCase{uint32(0), false, false, ""}, + geTestCase{uint32(math.MaxUint32), false, false, ""}, + + geTestCase{uint64(0), false, false, ""}, + geTestCase{uint64(kTwoTo54 - 1), false, false, ""}, + geTestCase{uint64(kTwoTo54 + 0), false, false, ""}, + geTestCase{uint64(kTwoTo54 + 1), true, false, ""}, + geTestCase{uint64(kTwoTo54 + 2), true, false, ""}, + + geTestCase{uintptr(0), false, false, ""}, + geTestCase{uintptr(kTwoTo54 - 1), false, false, ""}, + geTestCase{uintptr(kTwoTo54 + 0), false, false, ""}, + geTestCase{uintptr(kTwoTo54 + 1), true, false, ""}, + geTestCase{uintptr(kTwoTo54 + 2), true, false, ""}, + + // Floating point. + geTestCase{float64(-1), false, false, ""}, + geTestCase{float64(kTwoTo54 - 2), false, false, ""}, + geTestCase{float64(kTwoTo54 - 1), true, false, ""}, + geTestCase{float64(kTwoTo54 + 0), true, false, ""}, + geTestCase{float64(kTwoTo54 + 1), true, false, ""}, + geTestCase{float64(kTwoTo54 + 2), true, false, ""}, + geTestCase{float64(kTwoTo54 + 3), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterOrEqualTest) Float32AboveExactIntegerRange() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := GreaterOrEqual(float32(kTwoTo25 + 1)) + + desc := matcher.Description() + expectedDesc := "greater than or equal to 3.3554432e+07" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + // Signed integers. + geTestCase{int64(-1), false, false, ""}, + geTestCase{int64(kTwoTo25 - 2), false, false, ""}, + geTestCase{int64(kTwoTo25 - 1), true, false, ""}, + geTestCase{int64(kTwoTo25 + 0), true, false, ""}, + geTestCase{int64(kTwoTo25 + 1), true, false, ""}, + geTestCase{int64(kTwoTo25 + 2), true, false, ""}, + geTestCase{int64(kTwoTo25 + 3), true, false, ""}, + + // Unsigned integers. + geTestCase{uint64(0), false, false, ""}, + geTestCase{uint64(kTwoTo25 - 2), false, false, ""}, + geTestCase{uint64(kTwoTo25 - 1), true, false, ""}, + geTestCase{uint64(kTwoTo25 + 0), true, false, ""}, + geTestCase{uint64(kTwoTo25 + 1), true, false, ""}, + geTestCase{uint64(kTwoTo25 + 2), true, false, ""}, + geTestCase{uint64(kTwoTo25 + 3), true, false, ""}, + + // Floating point. + geTestCase{float32(-1), false, false, ""}, + geTestCase{float32(kTwoTo25 - 2), false, false, ""}, + geTestCase{float32(kTwoTo25 - 1), true, false, ""}, + geTestCase{float32(kTwoTo25 + 0), true, false, ""}, + geTestCase{float32(kTwoTo25 + 1), true, false, ""}, + geTestCase{float32(kTwoTo25 + 2), true, false, ""}, + geTestCase{float32(kTwoTo25 + 3), true, false, ""}, + + geTestCase{float64(-1), false, false, ""}, + geTestCase{float64(kTwoTo25 - 2), false, false, ""}, + geTestCase{float64(kTwoTo25 - 1), true, false, ""}, + geTestCase{float64(kTwoTo25 + 0), true, false, ""}, + geTestCase{float64(kTwoTo25 + 1), true, false, ""}, + geTestCase{float64(kTwoTo25 + 2), true, false, ""}, + geTestCase{float64(kTwoTo25 + 3), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterOrEqualTest) Float64AboveExactIntegerRange() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := GreaterOrEqual(float64(kTwoTo54 + 1)) + + desc := matcher.Description() + expectedDesc := "greater than or equal to 1.8014398509481984e+16" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + // Signed integers. + geTestCase{int64(-1), false, false, ""}, + geTestCase{int64(kTwoTo54 - 2), false, false, ""}, + geTestCase{int64(kTwoTo54 - 1), true, false, ""}, + geTestCase{int64(kTwoTo54 + 0), true, false, ""}, + geTestCase{int64(kTwoTo54 + 1), true, false, ""}, + geTestCase{int64(kTwoTo54 + 2), true, false, ""}, + geTestCase{int64(kTwoTo54 + 3), true, false, ""}, + + // Unsigned integers. + geTestCase{uint64(0), false, false, ""}, + geTestCase{uint64(kTwoTo54 - 2), false, false, ""}, + geTestCase{uint64(kTwoTo54 - 1), true, false, ""}, + geTestCase{uint64(kTwoTo54 + 0), true, false, ""}, + geTestCase{uint64(kTwoTo54 + 1), true, false, ""}, + geTestCase{uint64(kTwoTo54 + 2), true, false, ""}, + geTestCase{uint64(kTwoTo54 + 3), true, false, ""}, + + // Floating point. + geTestCase{float64(-1), false, false, ""}, + geTestCase{float64(kTwoTo54 - 2), false, false, ""}, + geTestCase{float64(kTwoTo54 - 1), true, false, ""}, + geTestCase{float64(kTwoTo54 + 0), true, false, ""}, + geTestCase{float64(kTwoTo54 + 1), true, false, ""}, + geTestCase{float64(kTwoTo54 + 2), true, false, ""}, + geTestCase{float64(kTwoTo54 + 3), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// String literals +//////////////////////////////////////////////////////////////////////// + +func (t *GreaterOrEqualTest) EmptyString() { + matcher := GreaterOrEqual("") + desc := matcher.Description() + expectedDesc := "greater than or equal to \"\"" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + geTestCase{"", true, false, ""}, + geTestCase{"\x00", true, false, ""}, + geTestCase{"a", true, false, ""}, + geTestCase{"foo", true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterOrEqualTest) SingleNullByte() { + matcher := GreaterOrEqual("\x00") + desc := matcher.Description() + expectedDesc := "greater than or equal to \"\x00\"" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + geTestCase{"", false, false, ""}, + geTestCase{"\x00", true, false, ""}, + geTestCase{"a", true, false, ""}, + geTestCase{"foo", true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterOrEqualTest) LongerString() { + matcher := GreaterOrEqual("foo\x00") + desc := matcher.Description() + expectedDesc := "greater than or equal to \"foo\x00\"" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []geTestCase{ + geTestCase{"", false, false, ""}, + geTestCase{"\x00", false, false, ""}, + geTestCase{"bar", false, false, ""}, + geTestCase{"foo", false, false, ""}, + geTestCase{"foo\x00", true, false, ""}, + geTestCase{"fooa", true, false, ""}, + geTestCase{"qux", true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than_test.go new file mode 100644 index 000000000..bf70fe566 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than_test.go @@ -0,0 +1,1077 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "math" + + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type GreaterThanTest struct { +} + +func init() { RegisterTestSuite(&GreaterThanTest{}) } + +type gtTestCase struct { + candidate interface{} + expectedResult bool + shouldBeFatal bool + expectedError string +} + +func (t *GreaterThanTest) checkTestCases(matcher Matcher, cases []gtTestCase) { + for i, c := range cases { + err := matcher.Matches(c.candidate) + + ExpectThat( + (err == nil), + Equals(c.expectedResult), + "Case %d (candidate %v)", + i, + c.candidate) + + if err == nil { + continue + } + + _, isFatal := err.(*FatalError) + ExpectEq( + c.shouldBeFatal, + isFatal, + "Case %d (candidate %v)", + i, + c.candidate) + + ExpectThat( + err, + Error(Equals(c.expectedError)), + "Case %d (candidate %v)", + i, + c.candidate) + } +} + +//////////////////////////////////////////////////////////////////////// +// Integer literals +//////////////////////////////////////////////////////////////////////// + +func (t *GreaterThanTest) IntegerCandidateBadTypes() { + matcher := GreaterThan(int(-150)) + + cases := []gtTestCase{ + gtTestCase{true, false, true, "which is not comparable"}, + gtTestCase{complex64(-151), false, true, "which is not comparable"}, + gtTestCase{complex128(-151), false, true, "which is not comparable"}, + gtTestCase{[...]int{-151}, false, true, "which is not comparable"}, + gtTestCase{make(chan int), false, true, "which is not comparable"}, + gtTestCase{func() {}, false, true, "which is not comparable"}, + gtTestCase{map[int]int{}, false, true, "which is not comparable"}, + gtTestCase{>TestCase{}, false, true, "which is not comparable"}, + gtTestCase{make([]int, 0), false, true, "which is not comparable"}, + gtTestCase{"-151", false, true, "which is not comparable"}, + gtTestCase{gtTestCase{}, false, true, "which is not comparable"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterThanTest) FloatCandidateBadTypes() { + matcher := GreaterThan(float32(-150)) + + cases := []gtTestCase{ + gtTestCase{true, false, true, "which is not comparable"}, + gtTestCase{complex64(-151), false, true, "which is not comparable"}, + gtTestCase{complex128(-151), false, true, "which is not comparable"}, + gtTestCase{[...]int{-151}, false, true, "which is not comparable"}, + gtTestCase{make(chan int), false, true, "which is not comparable"}, + gtTestCase{func() {}, false, true, "which is not comparable"}, + gtTestCase{map[int]int{}, false, true, "which is not comparable"}, + gtTestCase{>TestCase{}, false, true, "which is not comparable"}, + gtTestCase{make([]int, 0), false, true, "which is not comparable"}, + gtTestCase{"-151", false, true, "which is not comparable"}, + gtTestCase{gtTestCase{}, false, true, "which is not comparable"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterThanTest) StringCandidateBadTypes() { + matcher := GreaterThan("17") + + cases := []gtTestCase{ + gtTestCase{true, false, true, "which is not comparable"}, + gtTestCase{int(0), false, true, "which is not comparable"}, + gtTestCase{int8(0), false, true, "which is not comparable"}, + gtTestCase{int16(0), false, true, "which is not comparable"}, + gtTestCase{int32(0), false, true, "which is not comparable"}, + gtTestCase{int64(0), false, true, "which is not comparable"}, + gtTestCase{uint(0), false, true, "which is not comparable"}, + gtTestCase{uint8(0), false, true, "which is not comparable"}, + gtTestCase{uint16(0), false, true, "which is not comparable"}, + gtTestCase{uint32(0), false, true, "which is not comparable"}, + gtTestCase{uint64(0), false, true, "which is not comparable"}, + gtTestCase{float32(0), false, true, "which is not comparable"}, + gtTestCase{float64(0), false, true, "which is not comparable"}, + gtTestCase{complex64(-151), false, true, "which is not comparable"}, + gtTestCase{complex128(-151), false, true, "which is not comparable"}, + gtTestCase{[...]int{-151}, false, true, "which is not comparable"}, + gtTestCase{make(chan int), false, true, "which is not comparable"}, + gtTestCase{func() {}, false, true, "which is not comparable"}, + gtTestCase{map[int]int{}, false, true, "which is not comparable"}, + gtTestCase{>TestCase{}, false, true, "which is not comparable"}, + gtTestCase{make([]int, 0), false, true, "which is not comparable"}, + gtTestCase{gtTestCase{}, false, true, "which is not comparable"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterThanTest) BadArgument() { + panicked := false + + defer func() { + ExpectThat(panicked, Equals(true)) + }() + + defer func() { + if r := recover(); r != nil { + panicked = true + } + }() + + GreaterThan(complex128(0)) +} + +//////////////////////////////////////////////////////////////////////// +// Integer literals +//////////////////////////////////////////////////////////////////////// + +func (t *GreaterThanTest) NegativeIntegerLiteral() { + matcher := GreaterThan(-150) + desc := matcher.Description() + expectedDesc := "greater than -150" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + // Signed integers. + gtTestCase{-(1 << 30), false, false, ""}, + gtTestCase{-151, false, false, ""}, + gtTestCase{-150, false, false, ""}, + gtTestCase{-149, true, false, ""}, + gtTestCase{0, true, false, ""}, + gtTestCase{17, true, false, ""}, + + gtTestCase{int(-(1 << 30)), false, false, ""}, + gtTestCase{int(-151), false, false, ""}, + gtTestCase{int(-150), false, false, ""}, + gtTestCase{int(-149), true, false, ""}, + gtTestCase{int(0), true, false, ""}, + gtTestCase{int(17), true, false, ""}, + + gtTestCase{int8(-127), true, false, ""}, + gtTestCase{int8(0), true, false, ""}, + gtTestCase{int8(17), true, false, ""}, + + gtTestCase{int16(-(1 << 14)), false, false, ""}, + gtTestCase{int16(-151), false, false, ""}, + gtTestCase{int16(-150), false, false, ""}, + gtTestCase{int16(-149), true, false, ""}, + gtTestCase{int16(0), true, false, ""}, + gtTestCase{int16(17), true, false, ""}, + + gtTestCase{int32(-(1 << 30)), false, false, ""}, + gtTestCase{int32(-151), false, false, ""}, + gtTestCase{int32(-150), false, false, ""}, + gtTestCase{int32(-149), true, false, ""}, + gtTestCase{int32(0), true, false, ""}, + gtTestCase{int32(17), true, false, ""}, + + gtTestCase{int64(-(1 << 30)), false, false, ""}, + gtTestCase{int64(-151), false, false, ""}, + gtTestCase{int64(-150), false, false, ""}, + gtTestCase{int64(-149), true, false, ""}, + gtTestCase{int64(0), true, false, ""}, + gtTestCase{int64(17), true, false, ""}, + + // Unsigned integers. + gtTestCase{uint((1 << 32) - 151), true, false, ""}, + gtTestCase{uint(0), true, false, ""}, + gtTestCase{uint(17), true, false, ""}, + + gtTestCase{uint8(0), true, false, ""}, + gtTestCase{uint8(17), true, false, ""}, + gtTestCase{uint8(253), true, false, ""}, + + gtTestCase{uint16((1 << 16) - 151), true, false, ""}, + gtTestCase{uint16(0), true, false, ""}, + gtTestCase{uint16(17), true, false, ""}, + + gtTestCase{uint32((1 << 32) - 151), true, false, ""}, + gtTestCase{uint32(0), true, false, ""}, + gtTestCase{uint32(17), true, false, ""}, + + gtTestCase{uint64((1 << 64) - 151), true, false, ""}, + gtTestCase{uint64(0), true, false, ""}, + gtTestCase{uint64(17), true, false, ""}, + + // Floating point. + gtTestCase{float32(-(1 << 30)), false, false, ""}, + gtTestCase{float32(-151), false, false, ""}, + gtTestCase{float32(-150.1), false, false, ""}, + gtTestCase{float32(-150), false, false, ""}, + gtTestCase{float32(-149.9), true, false, ""}, + gtTestCase{float32(0), true, false, ""}, + gtTestCase{float32(17), true, false, ""}, + gtTestCase{float32(160), true, false, ""}, + + gtTestCase{float64(-(1 << 30)), false, false, ""}, + gtTestCase{float64(-151), false, false, ""}, + gtTestCase{float64(-150.1), false, false, ""}, + gtTestCase{float64(-150), false, false, ""}, + gtTestCase{float64(-149.9), true, false, ""}, + gtTestCase{float64(0), true, false, ""}, + gtTestCase{float64(17), true, false, ""}, + gtTestCase{float64(160), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterThanTest) ZeroIntegerLiteral() { + matcher := GreaterThan(0) + desc := matcher.Description() + expectedDesc := "greater than 0" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + // Signed integers. + gtTestCase{-(1 << 30), false, false, ""}, + gtTestCase{-1, false, false, ""}, + gtTestCase{0, false, false, ""}, + gtTestCase{1, true, false, ""}, + gtTestCase{17, true, false, ""}, + gtTestCase{(1 << 30), true, false, ""}, + + gtTestCase{int(-(1 << 30)), false, false, ""}, + gtTestCase{int(-1), false, false, ""}, + gtTestCase{int(0), false, false, ""}, + gtTestCase{int(1), true, false, ""}, + gtTestCase{int(17), true, false, ""}, + + gtTestCase{int8(-1), false, false, ""}, + gtTestCase{int8(0), false, false, ""}, + gtTestCase{int8(1), true, false, ""}, + + gtTestCase{int16(-(1 << 14)), false, false, ""}, + gtTestCase{int16(-1), false, false, ""}, + gtTestCase{int16(0), false, false, ""}, + gtTestCase{int16(1), true, false, ""}, + gtTestCase{int16(17), true, false, ""}, + + gtTestCase{int32(-(1 << 30)), false, false, ""}, + gtTestCase{int32(-1), false, false, ""}, + gtTestCase{int32(0), false, false, ""}, + gtTestCase{int32(1), true, false, ""}, + gtTestCase{int32(17), true, false, ""}, + + gtTestCase{int64(-(1 << 30)), false, false, ""}, + gtTestCase{int64(-1), false, false, ""}, + gtTestCase{int64(0), false, false, ""}, + gtTestCase{int64(1), true, false, ""}, + gtTestCase{int64(17), true, false, ""}, + + // Unsigned integers. + gtTestCase{uint((1 << 32) - 1), true, false, ""}, + gtTestCase{uint(0), false, false, ""}, + gtTestCase{uint(1), true, false, ""}, + gtTestCase{uint(17), true, false, ""}, + + gtTestCase{uint8(0), false, false, ""}, + gtTestCase{uint8(1), true, false, ""}, + gtTestCase{uint8(17), true, false, ""}, + gtTestCase{uint8(253), true, false, ""}, + + gtTestCase{uint16((1 << 16) - 1), true, false, ""}, + gtTestCase{uint16(0), false, false, ""}, + gtTestCase{uint16(1), true, false, ""}, + gtTestCase{uint16(17), true, false, ""}, + + gtTestCase{uint32((1 << 32) - 1), true, false, ""}, + gtTestCase{uint32(0), false, false, ""}, + gtTestCase{uint32(1), true, false, ""}, + gtTestCase{uint32(17), true, false, ""}, + + gtTestCase{uint64((1 << 64) - 1), true, false, ""}, + gtTestCase{uint64(0), false, false, ""}, + gtTestCase{uint64(1), true, false, ""}, + gtTestCase{uint64(17), true, false, ""}, + + // Floating point. + gtTestCase{float32(-(1 << 30)), false, false, ""}, + gtTestCase{float32(-1), false, false, ""}, + gtTestCase{float32(-0.1), false, false, ""}, + gtTestCase{float32(-0.0), false, false, ""}, + gtTestCase{float32(0), false, false, ""}, + gtTestCase{float32(0.1), true, false, ""}, + gtTestCase{float32(17), true, false, ""}, + gtTestCase{float32(160), true, false, ""}, + + gtTestCase{float64(-(1 << 30)), false, false, ""}, + gtTestCase{float64(-1), false, false, ""}, + gtTestCase{float64(-0.1), false, false, ""}, + gtTestCase{float64(-0), false, false, ""}, + gtTestCase{float64(0), false, false, ""}, + gtTestCase{float64(0.1), true, false, ""}, + gtTestCase{float64(17), true, false, ""}, + gtTestCase{float64(160), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterThanTest) PositiveIntegerLiteral() { + matcher := GreaterThan(150) + desc := matcher.Description() + expectedDesc := "greater than 150" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + // Signed integers. + gtTestCase{-1, false, false, ""}, + gtTestCase{149, false, false, ""}, + gtTestCase{150, false, false, ""}, + gtTestCase{151, true, false, ""}, + + gtTestCase{int(-1), false, false, ""}, + gtTestCase{int(149), false, false, ""}, + gtTestCase{int(150), false, false, ""}, + gtTestCase{int(151), true, false, ""}, + + gtTestCase{int8(-1), false, false, ""}, + gtTestCase{int8(0), false, false, ""}, + gtTestCase{int8(17), false, false, ""}, + gtTestCase{int8(127), false, false, ""}, + + gtTestCase{int16(-1), false, false, ""}, + gtTestCase{int16(149), false, false, ""}, + gtTestCase{int16(150), false, false, ""}, + gtTestCase{int16(151), true, false, ""}, + + gtTestCase{int32(-1), false, false, ""}, + gtTestCase{int32(149), false, false, ""}, + gtTestCase{int32(150), false, false, ""}, + gtTestCase{int32(151), true, false, ""}, + + gtTestCase{int64(-1), false, false, ""}, + gtTestCase{int64(149), false, false, ""}, + gtTestCase{int64(150), false, false, ""}, + gtTestCase{int64(151), true, false, ""}, + + // Unsigned integers. + gtTestCase{uint(0), false, false, ""}, + gtTestCase{uint(149), false, false, ""}, + gtTestCase{uint(150), false, false, ""}, + gtTestCase{uint(151), true, false, ""}, + + gtTestCase{uint8(0), false, false, ""}, + gtTestCase{uint8(127), false, false, ""}, + + gtTestCase{uint16(0), false, false, ""}, + gtTestCase{uint16(149), false, false, ""}, + gtTestCase{uint16(150), false, false, ""}, + gtTestCase{uint16(151), true, false, ""}, + + gtTestCase{uint32(0), false, false, ""}, + gtTestCase{uint32(149), false, false, ""}, + gtTestCase{uint32(150), false, false, ""}, + gtTestCase{uint32(151), true, false, ""}, + + gtTestCase{uint64(0), false, false, ""}, + gtTestCase{uint64(149), false, false, ""}, + gtTestCase{uint64(150), false, false, ""}, + gtTestCase{uint64(151), true, false, ""}, + + // Floating point. + gtTestCase{float32(-1), false, false, ""}, + gtTestCase{float32(149), false, false, ""}, + gtTestCase{float32(149.9), false, false, ""}, + gtTestCase{float32(150), false, false, ""}, + gtTestCase{float32(150.1), true, false, ""}, + gtTestCase{float32(151), true, false, ""}, + + gtTestCase{float64(-1), false, false, ""}, + gtTestCase{float64(149), false, false, ""}, + gtTestCase{float64(149.9), false, false, ""}, + gtTestCase{float64(150), false, false, ""}, + gtTestCase{float64(150.1), true, false, ""}, + gtTestCase{float64(151), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// Float literals +//////////////////////////////////////////////////////////////////////// + +func (t *GreaterThanTest) NegativeFloatLiteral() { + matcher := GreaterThan(-150.1) + desc := matcher.Description() + expectedDesc := "greater than -150.1" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + // Signed integers. + gtTestCase{-(1 << 30), false, false, ""}, + gtTestCase{-151, false, false, ""}, + gtTestCase{-150.1, false, false, ""}, + gtTestCase{-150, true, false, ""}, + gtTestCase{-149, true, false, ""}, + gtTestCase{0, true, false, ""}, + gtTestCase{17, true, false, ""}, + + gtTestCase{int(-(1 << 30)), false, false, ""}, + gtTestCase{int(-151), false, false, ""}, + gtTestCase{int(-150), true, false, ""}, + gtTestCase{int(-149), true, false, ""}, + gtTestCase{int(0), true, false, ""}, + gtTestCase{int(17), true, false, ""}, + + gtTestCase{int8(-127), true, false, ""}, + gtTestCase{int8(0), true, false, ""}, + gtTestCase{int8(17), true, false, ""}, + + gtTestCase{int16(-(1 << 14)), false, false, ""}, + gtTestCase{int16(-151), false, false, ""}, + gtTestCase{int16(-150), true, false, ""}, + gtTestCase{int16(-149), true, false, ""}, + gtTestCase{int16(0), true, false, ""}, + gtTestCase{int16(17), true, false, ""}, + + gtTestCase{int32(-(1 << 30)), false, false, ""}, + gtTestCase{int32(-151), false, false, ""}, + gtTestCase{int32(-150), true, false, ""}, + gtTestCase{int32(-149), true, false, ""}, + gtTestCase{int32(0), true, false, ""}, + gtTestCase{int32(17), true, false, ""}, + + gtTestCase{int64(-(1 << 30)), false, false, ""}, + gtTestCase{int64(-151), false, false, ""}, + gtTestCase{int64(-150), true, false, ""}, + gtTestCase{int64(-149), true, false, ""}, + gtTestCase{int64(0), true, false, ""}, + gtTestCase{int64(17), true, false, ""}, + + // Unsigned integers. + gtTestCase{uint((1 << 32) - 151), true, false, ""}, + gtTestCase{uint(0), true, false, ""}, + gtTestCase{uint(17), true, false, ""}, + + gtTestCase{uint8(0), true, false, ""}, + gtTestCase{uint8(17), true, false, ""}, + gtTestCase{uint8(253), true, false, ""}, + + gtTestCase{uint16((1 << 16) - 151), true, false, ""}, + gtTestCase{uint16(0), true, false, ""}, + gtTestCase{uint16(17), true, false, ""}, + + gtTestCase{uint32((1 << 32) - 151), true, false, ""}, + gtTestCase{uint32(0), true, false, ""}, + gtTestCase{uint32(17), true, false, ""}, + + gtTestCase{uint64((1 << 64) - 151), true, false, ""}, + gtTestCase{uint64(0), true, false, ""}, + gtTestCase{uint64(17), true, false, ""}, + + // Floating point. + gtTestCase{float32(-(1 << 30)), false, false, ""}, + gtTestCase{float32(-151), false, false, ""}, + gtTestCase{float32(-150.2), false, false, ""}, + gtTestCase{float32(-150.1), false, false, ""}, + gtTestCase{float32(-150), true, false, ""}, + gtTestCase{float32(0), true, false, ""}, + gtTestCase{float32(17), true, false, ""}, + gtTestCase{float32(160), true, false, ""}, + + gtTestCase{float64(-(1 << 30)), false, false, ""}, + gtTestCase{float64(-151), false, false, ""}, + gtTestCase{float64(-150.2), false, false, ""}, + gtTestCase{float64(-150.1), false, false, ""}, + gtTestCase{float64(-150), true, false, ""}, + gtTestCase{float64(0), true, false, ""}, + gtTestCase{float64(17), true, false, ""}, + gtTestCase{float64(160), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterThanTest) PositiveFloatLiteral() { + matcher := GreaterThan(149.9) + desc := matcher.Description() + expectedDesc := "greater than 149.9" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + // Signed integers. + gtTestCase{-1, false, false, ""}, + gtTestCase{149, false, false, ""}, + gtTestCase{149.9, false, false, ""}, + gtTestCase{150, true, false, ""}, + gtTestCase{151, true, false, ""}, + + gtTestCase{int(-1), false, false, ""}, + gtTestCase{int(149), false, false, ""}, + gtTestCase{int(150), true, false, ""}, + gtTestCase{int(151), true, false, ""}, + + gtTestCase{int8(-1), false, false, ""}, + gtTestCase{int8(0), false, false, ""}, + gtTestCase{int8(17), false, false, ""}, + gtTestCase{int8(127), false, false, ""}, + + gtTestCase{int16(-1), false, false, ""}, + gtTestCase{int16(149), false, false, ""}, + gtTestCase{int16(150), true, false, ""}, + gtTestCase{int16(151), true, false, ""}, + + gtTestCase{int32(-1), false, false, ""}, + gtTestCase{int32(149), false, false, ""}, + gtTestCase{int32(150), true, false, ""}, + gtTestCase{int32(151), true, false, ""}, + + gtTestCase{int64(-1), false, false, ""}, + gtTestCase{int64(149), false, false, ""}, + gtTestCase{int64(150), true, false, ""}, + gtTestCase{int64(151), true, false, ""}, + + // Unsigned integers. + gtTestCase{uint(0), false, false, ""}, + gtTestCase{uint(149), false, false, ""}, + gtTestCase{uint(150), true, false, ""}, + gtTestCase{uint(151), true, false, ""}, + + gtTestCase{uint8(0), false, false, ""}, + gtTestCase{uint8(127), false, false, ""}, + + gtTestCase{uint16(0), false, false, ""}, + gtTestCase{uint16(149), false, false, ""}, + gtTestCase{uint16(150), true, false, ""}, + gtTestCase{uint16(151), true, false, ""}, + + gtTestCase{uint32(0), false, false, ""}, + gtTestCase{uint32(149), false, false, ""}, + gtTestCase{uint32(150), true, false, ""}, + gtTestCase{uint32(151), true, false, ""}, + + gtTestCase{uint64(0), false, false, ""}, + gtTestCase{uint64(149), false, false, ""}, + gtTestCase{uint64(150), true, false, ""}, + gtTestCase{uint64(151), true, false, ""}, + + // Floating point. + gtTestCase{float32(-1), false, false, ""}, + gtTestCase{float32(149), false, false, ""}, + gtTestCase{float32(149.8), false, false, ""}, + gtTestCase{float32(149.9), false, false, ""}, + gtTestCase{float32(150), true, false, ""}, + gtTestCase{float32(151), true, false, ""}, + + gtTestCase{float64(-1), false, false, ""}, + gtTestCase{float64(149), false, false, ""}, + gtTestCase{float64(149.8), false, false, ""}, + gtTestCase{float64(149.9), false, false, ""}, + gtTestCase{float64(150), true, false, ""}, + gtTestCase{float64(151), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// Subtle cases +//////////////////////////////////////////////////////////////////////// + +func (t *GreaterThanTest) Int64NotExactlyRepresentableBySinglePrecision() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := GreaterThan(int64(kTwoTo25 + 1)) + + desc := matcher.Description() + expectedDesc := "greater than 33554433" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + // Signed integers. + gtTestCase{-1, false, false, ""}, + gtTestCase{kTwoTo25 + 0, false, false, ""}, + gtTestCase{kTwoTo25 + 1, false, false, ""}, + gtTestCase{kTwoTo25 + 2, true, false, ""}, + + gtTestCase{int(-1), false, false, ""}, + gtTestCase{int(kTwoTo25 + 0), false, false, ""}, + gtTestCase{int(kTwoTo25 + 1), false, false, ""}, + gtTestCase{int(kTwoTo25 + 2), true, false, ""}, + + gtTestCase{int8(-1), false, false, ""}, + gtTestCase{int8(127), false, false, ""}, + + gtTestCase{int16(-1), false, false, ""}, + gtTestCase{int16(0), false, false, ""}, + gtTestCase{int16(32767), false, false, ""}, + + gtTestCase{int32(-1), false, false, ""}, + gtTestCase{int32(kTwoTo25 + 0), false, false, ""}, + gtTestCase{int32(kTwoTo25 + 1), false, false, ""}, + gtTestCase{int32(kTwoTo25 + 2), true, false, ""}, + + gtTestCase{int64(-1), false, false, ""}, + gtTestCase{int64(kTwoTo25 + 0), false, false, ""}, + gtTestCase{int64(kTwoTo25 + 1), false, false, ""}, + gtTestCase{int64(kTwoTo25 + 2), true, false, ""}, + + // Unsigned integers. + gtTestCase{uint(0), false, false, ""}, + gtTestCase{uint(kTwoTo25 + 0), false, false, ""}, + gtTestCase{uint(kTwoTo25 + 1), false, false, ""}, + gtTestCase{uint(kTwoTo25 + 2), true, false, ""}, + + gtTestCase{uint8(0), false, false, ""}, + gtTestCase{uint8(255), false, false, ""}, + + gtTestCase{uint16(0), false, false, ""}, + gtTestCase{uint16(65535), false, false, ""}, + + gtTestCase{uint32(0), false, false, ""}, + gtTestCase{uint32(kTwoTo25 + 0), false, false, ""}, + gtTestCase{uint32(kTwoTo25 + 1), false, false, ""}, + gtTestCase{uint32(kTwoTo25 + 2), true, false, ""}, + + gtTestCase{uint64(0), false, false, ""}, + gtTestCase{uint64(kTwoTo25 + 0), false, false, ""}, + gtTestCase{uint64(kTwoTo25 + 1), false, false, ""}, + gtTestCase{uint64(kTwoTo25 + 2), true, false, ""}, + + // Floating point. + gtTestCase{float32(-1), false, false, ""}, + gtTestCase{float32(kTwoTo25 - 2), false, false, ""}, + gtTestCase{float32(kTwoTo25 - 1), false, false, ""}, + gtTestCase{float32(kTwoTo25 + 0), false, false, ""}, + gtTestCase{float32(kTwoTo25 + 1), false, false, ""}, + gtTestCase{float32(kTwoTo25 + 2), false, false, ""}, + gtTestCase{float32(kTwoTo25 + 3), true, false, ""}, + + gtTestCase{float64(-1), false, false, ""}, + gtTestCase{float64(kTwoTo25 - 2), false, false, ""}, + gtTestCase{float64(kTwoTo25 - 1), false, false, ""}, + gtTestCase{float64(kTwoTo25 + 0), false, false, ""}, + gtTestCase{float64(kTwoTo25 + 1), false, false, ""}, + gtTestCase{float64(kTwoTo25 + 2), true, false, ""}, + gtTestCase{float64(kTwoTo25 + 3), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterThanTest) Int64NotExactlyRepresentableByDoublePrecision() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := GreaterThan(int64(kTwoTo54 + 1)) + + desc := matcher.Description() + expectedDesc := "greater than 18014398509481985" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + // Signed integers. + gtTestCase{-1, false, false, ""}, + gtTestCase{1 << 30, false, false, ""}, + + gtTestCase{int(-1), false, false, ""}, + gtTestCase{int(math.MaxInt32), false, false, ""}, + + gtTestCase{int8(-1), false, false, ""}, + gtTestCase{int8(127), false, false, ""}, + + gtTestCase{int16(-1), false, false, ""}, + gtTestCase{int16(0), false, false, ""}, + gtTestCase{int16(32767), false, false, ""}, + + gtTestCase{int32(-1), false, false, ""}, + gtTestCase{int32(math.MaxInt32), false, false, ""}, + + gtTestCase{int64(-1), false, false, ""}, + gtTestCase{int64(kTwoTo54 - 1), false, false, ""}, + gtTestCase{int64(kTwoTo54 + 0), false, false, ""}, + gtTestCase{int64(kTwoTo54 + 1), false, false, ""}, + gtTestCase{int64(kTwoTo54 + 2), true, false, ""}, + + // Unsigned integers. + gtTestCase{uint(0), false, false, ""}, + gtTestCase{uint(math.MaxUint32), false, false, ""}, + + gtTestCase{uint8(0), false, false, ""}, + gtTestCase{uint8(255), false, false, ""}, + + gtTestCase{uint16(0), false, false, ""}, + gtTestCase{uint16(65535), false, false, ""}, + + gtTestCase{uint32(0), false, false, ""}, + gtTestCase{uint32(math.MaxUint32), false, false, ""}, + + gtTestCase{uint64(0), false, false, ""}, + gtTestCase{uint64(kTwoTo54 - 1), false, false, ""}, + gtTestCase{uint64(kTwoTo54 + 0), false, false, ""}, + gtTestCase{uint64(kTwoTo54 + 1), false, false, ""}, + gtTestCase{uint64(kTwoTo54 + 2), true, false, ""}, + + // Floating point. + gtTestCase{float64(-1), false, false, ""}, + gtTestCase{float64(kTwoTo54 - 2), false, false, ""}, + gtTestCase{float64(kTwoTo54 - 1), false, false, ""}, + gtTestCase{float64(kTwoTo54 + 0), false, false, ""}, + gtTestCase{float64(kTwoTo54 + 1), false, false, ""}, + gtTestCase{float64(kTwoTo54 + 2), false, false, ""}, + gtTestCase{float64(kTwoTo54 + 3), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterThanTest) Uint64NotExactlyRepresentableBySinglePrecision() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := GreaterThan(uint64(kTwoTo25 + 1)) + + desc := matcher.Description() + expectedDesc := "greater than 33554433" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + // Signed integers. + gtTestCase{-1, false, false, ""}, + gtTestCase{kTwoTo25 + 0, false, false, ""}, + gtTestCase{kTwoTo25 + 1, false, false, ""}, + gtTestCase{kTwoTo25 + 2, true, false, ""}, + + gtTestCase{int(-1), false, false, ""}, + gtTestCase{int(kTwoTo25 + 0), false, false, ""}, + gtTestCase{int(kTwoTo25 + 1), false, false, ""}, + gtTestCase{int(kTwoTo25 + 2), true, false, ""}, + + gtTestCase{int8(-1), false, false, ""}, + gtTestCase{int8(127), false, false, ""}, + + gtTestCase{int16(-1), false, false, ""}, + gtTestCase{int16(0), false, false, ""}, + gtTestCase{int16(32767), false, false, ""}, + + gtTestCase{int32(-1), false, false, ""}, + gtTestCase{int32(kTwoTo25 + 0), false, false, ""}, + gtTestCase{int32(kTwoTo25 + 1), false, false, ""}, + gtTestCase{int32(kTwoTo25 + 2), true, false, ""}, + + gtTestCase{int64(-1), false, false, ""}, + gtTestCase{int64(kTwoTo25 + 0), false, false, ""}, + gtTestCase{int64(kTwoTo25 + 1), false, false, ""}, + gtTestCase{int64(kTwoTo25 + 2), true, false, ""}, + + // Unsigned integers. + gtTestCase{uint(0), false, false, ""}, + gtTestCase{uint(kTwoTo25 + 0), false, false, ""}, + gtTestCase{uint(kTwoTo25 + 1), false, false, ""}, + gtTestCase{uint(kTwoTo25 + 2), true, false, ""}, + + gtTestCase{uint8(0), false, false, ""}, + gtTestCase{uint8(255), false, false, ""}, + + gtTestCase{uint16(0), false, false, ""}, + gtTestCase{uint16(65535), false, false, ""}, + + gtTestCase{uint32(0), false, false, ""}, + gtTestCase{uint32(kTwoTo25 + 0), false, false, ""}, + gtTestCase{uint32(kTwoTo25 + 1), false, false, ""}, + gtTestCase{uint32(kTwoTo25 + 2), true, false, ""}, + + gtTestCase{uint64(0), false, false, ""}, + gtTestCase{uint64(kTwoTo25 + 0), false, false, ""}, + gtTestCase{uint64(kTwoTo25 + 1), false, false, ""}, + gtTestCase{uint64(kTwoTo25 + 2), true, false, ""}, + + // Floating point. + gtTestCase{float32(-1), false, false, ""}, + gtTestCase{float32(kTwoTo25 - 2), false, false, ""}, + gtTestCase{float32(kTwoTo25 - 1), false, false, ""}, + gtTestCase{float32(kTwoTo25 + 0), false, false, ""}, + gtTestCase{float32(kTwoTo25 + 1), false, false, ""}, + gtTestCase{float32(kTwoTo25 + 2), false, false, ""}, + gtTestCase{float32(kTwoTo25 + 3), true, false, ""}, + + gtTestCase{float64(-1), false, false, ""}, + gtTestCase{float64(kTwoTo25 - 2), false, false, ""}, + gtTestCase{float64(kTwoTo25 - 1), false, false, ""}, + gtTestCase{float64(kTwoTo25 + 0), false, false, ""}, + gtTestCase{float64(kTwoTo25 + 1), false, false, ""}, + gtTestCase{float64(kTwoTo25 + 2), true, false, ""}, + gtTestCase{float64(kTwoTo25 + 3), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterThanTest) Uint64NotExactlyRepresentableByDoublePrecision() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := GreaterThan(uint64(kTwoTo54 + 1)) + + desc := matcher.Description() + expectedDesc := "greater than 18014398509481985" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + // Signed integers. + gtTestCase{-1, false, false, ""}, + gtTestCase{1 << 30, false, false, ""}, + + gtTestCase{int(-1), false, false, ""}, + gtTestCase{int(math.MaxInt32), false, false, ""}, + + gtTestCase{int8(-1), false, false, ""}, + gtTestCase{int8(127), false, false, ""}, + + gtTestCase{int16(-1), false, false, ""}, + gtTestCase{int16(0), false, false, ""}, + gtTestCase{int16(32767), false, false, ""}, + + gtTestCase{int32(-1), false, false, ""}, + gtTestCase{int32(math.MaxInt32), false, false, ""}, + + gtTestCase{int64(-1), false, false, ""}, + gtTestCase{int64(kTwoTo54 - 1), false, false, ""}, + gtTestCase{int64(kTwoTo54 + 0), false, false, ""}, + gtTestCase{int64(kTwoTo54 + 1), false, false, ""}, + gtTestCase{int64(kTwoTo54 + 2), true, false, ""}, + + // Unsigned integers. + gtTestCase{uint(0), false, false, ""}, + gtTestCase{uint(math.MaxUint32), false, false, ""}, + + gtTestCase{uint8(0), false, false, ""}, + gtTestCase{uint8(255), false, false, ""}, + + gtTestCase{uint16(0), false, false, ""}, + gtTestCase{uint16(65535), false, false, ""}, + + gtTestCase{uint32(0), false, false, ""}, + gtTestCase{uint32(math.MaxUint32), false, false, ""}, + + gtTestCase{uint64(0), false, false, ""}, + gtTestCase{uint64(kTwoTo54 - 1), false, false, ""}, + gtTestCase{uint64(kTwoTo54 + 0), false, false, ""}, + gtTestCase{uint64(kTwoTo54 + 1), false, false, ""}, + gtTestCase{uint64(kTwoTo54 + 2), true, false, ""}, + + // Floating point. + gtTestCase{float64(-1), false, false, ""}, + gtTestCase{float64(kTwoTo54 - 2), false, false, ""}, + gtTestCase{float64(kTwoTo54 - 1), false, false, ""}, + gtTestCase{float64(kTwoTo54 + 0), false, false, ""}, + gtTestCase{float64(kTwoTo54 + 1), false, false, ""}, + gtTestCase{float64(kTwoTo54 + 2), false, false, ""}, + gtTestCase{float64(kTwoTo54 + 3), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterThanTest) Float32AboveExactIntegerRange() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := GreaterThan(float32(kTwoTo25 + 1)) + + desc := matcher.Description() + expectedDesc := "greater than 3.3554432e+07" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + // Signed integers. + gtTestCase{int64(-1), false, false, ""}, + gtTestCase{int64(kTwoTo25 - 2), false, false, ""}, + gtTestCase{int64(kTwoTo25 - 1), false, false, ""}, + gtTestCase{int64(kTwoTo25 + 0), false, false, ""}, + gtTestCase{int64(kTwoTo25 + 1), false, false, ""}, + gtTestCase{int64(kTwoTo25 + 2), false, false, ""}, + gtTestCase{int64(kTwoTo25 + 3), true, false, ""}, + + // Unsigned integers. + gtTestCase{uint64(0), false, false, ""}, + gtTestCase{uint64(kTwoTo25 - 2), false, false, ""}, + gtTestCase{uint64(kTwoTo25 - 1), false, false, ""}, + gtTestCase{uint64(kTwoTo25 + 0), false, false, ""}, + gtTestCase{uint64(kTwoTo25 + 1), false, false, ""}, + gtTestCase{uint64(kTwoTo25 + 2), false, false, ""}, + gtTestCase{uint64(kTwoTo25 + 3), true, false, ""}, + + // Floating point. + gtTestCase{float32(-1), false, false, ""}, + gtTestCase{float32(kTwoTo25 - 2), false, false, ""}, + gtTestCase{float32(kTwoTo25 - 1), false, false, ""}, + gtTestCase{float32(kTwoTo25 + 0), false, false, ""}, + gtTestCase{float32(kTwoTo25 + 1), false, false, ""}, + gtTestCase{float32(kTwoTo25 + 2), false, false, ""}, + gtTestCase{float32(kTwoTo25 + 3), true, false, ""}, + + gtTestCase{float64(-1), false, false, ""}, + gtTestCase{float64(kTwoTo25 - 2), false, false, ""}, + gtTestCase{float64(kTwoTo25 - 1), false, false, ""}, + gtTestCase{float64(kTwoTo25 + 0), false, false, ""}, + gtTestCase{float64(kTwoTo25 + 1), false, false, ""}, + gtTestCase{float64(kTwoTo25 + 2), false, false, ""}, + gtTestCase{float64(kTwoTo25 + 3), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterThanTest) Float64AboveExactIntegerRange() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := GreaterThan(float64(kTwoTo54 + 1)) + + desc := matcher.Description() + expectedDesc := "greater than 1.8014398509481984e+16" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + // Signed integers. + gtTestCase{int64(-1), false, false, ""}, + gtTestCase{int64(kTwoTo54 - 2), false, false, ""}, + gtTestCase{int64(kTwoTo54 - 1), false, false, ""}, + gtTestCase{int64(kTwoTo54 + 0), false, false, ""}, + gtTestCase{int64(kTwoTo54 + 1), false, false, ""}, + gtTestCase{int64(kTwoTo54 + 2), false, false, ""}, + gtTestCase{int64(kTwoTo54 + 3), true, false, ""}, + + // Unsigned integers. + gtTestCase{uint64(0), false, false, ""}, + gtTestCase{uint64(kTwoTo54 - 2), false, false, ""}, + gtTestCase{uint64(kTwoTo54 - 1), false, false, ""}, + gtTestCase{uint64(kTwoTo54 + 0), false, false, ""}, + gtTestCase{uint64(kTwoTo54 + 1), false, false, ""}, + gtTestCase{uint64(kTwoTo54 + 2), false, false, ""}, + gtTestCase{uint64(kTwoTo54 + 3), true, false, ""}, + + // Floating point. + gtTestCase{float64(-1), false, false, ""}, + gtTestCase{float64(kTwoTo54 - 2), false, false, ""}, + gtTestCase{float64(kTwoTo54 - 1), false, false, ""}, + gtTestCase{float64(kTwoTo54 + 0), false, false, ""}, + gtTestCase{float64(kTwoTo54 + 1), false, false, ""}, + gtTestCase{float64(kTwoTo54 + 2), false, false, ""}, + gtTestCase{float64(kTwoTo54 + 3), true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// String literals +//////////////////////////////////////////////////////////////////////// + +func (t *GreaterThanTest) EmptyString() { + matcher := GreaterThan("") + desc := matcher.Description() + expectedDesc := "greater than \"\"" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + gtTestCase{"", false, false, ""}, + gtTestCase{"\x00", true, false, ""}, + gtTestCase{"a", true, false, ""}, + gtTestCase{"foo", true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterThanTest) SingleNullByte() { + matcher := GreaterThan("\x00") + desc := matcher.Description() + expectedDesc := "greater than \"\x00\"" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + gtTestCase{"", false, false, ""}, + gtTestCase{"\x00", false, false, ""}, + gtTestCase{"\x00\x00", true, false, ""}, + gtTestCase{"a", true, false, ""}, + gtTestCase{"foo", true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *GreaterThanTest) LongerString() { + matcher := GreaterThan("foo\x00") + desc := matcher.Description() + expectedDesc := "greater than \"foo\x00\"" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []gtTestCase{ + gtTestCase{"", false, false, ""}, + gtTestCase{"\x00", false, false, ""}, + gtTestCase{"bar", false, false, ""}, + gtTestCase{"foo", false, false, ""}, + gtTestCase{"foo\x00", false, false, ""}, + gtTestCase{"foo\x00\x00", true, false, ""}, + gtTestCase{"fooa", true, false, ""}, + gtTestCase{"qux", true, false, ""}, + } + + t.checkTestCases(matcher, cases) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go new file mode 100644 index 000000000..3b286f732 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go @@ -0,0 +1,37 @@ +// Copyright 2015 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers + +import ( + "fmt" + "reflect" +) + +// HasSameTypeAs returns a matcher that matches values with exactly the same +// type as the supplied prototype. +func HasSameTypeAs(p interface{}) Matcher { + expected := reflect.TypeOf(p) + pred := func(c interface{}) error { + actual := reflect.TypeOf(c) + if actual != expected { + return fmt.Errorf("which has type %v", actual) + } + + return nil + } + + return NewMatcher(pred, fmt.Sprintf("has type %v", expected)) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as_test.go new file mode 100644 index 000000000..a4a3e308a --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as_test.go @@ -0,0 +1,181 @@ +// Copyright 2015 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "io" + "testing" + + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +func TestHasSameTypeAs(t *testing.T) { RunTests(t) } + +//////////////////////////////////////////////////////////////////////// +// Boilerplate +//////////////////////////////////////////////////////////////////////// + +type HasSameTypeAsTest struct { +} + +func init() { RegisterTestSuite(&HasSameTypeAsTest{}) } + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *HasSameTypeAsTest) CandidateIsLiteralNil() { + matcher := HasSameTypeAs(nil) + var err error + + // Description + ExpectEq("has type ", matcher.Description()) + + // Literal nil + err = matcher.Matches(nil) + ExpectEq(nil, err) + + // nil in interface variable + var r io.Reader + err = matcher.Matches(r) + ExpectEq(nil, err) + + // int + err = matcher.Matches(17) + AssertNe(nil, err) + ExpectThat(err, Error(Equals("which has type int"))) + + // string + err = matcher.Matches("") + AssertNe(nil, err) + ExpectThat(err, Error(Equals("which has type string"))) + + // nil map + var m map[string]string + err = matcher.Matches(m) + + AssertNe(nil, err) + ExpectThat(err, Error(Equals("which has type map[string]string"))) + + // Non-nil map + m = make(map[string]string) + err = matcher.Matches(m) + + AssertNe(nil, err) + ExpectThat(err, Error(Equals("which has type map[string]string"))) +} + +func (t *HasSameTypeAsTest) CandidateIsNilMap() { + var m map[string]string + matcher := HasSameTypeAs(m) + var err error + + // Description + ExpectEq("has type map[string]string", matcher.Description()) + + // nil map + m = nil + err = matcher.Matches(m) + ExpectEq(nil, err) + + // Non-nil map + m = make(map[string]string) + err = matcher.Matches(m) + ExpectEq(nil, err) + + // Literal nil + err = matcher.Matches(nil) + AssertNe(nil, err) + ExpectThat(err, Error(Equals("which has type "))) + + // int + err = matcher.Matches(17) + AssertNe(nil, err) + ExpectThat(err, Error(Equals("which has type int"))) + + // string + err = matcher.Matches("") + AssertNe(nil, err) + ExpectThat(err, Error(Equals("which has type string"))) +} + +func (t *HasSameTypeAsTest) CandidateIsNilInInterfaceVariable() { + var r io.Reader + matcher := HasSameTypeAs(r) + var err error + + // Description + ExpectEq("has type ", matcher.Description()) + + // nil in interface variable + r = nil + err = matcher.Matches(r) + ExpectEq(nil, err) + + // Literal nil + err = matcher.Matches(nil) + ExpectEq(nil, err) + + // int + err = matcher.Matches(17) + AssertNe(nil, err) + ExpectThat(err, Error(Equals("which has type int"))) +} + +func (t *HasSameTypeAsTest) CandidateIsString() { + matcher := HasSameTypeAs("") + var err error + + // Description + ExpectEq("has type string", matcher.Description()) + + // string + err = matcher.Matches("taco") + ExpectEq(nil, err) + + // string alias + type Foo string + err = matcher.Matches(Foo("taco")) + ExpectThat(err, Error(MatchesRegexp("which has type .*Foo"))) + + // Literal nil + err = matcher.Matches(nil) + AssertNe(nil, err) + ExpectThat(err, Error(Equals("which has type "))) + + // int + err = matcher.Matches(17) + AssertNe(nil, err) + ExpectThat(err, Error(Equals("which has type int"))) +} + +func (t *HasSameTypeAsTest) CandidateIsStringAlias() { + type Foo string + matcher := HasSameTypeAs(Foo("")) + var err error + + // Description + ExpectThat(matcher.Description(), MatchesRegexp("has type .*Foo")) + + // string alias + err = matcher.Matches(Foo("taco")) + ExpectEq(nil, err) + + // string + err = matcher.Matches("taco") + ExpectThat(err, Error(Equals("which has type string"))) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go new file mode 100644 index 000000000..bf5bd6ae6 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go @@ -0,0 +1,46 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers + +import ( + "errors" + "fmt" + "reflect" + "strings" +) + +// HasSubstr returns a matcher that matches strings containing s as a +// substring. +func HasSubstr(s string) Matcher { + return NewMatcher( + func(c interface{}) error { return hasSubstr(s, c) }, + fmt.Sprintf("has substring \"%s\"", s)) +} + +func hasSubstr(needle string, c interface{}) error { + v := reflect.ValueOf(c) + if v.Kind() != reflect.String { + return NewFatalError("which is not a string") + } + + // Perform the substring search. + haystack := v.String() + if strings.Contains(haystack, needle) { + return nil + } + + return errors.New("") +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr_test.go new file mode 100644 index 000000000..6fc913a24 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr_test.go @@ -0,0 +1,93 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type HasSubstrTest struct { + +} + +func init() { RegisterTestSuite(&HasSubstrTest{}) } + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *HasSubstrTest) Description() { + matcher := HasSubstr("taco") + ExpectThat(matcher.Description(), Equals("has substring \"taco\"")) +} + +func (t *HasSubstrTest) CandidateIsNil() { + matcher := HasSubstr("") + err := matcher.Matches(nil) + + ExpectThat(err, Error(Equals("which is not a string"))) + ExpectTrue(isFatal(err)) +} + +func (t *HasSubstrTest) CandidateIsInteger() { + matcher := HasSubstr("") + err := matcher.Matches(17) + + ExpectThat(err, Error(Equals("which is not a string"))) + ExpectTrue(isFatal(err)) +} + +func (t *HasSubstrTest) CandidateIsByteSlice() { + matcher := HasSubstr("") + err := matcher.Matches([]byte{17}) + + ExpectThat(err, Error(Equals("which is not a string"))) + ExpectTrue(isFatal(err)) +} + +func (t *HasSubstrTest) CandidateDoesntHaveSubstring() { + matcher := HasSubstr("taco") + err := matcher.Matches("tac") + + ExpectThat(err, Error(Equals(""))) + ExpectFalse(isFatal(err)) +} + +func (t *HasSubstrTest) CandidateEqualsArg() { + matcher := HasSubstr("taco") + err := matcher.Matches("taco") + + ExpectThat(err, Equals(nil)) +} + +func (t *HasSubstrTest) CandidateHasProperSubstring() { + matcher := HasSubstr("taco") + err := matcher.Matches("burritos and tacos") + + ExpectThat(err, Equals(nil)) +} + +func (t *HasSubstrTest) EmptyStringIsAlwaysSubString() { + matcher := HasSubstr("") + err := matcher.Matches("asdf") + + ExpectThat(err, Equals(nil)) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go new file mode 100644 index 000000000..ae6460ed9 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go @@ -0,0 +1,134 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers + +import ( + "errors" + "fmt" + "reflect" +) + +// Is the type comparable according to the definition here? +// +// http://weekly.golang.org/doc/go_spec.html#Comparison_operators +// +func isComparable(t reflect.Type) bool { + switch t.Kind() { + case reflect.Array: + return isComparable(t.Elem()) + + case reflect.Struct: + for i := 0; i < t.NumField(); i++ { + if !isComparable(t.Field(i).Type) { + return false + } + } + + return true + + case reflect.Slice, reflect.Map, reflect.Func: + return false + } + + return true +} + +// Should the supplied type be allowed as an argument to IdenticalTo? +func isLegalForIdenticalTo(t reflect.Type) (bool, error) { + // Allow the zero type. + if t == nil { + return true, nil + } + + // Reference types are always okay; we compare pointers. + switch t.Kind() { + case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan: + return true, nil + } + + // Reject other non-comparable types. + if !isComparable(t) { + return false, errors.New(fmt.Sprintf("%v is not comparable", t)) + } + + return true, nil +} + +// IdenticalTo(x) returns a matcher that matches values v with type identical +// to x such that: +// +// 1. If v and x are of a reference type (slice, map, function, channel), then +// they are either both nil or are references to the same object. +// +// 2. Otherwise, if v and x are not of a reference type but have a valid type, +// then v == x. +// +// If v and x are both the invalid type (which results from the predeclared nil +// value, or from nil interface variables), then the matcher is satisfied. +// +// This function will panic if x is of a value type that is not comparable. For +// example, x cannot be an array of functions. +func IdenticalTo(x interface{}) Matcher { + t := reflect.TypeOf(x) + + // Reject illegal arguments. + if ok, err := isLegalForIdenticalTo(t); !ok { + panic("IdenticalTo: " + err.Error()) + } + + return &identicalToMatcher{x} +} + +type identicalToMatcher struct { + x interface{} +} + +func (m *identicalToMatcher) Description() string { + t := reflect.TypeOf(m.x) + return fmt.Sprintf("identical to <%v> %v", t, m.x) +} + +func (m *identicalToMatcher) Matches(c interface{}) error { + // Make sure the candidate's type is correct. + t := reflect.TypeOf(m.x) + if ct := reflect.TypeOf(c); t != ct { + return NewFatalError(fmt.Sprintf("which is of type %v", ct)) + } + + // Special case: two values of the invalid type are always identical. + if t == nil { + return nil + } + + // Handle reference types. + switch t.Kind() { + case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan: + xv := reflect.ValueOf(m.x) + cv := reflect.ValueOf(c) + if xv.Pointer() == cv.Pointer() { + return nil + } + + return errors.New("which is not an identical reference") + } + + // Are the values equal? + if m.x == c { + return nil + } + + return errors.New("") +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to_test.go new file mode 100644 index 000000000..cc03b214a --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to_test.go @@ -0,0 +1,849 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" + "fmt" + "io" + "unsafe" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type IdenticalToTest struct { +} + +func init() { RegisterTestSuite(&IdenticalToTest{}) } + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *IdenticalToTest) TypesNotIdentical() { + var m Matcher + var err error + + type intAlias int + + // Type alias expected value + m = IdenticalTo(intAlias(17)) + err = m.Matches(int(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int"))) + + // Type alias candidate + m = IdenticalTo(int(17)) + err = m.Matches(intAlias(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.intAlias"))) + + // int and uint + m = IdenticalTo(int(17)) + err = m.Matches(uint(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type uint"))) +} + +func (t *IdenticalToTest) PredeclaredNilIdentifier() { + var m Matcher + var err error + + // Nil literal + m = IdenticalTo(nil) + err = m.Matches(nil) + ExpectEq(nil, err) + + // Zero interface var (which is the same as above since IdenticalTo takes an + // interface{} as an arg) + var nilReader io.Reader + var nilWriter io.Writer + + m = IdenticalTo(nilReader) + err = m.Matches(nilWriter) + ExpectEq(nil, err) + + // Typed nil value. + m = IdenticalTo(nil) + err = m.Matches((chan int)(nil)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type chan int"))) + + // Non-nil value. + m = IdenticalTo(nil) + err = m.Matches("taco") + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type string"))) +} + +func (t *IdenticalToTest) Slices() { + var m Matcher + var err error + + // Nil expected value + m = IdenticalTo(([]int)(nil)) + ExpectEq("identical to <[]int> []", m.Description()) + + err = m.Matches(([]int)(nil)) + ExpectEq(nil, err) + + err = m.Matches([]int{}) + ExpectThat(err, Error(Equals("which is not an identical reference"))) + + // Non-nil expected value + o1 := make([]int, 1) + o2 := make([]int, 1) + m = IdenticalTo(o1) + ExpectEq(fmt.Sprintf("identical to <[]int> %v", o1), m.Description()) + + err = m.Matches(o1) + ExpectEq(nil, err) + + err = m.Matches(o2) + ExpectThat(err, Error(Equals("which is not an identical reference"))) +} + +func (t *IdenticalToTest) Maps() { + var m Matcher + var err error + + // Nil expected value + m = IdenticalTo((map[int]int)(nil)) + ExpectEq("identical to map[]", m.Description()) + + err = m.Matches((map[int]int)(nil)) + ExpectEq(nil, err) + + err = m.Matches(map[int]int{}) + ExpectThat(err, Error(Equals("which is not an identical reference"))) + + // Non-nil expected value + o1 := map[int]int{} + o2 := map[int]int{} + m = IdenticalTo(o1) + ExpectEq(fmt.Sprintf("identical to %v", o1), m.Description()) + + err = m.Matches(o1) + ExpectEq(nil, err) + + err = m.Matches(o2) + ExpectThat(err, Error(Equals("which is not an identical reference"))) +} + +func (t *IdenticalToTest) Functions() { + var m Matcher + var err error + + // Nil expected value + m = IdenticalTo((func())(nil)) + ExpectEq("identical to ", m.Description()) + + err = m.Matches((func())(nil)) + ExpectEq(nil, err) + + err = m.Matches(func(){}) + ExpectThat(err, Error(Equals("which is not an identical reference"))) + + // Non-nil expected value + o1 := func() {} + o2 := func() {} + m = IdenticalTo(o1) + ExpectEq(fmt.Sprintf("identical to %v", o1), m.Description()) + + err = m.Matches(o1) + ExpectEq(nil, err) + + err = m.Matches(o2) + ExpectThat(err, Error(Equals("which is not an identical reference"))) +} + +func (t *IdenticalToTest) Channels() { + var m Matcher + var err error + + // Nil expected value + m = IdenticalTo((chan int)(nil)) + ExpectEq("identical to ", m.Description()) + + err = m.Matches((chan int)(nil)) + ExpectEq(nil, err) + + err = m.Matches(make(chan int)) + ExpectThat(err, Error(Equals("which is not an identical reference"))) + + // Non-nil expected value + o1 := make(chan int) + o2 := make(chan int) + m = IdenticalTo(o1) + ExpectEq(fmt.Sprintf("identical to %v", o1), m.Description()) + + err = m.Matches(o1) + ExpectEq(nil, err) + + err = m.Matches(o2) + ExpectThat(err, Error(Equals("which is not an identical reference"))) +} + +func (t *IdenticalToTest) Bools() { + var m Matcher + var err error + + // false + m = IdenticalTo(false) + ExpectEq("identical to false", m.Description()) + + err = m.Matches(false) + ExpectEq(nil, err) + + err = m.Matches(true) + ExpectThat(err, Error(Equals(""))) + + // true + m = IdenticalTo(true) + ExpectEq("identical to true", m.Description()) + + err = m.Matches(false) + ExpectThat(err, Error(Equals(""))) + + err = m.Matches(true) + ExpectEq(nil, err) +} + +func (t *IdenticalToTest) Ints() { + var m Matcher + var err error + + m = IdenticalTo(int(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(int(17)) + ExpectEq(nil, err) + + // Type alias + type myType int + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) Int8s() { + var m Matcher + var err error + + m = IdenticalTo(int8(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(int8(17)) + ExpectEq(nil, err) + + // Type alias + type myType int8 + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) Int16s() { + var m Matcher + var err error + + m = IdenticalTo(int16(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(int16(17)) + ExpectEq(nil, err) + + // Type alias + type myType int16 + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) Int32s() { + var m Matcher + var err error + + m = IdenticalTo(int32(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(int32(17)) + ExpectEq(nil, err) + + // Type alias + type myType int32 + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int16(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int16"))) +} + +func (t *IdenticalToTest) Int64s() { + var m Matcher + var err error + + m = IdenticalTo(int64(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(int64(17)) + ExpectEq(nil, err) + + // Type alias + type myType int64 + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) Uints() { + var m Matcher + var err error + + m = IdenticalTo(uint(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(uint(17)) + ExpectEq(nil, err) + + // Type alias + type myType uint + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) Uint8s() { + var m Matcher + var err error + + m = IdenticalTo(uint8(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(uint8(17)) + ExpectEq(nil, err) + + // Type alias + type myType uint8 + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) Uint16s() { + var m Matcher + var err error + + m = IdenticalTo(uint16(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(uint16(17)) + ExpectEq(nil, err) + + // Type alias + type myType uint16 + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) Uint32s() { + var m Matcher + var err error + + m = IdenticalTo(uint32(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(uint32(17)) + ExpectEq(nil, err) + + // Type alias + type myType uint32 + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) Uint64s() { + var m Matcher + var err error + + m = IdenticalTo(uint64(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(uint64(17)) + ExpectEq(nil, err) + + // Type alias + type myType uint64 + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) Uintptrs() { + var m Matcher + var err error + + m = IdenticalTo(uintptr(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(uintptr(17)) + ExpectEq(nil, err) + + // Type alias + type myType uintptr + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) Float32s() { + var m Matcher + var err error + + m = IdenticalTo(float32(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(float32(17)) + ExpectEq(nil, err) + + // Type alias + type myType float32 + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) Float64s() { + var m Matcher + var err error + + m = IdenticalTo(float64(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(float64(17)) + ExpectEq(nil, err) + + // Type alias + type myType float64 + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) Complex64s() { + var m Matcher + var err error + + m = IdenticalTo(complex64(17)) + ExpectEq("identical to (17+0i)", m.Description()) + + // Identical value + err = m.Matches(complex64(17)) + ExpectEq(nil, err) + + // Type alias + type myType complex64 + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) Complex128s() { + var m Matcher + var err error + + m = IdenticalTo(complex128(17)) + ExpectEq("identical to (17+0i)", m.Description()) + + // Identical value + err = m.Matches(complex128(17)) + ExpectEq(nil, err) + + // Type alias + type myType complex128 + err = m.Matches(myType(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) EmptyComparableArrays() { + var m Matcher + var err error + + m = IdenticalTo([0]int{}) + ExpectEq("identical to <[0]int> []", m.Description()) + + // Identical value + err = m.Matches([0]int{}) + ExpectEq(nil, err) + + // Length too long + err = m.Matches([1]int{17}) + ExpectThat(err, Error(Equals("which is of type [1]int"))) + + // Element type alias + type myType int + err = m.Matches([0]myType{}) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type [0]oglematchers_test.myType"))) + + // Completely wrong element type + err = m.Matches([0]int32{}) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type [0]int32"))) +} + +func (t *IdenticalToTest) NonEmptyComparableArrays() { + var m Matcher + var err error + + m = IdenticalTo([2]int{17, 19}) + ExpectEq("identical to <[2]int> [17 19]", m.Description()) + + // Identical value + err = m.Matches([2]int{17, 19}) + ExpectEq(nil, err) + + // Length too short + err = m.Matches([1]int{17}) + ExpectThat(err, Error(Equals("which is of type [1]int"))) + + // Length too long + err = m.Matches([3]int{17, 19, 23}) + ExpectThat(err, Error(Equals("which is of type [3]int"))) + + // First element different + err = m.Matches([2]int{13, 19}) + ExpectThat(err, Error(Equals(""))) + + // Second element different + err = m.Matches([2]int{17, 23}) + ExpectThat(err, Error(Equals(""))) + + // Element type alias + type myType int + err = m.Matches([2]myType{17, 19}) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type [2]oglematchers_test.myType"))) + + // Completely wrong element type + err = m.Matches([2]int32{17, 19}) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type [2]int32"))) +} + +func (t *IdenticalToTest) NonEmptyArraysOfComparableArrays() { + var m Matcher + var err error + + x := [2][2]int{ + [2]int{17, 19}, + [2]int{23, 29}, + } + m = IdenticalTo(x) + ExpectEq("identical to <[2][2]int> [[17 19] [23 29]]", m.Description()) + + // Identical value + err = m.Matches([2][2]int{[2]int{17, 19}, [2]int{23, 29}}) + ExpectEq(nil, err) + + // Outer length too short + err = m.Matches([1][2]int{[2]int{17, 19}}) + ExpectThat(err, Error(Equals("which is of type [1][2]int"))) + + // Inner length too short + err = m.Matches([2][1]int{[1]int{17}, [1]int{23}}) + ExpectThat(err, Error(Equals("which is of type [2][1]int"))) + + // First element different + err = m.Matches([2][2]int{[2]int{13, 19}, [2]int{23, 29}}) + ExpectThat(err, Error(Equals(""))) + + // Element type alias + type myType int + err = m.Matches([2][2]myType{[2]myType{17, 19}, [2]myType{23, 29}}) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type [2][2]oglematchers_test.myType"))) +} + +func (t *IdenticalToTest) NonComparableArrays() { + x := [0]func(){} + f := func() { IdenticalTo(x) } + ExpectThat(f, Panics(HasSubstr("is not comparable"))) +} + +func (t *IdenticalToTest) ArraysOfNonComparableArrays() { + x := [0][0]func(){} + f := func() { IdenticalTo(x) } + ExpectThat(f, Panics(HasSubstr("is not comparable"))) +} + +func (t *IdenticalToTest) Strings() { + var m Matcher + var err error + + m = IdenticalTo("taco") + ExpectEq("identical to taco", m.Description()) + + // Identical value + err = m.Matches("ta" + "co") + ExpectEq(nil, err) + + // Type alias + type myType string + err = m.Matches(myType("taco")) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) ComparableStructs() { + var m Matcher + var err error + + type subStruct struct { + i int + } + + type myStruct struct { + u uint + s subStruct + } + + x := myStruct{17, subStruct{19}} + m = IdenticalTo(x) + ExpectEq("identical to {17 {19}}", m.Description()) + + // Identical value + err = m.Matches(myStruct{17, subStruct{19}}) + ExpectEq(nil, err) + + // Wrong outer field + err = m.Matches(myStruct{13, subStruct{19}}) + ExpectThat(err, Error(Equals(""))) + + // Wrong inner field + err = m.Matches(myStruct{17, subStruct{23}}) + ExpectThat(err, Error(Equals(""))) + + // Type alias + type myType myStruct + err = m.Matches(myType{17, subStruct{19}}) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) NonComparableStructs() { + type subStruct struct { + s []int + } + + type myStruct struct { + u uint + s subStruct + } + + x := myStruct{17, subStruct{[]int{19}}} + f := func() { IdenticalTo(x) } + ExpectThat(f, Panics(AllOf(HasSubstr("IdenticalTo"), HasSubstr("comparable")))) +} + +func (t *IdenticalToTest) NilUnsafePointer() { + var m Matcher + var err error + + x := unsafe.Pointer(nil) + m = IdenticalTo(x) + ExpectEq(fmt.Sprintf("identical to %v", x), m.Description()) + + // Identical value + err = m.Matches(unsafe.Pointer(nil)) + ExpectEq(nil, err) + + // Wrong value + j := 17 + err = m.Matches(unsafe.Pointer(&j)) + ExpectThat(err, Error(Equals(""))) + + // Type alias + type myType unsafe.Pointer + err = m.Matches(myType(unsafe.Pointer(nil))) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) NonNilUnsafePointer() { + var m Matcher + var err error + + i := 17 + x := unsafe.Pointer(&i) + m = IdenticalTo(x) + ExpectEq(fmt.Sprintf("identical to %v", x), m.Description()) + + // Identical value + err = m.Matches(unsafe.Pointer(&i)) + ExpectEq(nil, err) + + // Nil value + err = m.Matches(unsafe.Pointer(nil)) + ExpectThat(err, Error(Equals(""))) + + // Wrong value + j := 17 + err = m.Matches(unsafe.Pointer(&j)) + ExpectThat(err, Error(Equals(""))) + + // Type alias + type myType unsafe.Pointer + err = m.Matches(myType(unsafe.Pointer(&i))) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} + +func (t *IdenticalToTest) IntAlias() { + var m Matcher + var err error + + type intAlias int + + m = IdenticalTo(intAlias(17)) + ExpectEq("identical to 17", m.Description()) + + // Identical value + err = m.Matches(intAlias(17)) + ExpectEq(nil, err) + + // Int + err = m.Matches(int(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int"))) + + // Completely wrong type + err = m.Matches(int32(17)) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("which is of type int32"))) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal_test.go new file mode 100644 index 000000000..a1a2ae7d6 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal_test.go @@ -0,0 +1,1077 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "math" + + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type LessOrEqualTest struct { +} + +func init() { RegisterTestSuite(&LessOrEqualTest{}) } + +type leTestCase struct { + candidate interface{} + expectedResult bool + shouldBeFatal bool + expectedError string +} + +func (t *LessOrEqualTest) checkTestCases(matcher Matcher, cases []leTestCase) { + for i, c := range cases { + err := matcher.Matches(c.candidate) + + ExpectThat( + (err == nil), + Equals(c.expectedResult), + "Case %d (candidate %v)", + i, + c.candidate) + + if err == nil { + continue + } + + _, isFatal := err.(*FatalError) + ExpectEq( + c.shouldBeFatal, + isFatal, + "Case %d (candidate %v)", + i, + c.candidate) + + ExpectThat( + err, + Error(Equals(c.expectedError)), + "Case %d (candidate %v)", + i, + c.candidate) + } +} + +//////////////////////////////////////////////////////////////////////// +// Integer literals +//////////////////////////////////////////////////////////////////////// + +func (t *LessOrEqualTest) IntegerCandidateBadTypes() { + matcher := LessOrEqual(int(-150)) + + cases := []leTestCase{ + leTestCase{true, false, true, "which is not comparable"}, + leTestCase{complex64(-151), false, true, "which is not comparable"}, + leTestCase{complex128(-151), false, true, "which is not comparable"}, + leTestCase{[...]int{-151}, false, true, "which is not comparable"}, + leTestCase{make(chan int), false, true, "which is not comparable"}, + leTestCase{func() {}, false, true, "which is not comparable"}, + leTestCase{map[int]int{}, false, true, "which is not comparable"}, + leTestCase{&leTestCase{}, false, true, "which is not comparable"}, + leTestCase{make([]int, 0), false, true, "which is not comparable"}, + leTestCase{"-151", false, true, "which is not comparable"}, + leTestCase{leTestCase{}, false, true, "which is not comparable"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessOrEqualTest) FloatCandidateBadTypes() { + matcher := LessOrEqual(float32(-150)) + + cases := []leTestCase{ + leTestCase{true, false, true, "which is not comparable"}, + leTestCase{complex64(-151), false, true, "which is not comparable"}, + leTestCase{complex128(-151), false, true, "which is not comparable"}, + leTestCase{[...]int{-151}, false, true, "which is not comparable"}, + leTestCase{make(chan int), false, true, "which is not comparable"}, + leTestCase{func() {}, false, true, "which is not comparable"}, + leTestCase{map[int]int{}, false, true, "which is not comparable"}, + leTestCase{&leTestCase{}, false, true, "which is not comparable"}, + leTestCase{make([]int, 0), false, true, "which is not comparable"}, + leTestCase{"-151", false, true, "which is not comparable"}, + leTestCase{leTestCase{}, false, true, "which is not comparable"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessOrEqualTest) StringCandidateBadTypes() { + matcher := LessOrEqual("17") + + cases := []leTestCase{ + leTestCase{true, false, true, "which is not comparable"}, + leTestCase{int(0), false, true, "which is not comparable"}, + leTestCase{int8(0), false, true, "which is not comparable"}, + leTestCase{int16(0), false, true, "which is not comparable"}, + leTestCase{int32(0), false, true, "which is not comparable"}, + leTestCase{int64(0), false, true, "which is not comparable"}, + leTestCase{uint(0), false, true, "which is not comparable"}, + leTestCase{uint8(0), false, true, "which is not comparable"}, + leTestCase{uint16(0), false, true, "which is not comparable"}, + leTestCase{uint32(0), false, true, "which is not comparable"}, + leTestCase{uint64(0), false, true, "which is not comparable"}, + leTestCase{float32(0), false, true, "which is not comparable"}, + leTestCase{float64(0), false, true, "which is not comparable"}, + leTestCase{complex64(-151), false, true, "which is not comparable"}, + leTestCase{complex128(-151), false, true, "which is not comparable"}, + leTestCase{[...]int{-151}, false, true, "which is not comparable"}, + leTestCase{make(chan int), false, true, "which is not comparable"}, + leTestCase{func() {}, false, true, "which is not comparable"}, + leTestCase{map[int]int{}, false, true, "which is not comparable"}, + leTestCase{&leTestCase{}, false, true, "which is not comparable"}, + leTestCase{make([]int, 0), false, true, "which is not comparable"}, + leTestCase{leTestCase{}, false, true, "which is not comparable"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessOrEqualTest) BadArgument() { + panicked := false + + defer func() { + ExpectThat(panicked, Equals(true)) + }() + + defer func() { + if r := recover(); r != nil { + panicked = true + } + }() + + LessOrEqual(complex128(0)) +} + +//////////////////////////////////////////////////////////////////////// +// Integer literals +//////////////////////////////////////////////////////////////////////// + +func (t *LessOrEqualTest) NegativeIntegerLiteral() { + matcher := LessOrEqual(-150) + desc := matcher.Description() + expectedDesc := "less than or equal to -150" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + // Signed integers. + leTestCase{-(1 << 30), true, false, ""}, + leTestCase{-151, true, false, ""}, + leTestCase{-150, true, false, ""}, + leTestCase{-149, false, false, ""}, + leTestCase{0, false, false, ""}, + leTestCase{17, false, false, ""}, + + leTestCase{int(-(1 << 30)), true, false, ""}, + leTestCase{int(-151), true, false, ""}, + leTestCase{int(-150), true, false, ""}, + leTestCase{int(-149), false, false, ""}, + leTestCase{int(0), false, false, ""}, + leTestCase{int(17), false, false, ""}, + + leTestCase{int8(-127), false, false, ""}, + leTestCase{int8(0), false, false, ""}, + leTestCase{int8(17), false, false, ""}, + + leTestCase{int16(-(1 << 14)), true, false, ""}, + leTestCase{int16(-151), true, false, ""}, + leTestCase{int16(-150), true, false, ""}, + leTestCase{int16(-149), false, false, ""}, + leTestCase{int16(0), false, false, ""}, + leTestCase{int16(17), false, false, ""}, + + leTestCase{int32(-(1 << 30)), true, false, ""}, + leTestCase{int32(-151), true, false, ""}, + leTestCase{int32(-150), true, false, ""}, + leTestCase{int32(-149), false, false, ""}, + leTestCase{int32(0), false, false, ""}, + leTestCase{int32(17), false, false, ""}, + + leTestCase{int64(-(1 << 30)), true, false, ""}, + leTestCase{int64(-151), true, false, ""}, + leTestCase{int64(-150), true, false, ""}, + leTestCase{int64(-149), false, false, ""}, + leTestCase{int64(0), false, false, ""}, + leTestCase{int64(17), false, false, ""}, + + // Unsigned integers. + leTestCase{uint((1 << 32) - 151), false, false, ""}, + leTestCase{uint(0), false, false, ""}, + leTestCase{uint(17), false, false, ""}, + + leTestCase{uint8(0), false, false, ""}, + leTestCase{uint8(17), false, false, ""}, + leTestCase{uint8(253), false, false, ""}, + + leTestCase{uint16((1 << 16) - 151), false, false, ""}, + leTestCase{uint16(0), false, false, ""}, + leTestCase{uint16(17), false, false, ""}, + + leTestCase{uint32((1 << 32) - 151), false, false, ""}, + leTestCase{uint32(0), false, false, ""}, + leTestCase{uint32(17), false, false, ""}, + + leTestCase{uint64((1 << 64) - 151), false, false, ""}, + leTestCase{uint64(0), false, false, ""}, + leTestCase{uint64(17), false, false, ""}, + + // Floating point. + leTestCase{float32(-(1 << 30)), true, false, ""}, + leTestCase{float32(-151), true, false, ""}, + leTestCase{float32(-150.1), true, false, ""}, + leTestCase{float32(-150), true, false, ""}, + leTestCase{float32(-149.9), false, false, ""}, + leTestCase{float32(0), false, false, ""}, + leTestCase{float32(17), false, false, ""}, + leTestCase{float32(160), false, false, ""}, + + leTestCase{float64(-(1 << 30)), true, false, ""}, + leTestCase{float64(-151), true, false, ""}, + leTestCase{float64(-150.1), true, false, ""}, + leTestCase{float64(-150), true, false, ""}, + leTestCase{float64(-149.9), false, false, ""}, + leTestCase{float64(0), false, false, ""}, + leTestCase{float64(17), false, false, ""}, + leTestCase{float64(160), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessOrEqualTest) ZeroIntegerLiteral() { + matcher := LessOrEqual(0) + desc := matcher.Description() + expectedDesc := "less than or equal to 0" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + // Signed integers. + leTestCase{-(1 << 30), true, false, ""}, + leTestCase{-1, true, false, ""}, + leTestCase{0, true, false, ""}, + leTestCase{1, false, false, ""}, + leTestCase{17, false, false, ""}, + leTestCase{(1 << 30), false, false, ""}, + + leTestCase{int(-(1 << 30)), true, false, ""}, + leTestCase{int(-1), true, false, ""}, + leTestCase{int(0), true, false, ""}, + leTestCase{int(1), false, false, ""}, + leTestCase{int(17), false, false, ""}, + + leTestCase{int8(-1), true, false, ""}, + leTestCase{int8(0), true, false, ""}, + leTestCase{int8(1), false, false, ""}, + + leTestCase{int16(-(1 << 14)), true, false, ""}, + leTestCase{int16(-1), true, false, ""}, + leTestCase{int16(0), true, false, ""}, + leTestCase{int16(1), false, false, ""}, + leTestCase{int16(17), false, false, ""}, + + leTestCase{int32(-(1 << 30)), true, false, ""}, + leTestCase{int32(-1), true, false, ""}, + leTestCase{int32(0), true, false, ""}, + leTestCase{int32(1), false, false, ""}, + leTestCase{int32(17), false, false, ""}, + + leTestCase{int64(-(1 << 30)), true, false, ""}, + leTestCase{int64(-1), true, false, ""}, + leTestCase{int64(0), true, false, ""}, + leTestCase{int64(1), false, false, ""}, + leTestCase{int64(17), false, false, ""}, + + // Unsigned integers. + leTestCase{uint((1 << 32) - 1), false, false, ""}, + leTestCase{uint(0), true, false, ""}, + leTestCase{uint(1), false, false, ""}, + leTestCase{uint(17), false, false, ""}, + + leTestCase{uint8(0), true, false, ""}, + leTestCase{uint8(1), false, false, ""}, + leTestCase{uint8(17), false, false, ""}, + leTestCase{uint8(253), false, false, ""}, + + leTestCase{uint16((1 << 16) - 1), false, false, ""}, + leTestCase{uint16(0), true, false, ""}, + leTestCase{uint16(1), false, false, ""}, + leTestCase{uint16(17), false, false, ""}, + + leTestCase{uint32((1 << 32) - 1), false, false, ""}, + leTestCase{uint32(0), true, false, ""}, + leTestCase{uint32(1), false, false, ""}, + leTestCase{uint32(17), false, false, ""}, + + leTestCase{uint64((1 << 64) - 1), false, false, ""}, + leTestCase{uint64(0), true, false, ""}, + leTestCase{uint64(1), false, false, ""}, + leTestCase{uint64(17), false, false, ""}, + + // Floating point. + leTestCase{float32(-(1 << 30)), true, false, ""}, + leTestCase{float32(-1), true, false, ""}, + leTestCase{float32(-0.1), true, false, ""}, + leTestCase{float32(-0.0), true, false, ""}, + leTestCase{float32(0), true, false, ""}, + leTestCase{float32(0.1), false, false, ""}, + leTestCase{float32(17), false, false, ""}, + leTestCase{float32(160), false, false, ""}, + + leTestCase{float64(-(1 << 30)), true, false, ""}, + leTestCase{float64(-1), true, false, ""}, + leTestCase{float64(-0.1), true, false, ""}, + leTestCase{float64(-0), true, false, ""}, + leTestCase{float64(0), true, false, ""}, + leTestCase{float64(0.1), false, false, ""}, + leTestCase{float64(17), false, false, ""}, + leTestCase{float64(160), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessOrEqualTest) PositiveIntegerLiteral() { + matcher := LessOrEqual(150) + desc := matcher.Description() + expectedDesc := "less than or equal to 150" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + // Signed integers. + leTestCase{-1, true, false, ""}, + leTestCase{149, true, false, ""}, + leTestCase{150, true, false, ""}, + leTestCase{151, false, false, ""}, + + leTestCase{int(-1), true, false, ""}, + leTestCase{int(149), true, false, ""}, + leTestCase{int(150), true, false, ""}, + leTestCase{int(151), false, false, ""}, + + leTestCase{int8(-1), true, false, ""}, + leTestCase{int8(0), true, false, ""}, + leTestCase{int8(17), true, false, ""}, + leTestCase{int8(127), true, false, ""}, + + leTestCase{int16(-1), true, false, ""}, + leTestCase{int16(149), true, false, ""}, + leTestCase{int16(150), true, false, ""}, + leTestCase{int16(151), false, false, ""}, + + leTestCase{int32(-1), true, false, ""}, + leTestCase{int32(149), true, false, ""}, + leTestCase{int32(150), true, false, ""}, + leTestCase{int32(151), false, false, ""}, + + leTestCase{int64(-1), true, false, ""}, + leTestCase{int64(149), true, false, ""}, + leTestCase{int64(150), true, false, ""}, + leTestCase{int64(151), false, false, ""}, + + // Unsigned integers. + leTestCase{uint(0), true, false, ""}, + leTestCase{uint(149), true, false, ""}, + leTestCase{uint(150), true, false, ""}, + leTestCase{uint(151), false, false, ""}, + + leTestCase{uint8(0), true, false, ""}, + leTestCase{uint8(127), true, false, ""}, + + leTestCase{uint16(0), true, false, ""}, + leTestCase{uint16(149), true, false, ""}, + leTestCase{uint16(150), true, false, ""}, + leTestCase{uint16(151), false, false, ""}, + + leTestCase{uint32(0), true, false, ""}, + leTestCase{uint32(149), true, false, ""}, + leTestCase{uint32(150), true, false, ""}, + leTestCase{uint32(151), false, false, ""}, + + leTestCase{uint64(0), true, false, ""}, + leTestCase{uint64(149), true, false, ""}, + leTestCase{uint64(150), true, false, ""}, + leTestCase{uint64(151), false, false, ""}, + + // Floating point. + leTestCase{float32(-1), true, false, ""}, + leTestCase{float32(149), true, false, ""}, + leTestCase{float32(149.9), true, false, ""}, + leTestCase{float32(150), true, false, ""}, + leTestCase{float32(150.1), false, false, ""}, + leTestCase{float32(151), false, false, ""}, + + leTestCase{float64(-1), true, false, ""}, + leTestCase{float64(149), true, false, ""}, + leTestCase{float64(149.9), true, false, ""}, + leTestCase{float64(150), true, false, ""}, + leTestCase{float64(150.1), false, false, ""}, + leTestCase{float64(151), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// Float literals +//////////////////////////////////////////////////////////////////////// + +func (t *LessOrEqualTest) NegativeFloatLiteral() { + matcher := LessOrEqual(-150.1) + desc := matcher.Description() + expectedDesc := "less than or equal to -150.1" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + // Signed integers. + leTestCase{-(1 << 30), true, false, ""}, + leTestCase{-151, true, false, ""}, + leTestCase{-150.1, true, false, ""}, + leTestCase{-150, false, false, ""}, + leTestCase{-149, false, false, ""}, + leTestCase{0, false, false, ""}, + leTestCase{17, false, false, ""}, + + leTestCase{int(-(1 << 30)), true, false, ""}, + leTestCase{int(-151), true, false, ""}, + leTestCase{int(-150), false, false, ""}, + leTestCase{int(-149), false, false, ""}, + leTestCase{int(0), false, false, ""}, + leTestCase{int(17), false, false, ""}, + + leTestCase{int8(-127), false, false, ""}, + leTestCase{int8(0), false, false, ""}, + leTestCase{int8(17), false, false, ""}, + + leTestCase{int16(-(1 << 14)), true, false, ""}, + leTestCase{int16(-151), true, false, ""}, + leTestCase{int16(-150), false, false, ""}, + leTestCase{int16(-149), false, false, ""}, + leTestCase{int16(0), false, false, ""}, + leTestCase{int16(17), false, false, ""}, + + leTestCase{int32(-(1 << 30)), true, false, ""}, + leTestCase{int32(-151), true, false, ""}, + leTestCase{int32(-150), false, false, ""}, + leTestCase{int32(-149), false, false, ""}, + leTestCase{int32(0), false, false, ""}, + leTestCase{int32(17), false, false, ""}, + + leTestCase{int64(-(1 << 30)), true, false, ""}, + leTestCase{int64(-151), true, false, ""}, + leTestCase{int64(-150), false, false, ""}, + leTestCase{int64(-149), false, false, ""}, + leTestCase{int64(0), false, false, ""}, + leTestCase{int64(17), false, false, ""}, + + // Unsigned integers. + leTestCase{uint((1 << 32) - 151), false, false, ""}, + leTestCase{uint(0), false, false, ""}, + leTestCase{uint(17), false, false, ""}, + + leTestCase{uint8(0), false, false, ""}, + leTestCase{uint8(17), false, false, ""}, + leTestCase{uint8(253), false, false, ""}, + + leTestCase{uint16((1 << 16) - 151), false, false, ""}, + leTestCase{uint16(0), false, false, ""}, + leTestCase{uint16(17), false, false, ""}, + + leTestCase{uint32((1 << 32) - 151), false, false, ""}, + leTestCase{uint32(0), false, false, ""}, + leTestCase{uint32(17), false, false, ""}, + + leTestCase{uint64((1 << 64) - 151), false, false, ""}, + leTestCase{uint64(0), false, false, ""}, + leTestCase{uint64(17), false, false, ""}, + + // Floating point. + leTestCase{float32(-(1 << 30)), true, false, ""}, + leTestCase{float32(-151), true, false, ""}, + leTestCase{float32(-150.2), true, false, ""}, + leTestCase{float32(-150.1), true, false, ""}, + leTestCase{float32(-150), false, false, ""}, + leTestCase{float32(0), false, false, ""}, + leTestCase{float32(17), false, false, ""}, + leTestCase{float32(160), false, false, ""}, + + leTestCase{float64(-(1 << 30)), true, false, ""}, + leTestCase{float64(-151), true, false, ""}, + leTestCase{float64(-150.2), true, false, ""}, + leTestCase{float64(-150.1), true, false, ""}, + leTestCase{float64(-150), false, false, ""}, + leTestCase{float64(0), false, false, ""}, + leTestCase{float64(17), false, false, ""}, + leTestCase{float64(160), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessOrEqualTest) PositiveFloatLiteral() { + matcher := LessOrEqual(149.9) + desc := matcher.Description() + expectedDesc := "less than or equal to 149.9" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + // Signed integers. + leTestCase{-1, true, false, ""}, + leTestCase{149, true, false, ""}, + leTestCase{149.9, true, false, ""}, + leTestCase{150, false, false, ""}, + leTestCase{151, false, false, ""}, + + leTestCase{int(-1), true, false, ""}, + leTestCase{int(149), true, false, ""}, + leTestCase{int(150), false, false, ""}, + leTestCase{int(151), false, false, ""}, + + leTestCase{int8(-1), true, false, ""}, + leTestCase{int8(0), true, false, ""}, + leTestCase{int8(17), true, false, ""}, + leTestCase{int8(127), true, false, ""}, + + leTestCase{int16(-1), true, false, ""}, + leTestCase{int16(149), true, false, ""}, + leTestCase{int16(150), false, false, ""}, + leTestCase{int16(151), false, false, ""}, + + leTestCase{int32(-1), true, false, ""}, + leTestCase{int32(149), true, false, ""}, + leTestCase{int32(150), false, false, ""}, + leTestCase{int32(151), false, false, ""}, + + leTestCase{int64(-1), true, false, ""}, + leTestCase{int64(149), true, false, ""}, + leTestCase{int64(150), false, false, ""}, + leTestCase{int64(151), false, false, ""}, + + // Unsigned integers. + leTestCase{uint(0), true, false, ""}, + leTestCase{uint(149), true, false, ""}, + leTestCase{uint(150), false, false, ""}, + leTestCase{uint(151), false, false, ""}, + + leTestCase{uint8(0), true, false, ""}, + leTestCase{uint8(127), true, false, ""}, + + leTestCase{uint16(0), true, false, ""}, + leTestCase{uint16(149), true, false, ""}, + leTestCase{uint16(150), false, false, ""}, + leTestCase{uint16(151), false, false, ""}, + + leTestCase{uint32(0), true, false, ""}, + leTestCase{uint32(149), true, false, ""}, + leTestCase{uint32(150), false, false, ""}, + leTestCase{uint32(151), false, false, ""}, + + leTestCase{uint64(0), true, false, ""}, + leTestCase{uint64(149), true, false, ""}, + leTestCase{uint64(150), false, false, ""}, + leTestCase{uint64(151), false, false, ""}, + + // Floating point. + leTestCase{float32(-1), true, false, ""}, + leTestCase{float32(149), true, false, ""}, + leTestCase{float32(149.8), true, false, ""}, + leTestCase{float32(149.9), true, false, ""}, + leTestCase{float32(150), false, false, ""}, + leTestCase{float32(151), false, false, ""}, + + leTestCase{float64(-1), true, false, ""}, + leTestCase{float64(149), true, false, ""}, + leTestCase{float64(149.8), true, false, ""}, + leTestCase{float64(149.9), true, false, ""}, + leTestCase{float64(150), false, false, ""}, + leTestCase{float64(151), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// Subtle cases +//////////////////////////////////////////////////////////////////////// + +func (t *LessOrEqualTest) Int64NotExactlyRepresentableBySinglePrecision() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := LessOrEqual(int64(kTwoTo25 + 1)) + + desc := matcher.Description() + expectedDesc := "less than or equal to 33554433" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + // Signed integers. + leTestCase{-1, true, false, ""}, + leTestCase{kTwoTo25 + 0, true, false, ""}, + leTestCase{kTwoTo25 + 1, true, false, ""}, + leTestCase{kTwoTo25 + 2, false, false, ""}, + + leTestCase{int(-1), true, false, ""}, + leTestCase{int(kTwoTo25 + 0), true, false, ""}, + leTestCase{int(kTwoTo25 + 1), true, false, ""}, + leTestCase{int(kTwoTo25 + 2), false, false, ""}, + + leTestCase{int8(-1), true, false, ""}, + leTestCase{int8(127), true, false, ""}, + + leTestCase{int16(-1), true, false, ""}, + leTestCase{int16(0), true, false, ""}, + leTestCase{int16(32767), true, false, ""}, + + leTestCase{int32(-1), true, false, ""}, + leTestCase{int32(kTwoTo25 + 0), true, false, ""}, + leTestCase{int32(kTwoTo25 + 1), true, false, ""}, + leTestCase{int32(kTwoTo25 + 2), false, false, ""}, + + leTestCase{int64(-1), true, false, ""}, + leTestCase{int64(kTwoTo25 + 0), true, false, ""}, + leTestCase{int64(kTwoTo25 + 1), true, false, ""}, + leTestCase{int64(kTwoTo25 + 2), false, false, ""}, + + // Unsigned integers. + leTestCase{uint(0), true, false, ""}, + leTestCase{uint(kTwoTo25 + 0), true, false, ""}, + leTestCase{uint(kTwoTo25 + 1), true, false, ""}, + leTestCase{uint(kTwoTo25 + 2), false, false, ""}, + + leTestCase{uint8(0), true, false, ""}, + leTestCase{uint8(255), true, false, ""}, + + leTestCase{uint16(0), true, false, ""}, + leTestCase{uint16(65535), true, false, ""}, + + leTestCase{uint32(0), true, false, ""}, + leTestCase{uint32(kTwoTo25 + 0), true, false, ""}, + leTestCase{uint32(kTwoTo25 + 1), true, false, ""}, + leTestCase{uint32(kTwoTo25 + 2), false, false, ""}, + + leTestCase{uint64(0), true, false, ""}, + leTestCase{uint64(kTwoTo25 + 0), true, false, ""}, + leTestCase{uint64(kTwoTo25 + 1), true, false, ""}, + leTestCase{uint64(kTwoTo25 + 2), false, false, ""}, + + // Floating point. + leTestCase{float32(-1), true, false, ""}, + leTestCase{float32(kTwoTo25 - 2), true, false, ""}, + leTestCase{float32(kTwoTo25 - 1), true, false, ""}, + leTestCase{float32(kTwoTo25 + 0), true, false, ""}, + leTestCase{float32(kTwoTo25 + 1), true, false, ""}, + leTestCase{float32(kTwoTo25 + 2), true, false, ""}, + leTestCase{float32(kTwoTo25 + 3), false, false, ""}, + + leTestCase{float64(-1), true, false, ""}, + leTestCase{float64(kTwoTo25 - 2), true, false, ""}, + leTestCase{float64(kTwoTo25 - 1), true, false, ""}, + leTestCase{float64(kTwoTo25 + 0), true, false, ""}, + leTestCase{float64(kTwoTo25 + 1), true, false, ""}, + leTestCase{float64(kTwoTo25 + 2), false, false, ""}, + leTestCase{float64(kTwoTo25 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessOrEqualTest) Int64NotExactlyRepresentableByDoublePrecision() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := LessOrEqual(int64(kTwoTo54 + 1)) + + desc := matcher.Description() + expectedDesc := "less than or equal to 18014398509481985" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + // Signed integers. + leTestCase{-1, true, false, ""}, + leTestCase{1 << 30, true, false, ""}, + + leTestCase{int(-1), true, false, ""}, + leTestCase{int(math.MaxInt32), true, false, ""}, + + leTestCase{int8(-1), true, false, ""}, + leTestCase{int8(127), true, false, ""}, + + leTestCase{int16(-1), true, false, ""}, + leTestCase{int16(0), true, false, ""}, + leTestCase{int16(32767), true, false, ""}, + + leTestCase{int32(-1), true, false, ""}, + leTestCase{int32(math.MaxInt32), true, false, ""}, + + leTestCase{int64(-1), true, false, ""}, + leTestCase{int64(kTwoTo54 - 1), true, false, ""}, + leTestCase{int64(kTwoTo54 + 0), true, false, ""}, + leTestCase{int64(kTwoTo54 + 1), true, false, ""}, + leTestCase{int64(kTwoTo54 + 2), false, false, ""}, + + // Unsigned integers. + leTestCase{uint(0), true, false, ""}, + leTestCase{uint(math.MaxUint32), true, false, ""}, + + leTestCase{uint8(0), true, false, ""}, + leTestCase{uint8(255), true, false, ""}, + + leTestCase{uint16(0), true, false, ""}, + leTestCase{uint16(65535), true, false, ""}, + + leTestCase{uint32(0), true, false, ""}, + leTestCase{uint32(math.MaxUint32), true, false, ""}, + + leTestCase{uint64(0), true, false, ""}, + leTestCase{uint64(kTwoTo54 - 1), true, false, ""}, + leTestCase{uint64(kTwoTo54 + 0), true, false, ""}, + leTestCase{uint64(kTwoTo54 + 1), true, false, ""}, + leTestCase{uint64(kTwoTo54 + 2), false, false, ""}, + + // Floating point. + leTestCase{float64(-1), true, false, ""}, + leTestCase{float64(kTwoTo54 - 2), true, false, ""}, + leTestCase{float64(kTwoTo54 - 1), true, false, ""}, + leTestCase{float64(kTwoTo54 + 0), true, false, ""}, + leTestCase{float64(kTwoTo54 + 1), true, false, ""}, + leTestCase{float64(kTwoTo54 + 2), true, false, ""}, + leTestCase{float64(kTwoTo54 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessOrEqualTest) Uint64NotExactlyRepresentableBySinglePrecision() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := LessOrEqual(uint64(kTwoTo25 + 1)) + + desc := matcher.Description() + expectedDesc := "less than or equal to 33554433" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + // Signed integers. + leTestCase{-1, true, false, ""}, + leTestCase{kTwoTo25 + 0, true, false, ""}, + leTestCase{kTwoTo25 + 1, true, false, ""}, + leTestCase{kTwoTo25 + 2, false, false, ""}, + + leTestCase{int(-1), true, false, ""}, + leTestCase{int(kTwoTo25 + 0), true, false, ""}, + leTestCase{int(kTwoTo25 + 1), true, false, ""}, + leTestCase{int(kTwoTo25 + 2), false, false, ""}, + + leTestCase{int8(-1), true, false, ""}, + leTestCase{int8(127), true, false, ""}, + + leTestCase{int16(-1), true, false, ""}, + leTestCase{int16(0), true, false, ""}, + leTestCase{int16(32767), true, false, ""}, + + leTestCase{int32(-1), true, false, ""}, + leTestCase{int32(kTwoTo25 + 0), true, false, ""}, + leTestCase{int32(kTwoTo25 + 1), true, false, ""}, + leTestCase{int32(kTwoTo25 + 2), false, false, ""}, + + leTestCase{int64(-1), true, false, ""}, + leTestCase{int64(kTwoTo25 + 0), true, false, ""}, + leTestCase{int64(kTwoTo25 + 1), true, false, ""}, + leTestCase{int64(kTwoTo25 + 2), false, false, ""}, + + // Unsigned integers. + leTestCase{uint(0), true, false, ""}, + leTestCase{uint(kTwoTo25 + 0), true, false, ""}, + leTestCase{uint(kTwoTo25 + 1), true, false, ""}, + leTestCase{uint(kTwoTo25 + 2), false, false, ""}, + + leTestCase{uint8(0), true, false, ""}, + leTestCase{uint8(255), true, false, ""}, + + leTestCase{uint16(0), true, false, ""}, + leTestCase{uint16(65535), true, false, ""}, + + leTestCase{uint32(0), true, false, ""}, + leTestCase{uint32(kTwoTo25 + 0), true, false, ""}, + leTestCase{uint32(kTwoTo25 + 1), true, false, ""}, + leTestCase{uint32(kTwoTo25 + 2), false, false, ""}, + + leTestCase{uint64(0), true, false, ""}, + leTestCase{uint64(kTwoTo25 + 0), true, false, ""}, + leTestCase{uint64(kTwoTo25 + 1), true, false, ""}, + leTestCase{uint64(kTwoTo25 + 2), false, false, ""}, + + // Floating point. + leTestCase{float32(-1), true, false, ""}, + leTestCase{float32(kTwoTo25 - 2), true, false, ""}, + leTestCase{float32(kTwoTo25 - 1), true, false, ""}, + leTestCase{float32(kTwoTo25 + 0), true, false, ""}, + leTestCase{float32(kTwoTo25 + 1), true, false, ""}, + leTestCase{float32(kTwoTo25 + 2), true, false, ""}, + leTestCase{float32(kTwoTo25 + 3), false, false, ""}, + + leTestCase{float64(-1), true, false, ""}, + leTestCase{float64(kTwoTo25 - 2), true, false, ""}, + leTestCase{float64(kTwoTo25 - 1), true, false, ""}, + leTestCase{float64(kTwoTo25 + 0), true, false, ""}, + leTestCase{float64(kTwoTo25 + 1), true, false, ""}, + leTestCase{float64(kTwoTo25 + 2), false, false, ""}, + leTestCase{float64(kTwoTo25 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessOrEqualTest) Uint64NotExactlyRepresentableByDoublePrecision() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := LessOrEqual(uint64(kTwoTo54 + 1)) + + desc := matcher.Description() + expectedDesc := "less than or equal to 18014398509481985" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + // Signed integers. + leTestCase{-1, true, false, ""}, + leTestCase{1 << 30, true, false, ""}, + + leTestCase{int(-1), true, false, ""}, + leTestCase{int(math.MaxInt32), true, false, ""}, + + leTestCase{int8(-1), true, false, ""}, + leTestCase{int8(127), true, false, ""}, + + leTestCase{int16(-1), true, false, ""}, + leTestCase{int16(0), true, false, ""}, + leTestCase{int16(32767), true, false, ""}, + + leTestCase{int32(-1), true, false, ""}, + leTestCase{int32(math.MaxInt32), true, false, ""}, + + leTestCase{int64(-1), true, false, ""}, + leTestCase{int64(kTwoTo54 - 1), true, false, ""}, + leTestCase{int64(kTwoTo54 + 0), true, false, ""}, + leTestCase{int64(kTwoTo54 + 1), true, false, ""}, + leTestCase{int64(kTwoTo54 + 2), false, false, ""}, + + // Unsigned integers. + leTestCase{uint(0), true, false, ""}, + leTestCase{uint(math.MaxUint32), true, false, ""}, + + leTestCase{uint8(0), true, false, ""}, + leTestCase{uint8(255), true, false, ""}, + + leTestCase{uint16(0), true, false, ""}, + leTestCase{uint16(65535), true, false, ""}, + + leTestCase{uint32(0), true, false, ""}, + leTestCase{uint32(math.MaxUint32), true, false, ""}, + + leTestCase{uint64(0), true, false, ""}, + leTestCase{uint64(kTwoTo54 - 1), true, false, ""}, + leTestCase{uint64(kTwoTo54 + 0), true, false, ""}, + leTestCase{uint64(kTwoTo54 + 1), true, false, ""}, + leTestCase{uint64(kTwoTo54 + 2), false, false, ""}, + + // Floating point. + leTestCase{float64(-1), true, false, ""}, + leTestCase{float64(kTwoTo54 - 2), true, false, ""}, + leTestCase{float64(kTwoTo54 - 1), true, false, ""}, + leTestCase{float64(kTwoTo54 + 0), true, false, ""}, + leTestCase{float64(kTwoTo54 + 1), true, false, ""}, + leTestCase{float64(kTwoTo54 + 2), true, false, ""}, + leTestCase{float64(kTwoTo54 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessOrEqualTest) Float32AboveExactIntegerRange() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := LessOrEqual(float32(kTwoTo25 + 1)) + + desc := matcher.Description() + expectedDesc := "less than or equal to 3.3554432e+07" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + // Signed integers. + leTestCase{int64(-1), true, false, ""}, + leTestCase{int64(kTwoTo25 - 2), true, false, ""}, + leTestCase{int64(kTwoTo25 - 1), true, false, ""}, + leTestCase{int64(kTwoTo25 + 0), true, false, ""}, + leTestCase{int64(kTwoTo25 + 1), true, false, ""}, + leTestCase{int64(kTwoTo25 + 2), true, false, ""}, + leTestCase{int64(kTwoTo25 + 3), false, false, ""}, + + // Unsigned integers. + leTestCase{uint64(0), true, false, ""}, + leTestCase{uint64(kTwoTo25 - 2), true, false, ""}, + leTestCase{uint64(kTwoTo25 - 1), true, false, ""}, + leTestCase{uint64(kTwoTo25 + 0), true, false, ""}, + leTestCase{uint64(kTwoTo25 + 1), true, false, ""}, + leTestCase{uint64(kTwoTo25 + 2), true, false, ""}, + leTestCase{uint64(kTwoTo25 + 3), false, false, ""}, + + // Floating point. + leTestCase{float32(-1), true, false, ""}, + leTestCase{float32(kTwoTo25 - 2), true, false, ""}, + leTestCase{float32(kTwoTo25 - 1), true, false, ""}, + leTestCase{float32(kTwoTo25 + 0), true, false, ""}, + leTestCase{float32(kTwoTo25 + 1), true, false, ""}, + leTestCase{float32(kTwoTo25 + 2), true, false, ""}, + leTestCase{float32(kTwoTo25 + 3), false, false, ""}, + + leTestCase{float64(-1), true, false, ""}, + leTestCase{float64(kTwoTo25 - 2), true, false, ""}, + leTestCase{float64(kTwoTo25 - 1), true, false, ""}, + leTestCase{float64(kTwoTo25 + 0), true, false, ""}, + leTestCase{float64(kTwoTo25 + 1), true, false, ""}, + leTestCase{float64(kTwoTo25 + 2), true, false, ""}, + leTestCase{float64(kTwoTo25 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessOrEqualTest) Float64AboveExactIntegerRange() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := LessOrEqual(float64(kTwoTo54 + 1)) + + desc := matcher.Description() + expectedDesc := "less than or equal to 1.8014398509481984e+16" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + // Signed integers. + leTestCase{int64(-1), true, false, ""}, + leTestCase{int64(kTwoTo54 - 2), true, false, ""}, + leTestCase{int64(kTwoTo54 - 1), true, false, ""}, + leTestCase{int64(kTwoTo54 + 0), true, false, ""}, + leTestCase{int64(kTwoTo54 + 1), true, false, ""}, + leTestCase{int64(kTwoTo54 + 2), true, false, ""}, + leTestCase{int64(kTwoTo54 + 3), false, false, ""}, + + // Unsigned integers. + leTestCase{uint64(0), true, false, ""}, + leTestCase{uint64(kTwoTo54 - 2), true, false, ""}, + leTestCase{uint64(kTwoTo54 - 1), true, false, ""}, + leTestCase{uint64(kTwoTo54 + 0), true, false, ""}, + leTestCase{uint64(kTwoTo54 + 1), true, false, ""}, + leTestCase{uint64(kTwoTo54 + 2), true, false, ""}, + leTestCase{uint64(kTwoTo54 + 3), false, false, ""}, + + // Floating point. + leTestCase{float64(-1), true, false, ""}, + leTestCase{float64(kTwoTo54 - 2), true, false, ""}, + leTestCase{float64(kTwoTo54 - 1), true, false, ""}, + leTestCase{float64(kTwoTo54 + 0), true, false, ""}, + leTestCase{float64(kTwoTo54 + 1), true, false, ""}, + leTestCase{float64(kTwoTo54 + 2), true, false, ""}, + leTestCase{float64(kTwoTo54 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// String literals +//////////////////////////////////////////////////////////////////////// + +func (t *LessOrEqualTest) EmptyString() { + matcher := LessOrEqual("") + desc := matcher.Description() + expectedDesc := "less than or equal to \"\"" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + leTestCase{"", true, false, ""}, + leTestCase{"\x00", false, false, ""}, + leTestCase{"a", false, false, ""}, + leTestCase{"foo", false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessOrEqualTest) SingleNullByte() { + matcher := LessOrEqual("\x00") + desc := matcher.Description() + expectedDesc := "less than or equal to \"\x00\"" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + leTestCase{"", true, false, ""}, + leTestCase{"\x00", true, false, ""}, + leTestCase{"\x00\x00", false, false, ""}, + leTestCase{"a", false, false, ""}, + leTestCase{"foo", false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessOrEqualTest) LongerString() { + matcher := LessOrEqual("foo\x00") + desc := matcher.Description() + expectedDesc := "less than or equal to \"foo\x00\"" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []leTestCase{ + leTestCase{"", true, false, ""}, + leTestCase{"\x00", true, false, ""}, + leTestCase{"bar", true, false, ""}, + leTestCase{"foo", true, false, ""}, + leTestCase{"foo\x00", true, false, ""}, + leTestCase{"foo\x00\x00", false, false, ""}, + leTestCase{"fooa", false, false, ""}, + leTestCase{"qux", false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_than_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_than_test.go new file mode 100644 index 000000000..59f5b7f56 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_than_test.go @@ -0,0 +1,1057 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "math" + + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type LessThanTest struct { +} + +func init() { RegisterTestSuite(&LessThanTest{}) } + +type ltTestCase struct { + candidate interface{} + expectedResult bool + shouldBeFatal bool + expectedError string +} + +func (t *LessThanTest) checkTestCases(matcher Matcher, cases []ltTestCase) { + for i, c := range cases { + err := matcher.Matches(c.candidate) + + ExpectThat( + (err == nil), + Equals(c.expectedResult), + "Case %d (candidate %v)", + i, + c.candidate) + + if err == nil { + continue + } + + _, isFatal := err.(*FatalError) + ExpectEq( + c.shouldBeFatal, + isFatal, + "Case %d (candidate %v)", + i, + c.candidate) + + ExpectThat( + err, + Error(Equals(c.expectedError)), + "Case %d (candidate %v)", + i, + c.candidate) + } +} + +//////////////////////////////////////////////////////////////////////// +// Integer literals +//////////////////////////////////////////////////////////////////////// + +func (t *LessThanTest) IntegerCandidateBadTypes() { + matcher := LessThan(int(-150)) + + cases := []ltTestCase{ + ltTestCase{true, false, true, "which is not comparable"}, + ltTestCase{complex64(-151), false, true, "which is not comparable"}, + ltTestCase{complex128(-151), false, true, "which is not comparable"}, + ltTestCase{[...]int{-151}, false, true, "which is not comparable"}, + ltTestCase{make(chan int), false, true, "which is not comparable"}, + ltTestCase{func() {}, false, true, "which is not comparable"}, + ltTestCase{map[int]int{}, false, true, "which is not comparable"}, + ltTestCase{<TestCase{}, false, true, "which is not comparable"}, + ltTestCase{make([]int, 0), false, true, "which is not comparable"}, + ltTestCase{"-151", false, true, "which is not comparable"}, + ltTestCase{ltTestCase{}, false, true, "which is not comparable"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessThanTest) FloatCandidateBadTypes() { + matcher := LessThan(float32(-150)) + + cases := []ltTestCase{ + ltTestCase{true, false, true, "which is not comparable"}, + ltTestCase{complex64(-151), false, true, "which is not comparable"}, + ltTestCase{complex128(-151), false, true, "which is not comparable"}, + ltTestCase{[...]int{-151}, false, true, "which is not comparable"}, + ltTestCase{make(chan int), false, true, "which is not comparable"}, + ltTestCase{func() {}, false, true, "which is not comparable"}, + ltTestCase{map[int]int{}, false, true, "which is not comparable"}, + ltTestCase{<TestCase{}, false, true, "which is not comparable"}, + ltTestCase{make([]int, 0), false, true, "which is not comparable"}, + ltTestCase{"-151", false, true, "which is not comparable"}, + ltTestCase{ltTestCase{}, false, true, "which is not comparable"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessThanTest) StringCandidateBadTypes() { + matcher := LessThan("17") + + cases := []ltTestCase{ + ltTestCase{true, false, true, "which is not comparable"}, + ltTestCase{int(0), false, true, "which is not comparable"}, + ltTestCase{int8(0), false, true, "which is not comparable"}, + ltTestCase{int16(0), false, true, "which is not comparable"}, + ltTestCase{int32(0), false, true, "which is not comparable"}, + ltTestCase{int64(0), false, true, "which is not comparable"}, + ltTestCase{uint(0), false, true, "which is not comparable"}, + ltTestCase{uint8(0), false, true, "which is not comparable"}, + ltTestCase{uint16(0), false, true, "which is not comparable"}, + ltTestCase{uint32(0), false, true, "which is not comparable"}, + ltTestCase{uint64(0), false, true, "which is not comparable"}, + ltTestCase{float32(0), false, true, "which is not comparable"}, + ltTestCase{float64(0), false, true, "which is not comparable"}, + ltTestCase{complex64(-151), false, true, "which is not comparable"}, + ltTestCase{complex128(-151), false, true, "which is not comparable"}, + ltTestCase{[...]int{-151}, false, true, "which is not comparable"}, + ltTestCase{make(chan int), false, true, "which is not comparable"}, + ltTestCase{func() {}, false, true, "which is not comparable"}, + ltTestCase{map[int]int{}, false, true, "which is not comparable"}, + ltTestCase{<TestCase{}, false, true, "which is not comparable"}, + ltTestCase{make([]int, 0), false, true, "which is not comparable"}, + ltTestCase{ltTestCase{}, false, true, "which is not comparable"}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessThanTest) BadArgument() { + panicked := false + + defer func() { + ExpectThat(panicked, Equals(true)) + }() + + defer func() { + if r := recover(); r != nil { + panicked = true + } + }() + + LessThan(complex128(0)) +} + +//////////////////////////////////////////////////////////////////////// +// Integer literals +//////////////////////////////////////////////////////////////////////// + +func (t *LessThanTest) NegativeIntegerLiteral() { + matcher := LessThan(-150) + desc := matcher.Description() + expectedDesc := "less than -150" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + // Signed integers. + ltTestCase{-(1 << 30), true, false, ""}, + ltTestCase{-151, true, false, ""}, + ltTestCase{-150, false, false, ""}, + ltTestCase{0, false, false, ""}, + ltTestCase{17, false, false, ""}, + + ltTestCase{int(-(1 << 30)), true, false, ""}, + ltTestCase{int(-151), true, false, ""}, + ltTestCase{int(-150), false, false, ""}, + ltTestCase{int(0), false, false, ""}, + ltTestCase{int(17), false, false, ""}, + + ltTestCase{int8(-127), false, false, ""}, + ltTestCase{int8(0), false, false, ""}, + ltTestCase{int8(17), false, false, ""}, + + ltTestCase{int16(-(1 << 14)), true, false, ""}, + ltTestCase{int16(-151), true, false, ""}, + ltTestCase{int16(-150), false, false, ""}, + ltTestCase{int16(0), false, false, ""}, + ltTestCase{int16(17), false, false, ""}, + + ltTestCase{int32(-(1 << 30)), true, false, ""}, + ltTestCase{int32(-151), true, false, ""}, + ltTestCase{int32(-150), false, false, ""}, + ltTestCase{int32(0), false, false, ""}, + ltTestCase{int32(17), false, false, ""}, + + ltTestCase{int64(-(1 << 30)), true, false, ""}, + ltTestCase{int64(-151), true, false, ""}, + ltTestCase{int64(-150), false, false, ""}, + ltTestCase{int64(0), false, false, ""}, + ltTestCase{int64(17), false, false, ""}, + + // Unsigned integers. + ltTestCase{uint((1 << 32) - 151), false, false, ""}, + ltTestCase{uint(0), false, false, ""}, + ltTestCase{uint(17), false, false, ""}, + + ltTestCase{uint8(0), false, false, ""}, + ltTestCase{uint8(17), false, false, ""}, + ltTestCase{uint8(253), false, false, ""}, + + ltTestCase{uint16((1 << 16) - 151), false, false, ""}, + ltTestCase{uint16(0), false, false, ""}, + ltTestCase{uint16(17), false, false, ""}, + + ltTestCase{uint32((1 << 32) - 151), false, false, ""}, + ltTestCase{uint32(0), false, false, ""}, + ltTestCase{uint32(17), false, false, ""}, + + ltTestCase{uint64((1 << 64) - 151), false, false, ""}, + ltTestCase{uint64(0), false, false, ""}, + ltTestCase{uint64(17), false, false, ""}, + + // Floating point. + ltTestCase{float32(-(1 << 30)), true, false, ""}, + ltTestCase{float32(-151), true, false, ""}, + ltTestCase{float32(-150.1), true, false, ""}, + ltTestCase{float32(-150), false, false, ""}, + ltTestCase{float32(-149.9), false, false, ""}, + ltTestCase{float32(0), false, false, ""}, + ltTestCase{float32(17), false, false, ""}, + ltTestCase{float32(160), false, false, ""}, + + ltTestCase{float64(-(1 << 30)), true, false, ""}, + ltTestCase{float64(-151), true, false, ""}, + ltTestCase{float64(-150.1), true, false, ""}, + ltTestCase{float64(-150), false, false, ""}, + ltTestCase{float64(-149.9), false, false, ""}, + ltTestCase{float64(0), false, false, ""}, + ltTestCase{float64(17), false, false, ""}, + ltTestCase{float64(160), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessThanTest) ZeroIntegerLiteral() { + matcher := LessThan(0) + desc := matcher.Description() + expectedDesc := "less than 0" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + // Signed integers. + ltTestCase{-(1 << 30), true, false, ""}, + ltTestCase{-1, true, false, ""}, + ltTestCase{0, false, false, ""}, + ltTestCase{1, false, false, ""}, + ltTestCase{17, false, false, ""}, + ltTestCase{(1 << 30), false, false, ""}, + + ltTestCase{int(-(1 << 30)), true, false, ""}, + ltTestCase{int(-1), true, false, ""}, + ltTestCase{int(0), false, false, ""}, + ltTestCase{int(1), false, false, ""}, + ltTestCase{int(17), false, false, ""}, + + ltTestCase{int8(-1), true, false, ""}, + ltTestCase{int8(0), false, false, ""}, + ltTestCase{int8(1), false, false, ""}, + + ltTestCase{int16(-(1 << 14)), true, false, ""}, + ltTestCase{int16(-1), true, false, ""}, + ltTestCase{int16(0), false, false, ""}, + ltTestCase{int16(1), false, false, ""}, + ltTestCase{int16(17), false, false, ""}, + + ltTestCase{int32(-(1 << 30)), true, false, ""}, + ltTestCase{int32(-1), true, false, ""}, + ltTestCase{int32(0), false, false, ""}, + ltTestCase{int32(1), false, false, ""}, + ltTestCase{int32(17), false, false, ""}, + + ltTestCase{int64(-(1 << 30)), true, false, ""}, + ltTestCase{int64(-1), true, false, ""}, + ltTestCase{int64(0), false, false, ""}, + ltTestCase{int64(1), false, false, ""}, + ltTestCase{int64(17), false, false, ""}, + + // Unsigned integers. + ltTestCase{uint((1 << 32) - 1), false, false, ""}, + ltTestCase{uint(0), false, false, ""}, + ltTestCase{uint(17), false, false, ""}, + + ltTestCase{uint8(0), false, false, ""}, + ltTestCase{uint8(17), false, false, ""}, + ltTestCase{uint8(253), false, false, ""}, + + ltTestCase{uint16((1 << 16) - 1), false, false, ""}, + ltTestCase{uint16(0), false, false, ""}, + ltTestCase{uint16(17), false, false, ""}, + + ltTestCase{uint32((1 << 32) - 1), false, false, ""}, + ltTestCase{uint32(0), false, false, ""}, + ltTestCase{uint32(17), false, false, ""}, + + ltTestCase{uint64((1 << 64) - 1), false, false, ""}, + ltTestCase{uint64(0), false, false, ""}, + ltTestCase{uint64(17), false, false, ""}, + + // Floating point. + ltTestCase{float32(-(1 << 30)), true, false, ""}, + ltTestCase{float32(-1), true, false, ""}, + ltTestCase{float32(-0.1), true, false, ""}, + ltTestCase{float32(-0.0), false, false, ""}, + ltTestCase{float32(0), false, false, ""}, + ltTestCase{float32(0.1), false, false, ""}, + ltTestCase{float32(17), false, false, ""}, + ltTestCase{float32(160), false, false, ""}, + + ltTestCase{float64(-(1 << 30)), true, false, ""}, + ltTestCase{float64(-1), true, false, ""}, + ltTestCase{float64(-0.1), true, false, ""}, + ltTestCase{float64(-0), false, false, ""}, + ltTestCase{float64(0), false, false, ""}, + ltTestCase{float64(17), false, false, ""}, + ltTestCase{float64(160), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessThanTest) PositiveIntegerLiteral() { + matcher := LessThan(150) + desc := matcher.Description() + expectedDesc := "less than 150" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + // Signed integers. + ltTestCase{-1, true, false, ""}, + ltTestCase{149, true, false, ""}, + ltTestCase{150, false, false, ""}, + ltTestCase{151, false, false, ""}, + + ltTestCase{int(-1), true, false, ""}, + ltTestCase{int(149), true, false, ""}, + ltTestCase{int(150), false, false, ""}, + ltTestCase{int(151), false, false, ""}, + + ltTestCase{int8(-1), true, false, ""}, + ltTestCase{int8(0), true, false, ""}, + ltTestCase{int8(17), true, false, ""}, + ltTestCase{int8(127), true, false, ""}, + + ltTestCase{int16(-1), true, false, ""}, + ltTestCase{int16(149), true, false, ""}, + ltTestCase{int16(150), false, false, ""}, + ltTestCase{int16(151), false, false, ""}, + + ltTestCase{int32(-1), true, false, ""}, + ltTestCase{int32(149), true, false, ""}, + ltTestCase{int32(150), false, false, ""}, + ltTestCase{int32(151), false, false, ""}, + + ltTestCase{int64(-1), true, false, ""}, + ltTestCase{int64(149), true, false, ""}, + ltTestCase{int64(150), false, false, ""}, + ltTestCase{int64(151), false, false, ""}, + + // Unsigned integers. + ltTestCase{uint(0), true, false, ""}, + ltTestCase{uint(149), true, false, ""}, + ltTestCase{uint(150), false, false, ""}, + ltTestCase{uint(151), false, false, ""}, + + ltTestCase{uint8(0), true, false, ""}, + ltTestCase{uint8(127), true, false, ""}, + + ltTestCase{uint16(0), true, false, ""}, + ltTestCase{uint16(149), true, false, ""}, + ltTestCase{uint16(150), false, false, ""}, + ltTestCase{uint16(151), false, false, ""}, + + ltTestCase{uint32(0), true, false, ""}, + ltTestCase{uint32(149), true, false, ""}, + ltTestCase{uint32(150), false, false, ""}, + ltTestCase{uint32(151), false, false, ""}, + + ltTestCase{uint64(0), true, false, ""}, + ltTestCase{uint64(149), true, false, ""}, + ltTestCase{uint64(150), false, false, ""}, + ltTestCase{uint64(151), false, false, ""}, + + // Floating point. + ltTestCase{float32(-1), true, false, ""}, + ltTestCase{float32(149), true, false, ""}, + ltTestCase{float32(149.9), true, false, ""}, + ltTestCase{float32(150), false, false, ""}, + ltTestCase{float32(150.1), false, false, ""}, + ltTestCase{float32(151), false, false, ""}, + + ltTestCase{float64(-1), true, false, ""}, + ltTestCase{float64(149), true, false, ""}, + ltTestCase{float64(149.9), true, false, ""}, + ltTestCase{float64(150), false, false, ""}, + ltTestCase{float64(150.1), false, false, ""}, + ltTestCase{float64(151), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// Float literals +//////////////////////////////////////////////////////////////////////// + +func (t *LessThanTest) NegativeFloatLiteral() { + matcher := LessThan(-150.1) + desc := matcher.Description() + expectedDesc := "less than -150.1" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + // Signed integers. + ltTestCase{-(1 << 30), true, false, ""}, + ltTestCase{-151, true, false, ""}, + ltTestCase{-150, false, false, ""}, + ltTestCase{0, false, false, ""}, + ltTestCase{17, false, false, ""}, + + ltTestCase{int(-(1 << 30)), true, false, ""}, + ltTestCase{int(-151), true, false, ""}, + ltTestCase{int(-150), false, false, ""}, + ltTestCase{int(0), false, false, ""}, + ltTestCase{int(17), false, false, ""}, + + ltTestCase{int8(-127), false, false, ""}, + ltTestCase{int8(0), false, false, ""}, + ltTestCase{int8(17), false, false, ""}, + + ltTestCase{int16(-(1 << 14)), true, false, ""}, + ltTestCase{int16(-151), true, false, ""}, + ltTestCase{int16(-150), false, false, ""}, + ltTestCase{int16(0), false, false, ""}, + ltTestCase{int16(17), false, false, ""}, + + ltTestCase{int32(-(1 << 30)), true, false, ""}, + ltTestCase{int32(-151), true, false, ""}, + ltTestCase{int32(-150), false, false, ""}, + ltTestCase{int32(0), false, false, ""}, + ltTestCase{int32(17), false, false, ""}, + + ltTestCase{int64(-(1 << 30)), true, false, ""}, + ltTestCase{int64(-151), true, false, ""}, + ltTestCase{int64(-150), false, false, ""}, + ltTestCase{int64(0), false, false, ""}, + ltTestCase{int64(17), false, false, ""}, + + // Unsigned integers. + ltTestCase{uint((1 << 32) - 151), false, false, ""}, + ltTestCase{uint(0), false, false, ""}, + ltTestCase{uint(17), false, false, ""}, + + ltTestCase{uint8(0), false, false, ""}, + ltTestCase{uint8(17), false, false, ""}, + ltTestCase{uint8(253), false, false, ""}, + + ltTestCase{uint16((1 << 16) - 151), false, false, ""}, + ltTestCase{uint16(0), false, false, ""}, + ltTestCase{uint16(17), false, false, ""}, + + ltTestCase{uint32((1 << 32) - 151), false, false, ""}, + ltTestCase{uint32(0), false, false, ""}, + ltTestCase{uint32(17), false, false, ""}, + + ltTestCase{uint64((1 << 64) - 151), false, false, ""}, + ltTestCase{uint64(0), false, false, ""}, + ltTestCase{uint64(17), false, false, ""}, + + // Floating point. + ltTestCase{float32(-(1 << 30)), true, false, ""}, + ltTestCase{float32(-151), true, false, ""}, + ltTestCase{float32(-150.2), true, false, ""}, + ltTestCase{float32(-150.1), false, false, ""}, + ltTestCase{float32(-150), false, false, ""}, + ltTestCase{float32(0), false, false, ""}, + ltTestCase{float32(17), false, false, ""}, + ltTestCase{float32(160), false, false, ""}, + + ltTestCase{float64(-(1 << 30)), true, false, ""}, + ltTestCase{float64(-151), true, false, ""}, + ltTestCase{float64(-150.2), true, false, ""}, + ltTestCase{float64(-150.1), false, false, ""}, + ltTestCase{float64(-150), false, false, ""}, + ltTestCase{float64(0), false, false, ""}, + ltTestCase{float64(17), false, false, ""}, + ltTestCase{float64(160), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessThanTest) PositiveFloatLiteral() { + matcher := LessThan(149.9) + desc := matcher.Description() + expectedDesc := "less than 149.9" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + // Signed integers. + ltTestCase{-1, true, false, ""}, + ltTestCase{149, true, false, ""}, + ltTestCase{150, false, false, ""}, + ltTestCase{151, false, false, ""}, + + ltTestCase{int(-1), true, false, ""}, + ltTestCase{int(149), true, false, ""}, + ltTestCase{int(150), false, false, ""}, + ltTestCase{int(151), false, false, ""}, + + ltTestCase{int8(-1), true, false, ""}, + ltTestCase{int8(0), true, false, ""}, + ltTestCase{int8(17), true, false, ""}, + ltTestCase{int8(127), true, false, ""}, + + ltTestCase{int16(-1), true, false, ""}, + ltTestCase{int16(149), true, false, ""}, + ltTestCase{int16(150), false, false, ""}, + ltTestCase{int16(151), false, false, ""}, + + ltTestCase{int32(-1), true, false, ""}, + ltTestCase{int32(149), true, false, ""}, + ltTestCase{int32(150), false, false, ""}, + ltTestCase{int32(151), false, false, ""}, + + ltTestCase{int64(-1), true, false, ""}, + ltTestCase{int64(149), true, false, ""}, + ltTestCase{int64(150), false, false, ""}, + ltTestCase{int64(151), false, false, ""}, + + // Unsigned integers. + ltTestCase{uint(0), true, false, ""}, + ltTestCase{uint(149), true, false, ""}, + ltTestCase{uint(150), false, false, ""}, + ltTestCase{uint(151), false, false, ""}, + + ltTestCase{uint8(0), true, false, ""}, + ltTestCase{uint8(127), true, false, ""}, + + ltTestCase{uint16(0), true, false, ""}, + ltTestCase{uint16(149), true, false, ""}, + ltTestCase{uint16(150), false, false, ""}, + ltTestCase{uint16(151), false, false, ""}, + + ltTestCase{uint32(0), true, false, ""}, + ltTestCase{uint32(149), true, false, ""}, + ltTestCase{uint32(150), false, false, ""}, + ltTestCase{uint32(151), false, false, ""}, + + ltTestCase{uint64(0), true, false, ""}, + ltTestCase{uint64(149), true, false, ""}, + ltTestCase{uint64(150), false, false, ""}, + ltTestCase{uint64(151), false, false, ""}, + + // Floating point. + ltTestCase{float32(-1), true, false, ""}, + ltTestCase{float32(149), true, false, ""}, + ltTestCase{float32(149.8), true, false, ""}, + ltTestCase{float32(149.9), false, false, ""}, + ltTestCase{float32(150), false, false, ""}, + ltTestCase{float32(151), false, false, ""}, + + ltTestCase{float64(-1), true, false, ""}, + ltTestCase{float64(149), true, false, ""}, + ltTestCase{float64(149.8), true, false, ""}, + ltTestCase{float64(149.9), false, false, ""}, + ltTestCase{float64(150), false, false, ""}, + ltTestCase{float64(151), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// Subtle cases +//////////////////////////////////////////////////////////////////////// + +func (t *LessThanTest) Int64NotExactlyRepresentableBySinglePrecision() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := LessThan(int64(kTwoTo25 + 1)) + + desc := matcher.Description() + expectedDesc := "less than 33554433" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + // Signed integers. + ltTestCase{-1, true, false, ""}, + ltTestCase{kTwoTo25 + 0, true, false, ""}, + ltTestCase{kTwoTo25 + 1, false, false, ""}, + ltTestCase{kTwoTo25 + 2, false, false, ""}, + + ltTestCase{int(-1), true, false, ""}, + ltTestCase{int(kTwoTo25 + 0), true, false, ""}, + ltTestCase{int(kTwoTo25 + 1), false, false, ""}, + ltTestCase{int(kTwoTo25 + 2), false, false, ""}, + + ltTestCase{int8(-1), true, false, ""}, + ltTestCase{int8(127), true, false, ""}, + + ltTestCase{int16(-1), true, false, ""}, + ltTestCase{int16(0), true, false, ""}, + ltTestCase{int16(32767), true, false, ""}, + + ltTestCase{int32(-1), true, false, ""}, + ltTestCase{int32(kTwoTo25 + 0), true, false, ""}, + ltTestCase{int32(kTwoTo25 + 1), false, false, ""}, + ltTestCase{int32(kTwoTo25 + 2), false, false, ""}, + + ltTestCase{int64(-1), true, false, ""}, + ltTestCase{int64(kTwoTo25 + 0), true, false, ""}, + ltTestCase{int64(kTwoTo25 + 1), false, false, ""}, + ltTestCase{int64(kTwoTo25 + 2), false, false, ""}, + + // Unsigned integers. + ltTestCase{uint(0), true, false, ""}, + ltTestCase{uint(kTwoTo25 + 0), true, false, ""}, + ltTestCase{uint(kTwoTo25 + 1), false, false, ""}, + ltTestCase{uint(kTwoTo25 + 2), false, false, ""}, + + ltTestCase{uint8(0), true, false, ""}, + ltTestCase{uint8(255), true, false, ""}, + + ltTestCase{uint16(0), true, false, ""}, + ltTestCase{uint16(65535), true, false, ""}, + + ltTestCase{uint32(0), true, false, ""}, + ltTestCase{uint32(kTwoTo25 + 0), true, false, ""}, + ltTestCase{uint32(kTwoTo25 + 1), false, false, ""}, + ltTestCase{uint32(kTwoTo25 + 2), false, false, ""}, + + ltTestCase{uint64(0), true, false, ""}, + ltTestCase{uint64(kTwoTo25 + 0), true, false, ""}, + ltTestCase{uint64(kTwoTo25 + 1), false, false, ""}, + ltTestCase{uint64(kTwoTo25 + 2), false, false, ""}, + + // Floating point. + ltTestCase{float32(-1), true, false, ""}, + ltTestCase{float32(kTwoTo25 - 2), true, false, ""}, + ltTestCase{float32(kTwoTo25 - 1), false, false, ""}, + ltTestCase{float32(kTwoTo25 + 0), false, false, ""}, + ltTestCase{float32(kTwoTo25 + 1), false, false, ""}, + ltTestCase{float32(kTwoTo25 + 2), false, false, ""}, + ltTestCase{float32(kTwoTo25 + 3), false, false, ""}, + + ltTestCase{float64(-1), true, false, ""}, + ltTestCase{float64(kTwoTo25 - 2), true, false, ""}, + ltTestCase{float64(kTwoTo25 - 1), true, false, ""}, + ltTestCase{float64(kTwoTo25 + 0), true, false, ""}, + ltTestCase{float64(kTwoTo25 + 1), false, false, ""}, + ltTestCase{float64(kTwoTo25 + 2), false, false, ""}, + ltTestCase{float64(kTwoTo25 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessThanTest) Int64NotExactlyRepresentableByDoublePrecision() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := LessThan(int64(kTwoTo54 + 1)) + + desc := matcher.Description() + expectedDesc := "less than 18014398509481985" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + // Signed integers. + ltTestCase{-1, true, false, ""}, + ltTestCase{1 << 30, true, false, ""}, + + ltTestCase{int(-1), true, false, ""}, + ltTestCase{int(math.MaxInt32), true, false, ""}, + + ltTestCase{int8(-1), true, false, ""}, + ltTestCase{int8(127), true, false, ""}, + + ltTestCase{int16(-1), true, false, ""}, + ltTestCase{int16(0), true, false, ""}, + ltTestCase{int16(32767), true, false, ""}, + + ltTestCase{int32(-1), true, false, ""}, + ltTestCase{int32(math.MaxInt32), true, false, ""}, + + ltTestCase{int64(-1), true, false, ""}, + ltTestCase{int64(kTwoTo54 - 1), true, false, ""}, + ltTestCase{int64(kTwoTo54 + 0), true, false, ""}, + ltTestCase{int64(kTwoTo54 + 1), false, false, ""}, + ltTestCase{int64(kTwoTo54 + 2), false, false, ""}, + + // Unsigned integers. + ltTestCase{uint(0), true, false, ""}, + ltTestCase{uint(math.MaxUint32), true, false, ""}, + + ltTestCase{uint8(0), true, false, ""}, + ltTestCase{uint8(255), true, false, ""}, + + ltTestCase{uint16(0), true, false, ""}, + ltTestCase{uint16(65535), true, false, ""}, + + ltTestCase{uint32(0), true, false, ""}, + ltTestCase{uint32(math.MaxUint32), true, false, ""}, + + ltTestCase{uint64(0), true, false, ""}, + ltTestCase{uint64(kTwoTo54 - 1), true, false, ""}, + ltTestCase{uint64(kTwoTo54 + 0), true, false, ""}, + ltTestCase{uint64(kTwoTo54 + 1), false, false, ""}, + ltTestCase{uint64(kTwoTo54 + 2), false, false, ""}, + + // Floating point. + ltTestCase{float64(-1), true, false, ""}, + ltTestCase{float64(kTwoTo54 - 2), true, false, ""}, + ltTestCase{float64(kTwoTo54 - 1), false, false, ""}, + ltTestCase{float64(kTwoTo54 + 0), false, false, ""}, + ltTestCase{float64(kTwoTo54 + 1), false, false, ""}, + ltTestCase{float64(kTwoTo54 + 2), false, false, ""}, + ltTestCase{float64(kTwoTo54 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessThanTest) Uint64NotExactlyRepresentableBySinglePrecision() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := LessThan(uint64(kTwoTo25 + 1)) + + desc := matcher.Description() + expectedDesc := "less than 33554433" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + // Signed integers. + ltTestCase{-1, true, false, ""}, + ltTestCase{kTwoTo25 + 0, true, false, ""}, + ltTestCase{kTwoTo25 + 1, false, false, ""}, + ltTestCase{kTwoTo25 + 2, false, false, ""}, + + ltTestCase{int(-1), true, false, ""}, + ltTestCase{int(kTwoTo25 + 0), true, false, ""}, + ltTestCase{int(kTwoTo25 + 1), false, false, ""}, + ltTestCase{int(kTwoTo25 + 2), false, false, ""}, + + ltTestCase{int8(-1), true, false, ""}, + ltTestCase{int8(127), true, false, ""}, + + ltTestCase{int16(-1), true, false, ""}, + ltTestCase{int16(0), true, false, ""}, + ltTestCase{int16(32767), true, false, ""}, + + ltTestCase{int32(-1), true, false, ""}, + ltTestCase{int32(kTwoTo25 + 0), true, false, ""}, + ltTestCase{int32(kTwoTo25 + 1), false, false, ""}, + ltTestCase{int32(kTwoTo25 + 2), false, false, ""}, + + ltTestCase{int64(-1), true, false, ""}, + ltTestCase{int64(kTwoTo25 + 0), true, false, ""}, + ltTestCase{int64(kTwoTo25 + 1), false, false, ""}, + ltTestCase{int64(kTwoTo25 + 2), false, false, ""}, + + // Unsigned integers. + ltTestCase{uint(0), true, false, ""}, + ltTestCase{uint(kTwoTo25 + 0), true, false, ""}, + ltTestCase{uint(kTwoTo25 + 1), false, false, ""}, + ltTestCase{uint(kTwoTo25 + 2), false, false, ""}, + + ltTestCase{uint8(0), true, false, ""}, + ltTestCase{uint8(255), true, false, ""}, + + ltTestCase{uint16(0), true, false, ""}, + ltTestCase{uint16(65535), true, false, ""}, + + ltTestCase{uint32(0), true, false, ""}, + ltTestCase{uint32(kTwoTo25 + 0), true, false, ""}, + ltTestCase{uint32(kTwoTo25 + 1), false, false, ""}, + ltTestCase{uint32(kTwoTo25 + 2), false, false, ""}, + + ltTestCase{uint64(0), true, false, ""}, + ltTestCase{uint64(kTwoTo25 + 0), true, false, ""}, + ltTestCase{uint64(kTwoTo25 + 1), false, false, ""}, + ltTestCase{uint64(kTwoTo25 + 2), false, false, ""}, + + // Floating point. + ltTestCase{float32(-1), true, false, ""}, + ltTestCase{float32(kTwoTo25 - 2), true, false, ""}, + ltTestCase{float32(kTwoTo25 - 1), false, false, ""}, + ltTestCase{float32(kTwoTo25 + 0), false, false, ""}, + ltTestCase{float32(kTwoTo25 + 1), false, false, ""}, + ltTestCase{float32(kTwoTo25 + 2), false, false, ""}, + ltTestCase{float32(kTwoTo25 + 3), false, false, ""}, + + ltTestCase{float64(-1), true, false, ""}, + ltTestCase{float64(kTwoTo25 - 2), true, false, ""}, + ltTestCase{float64(kTwoTo25 - 1), true, false, ""}, + ltTestCase{float64(kTwoTo25 + 0), true, false, ""}, + ltTestCase{float64(kTwoTo25 + 1), false, false, ""}, + ltTestCase{float64(kTwoTo25 + 2), false, false, ""}, + ltTestCase{float64(kTwoTo25 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessThanTest) Uint64NotExactlyRepresentableByDoublePrecision() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := LessThan(uint64(kTwoTo54 + 1)) + + desc := matcher.Description() + expectedDesc := "less than 18014398509481985" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + // Signed integers. + ltTestCase{-1, true, false, ""}, + ltTestCase{1 << 30, true, false, ""}, + + ltTestCase{int(-1), true, false, ""}, + ltTestCase{int(math.MaxInt32), true, false, ""}, + + ltTestCase{int8(-1), true, false, ""}, + ltTestCase{int8(127), true, false, ""}, + + ltTestCase{int16(-1), true, false, ""}, + ltTestCase{int16(0), true, false, ""}, + ltTestCase{int16(32767), true, false, ""}, + + ltTestCase{int32(-1), true, false, ""}, + ltTestCase{int32(math.MaxInt32), true, false, ""}, + + ltTestCase{int64(-1), true, false, ""}, + ltTestCase{int64(kTwoTo54 - 1), true, false, ""}, + ltTestCase{int64(kTwoTo54 + 0), true, false, ""}, + ltTestCase{int64(kTwoTo54 + 1), false, false, ""}, + ltTestCase{int64(kTwoTo54 + 2), false, false, ""}, + + // Unsigned integers. + ltTestCase{uint(0), true, false, ""}, + ltTestCase{uint(math.MaxUint32), true, false, ""}, + + ltTestCase{uint8(0), true, false, ""}, + ltTestCase{uint8(255), true, false, ""}, + + ltTestCase{uint16(0), true, false, ""}, + ltTestCase{uint16(65535), true, false, ""}, + + ltTestCase{uint32(0), true, false, ""}, + ltTestCase{uint32(math.MaxUint32), true, false, ""}, + + ltTestCase{uint64(0), true, false, ""}, + ltTestCase{uint64(kTwoTo54 - 1), true, false, ""}, + ltTestCase{uint64(kTwoTo54 + 0), true, false, ""}, + ltTestCase{uint64(kTwoTo54 + 1), false, false, ""}, + ltTestCase{uint64(kTwoTo54 + 2), false, false, ""}, + + // Floating point. + ltTestCase{float64(-1), true, false, ""}, + ltTestCase{float64(kTwoTo54 - 2), true, false, ""}, + ltTestCase{float64(kTwoTo54 - 1), false, false, ""}, + ltTestCase{float64(kTwoTo54 + 0), false, false, ""}, + ltTestCase{float64(kTwoTo54 + 1), false, false, ""}, + ltTestCase{float64(kTwoTo54 + 2), false, false, ""}, + ltTestCase{float64(kTwoTo54 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessThanTest) Float32AboveExactIntegerRange() { + // Single-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo25 = 1 << 25 + matcher := LessThan(float32(kTwoTo25 + 1)) + + desc := matcher.Description() + expectedDesc := "less than 3.3554432e+07" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + // Signed integers. + ltTestCase{int64(-1), true, false, ""}, + ltTestCase{int64(kTwoTo25 - 2), true, false, ""}, + ltTestCase{int64(kTwoTo25 - 1), false, false, ""}, + ltTestCase{int64(kTwoTo25 + 0), false, false, ""}, + ltTestCase{int64(kTwoTo25 + 1), false, false, ""}, + ltTestCase{int64(kTwoTo25 + 2), false, false, ""}, + ltTestCase{int64(kTwoTo25 + 3), false, false, ""}, + + // Unsigned integers. + ltTestCase{uint64(0), true, false, ""}, + ltTestCase{uint64(kTwoTo25 - 2), true, false, ""}, + ltTestCase{uint64(kTwoTo25 - 1), false, false, ""}, + ltTestCase{uint64(kTwoTo25 + 0), false, false, ""}, + ltTestCase{uint64(kTwoTo25 + 1), false, false, ""}, + ltTestCase{uint64(kTwoTo25 + 2), false, false, ""}, + ltTestCase{uint64(kTwoTo25 + 3), false, false, ""}, + + // Floating point. + ltTestCase{float32(-1), true, false, ""}, + ltTestCase{float32(kTwoTo25 - 2), true, false, ""}, + ltTestCase{float32(kTwoTo25 - 1), false, false, ""}, + ltTestCase{float32(kTwoTo25 + 0), false, false, ""}, + ltTestCase{float32(kTwoTo25 + 1), false, false, ""}, + ltTestCase{float32(kTwoTo25 + 2), false, false, ""}, + ltTestCase{float32(kTwoTo25 + 3), false, false, ""}, + + ltTestCase{float64(-1), true, false, ""}, + ltTestCase{float64(kTwoTo25 - 2), true, false, ""}, + ltTestCase{float64(kTwoTo25 - 1), false, false, ""}, + ltTestCase{float64(kTwoTo25 + 0), false, false, ""}, + ltTestCase{float64(kTwoTo25 + 1), false, false, ""}, + ltTestCase{float64(kTwoTo25 + 2), false, false, ""}, + ltTestCase{float64(kTwoTo25 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessThanTest) Float64AboveExactIntegerRange() { + // Double-precision floats don't have enough bits to represent the integers + // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value + // and should be treated as equivalent when floats are in the mix. + const kTwoTo54 = 1 << 54 + matcher := LessThan(float64(kTwoTo54 + 1)) + + desc := matcher.Description() + expectedDesc := "less than 1.8014398509481984e+16" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + // Signed integers. + ltTestCase{int64(-1), true, false, ""}, + ltTestCase{int64(kTwoTo54 - 2), true, false, ""}, + ltTestCase{int64(kTwoTo54 - 1), false, false, ""}, + ltTestCase{int64(kTwoTo54 + 0), false, false, ""}, + ltTestCase{int64(kTwoTo54 + 1), false, false, ""}, + ltTestCase{int64(kTwoTo54 + 2), false, false, ""}, + ltTestCase{int64(kTwoTo54 + 3), false, false, ""}, + + // Unsigned integers. + ltTestCase{uint64(0), true, false, ""}, + ltTestCase{uint64(kTwoTo54 - 2), true, false, ""}, + ltTestCase{uint64(kTwoTo54 - 1), false, false, ""}, + ltTestCase{uint64(kTwoTo54 + 0), false, false, ""}, + ltTestCase{uint64(kTwoTo54 + 1), false, false, ""}, + ltTestCase{uint64(kTwoTo54 + 2), false, false, ""}, + ltTestCase{uint64(kTwoTo54 + 3), false, false, ""}, + + // Floating point. + ltTestCase{float64(-1), true, false, ""}, + ltTestCase{float64(kTwoTo54 - 2), true, false, ""}, + ltTestCase{float64(kTwoTo54 - 1), false, false, ""}, + ltTestCase{float64(kTwoTo54 + 0), false, false, ""}, + ltTestCase{float64(kTwoTo54 + 1), false, false, ""}, + ltTestCase{float64(kTwoTo54 + 2), false, false, ""}, + ltTestCase{float64(kTwoTo54 + 3), false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +//////////////////////////////////////////////////////////////////////// +// String literals +//////////////////////////////////////////////////////////////////////// + +func (t *LessThanTest) EmptyString() { + matcher := LessThan("") + desc := matcher.Description() + expectedDesc := "less than \"\"" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + ltTestCase{"", false, false, ""}, + ltTestCase{"\x00", false, false, ""}, + ltTestCase{"a", false, false, ""}, + ltTestCase{"foo", false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessThanTest) SingleNullByte() { + matcher := LessThan("\x00") + desc := matcher.Description() + expectedDesc := "less than \"\x00\"" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + ltTestCase{"", true, false, ""}, + ltTestCase{"\x00", false, false, ""}, + ltTestCase{"a", false, false, ""}, + ltTestCase{"foo", false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} + +func (t *LessThanTest) LongerString() { + matcher := LessThan("foo\x00") + desc := matcher.Description() + expectedDesc := "less than \"foo\x00\"" + + ExpectThat(desc, Equals(expectedDesc)) + + cases := []ltTestCase{ + ltTestCase{"", true, false, ""}, + ltTestCase{"\x00", true, false, ""}, + ltTestCase{"bar", true, false, ""}, + ltTestCase{"foo", true, false, ""}, + ltTestCase{"foo\x00", false, false, ""}, + ltTestCase{"fooa", false, false, ""}, + ltTestCase{"qux", false, false, ""}, + } + + t.checkTestCases(matcher, cases) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go new file mode 100644 index 000000000..1ed63f30c --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go @@ -0,0 +1,69 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers + +import ( + "errors" + "fmt" + "reflect" + "regexp" +) + +// MatchesRegexp returns a matcher that matches strings and byte slices whose +// contents match the supplied regular expression. The semantics are those of +// regexp.Match. In particular, that means the match is not implicitly anchored +// to the ends of the string: MatchesRegexp("bar") will match "foo bar baz". +func MatchesRegexp(pattern string) Matcher { + re, err := regexp.Compile(pattern) + if err != nil { + panic("MatchesRegexp: " + err.Error()) + } + + return &matchesRegexpMatcher{re} +} + +type matchesRegexpMatcher struct { + re *regexp.Regexp +} + +func (m *matchesRegexpMatcher) Description() string { + return fmt.Sprintf("matches regexp \"%s\"", m.re.String()) +} + +func (m *matchesRegexpMatcher) Matches(c interface{}) (err error) { + v := reflect.ValueOf(c) + isString := v.Kind() == reflect.String + isByteSlice := v.Kind() == reflect.Slice && v.Elem().Kind() == reflect.Uint8 + + err = errors.New("") + + switch { + case isString: + if m.re.MatchString(v.String()) { + err = nil + } + + case isByteSlice: + if m.re.Match(v.Bytes()) { + err = nil + } + + default: + err = NewFatalError("which is not a string or []byte") + } + + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp_test.go new file mode 100644 index 000000000..031c6cb3e --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp_test.go @@ -0,0 +1,92 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type MatchesRegexpTest struct { +} + +func init() { RegisterTestSuite(&MatchesRegexpTest{}) } + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *MatchesRegexpTest) Description() { + m := MatchesRegexp("foo.*bar") + ExpectEq("matches regexp \"foo.*bar\"", m.Description()) +} + +func (t *MatchesRegexpTest) InvalidRegexp() { + ExpectThat( + func() { MatchesRegexp("(foo") }, + Panics(HasSubstr("missing closing )"))) +} + +func (t *MatchesRegexpTest) CandidateIsNil() { + m := MatchesRegexp("") + err := m.Matches(nil) + + ExpectThat(err, Error(Equals("which is not a string or []byte"))) + ExpectTrue(isFatal(err)) +} + +func (t *MatchesRegexpTest) CandidateIsInteger() { + m := MatchesRegexp("") + err := m.Matches(17) + + ExpectThat(err, Error(Equals("which is not a string or []byte"))) + ExpectTrue(isFatal(err)) +} + +func (t *MatchesRegexpTest) NonMatchingCandidates() { + m := MatchesRegexp("fo[op]\\s+x") + var err error + + err = m.Matches("fon x") + ExpectThat(err, Error(Equals(""))) + ExpectFalse(isFatal(err)) + + err = m.Matches("fopx") + ExpectThat(err, Error(Equals(""))) + ExpectFalse(isFatal(err)) + + err = m.Matches("fop ") + ExpectThat(err, Error(Equals(""))) + ExpectFalse(isFatal(err)) +} + +func (t *MatchesRegexpTest) MatchingCandidates() { + m := MatchesRegexp("fo[op]\\s+x") + var err error + + err = m.Matches("foo x") + ExpectEq(nil, err) + + err = m.Matches("fop x") + ExpectEq(nil, err) + + err = m.Matches("blah blah foo x blah blah") + ExpectEq(nil, err) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go new file mode 100644 index 000000000..c9d8398ee --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go @@ -0,0 +1,43 @@ +// Copyright 2015 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers + +// Create a matcher with the given description and predicate function, which +// will be invoked to handle calls to Matchers. +// +// Using this constructor may be a convenience over defining your own type that +// implements Matcher if you do not need any logic in your Description method. +func NewMatcher( + predicate func(interface{}) error, + description string) Matcher { + return &predicateMatcher{ + predicate: predicate, + description: description, + } +} + +type predicateMatcher struct { + predicate func(interface{}) error + description string +} + +func (pm *predicateMatcher) Matches(c interface{}) error { + return pm.predicate(c) +} + +func (pm *predicateMatcher) Description() string { + return pm.description +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/not_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/not_test.go new file mode 100644 index 000000000..9c65b85ef --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/not_test.go @@ -0,0 +1,108 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "errors" + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" + "testing" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type fakeMatcher struct { + matchFunc func(interface{}) error + description string +} + +func (m *fakeMatcher) Matches(c interface{}) error { + return m.matchFunc(c) +} + +func (m *fakeMatcher) Description() string { + return m.description +} + +type NotTest struct { + +} + +func init() { RegisterTestSuite(&NotTest{}) } +func TestOgletest(t *testing.T) { RunTests(t) } + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *NotTest) CallsWrapped() { + var suppliedCandidate interface{} + matchFunc := func(c interface{}) error { + suppliedCandidate = c + return nil + } + + wrapped := &fakeMatcher{matchFunc, ""} + matcher := Not(wrapped) + + matcher.Matches(17) + ExpectThat(suppliedCandidate, Equals(17)) +} + +func (t *NotTest) WrappedReturnsTrue() { + matchFunc := func(c interface{}) error { + return nil + } + + wrapped := &fakeMatcher{matchFunc, ""} + matcher := Not(wrapped) + + err := matcher.Matches(0) + ExpectThat(err, Error(Equals(""))) +} + +func (t *NotTest) WrappedReturnsNonFatalError() { + matchFunc := func(c interface{}) error { + return errors.New("taco") + } + + wrapped := &fakeMatcher{matchFunc, ""} + matcher := Not(wrapped) + + err := matcher.Matches(0) + ExpectEq(nil, err) +} + +func (t *NotTest) WrappedReturnsFatalError() { + matchFunc := func(c interface{}) error { + return NewFatalError("taco") + } + + wrapped := &fakeMatcher{matchFunc, ""} + matcher := Not(wrapped) + + err := matcher.Matches(0) + ExpectThat(err, Error(Equals("taco"))) +} + +func (t *NotTest) Description() { + wrapped := &fakeMatcher{nil, "taco"} + matcher := Not(wrapped) + + ExpectEq("not(taco)", matcher.Description()) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/panics.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/panics.go new file mode 100644 index 000000000..d2cfc9786 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/panics.go @@ -0,0 +1,74 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers + +import ( + "errors" + "fmt" + "reflect" +) + +// Panics matches zero-arg functions which, when invoked, panic with an error +// that matches the supplied matcher. +// +// NOTE(jacobsa): This matcher cannot detect the case where the function panics +// using panic(nil), by design of the language. See here for more info: +// +// http://goo.gl/9aIQL +// +func Panics(m Matcher) Matcher { + return &panicsMatcher{m} +} + +type panicsMatcher struct { + wrappedMatcher Matcher +} + +func (m *panicsMatcher) Description() string { + return "panics with: " + m.wrappedMatcher.Description() +} + +func (m *panicsMatcher) Matches(c interface{}) (err error) { + // Make sure c is a zero-arg function. + v := reflect.ValueOf(c) + if v.Kind() != reflect.Func || v.Type().NumIn() != 0 { + err = NewFatalError("which is not a zero-arg function") + return + } + + // Call the function and check its panic error. + defer func() { + if e := recover(); e != nil { + err = m.wrappedMatcher.Matches(e) + + // Set a clearer error message if the matcher said no. + if err != nil { + wrappedClause := "" + if err.Error() != "" { + wrappedClause = ", " + err.Error() + } + + err = errors.New(fmt.Sprintf("which panicked with: %v%s", e, wrappedClause)) + } + } + }() + + v.Call([]reflect.Value{}) + + // If we get here, the function didn't panic. + err = errors.New("which didn't panic") + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/panics_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/panics_test.go new file mode 100644 index 000000000..fbb66bf31 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/panics_test.go @@ -0,0 +1,141 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "errors" + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type PanicsTest struct { + matcherCalled bool + suppliedCandidate interface{} + wrappedError error + + matcher Matcher +} + +func init() { RegisterTestSuite(&PanicsTest{}) } + +func (t *PanicsTest) SetUp(i *TestInfo) { + wrapped := &fakeMatcher{ + func(c interface{}) error { + t.matcherCalled = true + t.suppliedCandidate = c + return t.wrappedError + }, + "foo", + } + + t.matcher = Panics(wrapped) +} + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *PanicsTest) Description() { + ExpectThat(t.matcher.Description(), Equals("panics with: foo")) +} + +func (t *PanicsTest) CandidateIsNil() { + err := t.matcher.Matches(nil) + + ExpectThat(err, Error(Equals("which is not a zero-arg function"))) + ExpectTrue(isFatal(err)) +} + +func (t *PanicsTest) CandidateIsString() { + err := t.matcher.Matches("taco") + + ExpectThat(err, Error(Equals("which is not a zero-arg function"))) + ExpectTrue(isFatal(err)) +} + +func (t *PanicsTest) CandidateTakesArgs() { + err := t.matcher.Matches(func(i int) string { return "" }) + + ExpectThat(err, Error(Equals("which is not a zero-arg function"))) + ExpectTrue(isFatal(err)) +} + +func (t *PanicsTest) CallsFunction() { + callCount := 0 + t.matcher.Matches(func() string { + callCount++ + return "" + }) + + ExpectThat(callCount, Equals(1)) +} + +func (t *PanicsTest) FunctionDoesntPanic() { + err := t.matcher.Matches(func() {}) + + ExpectThat(err, Error(Equals("which didn't panic"))) + ExpectFalse(isFatal(err)) +} + +func (t *PanicsTest) CallsWrappedMatcher() { + expectedErr := 17 + t.wrappedError = errors.New("") + t.matcher.Matches(func() { panic(expectedErr) }) + + ExpectThat(t.suppliedCandidate, Equals(expectedErr)) +} + +func (t *PanicsTest) WrappedReturnsTrue() { + err := t.matcher.Matches(func() { panic("") }) + + ExpectEq(nil, err) +} + +func (t *PanicsTest) WrappedReturnsFatalErrorWithoutText() { + t.wrappedError = NewFatalError("") + err := t.matcher.Matches(func() { panic(17) }) + + ExpectThat(err, Error(Equals("which panicked with: 17"))) + ExpectFalse(isFatal(err)) +} + +func (t *PanicsTest) WrappedReturnsFatalErrorWithText() { + t.wrappedError = NewFatalError("which blah") + err := t.matcher.Matches(func() { panic(17) }) + + ExpectThat(err, Error(Equals("which panicked with: 17, which blah"))) + ExpectFalse(isFatal(err)) +} + +func (t *PanicsTest) WrappedReturnsNonFatalErrorWithoutText() { + t.wrappedError = errors.New("") + err := t.matcher.Matches(func() { panic(17) }) + + ExpectThat(err, Error(Equals("which panicked with: 17"))) + ExpectFalse(isFatal(err)) +} + +func (t *PanicsTest) WrappedReturnsNonFatalErrorWithText() { + t.wrappedError = errors.New("which blah") + err := t.matcher.Matches(func() { panic(17) }) + + ExpectThat(err, Error(Equals("which panicked with: 17, which blah"))) + ExpectFalse(isFatal(err)) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee.go new file mode 100644 index 000000000..c5383f240 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee.go @@ -0,0 +1,65 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers + +import ( + "errors" + "fmt" + "reflect" +) + +// Return a matcher that matches non-nil pointers whose pointee matches the +// wrapped matcher. +func Pointee(m Matcher) Matcher { + return &pointeeMatcher{m} +} + +type pointeeMatcher struct { + wrapped Matcher +} + +func (m *pointeeMatcher) Matches(c interface{}) (err error) { + // Make sure the candidate is of the appropriate type. + cv := reflect.ValueOf(c) + if !cv.IsValid() || cv.Kind() != reflect.Ptr { + return NewFatalError("which is not a pointer") + } + + // Make sure the candidate is non-nil. + if cv.IsNil() { + return NewFatalError("") + } + + // Defer to the wrapped matcher. Fix up empty errors so that failure messages + // are more helpful than just printing a pointer for "Actual". + pointee := cv.Elem().Interface() + err = m.wrapped.Matches(pointee) + if err != nil && err.Error() == "" { + s := fmt.Sprintf("whose pointee is %v", pointee) + + if _, ok := err.(*FatalError); ok { + err = NewFatalError(s) + } else { + err = errors.New(s) + } + } + + return err +} + +func (m *pointeeMatcher) Description() string { + return fmt.Sprintf("pointee(%s)", m.wrapped.Description()) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee_test.go new file mode 100644 index 000000000..3bb72a702 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee_test.go @@ -0,0 +1,152 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "errors" + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" + "testing" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type PointeeTest struct {} +func init() { RegisterTestSuite(&PointeeTest{}) } + +func TestPointee(t *testing.T) { RunTests(t) } + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *PointeeTest) Description() { + wrapped := &fakeMatcher{nil, "taco"} + matcher := Pointee(wrapped) + + ExpectEq("pointee(taco)", matcher.Description()) +} + +func (t *PointeeTest) CandidateIsNotAPointer() { + matcher := Pointee(HasSubstr("")) + err := matcher.Matches([]byte{}) + + ExpectThat(err, Error(Equals("which is not a pointer"))) + ExpectTrue(isFatal(err)) +} + +func (t *PointeeTest) CandidateIsANilLiteral() { + matcher := Pointee(HasSubstr("")) + err := matcher.Matches(nil) + + ExpectThat(err, Error(Equals("which is not a pointer"))) + ExpectTrue(isFatal(err)) +} + +func (t *PointeeTest) CandidateIsANilPointer() { + matcher := Pointee(HasSubstr("")) + err := matcher.Matches((*int)(nil)) + + ExpectThat(err, Error(Equals(""))) + ExpectTrue(isFatal(err)) +} + +func (t *PointeeTest) CallsWrapped() { + var suppliedCandidate interface{} + matchFunc := func(c interface{}) error { + suppliedCandidate = c + return nil + } + + wrapped := &fakeMatcher{matchFunc, ""} + matcher := Pointee(wrapped) + + someSlice := []byte{} + matcher.Matches(&someSlice) + ExpectThat(suppliedCandidate, IdenticalTo(someSlice)) +} + +func (t *PointeeTest) WrappedReturnsOkay() { + matchFunc := func(c interface{}) error { + return nil + } + + wrapped := &fakeMatcher{matchFunc, ""} + matcher := Pointee(wrapped) + + err := matcher.Matches(new(int)) + ExpectEq(nil, err) +} + +func (t *PointeeTest) WrappedReturnsNonFatalNonEmptyError() { + matchFunc := func(c interface{}) error { + return errors.New("taco") + } + + wrapped := &fakeMatcher{matchFunc, ""} + matcher := Pointee(wrapped) + + i := 17 + err := matcher.Matches(&i) + ExpectFalse(isFatal(err)) + ExpectThat(err, Error(Equals("taco"))) +} + +func (t *PointeeTest) WrappedReturnsNonFatalEmptyError() { + matchFunc := func(c interface{}) error { + return errors.New("") + } + + wrapped := &fakeMatcher{matchFunc, ""} + matcher := Pointee(wrapped) + + i := 17 + err := matcher.Matches(&i) + ExpectFalse(isFatal(err)) + ExpectThat(err, Error(HasSubstr("whose pointee"))) + ExpectThat(err, Error(HasSubstr("17"))) +} + +func (t *PointeeTest) WrappedReturnsFatalNonEmptyError() { + matchFunc := func(c interface{}) error { + return NewFatalError("taco") + } + + wrapped := &fakeMatcher{matchFunc, ""} + matcher := Pointee(wrapped) + + i := 17 + err := matcher.Matches(&i) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(Equals("taco"))) +} + +func (t *PointeeTest) WrappedReturnsFatalEmptyError() { + matchFunc := func(c interface{}) error { + return NewFatalError("") + } + + wrapped := &fakeMatcher{matchFunc, ""} + matcher := Pointee(wrapped) + + i := 17 + err := matcher.Matches(&i) + ExpectTrue(isFatal(err)) + ExpectThat(err, Error(HasSubstr("whose pointee"))) + ExpectThat(err, Error(HasSubstr("17"))) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go index 8ea2807c6..f79d0c03d 100644 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go +++ b/vendor/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go @@ -23,7 +23,7 @@ func transformDescription(m Matcher, newDesc string) Matcher { } type transformDescriptionMatcher struct { - desc string + desc string wrappedMatcher Matcher } diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/.gitignore b/vendor/github.com/smartystreets/assertions/internal/oglemock/.gitignore new file mode 100644 index 000000000..dd8fc7468 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/.gitignore @@ -0,0 +1,5 @@ +*.6 +6.out +_obj/ +_test/ +_testmain.go diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/.travis.yml b/vendor/github.com/smartystreets/assertions/internal/oglemock/.travis.yml new file mode 100644 index 000000000..b97211926 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/.travis.yml @@ -0,0 +1,4 @@ +# Cf. http://docs.travis-ci.com/user/getting-started/ +# Cf. http://docs.travis-ci.com/user/languages/go/ + +language: go diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/LICENSE b/vendor/github.com/smartystreets/assertions/internal/oglemock/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/README.md b/vendor/github.com/smartystreets/assertions/internal/oglemock/README.md new file mode 100644 index 000000000..c5cb5c06b --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/README.md @@ -0,0 +1,103 @@ +[![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/oglemock?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/oglemock) + +`oglemock` is a mocking framework for the Go programming language with the +following features: + + * An extensive and extensible set of matchers for expressing call + expectations (provided by the [oglematchers][] package). + + * Clean, readable output that tells you exactly what you need to know. + + * Style and semantics similar to [Google Mock][googlemock] and + [Google JS Test][google-js-test]. + + * Seamless integration with the [ogletest][] unit testing framework. + +It can be integrated into any testing framework (including Go's `testing` +package), but out of the box support is built in to [ogletest][] and that is the +easiest place to use it. + + +Installation +------------ + +First, make sure you have installed Go 1.0.2 or newer. See +[here][golang-install] for instructions. + +Use the following command to install `oglemock` and its dependencies, and to +keep them up to date: + + go get -u github.com/smartystreets/assertions/internal/oglemock + go get -u github.com/smartystreets/assertions/internal/oglemock/createmock + +Those commands will install the `oglemock` package itself, along with the +`createmock` tool that is used to auto-generate mock types. + + +Generating and using mock types +------------------------------- + +Automatically generating a mock implementation of an interface is easy. If you +want to mock interfaces `Bar` and `Baz` from package `foo`, simply run the +following: + + createmock foo Bar Baz + +That will print source code that can be saved to a file and used in your tests. +For example, to create a `mock_io` package containing mock implementations of +`io.Reader` and `io.Writer`: + + mkdir mock_io + createmock io Reader Writer > mock_io/mock_io.go + +The new package will be named `mock_io`, and contain types called `MockReader` +and `MockWriter`, which implement `io.Reader` and `io.Writer` respectively. + +For each generated mock type, there is a corresponding function for creating an +instance of that type given a `Controller` object (see below). For example, to +create a mock reader: + +```go +someController := [...] // See next section. +someReader := mock_io.NewMockReader(someController, "Mock file reader") +``` + +The snippet above creates a mock `io.Reader` that reports failures to +`someController`. The reader can subsequently have expectations set up and be +passed to your code under test that uses an `io.Reader`. + + +Getting ahold of a controller +----------------------------- + +[oglemock.Controller][controller-ref] is used to create mock objects, and to set +up and verify expectations for them. You can create one by calling +`NewController` with an `ErrorReporter`, which is the basic type used to +interface between `oglemock` and the testing framework within which it is being +used. + +If you are using [ogletest][] you don't need to worry about any of this, since +the `TestInfo` struct provided to your test's `SetUp` function already contains +a working `Controller` that you can use to create mock object, and you can use +the built-in `ExpectCall` function for setting expectations. (See the +[ogletest documentation][ogletest-docs] for more info.) Otherwise, you will need +to implement the simple [ErrorReporter interface][reporter-ref] for your test +environment. + + +Documentation +------------- + +For thorough documentation, including information on how to set up expectations, +see [here][oglemock-docs]. + + +[controller-ref]: http://godoc.org/github.com/smartystreets/assertions/internal/oglemock#Controller +[reporter-ref]: http://godoc.org/github.com/smartystreets/assertions/internal/oglemock#ErrorReporter +[golang-install]: http://golang.org/doc/install.html +[google-js-test]: http://code.google.com/p/google-js-test/ +[googlemock]: http://code.google.com/p/googlemock/ +[oglematchers]: https://github.com/smartystreets/assertions/internal/oglematchers +[oglemock-docs]: http://godoc.org/github.com/smartystreets/assertions/internal/oglemock +[ogletest]: https://github.com/smartystreets/assertions/internal/ogletest +[ogletest-docs]: http://godoc.org/github.com/smartystreets/assertions/internal/ogletest diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/action.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/action.go new file mode 100644 index 000000000..9fd40d81f --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/action.go @@ -0,0 +1,36 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock + +import ( + "reflect" +) + +// Action represents an action to be taken in response to a call to a mock +// method. +type Action interface { + // Set the signature of the function with which this action is being used. + // This must be called before Invoke is called. + SetSignature(signature reflect.Type) error + + // Invoke runs the specified action, given the arguments to the mock method. + // It returns zero or more values that may be treated as the return values of + // the method. If the action doesn't return any values, it may return the nil + // slice. + // + // You must call SetSignature before calling Invoke. + Invoke(methodArgs []interface{}) []interface{} +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/controller.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/controller.go new file mode 100644 index 000000000..93a1d6239 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/controller.go @@ -0,0 +1,480 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock + +import ( + "errors" + "fmt" + "log" + "math" + "reflect" + "sync" +) + +// PartialExpecation is a function that should be called exactly once with +// expected arguments or matchers in order to set up an expected method call. +// See Controller.ExpectMethodCall below. It returns an expectation that can be +// further modified (e.g. by calling WillOnce). +// +// If the arguments are of the wrong type, the function reports a fatal error +// and returns nil. +type PartialExpecation func(...interface{}) Expectation + +// Controller represents an object that implements the central logic of +// oglemock: recording and verifying expectations, responding to mock method +// calls, and so on. +type Controller interface { + // ExpectCall expresses an expectation that the method of the given name + // should be called on the supplied mock object. It returns a function that + // should be called with the expected arguments, matchers for the arguments, + // or a mix of both. + // + // fileName and lineNumber should indicate the line on which the expectation + // was made, if known. + // + // For example: + // + // mockWriter := [...] + // controller.ExpectCall(mockWriter, "Write", "foo.go", 17)(ElementsAre(0x1)) + // .WillOnce(Return(1, nil)) + // + // If the mock object doesn't have a method of the supplied name, the + // function reports a fatal error and returns nil. + ExpectCall( + o MockObject, + methodName string, + fileName string, + lineNumber int) PartialExpecation + + // Finish causes the controller to check for any unsatisfied expectations, + // and report them as errors if they exist. + // + // The controller may panic if any of its methods (including this one) are + // called after Finish is called. + Finish() + + // HandleMethodCall looks for a registered expectation matching the call of + // the given method on mock object o, invokes the appropriate action (if + // any), and returns the values returned by that action (if any). + // + // If the action returns nothing, the controller returns zero values. If + // there is no matching expectation, the controller reports an error and + // returns zero values. + // + // If the mock object doesn't have a method of the supplied name, the + // arguments are of the wrong type, or the action returns the wrong types, + // the function reports a fatal error. + // + // HandleMethodCall is exported for the sake of mock implementations, and + // should not be used directly. + HandleMethodCall( + o MockObject, + methodName string, + fileName string, + lineNumber int, + args []interface{}) []interface{} +} + +// methodMap represents a map from method name to set of expectations for that +// method. +type methodMap map[string][]*InternalExpectation + +// objectMap represents a map from mock object ID to a methodMap for that object. +type objectMap map[uintptr]methodMap + +// NewController sets up a fresh controller, without any expectations set, and +// configures the controller to use the supplied error reporter. +func NewController(reporter ErrorReporter) Controller { + return &controllerImpl{reporter, sync.RWMutex{}, objectMap{}} +} + +type controllerImpl struct { + reporter ErrorReporter + + mutex sync.RWMutex + expectationsByObject objectMap // Protected by mutex +} + +// Return the list of registered expectations for the named method of the +// supplied object, or an empty slice if none have been registered. When this +// method returns, it is guaranteed that c.expectationsByObject has an entry +// for the object. +// +// c.mutex must be held for reading. +func (c *controllerImpl) getExpectationsLocked( + o MockObject, + methodName string) []*InternalExpectation { + id := o.Oglemock_Id() + + // Look up the mock object. + expectationsByMethod, ok := c.expectationsByObject[id] + if !ok { + expectationsByMethod = methodMap{} + c.expectationsByObject[id] = expectationsByMethod + } + + result, ok := expectationsByMethod[methodName] + if !ok { + return []*InternalExpectation{} + } + + return result +} + +// Add an expectation to the list registered for the named method of the +// supplied mock object. +// +// c.mutex must be held for writing. +func (c *controllerImpl) addExpectationLocked( + o MockObject, + methodName string, + exp *InternalExpectation) { + // Get the existing list. + existing := c.getExpectationsLocked(o, methodName) + + // Store a modified list. + id := o.Oglemock_Id() + c.expectationsByObject[id][methodName] = append(existing, exp) +} + +func (c *controllerImpl) ExpectCall( + o MockObject, + methodName string, + fileName string, + lineNumber int) PartialExpecation { + // Find the signature for the requested method. + ov := reflect.ValueOf(o) + method := ov.MethodByName(methodName) + if method.Kind() == reflect.Invalid { + c.reporter.ReportFatalError( + fileName, + lineNumber, + errors.New("Unknown method: "+methodName)) + return nil + } + + partialAlreadyCalled := false // Protected by c.mutex + return func(args ...interface{}) Expectation { + c.mutex.Lock() + defer c.mutex.Unlock() + + // This function should only be called once. + if partialAlreadyCalled { + c.reporter.ReportFatalError( + fileName, + lineNumber, + errors.New("Partial expectation called more than once.")) + return nil + } + + partialAlreadyCalled = true + + // Make sure that the number of args is legal. Keep in mind that the + // method's type has an extra receiver arg. + if len(args) != method.Type().NumIn() { + c.reporter.ReportFatalError( + fileName, + lineNumber, + errors.New( + fmt.Sprintf( + "Expectation for %s given wrong number of arguments: "+ + "expected %d, got %d.", + methodName, + method.Type().NumIn(), + len(args)))) + return nil + } + + // Create an expectation and insert it into the controller's map. + exp := InternalNewExpectation( + c.reporter, + method.Type(), + args, + fileName, + lineNumber) + + c.addExpectationLocked(o, methodName, exp) + + // Return the expectation to the user. + return exp + } +} + +func (c *controllerImpl) Finish() { + c.mutex.Lock() + defer c.mutex.Unlock() + + // Check whether the minimum cardinality for each registered expectation has + // been satisfied. + for _, expectationsByMethod := range c.expectationsByObject { + for methodName, expectations := range expectationsByMethod { + for _, exp := range expectations { + exp.mutex.Lock() + defer exp.mutex.Unlock() + + minCardinality, _ := computeCardinalityLocked(exp) + if exp.NumMatches < minCardinality { + c.reporter.ReportError( + exp.FileName, + exp.LineNumber, + errors.New( + fmt.Sprintf( + "Unsatisfied expectation; expected %s to be called "+ + "at least %d times; called %d times.", + methodName, + minCardinality, + exp.NumMatches))) + } + } + } + } +} + +// expectationMatches checks the matchers for the expectation against the +// supplied arguments. +func expectationMatches(exp *InternalExpectation, args []interface{}) bool { + matchers := exp.ArgMatchers + if len(args) != len(matchers) { + panic("expectationMatches: len(args)") + } + + // Check each matcher. + for i, matcher := range matchers { + if err := matcher.Matches(args[i]); err != nil { + return false + } + } + + return true +} + +// Return the expectation that matches the supplied arguments. If there is more +// than one such expectation, the one furthest along in the list for the method +// is returned. If there is no such expectation, nil is returned. +// +// c.mutex must be held for reading. +func (c *controllerImpl) chooseExpectationLocked( + o MockObject, + methodName string, + args []interface{}) *InternalExpectation { + // Do we have any expectations for this method? + expectations := c.getExpectationsLocked(o, methodName) + if len(expectations) == 0 { + return nil + } + + for i := len(expectations) - 1; i >= 0; i-- { + if expectationMatches(expectations[i], args) { + return expectations[i] + } + } + + return nil +} + +// makeZeroReturnValues creates a []interface{} containing appropriate zero +// values for returning from the supplied method type. +func makeZeroReturnValues(signature reflect.Type) []interface{} { + result := make([]interface{}, signature.NumOut()) + + for i, _ := range result { + outType := signature.Out(i) + zeroVal := reflect.Zero(outType) + result[i] = zeroVal.Interface() + } + + return result +} + +// computeCardinality decides on the [min, max] range of the number of expected +// matches for the supplied expectations, according to the rules documented in +// expectation.go. +// +// exp.mutex must be held for reading. +func computeCardinalityLocked(exp *InternalExpectation) (min, max uint) { + // Explicit cardinality. + if exp.ExpectedNumMatches >= 0 { + min = uint(exp.ExpectedNumMatches) + max = min + return + } + + // Implicit count based on one-time actions. + if len(exp.OneTimeActions) != 0 { + min = uint(len(exp.OneTimeActions)) + max = min + + // If there is a fallback action, this is only a lower bound. + if exp.FallbackAction != nil { + max = math.MaxUint32 + } + + return + } + + // Implicit lack of restriction based on a fallback action being configured. + if exp.FallbackAction != nil { + min = 0 + max = math.MaxUint32 + return + } + + // Implicit cardinality of one. + min = 1 + max = 1 + return +} + +// chooseAction returns the action that should be invoked for the i'th match to +// the supplied expectation (counting from zero). If the implicit "return zero +// values" action should be used, it returns nil. +// +// exp.mutex must be held for reading. +func chooseActionLocked(i uint, exp *InternalExpectation) Action { + // Exhaust one-time actions first. + if i < uint(len(exp.OneTimeActions)) { + return exp.OneTimeActions[i] + } + + // Fallback action (or nil if none is configured). + return exp.FallbackAction +} + +// Find an action for the method call, updating expectation match state in the +// process. Return either an action that should be invoked or a set of zero +// values to return immediately. +// +// This is split out from HandleMethodCall in order to more easily avoid +// invoking the action with locks held. +func (c *controllerImpl) chooseActionAndUpdateExpectations( + o MockObject, + methodName string, + fileName string, + lineNumber int, + args []interface{}, +) (action Action, zeroVals []interface{}) { + c.mutex.Lock() + defer c.mutex.Unlock() + + // Find the signature for the requested method. + ov := reflect.ValueOf(o) + method := ov.MethodByName(methodName) + if method.Kind() == reflect.Invalid { + c.reporter.ReportFatalError( + fileName, + lineNumber, + errors.New("Unknown method: "+methodName), + ) + + // Should never get here in real code. + log.Println("ReportFatalError unexpectedly returned.") + return + } + + // HACK(jacobsa): Make sure we got the correct number of arguments. This will + // need to be refined when issue #5 (variadic methods) is handled. + if len(args) != method.Type().NumIn() { + c.reporter.ReportFatalError( + fileName, + lineNumber, + errors.New( + fmt.Sprintf( + "Wrong number of arguments: expected %d; got %d", + method.Type().NumIn(), + len(args), + ), + ), + ) + + // Should never get here in real code. + log.Println("ReportFatalError unexpectedly returned.") + return + } + + // Find an expectation matching this call. + expectation := c.chooseExpectationLocked(o, methodName, args) + if expectation == nil { + c.reporter.ReportError( + fileName, + lineNumber, + errors.New( + fmt.Sprintf("Unexpected call to %s with args: %v", methodName, args), + ), + ) + + zeroVals = makeZeroReturnValues(method.Type()) + return + } + + expectation.mutex.Lock() + defer expectation.mutex.Unlock() + + // Increase the number of matches recorded, and check whether we're over the + // number expected. + expectation.NumMatches++ + _, maxCardinality := computeCardinalityLocked(expectation) + if expectation.NumMatches > maxCardinality { + c.reporter.ReportError( + expectation.FileName, + expectation.LineNumber, + errors.New( + fmt.Sprintf( + "Unexpected call to %s: "+ + "expected to be called at most %d times; called %d times.", + methodName, + maxCardinality, + expectation.NumMatches, + ), + ), + ) + + zeroVals = makeZeroReturnValues(method.Type()) + return + } + + // Choose an action to invoke. If there is none, just return zero values. + action = chooseActionLocked(expectation.NumMatches-1, expectation) + if action == nil { + zeroVals = makeZeroReturnValues(method.Type()) + return + } + + // Let the action take over. + return +} + +func (c *controllerImpl) HandleMethodCall( + o MockObject, + methodName string, + fileName string, + lineNumber int, + args []interface{}, +) []interface{} { + // Figure out whether to invoke an action or return zero values. + action, zeroVals := c.chooseActionAndUpdateExpectations( + o, + methodName, + fileName, + lineNumber, + args, + ) + + if action != nil { + return action.Invoke(args) + } + + return zeroVals +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/controller_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/controller_test.go new file mode 100644 index 000000000..0ff5e5c41 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/controller_test.go @@ -0,0 +1,1249 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/oglemock" + . "github.com/smartystreets/assertions/internal/ogletest" + "reflect" +) + +//////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////// + +type errorReport struct { + fileName string + lineNumber int + err error +} + +type fakeErrorReporter struct { + errors []errorReport + fatalErrors []errorReport +} + +func (r *fakeErrorReporter) ReportError(fileName string, lineNumber int, err error) { + report := errorReport{fileName, lineNumber, err} + r.errors = append(r.errors, report) +} + +func (r *fakeErrorReporter) ReportFatalError(fileName string, lineNumber int, err error) { + report := errorReport{fileName, lineNumber, err} + r.fatalErrors = append(r.fatalErrors, report) +} + +type trivialMockObject struct { + id uintptr + desc string +} + +func (o *trivialMockObject) Oglemock_Id() uintptr { + return o.id +} + +func (o *trivialMockObject) Oglemock_Description() string { + return o.desc +} + +// Method being mocked +func (o *trivialMockObject) StringToInt(s string) int { + return 0 +} + +// Method being mocked +func (o *trivialMockObject) TwoIntsToString(i, j int) string { + return "" +} + +type ControllerTest struct { + reporter fakeErrorReporter + controller Controller + + mock1 MockObject + mock2 MockObject +} + +func (t *ControllerTest) SetUp(c *TestInfo) { + t.reporter.errors = make([]errorReport, 0) + t.reporter.fatalErrors = make([]errorReport, 0) + t.controller = NewController(&t.reporter) + + t.mock1 = &trivialMockObject{17, "taco"} + t.mock2 = &trivialMockObject{19, "burrito"} +} + +func init() { RegisterTestSuite(&ControllerTest{}) } + +//////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////// + +func (t *ControllerTest) FinishWithoutAnyEvents() { + t.controller.Finish() + ExpectEq(0, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) +} + +func (t *ControllerTest) HandleCallForUnknownObject() { + p := []byte{255} + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "taco.go", + 112, + []interface{}{p}) + + // The error should be reported immediately. + AssertEq(1, len(t.reporter.errors)) + AssertEq(0, len(t.reporter.fatalErrors)) + + ExpectEq("taco.go", t.reporter.errors[0].fileName) + ExpectEq(112, t.reporter.errors[0].lineNumber) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unexpected"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("[255]"))) + + // Finish should change nothing. + t.controller.Finish() + + ExpectEq(1, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) +} + +func (t *ControllerTest) ExpectCallForUnknownMethod() { + ExpectEq( + nil, + t.controller.ExpectCall(t.mock1, "Frobnicate", "burrito.go", 117)) + + // A fatal error should be reported immediately. + AssertEq(0, len(t.reporter.errors)) + AssertEq(1, len(t.reporter.fatalErrors)) + + report := t.reporter.fatalErrors[0] + ExpectEq("burrito.go", report.fileName) + ExpectEq(117, report.lineNumber) + ExpectThat(report.err, Error(HasSubstr("Unknown method"))) + ExpectThat(report.err, Error(HasSubstr("Frobnicate"))) +} + +func (t *ControllerTest) PartialExpectationGivenWrongNumberOfArgs() { + ExpectEq( + nil, + t.controller.ExpectCall(t.mock1, "TwoIntsToString", "burrito.go", 117)( + 17, 19, 23)) + + // A fatal error should be reported immediately. + AssertEq(0, len(t.reporter.errors)) + AssertEq(1, len(t.reporter.fatalErrors)) + + report := t.reporter.fatalErrors[0] + ExpectEq("burrito.go", report.fileName) + ExpectEq(117, report.lineNumber) + ExpectThat(report.err, Error(HasSubstr("TwoIntsToString"))) + ExpectThat(report.err, Error(HasSubstr("arguments"))) + ExpectThat(report.err, Error(HasSubstr("expected 2"))) + ExpectThat(report.err, Error(HasSubstr("got 3"))) +} + +func (t *ControllerTest) PartialExpectationCalledTwice() { + partial := t.controller.ExpectCall(t.mock1, "StringToInt", "burrito.go", 117) + AssertNe(nil, partial("taco")) + ExpectEq(nil, partial("taco")) + + // A fatal error should be reported immediately. + AssertEq(0, len(t.reporter.errors)) + AssertEq(1, len(t.reporter.fatalErrors)) + + report := t.reporter.fatalErrors[0] + ExpectEq("burrito.go", report.fileName) + ExpectEq(117, report.lineNumber) + ExpectThat(report.err, Error(HasSubstr("called more than once"))) +} + +func (t *ControllerTest) HandleMethodCallForUnknownMethod() { + ExpectEq( + nil, + t.controller.HandleMethodCall( + t.mock1, + "Frobnicate", + "burrito.go", + 117, + []interface{}{})) + + // A fatal error should be reported immediately. + AssertEq(0, len(t.reporter.errors)) + AssertEq(1, len(t.reporter.fatalErrors)) + + report := t.reporter.fatalErrors[0] + ExpectEq("burrito.go", report.fileName) + ExpectEq(117, report.lineNumber) + ExpectThat(report.err, Error(HasSubstr("Unknown method"))) + ExpectThat(report.err, Error(HasSubstr("Frobnicate"))) +} + +func (t *ControllerTest) HandleMethodCallGivenWrongNumberOfArgs() { + t.controller.ExpectCall(t.mock1, "TwoIntsToString", "", 0)(17, 19) + + ExpectEq( + nil, + t.controller.HandleMethodCall( + t.mock1, + "TwoIntsToString", + "burrito.go", + 117, + []interface{}{17, 19, 23})) + + // A fatal error should be reported immediately. + AssertEq(0, len(t.reporter.errors)) + AssertEq(1, len(t.reporter.fatalErrors)) + + report := t.reporter.fatalErrors[0] + ExpectEq("burrito.go", report.fileName) + ExpectEq(117, report.lineNumber) + ExpectThat(report.err, Error(HasSubstr("arguments"))) + ExpectThat(report.err, Error(HasSubstr("expected 2"))) + ExpectThat(report.err, Error(HasSubstr("got 3"))) +} + +func (t *ControllerTest) ExpectThenNonMatchingCall() { + // Expectation -- set up a fallback action to make it optional. + partial := t.controller.ExpectCall( + t.mock1, + "TwoIntsToString", + "burrito.go", + 117) + + exp := partial(LessThan(10), Equals(2)) + exp.WillRepeatedly(Return("")) + + // Call + t.controller.HandleMethodCall( + t.mock1, + "TwoIntsToString", + "taco.go", + 112, + []interface{}{8, 1}) + + // The error should be reported immediately. + AssertEq(1, len(t.reporter.errors)) + AssertEq(0, len(t.reporter.fatalErrors)) + + ExpectEq("taco.go", t.reporter.errors[0].fileName) + ExpectEq(112, t.reporter.errors[0].lineNumber) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unexpected"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("TwoIntsToString"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("[8 1]"))) + + // Finish should change nothing. + t.controller.Finish() + + ExpectEq(1, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) +} + +func (t *ControllerTest) ExplicitCardinalityNotSatisfied() { + // Expectation -- set up an explicit cardinality of three. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.Times(3) + + // Call twice. + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + // The error should not yet be reported. + ExpectEq(0, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) + + // Finish should cause the error to be reported. + t.controller.Finish() + + AssertEq(1, len(t.reporter.errors)) + AssertEq(0, len(t.reporter.fatalErrors)) + + ExpectEq("burrito.go", t.reporter.errors[0].fileName) + ExpectEq(117, t.reporter.errors[0].lineNumber) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unsatisfied"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at least 3 times"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 2 times"))) +} + +func (t *ControllerTest) ImplicitOneTimeActionCountNotSatisfied() { + // Expectation -- add three one-time actions. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillOnce(Return(0)) + exp.WillOnce(Return(1)) + exp.WillOnce(Return(2)) + + // Call twice. + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + // The error should not yet be reported. + ExpectEq(0, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) + + // Finish should cause the error to be reported. + t.controller.Finish() + + AssertEq(1, len(t.reporter.errors)) + AssertEq(0, len(t.reporter.fatalErrors)) + + ExpectEq("burrito.go", t.reporter.errors[0].fileName) + ExpectEq(117, t.reporter.errors[0].lineNumber) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unsatisfied"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at least 3 times"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 2 times"))) +} + +func (t *ControllerTest) ImplicitOneTimeActionLowerBoundNotSatisfied() { + // Expectation -- add three one-time actions and a fallback. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillOnce(Return(0)) + exp.WillOnce(Return(1)) + exp.WillOnce(Return(2)) + exp.WillRepeatedly(Return(3)) + + // Call twice. + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + // The error should not yet be reported. + ExpectEq(0, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) + + // Finish should cause the error to be reported. + t.controller.Finish() + + AssertEq(1, len(t.reporter.errors)) + AssertEq(0, len(t.reporter.fatalErrors)) + + ExpectEq("burrito.go", t.reporter.errors[0].fileName) + ExpectEq(117, t.reporter.errors[0].lineNumber) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unsatisfied"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at least 3 times"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 2 times"))) +} + +func (t *ControllerTest) ImplicitCardinalityOfOneNotSatisfied() { + // Expectation -- add no actions. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + partial(HasSubstr("")) + + // Don't call. + + // The error should not yet be reported. + ExpectEq(0, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) + + // Finish should cause the error to be reported. + t.controller.Finish() + + AssertEq(1, len(t.reporter.errors)) + AssertEq(0, len(t.reporter.fatalErrors)) + + ExpectEq("burrito.go", t.reporter.errors[0].fileName) + ExpectEq(117, t.reporter.errors[0].lineNumber) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unsatisfied"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at least 1 time"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 0 times"))) +} + +func (t *ControllerTest) ExplicitCardinalityOverrun() { + // Expectation -- call times(2). + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.Times(2) + + // Call three times. + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + // The error should be reported immediately. + AssertEq(1, len(t.reporter.errors)) + AssertEq(0, len(t.reporter.fatalErrors)) + + ExpectEq("burrito.go", t.reporter.errors[0].fileName) + ExpectEq(117, t.reporter.errors[0].lineNumber) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unexpected"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at most 2 times"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 3 times"))) + + // Finish should change nothing. + t.controller.Finish() + + ExpectEq(1, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) +} + +func (t *ControllerTest) ImplicitOneTimeActionCountOverrun() { + // Expectation -- add a one-time action. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillOnce(Return(0)) + + // Call twice. + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + // The error should be reported immediately. + AssertEq(1, len(t.reporter.errors)) + AssertEq(0, len(t.reporter.fatalErrors)) + + ExpectEq("burrito.go", t.reporter.errors[0].fileName) + ExpectEq(117, t.reporter.errors[0].lineNumber) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unexpected"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at most 1 time"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 2 times"))) + + // Finish should change nothing. + t.controller.Finish() + + ExpectEq(1, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) +} + +func (t *ControllerTest) ImplicitCardinalityOfOneOverrun() { + // Expectation -- don't add any actions. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + partial(HasSubstr("")) + + // Call twice. + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + // The error should be reported immediately. + AssertEq(1, len(t.reporter.errors)) + AssertEq(0, len(t.reporter.fatalErrors)) + + ExpectEq("burrito.go", t.reporter.errors[0].fileName) + ExpectEq(117, t.reporter.errors[0].lineNumber) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unexpected"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at most 1 time"))) + ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 2 times"))) + + // Finish should change nothing. + t.controller.Finish() + + ExpectEq(1, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) +} + +func (t *ControllerTest) ExplicitCardinalitySatisfied() { + // Expectation -- set up an explicit cardinality of two. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.Times(2) + + // Call twice. + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + // There should be no errors. + t.controller.Finish() + + ExpectEq(0, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) +} + +func (t *ControllerTest) ImplicitOneTimeActionCountSatisfied() { + // Expectation -- set up two one-time actions. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillOnce(Return(0)) + exp.WillOnce(Return(1)) + + // Call twice. + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + // There should be no errors. + t.controller.Finish() + + ExpectEq(0, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) +} + +func (t *ControllerTest) ImplicitOneTimeActionLowerBoundJustSatisfied() { + // Expectation -- set up two one-time actions and a fallback. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillOnce(Return(0)) + exp.WillOnce(Return(1)) + exp.WillRepeatedly(Return(2)) + + // Call twice. + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + // There should be no errors. + t.controller.Finish() + + ExpectEq(0, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) +} + +func (t *ControllerTest) ImplicitOneTimeActionLowerBoundMoreThanSatisfied() { + // Expectation -- set up two one-time actions and a fallback. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillOnce(Return(0)) + exp.WillOnce(Return(1)) + exp.WillRepeatedly(Return(2)) + + // Call four times. + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + // There should be no errors. + t.controller.Finish() + + ExpectEq(0, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) +} + +func (t *ControllerTest) FallbackActionConfiguredWithZeroCalls() { + // Expectation -- set up a fallback action. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillRepeatedly(Return(0)) + + // Don't call. + + // There should be no errors. + t.controller.Finish() + + ExpectEq(0, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) +} + +func (t *ControllerTest) FallbackActionConfiguredWithMultipleCalls() { + // Expectation -- set up a fallback action. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillRepeatedly(Return(0)) + + // Call twice. + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + // There should be no errors. + t.controller.Finish() + + ExpectEq(0, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) +} + +func (t *ControllerTest) ImplicitCardinalityOfOneSatisfied() { + // Expectation -- don't add actions. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + partial(HasSubstr("")) + + // Call once. + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + // There should be no errors. + t.controller.Finish() + + ExpectEq(0, len(t.reporter.errors)) + ExpectEq(0, len(t.reporter.fatalErrors)) +} + +func (t *ControllerTest) InvokesOneTimeActions() { + var res []interface{} + + // Expectation -- set up two one-time actions. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + suppliedArg := "" + expectedReturn := 17 + + f := func(s string) int { + suppliedArg = s + return expectedReturn + } + + exp := partial(HasSubstr("")) + exp.WillOnce(Invoke(f)) + exp.WillOnce(Return(1)) + + AssertThat(t.reporter.fatalErrors, ElementsAre()) + + // Call 0 + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{"taco"}) + + ExpectEq("taco", suppliedArg) + ExpectThat(res, ElementsAre(IdenticalTo(expectedReturn))) + + // Call 1 + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals(1)) +} + +func (t *ControllerTest) InvokesFallbackActionAfterOneTimeActions() { + var res []interface{} + + // Expectation -- set up two one-time actions and a fallback. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillOnce(Return(0)) + exp.WillOnce(Return(1)) + exp.WillRepeatedly(Return(2)) + + // Call 0 + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals(0)) + + // Call 1 + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals(1)) + + // Call 2 + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals(2)) + + // Call 3 + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals(2)) +} + +func (t *ControllerTest) InvokesFallbackActionWithoutOneTimeActions() { + var res []interface{} + + // Expectation -- set up only a fallback action. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillRepeatedly(Return(2)) + + // Call 0 + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals(2)) + + // Call 1 + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals(2)) + + // Call 2 + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals(2)) +} + +func (t *ControllerTest) ImplicitActionReturnsZeroInts() { + var res []interface{} + + // Expectation -- set up a cardinality of two. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.Times(2) + + // Call 0 + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(reflect.TypeOf(res[0]), Equals(reflect.TypeOf(int(0)))) + ExpectThat(res[0], Equals(0)) + + // Call 1 + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(reflect.TypeOf(res[0]), Equals(reflect.TypeOf(int(0)))) + ExpectThat(res[0], Equals(0)) +} + +func (t *ControllerTest) ImplicitActionReturnsEmptyStrings() { + var res []interface{} + + // Expectation -- set up a cardinality of two. + partial := t.controller.ExpectCall( + t.mock1, + "TwoIntsToString", + "burrito.go", + 117) + + exp := partial(LessThan(100), LessThan(100)) + exp.Times(2) + + // Call 0 + res = t.controller.HandleMethodCall( + t.mock1, + "TwoIntsToString", + "", + 0, + []interface{}{0, 0}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals("")) + + // Call 1 + res = t.controller.HandleMethodCall( + t.mock1, + "TwoIntsToString", + "", + 0, + []interface{}{0, 0}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals("")) +} + +func (t *ControllerTest) ExpectationsAreMatchedLastToFirst() { + var res []interface{} + + // General expectation + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillRepeatedly(Return(17)) + + // More specific expectation + partial = t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp = partial(Equals("taco")) + exp.WillRepeatedly(Return(19)) + + // Call -- the second expectation should match. + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{"taco"}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals(19)) + + // Call -- the first expectation should match because the second doesn't. + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{"burrito"}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals(17)) +} + +func (t *ControllerTest) ExpectationsAreSegregatedByMockObject() { + var res []interface{} + + // Expectation for mock1 -- return 17. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillRepeatedly(Return(17)) + + // Expectation for mock2 -- return 19. + partial = t.controller.ExpectCall( + t.mock2, + "StringToInt", + "burrito.go", + 117) + + exp = partial(HasSubstr("")) + exp.WillRepeatedly(Return(19)) + + // Call mock1. + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals(17)) + + // Call mock2. + res = t.controller.HandleMethodCall( + t.mock2, + "StringToInt", + "", + 0, + []interface{}{""}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals(19)) +} + +func (t *ControllerTest) ExpectationsAreSegregatedByMethodName() { + var res []interface{} + + // Expectation for StringToInt + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillRepeatedly(Return(17)) + + // Expectation for TwoIntsToString + partial = t.controller.ExpectCall( + t.mock1, + "TwoIntsToString", + "burrito.go", + 117) + + exp = partial(1, 2) + exp.WillRepeatedly(Return("taco")) + + // Call StringToInt. + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals(17)) + + // Call TwoIntsToString. + res = t.controller.HandleMethodCall( + t.mock1, + "TwoIntsToString", + "", + 0, + []interface{}{1, 2}) + + ExpectThat(len(res), Equals(1)) + ExpectThat(res[0], Equals("taco")) +} + +func (t *ControllerTest) ActionCallsAgainMatchingDifferentExpectation() { + var res []interface{} + + // Expectation for StringToInt + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.WillOnce(Return(17)) + + // Expectation for TwoIntsToString -- pretend we call StringToInt. + partial = t.controller.ExpectCall( + t.mock1, + "TwoIntsToString", + "burrito.go", + 117) + + exp = partial(1, 2) + exp.WillOnce(Invoke(func(int, int) string { + t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "taco.go", + 112, + []interface{}{""}) + + return "queso" + })) + + // Call TwoIntsToString. + res = t.controller.HandleMethodCall( + t.mock1, + "TwoIntsToString", + "", + 0, + []interface{}{1, 2}) + + AssertThat(res, ElementsAre("queso")) + + // Finish. Everything should be satisfied. + t.controller.Finish() + + ExpectThat(t.reporter.errors, ElementsAre()) + ExpectThat(t.reporter.fatalErrors, ElementsAre()) +} + +func (t *ControllerTest) ActionCallsAgainMatchingSameExpectation() { + var res []interface{} + + // Expectation for StringToInt -- should be called twice. The first time it + // should call itself. + partial := t.controller.ExpectCall( + t.mock1, + "StringToInt", + "burrito.go", + 117) + + exp := partial(HasSubstr("")) + exp.Times(2) + exp.WillOnce(Invoke(func(string) int { + subCallRes := t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "taco.go", + 112, + []interface{}{""}) + + return subCallRes[0].(int) + 19 + })) + + exp.WillOnce(Return(17)) + + // Call. + res = t.controller.HandleMethodCall( + t.mock1, + "StringToInt", + "", + 0, + []interface{}{""}) + + AssertThat(res, ElementsAre(17+19)) + + // Finish. Everything should be satisfied. + t.controller.Finish() + + ExpectThat(t.reporter.errors, ElementsAre()) + ExpectThat(t.reporter.fatalErrors, ElementsAre()) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock.go new file mode 100644 index 000000000..b9243a7d5 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock.go @@ -0,0 +1,226 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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. + +// createmock is used to generate source code for mock versions of interfaces +// from installed packages. +package main + +import ( + "errors" + "flag" + "fmt" + "go/build" + "io/ioutil" + "log" + "os" + "os/exec" + "path" + "regexp" + "text/template" + + // Ensure that the generate package, which is used by the generated code, is + // installed by goinstall. + _ "github.com/smartystreets/assertions/internal/oglemock/generate" +) + +// A template for generated code that is used to print the result. +const tmplStr = ` +{{$inputPkg := .InputPkg}} +{{$outputPkg := .OutputPkg}} + +package main + +import ( + {{range $identifier, $import := .Imports}} + {{$identifier}} "{{$import}}" + {{end}} +) + +func getTypeForPtr(ptr interface{}) reflect.Type { + return reflect.TypeOf(ptr).Elem() +} + +func main() { + // Reduce noise in logging output. + log.SetFlags(0) + + interfaces := []reflect.Type{ + {{range $typeName := .TypeNames}} + getTypeForPtr((*{{base $inputPkg}}.{{$typeName}})(nil)), + {{end}} + } + + err := generate.GenerateMockSource(os.Stdout, "{{$outputPkg}}", interfaces) + if err != nil { + log.Fatalf("Error generating mock source: %v", err) + } +} +` + +// A map from import identifier to package to use that identifier for, +// containing elements for each import needed by the generated code. +type importMap map[string]string + +type tmplArg struct { + InputPkg string + OutputPkg string + + // Imports needed by the generated code. + Imports importMap + + // Types to be mocked, relative to their package's name. + TypeNames []string +} + +var unknownPackageRegexp = regexp.MustCompile( + `tool\.go:\d+:\d+: cannot find package "([^"]+)"`) + +var undefinedInterfaceRegexp = regexp.MustCompile(`tool\.go:\d+: undefined: [\pL_0-9]+\.([\pL_0-9]+)`) + +// Does the 'go build' output indicate that a package wasn't found? If so, +// return the name of the package. +func findUnknownPackage(output []byte) *string { + if match := unknownPackageRegexp.FindSubmatch(output); match != nil { + res := string(match[1]) + return &res + } + + return nil +} + +// Does the 'go build' output indicate that an interface wasn't found? If so, +// return the name of the interface. +func findUndefinedInterface(output []byte) *string { + if match := undefinedInterfaceRegexp.FindSubmatch(output); match != nil { + res := string(match[1]) + return &res + } + + return nil +} + +// Split out from main so that deferred calls are executed even in the event of +// an error. +func run() error { + // Reduce noise in logging output. + log.SetFlags(0) + + // Check the command-line arguments. + flag.Parse() + + cmdLineArgs := flag.Args() + if len(cmdLineArgs) < 2 { + return errors.New("Usage: createmock [package] [interface ...]") + } + + // Create a temporary directory inside of $GOPATH to hold generated code. + buildPkg, err := build.Import("github.com/smartystreets/assertions/internal/oglemock", "", build.FindOnly) + if err != nil { + return errors.New(fmt.Sprintf("Couldn't find oglemock in $GOPATH: %v", err)) + } + + tmpDir, err := ioutil.TempDir(buildPkg.SrcRoot, "tmp-createmock-") + if err != nil { + return errors.New(fmt.Sprintf("Creating temp dir: %v", err)) + } + + defer os.RemoveAll(tmpDir) + + // Create a file to hold generated code. + codeFile, err := os.Create(path.Join(tmpDir, "tool.go")) + if err != nil { + return errors.New(fmt.Sprintf("Couldn't create a file to hold code: %v", err)) + } + + // Create an appropriate path for the built binary. + binaryPath := path.Join(tmpDir, "tool") + + // Create an appropriate template argument. + var arg tmplArg + arg.InputPkg = cmdLineArgs[0] + arg.OutputPkg = "mock_" + path.Base(arg.InputPkg) + arg.TypeNames = cmdLineArgs[1:] + + arg.Imports = make(importMap) + arg.Imports[path.Base(arg.InputPkg)] = arg.InputPkg + arg.Imports["generate"] = "github.com/smartystreets/assertions/internal/oglemock/generate" + arg.Imports["log"] = "log" + arg.Imports["os"] = "os" + arg.Imports["reflect"] = "reflect" + + // Execute the template to generate code that will itself generate the mock + // code. Write the code to the temp file. + tmpl := template.Must( + template.New("code").Funcs( + template.FuncMap{ + "base": path.Base, + }).Parse(tmplStr)) + if err := tmpl.Execute(codeFile, arg); err != nil { + return errors.New(fmt.Sprintf("Error executing template: %v", err)) + } + + codeFile.Close() + + // Attempt to build the code. + cmd := exec.Command("go", "build", "-o", binaryPath) + cmd.Dir = tmpDir + buildOutput, err := cmd.CombinedOutput() + + if err != nil { + // Did the compilation fail due to the user-specified package not being found? + if pkg := findUnknownPackage(buildOutput); pkg != nil && *pkg == arg.InputPkg { + return errors.New(fmt.Sprintf("Unknown package: %s", *pkg)) + } + + // Did the compilation fail due to an unknown interface? + if in := findUndefinedInterface(buildOutput); in != nil { + return errors.New(fmt.Sprintf("Unknown interface: %s", *in)) + } + + // Otherwise return a generic error. + return errors.New(fmt.Sprintf( + "%s\n\nError building generated code:\n\n"+ + " %v\n\nPlease report this oglemock bug.", + buildOutput, + err)) + } + + // Run the binary. + cmd = exec.Command(binaryPath) + binaryOutput, err := cmd.CombinedOutput() + + if err != nil { + return errors.New(fmt.Sprintf( + "%s\n\nError running generated code:\n\n"+ + " %v\n\n Please report this oglemock bug.", + binaryOutput, + err)) + } + + // Copy its output. + _, err = os.Stdout.Write(binaryOutput) + if err != nil { + return errors.New(fmt.Sprintf("Error copying binary output: %v", err)) + } + + return nil +} + +func main() { + if err := run(); err != nil { + fmt.Println(err.Error()) + os.Exit(1) + } +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock_test.go new file mode 100644 index 000000000..cb1bb0815 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock_test.go @@ -0,0 +1,215 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 main + +import ( + "bytes" + "flag" + "fmt" + . "github.com/smartystreets/assertions/internal/ogletest" + "go/build" + "io/ioutil" + "os" + "os/exec" + "path" + "syscall" + "testing" +) + +var dumpNew = flag.Bool("dump_new", false, "Dump new golden files.") + +//////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////// + +var tempDir string +var createmockPath string + +type CreateMockTest struct { +} + +func TestOgletest(t *testing.T) { RunTests(t) } +func init() { RegisterTestSuite(&CreateMockTest{}) } + +func (t *CreateMockTest) SetUpTestSuite() { + // Create a temporary file to hold the built createmock binary. + tempDir, err := ioutil.TempDir("", "createmock-") + if err != nil { + panic("Creating temporary directory: " + err.Error()) + } + + createmockPath = path.Join(tempDir, "createmock") + + // Build the createmock tool so that it can be used in the tests below. + cmd := exec.Command("go", "build", "-o", createmockPath, "github.com/smartystreets/assertions/internal/oglemock/createmock") + if output, err := cmd.CombinedOutput(); err != nil { + panic(fmt.Sprintf("Error building createmock: %v\n\n%s", err, output)) + } +} + +func (t *CreateMockTest) TearDownTestSuite() { + // Delete the createmock binary we built above. + os.RemoveAll(tempDir) + tempDir = "" + createmockPath = "" +} + +func (t *CreateMockTest) runGoldenTest( + caseName string, + expectedReturnCode int, + createmockArgs ...string) { + // Run createmock. + cmd := exec.Command(createmockPath, createmockArgs...) + output, err := cmd.CombinedOutput() + + // Make sure the process actually exited. + exitError, ok := err.(*exec.ExitError) + if err != nil && (!ok || !exitError.Exited()) { + panic("exec.Command.CombinedOutput: " + err.Error()) + } + + // Extract a return code. + var actualReturnCode int + if exitError != nil { + actualReturnCode = exitError.Sys().(syscall.WaitStatus).ExitStatus() + } + + // Make sure the return code is correct. + ExpectEq(expectedReturnCode, actualReturnCode) + + // Read the golden file. + goldenPath := path.Join("test_cases", "golden."+caseName) + goldenData := readFileOrDie(goldenPath) + + // Compare the two. + identical := (string(output) == string(goldenData)) + ExpectTrue(identical, "Output doesn't match for case '%s'.", caseName) + + // Write out a new golden file if requested. + if !identical && *dumpNew { + writeContentsToFileOrDie(output, goldenPath) + } +} + +// Ensure that when createmock is run with the supplied args, it produces +// output that can be compiled. +func (t *CreateMockTest) runCompilationTest(createmockArgs ...string) { + // Create a temporary directory inside of $GOPATH to hold generated code. + buildPkg, err := build.Import("github.com/smartystreets/assertions/internal/oglemock", "", build.FindOnly) + AssertEq(nil, err) + + tmpDir, err := ioutil.TempDir(buildPkg.SrcRoot, "tmp-createmock_test-") + AssertEq(nil, err) + defer os.RemoveAll(tmpDir) + + // Create a file to hold the mock code. + codeFile, err := os.Create(path.Join(tmpDir, "mock.go")) + AssertEq(nil, err) + + // Run createmock and save its output to the file created above. + stdErrBuf := new(bytes.Buffer) + + cmd := exec.Command(createmockPath, createmockArgs...) + cmd.Stdout = codeFile + cmd.Stderr = stdErrBuf + + err = cmd.Run() + AssertEq(nil, err, "createmock stderr output:\n\n%s", stdErrBuf.String()) + codeFile.Close() + + // Run 'go build' in the directory and make sure it exits with return code + // zero. + cmd = exec.Command("go", "build") + cmd.Dir = tmpDir + output, err := cmd.CombinedOutput() + + ExpectEq(nil, err, "go build output:\n\n%s", output) +} + +func writeContentsToFileOrDie(contents []byte, path string) { + if err := ioutil.WriteFile(path, contents, 0600); err != nil { + panic("ioutil.WriteFile: " + err.Error()) + } +} + +func readFileOrDie(path string) []byte { + contents, err := ioutil.ReadFile(path) + if err != nil { + panic("ioutil.ReadFile: " + err.Error()) + } + + return contents +} + +//////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////// + +func (t *CreateMockTest) NoPackage() { + t.runGoldenTest( + "no_package", + 1) +} + +func (t *CreateMockTest) NoInterfaces() { + t.runGoldenTest( + "no_interfaces", + 1, + "io") +} + +func (t *CreateMockTest) UnknownPackage() { + t.runGoldenTest( + "unknown_package", + 1, + "foo/bar", + "Reader") +} + +func (t *CreateMockTest) UnknownInterface() { + t.runGoldenTest( + "unknown_interface", + 1, + "io", + "Frobnicator") +} + +func (t *CreateMockTest) IoReaderAndWriter() { + t.runCompilationTest( + "io", + "Reader", + "Writer") +} + +func (t *CreateMockTest) OsFileInfo() { + // Note that os is also used by the code that createmock generates; there + // should be no conflict. + t.runCompilationTest( + "os", + "FileInfo") +} + +func (t *CreateMockTest) ComplicatedSamplePackage() { + t.runCompilationTest( + "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg", + "ComplicatedThing") +} + +func (t *CreateMockTest) RenamedSamplePackage() { + t.runCompilationTest( + "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg", + "SomeInterface") +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_interfaces b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_interfaces new file mode 100644 index 000000000..b70535fae --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_interfaces @@ -0,0 +1 @@ +Usage: createmock [package] [interface ...] diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_package b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_package new file mode 100644 index 000000000..b70535fae --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_package @@ -0,0 +1 @@ +Usage: createmock [package] [interface ...] diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_interface b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_interface new file mode 100644 index 000000000..c32950a17 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_interface @@ -0,0 +1 @@ +Unknown interface: Frobnicator diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_package b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_package new file mode 100644 index 000000000..d07e915d2 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_package @@ -0,0 +1 @@ +Unknown package: foo/bar diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/do_all.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/do_all.go new file mode 100644 index 000000000..c0cd3ffbd --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/do_all.go @@ -0,0 +1,53 @@ +// Copyright 2015 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock + +import ( + "fmt" + "reflect" +) + +// Create an Action that invokes the supplied actions one after another. The +// return values from the final action are used; others are ignored. +func DoAll(first Action, others ...Action) Action { + return &doAll{ + wrapped: append([]Action{first}, others...), + } +} + +type doAll struct { + wrapped []Action +} + +func (a *doAll) SetSignature(signature reflect.Type) (err error) { + for i, w := range a.wrapped { + err = w.SetSignature(signature) + if err != nil { + err = fmt.Errorf("Action %v: %v", i, err) + return + } + } + + return +} + +func (a *doAll) Invoke(methodArgs []interface{}) (rets []interface{}) { + for _, w := range a.wrapped { + rets = w.Invoke(methodArgs) + } + + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/do_all_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/do_all_test.go new file mode 100644 index 000000000..f835b66c7 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/do_all_test.go @@ -0,0 +1,90 @@ +// Copyright 2015 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock_test + +import ( + "reflect" + "testing" + + . "github.com/smartystreets/assertions/internal/oglematchers" + "github.com/smartystreets/assertions/internal/oglemock" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +func TestDoAll(t *testing.T) { RunTests(t) } + +//////////////////////////////////////////////////////////// +// Boilerplate +//////////////////////////////////////////////////////////// + +type DoAllTest struct { +} + +func init() { RegisterTestSuite(&DoAllTest{}) } + +//////////////////////////////////////////////////////////// +// Test functions +//////////////////////////////////////////////////////////// + +func (t *DoAllTest) FirstActionDoesntLikeSignature() { + f := func(a int, b string) {} + + a0 := oglemock.Invoke(func() {}) + a1 := oglemock.Invoke(f) + a2 := oglemock.Return() + + err := oglemock.DoAll(a0, a1, a2).SetSignature(reflect.TypeOf(f)) + ExpectThat(err, Error(HasSubstr("Action 0"))) + ExpectThat(err, Error(HasSubstr("func()"))) +} + +func (t *DoAllTest) LastActionDoesntLikeSignature() { + f := func(a int, b string) {} + + a0 := oglemock.Invoke(f) + a1 := oglemock.Invoke(f) + a2 := oglemock.Return(17) + + err := oglemock.DoAll(a0, a1, a2).SetSignature(reflect.TypeOf(f)) + ExpectThat(err, Error(HasSubstr("Action 2"))) + ExpectThat(err, Error(HasSubstr("1 vals; expected 0"))) +} + +func (t *DoAllTest) SingleAction() { + f := func(a int) string { return "" } + a0 := oglemock.Return("taco") + + action := oglemock.DoAll(a0) + AssertEq(nil, action.SetSignature(reflect.TypeOf(f))) + + rets := action.Invoke([]interface{}{17}) + ExpectThat(rets, ElementsAre("taco")) +} + +func (t *DoAllTest) MultipleActions() { + f := func(a int) string { return "" } + + var saved int + a0 := oglemock.SaveArg(0, &saved) + a1 := oglemock.Return("taco") + + action := oglemock.DoAll(a0, a1) + AssertEq(nil, action.SetSignature(reflect.TypeOf(f))) + + rets := action.Invoke([]interface{}{17}) + ExpectEq(17, saved) + ExpectThat(rets, ElementsAre("taco")) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/error_reporter.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/error_reporter.go new file mode 100644 index 000000000..0c3a65ee1 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/error_reporter.go @@ -0,0 +1,29 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock + +// ErrorReporter is an interface that wraps methods for reporting errors that +// should cause test failures. +type ErrorReporter interface { + // Report that some failure (e.g. an unsatisfied expectation) occurred. If + // known, fileName and lineNumber should contain information about where it + // occurred. The test may continue if the test framework supports it. + ReportError(fileName string, lineNumber int, err error) + + // Like ReportError, but the test should be halted immediately. It is assumed + // that this method does not return. + ReportFatalError(fileName string, lineNumber int, err error) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/expectation.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/expectation.go new file mode 100644 index 000000000..d18bfb8bc --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/expectation.go @@ -0,0 +1,59 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock + +// Expectation is an expectation for zero or more calls to a mock method with +// particular arguments or sets of arguments. +type Expectation interface { + // Times expresses that a matching method call should happen exactly N times. + // Times must not be called more than once, and must not be called after + // WillOnce or WillRepeatedly. + // + // The full rules for the cardinality of an expectation are as follows: + // + // 1. If an explicit cardinality is set with Times(N), then anything other + // than exactly N matching calls will cause a test failure. + // + // 2. Otherwise, if there are any one-time actions set up, then it is + // expected there will be at least that many matching calls. If there is + // not also a fallback action, then it is expected that there will be + // exactly that many. + // + // 3. Otherwise, if there is a fallback action configured, any number of + // matching calls (including zero) is allowed. + // + // 4. Otherwise, the implicit cardinality is one. + // + Times(n uint) Expectation + + // WillOnce configures a "one-time action". WillOnce can be called zero or + // more times, but must be called after any call to Times and before any call + // to WillRepeatedly. + // + // When matching method calls are made on the mock object, one-time actions + // are invoked one per matching call in the order that they were set up until + // they are exhausted. Afterward the fallback action, if any, will be used. + WillOnce(a Action) Expectation + + // WillRepeatedly configures a "fallback action". WillRepeatedly can be + // called zero or one times, and must not be called before Times or WillOnce. + // + // Once all one-time actions are exhausted (see above), the fallback action + // will be invoked for any further method calls. If WillRepeatedly is not + // called, the fallback action is implicitly an action that returns zero + // values for the method's return values. + WillRepeatedly(a Action) Expectation +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate.go new file mode 100644 index 000000000..387367ed7 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate.go @@ -0,0 +1,329 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 generate implements code generation for mock classes. This is an +// implementation detail of the createmock command, which you probably want to +// use directly instead. +package generate + +import ( + "bytes" + "errors" + "go/ast" + "go/parser" + "go/printer" + "go/token" + "io" + "reflect" + "regexp" + "text/template" +) + +const tmplStr = ` +// This file was auto-generated using createmock. See the following page for +// more information: +// +// https://github.com/smartystreets/assertions/internal/oglemock +// + +package {{.Pkg}} + +import ( + {{range $identifier, $import := .Imports}}{{$identifier}} "{{$import}}" + {{end}} +) + +{{range .Interfaces}} + {{$interfaceName := printf "Mock%s" .Name}} + {{$structName := printf "mock%s" .Name}} + + type {{$interfaceName}} interface { + {{getTypeString .}} + oglemock.MockObject + } + + type {{$structName}} struct { + controller oglemock.Controller + description string + } + + func New{{printf "Mock%s" .Name}}( + c oglemock.Controller, + desc string) {{$interfaceName}} { + return &{{$structName}}{ + controller: c, + description: desc, + } + } + + func (m *{{$structName}}) Oglemock_Id() uintptr { + return uintptr(unsafe.Pointer(m)) + } + + func (m *{{$structName}}) Oglemock_Description() string { + return m.description + } + + {{range getMethods .}} + {{$funcType := .Type}} + {{$inputTypes := getInputs $funcType}} + {{$outputTypes := getOutputs $funcType}} + + func (m *{{$structName}}) {{.Name}}({{range $i, $type := $inputTypes}}p{{$i}} {{getInputTypeString $i $funcType}}, {{end}}) ({{range $i, $type := $outputTypes}}o{{$i}} {{getTypeString $type}}, {{end}}) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "{{.Name}}", + file, + line, + []interface{}{ {{range $i, $type := $inputTypes}}p{{$i}}, {{end}} }) + + if len(retVals) != {{len $outputTypes}} { + panic(fmt.Sprintf("{{$structName}}.{{.Name}}: invalid return values: %v", retVals)) + } + + {{range $i, $type := $outputTypes}} + // o{{$i}} {{getTypeString $type}} + if retVals[{{$i}}] != nil { + o{{$i}} = retVals[{{$i}}].({{getTypeString $type}}) + } + {{end}} + + return + } + {{end}} +{{end}} +` + +type tmplArg struct { + // The package of the generated code. + Pkg string + + // Imports needed by the interfaces. + Imports importMap + + // The set of interfaces to mock. + Interfaces []reflect.Type +} + +var tmpl *template.Template + +func init() { + extraFuncs := make(template.FuncMap) + extraFuncs["getMethods"] = getMethods + extraFuncs["getInputs"] = getInputs + extraFuncs["getOutputs"] = getOutputs + extraFuncs["getInputTypeString"] = getInputTypeString + extraFuncs["getTypeString"] = getTypeString + + tmpl = template.New("code") + tmpl.Funcs(extraFuncs) + tmpl.Parse(tmplStr) +} + +func getInputTypeString(i int, ft reflect.Type) string { + numInputs := ft.NumIn() + if i == numInputs-1 && ft.IsVariadic() { + return "..." + getTypeString(ft.In(i).Elem()) + } + + return getTypeString(ft.In(i)) +} + +func getTypeString(t reflect.Type) string { + return t.String() +} + +func getMethods(it reflect.Type) []reflect.Method { + numMethods := it.NumMethod() + methods := make([]reflect.Method, numMethods) + + for i := 0; i < numMethods; i++ { + methods[i] = it.Method(i) + } + + return methods +} + +func getInputs(ft reflect.Type) []reflect.Type { + numIn := ft.NumIn() + inputs := make([]reflect.Type, numIn) + + for i := 0; i < numIn; i++ { + inputs[i] = ft.In(i) + } + + return inputs +} + +func getOutputs(ft reflect.Type) []reflect.Type { + numOut := ft.NumOut() + outputs := make([]reflect.Type, numOut) + + for i := 0; i < numOut; i++ { + outputs[i] = ft.Out(i) + } + + return outputs +} + +// A map from import identifier to package to use that identifier for, +// containing elements for each import needed by a set of mocked interfaces. +type importMap map[string]string + +var typePackageIdentifierRegexp = regexp.MustCompile(`^([\pL_0-9]+)\.[\pL_0-9]+$`) + +// Add an import for the supplied type, without recursing. +func addImportForType(imports importMap, t reflect.Type) { + // If there is no package path, this is a built-in type and we don't need an + // import. + pkgPath := t.PkgPath() + if pkgPath == "" { + return + } + + // Work around a bug in Go: + // + // http://code.google.com/p/go/issues/detail?id=2660 + // + var errorPtr *error + if t == reflect.TypeOf(errorPtr).Elem() { + return + } + + // Use the identifier that's part of the type's string representation as the + // import identifier. This means that we'll do the right thing for package + // "foo/bar" with declaration "package baz". + match := typePackageIdentifierRegexp.FindStringSubmatch(t.String()) + if match == nil { + return + } + + imports[match[1]] = pkgPath +} + +// Add all necessary imports for the type, recursing as appropriate. +func addImportsForType(imports importMap, t reflect.Type) { + // Add any import needed for the type itself. + addImportForType(imports, t) + + // Handle special cases where recursion is needed. + switch t.Kind() { + case reflect.Array, reflect.Chan, reflect.Ptr, reflect.Slice: + addImportsForType(imports, t.Elem()) + + case reflect.Func: + // Input parameters. + for i := 0; i < t.NumIn(); i++ { + addImportsForType(imports, t.In(i)) + } + + // Return values. + for i := 0; i < t.NumOut(); i++ { + addImportsForType(imports, t.Out(i)) + } + + case reflect.Map: + addImportsForType(imports, t.Key()) + addImportsForType(imports, t.Elem()) + } +} + +// Add imports for each of the methods of the interface, but not the interface +// itself. +func addImportsForInterfaceMethods(imports importMap, it reflect.Type) { + // Handle each method. + for i := 0; i < it.NumMethod(); i++ { + m := it.Method(i) + addImportsForType(imports, m.Type) + } +} + +// Given a set of interfaces, return a map from import identifier to package to +// use that identifier for, containing elements for each import needed by the +// mock versions of those interfaces. +func getImports(interfaces []reflect.Type) importMap { + imports := make(importMap) + for _, it := range interfaces { + addImportForType(imports, it) + addImportsForInterfaceMethods(imports, it) + } + + // Make sure there are imports for other types used by the generated code + // itself. + imports["fmt"] = "fmt" + imports["oglemock"] = "github.com/smartystreets/assertions/internal/oglemock" + imports["runtime"] = "runtime" + imports["unsafe"] = "unsafe" + + return imports +} + +// Given a set of interfaces to mock, write out source code for a package named +// `pkg` that contains mock implementations of those interfaces. +func GenerateMockSource(w io.Writer, pkg string, interfaces []reflect.Type) error { + // Sanity-check arguments. + if pkg == "" { + return errors.New("Package name must be non-empty.") + } + + if len(interfaces) == 0 { + return errors.New("List of interfaces must be non-empty.") + } + + // Make sure each type is indeed an interface. + for _, it := range interfaces { + if it.Kind() != reflect.Interface { + return errors.New("Invalid type: " + it.String()) + } + } + + // Create an appropriate template arg, then execute the template. Write the + // raw output into a buffer. + var arg tmplArg + arg.Pkg = pkg + arg.Imports = getImports(interfaces) + arg.Interfaces = interfaces + + buf := new(bytes.Buffer) + if err := tmpl.Execute(buf, arg); err != nil { + return err + } + + // Parse the output. + fset := token.NewFileSet() + astFile, err := parser.ParseFile(fset, pkg+".go", buf, parser.ParseComments) + if err != nil { + return errors.New("Error parsing generated code: " + err.Error()) + } + + // Sort the import lines in the AST in the same way that gofmt does. + ast.SortImports(fset, astFile) + + // Pretty-print the AST, using the same options that gofmt does by default. + cfg := &printer.Config{ + Mode: printer.UseSpaces | printer.TabIndent, + Tabwidth: 8, + } + + if err = cfg.Fprint(w, fset, astFile); err != nil { + return errors.New("Error pretty printing: " + err.Error()) + } + + return nil +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate_test.go new file mode 100644 index 000000000..2cdd1b4cf --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate_test.go @@ -0,0 +1,153 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 generate_test + +import ( + "bytes" + "flag" + . "github.com/smartystreets/assertions/internal/oglematchers" + "github.com/smartystreets/assertions/internal/oglemock/generate" + "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg" + "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg" + . "github.com/smartystreets/assertions/internal/ogletest" + "image" + "io" + "io/ioutil" + "path" + "reflect" + "testing" +) + +var dumpNew = flag.Bool("dump_new", false, "Dump new golden files.") + +//////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////// + +type GenerateTest struct { +} + +func TestOgletest(t *testing.T) { RunTests(t) } +func init() { RegisterTestSuite(&GenerateTest{}) } + +func (t *GenerateTest) runGoldenTest( + caseName string, + nilPtrs ...interface{}) { + // Make a slice of interface types to give to GenerateMockSource. + interfaces := make([]reflect.Type, len(nilPtrs)) + for i, ptr := range nilPtrs { + interfaces[i] = reflect.TypeOf(ptr).Elem() + } + + // Create the mock source. + buf := new(bytes.Buffer) + err := generate.GenerateMockSource(buf, "some_pkg", interfaces) + AssertEq(nil, err, "Error from GenerateMockSource: %v", err) + + // Read the golden file. + goldenPath := path.Join("test_cases", "golden."+caseName+".go") + goldenData := readFileOrDie(goldenPath) + + // Compare the two. + identical := (buf.String() == string(goldenData)) + ExpectTrue(identical, "Output doesn't match for case '%s'.", caseName) + + // Write out a new golden file if requested. + if !identical && *dumpNew { + writeContentsToFileOrDie(buf.Bytes(), goldenPath) + } +} + +func writeContentsToFileOrDie(contents []byte, path string) { + if err := ioutil.WriteFile(path, contents, 0600); err != nil { + panic("ioutil.WriteFile: " + err.Error()) + } +} + +func readFileOrDie(path string) []byte { + contents, err := ioutil.ReadFile(path) + if err != nil { + panic("ioutil.ReadFile: " + err.Error()) + } + + return contents +} + +//////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////// + +func (t *GenerateTest) EmptyPackageName() { + err := generate.GenerateMockSource( + new(bytes.Buffer), + "", + []reflect.Type{ + reflect.TypeOf((*io.Reader)(nil)).Elem(), + }) + + ExpectThat(err, Error(HasSubstr("Package name"))) + ExpectThat(err, Error(HasSubstr("non-empty"))) +} + +func (t *GenerateTest) EmptySetOfInterfaces() { + err := generate.GenerateMockSource( + new(bytes.Buffer), + "foo", + []reflect.Type{}) + + ExpectThat(err, Error(HasSubstr("interfaces"))) + ExpectThat(err, Error(HasSubstr("non-empty"))) +} + +func (t *GenerateTest) NonInterfaceType() { + err := generate.GenerateMockSource( + new(bytes.Buffer), + "foo", + []reflect.Type{ + reflect.TypeOf((*io.Reader)(nil)).Elem(), + reflect.TypeOf(17), + reflect.TypeOf((*io.Writer)(nil)).Elem(), + }) + + ExpectThat(err, Error(HasSubstr("Invalid type"))) +} + +func (t *GenerateTest) IoReaderAndWriter() { + // Mock io.Reader and io.Writer. + t.runGoldenTest( + "io_reader_writer", + (*io.Reader)(nil), + (*io.Writer)(nil)) +} + +func (t *GenerateTest) Image() { + t.runGoldenTest( + "image", + (*image.Image)(nil), + (*image.PalettedImage)(nil)) +} + +func (t *GenerateTest) ComplicatedPackage() { + t.runGoldenTest( + "complicated_pkg", + (*complicated_pkg.ComplicatedThing)(nil)) +} + +func (t *GenerateTest) RenamedPackage() { + t.runGoldenTest( + "renamed_pkg", + (*tony.SomeInterface)(nil)) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg/complicated_pkg.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg/complicated_pkg.go new file mode 100644 index 000000000..08844fe55 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg/complicated_pkg.go @@ -0,0 +1,40 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 complicated_pkg contains an interface with lots of interesting +// cases, for use in integration testing. +package complicated_pkg + +import ( + "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg" + "image" + "io" + "net" +) + +type Byte uint8 + +type ComplicatedThing interface { + Channels(a chan chan<- <-chan net.Conn) chan int + Pointers(a *int, b *net.Conn, c **io.Reader) (*int, error) + Functions(a func(int, image.Image) int) func(string, int) net.Conn + Maps(a map[string]*int) (map[int]*string, error) + Arrays(a [3]string) ([3]int, error) + Slices(a []string) ([]int, error) + NamedScalarType(a Byte) ([]Byte, error) + EmptyInterface(a interface{}) (interface{}, error) + RenamedPackage(a tony.SomeUint8Alias) + Variadic(a int, b ...net.Conn) int +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.complicated_pkg.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.complicated_pkg.go new file mode 100644 index 000000000..c8c9f7992 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.complicated_pkg.go @@ -0,0 +1,311 @@ +// This file was auto-generated using createmock. See the following page for +// more information: +// +// https://github.com/smartystreets/assertions/internal/oglemock +// + +package some_pkg + +import ( + fmt "fmt" + oglemock "github.com/smartystreets/assertions/internal/oglemock" + complicated_pkg "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg" + tony "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg" + image "image" + io "io" + net "net" + runtime "runtime" + unsafe "unsafe" +) + +type MockComplicatedThing interface { + complicated_pkg.ComplicatedThing + oglemock.MockObject +} + +type mockComplicatedThing struct { + controller oglemock.Controller + description string +} + +func NewMockComplicatedThing( + c oglemock.Controller, + desc string) MockComplicatedThing { + return &mockComplicatedThing{ + controller: c, + description: desc, + } +} + +func (m *mockComplicatedThing) Oglemock_Id() uintptr { + return uintptr(unsafe.Pointer(m)) +} + +func (m *mockComplicatedThing) Oglemock_Description() string { + return m.description +} + +func (m *mockComplicatedThing) Arrays(p0 [3]string) (o0 [3]int, o1 error) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "Arrays", + file, + line, + []interface{}{p0}) + + if len(retVals) != 2 { + panic(fmt.Sprintf("mockComplicatedThing.Arrays: invalid return values: %v", retVals)) + } + + // o0 [3]int + if retVals[0] != nil { + o0 = retVals[0].([3]int) + } + + // o1 error + if retVals[1] != nil { + o1 = retVals[1].(error) + } + + return +} + +func (m *mockComplicatedThing) Channels(p0 chan chan<- <-chan net.Conn) (o0 chan int) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "Channels", + file, + line, + []interface{}{p0}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockComplicatedThing.Channels: invalid return values: %v", retVals)) + } + + // o0 chan int + if retVals[0] != nil { + o0 = retVals[0].(chan int) + } + + return +} + +func (m *mockComplicatedThing) EmptyInterface(p0 interface{}) (o0 interface{}, o1 error) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "EmptyInterface", + file, + line, + []interface{}{p0}) + + if len(retVals) != 2 { + panic(fmt.Sprintf("mockComplicatedThing.EmptyInterface: invalid return values: %v", retVals)) + } + + // o0 interface {} + if retVals[0] != nil { + o0 = retVals[0].(interface{}) + } + + // o1 error + if retVals[1] != nil { + o1 = retVals[1].(error) + } + + return +} + +func (m *mockComplicatedThing) Functions(p0 func(int, image.Image) int) (o0 func(string, int) net.Conn) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "Functions", + file, + line, + []interface{}{p0}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockComplicatedThing.Functions: invalid return values: %v", retVals)) + } + + // o0 func(string, int) net.Conn + if retVals[0] != nil { + o0 = retVals[0].(func(string, int) net.Conn) + } + + return +} + +func (m *mockComplicatedThing) Maps(p0 map[string]*int) (o0 map[int]*string, o1 error) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "Maps", + file, + line, + []interface{}{p0}) + + if len(retVals) != 2 { + panic(fmt.Sprintf("mockComplicatedThing.Maps: invalid return values: %v", retVals)) + } + + // o0 map[int]*string + if retVals[0] != nil { + o0 = retVals[0].(map[int]*string) + } + + // o1 error + if retVals[1] != nil { + o1 = retVals[1].(error) + } + + return +} + +func (m *mockComplicatedThing) NamedScalarType(p0 complicated_pkg.Byte) (o0 []complicated_pkg.Byte, o1 error) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "NamedScalarType", + file, + line, + []interface{}{p0}) + + if len(retVals) != 2 { + panic(fmt.Sprintf("mockComplicatedThing.NamedScalarType: invalid return values: %v", retVals)) + } + + // o0 []complicated_pkg.Byte + if retVals[0] != nil { + o0 = retVals[0].([]complicated_pkg.Byte) + } + + // o1 error + if retVals[1] != nil { + o1 = retVals[1].(error) + } + + return +} + +func (m *mockComplicatedThing) Pointers(p0 *int, p1 *net.Conn, p2 **io.Reader) (o0 *int, o1 error) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "Pointers", + file, + line, + []interface{}{p0, p1, p2}) + + if len(retVals) != 2 { + panic(fmt.Sprintf("mockComplicatedThing.Pointers: invalid return values: %v", retVals)) + } + + // o0 *int + if retVals[0] != nil { + o0 = retVals[0].(*int) + } + + // o1 error + if retVals[1] != nil { + o1 = retVals[1].(error) + } + + return +} + +func (m *mockComplicatedThing) RenamedPackage(p0 tony.SomeUint8Alias) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "RenamedPackage", + file, + line, + []interface{}{p0}) + + if len(retVals) != 0 { + panic(fmt.Sprintf("mockComplicatedThing.RenamedPackage: invalid return values: %v", retVals)) + } + + return +} + +func (m *mockComplicatedThing) Slices(p0 []string) (o0 []int, o1 error) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "Slices", + file, + line, + []interface{}{p0}) + + if len(retVals) != 2 { + panic(fmt.Sprintf("mockComplicatedThing.Slices: invalid return values: %v", retVals)) + } + + // o0 []int + if retVals[0] != nil { + o0 = retVals[0].([]int) + } + + // o1 error + if retVals[1] != nil { + o1 = retVals[1].(error) + } + + return +} + +func (m *mockComplicatedThing) Variadic(p0 int, p1 ...net.Conn) (o0 int) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "Variadic", + file, + line, + []interface{}{p0, p1}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockComplicatedThing.Variadic: invalid return values: %v", retVals)) + } + + // o0 int + if retVals[0] != nil { + o0 = retVals[0].(int) + } + + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.image.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.image.go new file mode 100644 index 000000000..957186d0c --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.image.go @@ -0,0 +1,238 @@ +// This file was auto-generated using createmock. See the following page for +// more information: +// +// https://github.com/smartystreets/assertions/internal/oglemock +// + +package some_pkg + +import ( + fmt "fmt" + oglemock "github.com/smartystreets/assertions/internal/oglemock" + image "image" + color "image/color" + runtime "runtime" + unsafe "unsafe" +) + +type MockImage interface { + image.Image + oglemock.MockObject +} + +type mockImage struct { + controller oglemock.Controller + description string +} + +func NewMockImage( + c oglemock.Controller, + desc string) MockImage { + return &mockImage{ + controller: c, + description: desc, + } +} + +func (m *mockImage) Oglemock_Id() uintptr { + return uintptr(unsafe.Pointer(m)) +} + +func (m *mockImage) Oglemock_Description() string { + return m.description +} + +func (m *mockImage) At(p0 int, p1 int) (o0 color.Color) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "At", + file, + line, + []interface{}{p0, p1}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockImage.At: invalid return values: %v", retVals)) + } + + // o0 color.Color + if retVals[0] != nil { + o0 = retVals[0].(color.Color) + } + + return +} + +func (m *mockImage) Bounds() (o0 image.Rectangle) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "Bounds", + file, + line, + []interface{}{}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockImage.Bounds: invalid return values: %v", retVals)) + } + + // o0 image.Rectangle + if retVals[0] != nil { + o0 = retVals[0].(image.Rectangle) + } + + return +} + +func (m *mockImage) ColorModel() (o0 color.Model) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "ColorModel", + file, + line, + []interface{}{}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockImage.ColorModel: invalid return values: %v", retVals)) + } + + // o0 color.Model + if retVals[0] != nil { + o0 = retVals[0].(color.Model) + } + + return +} + +type MockPalettedImage interface { + image.PalettedImage + oglemock.MockObject +} + +type mockPalettedImage struct { + controller oglemock.Controller + description string +} + +func NewMockPalettedImage( + c oglemock.Controller, + desc string) MockPalettedImage { + return &mockPalettedImage{ + controller: c, + description: desc, + } +} + +func (m *mockPalettedImage) Oglemock_Id() uintptr { + return uintptr(unsafe.Pointer(m)) +} + +func (m *mockPalettedImage) Oglemock_Description() string { + return m.description +} + +func (m *mockPalettedImage) At(p0 int, p1 int) (o0 color.Color) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "At", + file, + line, + []interface{}{p0, p1}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockPalettedImage.At: invalid return values: %v", retVals)) + } + + // o0 color.Color + if retVals[0] != nil { + o0 = retVals[0].(color.Color) + } + + return +} + +func (m *mockPalettedImage) Bounds() (o0 image.Rectangle) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "Bounds", + file, + line, + []interface{}{}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockPalettedImage.Bounds: invalid return values: %v", retVals)) + } + + // o0 image.Rectangle + if retVals[0] != nil { + o0 = retVals[0].(image.Rectangle) + } + + return +} + +func (m *mockPalettedImage) ColorIndexAt(p0 int, p1 int) (o0 uint8) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "ColorIndexAt", + file, + line, + []interface{}{p0, p1}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockPalettedImage.ColorIndexAt: invalid return values: %v", retVals)) + } + + // o0 uint8 + if retVals[0] != nil { + o0 = retVals[0].(uint8) + } + + return +} + +func (m *mockPalettedImage) ColorModel() (o0 color.Model) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "ColorModel", + file, + line, + []interface{}{}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockPalettedImage.ColorModel: invalid return values: %v", retVals)) + } + + // o0 color.Model + if retVals[0] != nil { + o0 = retVals[0].(color.Model) + } + + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.io_reader_writer.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.io_reader_writer.go new file mode 100644 index 000000000..59cba8618 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.io_reader_writer.go @@ -0,0 +1,127 @@ +// This file was auto-generated using createmock. See the following page for +// more information: +// +// https://github.com/smartystreets/assertions/internal/oglemock +// + +package some_pkg + +import ( + fmt "fmt" + oglemock "github.com/smartystreets/assertions/internal/oglemock" + io "io" + runtime "runtime" + unsafe "unsafe" +) + +type MockReader interface { + io.Reader + oglemock.MockObject +} + +type mockReader struct { + controller oglemock.Controller + description string +} + +func NewMockReader( + c oglemock.Controller, + desc string) MockReader { + return &mockReader{ + controller: c, + description: desc, + } +} + +func (m *mockReader) Oglemock_Id() uintptr { + return uintptr(unsafe.Pointer(m)) +} + +func (m *mockReader) Oglemock_Description() string { + return m.description +} + +func (m *mockReader) Read(p0 []uint8) (o0 int, o1 error) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "Read", + file, + line, + []interface{}{p0}) + + if len(retVals) != 2 { + panic(fmt.Sprintf("mockReader.Read: invalid return values: %v", retVals)) + } + + // o0 int + if retVals[0] != nil { + o0 = retVals[0].(int) + } + + // o1 error + if retVals[1] != nil { + o1 = retVals[1].(error) + } + + return +} + +type MockWriter interface { + io.Writer + oglemock.MockObject +} + +type mockWriter struct { + controller oglemock.Controller + description string +} + +func NewMockWriter( + c oglemock.Controller, + desc string) MockWriter { + return &mockWriter{ + controller: c, + description: desc, + } +} + +func (m *mockWriter) Oglemock_Id() uintptr { + return uintptr(unsafe.Pointer(m)) +} + +func (m *mockWriter) Oglemock_Description() string { + return m.description +} + +func (m *mockWriter) Write(p0 []uint8) (o0 int, o1 error) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "Write", + file, + line, + []interface{}{p0}) + + if len(retVals) != 2 { + panic(fmt.Sprintf("mockWriter.Write: invalid return values: %v", retVals)) + } + + // o0 int + if retVals[0] != nil { + o0 = retVals[0].(int) + } + + // o1 error + if retVals[1] != nil { + o1 = retVals[1].(error) + } + + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.renamed_pkg.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.renamed_pkg.go new file mode 100644 index 000000000..9b4158faf --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.renamed_pkg.go @@ -0,0 +1,66 @@ +// This file was auto-generated using createmock. See the following page for +// more information: +// +// https://github.com/smartystreets/assertions/internal/oglemock +// + +package some_pkg + +import ( + fmt "fmt" + oglemock "github.com/smartystreets/assertions/internal/oglemock" + tony "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg" + runtime "runtime" + unsafe "unsafe" +) + +type MockSomeInterface interface { + tony.SomeInterface + oglemock.MockObject +} + +type mockSomeInterface struct { + controller oglemock.Controller + description string +} + +func NewMockSomeInterface( + c oglemock.Controller, + desc string) MockSomeInterface { + return &mockSomeInterface{ + controller: c, + description: desc, + } +} + +func (m *mockSomeInterface) Oglemock_Id() uintptr { + return uintptr(unsafe.Pointer(m)) +} + +func (m *mockSomeInterface) Oglemock_Description() string { + return m.description +} + +func (m *mockSomeInterface) DoFoo(p0 int) (o0 int) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "DoFoo", + file, + line, + []interface{}{p0}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockSomeInterface.DoFoo: invalid return values: %v", retVals)) + } + + // o0 int + if retVals[0] != nil { + o0 = retVals[0].(int) + } + + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg/renamed_pkg.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg/renamed_pkg.go new file mode 100644 index 000000000..1461cd696 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg/renamed_pkg.go @@ -0,0 +1,24 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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. + +// A package that calls itself something different than its package path would +// have you believe. +package tony + +type SomeUint8Alias uint8 + +type SomeInterface interface { + DoFoo(a int) int +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/integration_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/integration_test.go new file mode 100644 index 000000000..e72f0cbb1 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/integration_test.go @@ -0,0 +1,129 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock_test + +import ( + "errors" + . "github.com/smartystreets/assertions/internal/oglematchers" + "github.com/smartystreets/assertions/internal/oglemock" + "github.com/smartystreets/assertions/internal/oglemock/sample/mock_io" + . "github.com/smartystreets/assertions/internal/ogletest" + "path" + "runtime" +) + +//////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////// + +func getLineNumber() int { + _, _, line, _ := runtime.Caller(1) + return line +} + +type IntegrationTest struct { + reporter fakeErrorReporter + controller oglemock.Controller + + reader mock_io.MockReader +} + +func init() { RegisterTestSuite(&IntegrationTest{}) } + +func (t *IntegrationTest) SetUp(c *TestInfo) { + t.reporter.errors = make([]errorReport, 0) + t.reporter.fatalErrors = make([]errorReport, 0) + t.controller = oglemock.NewController(&t.reporter) + + t.reader = mock_io.NewMockReader(t.controller, "") +} + +//////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////// + +func (t *IntegrationTest) UnexpectedCall() { + t.reader.Read([]uint8{1, 2, 3}) + expectedLine := getLineNumber() - 1 + + // An error should have been reported. + AssertEq(1, len(t.reporter.errors), "%v", t.reporter.errors) + AssertEq(0, len(t.reporter.fatalErrors), "%v", t.reporter.fatalErrors) + + r := t.reporter.errors[0] + ExpectEq("integration_test.go", path.Base(r.fileName)) + ExpectEq(expectedLine, r.lineNumber) + ExpectThat(r.err, Error(HasSubstr("Unexpected"))) + ExpectThat(r.err, Error(HasSubstr("Read"))) + ExpectThat(r.err, Error(HasSubstr("[1 2 3]"))) +} + +func (t *IntegrationTest) ZeroValues() { + // Make an unexpected call. + n, err := t.reader.Read([]uint8{}) + + // Check the return values. + ExpectEq(0, n) + ExpectEq(nil, err) +} + +func (t *IntegrationTest) ExpectedCalls() { + // Expectations + t.controller.ExpectCall(t.reader, "Read", "", 112)(nil). + WillOnce(oglemock.Return(17, nil)). + WillOnce(oglemock.Return(19, nil)) + + t.controller.ExpectCall(t.reader, "Read", "", 112)(Not(Equals(nil))). + WillOnce(oglemock.Return(23, errors.New("taco"))) + + // Calls + var n int + var err error + + n, err = t.reader.Read(nil) + ExpectEq(17, n) + ExpectEq(nil, err) + + n, err = t.reader.Read([]byte{}) + ExpectEq(23, n) + ExpectThat(err, Error(Equals("taco"))) + + n, err = t.reader.Read(nil) + ExpectEq(19, n) + ExpectEq(nil, err) + + // Errors + AssertEq(0, len(t.reporter.errors), "%v", t.reporter.errors) + AssertEq(0, len(t.reporter.fatalErrors), "%v", t.reporter.fatalErrors) +} + +func (t *IntegrationTest) WrongTypeForReturn() { + t.controller.ExpectCall(t.reader, "Read", "foo.go", 112)(nil). + WillOnce(oglemock.Return(0, errors.New(""))). + WillOnce(oglemock.Return("taco", errors.New(""))) + + // Errors + AssertEq(0, len(t.reporter.errors), "%v", t.reporter.errors) + AssertEq(1, len(t.reporter.fatalErrors), "%v", t.reporter.fatalErrors) + + r := t.reporter.fatalErrors[0] + ExpectEq("foo.go", r.fileName) + ExpectEq(112, r.lineNumber) + ExpectThat(r.err, Error(HasSubstr("Return"))) + ExpectThat(r.err, Error(HasSubstr("arg 0"))) + ExpectThat(r.err, Error(HasSubstr("int"))) + ExpectThat(r.err, Error(HasSubstr("string"))) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation.go new file mode 100644 index 000000000..8fa8aeafa --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation.go @@ -0,0 +1,180 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock + +import ( + "errors" + "fmt" + "github.com/smartystreets/assertions/internal/oglematchers" + "reflect" + "sync" +) + +// InternalExpectation is exported for purposes of testing only. You should not +// touch it. +// +// InternalExpectation represents an expectation for zero or more calls to a +// mock method, and a set of actions to be taken when those calls are received. +type InternalExpectation struct { + // The signature of the method to which this expectation is bound, for + // checking action types. + methodSignature reflect.Type + + // An error reporter to use for reporting errors in the way that expectations + // are set. + errorReporter ErrorReporter + + // A mutex protecting mutable fields of the struct. + mutex sync.Mutex + + // Matchers that the arguments to the mock method must satisfy in order to + // match this expectation. + ArgMatchers []oglematchers.Matcher + + // The name of the file in which this expectation was expressed. + FileName string + + // The line number at which this expectation was expressed. + LineNumber int + + // The number of times this expectation should be matched, as explicitly + // listed by the user. If there was no explicit number expressed, this is -1. + ExpectedNumMatches int + + // Actions to be taken for the first N calls, one per call in order, where N + // is the length of this slice. + OneTimeActions []Action + + // An action to be taken when the one-time actions have expired, or nil if + // there is no such action. + FallbackAction Action + + // The number of times this expectation has been matched so far. + NumMatches uint +} + +// InternalNewExpectation is exported for purposes of testing only. You should +// not touch it. +func InternalNewExpectation( + reporter ErrorReporter, + methodSignature reflect.Type, + args []interface{}, + fileName string, + lineNumber int) *InternalExpectation { + result := &InternalExpectation{} + + // Store fields that can be stored directly. + result.methodSignature = methodSignature + result.errorReporter = reporter + result.FileName = fileName + result.LineNumber = lineNumber + + // Set up defaults. + result.ExpectedNumMatches = -1 + result.OneTimeActions = make([]Action, 0) + + // Set up the ArgMatchers slice, using Equals(x) for each x that is not a + // matcher itself. + result.ArgMatchers = make([]oglematchers.Matcher, len(args)) + for i, x := range args { + if matcher, ok := x.(oglematchers.Matcher); ok { + result.ArgMatchers[i] = matcher + } else { + result.ArgMatchers[i] = oglematchers.Equals(x) + } + } + + return result +} + +func (e *InternalExpectation) Times(n uint) Expectation { + e.mutex.Lock() + defer e.mutex.Unlock() + + // It is illegal to call this more than once. + if e.ExpectedNumMatches != -1 { + e.reportFatalError("Times called more than once.") + return nil + } + + // It is illegal to call this after any actions are configured. + if len(e.OneTimeActions) != 0 { + e.reportFatalError("Times called after WillOnce.") + return nil + } + + if e.FallbackAction != nil { + e.reportFatalError("Times called after WillRepeatedly.") + return nil + } + + // Make sure the number is reasonable (and will fit in an int). + if n > 1000 { + e.reportFatalError("Expectation.Times: N must be at most 1000") + return nil + } + + e.ExpectedNumMatches = int(n) + return e +} + +func (e *InternalExpectation) WillOnce(a Action) Expectation { + e.mutex.Lock() + defer e.mutex.Unlock() + + // It is illegal to call this after WillRepeatedly. + if e.FallbackAction != nil { + e.reportFatalError("WillOnce called after WillRepeatedly.") + return nil + } + + // Tell the action about the method's signature. + if err := a.SetSignature(e.methodSignature); err != nil { + e.reportFatalError(fmt.Sprintf("WillOnce given invalid action: %v", err)) + return nil + } + + // Store the action. + e.OneTimeActions = append(e.OneTimeActions, a) + + return e +} + +func (e *InternalExpectation) WillRepeatedly(a Action) Expectation { + e.mutex.Lock() + defer e.mutex.Unlock() + + // It is illegal to call this twice. + if e.FallbackAction != nil { + e.reportFatalError("WillRepeatedly called more than once.") + return nil + } + + // Tell the action about the method's signature. + if err := a.SetSignature(e.methodSignature); err != nil { + e.reportFatalError(fmt.Sprintf("WillRepeatedly given invalid action: %v", err)) + return nil + } + + // Store the action. + e.FallbackAction = a + + return e +} + +func (e *InternalExpectation) reportFatalError(errorText string) { + e.errorReporter.ReportFatalError(e.FileName, e.LineNumber, errors.New(errorText)) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation_test.go new file mode 100644 index 000000000..977fe1ac3 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation_test.go @@ -0,0 +1,265 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/oglemock" + . "github.com/smartystreets/assertions/internal/ogletest" + "reflect" +) + +//////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////// + +var emptyReturnSig reflect.Type = reflect.TypeOf(func(i int) {}) +var float64ReturnSig reflect.Type = reflect.TypeOf(func(i int) float64 { return 17.0 }) + +type InternalExpectationTest struct { + reporter fakeErrorReporter +} + +func init() { RegisterTestSuite(&InternalExpectationTest{}) } + +func (t *InternalExpectationTest) SetUp(c *TestInfo) { + t.reporter.errors = make([]errorReport, 0) + t.reporter.fatalErrors = make([]errorReport, 0) +} + +func (t *InternalExpectationTest) makeExpectation( + sig reflect.Type, + args []interface{}, + fileName string, + lineNumber int) *InternalExpectation { + return InternalNewExpectation(&t.reporter, sig, args, fileName, lineNumber) +} + +//////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////// + +func (t *InternalExpectationTest) StoresFileNameAndLineNumber() { + args := []interface{}{} + exp := t.makeExpectation(emptyReturnSig, args, "taco", 17) + + ExpectThat(exp.FileName, Equals("taco")) + ExpectThat(exp.LineNumber, Equals(17)) +} + +func (t *InternalExpectationTest) NoArgs() { + args := []interface{}{} + exp := t.makeExpectation(emptyReturnSig, args, "", 0) + + ExpectThat(len(exp.ArgMatchers), Equals(0)) +} + +func (t *InternalExpectationTest) MixOfMatchersAndNonMatchers() { + args := []interface{}{Equals(17), 19, Equals(23)} + exp := t.makeExpectation(emptyReturnSig, args, "", 0) + + // Matcher args + ExpectThat(len(exp.ArgMatchers), Equals(3)) + ExpectThat(exp.ArgMatchers[0], Equals(args[0])) + ExpectThat(exp.ArgMatchers[2], Equals(args[2])) + + // Non-matcher arg + var err error + matcher1 := exp.ArgMatchers[1] + + err = matcher1.Matches(17) + ExpectNe(nil, err) + + err = matcher1.Matches(19) + ExpectEq(nil, err) + + err = matcher1.Matches(23) + ExpectNe(nil, err) +} + +func (t *InternalExpectationTest) NoTimes() { + exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "", 0) + + ExpectThat(exp.ExpectedNumMatches, Equals(-1)) +} + +func (t *InternalExpectationTest) TimesN() { + exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "", 0) + exp.Times(17) + + ExpectThat(exp.ExpectedNumMatches, Equals(17)) +} + +func (t *InternalExpectationTest) NoActions() { + exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "", 0) + + ExpectThat(len(exp.OneTimeActions), Equals(0)) + ExpectThat(exp.FallbackAction, Equals(nil)) +} + +func (t *InternalExpectationTest) WillOnce() { + action0 := Return(17.0) + action1 := Return(19.0) + + exp := t.makeExpectation(float64ReturnSig, []interface{}{}, "", 0) + exp.WillOnce(action0).WillOnce(action1) + + ExpectThat(len(exp.OneTimeActions), Equals(2)) + ExpectThat(exp.OneTimeActions[0], Equals(action0)) + ExpectThat(exp.OneTimeActions[1], Equals(action1)) +} + +func (t *InternalExpectationTest) WillRepeatedly() { + action := Return(17.0) + + exp := t.makeExpectation(float64ReturnSig, []interface{}{}, "", 0) + exp.WillRepeatedly(action) + + ExpectThat(exp.FallbackAction, Equals(action)) +} + +func (t *InternalExpectationTest) BothKindsOfAction() { + action0 := Return(17.0) + action1 := Return(19.0) + action2 := Return(23.0) + + exp := t.makeExpectation(float64ReturnSig, []interface{}{}, "", 0) + exp.WillOnce(action0).WillOnce(action1).WillRepeatedly(action2) + + ExpectThat(len(exp.OneTimeActions), Equals(2)) + ExpectThat(exp.OneTimeActions[0], Equals(action0)) + ExpectThat(exp.OneTimeActions[1], Equals(action1)) + ExpectThat(exp.FallbackAction, Equals(action2)) +} + +func (t *InternalExpectationTest) TimesCalledWithHugeNumber() { + exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "taco.go", 112) + exp.Times(1 << 30) + + AssertEq(1, len(t.reporter.fatalErrors)) + AssertEq(0, len(t.reporter.errors)) + + r := t.reporter.fatalErrors[0] + ExpectEq("taco.go", r.fileName) + ExpectEq(112, r.lineNumber) + ExpectThat(r.err, Error(HasSubstr("Times"))) + ExpectThat(r.err, Error(HasSubstr("N must be at most 1000"))) +} + +func (t *InternalExpectationTest) TimesCalledTwice() { + exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "taco.go", 112) + exp.Times(17) + exp.Times(17) + + AssertEq(1, len(t.reporter.fatalErrors)) + AssertEq(0, len(t.reporter.errors)) + + r := t.reporter.fatalErrors[0] + ExpectEq("taco.go", r.fileName) + ExpectEq(112, r.lineNumber) + ExpectThat(r.err, Error(HasSubstr("Times"))) + ExpectThat(r.err, Error(HasSubstr("more than once"))) +} + +func (t *InternalExpectationTest) TimesCalledAfterWillOnce() { + exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "taco.go", 112) + exp.WillOnce(Return()) + exp.Times(17) + + AssertEq(1, len(t.reporter.fatalErrors)) + AssertEq(0, len(t.reporter.errors)) + + r := t.reporter.fatalErrors[0] + ExpectEq("taco.go", r.fileName) + ExpectEq(112, r.lineNumber) + ExpectThat(r.err, Error(HasSubstr("Times"))) + ExpectThat(r.err, Error(HasSubstr("after WillOnce"))) +} + +func (t *InternalExpectationTest) TimesCalledAfterWillRepeatedly() { + exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "taco.go", 112) + exp.WillRepeatedly(Return()) + exp.Times(17) + + AssertEq(1, len(t.reporter.fatalErrors)) + AssertEq(0, len(t.reporter.errors)) + + r := t.reporter.fatalErrors[0] + ExpectEq("taco.go", r.fileName) + ExpectEq(112, r.lineNumber) + ExpectThat(r.err, Error(HasSubstr("Times"))) + ExpectThat(r.err, Error(HasSubstr("after WillRepeatedly"))) +} + +func (t *InternalExpectationTest) WillOnceCalledAfterWillRepeatedly() { + exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "taco.go", 112) + exp.WillRepeatedly(Return()) + exp.WillOnce(Return()) + + AssertEq(1, len(t.reporter.fatalErrors)) + AssertEq(0, len(t.reporter.errors)) + + r := t.reporter.fatalErrors[0] + ExpectEq("taco.go", r.fileName) + ExpectEq(112, r.lineNumber) + ExpectThat(r.err, Error(HasSubstr("WillOnce"))) + ExpectThat(r.err, Error(HasSubstr("after WillRepeatedly"))) +} + +func (t *InternalExpectationTest) OneTimeActionRejectsSignature() { + exp := t.makeExpectation(float64ReturnSig, []interface{}{}, "taco.go", 112) + exp.WillOnce(Return("taco")) + + AssertEq(1, len(t.reporter.fatalErrors)) + AssertEq(0, len(t.reporter.errors)) + + r := t.reporter.fatalErrors[0] + ExpectEq("taco.go", r.fileName) + ExpectEq(112, r.lineNumber) + ExpectThat(r.err, Error(HasSubstr("arg 0"))) + ExpectThat(r.err, Error(HasSubstr("expected float64"))) + ExpectThat(r.err, Error(HasSubstr("given string"))) +} + +func (t *InternalExpectationTest) WillRepeatedlyCalledTwice() { + exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "taco.go", 112) + exp.WillRepeatedly(Return()) + exp.WillRepeatedly(Return()) + + AssertEq(1, len(t.reporter.fatalErrors)) + AssertEq(0, len(t.reporter.errors)) + + r := t.reporter.fatalErrors[0] + ExpectEq("taco.go", r.fileName) + ExpectEq(112, r.lineNumber) + ExpectThat(r.err, Error(HasSubstr("WillRepeatedly"))) + ExpectThat(r.err, Error(HasSubstr("once"))) +} + +func (t *InternalExpectationTest) FallbackActionRejectsSignature() { + exp := t.makeExpectation(float64ReturnSig, []interface{}{}, "taco.go", 112) + exp.WillRepeatedly(Return("taco")) + + AssertEq(1, len(t.reporter.fatalErrors)) + AssertEq(0, len(t.reporter.errors)) + + r := t.reporter.fatalErrors[0] + ExpectEq("taco.go", r.fileName) + ExpectEq(112, r.lineNumber) + ExpectThat(r.err, Error(HasSubstr("arg 0"))) + ExpectThat(r.err, Error(HasSubstr("expected float64"))) + ExpectThat(r.err, Error(HasSubstr("given string"))) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/invoke.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/invoke.go new file mode 100644 index 000000000..07630cbbb --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/invoke.go @@ -0,0 +1,73 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock + +import ( + "errors" + "fmt" + "reflect" +) + +// Create an Action that invokes the supplied function, returning whatever it +// returns. The signature of the function must match that of the mocked method +// exactly. +func Invoke(f interface{}) Action { + // Make sure f is a function. + fv := reflect.ValueOf(f) + fk := fv.Kind() + + if fk != reflect.Func { + desc := "" + if fk != reflect.Invalid { + desc = fv.Type().String() + } + + panic(fmt.Sprintf("Invoke: expected function, got %s", desc)) + } + + return &invokeAction{fv} +} + +type invokeAction struct { + f reflect.Value +} + +func (a *invokeAction) SetSignature(signature reflect.Type) error { + // The signature must match exactly. + ft := a.f.Type() + if ft != signature { + return errors.New(fmt.Sprintf("Invoke: expected %v, got %v", signature, ft)) + } + + return nil +} + +func (a *invokeAction) Invoke(vals []interface{}) []interface{} { + // Create a slice of args for the function. + in := make([]reflect.Value, len(vals)) + for i, x := range vals { + in[i] = reflect.ValueOf(x) + } + + // Call the function and return its return values. + out := a.f.Call(in) + result := make([]interface{}, len(out)) + for i, v := range out { + result[i] = v.Interface() + } + + return result +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/invoke_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/invoke_test.go new file mode 100644 index 000000000..9e1478ba8 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/invoke_test.go @@ -0,0 +1,110 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + "github.com/smartystreets/assertions/internal/oglemock" + . "github.com/smartystreets/assertions/internal/ogletest" + "reflect" +) + +//////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////// + +type InvokeTest struct { +} + +func init() { RegisterTestSuite(&InvokeTest{}) } + +//////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////// + +func (t *InvokeTest) ArgumentIsNil() { + f := func() { oglemock.Invoke(nil) } + ExpectThat(f, Panics(MatchesRegexp("Invoke.*function.*"))) +} + +func (t *InvokeTest) ArgumentIsInt() { + f := func() { oglemock.Invoke(17) } + ExpectThat(f, Panics(MatchesRegexp("Invoke.*function.*int"))) +} + +func (t *InvokeTest) FunctionHasOneWrongInputType() { + f := func(a int, b int32, c string) {} + g := func(a int, b int, c string) {} + + err := oglemock.Invoke(f).SetSignature(reflect.TypeOf(g)) + ExpectThat(err, Error(HasSubstr("func(int, int32, string)"))) + ExpectThat(err, Error(HasSubstr("func(int, int, string)"))) +} + +func (t *InvokeTest) FunctionHasOneWrongOutputType() { + f := func() (int32, string) { return 0, "" } + g := func() (int, string) { return 0, "" } + + err := oglemock.Invoke(f).SetSignature(reflect.TypeOf(g)) + ExpectThat(err, Error(HasSubstr("func() (int32, string)"))) + ExpectThat(err, Error(HasSubstr("func() (int, string)"))) +} + +func (t *InvokeTest) CallsFunction() { + var actualArg0, actualArg1 interface{} + + f := func(a uintptr, b int8) { + actualArg0 = a + actualArg1 = b + } + + a := oglemock.Invoke(f) + + // Set signature. + AssertEq(nil, a.SetSignature(reflect.TypeOf(f))) + + // Call the action. + expectedArg0 := uintptr(17) + expectedArg1 := int8(-7) + + a.Invoke([]interface{}{expectedArg0, expectedArg1}) + + ExpectThat(actualArg0, IdenticalTo(expectedArg0)) + ExpectThat(actualArg1, IdenticalTo(expectedArg1)) +} + +func (t *InvokeTest) ReturnsFunctionResult() { + expectedReturn0 := int16(3) + expectedReturn1 := "taco" + + f := func() (int16, string) { + return expectedReturn0, expectedReturn1 + } + + a := oglemock.Invoke(f) + + // Set signature. + AssertEq(nil, a.SetSignature(reflect.TypeOf(f))) + + // Call the action. + res := a.Invoke([]interface{}{}) + + ExpectThat( + res, + ElementsAre( + IdenticalTo(expectedReturn0), + IdenticalTo(expectedReturn1))) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/mock_object.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/mock_object.go new file mode 100644 index 000000000..de995efc6 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/mock_object.go @@ -0,0 +1,30 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock + +// MockObject is an interface that mock object implementations must conform to +// in order to register expectations with and hand off calls to a +// MockController. Users should not interact with this interface directly. +type MockObject interface { + // Oglemock_Id returns an identifier for the mock object that is guaranteed + // to be unique within the process at least until the mock object is garbage + // collected. + Oglemock_Id() uintptr + + // Oglemock_Description returns a description of the mock object that may be + // helpful in test failure messages. + Oglemock_Description() string +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/return.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/return.go new file mode 100644 index 000000000..c66d248f4 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/return.go @@ -0,0 +1,251 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock + +import ( + "errors" + "fmt" + "math" + "reflect" +) + +var intType = reflect.TypeOf(int(0)) +var float64Type = reflect.TypeOf(float64(0)) +var complex128Type = reflect.TypeOf(complex128(0)) + +// Return creates an Action that returns the values passed to Return as +// arguments, after suitable legal type conversions. The following rules apply. +// Given an argument x to Return and a corresponding type T in the method's +// signature, at least one of the following must hold: +// +// * x is assignable to T. (See "Assignability" in the language spec.) Note +// that this in particular applies that x may be a type that implements an +// interface T. It also implies that the nil literal can be used if T is a +// pointer, function, interface, slice, channel, or map type. +// +// * T is any numeric type, and x is an int that is in-range for that type. +// This facilities using raw integer constants: Return(17). +// +// * T is a floating-point or complex number type, and x is a float64. This +// facilities using raw floating-point constants: Return(17.5). +// +// * T is a complex number type, and x is a complex128. This facilities using +// raw complex constants: Return(17+2i). +// +func Return(vals ...interface{}) Action { + return &returnAction{vals, nil} +} + +type returnAction struct { + returnVals []interface{} + signature reflect.Type +} + +func (a *returnAction) Invoke(vals []interface{}) []interface{} { + if a.signature == nil { + panic("You must first call SetSignature with a valid signature.") + } + + res, err := a.buildInvokeResult(a.signature) + if err != nil { + panic(err) + } + + return res +} + +func (a *returnAction) SetSignature(signature reflect.Type) error { + if _, err := a.buildInvokeResult(signature); err != nil { + return err + } + + a.signature = signature + return nil +} + +// A version of Invoke that does error checking, used by both public methods. +func (a *returnAction) buildInvokeResult( + sig reflect.Type) (res []interface{}, err error) { + // Check the length of the return value. + numOut := sig.NumOut() + numVals := len(a.returnVals) + + if numOut != numVals { + err = errors.New( + fmt.Sprintf("Return given %d vals; expected %d.", numVals, numOut)) + return + } + + // Attempt to coerce each return value. + res = make([]interface{}, numOut) + + for i, val := range a.returnVals { + resType := sig.Out(i) + res[i], err = a.coerce(val, resType) + + if err != nil { + res = nil + err = errors.New(fmt.Sprintf("Return: arg %d: %v", i, err)) + return + } + } + + return +} + +func (a *returnAction) coerce(x interface{}, t reflect.Type) (interface{}, error) { + xv := reflect.ValueOf(x) + rv := reflect.New(t).Elem() + + // Special case: the language spec says that the predeclared identifier nil + // is assignable to pointers, functions, interface, slices, channels, and map + // types. However, reflect.ValueOf(nil) returns an invalid value that will + // not cooperate below. So handle invalid values here, assuming that they + // resulted from Return(nil). + if !xv.IsValid() { + switch t.Kind() { + case reflect.Ptr, reflect.Func, reflect.Interface, reflect.Chan, reflect.Slice, reflect.Map, reflect.UnsafePointer: + return rv.Interface(), nil + } + + return nil, errors.New(fmt.Sprintf("expected %v, given ", t)) + } + + // If x is assignable to type t, let the reflect package do the heavy + // lifting. + if reflect.TypeOf(x).AssignableTo(t) { + rv.Set(xv) + return rv.Interface(), nil + } + + // Handle numeric types as described in the documentation on Return. + switch { + case xv.Type() == intType && a.isNumeric(t): + return a.coerceInt(xv.Int(), t) + + case xv.Type() == float64Type && (a.isFloatingPoint(t) || a.isComplex(t)): + return a.coerceFloat(xv.Float(), t) + + case xv.Type() == complex128Type && a.isComplex(t): + return a.coerceComplex(xv.Complex(), t) + } + + // The value wasn't of a legal type. + return nil, errors.New(fmt.Sprintf("expected %v, given %v", t, xv.Type())) +} + +func (a *returnAction) isNumeric(t reflect.Type) bool { + return (t.Kind() >= reflect.Int && t.Kind() <= reflect.Uint64) || + a.isFloatingPoint(t) || + a.isComplex(t) +} + +func (a *returnAction) isFloatingPoint(t reflect.Type) bool { + return t.Kind() == reflect.Float32 || t.Kind() == reflect.Float64 +} + +func (a *returnAction) isComplex(t reflect.Type) bool { + return t.Kind() == reflect.Complex64 || t.Kind() == reflect.Complex128 +} + +func (a *returnAction) coerceInt(x int64, t reflect.Type) (interface{}, error) { + k := t.Kind() + + // Floating point and complex numbers: promote appropriately. + if a.isFloatingPoint(t) || a.isComplex(t) { + return a.coerceFloat(float64(x), t) + } + + // Integers: range check. + var min, max int64 + unsigned := false + + switch k { + case reflect.Int8: + min = math.MinInt8 + max = math.MaxInt8 + + case reflect.Int16: + min = math.MinInt16 + max = math.MaxInt16 + + case reflect.Int32: + min = math.MinInt32 + max = math.MaxInt32 + + case reflect.Int64: + min = math.MinInt64 + max = math.MaxInt64 + + case reflect.Uint: + unsigned = true + min = 0 + max = math.MaxUint32 + + case reflect.Uint8: + unsigned = true + min = 0 + max = math.MaxUint8 + + case reflect.Uint16: + unsigned = true + min = 0 + max = math.MaxUint16 + + case reflect.Uint32: + unsigned = true + min = 0 + max = math.MaxUint32 + + case reflect.Uint64: + unsigned = true + min = 0 + max = math.MaxInt64 + + default: + panic(fmt.Sprintf("Unexpected type: %v", t)) + } + + if x < min || x > max { + return nil, errors.New("int value out of range") + } + + rv := reflect.New(t).Elem() + if unsigned { + rv.SetUint(uint64(x)) + } else { + rv.SetInt(x) + } + + return rv.Interface(), nil +} + +func (a *returnAction) coerceFloat(x float64, t reflect.Type) (interface{}, error) { + // Promote complex numbers. + if a.isComplex(t) { + return a.coerceComplex(complex(x, 0), t) + } + + rv := reflect.New(t).Elem() + rv.SetFloat(x) + return rv.Interface(), nil +} + +func (a *returnAction) coerceComplex(x complex128, t reflect.Type) (interface{}, error) { + rv := reflect.New(t).Elem() + rv.SetComplex(x) + return rv.Interface(), nil +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/return_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/return_test.go new file mode 100644 index 000000000..f1794bd76 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/return_test.go @@ -0,0 +1,978 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock_test + +import ( + "bytes" + . "github.com/smartystreets/assertions/internal/oglematchers" + "github.com/smartystreets/assertions/internal/oglemock" + . "github.com/smartystreets/assertions/internal/ogletest" + "io" + "math" + "reflect" + "testing" + "unsafe" +) + +//////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////// + +var someInt int = 17 + +type ReturnTest struct { +} + +func init() { RegisterTestSuite(&ReturnTest{}) } +func TestOgletest(t *testing.T) { RunTests(t) } + +type returnTestCase struct { + suppliedVal interface{} + expectedVal interface{} + expectedSetSignatureErrorSubstring string +} + +func (t *ReturnTest) runTestCases(signature reflect.Type, cases []returnTestCase) { + for i, c := range cases { + a := oglemock.Return(c.suppliedVal) + + // SetSignature + err := a.SetSignature(signature) + if c.expectedSetSignatureErrorSubstring == "" { + ExpectEq(nil, err, "Test case %d: %v", i, c) + + if err != nil { + continue + } + } else { + ExpectThat(err, Error(HasSubstr(c.expectedSetSignatureErrorSubstring)), + "Test case %d: %v", i, c) + continue + } + + // Invoke + res := a.Invoke([]interface{}{}) + AssertThat(res, ElementsAre(Any())) + ExpectThat(res[0], IdenticalTo(c.expectedVal), "Test case %d: %v", i, c) + } +} + +//////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////// + +func (t *ReturnTest) SetSignatureNotCalled() { + a := oglemock.Return() + f := func() { a.Invoke([]interface{}{}) } + ExpectThat(f, Panics(MatchesRegexp("first call SetSignature"))) +} + +func (t *ReturnTest) NoReturnValues() { + sig := reflect.TypeOf(func() {}) + var a oglemock.Action + var err error + var vals []interface{} + + // No values. + a = oglemock.Return() + err = a.SetSignature(sig) + AssertEq(nil, err) + + vals = a.Invoke([]interface{}{}) + ExpectThat(vals, ElementsAre()) + + // One value. + a = oglemock.Return(17) + err = a.SetSignature(sig) + ExpectThat(err, Error(HasSubstr("given 1 val"))) + ExpectThat(err, Error(HasSubstr("expected 0"))) + + // Two values. + a = oglemock.Return(17, 19) + err = a.SetSignature(sig) + ExpectThat(err, Error(HasSubstr("given 2 vals"))) + ExpectThat(err, Error(HasSubstr("expected 0"))) +} + +func (t *ReturnTest) MultipleReturnValues() { + sig := reflect.TypeOf(func() (int, string) { return 0, "" }) + var a oglemock.Action + var err error + var vals []interface{} + + // No values. + a = oglemock.Return() + err = a.SetSignature(sig) + ExpectThat(err, Error(HasSubstr("given 0 vals"))) + ExpectThat(err, Error(HasSubstr("expected 2"))) + + // One value. + a = oglemock.Return(17) + err = a.SetSignature(sig) + ExpectThat(err, Error(HasSubstr("given 1 val"))) + ExpectThat(err, Error(HasSubstr("expected 2"))) + + // Two values. + a = oglemock.Return(17, "taco") + err = a.SetSignature(sig) + AssertEq(nil, err) + + vals = a.Invoke([]interface{}{}) + ExpectThat(vals, ElementsAre(IdenticalTo(int(17)), "taco")) +} + +func (t *ReturnTest) Bool() { + sig := reflect.TypeOf(func() bool { return false }) + cases := []returnTestCase{ + // Identical types. + {bool(true), bool(true), ""}, + {bool(false), bool(false), ""}, + + // Wrong types. + {nil, nil, "given "}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Int() { + sig := reflect.TypeOf(func() int { return 0 }) + cases := []returnTestCase{ + // Identical types. + {int(math.MinInt32), int(math.MinInt32), ""}, + {int(math.MaxInt32), int(math.MaxInt32), ""}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Int8() { + sig := reflect.TypeOf(func() int8 { return 0 }) + cases := []returnTestCase{ + // Identical types. + {int8(math.MinInt8), int8(math.MinInt8), ""}, + {int8(math.MaxInt8), int8(math.MaxInt8), ""}, + + // In-range ints. + {int(math.MinInt8), int8(math.MinInt8), ""}, + {int(math.MaxInt8), int8(math.MaxInt8), ""}, + + // Out of range ints. + {int(math.MinInt8 - 1), nil, "out of range"}, + {int(math.MaxInt8 + 1), nil, "out of range"}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Int16() { + sig := reflect.TypeOf(func() int16 { return 0 }) + cases := []returnTestCase{ + // Identical types. + {int16(math.MinInt16), int16(math.MinInt16), ""}, + {int16(math.MaxInt16), int16(math.MaxInt16), ""}, + + // In-range ints. + {int(math.MinInt16), int16(math.MinInt16), ""}, + {int(math.MaxInt16), int16(math.MaxInt16), ""}, + + // Out of range ints. + {int(math.MinInt16 - 1), nil, "out of range"}, + {int(math.MaxInt16 + 1), nil, "out of range"}, + + // Wrong types. + {nil, nil, "given "}, + {int8(1), nil, "given int8"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Int32() { + sig := reflect.TypeOf(func() int32 { return 0 }) + cases := []returnTestCase{ + // Identical types. + {int32(math.MinInt32), int32(math.MinInt32), ""}, + {int32(math.MaxInt32), int32(math.MaxInt32), ""}, + + // Aliased version of type. + {rune(17), int32(17), ""}, + + // In-range ints. + {int(math.MinInt32), int32(math.MinInt32), ""}, + {int(math.MaxInt32), int32(math.MaxInt32), ""}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Rune() { + sig := reflect.TypeOf(func() rune { return 0 }) + cases := []returnTestCase{ + // Identical types. + {rune(math.MinInt32), rune(math.MinInt32), ""}, + {rune(math.MaxInt32), rune(math.MaxInt32), ""}, + + // Aliased version of type. + {int32(17), rune(17), ""}, + + // In-range ints. + {int(math.MinInt32), rune(math.MinInt32), ""}, + {int(math.MaxInt32), rune(math.MaxInt32), ""}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Int64() { + sig := reflect.TypeOf(func() int64 { return 0 }) + cases := []returnTestCase{ + // Identical types. + {int64(math.MinInt64), int64(math.MinInt64), ""}, + {int64(math.MaxInt64), int64(math.MaxInt64), ""}, + + // In-range ints. + {int(math.MinInt32), int64(math.MinInt32), ""}, + {int(math.MaxInt32), int64(math.MaxInt32), ""}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Uint() { + sig := reflect.TypeOf(func() uint { return 0 }) + cases := []returnTestCase{ + // Identical types. + {uint(0), uint(0), ""}, + {uint(math.MaxUint32), uint(math.MaxUint32), ""}, + + // In-range ints. + {int(0), uint(0), ""}, + {int(math.MaxInt32), uint(math.MaxInt32), ""}, + + // Out of range ints. + {int(-1), nil, "out of range"}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Uint8() { + sig := reflect.TypeOf(func() uint8 { return 0 }) + cases := []returnTestCase{ + // Identical types. + {uint8(0), uint8(0), ""}, + {uint8(math.MaxUint8), uint8(math.MaxUint8), ""}, + + // Aliased version of type. + {byte(17), uint8(17), ""}, + + // In-range ints. + {int(0), uint8(0), ""}, + {int(math.MaxUint8), uint8(math.MaxUint8), ""}, + + // Out of range ints. + {int(-1), nil, "out of range"}, + {int(math.MaxUint8 + 1), nil, "out of range"}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Byte() { + sig := reflect.TypeOf(func() byte { return 0 }) + cases := []returnTestCase{ + // Identical types. + {byte(0), byte(0), ""}, + {byte(math.MaxUint8), byte(math.MaxUint8), ""}, + + // Aliased version of type. + {uint8(17), byte(17), ""}, + + // In-range ints. + {int(0), byte(0), ""}, + {int(math.MaxUint8), byte(math.MaxUint8), ""}, + + // Out of range ints. + {int(-1), nil, "out of range"}, + {int(math.MaxUint8 + 1), nil, "out of range"}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Uint16() { + sig := reflect.TypeOf(func() uint16 { return 0 }) + cases := []returnTestCase{ + // Identical types. + {uint16(0), uint16(0), ""}, + {uint16(math.MaxUint16), uint16(math.MaxUint16), ""}, + + // In-range ints. + {int(0), uint16(0), ""}, + {int(math.MaxUint16), uint16(math.MaxUint16), ""}, + + // Out of range ints. + {int(-1), nil, "out of range"}, + {int(math.MaxUint16 + 1), nil, "out of range"}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Uint32() { + sig := reflect.TypeOf(func() uint32 { return 0 }) + cases := []returnTestCase{ + // Identical types. + {uint32(0), uint32(0), ""}, + {uint32(math.MaxUint32), uint32(math.MaxUint32), ""}, + + // In-range ints. + {int(0), uint32(0), ""}, + {int(math.MaxInt32), uint32(math.MaxInt32), ""}, + + // Out of range ints. + {int(-1), nil, "out of range"}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Uint64() { + sig := reflect.TypeOf(func() uint64 { return 0 }) + cases := []returnTestCase{ + // Identical types. + {uint64(0), uint64(0), ""}, + {uint64(math.MaxUint64), uint64(math.MaxUint64), ""}, + + // In-range ints. + {int(0), uint64(0), ""}, + {int(math.MaxInt32), uint64(math.MaxInt32), ""}, + + // Out of range ints. + {int(-1), nil, "out of range"}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Uintptr() { + sig := reflect.TypeOf(func() uintptr { return 0 }) + cases := []returnTestCase{ + // Identical types. + {uintptr(17), uintptr(17), ""}, + + // Wrong types. + {nil, nil, "given "}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Float32() { + sig := reflect.TypeOf(func() float32 { return 0 }) + cases := []returnTestCase{ + // Identical types. + {float32(-17.5), float32(-17.5), ""}, + {float32(17.5), float32(17.5), ""}, + + // In-range ints. + {int(-17), float32(-17), ""}, + {int(17), float32(17), ""}, + + // Float64s + {float64(-17.5), float32(-17.5), ""}, + {float64(17.5), float32(17.5), ""}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Float64() { + sig := reflect.TypeOf(func() float64 { return 0 }) + cases := []returnTestCase{ + // Identical types. + {float64(-17.5), float64(-17.5), ""}, + {float64(17.5), float64(17.5), ""}, + + // In-range ints. + {int(-17), float64(-17), ""}, + {int(17), float64(17), ""}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float32(1), nil, "given float32"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Complex64() { + sig := reflect.TypeOf(func() complex64 { return 0 }) + cases := []returnTestCase{ + // Identical types. + {complex64(-17.5 - 1i), complex64(-17.5 - 1i), ""}, + {complex64(17.5 + 1i), complex64(17.5 + 1i), ""}, + + // In-range ints. + {int(-17), complex64(-17), ""}, + {int(17), complex64(17), ""}, + + // Float64s + {float64(-17.5), complex64(-17.5), ""}, + {float64(17.5), complex64(17.5), ""}, + + // Complex128s + {complex128(-17.5 - 1i), complex64(-17.5 - 1i), ""}, + {complex128(17.5 + 1i), complex64(17.5 + 1i), ""}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float32(1), nil, "given float32"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Complex128() { + sig := reflect.TypeOf(func() complex128 { return 0 }) + cases := []returnTestCase{ + // Identical types. + {complex128(-17.5 - 1i), complex128(-17.5 - 1i), ""}, + {complex128(17.5 + 1i), complex128(17.5 + 1i), ""}, + + // In-range ints. + {int(-17), complex128(-17), ""}, + {int(17), complex128(17), ""}, + + // Float64s + {float64(-17.5), complex128(-17.5), ""}, + {float64(17.5), complex128(17.5), ""}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float32(1), nil, "given float32"}, + {complex64(1), nil, "given complex64"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) ArrayOfInt() { + type namedElemType int + + sig := reflect.TypeOf(func() [2]int { return [2]int{0, 0} }) + cases := []returnTestCase{ + // Identical types. + {[2]int{19, 23}, [2]int{19, 23}, ""}, + + // Wrong length. + {[1]int{17}, nil, "given [1]int"}, + + // Wrong element types. + {[2]namedElemType{19, 23}, nil, "given [2]oglemock_test.namedElemType"}, + {[2]string{"", ""}, nil, "given [2]string"}, + + // Wrong types. + {nil, nil, "given "}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) ChanOfInt() { + type namedElemType int + someChan := make(chan int) + + sig := reflect.TypeOf(func() chan int { return nil }) + cases := []returnTestCase{ + // Identical types. + {someChan, someChan, ""}, + + // Nil values. + {(interface{})(nil), (chan int)(nil), ""}, + {(chan int)(nil), (chan int)(nil), ""}, + + // Wrong element types. + {make(chan string), nil, "given chan string"}, + {make(chan namedElemType), nil, "given chan oglemock_test.namedElemType"}, + + // Wrong direction + {(<-chan int)(someChan), nil, "given <-chan int"}, + {(chan<- int)(someChan), nil, "given chan<- int"}, + + // Wrong types. + {(func())(nil), nil, "given func()"}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) SendChanOfInt() { + type namedElemType int + + someChan := make(chan<- int) + someBidirectionalChannel := make(chan int) + + sig := reflect.TypeOf(func() chan<- int { return nil }) + cases := []returnTestCase{ + // Identical types. + {someChan, someChan, ""}, + + // Nil values. + {(interface{})(nil), (chan<- int)(nil), ""}, + {(chan int)(nil), (chan<- int)(nil), ""}, + + // Bidirectional channel + {someBidirectionalChannel, (chan<- int)(someBidirectionalChannel), ""}, + + // Wrong direction + {(<-chan int)(someBidirectionalChannel), nil, "given <-chan int"}, + + // Wrong element types. + {make(chan string), nil, "given chan string"}, + {make(chan namedElemType), nil, "given chan oglemock_test.namedElemType"}, + + // Wrong types. + {(func())(nil), nil, "given func()"}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) RecvChanOfInt() { + type namedElemType int + + someChan := make(<-chan int) + someBidirectionalChannel := make(chan int) + + sig := reflect.TypeOf(func() <-chan int { return nil }) + cases := []returnTestCase{ + // Identical types. + {someChan, someChan, ""}, + + // Nil values. + {(interface{})(nil), (<-chan int)(nil), ""}, + {(chan int)(nil), (<-chan int)(nil), ""}, + + // Bidirectional channel + {someBidirectionalChannel, (<-chan int)(someBidirectionalChannel), ""}, + + // Wrong direction + {(chan<- int)(someBidirectionalChannel), nil, "given chan<- int"}, + + // Wrong element types. + {make(chan string), nil, "given chan string"}, + {make(chan namedElemType), nil, "given chan oglemock_test.namedElemType"}, + + // Wrong types. + {(func())(nil), nil, "given func()"}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Func() { + someFunc := func(string) int { return 0 } + + sig := reflect.TypeOf(func() func(string) int { return nil }) + cases := []returnTestCase{ + // Identical types. + {someFunc, someFunc, ""}, + + // Nil values. + {(interface{})(nil), (func(string) int)(nil), ""}, + {(func(string) int)(nil), (func(string) int)(nil), ""}, + + // Wrong parameter and return types. + {func(int) int { return 0 }, nil, "given func(int) int"}, + {func(string) string { return "" }, nil, "given func(string) string"}, + + // Wrong types. + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {(chan int)(nil), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Interface() { + sig := reflect.TypeOf(func() io.Reader { return nil }) + + someBuffer := new(bytes.Buffer) + + cases := []returnTestCase{ + // Type that implements interface. + {someBuffer, someBuffer, ""}, + + // Nil value. + {(interface{})(nil), (interface{})(nil), ""}, + + // Non-implementing types. + {(chan int)(nil), nil, "given chan int"}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) MapFromStringToInt() { + type namedElemType string + + someMap := make(map[string]int) + + sig := reflect.TypeOf(func() map[string]int { return nil }) + cases := []returnTestCase{ + // Identical types. + {someMap, someMap, ""}, + + // Nil values. + {(interface{})(nil), (map[string]int)(nil), ""}, + {(map[string]int)(nil), (map[string]int)(nil), ""}, + + // Wrong element types. + {make(map[int]int), nil, "given map[int]int"}, + {make(map[namedElemType]int), nil, "given map[oglemock_test.namedElemType]int"}, + {make(map[string]string), nil, "given map[string]string"}, + + // Wrong types. + {(func())(nil), nil, "given func()"}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) PointerToString() { + type namedElemType string + + someStr := "" + + sig := reflect.TypeOf(func() *string { return nil }) + cases := []returnTestCase{ + // Identical types. + {(*string)(&someStr), (*string)(&someStr), ""}, + + // Nil values. + {(interface{})(nil), (*string)(nil), ""}, + {(*string)(nil), (*string)(nil), ""}, + + // Wrong element types. + {&someInt, nil, "given *int"}, + + // Wrong types. + {(func())(nil), nil, "given func()"}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {unsafe.Pointer(&someStr), nil, "given unsafe.Pointer"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) SliceOfInts() { + type namedElemType int + + someSlice := make([]int, 1) + + sig := reflect.TypeOf(func() []int { return nil }) + cases := []returnTestCase{ + // Identical types. + {someSlice, someSlice, ""}, + + // Nil values. + {(interface{})(nil), ([]int)(nil), ""}, + {([]int)(nil), ([]int)(nil), ""}, + + // Wrong element types. + {make([]string, 1), nil, "given []string"}, + {make([]namedElemType, 1), nil, "given []oglemock_test.namedElemType"}, + + // Wrong types. + {(func())(nil), nil, "given func()"}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) String() { + sig := reflect.TypeOf(func() string { return "" }) + cases := []returnTestCase{ + // Identical types. + {string(""), string(""), ""}, + {string("taco"), string("taco"), ""}, + + // Wrong types. + {nil, nil, "given "}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) Struct() { + type myStruct struct { + a int + } + + type otherStruct struct{} + + sig := reflect.TypeOf(func() myStruct { return myStruct{0} }) + cases := []returnTestCase{ + // Identical types. + {myStruct{17}, myStruct{17}, ""}, + + // Wrong field types. + {otherStruct{}, nil, "given oglemock_test.otherStruct"}, + + // Wrong types. + {nil, nil, "given "}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) UnsafePointer() { + someStr := "" + + sig := reflect.TypeOf(func() unsafe.Pointer { return nil }) + cases := []returnTestCase{ + // Identical types. + {unsafe.Pointer(&someStr), unsafe.Pointer(&someStr), ""}, + + // Nil values. + {(interface{})(nil), unsafe.Pointer(nil), ""}, + {unsafe.Pointer(nil), unsafe.Pointer(nil), ""}, + + // Wrong types. + {(func())(nil), nil, "given func()"}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {(*string)(&someStr), nil, "given *string"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) UserDefinedNumericType() { + type myType int16 + + sig := reflect.TypeOf(func() myType { return 0 }) + cases := []returnTestCase{ + // Identical types. + {myType(math.MinInt16), myType(math.MinInt16), ""}, + {myType(math.MaxInt16), myType(math.MaxInt16), ""}, + + // In-range ints. + {int(math.MinInt16), myType(math.MinInt16), ""}, + {int(math.MaxInt16), myType(math.MaxInt16), ""}, + + // Out of range ints. + {int(math.MinInt16 - 1), nil, "out of range"}, + {int(math.MaxInt16 + 1), nil, "out of range"}, + + // Wrong types. + {nil, nil, "given "}, + {int16(1), nil, "given int16"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} + +func (t *ReturnTest) UserDefinedNonNumericType() { + type myType string + + sig := reflect.TypeOf(func() myType { return "" }) + cases := []returnTestCase{ + // Identical types. + {myType("taco"), myType("taco"), ""}, + + // Wrong types. + {nil, nil, "given "}, + {int(1), nil, "given int"}, + {float64(1), nil, "given float64"}, + {complex128(1), nil, "given complex128"}, + {string(""), nil, "given string"}, + {&someInt, nil, "given *int"}, + {make(chan int), nil, "given chan int"}, + } + + t.runTestCases(sig, cases) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/sample/README.markdown b/vendor/github.com/smartystreets/assertions/internal/oglemock/sample/README.markdown new file mode 100644 index 000000000..60d5d2cb1 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/sample/README.markdown @@ -0,0 +1,6 @@ +This directory contains sample code generated with the `createmock` command. For +example, the file `mock_io.go` can be regenerated with: + + createmock io Reader > sample/mock_io/mock_io.go + +The files are also used by `integration_test.go`. diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/sample/mock_io/mock_io.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/sample/mock_io/mock_io.go new file mode 100644 index 000000000..76e8f0005 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/sample/mock_io/mock_io.go @@ -0,0 +1,71 @@ +// This file was auto-generated using createmock. See the following page for +// more information: +// +// https://github.com/smartystreets/assertions/internal/oglemock +// + +package mock_io + +import ( + fmt "fmt" + oglemock "github.com/smartystreets/assertions/internal/oglemock" + io "io" + runtime "runtime" + unsafe "unsafe" +) + +type MockReader interface { + io.Reader + oglemock.MockObject +} + +type mockReader struct { + controller oglemock.Controller + description string +} + +func NewMockReader( + c oglemock.Controller, + desc string) MockReader { + return &mockReader{ + controller: c, + description: desc, + } +} + +func (m *mockReader) Oglemock_Id() uintptr { + return uintptr(unsafe.Pointer(m)) +} + +func (m *mockReader) Oglemock_Description() string { + return m.description +} + +func (m *mockReader) Read(p0 []uint8) (o0 int, o1 error) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "Read", + file, + line, + []interface{}{p0}) + + if len(retVals) != 2 { + panic(fmt.Sprintf("mockReader.Read: invalid return values: %v", retVals)) + } + + // o0 int + if retVals[0] != nil { + o0 = retVals[0].(int) + } + + // o1 error + if retVals[1] != nil { + o1 = retVals[1].(error) + } + + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg.go new file mode 100644 index 000000000..27cfcf619 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg.go @@ -0,0 +1,83 @@ +// Copyright 2015 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock + +import ( + "fmt" + "reflect" +) + +// Create an Action that saves the argument at the given zero-based index to +// the supplied destination, which must be a pointer to a type that is +// assignable from the argument type. +func SaveArg(index int, dst interface{}) Action { + return &saveArg{ + index: index, + dstPointer: dst, + } +} + +type saveArg struct { + index int + dstPointer interface{} + + // Set by SetSignature. + dstValue reflect.Value +} + +func (a *saveArg) SetSignature(signature reflect.Type) (err error) { + // Extract the source type. + if a.index >= signature.NumIn() { + err = fmt.Errorf( + "Out of range argument index %v for function type %v", + a.index, + signature) + return + } + + srcType := signature.In(a.index) + + // The destination must be a pointer. + v := reflect.ValueOf(a.dstPointer) + if v.Kind() != reflect.Ptr { + err = fmt.Errorf("Destination is %v, not a pointer", v.Kind()) + return + } + + // Dereference the pointer. + if v.IsNil() { + err = fmt.Errorf("Destination pointer must be non-nil") + return + } + + a.dstValue = v.Elem() + + // The destination must be assignable from the source. + if !srcType.AssignableTo(a.dstValue.Type()) { + err = fmt.Errorf( + "%v is not assignable to %v", + srcType, + a.dstValue.Type()) + return + } + + return +} + +func (a *saveArg) Invoke(methodArgs []interface{}) (rets []interface{}) { + a.dstValue.Set(reflect.ValueOf(methodArgs[a.index])) + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg_test.go new file mode 100644 index 000000000..4051907e0 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg_test.go @@ -0,0 +1,132 @@ +// Copyright 2015 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglemock_test + +import ( + "io" + "os" + "reflect" + "testing" + + . "github.com/smartystreets/assertions/internal/oglematchers" + "github.com/smartystreets/assertions/internal/oglemock" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +func TestSaveArg(t *testing.T) { RunTests(t) } + +//////////////////////////////////////////////////////////// +// Boilerplate +//////////////////////////////////////////////////////////// + +type SaveArgTest struct { +} + +func init() { RegisterTestSuite(&SaveArgTest{}) } + +//////////////////////////////////////////////////////////// +// Test functions +//////////////////////////////////////////////////////////// + +func (t *SaveArgTest) FunctionHasNoArguments() { + const index = 0 + var dst int + f := func() (int, string) { return 0, "" } + + err := oglemock.SaveArg(index, &dst).SetSignature(reflect.TypeOf(f)) + ExpectThat(err, Error(HasSubstr("index 0"))) + ExpectThat(err, Error(HasSubstr("Out of range"))) + ExpectThat(err, Error(HasSubstr("func() (int, string)"))) +} + +func (t *SaveArgTest) ArgumentIndexOutOfRange() { + const index = 2 + var dst int + f := func(a int, b int) {} + + err := oglemock.SaveArg(index, &dst).SetSignature(reflect.TypeOf(f)) + ExpectThat(err, Error(HasSubstr("index 2"))) + ExpectThat(err, Error(HasSubstr("Out of range"))) + ExpectThat(err, Error(HasSubstr("func(int, int)"))) +} + +func (t *SaveArgTest) DestinationIsLiteralNil() { + const index = 0 + f := func(a int, b int) {} + + err := oglemock.SaveArg(index, nil).SetSignature(reflect.TypeOf(f)) + ExpectThat(err, Error(HasSubstr("not a pointer"))) +} + +func (t *SaveArgTest) DestinationIsNotAPointer() { + const index = 0 + f := func(a int, b int) {} + + err := oglemock.SaveArg(index, uint(17)).SetSignature(reflect.TypeOf(f)) + ExpectThat(err, Error(HasSubstr("pointer"))) + ExpectThat(err, Error(HasSubstr("uint"))) +} + +func (t *SaveArgTest) DestinationIsNilPointer() { + const index = 1 + var dst *int + f := func(a int, b int) {} + + err := oglemock.SaveArg(index, dst).SetSignature(reflect.TypeOf(f)) + ExpectThat(err, Error(HasSubstr("pointer"))) + ExpectThat(err, Error(HasSubstr("non-nil"))) +} + +func (t *SaveArgTest) DestinationNotAssignableFromSource() { + const index = 1 + var dst int + f := func(a int, b string) {} + + err := oglemock.SaveArg(index, &dst).SetSignature(reflect.TypeOf(f)) + ExpectThat(err, Error(HasSubstr("int"))) + ExpectThat(err, Error(HasSubstr("assignable"))) + ExpectThat(err, Error(HasSubstr("string"))) +} + +func (t *SaveArgTest) ExactTypeMatch() { + const index = 1 + var dst int + f := func(a int, b int) {} + + action := oglemock.SaveArg(index, &dst) + AssertEq(nil, action.SetSignature(reflect.TypeOf(f))) + + var a int = 17 + var b int = 19 + _ = action.Invoke([]interface{}{a, b}) + + ExpectEq(19, dst) +} + +func (t *SaveArgTest) AssignableTypeMatch() { + const index = 1 + var dst io.Reader + f := func(a int, b *os.File) {} + + action := oglemock.SaveArg(index, &dst) + AssertEq(nil, action.SetSignature(reflect.TypeOf(f))) + + var a int = 17 + var b *os.File = os.Stdout + _ = action.Invoke([]interface{}{a, b}) + + ExpectEq(os.Stdout, dst) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/.gitignore b/vendor/github.com/smartystreets/assertions/internal/ogletest/.gitignore new file mode 100644 index 000000000..dd8fc7468 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/.gitignore @@ -0,0 +1,5 @@ +*.6 +6.out +_obj/ +_test/ +_testmain.go diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/.travis.yml b/vendor/github.com/smartystreets/assertions/internal/ogletest/.travis.yml new file mode 100644 index 000000000..b97211926 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/.travis.yml @@ -0,0 +1,4 @@ +# Cf. http://docs.travis-ci.com/user/getting-started/ +# Cf. http://docs.travis-ci.com/user/languages/go/ + +language: go diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/LICENSE b/vendor/github.com/smartystreets/assertions/internal/ogletest/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/README.md b/vendor/github.com/smartystreets/assertions/internal/ogletest/README.md new file mode 100644 index 000000000..8e5486208 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/README.md @@ -0,0 +1,151 @@ +[![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/ogletest?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/ogletest) + +`ogletest` is a unit testing framework for Go with the following features: + + * An extensive and extensible set of matchers for expressing expectations. + * Automatic failure messages; no need to say `t.Errorf("Expected %v, got + %v"...)`. + * Clean, readable output that tells you exactly what you need to know. + * Built-in support for mocking through the [oglemock][] package. + * Style and semantics similar to [Google Test][googletest] and + [Google JS Test][google-js-test]. + +It integrates with Go's built-in `testing` package, so it works with the +`go test` command, and even with other types of test within your package. Unlike +the `testing` package which offers only basic capabilities for signalling +failures, it offers ways to express expectations and get nice failure messages +automatically. + + +Installation +------------ + +First, make sure you have installed Go 1.0.2 or newer. See +[here][golang-install] for instructions. + +Use the following command to install `ogletest` and its dependencies, and to +keep them up to date: + + go get -u github.com/smartystreets/assertions/internal/ogletest + + +Documentation +------------- + +See [here][reference] for package documentation containing an exhaustive list of +exported symbols. Alternatively, you can install the package and then use +`godoc`: + + godoc github.com/smartystreets/assertions/internal/ogletest + +An important part of `ogletest` is its use of matchers provided by the +[oglematchers][matcher-reference] package. See that package's documentation +for information on the built-in matchers available, and check out the +`oglematchers.Matcher` interface if you want to define your own. + + +Example +------- + +Let's say you have a function in your package `people` with the following +signature: + +```go +// GetRandomPerson returns the name and phone number of Tony, Dennis, or Scott. +func GetRandomPerson() (name, phone string) { + [...] +} +``` + +A silly function, but it will do for an example. You can write a couple of tests +for it as follows: + +```go +package people + +import ( + "github.com/smartystreets/assertions/internal/oglematchers" + "github.com/smartystreets/assertions/internal/ogletest" + "testing" +) + +// Give ogletest a chance to run your tests when invoked by 'go test'. +func TestOgletest(t *testing.T) { ogletest.RunTests(t) } + +// Create a test suite, which groups together logically related test methods +// (defined below). You can share common setup and teardown code here; see the +// package docs for more info. +type PeopleTest struct {} +func init() { ogletest.RegisterTestSuite(&PeopleTest{}) } + +func (t *PeopleTest) ReturnsCorrectNames() { + // Call the function a few times, and make sure it never strays from the set + // of expected names. + for i := 0; i < 25; i++ { + name, _ := GetRandomPerson() + ogletest.ExpectThat(name, oglematchers.AnyOf("Tony", "Dennis", "Scott")) + } +} + +func (t *PeopleTest) FormatsPhoneNumbersCorrectly() { + // Call the function a few times, and make sure it returns phone numbers in a + // standard US format. + for i := 0; i < 25; i++ { + _, phone := GetRandomPerson() + ogletest.ExpectThat(phone, oglematchers.MatchesRegexp(`^\(\d{3}\) \d{3}-\d{4}$`)) +} +``` + +Note that test control functions (`RunTests`, `ExpectThat`, and so on) are part +of the `ogletest` package, whereas built-in matchers (`AnyOf`, `MatchesRegexp`, +and more) are part of the [oglematchers][matcher-reference] library. You can of +course use dot imports so that you don't need to prefix each function with its +package name: + +```go +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) +``` + +If you save the test in a file whose name ends in `_test.go`, you can run your +tests by simply invoking the following in your package directory: + + go test + +Here's what the failure output of ogletest looks like, if your function's +implementation is bad. + + [----------] Running tests from PeopleTest + [ RUN ] PeopleTest.FormatsPhoneNumbersCorrectly + people_test.go:32: + Expected: matches regexp "^\(\d{3}\) \d{3}-\d{4}$" + Actual: +1 800 555 5555 + + [ FAILED ] PeopleTest.FormatsPhoneNumbersCorrectly + [ RUN ] PeopleTest.ReturnsCorrectNames + people_test.go:23: + Expected: or(Tony, Dennis, Scott) + Actual: Bart + + [ FAILED ] PeopleTest.ReturnsCorrectNames + [----------] Finished with tests from PeopleTest + +And if the test passes: + + [----------] Running tests from PeopleTest + [ RUN ] PeopleTest.FormatsPhoneNumbersCorrectly + [ OK ] PeopleTest.FormatsPhoneNumbersCorrectly + [ RUN ] PeopleTest.ReturnsCorrectNames + [ OK ] PeopleTest.ReturnsCorrectNames + [----------] Finished with tests from PeopleTest + + +[reference]: http://godoc.org/github.com/smartystreets/assertions/internal/ogletest +[matcher-reference]: http://godoc.org/github.com/smartystreets/assertions/internal/oglematchers +[golang-install]: http://golang.org/doc/install.html +[googletest]: http://code.google.com/p/googletest/ +[google-js-test]: http://code.google.com/p/google-js-test/ +[howtowrite]: http://golang.org/doc/code.html +[oglemock]: https://github.com/smartystreets/assertions/internal/oglemock diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/assert_aliases.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/assert_aliases.go new file mode 100644 index 000000000..70fa25c32 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/assert_aliases.go @@ -0,0 +1,70 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 ogletest + +import ( + "github.com/smartystreets/assertions/internal/oglematchers" +) + +// AssertEq(e, a) is equivalent to AssertThat(a, oglematchers.Equals(e)). +func AssertEq(expected, actual interface{}, errorParts ...interface{}) { + assertThat( + actual, + oglematchers.Equals(expected), + 1, + errorParts) +} + +// AssertNe(e, a) is equivalent to +// AssertThat(a, oglematchers.Not(oglematchers.Equals(e))). +func AssertNe(expected, actual interface{}, errorParts ...interface{}) { + assertThat( + actual, + oglematchers.Not(oglematchers.Equals(expected)), + 1, + errorParts) +} + +// AssertLt(x, y) is equivalent to AssertThat(x, oglematchers.LessThan(y)). +func AssertLt(x, y interface{}, errorParts ...interface{}) { + assertThat(x, oglematchers.LessThan(y), 1, errorParts) +} + +// AssertLe(x, y) is equivalent to AssertThat(x, oglematchers.LessOrEqual(y)). +func AssertLe(x, y interface{}, errorParts ...interface{}) { + assertThat(x, oglematchers.LessOrEqual(y), 1, errorParts) +} + +// AssertGt(x, y) is equivalent to AssertThat(x, oglematchers.GreaterThan(y)). +func AssertGt(x, y interface{}, errorParts ...interface{}) { + assertThat(x, oglematchers.GreaterThan(y), 1, errorParts) +} + +// AssertGe(x, y) is equivalent to +// AssertThat(x, oglematchers.GreaterOrEqual(y)). +func AssertGe(x, y interface{}, errorParts ...interface{}) { + assertThat(x, oglematchers.GreaterOrEqual(y), 1, errorParts) +} + +// AssertTrue(b) is equivalent to AssertThat(b, oglematchers.Equals(true)). +func AssertTrue(b interface{}, errorParts ...interface{}) { + assertThat(b, oglematchers.Equals(true), 1, errorParts) +} + +// AssertFalse(b) is equivalent to AssertThat(b, oglematchers.Equals(false)). +func AssertFalse(b interface{}, errorParts ...interface{}) { + assertThat(b, oglematchers.Equals(false), 1, errorParts) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/assert_that.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/assert_that.go new file mode 100644 index 000000000..65c8fbce0 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/assert_that.go @@ -0,0 +1,46 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 ogletest + +import ( + "github.com/smartystreets/assertions/internal/oglematchers" +) + +func assertThat( + x interface{}, + m oglematchers.Matcher, + depth int, + errorParts []interface{}) { + passed := expectThat(x, m, depth+1, errorParts) + if !passed { + AbortTest() + } +} + +// AssertThat is identical to ExpectThat, except that in the event of failure +// it halts the currently running test immediately. It is thus useful for +// things like bounds checking: +// +// someSlice := [...] +// AssertEq(1, len(someSlice)) // Protects next line from panicking. +// ExpectEq("taco", someSlice[0]) +// +func AssertThat( + x interface{}, + m oglematchers.Matcher, + errorParts ...interface{}) { + assertThat(x, m, 1, errorParts) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/doc.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/doc.go new file mode 100644 index 000000000..bf6507fae --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/doc.go @@ -0,0 +1,51 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 ogletest provides a framework for writing expressive unit tests. It +// integrates with the builtin testing package, so it works with the gotest +// command. Unlike the testing package which offers only basic capabilities for +// signalling failures, it offers ways to express expectations and get nice +// failure messages automatically. +// +// For example: +// +// //////////////////////////////////////////////////////////////////////// +// // testing package test +// //////////////////////////////////////////////////////////////////////// +// +// someStr, err := ComputeSomeString() +// if err != nil { +// t.Errorf("ComputeSomeString: expected nil error, got %v", err) +// } +// +// !strings.Contains(someStr, "foo") { +// t.Errorf("ComputeSomeString: expected substring foo, got %v", someStr) +// } +// +// //////////////////////////////////////////////////////////////////////// +// // ogletest test +// //////////////////////////////////////////////////////////////////////// +// +// someStr, err := ComputeSomeString() +// ExpectEq(nil, err) +// ExpectThat(someStr, HasSubstr("foo") +// +// Failure messages require no work from the user, and look like the following: +// +// foo_test.go:103: +// Expected: has substring "foo" +// Actual: "bar baz" +// +package ogletest diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_aliases.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_aliases.go new file mode 100644 index 000000000..5bc1dc120 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_aliases.go @@ -0,0 +1,64 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 ogletest + +import "github.com/smartystreets/assertions/internal/oglematchers" + +// ExpectEq(e, a) is equivalent to ExpectThat(a, oglematchers.Equals(e)). +func ExpectEq(expected, actual interface{}, errorParts ...interface{}) { + expectThat(actual, oglematchers.Equals(expected), 1, errorParts) +} + +// ExpectNe(e, a) is equivalent to +// ExpectThat(a, oglematchers.Not(oglematchers.Equals(e))). +func ExpectNe(expected, actual interface{}, errorParts ...interface{}) { + expectThat( + actual, + oglematchers.Not(oglematchers.Equals(expected)), + 1, + errorParts) +} + +// ExpectLt(x, y) is equivalent to ExpectThat(x, oglematchers.LessThan(y)). +func ExpectLt(x, y interface{}, errorParts ...interface{}) { + expectThat(x, oglematchers.LessThan(y), 1, errorParts) +} + +// ExpectLe(x, y) is equivalent to ExpectThat(x, oglematchers.LessOrEqual(y)). +func ExpectLe(x, y interface{}, errorParts ...interface{}) { + expectThat(x, oglematchers.LessOrEqual(y), 1, errorParts) +} + +// ExpectGt(x, y) is equivalent to ExpectThat(x, oglematchers.GreaterThan(y)). +func ExpectGt(x, y interface{}, errorParts ...interface{}) { + expectThat(x, oglematchers.GreaterThan(y), 1, errorParts) +} + +// ExpectGe(x, y) is equivalent to +// ExpectThat(x, oglematchers.GreaterOrEqual(y)). +func ExpectGe(x, y interface{}, errorParts ...interface{}) { + expectThat(x, oglematchers.GreaterOrEqual(y), 1, errorParts) +} + +// ExpectTrue(b) is equivalent to ExpectThat(b, oglematchers.Equals(true)). +func ExpectTrue(b interface{}, errorParts ...interface{}) { + expectThat(b, oglematchers.Equals(true), 1, errorParts) +} + +// ExpectFalse(b) is equivalent to ExpectThat(b, oglematchers.Equals(false)). +func ExpectFalse(b interface{}, errorParts ...interface{}) { + expectThat(b, oglematchers.Equals(false), 1, errorParts) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_call.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_call.go new file mode 100644 index 000000000..b8bf542a8 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_call.go @@ -0,0 +1,59 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 ogletest + +import ( + "github.com/smartystreets/assertions/internal/oglemock" + "runtime" +) + +// ExpectCall expresses an expectation that the method of the given name +// should be called on the supplied mock object. It returns a function that +// should be called with the expected arguments, matchers for the arguments, +// or a mix of both. +// +// For example: +// +// mockWriter := [...] +// ogletest.ExpectCall(mockWriter, "Write")(oglematchers.ElementsAre(0x1)) +// .WillOnce(oglemock.Return(1, nil)) +// +// This is a shortcut for calling i.MockController.ExpectCall, where i is the +// TestInfo struct for the currently-running test. Unlike that direct approach, +// this function automatically sets the correct file name and line number for +// the expectation. +func ExpectCall(o oglemock.MockObject, method string) oglemock.PartialExpecation { + // Get information about the call site. + _, file, lineNumber, ok := runtime.Caller(1) + if !ok { + panic("ExpectCall: runtime.Caller") + } + + // Grab the current test info. + info := currentlyRunningTest + if info == nil { + panic("ExpectCall: no test info.") + } + + // Grab the mock controller. + controller := currentlyRunningTest.MockController + if controller == nil { + panic("ExpectCall: no mock controller.") + } + + // Report the expectation. + return controller.ExpectCall(o, method, file, lineNumber) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that.go new file mode 100644 index 000000000..69fc66978 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that.go @@ -0,0 +1,100 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 ogletest + +import ( + "fmt" + "path" + "reflect" + "runtime" + + "github.com/smartystreets/assertions/internal/oglematchers" +) + +// ExpectThat confirms that the supplied matcher matches the value x, adding a +// failure record to the currently running test if it does not. If additional +// parameters are supplied, the first will be used as a format string for the +// later ones, and the user-supplied error message will be added to the test +// output in the event of a failure. +// +// For example: +// +// ExpectThat(userName, Equals("jacobsa")) +// ExpectThat(users[i], Equals("jacobsa"), "while processing user %d", i) +// +func ExpectThat( + x interface{}, + m oglematchers.Matcher, + errorParts ...interface{}) { + expectThat(x, m, 1, errorParts) +} + +// The generalized form of ExpectThat. depth is the distance on the stack +// between the caller's frame and the user's frame. Returns passed iff the +// match succeeded. +func expectThat( + x interface{}, + m oglematchers.Matcher, + depth int, + errorParts []interface{}) (passed bool) { + // Check whether the value matches. If it does, we are finished. + matcherErr := m.Matches(x) + if matcherErr == nil { + passed = true + return + } + + var r FailureRecord + + // Get information about the call site. + var ok bool + if _, r.FileName, r.LineNumber, ok = runtime.Caller(depth + 1); !ok { + panic("expectThat: runtime.Caller") + } + + r.FileName = path.Base(r.FileName) + + // Create an appropriate failure message. Make sure that the expected and + // actual values align properly. + relativeClause := "" + if matcherErr.Error() != "" { + relativeClause = fmt.Sprintf(", %s", matcherErr.Error()) + } + + r.Error = fmt.Sprintf( + "Expected: %s\nActual: %v%s", + m.Description(), + x, + relativeClause) + + // Add the user error, if any. + if len(errorParts) != 0 { + v := reflect.ValueOf(errorParts[0]) + if v.Kind() != reflect.String { + panic(fmt.Sprintf("ExpectThat: invalid format string type %v", v.Kind())) + } + + r.Error = fmt.Sprintf( + "%s\n%s", + r.Error, + fmt.Sprintf(v.String(), errorParts[1:]...)) + } + + // Report the failure. + AddFailureRecord(r) + + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that_test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that_test.go new file mode 100644 index 000000000..e3e372367 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that_test.go @@ -0,0 +1,168 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 ogletest + +import ( + "errors" + "testing" + + . "github.com/smartystreets/assertions/internal/oglematchers" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +// Set up a new test state with empty fields. +func setUpCurrentTest() { + currentlyRunningTest = newTestInfo() +} + +type fakeExpectThatMatcher struct { + desc string + err error +} + +func (m *fakeExpectThatMatcher) Matches(c interface{}) error { + return m.err +} + +func (m *fakeExpectThatMatcher) Description() string { + return m.desc +} + +func assertEqInt(t *testing.T, e, c int) { + if e != c { + t.Fatalf("Expected %d, got %d", e, c) + } +} + +func expectEqInt(t *testing.T, e, c int) { + if e != c { + t.Errorf("Expected %v, got %v", e, c) + } +} + +func expectEqStr(t *testing.T, e, c string) { + if e != c { + t.Errorf("Expected %s, got %s", e, c) + } +} + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func TestNoCurrentTest(t *testing.T) { + panicked := false + + defer func() { + if !panicked { + t.Errorf("Expected panic; got none.") + } + }() + + defer func() { + if r := recover(); r != nil { + panicked = true + } + }() + + currentlyRunningTest = nil + ExpectThat(17, Equals(19)) +} + +func TestNoFailure(t *testing.T) { + setUpCurrentTest() + matcher := &fakeExpectThatMatcher{"", nil} + ExpectThat(17, matcher) + + assertEqInt(t, 0, len(currentlyRunningTest.failureRecords)) +} + +func TestInvalidFormatString(t *testing.T) { + panicked := false + + defer func() { + if !panicked { + t.Errorf("Expected panic; got none.") + } + }() + + defer func() { + if r := recover(); r != nil { + panicked = true + } + }() + + setUpCurrentTest() + matcher := &fakeExpectThatMatcher{"", errors.New("")} + ExpectThat(17, matcher, 19, "blah") +} + +func TestNoMatchWithoutErrorText(t *testing.T) { + setUpCurrentTest() + matcher := &fakeExpectThatMatcher{"taco", errors.New("")} + ExpectThat(17, matcher) + + assertEqInt(t, 1, len(currentlyRunningTest.failureRecords)) + + record := currentlyRunningTest.failureRecords[0] + expectEqStr(t, "expect_that_test.go", record.FileName) + expectEqInt(t, 119, record.LineNumber) + expectEqStr(t, "Expected: taco\nActual: 17", record.Error) +} + +func TestNoMatchWithErrorTExt(t *testing.T) { + setUpCurrentTest() + matcher := &fakeExpectThatMatcher{"taco", errors.New("which is foo")} + ExpectThat(17, matcher) + + assertEqInt(t, 1, len(currentlyRunningTest.failureRecords)) + record := currentlyRunningTest.failureRecords[0] + + expectEqStr( + t, + "Expected: taco\nActual: 17, which is foo", + record.Error) +} + +func TestFailureWithUserMessage(t *testing.T) { + setUpCurrentTest() + matcher := &fakeExpectThatMatcher{"taco", errors.New("")} + ExpectThat(17, matcher, "Asd: %d %s", 19, "taco") + + assertEqInt(t, 1, len(currentlyRunningTest.failureRecords)) + record := currentlyRunningTest.failureRecords[0] + + expectEqStr(t, "Expected: taco\nActual: 17\nAsd: 19 taco", record.Error) +} + +func TestAdditionalFailure(t *testing.T) { + setUpCurrentTest() + matcher := &fakeExpectThatMatcher{"", errors.New("")} + + // Fail twice. + ExpectThat(17, matcher, "taco") + ExpectThat(19, matcher, "burrito") + + assertEqInt(t, 2, len(currentlyRunningTest.failureRecords)) + record1 := currentlyRunningTest.failureRecords[0] + record2 := currentlyRunningTest.failureRecords[1] + + expectEqStr(t, "Expected: \nActual: 17\ntaco", record1.Error) + expectEqStr(t, "Expected: \nActual: 19\nburrito", record2.Error) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/failure.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/failure.go new file mode 100644 index 000000000..95be2cf45 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/failure.go @@ -0,0 +1,90 @@ +// Copyright 2015 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 ogletest + +import ( + "fmt" + "path" + "runtime" +) + +// FailureRecord represents a single failed expectation or assertion for a +// test. Most users don't want to interact with these directly; they are +// generated implicitly using ExpectThat, AssertThat, ExpectLt, etc. +type FailureRecord struct { + // The file name within which the expectation failed, e.g. "foo_test.go". + FileName string + + // The line number at which the expectation failed. + LineNumber int + + // The error associated with the file:line pair above. For example, the + // following expectation: + // + // ExpectEq(17, "taco")" + // + // May cause this error: + // + // Expected: 17 + // Actual: "taco", which is not numeric + // + Error string +} + +// Record a failure for the currently running test (and continue running it). +// Most users will want to use ExpectThat, ExpectEq, etc. instead of this +// function. Those that do want to report arbitrary errors will probably be +// satisfied with AddFailure, which is easier to use. +func AddFailureRecord(r FailureRecord) { + currentlyRunningTest.mu.Lock() + defer currentlyRunningTest.mu.Unlock() + + currentlyRunningTest.failureRecords = append( + currentlyRunningTest.failureRecords, + r) +} + +// Call AddFailureRecord with a record whose file name and line number come +// from the caller of this function, and whose error string is created by +// calling fmt.Sprintf using the arguments to this function. +func AddFailure(format string, a ...interface{}) { + r := FailureRecord{ + Error: fmt.Sprintf(format, a...), + } + + // Get information about the call site. + var ok bool + if _, r.FileName, r.LineNumber, ok = runtime.Caller(1); !ok { + panic("Can't find caller") + } + + r.FileName = path.Base(r.FileName) + + AddFailureRecord(r) +} + +// A sentinel type that is used in a conspiracy between AbortTest and runTests. +// If runTests sees an abortError as the value given to a panic() call, it will +// avoid printing the panic error. +type abortError struct { +} + +// Immediately stop executing the running test, causing it to fail with the +// failures previously recorded. Behavior is undefined if no failures have been +// recorded. +func AbortTest() { + panic(abortError{}) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/integration_test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/integration_test.go new file mode 100644 index 000000000..ec45184e3 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/integration_test.go @@ -0,0 +1,265 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 ogletest_test + +import ( + "errors" + "flag" + "fmt" + "go/build" + "io/ioutil" + "os" + "os/exec" + "path" + "regexp" + "strings" + "syscall" + "testing" +) + +const ogletestPkg = "github.com/smartystreets/assertions/internal/ogletest" + +var dumpNew = flag.Bool("dump_new", false, "Dump new golden files.") +var objDir string + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +// Install the possibly locally-modified copy of ogletest, so that these +// integration tests run using the package currently being worked on by the +// programmer. Also install other dependencies needed by the test cases, so +// that `go test` complaining about non-up-to-date packages doesn't make it +// into the golden files. +func installLocalPackages() error { + cmd := exec.Command( + "go", + "install", + ogletestPkg, + "github.com/smartystreets/assertions/internal/oglemock", + "github.com/smartystreets/assertions/internal/ogletest/test_cases/mock_image") + + output, err := cmd.CombinedOutput() + + if err != nil { + return errors.New(fmt.Sprintf("%v:\n%s", err, output)) + } + + return nil +} + +// getCaseNames looks for integration test cases as files in the test_cases +// directory. +func getCaseNames() ([]string, error) { + // Open the test cases directory. + dir, err := os.Open("test_cases") + if err != nil { + return nil, errors.New(fmt.Sprintf("Opening dir: %v", err)) + } + + // Get a list of the names in the directory. + names, err := dir.Readdirnames(0) + if err != nil { + return nil, errors.New(fmt.Sprintf("Readdirnames: %v", err)) + } + + // Filter the names. + result := make([]string, len(names)) + resultLen := 0 + for _, name := range names { + // Skip golden files and hidden files. + if strings.HasPrefix(name, "golden.") || strings.HasPrefix(name, ".") { + continue + } + + // Check for the right format. + if !strings.HasSuffix(name, ".test.go") { + continue + } + + // Store the name minus the extension. + result[resultLen] = name[:len(name)-8] + resultLen++ + } + + return result[:resultLen], nil +} + +func writeContentsToFileOrDie(contents []byte, path string) { + if err := ioutil.WriteFile(path, contents, 0600); err != nil { + panic("ioutil.WriteFile: " + err.Error()) + } +} + +func readFileOrDie(path string) []byte { + contents, err := ioutil.ReadFile(path) + if err != nil { + panic("ioutil.ReadFile: " + err.Error()) + } + + return contents +} + +// cleanOutput transforms the supplied output so that it no longer contains +// information that changes from run to run, making the golden tests less +// flaky. +func cleanOutput(o []byte, testPkg string) []byte { + // Replace references to the last component of the test package name, which + // contains a unique number. + o = []byte(strings.Replace(string(o), path.Base(testPkg), "somepkg", -1)) + + // Replace things that look like line numbers and process counters in stack + // traces. + stackFrameRe := regexp.MustCompile(`\t\S+\.(c|go):\d+`) + o = stackFrameRe.ReplaceAll(o, []byte("\tsome_file.txt:0")) + + // Replace full paths in failure messages with fake paths. + pathRe := regexp.MustCompile(`/\S+/(\w+\.(?:go|s):\d+)`) + o = pathRe.ReplaceAll(o, []byte("/some/path/$1")) + + // Replace unstable timings in gotest fail messages. + timingRe1 := regexp.MustCompile(`--- FAIL: .* \(\d\.\d{2}s\)`) + o = timingRe1.ReplaceAll(o, []byte("--- FAIL: TestSomething (1.23s)")) + + timingRe2 := regexp.MustCompile(`FAIL.*somepkg\s*\d\.\d{2,}s`) + o = timingRe2.ReplaceAll(o, []byte("FAIL somepkg 1.234s")) + + timingRe3 := regexp.MustCompile(`ok.*somepkg\s*\d\.\d{2,}s`) + o = timingRe3.ReplaceAll(o, []byte("ok somepkg 1.234s")) + + timingRe4 := regexp.MustCompile(`SlowTest \([0-9.]+ms\)`) + o = timingRe4.ReplaceAll(o, []byte("SlowTest (1234ms)")) + + return o +} + +// Create a temporary package directory somewhere that 'go test' can find, and +// return the directory and package name. +func createTempPackageDir(caseName string) (dir, pkg string) { + // Figure out where the local source code for ogletest is. + buildPkg, err := build.Import(ogletestPkg, "", build.FindOnly) + if err != nil { + panic("Finding ogletest tree: " + err.Error()) + } + + // Create a temporary directory underneath this. + ogletestPkgDir := buildPkg.Dir + prefix := fmt.Sprintf("tmp-%s-", caseName) + + dir, err = ioutil.TempDir(ogletestPkgDir, prefix) + if err != nil { + panic("ioutil.TempDir: " + err.Error()) + } + + pkg = path.Join("github.com/smartystreets/assertions/internal/ogletest", dir[len(ogletestPkgDir):]) + return +} + +// runTestCase runs the case with the supplied name (e.g. "passing"), and +// returns its output and exit code. +func runTestCase(name string) ([]byte, int, error) { + // Create a temporary directory for the test files. + testDir, testPkg := createTempPackageDir(name) + defer os.RemoveAll(testDir) + + // Create the test source file. + sourceFile := name + ".test.go" + testContents := readFileOrDie(path.Join("test_cases", sourceFile)) + writeContentsToFileOrDie(testContents, path.Join(testDir, name+"_test.go")) + + // Invoke 'go test'. Use the package directory as working dir instead of + // giving the package name as an argument so that 'go test' prints passing + // test output. Special case: pass a test filter to the filtered case. + cmd := exec.Command("go", "test") + if name == "filtered" { + cmd.Args = append(cmd.Args, "--ogletest.run=Test(Bar|Baz)") + } + + cmd.Dir = testDir + output, err := cmd.CombinedOutput() + + // Clean up the process's output. + output = cleanOutput(output, testPkg) + + // Did the process exist with zero code? + if err == nil { + return output, 0, nil + } + + // Make sure the process actually exited. + exitError, ok := err.(*exec.ExitError) + if !ok || !exitError.Exited() { + return nil, 0, errors.New("exec.Command.Output: " + err.Error()) + } + + return output, exitError.Sys().(syscall.WaitStatus).ExitStatus(), nil +} + +// checkGolden file checks the supplied actual output for the named test case +// against the golden file for that case. If requested by the user, it rewrites +// the golden file on failure. +func checkAgainstGoldenFile(caseName string, output []byte) bool { + goldenFile := path.Join("test_cases", "golden."+caseName+"_test") + goldenContents := readFileOrDie(goldenFile) + + result := string(output) == string(goldenContents) + if !result && *dumpNew { + writeContentsToFileOrDie(output, goldenFile) + } + + return result +} + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func TestGoldenFiles(t *testing.T) { + // Ensure the local package is installed. This will prevent the test cases + // from using the installed version, which may be out of date. + err := installLocalPackages() + if err != nil { + t.Fatalf("Error installing local ogletest: %v", err) + } + + // We expect there to be at least one case. + caseNames, err := getCaseNames() + if err != nil || len(caseNames) == 0 { + t.Fatalf("Error getting cases: %v", err) + } + + // Run each test case. + for _, caseName := range caseNames { + // Run the test case. + output, exitCode, err := runTestCase(caseName) + if err != nil { + t.Fatalf("Running test case %s: %v", caseName, err) + } + + // Check the status code. We assume all test cases fail except for the + // passing one. + shouldPass := (caseName == "passing" || caseName == "no_cases") + didPass := exitCode == 0 + if shouldPass != didPass { + t.Errorf("Bad exit code for test case %s: %d", caseName, exitCode) + } + + // Check the output against the golden file. + if !checkAgainstGoldenFile(caseName, output) { + t.Errorf("Output for test case %s doesn't match golden file.", caseName) + } + } +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/register.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/register.go new file mode 100644 index 000000000..756f2aa9a --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/register.go @@ -0,0 +1,86 @@ +// Copyright 2015 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 ogletest + +// The input to ogletest.Register. Most users will want to use +// ogletest.RegisterTestSuite. +// +// A test suite is the basic unit of registration in ogletest. It consists of +// zero or more named test functions which will be run in sequence, along with +// optional setup and tear-down functions. +type TestSuite struct { + // The name of the overall suite, e.g. "MyPackageTest". + Name string + + // If non-nil, a function that will be run exactly once, before any of the + // test functions are run. + SetUp func() + + // The test functions comprising this suite. + TestFunctions []TestFunction + + // If non-nil, a function that will be run exactly once, after all of the + // test functions have run. + TearDown func() +} + +type TestFunction struct { + // The name of this test function, relative to the suite in which it resides. + // If the name is "TweaksFrobnicator", then the function might be presented + // in the ogletest UI as "FooTest.TweaksFrobnicator". + Name string + + // If non-nil, a function that is run before Run, passed a pointer to a + // struct containing information about the test run. + SetUp func(*TestInfo) + + // The function to invoke for the test body. Must be non-nil. Will not be run + // if SetUp panics. + Run func() + + // If non-nil, a function that is run after Run. + TearDown func() +} + +// Register a test suite for execution by RunTests. +// +// This is the most general registration mechanism. Most users will want +// RegisterTestSuite, which is a wrapper around this function that requires +// less boilerplate. +// +// Panics on invalid input. +func Register(suite TestSuite) { + // Make sure the suite is legal. + if suite.Name == "" { + panic("Test suites must have names.") + } + + for _, tf := range suite.TestFunctions { + if tf.Name == "" { + panic("Test functions must have names.") + } + + if tf.Run == nil { + panic("Test functions must have non-nil run fields.") + } + } + + // Save the suite for later. + registeredSuites = append(registeredSuites, suite) +} + +// The list of test suites previously registered. +var registeredSuites []TestSuite diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/register_test_suite.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/register_test_suite.go new file mode 100644 index 000000000..7303dfa8a --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/register_test_suite.go @@ -0,0 +1,193 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 ogletest + +import ( + "fmt" + "reflect" + + "github.com/smartystreets/assertions/internal/ogletest/srcutil" +) + +// Test suites that implement this interface have special meaning to +// RegisterTestSuite. +type SetUpTestSuiteInterface interface { + // This method will be called exactly once, before the first test method is + // run. The receiver of this method will be a zero value of the test suite + // type, and is not shared with any other methods. Use this method to set up + // any necessary global state shared by all of the test methods. + SetUpTestSuite() +} + +// Test suites that implement this interface have special meaning to +// RegisterTestSuite. +type TearDownTestSuiteInterface interface { + // This method will be called exactly once, after the last test method is + // run. The receiver of this method will be a zero value of the test suite + // type, and is not shared with any other methods. Use this method to clean + // up after any necessary global state shared by all of the test methods. + TearDownTestSuite() +} + +// Test suites that implement this interface have special meaning to +// Register. +type SetUpInterface interface { + // This method is called before each test method is invoked, with the same + // receiver as that test method. At the time this method is invoked, the + // receiver is a zero value for the test suite type. Use this method for + // common setup code that works on data not shared across tests. + SetUp(*TestInfo) +} + +// Test suites that implement this interface have special meaning to +// Register. +type TearDownInterface interface { + // This method is called after each test method is invoked, with the same + // receiver as that test method. Use this method for common cleanup code that + // works on data not shared across tests. + TearDown() +} + +// RegisterTestSuite tells ogletest about a test suite containing tests that it +// should run. Any exported method on the type pointed to by the supplied +// prototype value will be treated as test methods, with the exception of the +// methods defined by the following interfaces, which when present are treated +// as described in the documentation for those interfaces: +// +// * SetUpTestSuiteInterface +// * SetUpInterface +// * TearDownInterface +// * TearDownTestSuiteInterface +// +// Each test method is invoked on a different receiver, which is initially a +// zero value of the test suite type. +// +// Example: +// +// // Some value that is needed by the tests but is expensive to compute. +// var someExpensiveThing uint +// +// type FooTest struct { +// // Path to a temporary file used by the tests. Each test gets a +// // different temporary file. +// tempFile string +// } +// func init() { ogletest.RegisterTestSuite(&FooTest{}) } +// +// func (t *FooTest) SetUpTestSuite() { +// someExpensiveThing = ComputeSomeExpensiveThing() +// } +// +// func (t *FooTest) SetUp(ti *ogletest.TestInfo) { +// t.tempFile = CreateTempFile() +// } +// +// func (t *FooTest) TearDown() { +// DeleteTempFile(t.tempFile) +// } +// +// func (t *FooTest) FrobinicatorIsSuccessfullyTweaked() { +// res := DoSomethingWithExpensiveThing(someExpensiveThing, t.tempFile) +// ExpectThat(res, Equals(true)) +// } +// +func RegisterTestSuite(p interface{}) { + if p == nil { + panic("RegisterTestSuite called with nil suite.") + } + + val := reflect.ValueOf(p) + typ := val.Type() + var zeroInstance reflect.Value + + // We will transform to a TestSuite struct. + suite := TestSuite{} + suite.Name = typ.Elem().Name() + + zeroInstance = reflect.New(typ.Elem()) + if i, ok := zeroInstance.Interface().(SetUpTestSuiteInterface); ok { + suite.SetUp = func() { i.SetUpTestSuite() } + } + + zeroInstance = reflect.New(typ.Elem()) + if i, ok := zeroInstance.Interface().(TearDownTestSuiteInterface); ok { + suite.TearDown = func() { i.TearDownTestSuite() } + } + + // Transform a list of test methods for the suite, filtering them to just the + // ones that we don't need to skip. + for _, method := range filterMethods(suite.Name, srcutil.GetMethodsInSourceOrder(typ)) { + var tf TestFunction + tf.Name = method.Name + + // Create an instance to be operated on by all of the TestFunction's + // internal functions. + instance := reflect.New(typ.Elem()) + + // Bind the functions to the instance. + if i, ok := instance.Interface().(SetUpInterface); ok { + tf.SetUp = func(ti *TestInfo) { i.SetUp(ti) } + } + + methodCopy := method + tf.Run = func() { runTestMethod(instance, methodCopy) } + + if i, ok := instance.Interface().(TearDownInterface); ok { + tf.TearDown = func() { i.TearDown() } + } + + // Save the TestFunction. + suite.TestFunctions = append(suite.TestFunctions, tf) + } + + // Register the suite. + Register(suite) +} + +func runTestMethod(suite reflect.Value, method reflect.Method) { + if method.Func.Type().NumIn() != 1 { + panic(fmt.Sprintf( + "%s: expected 1 args, actually %d.", + method.Name, + method.Func.Type().NumIn())) + } + + method.Func.Call([]reflect.Value{suite}) +} + +func filterMethods(suiteName string, in []reflect.Method) (out []reflect.Method) { + for _, m := range in { + // Skip set up, tear down, and unexported methods. + if isSpecialMethod(m.Name) || !isExportedMethod(m.Name) { + continue + } + + out = append(out, m) + } + + return +} + +func isSpecialMethod(name string) bool { + return (name == "SetUpTestSuite") || + (name == "TearDownTestSuite") || + (name == "SetUp") || + (name == "TearDown") +} + +func isExportedMethod(name string) bool { + return len(name) > 0 && name[0] >= 'A' && name[0] <= 'Z' +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/run_tests.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/run_tests.go new file mode 100644 index 000000000..003aeb019 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/run_tests.go @@ -0,0 +1,354 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 ogletest + +import ( + "bytes" + "flag" + "fmt" + "os" + "path" + "regexp" + "runtime" + "sync" + "sync/atomic" + "testing" + "time" + + "github.com/smartystreets/assertions/internal/reqtrace" +) + +var fTestFilter = flag.String( + "ogletest.run", + "", + "Regexp for matching tests to run.") + +var fStopEarly = flag.Bool( + "ogletest.stop_early", + false, + "If true, stop after the first failure.") + +// runTestsOnce protects RunTests from executing multiple times. +var runTestsOnce sync.Once + +func isAbortError(x interface{}) bool { + _, ok := x.(abortError) + return ok +} + +// Run a single test function, returning a slice of failure records. +func runTestFunction(tf TestFunction) (failures []FailureRecord) { + // Set up a clean slate for this test. Make sure to reset it after everything + // below is finished, so we don't accidentally use it elsewhere. + currentlyRunningTest = newTestInfo() + defer func() { + currentlyRunningTest = nil + }() + + ti := currentlyRunningTest + + // Start a trace. + var reportOutcome reqtrace.ReportFunc + ti.Ctx, reportOutcome = reqtrace.Trace(ti.Ctx, tf.Name) + + // Run the SetUp function, if any, paying attention to whether it panics. + setUpPanicked := false + if tf.SetUp != nil { + setUpPanicked = runWithProtection(func() { tf.SetUp(ti) }) + } + + // Run the test function itself, but only if the SetUp function didn't panic. + // (This includes AssertThat errors.) + if !setUpPanicked { + runWithProtection(tf.Run) + } + + // Run the TearDown function, if any. + if tf.TearDown != nil { + runWithProtection(tf.TearDown) + } + + // Tell the mock controller for the tests to report any errors it's sitting + // on. + ti.MockController.Finish() + + // Report the outcome to reqtrace. + if len(ti.failureRecords) == 0 { + reportOutcome(nil) + } else { + reportOutcome(fmt.Errorf("%v failure records", len(ti.failureRecords))) + } + + return ti.failureRecords +} + +// Run everything registered with Register (including via the wrapper +// RegisterTestSuite). +// +// Failures are communicated to the supplied testing.T object. This is the +// bridge between ogletest and the testing package (and `go test`); you should +// ensure that it's called at least once by creating a test function compatible +// with `go test` and calling it there. +// +// For example: +// +// import ( +// "github.com/smartystreets/assertions/internal/ogletest" +// "testing" +// ) +// +// func TestOgletest(t *testing.T) { +// ogletest.RunTests(t) +// } +// +func RunTests(t *testing.T) { + runTestsOnce.Do(func() { runTestsInternal(t) }) +} + +// Signalling between RunTests and StopRunningTests. +var gStopRunning uint64 + +// Request that RunTests stop what it's doing. After the currently running test +// is finished, including tear-down, the program will exit with an error code. +func StopRunningTests() { + atomic.StoreUint64(&gStopRunning, 1) +} + +// runTestsInternal does the real work of RunTests, which simply wraps it in a +// sync.Once. +func runTestsInternal(t *testing.T) { + // Process each registered suite. + for _, suite := range registeredSuites { + // Stop now if we've already seen a failure and we've been told to stop + // early. + if t.Failed() && *fStopEarly { + break + } + + // Print a banner. + fmt.Printf("[----------] Running tests from %s\n", suite.Name) + + // Run the SetUp function, if any. + if suite.SetUp != nil { + suite.SetUp() + } + + // Run each test function that the user has not told us to skip. + stoppedEarly := false + for _, tf := range filterTestFunctions(suite) { + // Did the user request that we stop running tests? If so, skip the rest + // of this suite (and exit after tearing it down). + if atomic.LoadUint64(&gStopRunning) != 0 { + stoppedEarly = true + break + } + + // Print a banner for the start of this test function. + fmt.Printf("[ RUN ] %s.%s\n", suite.Name, tf.Name) + + // Run the test function. + startTime := time.Now() + failures := runTestFunction(tf) + runDuration := time.Since(startTime) + + // Print any failures, and mark the test as having failed if there are any. + for _, record := range failures { + t.Fail() + fmt.Printf( + "%s:%d:\n%s\n\n", + record.FileName, + record.LineNumber, + record.Error) + } + + // Print a banner for the end of the test. + bannerMessage := "[ OK ]" + if len(failures) != 0 { + bannerMessage = "[ FAILED ]" + } + + // Print a summary of the time taken, if long enough. + var timeMessage string + if runDuration >= 25*time.Millisecond { + timeMessage = fmt.Sprintf(" (%s)", runDuration.String()) + } + + fmt.Printf( + "%s %s.%s%s\n", + bannerMessage, + suite.Name, + tf.Name, + timeMessage) + + // Stop running tests from this suite if we've been told to stop early + // and this test failed. + if t.Failed() && *fStopEarly { + break + } + } + + // Run the suite's TearDown function, if any. + if suite.TearDown != nil { + suite.TearDown() + } + + // Were we told to exit early? + if stoppedEarly { + fmt.Println("Exiting early due to user request.") + os.Exit(1) + } + + fmt.Printf("[----------] Finished with tests from %s\n", suite.Name) + } +} + +// Return true iff the supplied program counter appears to lie within panic(). +func isPanic(pc uintptr) bool { + f := runtime.FuncForPC(pc) + if f == nil { + return false + } + + return f.Name() == "runtime.gopanic" || f.Name() == "runtime.sigpanic" +} + +// Find the deepest stack frame containing something that appears to be a +// panic. Return the 'skip' value that a caller to this function would need +// to supply to runtime.Caller for that frame, or a negative number if not found. +func findPanic() int { + localSkip := -1 + for i := 0; ; i++ { + // Stop if we've passed the base of the stack. + pc, _, _, ok := runtime.Caller(i) + if !ok { + break + } + + // Is this a panic? + if isPanic(pc) { + localSkip = i + } + } + + return localSkip - 1 +} + +// Attempt to find the file base name and line number for the ultimate source +// of a panic, on the panicking stack. Return a human-readable sentinel if +// unsuccessful. +func findPanicFileLine() (string, int) { + panicSkip := findPanic() + if panicSkip < 0 { + return "(unknown)", 0 + } + + // Find the trigger of the panic. + _, file, line, ok := runtime.Caller(panicSkip + 1) + if !ok { + return "(unknown)", 0 + } + + return path.Base(file), line +} + +// Run the supplied function, catching panics (including AssertThat errors) and +// reporting them to the currently-running test as appropriate. Return true iff +// the function panicked. +func runWithProtection(f func()) (panicked bool) { + defer func() { + // If the test didn't panic, we're done. + r := recover() + if r == nil { + return + } + + panicked = true + + // We modify the currently running test below. + currentlyRunningTest.mu.Lock() + defer currentlyRunningTest.mu.Unlock() + + // If the function panicked (and the panic was not due to an AssertThat + // failure), add a failure for the panic. + if !isAbortError(r) { + var panicRecord FailureRecord + panicRecord.FileName, panicRecord.LineNumber = findPanicFileLine() + panicRecord.Error = fmt.Sprintf( + "panic: %v\n\n%s", r, formatPanicStack()) + + currentlyRunningTest.failureRecords = append( + currentlyRunningTest.failureRecords, + panicRecord) + } + }() + + f() + return +} + +func formatPanicStack() string { + buf := new(bytes.Buffer) + + // Find the panic. If successful, we'll skip to below it. Otherwise, we'll + // format everything. + var initialSkip int + if panicSkip := findPanic(); panicSkip >= 0 { + initialSkip = panicSkip + 1 + } + + for i := initialSkip; ; i++ { + pc, file, line, ok := runtime.Caller(i) + if !ok { + break + } + + // Choose a function name to display. + funcName := "(unknown)" + if f := runtime.FuncForPC(pc); f != nil { + funcName = f.Name() + } + + // Stop if we've gotten as far as the test runner code. + if funcName == "github.com/smartystreets/assertions/internal/ogletest.runTestMethod" || + funcName == "github.com/smartystreets/assertions/internal/ogletest.runWithProtection" { + break + } + + // Add an entry for this frame. + fmt.Fprintf(buf, "%s\n\t%s:%d\n", funcName, file, line) + } + + return buf.String() +} + +// Filter test functions according to the user-supplied filter flag. +func filterTestFunctions(suite TestSuite) (out []TestFunction) { + re, err := regexp.Compile(*fTestFilter) + if err != nil { + panic("Invalid value for --ogletest.run: " + err.Error()) + } + + for _, tf := range suite.TestFunctions { + fullName := fmt.Sprintf("%s.%s", suite.Name, tf.Name) + if !re.MatchString(fullName) { + continue + } + + out = append(out, tf) + } + + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/docs.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/docs.go new file mode 100644 index 000000000..d9b9bc8e5 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/docs.go @@ -0,0 +1,5 @@ +// Copyright 2015 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) + +// Functions for working with source code. +package srcutil diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods.go new file mode 100644 index 000000000..a8c5828ea --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods.go @@ -0,0 +1,65 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 srcutil + +import ( + "fmt" + "reflect" + "runtime" + "sort" +) + +func getLine(m reflect.Method) int { + pc := m.Func.Pointer() + + f := runtime.FuncForPC(pc) + if f == nil { + panic(fmt.Sprintf("Couldn't get runtime func for method (pc=%d): %v", pc, m)) + } + + _, line := f.FileLine(pc) + return line +} + +type sortableMethodSet []reflect.Method + +func (s sortableMethodSet) Len() int { + return len(s) +} + +func (s sortableMethodSet) Less(i, j int) bool { + return getLine(s[i]) < getLine(s[j]) +} + +func (s sortableMethodSet) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} + +// Given a type t, return all of the methods of t sorted such that source file +// order is preserved. Order across files is undefined. Order within lines is +// undefined. +func GetMethodsInSourceOrder(t reflect.Type) []reflect.Method { + // Build the list of methods. + methods := sortableMethodSet{} + for i := 0; i < t.NumMethod(); i++ { + methods = append(methods, t.Method(i)) + } + + // Sort it. + sort.Sort(methods) + + return methods +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods_test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods_test.go new file mode 100644 index 000000000..95c07fd46 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods_test.go @@ -0,0 +1,107 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 srcutil_test + +import ( + "fmt" + "reflect" + "testing" + + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" + "github.com/smartystreets/assertions/internal/ogletest/srcutil" +) + +func TestRegisterMethodsTest(t *testing.T) { RunTests(t) } + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type MethodsTest struct { +} + +func init() { RegisterTestSuite(&MethodsTest{}) } + +type OneMethodType int + +func (x OneMethodType) Foo() {} + +type MultipleMethodsType int + +func (x MultipleMethodsType) Foo() {} +func (x MultipleMethodsType) Bar() {} +func (x MultipleMethodsType) Baz() {} + +type methodNameMatcher struct { + expected string +} + +func (m *methodNameMatcher) Description() string { + return fmt.Sprintf("method named %s", m.expected) +} + +func (m *methodNameMatcher) Matches(x interface{}) error { + method, ok := x.(reflect.Method) + if !ok { + panic("Invalid argument.") + } + + if method.Name != m.expected { + return fmt.Errorf("whose name is %s", method.Name) + } + + return nil +} + +func NameIs(name string) Matcher { + return &methodNameMatcher{name} +} + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *MethodsTest) NoMethods() { + type foo int + + methods := srcutil.GetMethodsInSourceOrder(reflect.TypeOf(foo(17))) + ExpectThat(methods, ElementsAre()) +} + +func (t *MethodsTest) OneMethod() { + methods := srcutil.GetMethodsInSourceOrder(reflect.TypeOf(OneMethodType(17))) + ExpectThat( + methods, + ElementsAre( + NameIs("Foo"), + )) +} + +func (t *MethodsTest) MultipleMethods() { + methods := srcutil.GetMethodsInSourceOrder(reflect.TypeOf(MultipleMethodsType(17))) + ExpectThat( + methods, + ElementsAre( + NameIs("Foo"), + NameIs("Bar"), + NameIs("Baz"), + )) + + ExpectEq("Foo", methods[0].Name) + ExpectEq("Bar", methods[1].Name) + ExpectEq("Baz", methods[2].Name) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/failing.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/failing.test.go new file mode 100644 index 000000000..17c50e194 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/failing.test.go @@ -0,0 +1,252 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "fmt" + "testing" + + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +func TestFailingTest(t *testing.T) { RunTests(t) } + +//////////////////////////////////////////////////////////////////////// +// Usual failures +//////////////////////////////////////////////////////////////////////// + +type FailingTest struct { +} + +var _ TearDownInterface = &FailingTest{} +var _ TearDownTestSuiteInterface = &FailingTest{} + +func init() { RegisterTestSuite(&FailingTest{}) } + +func (t *FailingTest) TearDown() { + fmt.Println("TearDown running.") +} + +func (t *FailingTest) TearDownTestSuite() { + fmt.Println("TearDownTestSuite running.") +} + +func (t *FailingTest) PassingMethod() { +} + +func (t *FailingTest) Equals() { + ExpectThat(17, Equals(17.5)) + ExpectThat(17, Equals("taco")) +} + +func (t *FailingTest) LessThan() { + ExpectThat(18, LessThan(17)) + ExpectThat(18, LessThan("taco")) +} + +func (t *FailingTest) HasSubstr() { + ExpectThat("taco", HasSubstr("ac")) + ExpectThat(17, HasSubstr("ac")) +} + +func (t *FailingTest) ExpectWithUserErrorMessages() { + ExpectThat(17, Equals(19), "foo bar: %d", 112) + ExpectEq(17, 17.5, "foo bar: %d", 112) + ExpectLe(17, 16.9, "foo bar: %d", 112) + ExpectLt(17, 16.9, "foo bar: %d", 112) + ExpectGe(17, 17.1, "foo bar: %d", 112) + ExpectGt(17, "taco", "foo bar: %d", 112) + ExpectNe(17, 17.0, "foo bar: %d", 112) + ExpectFalse(true, "foo bar: %d", 112) + ExpectTrue(false, "foo bar: %d", 112) +} + +func (t *FailingTest) AssertWithUserErrorMessages() { + AssertThat(17, Equals(19), "foo bar: %d", 112) +} + +func (t *FailingTest) ExpectationAliases() { + ExpectEq(17, 17.5) + ExpectEq("taco", 17.5) + + ExpectLe(17, 16.9) + ExpectLt(17, 16.9) + ExpectLt(17, "taco") + + ExpectGe(17, 17.1) + ExpectGt(17, 17.1) + ExpectGt(17, "taco") + + ExpectNe(17, 17.0) + ExpectNe(17, "taco") + + ExpectFalse(true) + ExpectFalse("taco") + + ExpectTrue(false) + ExpectTrue("taco") +} + +func (t *FailingTest) AssertThatFailure() { + AssertThat(17, Equals(19)) + panic("Shouldn't get here.") +} + +func (t *FailingTest) AssertEqFailure() { + AssertEq(19, 17) + panic("Shouldn't get here.") +} + +func (t *FailingTest) AssertNeFailure() { + AssertNe(19, 19) + panic("Shouldn't get here.") +} + +func (t *FailingTest) AssertLeFailure() { + AssertLe(19, 17) + panic("Shouldn't get here.") +} + +func (t *FailingTest) AssertLtFailure() { + AssertLt(19, 17) + panic("Shouldn't get here.") +} + +func (t *FailingTest) AssertGeFailure() { + AssertGe(17, 19) + panic("Shouldn't get here.") +} + +func (t *FailingTest) AssertGtFailure() { + AssertGt(17, 19) + panic("Shouldn't get here.") +} + +func (t *FailingTest) AssertTrueFailure() { + AssertTrue("taco") + panic("Shouldn't get here.") +} + +func (t *FailingTest) AssertFalseFailure() { + AssertFalse("taco") + panic("Shouldn't get here.") +} + +func (t *FailingTest) AddFailureRecord() { + r := FailureRecord{ + FileName: "foo.go", + LineNumber: 17, + Error: "taco\nburrito", + } + + AddFailureRecord(r) +} + +func (t *FailingTest) AddFailure() { + AddFailure("taco") + AddFailure("burrito: %d", 17) +} + +func (t *FailingTest) AddFailureThenAbortTest() { + AddFailure("enchilada") + AbortTest() + fmt.Println("Shouldn't get here.") +} + +//////////////////////////////////////////////////////////////////////// +// Expectation failure during SetUp +//////////////////////////////////////////////////////////////////////// + +type ExpectFailDuringSetUpTest struct { +} + +func init() { RegisterTestSuite(&ExpectFailDuringSetUpTest{}) } + +func (t *ExpectFailDuringSetUpTest) SetUp(i *TestInfo) { + ExpectFalse(true) +} + +func (t *ExpectFailDuringSetUpTest) TearDown() { + fmt.Println("TearDown running.") +} + +func (t *ExpectFailDuringSetUpTest) PassingMethod() { + fmt.Println("Method running.") +} + +//////////////////////////////////////////////////////////////////////// +// Assertion failure during SetUp +//////////////////////////////////////////////////////////////////////// + +type AssertFailDuringSetUpTest struct { +} + +func init() { RegisterTestSuite(&AssertFailDuringSetUpTest{}) } + +func (t *AssertFailDuringSetUpTest) SetUp(i *TestInfo) { + AssertFalse(true) +} + +func (t *AssertFailDuringSetUpTest) TearDown() { + fmt.Println("TearDown running.") +} + +func (t *AssertFailDuringSetUpTest) PassingMethod() { + fmt.Println("Method running.") +} + +//////////////////////////////////////////////////////////////////////// +// Expectation failure during TearDown +//////////////////////////////////////////////////////////////////////// + +type ExpectFailDuringTearDownTest struct { +} + +func init() { RegisterTestSuite(&ExpectFailDuringTearDownTest{}) } + +func (t *ExpectFailDuringTearDownTest) SetUp(i *TestInfo) { + fmt.Println("SetUp running.") +} + +func (t *ExpectFailDuringTearDownTest) TearDown() { + ExpectFalse(true) +} + +func (t *ExpectFailDuringTearDownTest) PassingMethod() { + fmt.Println("Method running.") +} + +//////////////////////////////////////////////////////////////////////// +// Assertion failure during TearDown +//////////////////////////////////////////////////////////////////////// + +type AssertFailDuringTearDownTest struct { +} + +func init() { RegisterTestSuite(&AssertFailDuringTearDownTest{}) } + +func (t *AssertFailDuringTearDownTest) SetUp(i *TestInfo) { + fmt.Println("SetUp running.") +} + +func (t *AssertFailDuringTearDownTest) TearDown() { + AssertFalse(true) +} + +func (t *AssertFailDuringTearDownTest) PassingMethod() { + fmt.Println("Method running.") +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/filtered.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/filtered.test.go new file mode 100644 index 000000000..e559c5f92 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/filtered.test.go @@ -0,0 +1,79 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "fmt" + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" + "testing" +) + +func TestFiltered(t *testing.T) { RunTests(t) } + +//////////////////////////////////////////////////////////////////////// +// Partially filtered out +//////////////////////////////////////////////////////////////////////// + +type PartiallyFilteredTest struct { +} + +func init() { RegisterTestSuite(&PartiallyFilteredTest{}) } + +func (t *PartiallyFilteredTest) PassingTestFoo() { + ExpectThat(19, Equals(19)) +} + +func (t *PartiallyFilteredTest) PassingTestBar() { + ExpectThat(17, Equals(17)) +} + +func (t *PartiallyFilteredTest) PartiallyFilteredTestFoo() { + ExpectThat(18, LessThan(17)) +} + +func (t *PartiallyFilteredTest) PartiallyFilteredTestBar() { + ExpectThat("taco", HasSubstr("blah")) +} + +func (t *PartiallyFilteredTest) PartiallyFilteredTestBaz() { + ExpectThat(18, LessThan(17)) +} + +//////////////////////////////////////////////////////////////////////// +// Completely filtered out +//////////////////////////////////////////////////////////////////////// + +type CompletelyFilteredTest struct { +} + +func init() { RegisterTestSuite(&CompletelyFilteredTest{}) } + +func (t *CompletelyFilteredTest) SetUpTestSuite() { + fmt.Println("SetUpTestSuite run!") +} + +func (t *CompletelyFilteredTest) TearDownTestSuite() { + fmt.Println("TearDownTestSuite run!") +} + +func (t *PartiallyFilteredTest) SomePassingTest() { + ExpectThat(19, Equals(19)) +} + +func (t *PartiallyFilteredTest) SomeFailingTest() { + ExpectThat(19, Equals(17)) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.failing_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.failing_test new file mode 100644 index 000000000..f0cd76af5 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.failing_test @@ -0,0 +1,278 @@ +[----------] Running tests from FailingTest +[ RUN ] FailingTest.PassingMethod +TearDown running. +[ OK ] FailingTest.PassingMethod +[ RUN ] FailingTest.Equals +TearDown running. +failing_test.go:52: +Expected: 17.5 +Actual: 17 + +failing_test.go:53: +Expected: taco +Actual: 17, which is not a string + +[ FAILED ] FailingTest.Equals +[ RUN ] FailingTest.LessThan +TearDown running. +failing_test.go:57: +Expected: less than 17 +Actual: 18 + +failing_test.go:58: +Expected: less than "taco" +Actual: 18, which is not comparable + +[ FAILED ] FailingTest.LessThan +[ RUN ] FailingTest.HasSubstr +TearDown running. +failing_test.go:63: +Expected: has substring "ac" +Actual: 17, which is not a string + +[ FAILED ] FailingTest.HasSubstr +[ RUN ] FailingTest.ExpectWithUserErrorMessages +TearDown running. +failing_test.go:67: +Expected: 19 +Actual: 17 +foo bar: 112 + +failing_test.go:68: +Expected: 17 +Actual: 17.5 +foo bar: 112 + +failing_test.go:69: +Expected: less than or equal to 16.9 +Actual: 17 +foo bar: 112 + +failing_test.go:70: +Expected: less than 16.9 +Actual: 17 +foo bar: 112 + +failing_test.go:71: +Expected: greater than or equal to 17.1 +Actual: 17 +foo bar: 112 + +failing_test.go:72: +Expected: greater than "taco" +Actual: 17, which is not comparable +foo bar: 112 + +failing_test.go:73: +Expected: not(17) +Actual: 17 +foo bar: 112 + +failing_test.go:74: +Expected: false +Actual: true +foo bar: 112 + +failing_test.go:75: +Expected: true +Actual: false +foo bar: 112 + +[ FAILED ] FailingTest.ExpectWithUserErrorMessages +[ RUN ] FailingTest.AssertWithUserErrorMessages +TearDown running. +failing_test.go:79: +Expected: 19 +Actual: 17 +foo bar: 112 + +[ FAILED ] FailingTest.AssertWithUserErrorMessages +[ RUN ] FailingTest.ExpectationAliases +TearDown running. +failing_test.go:83: +Expected: 17 +Actual: 17.5 + +failing_test.go:84: +Expected: taco +Actual: 17.5, which is not a string + +failing_test.go:86: +Expected: less than or equal to 16.9 +Actual: 17 + +failing_test.go:87: +Expected: less than 16.9 +Actual: 17 + +failing_test.go:88: +Expected: less than "taco" +Actual: 17, which is not comparable + +failing_test.go:90: +Expected: greater than or equal to 17.1 +Actual: 17 + +failing_test.go:91: +Expected: greater than 17.1 +Actual: 17 + +failing_test.go:92: +Expected: greater than "taco" +Actual: 17, which is not comparable + +failing_test.go:94: +Expected: not(17) +Actual: 17 + +failing_test.go:95: +Expected: not(17) +Actual: taco, which is not numeric + +failing_test.go:97: +Expected: false +Actual: true + +failing_test.go:98: +Expected: false +Actual: taco, which is not a bool + +failing_test.go:100: +Expected: true +Actual: false + +failing_test.go:101: +Expected: true +Actual: taco, which is not a bool + +[ FAILED ] FailingTest.ExpectationAliases +[ RUN ] FailingTest.AssertThatFailure +TearDown running. +failing_test.go:105: +Expected: 19 +Actual: 17 + +[ FAILED ] FailingTest.AssertThatFailure +[ RUN ] FailingTest.AssertEqFailure +TearDown running. +failing_test.go:110: +Expected: 19 +Actual: 17 + +[ FAILED ] FailingTest.AssertEqFailure +[ RUN ] FailingTest.AssertNeFailure +TearDown running. +failing_test.go:115: +Expected: not(19) +Actual: 19 + +[ FAILED ] FailingTest.AssertNeFailure +[ RUN ] FailingTest.AssertLeFailure +TearDown running. +failing_test.go:120: +Expected: less than or equal to 17 +Actual: 19 + +[ FAILED ] FailingTest.AssertLeFailure +[ RUN ] FailingTest.AssertLtFailure +TearDown running. +failing_test.go:125: +Expected: less than 17 +Actual: 19 + +[ FAILED ] FailingTest.AssertLtFailure +[ RUN ] FailingTest.AssertGeFailure +TearDown running. +failing_test.go:130: +Expected: greater than or equal to 19 +Actual: 17 + +[ FAILED ] FailingTest.AssertGeFailure +[ RUN ] FailingTest.AssertGtFailure +TearDown running. +failing_test.go:135: +Expected: greater than 19 +Actual: 17 + +[ FAILED ] FailingTest.AssertGtFailure +[ RUN ] FailingTest.AssertTrueFailure +TearDown running. +failing_test.go:140: +Expected: true +Actual: taco, which is not a bool + +[ FAILED ] FailingTest.AssertTrueFailure +[ RUN ] FailingTest.AssertFalseFailure +TearDown running. +failing_test.go:145: +Expected: false +Actual: taco, which is not a bool + +[ FAILED ] FailingTest.AssertFalseFailure +[ RUN ] FailingTest.AddFailureRecord +TearDown running. +foo.go:17: +taco +burrito + +[ FAILED ] FailingTest.AddFailureRecord +[ RUN ] FailingTest.AddFailure +TearDown running. +failing_test.go:160: +taco + +failing_test.go:161: +burrito: 17 + +[ FAILED ] FailingTest.AddFailure +[ RUN ] FailingTest.AddFailureThenAbortTest +TearDown running. +failing_test.go:165: +enchilada + +[ FAILED ] FailingTest.AddFailureThenAbortTest +TearDownTestSuite running. +[----------] Finished with tests from FailingTest +[----------] Running tests from ExpectFailDuringSetUpTest +[ RUN ] ExpectFailDuringSetUpTest.PassingMethod +Method running. +TearDown running. +failing_test.go:180: +Expected: false +Actual: true + +[ FAILED ] ExpectFailDuringSetUpTest.PassingMethod +[----------] Finished with tests from ExpectFailDuringSetUpTest +[----------] Running tests from AssertFailDuringSetUpTest +[ RUN ] AssertFailDuringSetUpTest.PassingMethod +TearDown running. +failing_test.go:201: +Expected: false +Actual: true + +[ FAILED ] AssertFailDuringSetUpTest.PassingMethod +[----------] Finished with tests from AssertFailDuringSetUpTest +[----------] Running tests from ExpectFailDuringTearDownTest +[ RUN ] ExpectFailDuringTearDownTest.PassingMethod +SetUp running. +Method running. +failing_test.go:226: +Expected: false +Actual: true + +[ FAILED ] ExpectFailDuringTearDownTest.PassingMethod +[----------] Finished with tests from ExpectFailDuringTearDownTest +[----------] Running tests from AssertFailDuringTearDownTest +[ RUN ] AssertFailDuringTearDownTest.PassingMethod +SetUp running. +Method running. +failing_test.go:247: +Expected: false +Actual: true + +[ FAILED ] AssertFailDuringTearDownTest.PassingMethod +[----------] Finished with tests from AssertFailDuringTearDownTest +--- FAIL: TestSomething (1.23s) +FAIL +exit status 1 +FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.filtered_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.filtered_test new file mode 100644 index 000000000..39fa69714 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.filtered_test @@ -0,0 +1,24 @@ +[----------] Running tests from PartiallyFilteredTest +[ RUN ] PartiallyFilteredTest.PassingTestBar +[ OK ] PartiallyFilteredTest.PassingTestBar +[ RUN ] PartiallyFilteredTest.PartiallyFilteredTestBar +filtered_test.go:49: +Expected: has substring "blah" +Actual: taco + +[ FAILED ] PartiallyFilteredTest.PartiallyFilteredTestBar +[ RUN ] PartiallyFilteredTest.PartiallyFilteredTestBaz +filtered_test.go:53: +Expected: less than 17 +Actual: 18 + +[ FAILED ] PartiallyFilteredTest.PartiallyFilteredTestBaz +[----------] Finished with tests from PartiallyFilteredTest +[----------] Running tests from CompletelyFilteredTest +SetUpTestSuite run! +TearDownTestSuite run! +[----------] Finished with tests from CompletelyFilteredTest +--- FAIL: TestSomething (1.23s) +FAIL +exit status 1 +FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.mock_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.mock_test new file mode 100644 index 000000000..4ca29791d --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.mock_test @@ -0,0 +1,25 @@ +[----------] Running tests from MockTest +[ RUN ] MockTest.ExpectationSatisfied +[ OK ] MockTest.ExpectationSatisfied +[ RUN ] MockTest.MockExpectationNotSatisfied +/some/path/mock_test.go:56: +Unsatisfied expectation; expected At to be called at least 1 times; called 0 times. + +[ FAILED ] MockTest.MockExpectationNotSatisfied +[ RUN ] MockTest.ExpectCallForUnknownMethod +/some/path/mock_test.go:61: +Unknown method: FooBar + +[ FAILED ] MockTest.ExpectCallForUnknownMethod +[ RUN ] MockTest.UnexpectedCall +/some/path/mock_test.go:65: +Unexpected call to At with args: [11 23] + +[ FAILED ] MockTest.UnexpectedCall +[ RUN ] MockTest.InvokeFunction +[ OK ] MockTest.InvokeFunction +[----------] Finished with tests from MockTest +--- FAIL: TestSomething (1.23s) +FAIL +exit status 1 +FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.no_cases_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.no_cases_test new file mode 100644 index 000000000..863138558 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.no_cases_test @@ -0,0 +1,6 @@ +[----------] Running tests from NoCasesTest +SetUpTestSuite run! +TearDownTestSuite run! +[----------] Finished with tests from NoCasesTest +PASS +ok somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.panicking_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.panicking_test new file mode 100644 index 000000000..32eac65f7 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.panicking_test @@ -0,0 +1,90 @@ +[----------] Running tests from PanickingTest +[ RUN ] PanickingTest.ExplicitPanic +TearDown running. +panicking_test.go:47: +panic: Panic in ExplicitPanic + +github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*PanickingTest).ExplicitPanic + some_file.txt:0 +runtime.call16 + /some/path/asm_amd64.s:401 +reflect.Value.call + some_file.txt:0 +reflect.Value.Call + some_file.txt:0 + + +[ FAILED ] PanickingTest.ExplicitPanic +[ RUN ] PanickingTest.ExplicitPanicInHelperFunction +TearDown running. +panicking_test.go:34: +panic: Panic in someFuncThatPanics + +github.com/smartystreets/assertions/internal/ogletest/somepkg_test.someFuncThatPanics + some_file.txt:0 +github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*PanickingTest).ExplicitPanicInHelperFunction + some_file.txt:0 +runtime.call16 + /some/path/asm_amd64.s:401 +reflect.Value.call + some_file.txt:0 +reflect.Value.Call + some_file.txt:0 + + +[ FAILED ] PanickingTest.ExplicitPanicInHelperFunction +[ RUN ] PanickingTest.NilPointerDerefence +TearDown running. +panicking_test.go:56: +panic: runtime error: invalid memory address or nil pointer dereference + +github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*PanickingTest).NilPointerDerefence + some_file.txt:0 +runtime.call16 + /some/path/asm_amd64.s:401 +reflect.Value.call + some_file.txt:0 +reflect.Value.Call + some_file.txt:0 + + +[ FAILED ] PanickingTest.NilPointerDerefence +[ RUN ] PanickingTest.ZzzSomeOtherTest +TearDown running. +[ OK ] PanickingTest.ZzzSomeOtherTest +[----------] Finished with tests from PanickingTest +[----------] Running tests from SetUpPanicTest +[ RUN ] SetUpPanicTest.SomeTestCase +SetUp about to panic. +TearDown running. +panicking_test.go:74: +panic: Panic in SetUp + +github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*SetUpPanicTest).SetUp + some_file.txt:0 +github.com/smartystreets/assertions/internal/ogletest.func·003 + some_file.txt:0 +github.com/smartystreets/assertions/internal/ogletest.func·007 + some_file.txt:0 + + +[ FAILED ] SetUpPanicTest.SomeTestCase +[----------] Finished with tests from SetUpPanicTest +[----------] Running tests from TearDownPanicTest +[ RUN ] TearDownPanicTest.SomeTestCase +TearDown about to panic. +panicking_test.go:95: +panic: Panic in TearDown + +github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*TearDownPanicTest).TearDown + some_file.txt:0 +github.com/smartystreets/assertions/internal/ogletest.func·005 + some_file.txt:0 + + +[ FAILED ] TearDownPanicTest.SomeTestCase +[----------] Finished with tests from TearDownPanicTest +--- FAIL: TestSomething (1.23s) +FAIL +exit status 1 +FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.passing_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.passing_test new file mode 100644 index 000000000..031128842 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.passing_test @@ -0,0 +1,22 @@ +[----------] Running tests from PassingTest +[ RUN ] PassingTest.EmptyTestMethod +[ OK ] PassingTest.EmptyTestMethod +[ RUN ] PassingTest.SuccessfullMatches +[ OK ] PassingTest.SuccessfullMatches +[ RUN ] PassingTest.ExpectAliases +[ OK ] PassingTest.ExpectAliases +[ RUN ] PassingTest.AssertAliases +[ OK ] PassingTest.AssertAliases +[ RUN ] PassingTest.SlowTest +[ OK ] PassingTest.SlowTest (1234ms) +[----------] Finished with tests from PassingTest +[----------] Running tests from PassingTestWithHelpers +SetUpTestSuite ran. +[ RUN ] PassingTestWithHelpers.EmptyTestMethod +SetUp ran. +TearDown ran. +[ OK ] PassingTestWithHelpers.EmptyTestMethod +TearDownTestSuite ran. +[----------] Finished with tests from PassingTestWithHelpers +PASS +ok somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.run_twice_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.run_twice_test new file mode 100644 index 000000000..0749f9164 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.run_twice_test @@ -0,0 +1,14 @@ +[----------] Running tests from RunTwiceTest +[ RUN ] RunTwiceTest.PassingMethod +[ OK ] RunTwiceTest.PassingMethod +[ RUN ] RunTwiceTest.FailingMethod +run_twice_test.go:46: +Expected: 17.5 +Actual: 17 + +[ FAILED ] RunTwiceTest.FailingMethod +[----------] Finished with tests from RunTwiceTest +--- FAIL: TestSomething (1.23s) +FAIL +exit status 1 +FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.stop_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.stop_test new file mode 100644 index 000000000..e7d42c793 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.stop_test @@ -0,0 +1,13 @@ +[----------] Running tests from StopTest +[ RUN ] StopTest.First +TearDown running. +[ OK ] StopTest.First +[ RUN ] StopTest.Second +About to call StopRunningTests. +Called StopRunningTests. +TearDown running. +[ OK ] StopTest.Second +TearDownTestSuite running. +Exiting early due to user request. +exit status 1 +FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.unexported_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.unexported_test new file mode 100644 index 000000000..6221e65ea --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.unexported_test @@ -0,0 +1,12 @@ +[----------] Running tests from UnexportedTest +[ RUN ] UnexportedTest.SomeTest +unexported_test.go:42: +Expected: 4 +Actual: 3 + +[ FAILED ] UnexportedTest.SomeTest +[----------] Finished with tests from UnexportedTest +--- FAIL: TestSomething (1.23s) +FAIL +exit status 1 +FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock.test.go new file mode 100644 index 000000000..8e0fca9cc --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock.test.go @@ -0,0 +1,82 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + "github.com/smartystreets/assertions/internal/oglemock" + . "github.com/smartystreets/assertions/internal/ogletest" + "github.com/smartystreets/assertions/internal/ogletest/test_cases/mock_image" + "image/color" + "testing" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type MockTest struct { + controller oglemock.Controller + image mock_image.MockImage +} + +func init() { RegisterTestSuite(&MockTest{}) } +func TestMockTest(t *testing.T) { RunTests(t) } + +func (t *MockTest) SetUp(i *TestInfo) { + t.controller = i.MockController + t.image = mock_image.NewMockImage(t.controller, "some mock image") +} + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *MockTest) ExpectationSatisfied() { + ExpectCall(t.image, "At")(11, GreaterThan(19)). + WillOnce(oglemock.Return(color.Gray{0})) + + ExpectThat(t.image.At(11, 23), IdenticalTo(color.Gray{0})) +} + +func (t *MockTest) MockExpectationNotSatisfied() { + ExpectCall(t.image, "At")(11, GreaterThan(19)). + WillOnce(oglemock.Return(color.Gray{0})) +} + +func (t *MockTest) ExpectCallForUnknownMethod() { + ExpectCall(t.image, "FooBar")(11) +} + +func (t *MockTest) UnexpectedCall() { + t.image.At(11, 23) +} + +func (t *MockTest) InvokeFunction() { + var suppliedX, suppliedY int + f := func(x, y int) color.Color { + suppliedX = x + suppliedY = y + return color.Gray{17} + } + + ExpectCall(t.image, "At")(Any(), Any()). + WillOnce(oglemock.Invoke(f)) + + ExpectThat(t.image.At(-1, 12), IdenticalTo(color.Gray{17})) + ExpectEq(-1, suppliedX) + ExpectEq(12, suppliedY) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock_image/mock_image.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock_image/mock_image.go new file mode 100644 index 000000000..a8d55bc48 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock_image/mock_image.go @@ -0,0 +1,115 @@ +// This file was auto-generated using createmock. See the following page for +// more information: +// +// https://github.com/smartystreets/assertions/internal/oglemock +// + +package mock_image + +import ( + fmt "fmt" + oglemock "github.com/smartystreets/assertions/internal/oglemock" + image "image" + color "image/color" + runtime "runtime" + unsafe "unsafe" +) + +type MockImage interface { + image.Image + oglemock.MockObject +} + +type mockImage struct { + controller oglemock.Controller + description string +} + +func NewMockImage( + c oglemock.Controller, + desc string) MockImage { + return &mockImage{ + controller: c, + description: desc, + } +} + +func (m *mockImage) Oglemock_Id() uintptr { + return uintptr(unsafe.Pointer(m)) +} + +func (m *mockImage) Oglemock_Description() string { + return m.description +} + +func (m *mockImage) At(p0 int, p1 int) (o0 color.Color) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "At", + file, + line, + []interface{}{p0, p1}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockImage.At: invalid return values: %v", retVals)) + } + + // o0 color.Color + if retVals[0] != nil { + o0 = retVals[0].(color.Color) + } + + return +} + +func (m *mockImage) Bounds() (o0 image.Rectangle) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "Bounds", + file, + line, + []interface{}{}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockImage.Bounds: invalid return values: %v", retVals)) + } + + // o0 image.Rectangle + if retVals[0] != nil { + o0 = retVals[0].(image.Rectangle) + } + + return +} + +func (m *mockImage) ColorModel() (o0 color.Model) { + // Get a file name and line number for the caller. + _, file, line, _ := runtime.Caller(1) + + // Hand the call off to the controller, which does most of the work. + retVals := m.controller.HandleMethodCall( + m, + "ColorModel", + file, + line, + []interface{}{}) + + if len(retVals) != 1 { + panic(fmt.Sprintf("mockImage.ColorModel: invalid return values: %v", retVals)) + } + + // o0 color.Model + if retVals[0] != nil { + o0 = retVals[0].(color.Model) + } + + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/no_cases.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/no_cases.test.go new file mode 100644 index 000000000..ad204e053 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/no_cases.test.go @@ -0,0 +1,41 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "fmt" + . "github.com/smartystreets/assertions/internal/ogletest" + "testing" +) + +func TestNoCases(t *testing.T) { RunTests(t) } + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type NoCasesTest struct { +} + +func init() { RegisterTestSuite(&NoCasesTest{}) } + +func (t *NoCasesTest) SetUpTestSuite() { + fmt.Println("SetUpTestSuite run!") +} + +func (t *NoCasesTest) TearDownTestSuite() { + fmt.Println("TearDownTestSuite run!") +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/panicking.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/panicking.test.go new file mode 100644 index 000000000..59d1fe3ba --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/panicking.test.go @@ -0,0 +1,99 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "fmt" + "log" + "testing" + + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +func TestPanickingTest(t *testing.T) { RunTests(t) } + +//////////////////////////////////////////////////////////////////////// +// PanickingTest +//////////////////////////////////////////////////////////////////////// + +func someFuncThatPanics() { + panic("Panic in someFuncThatPanics") +} + +type PanickingTest struct { +} + +func init() { RegisterTestSuite(&PanickingTest{}) } + +func (t *PanickingTest) TearDown() { + fmt.Println("TearDown running.") +} + +func (t *PanickingTest) ExplicitPanic() { + panic("Panic in ExplicitPanic") +} + +func (t *PanickingTest) ExplicitPanicInHelperFunction() { + someFuncThatPanics() +} + +func (t *PanickingTest) NilPointerDerefence() { + var p *int + log.Println(*p) +} + +func (t *PanickingTest) ZzzSomeOtherTest() { + ExpectThat(17, Equals(17.0)) +} + +//////////////////////////////////////////////////////////////////////// +// SetUpPanicTest +//////////////////////////////////////////////////////////////////////// + +type SetUpPanicTest struct { +} + +func init() { RegisterTestSuite(&SetUpPanicTest{}) } + +func (t *SetUpPanicTest) SetUp(ti *TestInfo) { + fmt.Println("SetUp about to panic.") + panic("Panic in SetUp") +} + +func (t *SetUpPanicTest) TearDown() { + fmt.Println("TearDown running.") +} + +func (t *SetUpPanicTest) SomeTestCase() { +} + +//////////////////////////////////////////////////////////////////////// +// TearDownPanicTest +//////////////////////////////////////////////////////////////////////// + +type TearDownPanicTest struct { +} + +func init() { RegisterTestSuite(&TearDownPanicTest{}) } + +func (t *TearDownPanicTest) TearDown() { + fmt.Println("TearDown about to panic.") + panic("Panic in TearDown") +} + +func (t *TearDownPanicTest) SomeTestCase() { +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/passing.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/passing.test.go new file mode 100644 index 000000000..01d8e6344 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/passing.test.go @@ -0,0 +1,120 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "fmt" + "testing" + "time" + + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" +) + +func TestPassingTest(t *testing.T) { RunTests(t) } + +//////////////////////////////////////////////////////////////////////// +// PassingTest +//////////////////////////////////////////////////////////////////////// + +type PassingTest struct { +} + +func init() { RegisterTestSuite(&PassingTest{}) } + +func (t *PassingTest) EmptyTestMethod() { +} + +func (t *PassingTest) SuccessfullMatches() { + ExpectThat(17, Equals(17.0)) + ExpectThat(16.9, LessThan(17)) + ExpectThat("taco", HasSubstr("ac")) + + AssertThat(17, Equals(17.0)) + AssertThat(16.9, LessThan(17)) + AssertThat("taco", HasSubstr("ac")) +} + +func (t *PassingTest) ExpectAliases() { + ExpectEq(17, 17.0) + + ExpectLe(17, 17.0) + ExpectLe(17, 18.0) + ExpectLt(17, 18.0) + + ExpectGe(17, 17.0) + ExpectGe(17, 16.0) + ExpectGt(17, 16.0) + + ExpectNe(17, 18.0) + + ExpectTrue(true) + ExpectFalse(false) +} + +func (t *PassingTest) AssertAliases() { + AssertEq(17, 17.0) + + AssertLe(17, 17.0) + AssertLe(17, 18.0) + AssertLt(17, 18.0) + + AssertGe(17, 17.0) + AssertGe(17, 16.0) + AssertGt(17, 16.0) + + AssertNe(17, 18.0) + + AssertTrue(true) + AssertFalse(false) +} + +func (t *PassingTest) SlowTest() { + time.Sleep(37 * time.Millisecond) +} + +//////////////////////////////////////////////////////////////////////// +// PassingTestWithHelpers +//////////////////////////////////////////////////////////////////////// + +type PassingTestWithHelpers struct { +} + +var _ SetUpTestSuiteInterface = &PassingTestWithHelpers{} +var _ SetUpInterface = &PassingTestWithHelpers{} +var _ TearDownInterface = &PassingTestWithHelpers{} +var _ TearDownTestSuiteInterface = &PassingTestWithHelpers{} + +func init() { RegisterTestSuite(&PassingTestWithHelpers{}) } + +func (t *PassingTestWithHelpers) SetUpTestSuite() { + fmt.Println("SetUpTestSuite ran.") +} + +func (t *PassingTestWithHelpers) SetUp(ti *TestInfo) { + fmt.Println("SetUp ran.") +} + +func (t *PassingTestWithHelpers) TearDown() { + fmt.Println("TearDown ran.") +} + +func (t *PassingTestWithHelpers) TearDownTestSuite() { + fmt.Println("TearDownTestSuite ran.") +} + +func (t *PassingTestWithHelpers) EmptyTestMethod() { +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/run_twice.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/run_twice.test.go new file mode 100644 index 000000000..a3a36c175 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/run_twice.test.go @@ -0,0 +1,47 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" + "testing" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type RunTwiceTest struct { +} + +func init() { RegisterTestSuite(&RunTwiceTest{}) } + +// Set up two helpers that call RunTests. The test should still only be run +// once. +func TestOgletest(t *testing.T) { RunTests(t) } +func TestOgletest2(t *testing.T) { RunTests(t) } + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *RunTwiceTest) PassingMethod() { +} + +func (t *RunTwiceTest) FailingMethod() { + ExpectThat(17, Equals(17.5)) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/stop.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/stop.test.go new file mode 100644 index 000000000..a008c081e --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/stop.test.go @@ -0,0 +1,61 @@ +// Copyright 2015 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + "fmt" + "testing" + + . "github.com/smartystreets/assertions/internal/ogletest" +) + +func TestStop(t *testing.T) { RunTests(t) } + +//////////////////////////////////////////////////////////////////////// +// Boilerplate +//////////////////////////////////////////////////////////////////////// + +type StopTest struct { +} + +var _ TearDownInterface = &StopTest{} +var _ TearDownTestSuiteInterface = &StopTest{} + +func init() { RegisterTestSuite(&StopTest{}) } + +func (t *StopTest) TearDown() { + fmt.Println("TearDown running.") +} + +func (t *StopTest) TearDownTestSuite() { + fmt.Println("TearDownTestSuite running.") +} + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *StopTest) First() { +} + +func (t *StopTest) Second() { + fmt.Println("About to call StopRunningTests.") + StopRunningTests() + fmt.Println("Called StopRunningTests.") +} + +func (t *StopTest) Third() { +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/unexported.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/unexported.test.go new file mode 100644 index 000000000..a425e78d4 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/unexported.test.go @@ -0,0 +1,43 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 oglematchers_test + +import ( + . "github.com/smartystreets/assertions/internal/oglematchers" + . "github.com/smartystreets/assertions/internal/ogletest" + "testing" +) + +//////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////// + +type UnexportedTest struct { +} + +func init() { RegisterTestSuite(&UnexportedTest{}) } +func TestUnexportedTest(t *testing.T) { RunTests(t) } + +func (t *UnexportedTest) someUnexportedMethod() { +} + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func (t *UnexportedTest) SomeTest() { + ExpectThat(3, Equals(4)) +} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_info.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_info.go new file mode 100644 index 000000000..3ae12526b --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_info.go @@ -0,0 +1,91 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// 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 ogletest + +import ( + "sync" + + "golang.org/x/net/context" + + "github.com/smartystreets/assertions/internal/oglemock" +) + +// TestInfo represents information about a currently running or previously-run +// test. +type TestInfo struct { + // A mock controller that is set up to report errors to the ogletest test + // runner. This can be used for setting up mock expectations and handling + // mock calls. The Finish method should not be run by the user; ogletest will + // do that automatically after the test's TearDown method is run. + // + // Note that this feature is still experimental, and is subject to change. + MockController oglemock.Controller + + // A context that can be used by tests for long-running operations. In + // particular, this enables conveniently tracing the execution of a test + // function with reqtrace. + Ctx context.Context + + // A mutex protecting shared state. + mu sync.RWMutex + + // A set of failure records that the test has produced. + // + // GUARDED_BY(mu) + failureRecords []FailureRecord +} + +// currentlyRunningTest is the state for the currently running test, if any. +var currentlyRunningTest *TestInfo + +// newTestInfo creates a valid but empty TestInfo struct. +func newTestInfo() (info *TestInfo) { + info = &TestInfo{} + info.MockController = oglemock.NewController(&testInfoErrorReporter{info}) + info.Ctx = context.Background() + + return +} + +// testInfoErrorReporter is an oglemock.ErrorReporter that writes failure +// records into a test info struct. +type testInfoErrorReporter struct { + testInfo *TestInfo +} + +func (r *testInfoErrorReporter) ReportError( + fileName string, + lineNumber int, + err error) { + r.testInfo.mu.Lock() + defer r.testInfo.mu.Unlock() + + record := FailureRecord{ + FileName: fileName, + LineNumber: lineNumber, + Error: err.Error(), + } + + r.testInfo.failureRecords = append(r.testInfo.failureRecords, record) +} + +func (r *testInfoErrorReporter) ReportFatalError( + fileName string, + lineNumber int, + err error) { + r.ReportError(fileName, lineNumber, err) + AbortTest() +} diff --git a/vendor/github.com/smartystreets/assertions/internal/reqtrace/.gitignore b/vendor/github.com/smartystreets/assertions/internal/reqtrace/.gitignore new file mode 100644 index 000000000..daf913b1b --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/reqtrace/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/vendor/github.com/smartystreets/assertions/internal/reqtrace/LICENSE b/vendor/github.com/smartystreets/assertions/internal/reqtrace/LICENSE new file mode 100644 index 000000000..8f71f43fe --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/reqtrace/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. + diff --git a/vendor/github.com/smartystreets/assertions/internal/reqtrace/README.md b/vendor/github.com/smartystreets/assertions/internal/reqtrace/README.md new file mode 100644 index 000000000..4392452b5 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/reqtrace/README.md @@ -0,0 +1,53 @@ +[![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/reqtrace?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/reqtrace) + +reqtrace is a package for simple request tracing. It requires nothing of its +user except: + + * They must use [golang.org/x/net/context][context]. + * They must add a single line to each function they want to be visible in + traces. + +[context]: http://godoc.org/golang.org/x/net/context + +In particular, reqtrace is console-based and doesn't require an HTTP server. + +**Warning**: This package is still barebones and in its early days. I reserve +the right to make backwards-incompatible changes to its API. But if it's useful +to you in your current form, have at it. + +## Use + +Call reqtrace.Trace anywhere you want to start a new root trace. (This is +probably where you create your root context.) This returns a new context that +you should pass to child operations, and a reporting function that you must use +to inform reqtrace when the trace is complete. + +For example: + +```Go +func HandleRequest(r *someRequest) (err error) { + ctx, report := reqtrace.Trace(context.Background(), "HandleRequest") + defer func() { report(err) }() + + // Do two things for this request. + DoSomething(ctx, r) + DoSomethingElse(ctx, r) +} +``` + +Within other functions that you want to show up in the trace, you +reqtrace.StartSpan (or its more convenient sibling reqtrace.StartSpanWithError): + +```Go +func DoSomething(ctx context.Context, r *someRequest) (err error) { + defer reqtrace.StartSpanWithError(&ctx, &err, "DoSomething")() + + // Process the request somehow using ctx. If downstream code also annotes + // using reqtrace, reqtrace will know that its spans are descendants of + // this one. + CallAnotherLibrary(ctx, r.Param) +} +``` + +When `--reqtrace.enable` is set, the completion of a trace will cause helpful +ASCII art to be spit out. diff --git a/vendor/github.com/smartystreets/assertions/internal/reqtrace/reqtrace.go b/vendor/github.com/smartystreets/assertions/internal/reqtrace/reqtrace.go new file mode 100644 index 000000000..853c02424 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/reqtrace/reqtrace.go @@ -0,0 +1,132 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package reqtrace contains a very simple request tracing framework. +package reqtrace + +import ( + "flag" + + "golang.org/x/net/context" +) + +type contextKey int + +var fEnabled = flag.Bool("reqtrace.enable", false, "Collect and print traces.") + +// The key used to associate a *traceState with a context. +const traceStateKey contextKey = 0 + +// A function that must be called exactly once to report the outcome of an +// operation represented by a span. +type ReportFunc func(error) + +// Return false only if traces are disabled, i.e. Trace will never cause a +// trace to be initiated. +// +// REQUIRES: flag.Parsed() +func Enabled() (enabled bool) { + enabled = *fEnabled + return +} + +// Begin a span within the current trace. Return a new context that should be +// used for operations that logically occur within the span, and a report +// function that must be called with the outcome of the logical operation +// represented by the span. +// +// If no trace is active, no span will be created but ctx and report will still +// be valid. +func StartSpan( + parent context.Context, + desc string) (ctx context.Context, report ReportFunc) { + // Look for the trace state. + val := parent.Value(traceStateKey) + if val == nil { + // Nothing to do. + ctx = parent + report = func(err error) {} + return + } + + ts := val.(*traceState) + + // Set up the report function. + report = ts.CreateSpan(desc) + + // For now we don't do anything interesting with the context. In the future, + // we may use it to record span hierarchy. + ctx = parent + + return +} + +// A wrapper around StartSpan that can be more convenient to use when the +// lifetime of a span matches the lifetime of a function. Intended to be used +// in a defer statement within a function using a named error return parameter. +// +// Equivalent to calling StartSpan with *ctx, replacing *ctx with the resulting +// new context, then setting f to a function that will invoke the report +// function with the contents of *error at the time that it is called. +// +// Example: +// +// func DoSomething(ctx context.Context) (err error) { +// defer reqtrace.StartSpanWithError(&ctx, &err, "DoSomething")() +// [...] +// } +// +func StartSpanWithError( + ctx *context.Context, + err *error, + desc string) (f func()) { + var report ReportFunc + *ctx, report = StartSpan(*ctx, desc) + f = func() { report(*err) } + return +} + +// Like StartSpan, but begins a root span for a new trace if no trace is active +// in the supplied context and tracing is enabled for the process. +func Trace( + parent context.Context, + desc string) (ctx context.Context, report ReportFunc) { + // If tracing is disabled, this is a no-op. + if !*fEnabled { + ctx = parent + report = func(err error) {} + return + } + + // Is this context already being traced? If so, simply add a span. + if parent.Value(traceStateKey) != nil { + ctx, report = StartSpan(parent, desc) + return + } + + // Set up a new trace state. + ts := new(traceState) + baseReport := ts.CreateSpan(desc) + + // Log when finished. + report = func(err error) { + baseReport(err) + ts.Log() + } + + // Set up the context. + ctx = context.WithValue(parent, traceStateKey, ts) + + return +} diff --git a/vendor/github.com/smartystreets/assertions/internal/reqtrace/trace_state.go b/vendor/github.com/smartystreets/assertions/internal/reqtrace/trace_state.go new file mode 100644 index 000000000..614ef90d8 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/reqtrace/trace_state.go @@ -0,0 +1,175 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package reqtrace + +import ( + "log" + "math" + "os" + "strings" + "sync" + "time" +) + +const logFlags = 0 + +var gLogger = log.New(os.Stderr, "reqtrace: ", logFlags) + +type span struct { + // Fixed at creation. + desc string + start time.Time + + // Updated by report functions. + finished bool + end time.Time + err error +} + +// All of the state for a particular trace root. The zero value is usable. +type traceState struct { + mu sync.Mutex + + // The list of spans associated with this state. Append-only. + // + // GUARDED_BY(mu) + spans []*span +} + +func (ts *traceState) report(spanIndex int, err error) { + ts.mu.Lock() + defer ts.mu.Unlock() + + s := ts.spans[spanIndex] + s.finished = true + s.end = time.Now() + s.err = err +} + +// Associate a new span with the trace. Return a function that will report its +// completion. +func (ts *traceState) CreateSpan(desc string) (report ReportFunc) { + ts.mu.Lock() + defer ts.mu.Unlock() + + index := len(ts.spans) + ts.spans = append(ts.spans, &span{desc: desc, start: time.Now()}) + + report = func(err error) { ts.report(index, err) } + return +} + +func round(x float64) float64 { + if x < 0 { + return math.Ceil(x - 0.5) + } + + return math.Floor(x + 0.5) +} + +// Log information about the spans in this trace. +func (ts *traceState) Log() { + ts.mu.Lock() + defer ts.mu.Unlock() + gLogger.Println() + + // Special case: we require at least one span. + if len(ts.spans) == 0 { + return + } + + // Print a banner for this trace. + const bannerHalfLength = 45 + + gLogger.Println() + gLogger.Printf( + "%s %s %s", + strings.Repeat("=", bannerHalfLength), + ts.spans[0].desc, + strings.Repeat("=", bannerHalfLength)) + gLogger.Printf("Start time: %v", ts.spans[0].start.Format(time.RFC3339Nano)) + gLogger.Println() + + // Find the minimum start time and maximum end time of all durations. + var minStart time.Time + var maxEnd time.Time + for _, s := range ts.spans { + if !s.finished { + continue + } + + if minStart.IsZero() || s.start.Before(minStart) { + minStart = s.start + } + + if maxEnd.Before(s.end) { + maxEnd = s.end + } + } + + // Bail out if something weird happened. + // + // TODO(jacobsa): Be more graceful. + totalDuration := maxEnd.Sub(minStart) + if minStart.IsZero() || maxEnd.IsZero() || totalDuration <= 0 { + gLogger.Println("(Weird trace)") + return + } + + // Calculate the number of nanoseconds elapsed, as a floating point number. + totalNs := float64(totalDuration / time.Nanosecond) + + // Log each span with some ASCII art showing its length relative to the + // total. + const totalNumCols float64 = 120 + for _, s := range ts.spans { + if !s.finished { + gLogger.Printf("(Unfinished: %s)", s.desc) + gLogger.Println() + continue + } + + // Calculate the duration of the span, and its width relative to the + // longest span. + d := s.end.Sub(s.start) + if d <= 0 { + gLogger.Println("(Weird duration)") + gLogger.Println() + continue + } + + durationRatio := float64(d/time.Nanosecond) / totalNs + + // We will offset the label and banner proportional to the time since the + // start of the earliest span. + offsetRatio := float64(s.start.Sub(minStart)/time.Nanosecond) / totalNs + offsetChars := int(round(offsetRatio * totalNumCols)) + offsetStr := strings.Repeat(" ", offsetChars) + + // Print the description and duration. + gLogger.Printf("%s%v", offsetStr, s.desc) + gLogger.Printf("%s%v", offsetStr, d) + + // Print a banner showing the duration graphically. + bannerChars := int(round(durationRatio * totalNumCols)) + var dashes string + if bannerChars > 2 { + dashes = strings.Repeat("-", bannerChars-2) + } + + gLogger.Printf("%s|%s|", offsetStr, dashes) + gLogger.Println() + } +} diff --git a/vendor/github.com/smartystreets/assertions/messages.go b/vendor/github.com/smartystreets/assertions/messages.go index 2756fb0ec..318854546 100644 --- a/vendor/github.com/smartystreets/assertions/messages.go +++ b/vendor/github.com/smartystreets/assertions/messages.go @@ -6,7 +6,8 @@ const ( // equality shouldHaveBeenEqualTypeMismatch = "Expected: '%v' (%T)\nActual: '%v' (%T)\n(Should be equal, type mismatch)" shouldHaveBeenAlmostEqual = "Expected '%v' to almost equal '%v' (but it didn't)!" shouldHaveNotBeenAlmostEqual = "Expected '%v' to NOT almost equal '%v' (but it did)!" - shouldHaveResembled = "Expected: '%s'\nActual: '%s'\n(Should resemble)!" + shouldHaveResembled = "Expected: '%#v'\nActual: '%#v'\n(Should resemble)!" + shouldHaveResembledTypeMismatch = "Expected: '%#v' (%T)\nActual: '%#v' (%T)\n(Should resemble, type mismatch)" shouldNotHaveResembled = "Expected '%#v'\nto NOT resemble '%#v'\n(but it did)!" shouldBePointers = "Both arguments should be pointers " shouldHaveBeenNonNilPointer = shouldBePointers + "(the %s was %s)!" @@ -44,7 +45,7 @@ const ( // collections shouldNotHaveBeenEmpty = "Expected %+v to NOT be empty (but it was)!" shouldHaveBeenAValidInteger = "You must provide a valid integer (was %v)!" shouldHaveBeenAValidLength = "You must provide a valid positive integer (was %v)!" - shouldHaveHadLength = "Expected %+v (length: %v) to have length equal to '%v', but it wasn't!" + shouldHaveHadLength = "Expected %+v to have length equal to '%v', but it wasn't!" ) const ( // strings @@ -77,9 +78,6 @@ const ( // type checking shouldNotHaveImplemented = "Expected '%v'\nto NOT implement '%v'\n(but it did)!" shouldCompareWithInterfacePointer = "The expected value must be a pointer to an interface type (eg. *fmt.Stringer)" shouldNotBeNilActual = "The actual value was 'nil' and should be a value or a pointer to a value!" - - shouldBeError = "Expected an error value (but was '%v' instead)!" - shouldBeErrorInvalidComparisonValue = "The final argument to this assertion must be a string or an error value (you provided: '%v')." ) const ( // time comparisons diff --git a/vendor/github.com/smartystreets/assertions/panic_test.go b/vendor/github.com/smartystreets/assertions/panic_test.go index e3abbf303..15eafac4f 100644 --- a/vendor/github.com/smartystreets/assertions/panic_test.go +++ b/vendor/github.com/smartystreets/assertions/panic_test.go @@ -1,50 +1,53 @@ package assertions -import "fmt" +import ( + "fmt" + "testing" +) -func (this *AssertionsFixture) TestShouldPanic() { - this.fail(so(func() {}, ShouldPanic, 1), "This assertion requires exactly 0 comparison values (you provided 1).") - this.fail(so(func() {}, ShouldPanic, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") +func TestShouldPanic(t *testing.T) { + fail(t, so(func() {}, ShouldPanic, 1), "This assertion requires exactly 0 comparison values (you provided 1).") + fail(t, so(func() {}, ShouldPanic, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") - this.fail(so(1, ShouldPanic), shouldUseVoidNiladicFunction) - this.fail(so(func(i int) {}, ShouldPanic), shouldUseVoidNiladicFunction) - this.fail(so(func() int { panic("hi") }, ShouldPanic), shouldUseVoidNiladicFunction) + fail(t, so(1, ShouldPanic), shouldUseVoidNiladicFunction) + fail(t, so(func(i int) {}, ShouldPanic), shouldUseVoidNiladicFunction) + fail(t, so(func() int { panic("hi") }, ShouldPanic), shouldUseVoidNiladicFunction) - this.fail(so(func() {}, ShouldPanic), shouldHavePanicked) - this.pass(so(func() { panic("hi") }, ShouldPanic)) + fail(t, so(func() {}, ShouldPanic), shouldHavePanicked) + pass(t, so(func() { panic("hi") }, ShouldPanic)) } -func (this *AssertionsFixture) TestShouldNotPanic() { - this.fail(so(func() {}, ShouldNotPanic, 1), "This assertion requires exactly 0 comparison values (you provided 1).") - this.fail(so(func() {}, ShouldNotPanic, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") +func TestShouldNotPanic(t *testing.T) { + fail(t, so(func() {}, ShouldNotPanic, 1), "This assertion requires exactly 0 comparison values (you provided 1).") + fail(t, so(func() {}, ShouldNotPanic, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") - this.fail(so(1, ShouldNotPanic), shouldUseVoidNiladicFunction) - this.fail(so(func(i int) {}, ShouldNotPanic), shouldUseVoidNiladicFunction) + fail(t, so(1, ShouldNotPanic), shouldUseVoidNiladicFunction) + fail(t, so(func(i int) {}, ShouldNotPanic), shouldUseVoidNiladicFunction) - this.fail(so(func() { panic("hi") }, ShouldNotPanic), fmt.Sprintf(shouldNotHavePanicked, "hi")) - this.pass(so(func() {}, ShouldNotPanic)) + fail(t, so(func() { panic("hi") }, ShouldNotPanic), fmt.Sprintf(shouldNotHavePanicked, "hi")) + pass(t, so(func() {}, ShouldNotPanic)) } -func (this *AssertionsFixture) TestShouldPanicWith() { - this.fail(so(func() {}, ShouldPanicWith), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(func() {}, ShouldPanicWith, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldPanicWith(t *testing.T) { + fail(t, so(func() {}, ShouldPanicWith), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(func() {}, ShouldPanicWith, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(1, ShouldPanicWith, 1), shouldUseVoidNiladicFunction) - this.fail(so(func(i int) {}, ShouldPanicWith, "hi"), shouldUseVoidNiladicFunction) - this.fail(so(func() {}, ShouldPanicWith, "bye"), shouldHavePanicked) - this.fail(so(func() { panic("hi") }, ShouldPanicWith, "bye"), "bye|hi|Expected func() to panic with 'bye' (but it panicked with 'hi')!") + fail(t, so(1, ShouldPanicWith, 1), shouldUseVoidNiladicFunction) + fail(t, so(func(i int) {}, ShouldPanicWith, "hi"), shouldUseVoidNiladicFunction) + fail(t, so(func() {}, ShouldPanicWith, "bye"), shouldHavePanicked) + fail(t, so(func() { panic("hi") }, ShouldPanicWith, "bye"), "bye|hi|Expected func() to panic with 'bye' (but it panicked with 'hi')!") - this.pass(so(func() { panic("hi") }, ShouldPanicWith, "hi")) + pass(t, so(func() { panic("hi") }, ShouldPanicWith, "hi")) } -func (this *AssertionsFixture) TestShouldNotPanicWith() { - this.fail(so(func() {}, ShouldNotPanicWith), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(func() {}, ShouldNotPanicWith, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldNotPanicWith(t *testing.T) { + fail(t, so(func() {}, ShouldNotPanicWith), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(func() {}, ShouldNotPanicWith, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(1, ShouldNotPanicWith, 1), shouldUseVoidNiladicFunction) - this.fail(so(func(i int) {}, ShouldNotPanicWith, "hi"), shouldUseVoidNiladicFunction) - this.fail(so(func() { panic("hi") }, ShouldNotPanicWith, "hi"), "Expected func() NOT to panic with 'hi' (but it did)!") + fail(t, so(1, ShouldNotPanicWith, 1), shouldUseVoidNiladicFunction) + fail(t, so(func(i int) {}, ShouldNotPanicWith, "hi"), shouldUseVoidNiladicFunction) + fail(t, so(func() { panic("hi") }, ShouldNotPanicWith, "hi"), "Expected func() NOT to panic with 'hi' (but it did)!") - this.pass(so(func() {}, ShouldNotPanicWith, "bye")) - this.pass(so(func() { panic("hi") }, ShouldNotPanicWith, "bye")) + pass(t, so(func() {}, ShouldNotPanicWith, "bye")) + pass(t, so(func() { panic("hi") }, ShouldNotPanicWith, "bye")) } diff --git a/vendor/github.com/smartystreets/assertions/quantity.go b/vendor/github.com/smartystreets/assertions/quantity.go index f28b0a062..80789f0cc 100644 --- a/vendor/github.com/smartystreets/assertions/quantity.go +++ b/vendor/github.com/smartystreets/assertions/quantity.go @@ -43,7 +43,7 @@ func ShouldBeLessThanOrEqualTo(actual interface{}, expected ...interface{}) stri if fail := need(1, expected); fail != success { return fail } else if matchError := oglematchers.LessOrEqual(expected[0]).Matches(actual); matchError != nil { - return fmt.Sprintf(shouldHaveBeenLessOrEqual, actual, expected[0]) + return fmt.Sprintf(shouldHaveBeenLess, actual, expected[0]) } return success } diff --git a/vendor/github.com/smartystreets/assertions/quantity_test.go b/vendor/github.com/smartystreets/assertions/quantity_test.go index ea04fc645..7546e7250 100644 --- a/vendor/github.com/smartystreets/assertions/quantity_test.go +++ b/vendor/github.com/smartystreets/assertions/quantity_test.go @@ -1,143 +1,145 @@ package assertions -func (this *AssertionsFixture) TestShouldBeGreaterThan() { - this.fail(so(1, ShouldBeGreaterThan), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(1, ShouldBeGreaterThan, 0, 0), "This assertion requires exactly 1 comparison values (you provided 2).") - - this.pass(so(1, ShouldBeGreaterThan, 0)) - this.pass(so(1.1, ShouldBeGreaterThan, 1)) - this.pass(so(1, ShouldBeGreaterThan, uint(0))) - this.pass(so("b", ShouldBeGreaterThan, "a")) - - this.fail(so(0, ShouldBeGreaterThan, 1), "Expected '0' to be greater than '1' (but it wasn't)!") - this.fail(so(1, ShouldBeGreaterThan, 1.1), "Expected '1' to be greater than '1.1' (but it wasn't)!") - this.fail(so(uint(0), ShouldBeGreaterThan, 1.1), "Expected '0' to be greater than '1.1' (but it wasn't)!") - this.fail(so("a", ShouldBeGreaterThan, "b"), "Expected 'a' to be greater than 'b' (but it wasn't)!") +import "testing" + +func TestShouldBeGreaterThan(t *testing.T) { + fail(t, so(1, ShouldBeGreaterThan), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(1, ShouldBeGreaterThan, 0, 0), "This assertion requires exactly 1 comparison values (you provided 2).") + + pass(t, so(1, ShouldBeGreaterThan, 0)) + pass(t, so(1.1, ShouldBeGreaterThan, 1)) + pass(t, so(1, ShouldBeGreaterThan, uint(0))) + pass(t, so("b", ShouldBeGreaterThan, "a")) + + fail(t, so(0, ShouldBeGreaterThan, 1), "Expected '0' to be greater than '1' (but it wasn't)!") + fail(t, so(1, ShouldBeGreaterThan, 1.1), "Expected '1' to be greater than '1.1' (but it wasn't)!") + fail(t, so(uint(0), ShouldBeGreaterThan, 1.1), "Expected '0' to be greater than '1.1' (but it wasn't)!") + fail(t, so("a", ShouldBeGreaterThan, "b"), "Expected 'a' to be greater than 'b' (but it wasn't)!") } -func (this *AssertionsFixture) TestShouldBeGreaterThanOrEqual() { - this.fail(so(1, ShouldBeGreaterThanOrEqualTo), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(1, ShouldBeGreaterThanOrEqualTo, 0, 0), "This assertion requires exactly 1 comparison values (you provided 2).") +func TestShouldBeGreaterThanOrEqual(t *testing.T) { + fail(t, so(1, ShouldBeGreaterThanOrEqualTo), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(1, ShouldBeGreaterThanOrEqualTo, 0, 0), "This assertion requires exactly 1 comparison values (you provided 2).") - this.pass(so(1, ShouldBeGreaterThanOrEqualTo, 1)) - this.pass(so(1.1, ShouldBeGreaterThanOrEqualTo, 1.1)) - this.pass(so(1, ShouldBeGreaterThanOrEqualTo, uint(1))) - this.pass(so("b", ShouldBeGreaterThanOrEqualTo, "b")) + pass(t, so(1, ShouldBeGreaterThanOrEqualTo, 1)) + pass(t, so(1.1, ShouldBeGreaterThanOrEqualTo, 1.1)) + pass(t, so(1, ShouldBeGreaterThanOrEqualTo, uint(1))) + pass(t, so("b", ShouldBeGreaterThanOrEqualTo, "b")) - this.pass(so(1, ShouldBeGreaterThanOrEqualTo, 0)) - this.pass(so(1.1, ShouldBeGreaterThanOrEqualTo, 1)) - this.pass(so(1, ShouldBeGreaterThanOrEqualTo, uint(0))) - this.pass(so("b", ShouldBeGreaterThanOrEqualTo, "a")) + pass(t, so(1, ShouldBeGreaterThanOrEqualTo, 0)) + pass(t, so(1.1, ShouldBeGreaterThanOrEqualTo, 1)) + pass(t, so(1, ShouldBeGreaterThanOrEqualTo, uint(0))) + pass(t, so("b", ShouldBeGreaterThanOrEqualTo, "a")) - this.fail(so(0, ShouldBeGreaterThanOrEqualTo, 1), "Expected '0' to be greater than or equal to '1' (but it wasn't)!") - this.fail(so(1, ShouldBeGreaterThanOrEqualTo, 1.1), "Expected '1' to be greater than or equal to '1.1' (but it wasn't)!") - this.fail(so(uint(0), ShouldBeGreaterThanOrEqualTo, 1.1), "Expected '0' to be greater than or equal to '1.1' (but it wasn't)!") - this.fail(so("a", ShouldBeGreaterThanOrEqualTo, "b"), "Expected 'a' to be greater than or equal to 'b' (but it wasn't)!") + fail(t, so(0, ShouldBeGreaterThanOrEqualTo, 1), "Expected '0' to be greater than or equal to '1' (but it wasn't)!") + fail(t, so(1, ShouldBeGreaterThanOrEqualTo, 1.1), "Expected '1' to be greater than or equal to '1.1' (but it wasn't)!") + fail(t, so(uint(0), ShouldBeGreaterThanOrEqualTo, 1.1), "Expected '0' to be greater than or equal to '1.1' (but it wasn't)!") + fail(t, so("a", ShouldBeGreaterThanOrEqualTo, "b"), "Expected 'a' to be greater than or equal to 'b' (but it wasn't)!") } -func (this *AssertionsFixture) TestShouldBeLessThan() { - this.fail(so(1, ShouldBeLessThan), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(1, ShouldBeLessThan, 0, 0), "This assertion requires exactly 1 comparison values (you provided 2).") +func TestShouldBeLessThan(t *testing.T) { + fail(t, so(1, ShouldBeLessThan), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(1, ShouldBeLessThan, 0, 0), "This assertion requires exactly 1 comparison values (you provided 2).") - this.pass(so(0, ShouldBeLessThan, 1)) - this.pass(so(1, ShouldBeLessThan, 1.1)) - this.pass(so(uint(0), ShouldBeLessThan, 1)) - this.pass(so("a", ShouldBeLessThan, "b")) + pass(t, so(0, ShouldBeLessThan, 1)) + pass(t, so(1, ShouldBeLessThan, 1.1)) + pass(t, so(uint(0), ShouldBeLessThan, 1)) + pass(t, so("a", ShouldBeLessThan, "b")) - this.fail(so(1, ShouldBeLessThan, 0), "Expected '1' to be less than '0' (but it wasn't)!") - this.fail(so(1.1, ShouldBeLessThan, 1), "Expected '1.1' to be less than '1' (but it wasn't)!") - this.fail(so(1.1, ShouldBeLessThan, uint(0)), "Expected '1.1' to be less than '0' (but it wasn't)!") - this.fail(so("b", ShouldBeLessThan, "a"), "Expected 'b' to be less than 'a' (but it wasn't)!") + fail(t, so(1, ShouldBeLessThan, 0), "Expected '1' to be less than '0' (but it wasn't)!") + fail(t, so(1.1, ShouldBeLessThan, 1), "Expected '1.1' to be less than '1' (but it wasn't)!") + fail(t, so(1.1, ShouldBeLessThan, uint(0)), "Expected '1.1' to be less than '0' (but it wasn't)!") + fail(t, so("b", ShouldBeLessThan, "a"), "Expected 'b' to be less than 'a' (but it wasn't)!") } -func (this *AssertionsFixture) TestShouldBeLessThanOrEqualTo() { - this.fail(so(1, ShouldBeLessThanOrEqualTo), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(1, ShouldBeLessThanOrEqualTo, 0, 0), "This assertion requires exactly 1 comparison values (you provided 2).") +func TestShouldBeLessThanOrEqualTo(t *testing.T) { + fail(t, so(1, ShouldBeLessThanOrEqualTo), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(1, ShouldBeLessThanOrEqualTo, 0, 0), "This assertion requires exactly 1 comparison values (you provided 2).") - this.pass(so(1, ShouldBeLessThanOrEqualTo, 1)) - this.pass(so(1.1, ShouldBeLessThanOrEqualTo, 1.1)) - this.pass(so(uint(1), ShouldBeLessThanOrEqualTo, 1)) - this.pass(so("b", ShouldBeLessThanOrEqualTo, "b")) + pass(t, so(1, ShouldBeLessThanOrEqualTo, 1)) + pass(t, so(1.1, ShouldBeLessThanOrEqualTo, 1.1)) + pass(t, so(uint(1), ShouldBeLessThanOrEqualTo, 1)) + pass(t, so("b", ShouldBeLessThanOrEqualTo, "b")) - this.pass(so(0, ShouldBeLessThanOrEqualTo, 1)) - this.pass(so(1, ShouldBeLessThanOrEqualTo, 1.1)) - this.pass(so(uint(0), ShouldBeLessThanOrEqualTo, 1)) - this.pass(so("a", ShouldBeLessThanOrEqualTo, "b")) + pass(t, so(0, ShouldBeLessThanOrEqualTo, 1)) + pass(t, so(1, ShouldBeLessThanOrEqualTo, 1.1)) + pass(t, so(uint(0), ShouldBeLessThanOrEqualTo, 1)) + pass(t, so("a", ShouldBeLessThanOrEqualTo, "b")) - this.fail(so(1, ShouldBeLessThanOrEqualTo, 0), "Expected '1' to be less than or equal to '0' (but it wasn't)!") - this.fail(so(1.1, ShouldBeLessThanOrEqualTo, 1), "Expected '1.1' to be less than or equal to '1' (but it wasn't)!") - this.fail(so(1.1, ShouldBeLessThanOrEqualTo, uint(0)), "Expected '1.1' to be less than or equal to '0' (but it wasn't)!") - this.fail(so("b", ShouldBeLessThanOrEqualTo, "a"), "Expected 'b' to be less than or equal to 'a' (but it wasn't)!") + fail(t, so(1, ShouldBeLessThanOrEqualTo, 0), "Expected '1' to be less than '0' (but it wasn't)!") + fail(t, so(1.1, ShouldBeLessThanOrEqualTo, 1), "Expected '1.1' to be less than '1' (but it wasn't)!") + fail(t, so(1.1, ShouldBeLessThanOrEqualTo, uint(0)), "Expected '1.1' to be less than '0' (but it wasn't)!") + fail(t, so("b", ShouldBeLessThanOrEqualTo, "a"), "Expected 'b' to be less than 'a' (but it wasn't)!") } -func (this *AssertionsFixture) TestShouldBeBetween() { - this.fail(so(1, ShouldBeBetween), "This assertion requires exactly 2 comparison values (you provided 0).") - this.fail(so(1, ShouldBeBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") +func TestShouldBeBetween(t *testing.T) { + fail(t, so(1, ShouldBeBetween), "This assertion requires exactly 2 comparison values (you provided 0).") + fail(t, so(1, ShouldBeBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - this.fail(so(4, ShouldBeBetween, 1, 1), "The lower and upper bounds must be different values (they were both '1').") + fail(t, so(4, ShouldBeBetween, 1, 1), "The lower and upper bounds must be different values (they were both '1').") - this.fail(so(7, ShouldBeBetween, 8, 12), "Expected '7' to be between '8' and '12' (but it wasn't)!") - this.fail(so(8, ShouldBeBetween, 8, 12), "Expected '8' to be between '8' and '12' (but it wasn't)!") - this.pass(so(9, ShouldBeBetween, 8, 12)) - this.pass(so(10, ShouldBeBetween, 8, 12)) - this.pass(so(11, ShouldBeBetween, 8, 12)) - this.fail(so(12, ShouldBeBetween, 8, 12), "Expected '12' to be between '8' and '12' (but it wasn't)!") - this.fail(so(13, ShouldBeBetween, 8, 12), "Expected '13' to be between '8' and '12' (but it wasn't)!") + fail(t, so(7, ShouldBeBetween, 8, 12), "Expected '7' to be between '8' and '12' (but it wasn't)!") + fail(t, so(8, ShouldBeBetween, 8, 12), "Expected '8' to be between '8' and '12' (but it wasn't)!") + pass(t, so(9, ShouldBeBetween, 8, 12)) + pass(t, so(10, ShouldBeBetween, 8, 12)) + pass(t, so(11, ShouldBeBetween, 8, 12)) + fail(t, so(12, ShouldBeBetween, 8, 12), "Expected '12' to be between '8' and '12' (but it wasn't)!") + fail(t, so(13, ShouldBeBetween, 8, 12), "Expected '13' to be between '8' and '12' (but it wasn't)!") - this.pass(so(1, ShouldBeBetween, 2, 0)) - this.fail(so(-1, ShouldBeBetween, 2, 0), "Expected '-1' to be between '0' and '2' (but it wasn't)!") + pass(t, so(1, ShouldBeBetween, 2, 0)) + fail(t, so(-1, ShouldBeBetween, 2, 0), "Expected '-1' to be between '0' and '2' (but it wasn't)!") } -func (this *AssertionsFixture) TestShouldNotBeBetween() { - this.fail(so(1, ShouldNotBeBetween), "This assertion requires exactly 2 comparison values (you provided 0).") - this.fail(so(1, ShouldNotBeBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") +func TestShouldNotBeBetween(t *testing.T) { + fail(t, so(1, ShouldNotBeBetween), "This assertion requires exactly 2 comparison values (you provided 0).") + fail(t, so(1, ShouldNotBeBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - this.fail(so(4, ShouldNotBeBetween, 1, 1), "The lower and upper bounds must be different values (they were both '1').") + fail(t, so(4, ShouldNotBeBetween, 1, 1), "The lower and upper bounds must be different values (they were both '1').") - this.pass(so(7, ShouldNotBeBetween, 8, 12)) - this.pass(so(8, ShouldNotBeBetween, 8, 12)) - this.fail(so(9, ShouldNotBeBetween, 8, 12), "Expected '9' NOT to be between '8' and '12' (but it was)!") - this.fail(so(10, ShouldNotBeBetween, 8, 12), "Expected '10' NOT to be between '8' and '12' (but it was)!") - this.fail(so(11, ShouldNotBeBetween, 8, 12), "Expected '11' NOT to be between '8' and '12' (but it was)!") - this.pass(so(12, ShouldNotBeBetween, 8, 12)) - this.pass(so(13, ShouldNotBeBetween, 8, 12)) + pass(t, so(7, ShouldNotBeBetween, 8, 12)) + pass(t, so(8, ShouldNotBeBetween, 8, 12)) + fail(t, so(9, ShouldNotBeBetween, 8, 12), "Expected '9' NOT to be between '8' and '12' (but it was)!") + fail(t, so(10, ShouldNotBeBetween, 8, 12), "Expected '10' NOT to be between '8' and '12' (but it was)!") + fail(t, so(11, ShouldNotBeBetween, 8, 12), "Expected '11' NOT to be between '8' and '12' (but it was)!") + pass(t, so(12, ShouldNotBeBetween, 8, 12)) + pass(t, so(13, ShouldNotBeBetween, 8, 12)) - this.pass(so(-1, ShouldNotBeBetween, 2, 0)) - this.fail(so(1, ShouldNotBeBetween, 2, 0), "Expected '1' NOT to be between '0' and '2' (but it was)!") + pass(t, so(-1, ShouldNotBeBetween, 2, 0)) + fail(t, so(1, ShouldNotBeBetween, 2, 0), "Expected '1' NOT to be between '0' and '2' (but it was)!") } -func (this *AssertionsFixture) TestShouldBeBetweenOrEqual() { - this.fail(so(1, ShouldBeBetweenOrEqual), "This assertion requires exactly 2 comparison values (you provided 0).") - this.fail(so(1, ShouldBeBetweenOrEqual, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") +func TestShouldBeBetweenOrEqual(t *testing.T) { + fail(t, so(1, ShouldBeBetweenOrEqual), "This assertion requires exactly 2 comparison values (you provided 0).") + fail(t, so(1, ShouldBeBetweenOrEqual, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - this.fail(so(4, ShouldBeBetweenOrEqual, 1, 1), "The lower and upper bounds must be different values (they were both '1').") + fail(t, so(4, ShouldBeBetweenOrEqual, 1, 1), "The lower and upper bounds must be different values (they were both '1').") - this.fail(so(7, ShouldBeBetweenOrEqual, 8, 12), "Expected '7' to be between '8' and '12' or equal to one of them (but it wasn't)!") - this.pass(so(8, ShouldBeBetweenOrEqual, 8, 12)) - this.pass(so(9, ShouldBeBetweenOrEqual, 8, 12)) - this.pass(so(10, ShouldBeBetweenOrEqual, 8, 12)) - this.pass(so(11, ShouldBeBetweenOrEqual, 8, 12)) - this.pass(so(12, ShouldBeBetweenOrEqual, 8, 12)) - this.fail(so(13, ShouldBeBetweenOrEqual, 8, 12), "Expected '13' to be between '8' and '12' or equal to one of them (but it wasn't)!") + fail(t, so(7, ShouldBeBetweenOrEqual, 8, 12), "Expected '7' to be between '8' and '12' or equal to one of them (but it wasn't)!") + pass(t, so(8, ShouldBeBetweenOrEqual, 8, 12)) + pass(t, so(9, ShouldBeBetweenOrEqual, 8, 12)) + pass(t, so(10, ShouldBeBetweenOrEqual, 8, 12)) + pass(t, so(11, ShouldBeBetweenOrEqual, 8, 12)) + pass(t, so(12, ShouldBeBetweenOrEqual, 8, 12)) + fail(t, so(13, ShouldBeBetweenOrEqual, 8, 12), "Expected '13' to be between '8' and '12' or equal to one of them (but it wasn't)!") - this.pass(so(1, ShouldBeBetweenOrEqual, 2, 0)) - this.fail(so(-1, ShouldBeBetweenOrEqual, 2, 0), "Expected '-1' to be between '0' and '2' or equal to one of them (but it wasn't)!") + pass(t, so(1, ShouldBeBetweenOrEqual, 2, 0)) + fail(t, so(-1, ShouldBeBetweenOrEqual, 2, 0), "Expected '-1' to be between '0' and '2' or equal to one of them (but it wasn't)!") } -func (this *AssertionsFixture) TestShouldNotBeBetweenOrEqual() { - this.fail(so(1, ShouldNotBeBetweenOrEqual), "This assertion requires exactly 2 comparison values (you provided 0).") - this.fail(so(1, ShouldNotBeBetweenOrEqual, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") +func TestShouldNotBeBetweenOrEqual(t *testing.T) { + fail(t, so(1, ShouldNotBeBetweenOrEqual), "This assertion requires exactly 2 comparison values (you provided 0).") + fail(t, so(1, ShouldNotBeBetweenOrEqual, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - this.fail(so(4, ShouldNotBeBetweenOrEqual, 1, 1), "The lower and upper bounds must be different values (they were both '1').") + fail(t, so(4, ShouldNotBeBetweenOrEqual, 1, 1), "The lower and upper bounds must be different values (they were both '1').") - this.pass(so(7, ShouldNotBeBetweenOrEqual, 8, 12)) - this.fail(so(8, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '8' NOT to be between '8' and '12' or equal to one of them (but it was)!") - this.fail(so(9, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '9' NOT to be between '8' and '12' or equal to one of them (but it was)!") - this.fail(so(10, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '10' NOT to be between '8' and '12' or equal to one of them (but it was)!") - this.fail(so(11, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '11' NOT to be between '8' and '12' or equal to one of them (but it was)!") - this.fail(so(12, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '12' NOT to be between '8' and '12' or equal to one of them (but it was)!") - this.pass(so(13, ShouldNotBeBetweenOrEqual, 8, 12)) + pass(t, so(7, ShouldNotBeBetweenOrEqual, 8, 12)) + fail(t, so(8, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '8' NOT to be between '8' and '12' or equal to one of them (but it was)!") + fail(t, so(9, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '9' NOT to be between '8' and '12' or equal to one of them (but it was)!") + fail(t, so(10, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '10' NOT to be between '8' and '12' or equal to one of them (but it was)!") + fail(t, so(11, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '11' NOT to be between '8' and '12' or equal to one of them (but it was)!") + fail(t, so(12, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '12' NOT to be between '8' and '12' or equal to one of them (but it was)!") + pass(t, so(13, ShouldNotBeBetweenOrEqual, 8, 12)) - this.pass(so(-1, ShouldNotBeBetweenOrEqual, 2, 0)) - this.fail(so(1, ShouldNotBeBetweenOrEqual, 2, 0), "Expected '1' NOT to be between '0' and '2' or equal to one of them (but it was)!") + pass(t, so(-1, ShouldNotBeBetweenOrEqual, 2, 0)) + fail(t, so(1, ShouldNotBeBetweenOrEqual, 2, 0), "Expected '1' NOT to be between '0' and '2' or equal to one of them (but it was)!") } diff --git a/vendor/github.com/smartystreets/assertions/serializer.go b/vendor/github.com/smartystreets/assertions/serializer.go index fa32f9403..90c4ae345 100644 --- a/vendor/github.com/smartystreets/assertions/serializer.go +++ b/vendor/github.com/smartystreets/assertions/serializer.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/smartystreets/assertions/internal/go-render/render" + "github.com/smartystreets/goconvey/convey/reporting" ) type Serializer interface { @@ -15,44 +15,40 @@ type Serializer interface { type failureSerializer struct{} func (self *failureSerializer) serializeDetailed(expected, actual interface{}, message string) string { - view := FailureView{ - Message: message, - Expected: render.Render(expected), - Actual: render.Render(actual), + view := self.format(expected, actual, message, "%#v") + serialized, err := json.Marshal(view) + if err != nil { + return message } - serialized, _ := json.Marshal(view) return string(serialized) } func (self *failureSerializer) serialize(expected, actual interface{}, message string) string { - view := FailureView{ - Message: message, - Expected: fmt.Sprintf("%+v", expected), - Actual: fmt.Sprintf("%+v", actual), + view := self.format(expected, actual, message, "%+v") + serialized, err := json.Marshal(view) + if err != nil { + return message } - serialized, _ := json.Marshal(view) return string(serialized) } -func newSerializer() *failureSerializer { - return &failureSerializer{} +func (self *failureSerializer) format(expected, actual interface{}, message string, format string) reporting.FailureView { + return reporting.FailureView{ + Message: message, + Expected: fmt.Sprintf(format, expected), + Actual: fmt.Sprintf(format, actual), + } } -/////////////////////////////////////////////////////////////////////////////// - -// This struct is also declared in github.com/smartystreets/goconvey/convey/reporting. -// The json struct tags should be equal in both declarations. -type FailureView struct { - Message string `json:"Message"` - Expected string `json:"Expected"` - Actual string `json:"Actual"` +func newSerializer() *failureSerializer { + return &failureSerializer{} } /////////////////////////////////////////////////////// // noopSerializer just gives back the original message. This is useful when we are using -// the assertions from a context other than the GoConvey Web UI, that requires the JSON -// structure provided by the failureSerializer. +// the assertions from a context other than the web UI, that requires the JSON structure +// provided by the failureSerializer. type noopSerializer struct{} func (self *noopSerializer) serialize(expected, actual interface{}, message string) string { diff --git a/vendor/github.com/smartystreets/assertions/serializer_test.go b/vendor/github.com/smartystreets/assertions/serializer_test.go index 9ae183624..798345d6c 100644 --- a/vendor/github.com/smartystreets/assertions/serializer_test.go +++ b/vendor/github.com/smartystreets/assertions/serializer_test.go @@ -4,9 +4,11 @@ import ( "encoding/json" "fmt" "testing" + + "github.com/smartystreets/goconvey/convey/reporting" ) -func TestFailureSerializerCreatesSerializedVersionOfAssertionResult(t *testing.T) { +func TestSerializerCreatesSerializedVersionOfAssertionResult(t *testing.T) { thing1 := Thing1{"Hi"} thing2 := Thing2{"Bye"} message := "Super-hip failure message." @@ -14,7 +16,7 @@ func TestFailureSerializerCreatesSerializedVersionOfAssertionResult(t *testing.T actualResult := serializer.serialize(thing1, thing2, message) - expectedResult, _ := json.Marshal(FailureView{ + expectedResult, _ := json.Marshal(reporting.FailureView{ Message: message, Expected: fmt.Sprintf("%+v", thing1), Actual: fmt.Sprintf("%+v", thing2), @@ -25,7 +27,7 @@ func TestFailureSerializerCreatesSerializedVersionOfAssertionResult(t *testing.T } actualResult = serializer.serializeDetailed(thing1, thing2, message) - expectedResult, _ = json.Marshal(FailureView{ + expectedResult, _ = json.Marshal(reporting.FailureView{ Message: message, Expected: fmt.Sprintf("%#v", thing1), Actual: fmt.Sprintf("%#v", thing2), @@ -34,19 +36,3 @@ func TestFailureSerializerCreatesSerializedVersionOfAssertionResult(t *testing.T t.Errorf("\nExpected: %s\nActual: %s", string(expectedResult), actualResult) } } - -func TestNoopSerializerJustReturnsTheMessageInAllCases(t *testing.T) { - thing1 := Thing1{"Hi"} - thing2 := Thing2{"Bye"} - expected := "Super-hip failure message." - serializer := &noopSerializer{} - actual := serializer.serialize(thing1, thing2, expected) - if actual != expected { - t.Errorf("\nExpected: %s\nActual: %s", string(expected), actual) - } - - actual = serializer.serializeDetailed(thing1, thing2, expected) - if actual != expected { - t.Errorf("\nExpected: %s\nActual: %s", string(expected), actual) - } -} diff --git a/vendor/github.com/smartystreets/assertions/should/should.go b/vendor/github.com/smartystreets/assertions/should/should.go index 18c37ed2b..596e43b8f 100644 --- a/vendor/github.com/smartystreets/assertions/should/should.go +++ b/vendor/github.com/smartystreets/assertions/should/should.go @@ -70,6 +70,4 @@ var ( HappenWithin = assertions.ShouldHappenWithin NotHappenWithin = assertions.ShouldNotHappenWithin BeChronological = assertions.ShouldBeChronological - - BeError = assertions.ShouldBeError ) diff --git a/vendor/github.com/smartystreets/assertions/strings_test.go b/vendor/github.com/smartystreets/assertions/strings_test.go index 9850c0774..ad8d0c885 100644 --- a/vendor/github.com/smartystreets/assertions/strings_test.go +++ b/vendor/github.com/smartystreets/assertions/strings_test.go @@ -1,108 +1,118 @@ package assertions -func (this *AssertionsFixture) TestShouldStartWith() { - this.fail(so("", ShouldStartWith), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so("", ShouldStartWith, "asdf", "asdf"), "This assertion requires exactly 1 comparison values (you provided 2).") +import "testing" - this.pass(so("", ShouldStartWith, "")) - this.fail(so("", ShouldStartWith, "x"), "x||Expected '' to start with 'x' (but it didn't)!") - this.pass(so("abc", ShouldStartWith, "abc")) - this.fail(so("abc", ShouldStartWith, "abcd"), "abcd|abc|Expected 'abc' to start with 'abcd' (but it didn't)!") +func TestShouldStartWith(t *testing.T) { + serializer = newFakeSerializer() - this.pass(so("superman", ShouldStartWith, "super")) - this.fail(so("superman", ShouldStartWith, "bat"), "bat|sup...|Expected 'superman' to start with 'bat' (but it didn't)!") - this.fail(so("superman", ShouldStartWith, "man"), "man|sup...|Expected 'superman' to start with 'man' (but it didn't)!") + fail(t, so("", ShouldStartWith), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so("", ShouldStartWith, "asdf", "asdf"), "This assertion requires exactly 1 comparison values (you provided 2).") - this.fail(so(1, ShouldStartWith, 2), "Both arguments to this assertion must be strings (you provided int and int).") + pass(t, so("", ShouldStartWith, "")) + fail(t, so("", ShouldStartWith, "x"), "x||Expected '' to start with 'x' (but it didn't)!") + pass(t, so("abc", ShouldStartWith, "abc")) + fail(t, so("abc", ShouldStartWith, "abcd"), "abcd|abc|Expected 'abc' to start with 'abcd' (but it didn't)!") + + pass(t, so("superman", ShouldStartWith, "super")) + fail(t, so("superman", ShouldStartWith, "bat"), "bat|sup...|Expected 'superman' to start with 'bat' (but it didn't)!") + fail(t, so("superman", ShouldStartWith, "man"), "man|sup...|Expected 'superman' to start with 'man' (but it didn't)!") + + fail(t, so(1, ShouldStartWith, 2), "Both arguments to this assertion must be strings (you provided int and int).") } -func (this *AssertionsFixture) TestShouldNotStartWith() { - this.fail(so("", ShouldNotStartWith), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so("", ShouldNotStartWith, "asdf", "asdf"), "This assertion requires exactly 1 comparison values (you provided 2).") +func TestShouldNotStartWith(t *testing.T) { + fail(t, so("", ShouldNotStartWith), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so("", ShouldNotStartWith, "asdf", "asdf"), "This assertion requires exactly 1 comparison values (you provided 2).") - this.fail(so("", ShouldNotStartWith, ""), "Expected '' NOT to start with '' (but it did)!") - this.fail(so("superman", ShouldNotStartWith, "super"), "Expected 'superman' NOT to start with 'super' (but it did)!") - this.pass(so("superman", ShouldNotStartWith, "bat")) - this.pass(so("superman", ShouldNotStartWith, "man")) + fail(t, so("", ShouldNotStartWith, ""), "Expected '' NOT to start with '' (but it did)!") + fail(t, so("superman", ShouldNotStartWith, "super"), "Expected 'superman' NOT to start with 'super' (but it did)!") + pass(t, so("superman", ShouldNotStartWith, "bat")) + pass(t, so("superman", ShouldNotStartWith, "man")) - this.fail(so(1, ShouldNotStartWith, 2), "Both arguments to this assertion must be strings (you provided int and int).") + fail(t, so(1, ShouldNotStartWith, 2), "Both arguments to this assertion must be strings (you provided int and int).") } -func (this *AssertionsFixture) TestShouldEndWith() { - this.fail(so("", ShouldEndWith), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so("", ShouldEndWith, "", ""), "This assertion requires exactly 1 comparison values (you provided 2).") +func TestShouldEndWith(t *testing.T) { + serializer = newFakeSerializer() + + fail(t, so("", ShouldEndWith), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so("", ShouldEndWith, "", ""), "This assertion requires exactly 1 comparison values (you provided 2).") - this.pass(so("", ShouldEndWith, "")) - this.fail(so("", ShouldEndWith, "z"), "z||Expected '' to end with 'z' (but it didn't)!") - this.pass(so("xyz", ShouldEndWith, "xyz")) - this.fail(so("xyz", ShouldEndWith, "wxyz"), "wxyz|xyz|Expected 'xyz' to end with 'wxyz' (but it didn't)!") + pass(t, so("", ShouldEndWith, "")) + fail(t, so("", ShouldEndWith, "z"), "z||Expected '' to end with 'z' (but it didn't)!") + pass(t, so("xyz", ShouldEndWith, "xyz")) + fail(t, so("xyz", ShouldEndWith, "wxyz"), "wxyz|xyz|Expected 'xyz' to end with 'wxyz' (but it didn't)!") - this.pass(so("superman", ShouldEndWith, "man")) - this.fail(so("superman", ShouldEndWith, "super"), "super|...erman|Expected 'superman' to end with 'super' (but it didn't)!") - this.fail(so("superman", ShouldEndWith, "blah"), "blah|...rman|Expected 'superman' to end with 'blah' (but it didn't)!") + pass(t, so("superman", ShouldEndWith, "man")) + fail(t, so("superman", ShouldEndWith, "super"), "super|...erman|Expected 'superman' to end with 'super' (but it didn't)!") + fail(t, so("superman", ShouldEndWith, "blah"), "blah|...rman|Expected 'superman' to end with 'blah' (but it didn't)!") - this.fail(so(1, ShouldEndWith, 2), "Both arguments to this assertion must be strings (you provided int and int).") + fail(t, so(1, ShouldEndWith, 2), "Both arguments to this assertion must be strings (you provided int and int).") } -func (this *AssertionsFixture) TestShouldNotEndWith() { - this.fail(so("", ShouldNotEndWith), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so("", ShouldNotEndWith, "", ""), "This assertion requires exactly 1 comparison values (you provided 2).") +func TestShouldNotEndWith(t *testing.T) { + fail(t, so("", ShouldNotEndWith), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so("", ShouldNotEndWith, "", ""), "This assertion requires exactly 1 comparison values (you provided 2).") - this.fail(so("", ShouldNotEndWith, ""), "Expected '' NOT to end with '' (but it did)!") - this.fail(so("superman", ShouldNotEndWith, "man"), "Expected 'superman' NOT to end with 'man' (but it did)!") - this.pass(so("superman", ShouldNotEndWith, "super")) + fail(t, so("", ShouldNotEndWith, ""), "Expected '' NOT to end with '' (but it did)!") + fail(t, so("superman", ShouldNotEndWith, "man"), "Expected 'superman' NOT to end with 'man' (but it did)!") + pass(t, so("superman", ShouldNotEndWith, "super")) - this.fail(so(1, ShouldNotEndWith, 2), "Both arguments to this assertion must be strings (you provided int and int).") + fail(t, so(1, ShouldNotEndWith, 2), "Both arguments to this assertion must be strings (you provided int and int).") } -func (this *AssertionsFixture) TestShouldContainSubstring() { - this.fail(so("asdf", ShouldContainSubstring), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so("asdf", ShouldContainSubstring, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldContainSubstring(t *testing.T) { + serializer = newFakeSerializer() - this.fail(so(123, ShouldContainSubstring, 23), "Both arguments to this assertion must be strings (you provided int and int).") + fail(t, so("asdf", ShouldContainSubstring), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so("asdf", ShouldContainSubstring, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.pass(so("asdf", ShouldContainSubstring, "sd")) - this.fail(so("qwer", ShouldContainSubstring, "sd"), "sd|qwer|Expected 'qwer' to contain substring 'sd' (but it didn't)!") + fail(t, so(123, ShouldContainSubstring, 23), "Both arguments to this assertion must be strings (you provided int and int).") + + pass(t, so("asdf", ShouldContainSubstring, "sd")) + fail(t, so("qwer", ShouldContainSubstring, "sd"), "sd|qwer|Expected 'qwer' to contain substring 'sd' (but it didn't)!") } -func (this *AssertionsFixture) TestShouldNotContainSubstring() { - this.fail(so("asdf", ShouldNotContainSubstring), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so("asdf", ShouldNotContainSubstring, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldNotContainSubstring(t *testing.T) { + fail(t, so("asdf", ShouldNotContainSubstring), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so("asdf", ShouldNotContainSubstring, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(123, ShouldNotContainSubstring, 23), "Both arguments to this assertion must be strings (you provided int and int).") + fail(t, so(123, ShouldNotContainSubstring, 23), "Both arguments to this assertion must be strings (you provided int and int).") - this.pass(so("qwer", ShouldNotContainSubstring, "sd")) - this.fail(so("asdf", ShouldNotContainSubstring, "sd"), "Expected 'asdf' NOT to contain substring 'sd' (but it did)!") + pass(t, so("qwer", ShouldNotContainSubstring, "sd")) + fail(t, so("asdf", ShouldNotContainSubstring, "sd"), "Expected 'asdf' NOT to contain substring 'sd' (but it did)!") } -func (this *AssertionsFixture) TestShouldBeBlank() { - this.fail(so("", ShouldBeBlank, "adsf"), "This assertion requires exactly 0 comparison values (you provided 1).") - this.fail(so(1, ShouldBeBlank), "The argument to this assertion must be a string (you provided int).") +func TestShouldBeBlank(t *testing.T) { + serializer = newFakeSerializer() + + fail(t, so("", ShouldBeBlank, "adsf"), "This assertion requires exactly 0 comparison values (you provided 1).") + fail(t, so(1, ShouldBeBlank), "The argument to this assertion must be a string (you provided int).") - this.fail(so("asdf", ShouldBeBlank), "|asdf|Expected 'asdf' to be blank (but it wasn't)!") - this.pass(so("", ShouldBeBlank)) + fail(t, so("asdf", ShouldBeBlank), "|asdf|Expected 'asdf' to be blank (but it wasn't)!") + pass(t, so("", ShouldBeBlank)) } -func (this *AssertionsFixture) TestShouldNotBeBlank() { - this.fail(so("", ShouldNotBeBlank, "adsf"), "This assertion requires exactly 0 comparison values (you provided 1).") - this.fail(so(1, ShouldNotBeBlank), "The argument to this assertion must be a string (you provided int).") +func TestShouldNotBeBlank(t *testing.T) { + fail(t, so("", ShouldNotBeBlank, "adsf"), "This assertion requires exactly 0 comparison values (you provided 1).") + fail(t, so(1, ShouldNotBeBlank), "The argument to this assertion must be a string (you provided int).") - this.fail(so("", ShouldNotBeBlank), "Expected value to NOT be blank (but it was)!") - this.pass(so("asdf", ShouldNotBeBlank)) + fail(t, so("", ShouldNotBeBlank), "Expected value to NOT be blank (but it was)!") + pass(t, so("asdf", ShouldNotBeBlank)) } -func (this *AssertionsFixture) TestShouldEqualWithout() { - this.fail(so("", ShouldEqualWithout, ""), "This assertion requires exactly 2 comparison values (you provided 1).") - this.fail(so(1, ShouldEqualWithout, 2, 3), "All arguments to this assertion must be strings (you provided: [int int int]).") +func TestShouldEqualWithout(t *testing.T) { + fail(t, so("", ShouldEqualWithout, ""), "This assertion requires exactly 2 comparison values (you provided 1).") + fail(t, so(1, ShouldEqualWithout, 2, 3), "All arguments to this assertion must be strings (you provided: [int int int]).") - this.fail(so("asdf", ShouldEqualWithout, "qwer", "q"), "Expected 'asdf' to equal 'qwer' but without any 'q' (but it didn't).") - this.pass(so("asdf", ShouldEqualWithout, "df", "as")) + fail(t, so("asdf", ShouldEqualWithout, "qwer", "q"), "Expected 'asdf' to equal 'qwer' but without any 'q' (but it didn't).") + pass(t, so("asdf", ShouldEqualWithout, "df", "as")) } -func (this *AssertionsFixture) TestShouldEqualTrimSpace() { - this.fail(so(" asdf ", ShouldEqualTrimSpace), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(1, ShouldEqualTrimSpace, 2), "Both arguments to this assertion must be strings (you provided int and int).") +func TestShouldEqualTrimSpace(t *testing.T) { + fail(t, so(" asdf ", ShouldEqualTrimSpace), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(1, ShouldEqualTrimSpace, 2), "Both arguments to this assertion must be strings (you provided int and int).") - this.fail(so("asdf", ShouldEqualTrimSpace, "qwer"), "qwer|asdf|Expected: 'qwer' Actual: 'asdf' (Should be equal)") - this.pass(so(" asdf\t\n", ShouldEqualTrimSpace, "asdf")) + fail(t, so("asdf", ShouldEqualTrimSpace, "qwer"), "qwer|asdf|Expected: 'qwer' Actual: 'asdf' (Should be equal)") + pass(t, so(" asdf\t\n", ShouldEqualTrimSpace, "asdf")) } diff --git a/vendor/github.com/smartystreets/assertions/time_test.go b/vendor/github.com/smartystreets/assertions/time_test.go index 6929962e8..f9dda8f8f 100644 --- a/vendor/github.com/smartystreets/assertions/time_test.go +++ b/vendor/github.com/smartystreets/assertions/time_test.go @@ -2,144 +2,145 @@ package assertions import ( "fmt" + "testing" "time" ) -func (this *AssertionsFixture) TestShouldHappenBefore() { - this.fail(so(0, ShouldHappenBefore), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(0, ShouldHappenBefore, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldHappenBefore(t *testing.T) { + fail(t, so(0, ShouldHappenBefore), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(0, ShouldHappenBefore, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(0, ShouldHappenBefore, 1), shouldUseTimes) - this.fail(so(0, ShouldHappenBefore, time.Now()), shouldUseTimes) - this.fail(so(time.Now(), ShouldHappenBefore, 0), shouldUseTimes) + fail(t, so(0, ShouldHappenBefore, 1), shouldUseTimes) + fail(t, so(0, ShouldHappenBefore, time.Now()), shouldUseTimes) + fail(t, so(time.Now(), ShouldHappenBefore, 0), shouldUseTimes) - this.fail(so(january3, ShouldHappenBefore, january1), fmt.Sprintf("Expected '%s' to happen before '%s' (it happened '48h0m0s' after)!", pretty(january3), pretty(january1))) - this.fail(so(january3, ShouldHappenBefore, january3), fmt.Sprintf("Expected '%s' to happen before '%s' (it happened '0s' after)!", pretty(january3), pretty(january3))) - this.pass(so(january1, ShouldHappenBefore, january3)) + fail(t, so(january3, ShouldHappenBefore, january1), fmt.Sprintf("Expected '%s' to happen before '%s' (it happened '48h0m0s' after)!", pretty(january3), pretty(january1))) + fail(t, so(january3, ShouldHappenBefore, january3), fmt.Sprintf("Expected '%s' to happen before '%s' (it happened '0' after)!", pretty(january3), pretty(january3))) + pass(t, so(january1, ShouldHappenBefore, january3)) } -func (this *AssertionsFixture) TestShouldHappenOnOrBefore() { - this.fail(so(0, ShouldHappenOnOrBefore), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(0, ShouldHappenOnOrBefore, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldHappenOnOrBefore(t *testing.T) { + fail(t, so(0, ShouldHappenOnOrBefore), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(0, ShouldHappenOnOrBefore, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(0, ShouldHappenOnOrBefore, 1), shouldUseTimes) - this.fail(so(0, ShouldHappenOnOrBefore, time.Now()), shouldUseTimes) - this.fail(so(time.Now(), ShouldHappenOnOrBefore, 0), shouldUseTimes) + fail(t, so(0, ShouldHappenOnOrBefore, 1), shouldUseTimes) + fail(t, so(0, ShouldHappenOnOrBefore, time.Now()), shouldUseTimes) + fail(t, so(time.Now(), ShouldHappenOnOrBefore, 0), shouldUseTimes) - this.fail(so(january3, ShouldHappenOnOrBefore, january1), fmt.Sprintf("Expected '%s' to happen before '%s' (it happened '48h0m0s' after)!", pretty(january3), pretty(january1))) - this.pass(so(january3, ShouldHappenOnOrBefore, january3)) - this.pass(so(january1, ShouldHappenOnOrBefore, january3)) + fail(t, so(january3, ShouldHappenOnOrBefore, january1), fmt.Sprintf("Expected '%s' to happen before '%s' (it happened '48h0m0s' after)!", pretty(january3), pretty(january1))) + pass(t, so(january3, ShouldHappenOnOrBefore, january3)) + pass(t, so(january1, ShouldHappenOnOrBefore, january3)) } -func (this *AssertionsFixture) TestShouldHappenAfter() { - this.fail(so(0, ShouldHappenAfter), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(0, ShouldHappenAfter, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldHappenAfter(t *testing.T) { + fail(t, so(0, ShouldHappenAfter), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(0, ShouldHappenAfter, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(0, ShouldHappenAfter, 1), shouldUseTimes) - this.fail(so(0, ShouldHappenAfter, time.Now()), shouldUseTimes) - this.fail(so(time.Now(), ShouldHappenAfter, 0), shouldUseTimes) + fail(t, so(0, ShouldHappenAfter, 1), shouldUseTimes) + fail(t, so(0, ShouldHappenAfter, time.Now()), shouldUseTimes) + fail(t, so(time.Now(), ShouldHappenAfter, 0), shouldUseTimes) - this.fail(so(january1, ShouldHappenAfter, january2), fmt.Sprintf("Expected '%s' to happen after '%s' (it happened '24h0m0s' before)!", pretty(january1), pretty(january2))) - this.fail(so(january1, ShouldHappenAfter, january1), fmt.Sprintf("Expected '%s' to happen after '%s' (it happened '0s' before)!", pretty(january1), pretty(january1))) - this.pass(so(january3, ShouldHappenAfter, january1)) + fail(t, so(january1, ShouldHappenAfter, january2), fmt.Sprintf("Expected '%s' to happen after '%s' (it happened '24h0m0s' before)!", pretty(january1), pretty(january2))) + fail(t, so(january1, ShouldHappenAfter, january1), fmt.Sprintf("Expected '%s' to happen after '%s' (it happened '0' before)!", pretty(january1), pretty(january1))) + pass(t, so(january3, ShouldHappenAfter, january1)) } -func (this *AssertionsFixture) TestShouldHappenOnOrAfter() { - this.fail(so(0, ShouldHappenOnOrAfter), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(0, ShouldHappenOnOrAfter, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldHappenOnOrAfter(t *testing.T) { + fail(t, so(0, ShouldHappenOnOrAfter), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(0, ShouldHappenOnOrAfter, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(0, ShouldHappenOnOrAfter, 1), shouldUseTimes) - this.fail(so(0, ShouldHappenOnOrAfter, time.Now()), shouldUseTimes) - this.fail(so(time.Now(), ShouldHappenOnOrAfter, 0), shouldUseTimes) + fail(t, so(0, ShouldHappenOnOrAfter, 1), shouldUseTimes) + fail(t, so(0, ShouldHappenOnOrAfter, time.Now()), shouldUseTimes) + fail(t, so(time.Now(), ShouldHappenOnOrAfter, 0), shouldUseTimes) - this.fail(so(january1, ShouldHappenOnOrAfter, january2), fmt.Sprintf("Expected '%s' to happen after '%s' (it happened '24h0m0s' before)!", pretty(january1), pretty(january2))) - this.pass(so(january1, ShouldHappenOnOrAfter, january1)) - this.pass(so(january3, ShouldHappenOnOrAfter, january1)) + fail(t, so(january1, ShouldHappenOnOrAfter, january2), fmt.Sprintf("Expected '%s' to happen after '%s' (it happened '24h0m0s' before)!", pretty(january1), pretty(january2))) + pass(t, so(january1, ShouldHappenOnOrAfter, january1)) + pass(t, so(january3, ShouldHappenOnOrAfter, january1)) } -func (this *AssertionsFixture) TestShouldHappenBetween() { - this.fail(so(0, ShouldHappenBetween), "This assertion requires exactly 2 comparison values (you provided 0).") - this.fail(so(0, ShouldHappenBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") +func TestShouldHappenBetween(t *testing.T) { + fail(t, so(0, ShouldHappenBetween), "This assertion requires exactly 2 comparison values (you provided 0).") + fail(t, so(0, ShouldHappenBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - this.fail(so(0, ShouldHappenBetween, 1, 2), shouldUseTimes) - this.fail(so(0, ShouldHappenBetween, time.Now(), time.Now()), shouldUseTimes) - this.fail(so(time.Now(), ShouldHappenBetween, 0, time.Now()), shouldUseTimes) - this.fail(so(time.Now(), ShouldHappenBetween, time.Now(), 9), shouldUseTimes) + fail(t, so(0, ShouldHappenBetween, 1, 2), shouldUseTimes) + fail(t, so(0, ShouldHappenBetween, time.Now(), time.Now()), shouldUseTimes) + fail(t, so(time.Now(), ShouldHappenBetween, 0, time.Now()), shouldUseTimes) + fail(t, so(time.Now(), ShouldHappenBetween, time.Now(), 9), shouldUseTimes) - this.fail(so(january1, ShouldHappenBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january1), pretty(january2), pretty(january4))) - this.fail(so(january2, ShouldHappenBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '0s' outside threshold)!", pretty(january2), pretty(january2), pretty(january4))) - this.pass(so(january3, ShouldHappenBetween, january2, january4)) - this.fail(so(january4, ShouldHappenBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '0s' outside threshold)!", pretty(january4), pretty(january2), pretty(january4))) - this.fail(so(january5, ShouldHappenBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january5), pretty(january2), pretty(january4))) + fail(t, so(january1, ShouldHappenBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january1), pretty(january2), pretty(january4))) + fail(t, so(january2, ShouldHappenBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '0' outside threshold)!", pretty(january2), pretty(january2), pretty(january4))) + pass(t, so(january3, ShouldHappenBetween, january2, january4)) + fail(t, so(january4, ShouldHappenBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '0' outside threshold)!", pretty(january4), pretty(january2), pretty(january4))) + fail(t, so(january5, ShouldHappenBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january5), pretty(january2), pretty(january4))) } -func (this *AssertionsFixture) TestShouldHappenOnOrBetween() { - this.fail(so(0, ShouldHappenOnOrBetween), "This assertion requires exactly 2 comparison values (you provided 0).") - this.fail(so(0, ShouldHappenOnOrBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") +func TestShouldHappenOnOrBetween(t *testing.T) { + fail(t, so(0, ShouldHappenOnOrBetween), "This assertion requires exactly 2 comparison values (you provided 0).") + fail(t, so(0, ShouldHappenOnOrBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - this.fail(so(0, ShouldHappenOnOrBetween, 1, time.Now()), shouldUseTimes) - this.fail(so(0, ShouldHappenOnOrBetween, time.Now(), 1), shouldUseTimes) - this.fail(so(time.Now(), ShouldHappenOnOrBetween, 0, 1), shouldUseTimes) + fail(t, so(0, ShouldHappenOnOrBetween, 1, time.Now()), shouldUseTimes) + fail(t, so(0, ShouldHappenOnOrBetween, time.Now(), 1), shouldUseTimes) + fail(t, so(time.Now(), ShouldHappenOnOrBetween, 0, 1), shouldUseTimes) - this.fail(so(january1, ShouldHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january1), pretty(january2), pretty(january4))) - this.pass(so(january2, ShouldHappenOnOrBetween, january2, january4)) - this.pass(so(january3, ShouldHappenOnOrBetween, january2, january4)) - this.pass(so(january4, ShouldHappenOnOrBetween, january2, january4)) - this.fail(so(january5, ShouldHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january5), pretty(january2), pretty(january4))) + fail(t, so(january1, ShouldHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january1), pretty(january2), pretty(january4))) + pass(t, so(january2, ShouldHappenOnOrBetween, january2, january4)) + pass(t, so(january3, ShouldHappenOnOrBetween, january2, january4)) + pass(t, so(january4, ShouldHappenOnOrBetween, january2, january4)) + fail(t, so(january5, ShouldHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january5), pretty(january2), pretty(january4))) } -func (this *AssertionsFixture) TestShouldNotHappenOnOrBetween() { - this.fail(so(0, ShouldNotHappenOnOrBetween), "This assertion requires exactly 2 comparison values (you provided 0).") - this.fail(so(0, ShouldNotHappenOnOrBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") +func TestShouldNotHappenOnOrBetween(t *testing.T) { + fail(t, so(0, ShouldNotHappenOnOrBetween), "This assertion requires exactly 2 comparison values (you provided 0).") + fail(t, so(0, ShouldNotHappenOnOrBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - this.fail(so(0, ShouldNotHappenOnOrBetween, 1, time.Now()), shouldUseTimes) - this.fail(so(0, ShouldNotHappenOnOrBetween, time.Now(), 1), shouldUseTimes) - this.fail(so(time.Now(), ShouldNotHappenOnOrBetween, 0, 1), shouldUseTimes) + fail(t, so(0, ShouldNotHappenOnOrBetween, 1, time.Now()), shouldUseTimes) + fail(t, so(0, ShouldNotHappenOnOrBetween, time.Now(), 1), shouldUseTimes) + fail(t, so(time.Now(), ShouldNotHappenOnOrBetween, 0, 1), shouldUseTimes) - this.pass(so(january1, ShouldNotHappenOnOrBetween, january2, january4)) - this.fail(so(january2, ShouldNotHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january2), pretty(january2), pretty(january4))) - this.fail(so(january3, ShouldNotHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january3), pretty(january2), pretty(january4))) - this.fail(so(january4, ShouldNotHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january4), pretty(january2), pretty(january4))) - this.pass(so(january5, ShouldNotHappenOnOrBetween, january2, january4)) + pass(t, so(january1, ShouldNotHappenOnOrBetween, january2, january4)) + fail(t, so(january2, ShouldNotHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january2), pretty(january2), pretty(january4))) + fail(t, so(january3, ShouldNotHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january3), pretty(january2), pretty(january4))) + fail(t, so(january4, ShouldNotHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january4), pretty(january2), pretty(january4))) + pass(t, so(january5, ShouldNotHappenOnOrBetween, january2, january4)) } -func (this *AssertionsFixture) TestShouldHappenWithin() { - this.fail(so(0, ShouldHappenWithin), "This assertion requires exactly 2 comparison values (you provided 0).") - this.fail(so(0, ShouldHappenWithin, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") +func TestShouldHappenWithin(t *testing.T) { + fail(t, so(0, ShouldHappenWithin), "This assertion requires exactly 2 comparison values (you provided 0).") + fail(t, so(0, ShouldHappenWithin, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - this.fail(so(0, ShouldHappenWithin, 1, 2), shouldUseDurationAndTime) - this.fail(so(0, ShouldHappenWithin, oneDay, time.Now()), shouldUseDurationAndTime) - this.fail(so(time.Now(), ShouldHappenWithin, 0, time.Now()), shouldUseDurationAndTime) + fail(t, so(0, ShouldHappenWithin, 1, 2), shouldUseDurationAndTime) + fail(t, so(0, ShouldHappenWithin, oneDay, time.Now()), shouldUseDurationAndTime) + fail(t, so(time.Now(), ShouldHappenWithin, 0, time.Now()), shouldUseDurationAndTime) - this.fail(so(january1, ShouldHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january1), pretty(january2), pretty(january4))) - this.pass(so(january2, ShouldHappenWithin, oneDay, january3)) - this.pass(so(january3, ShouldHappenWithin, oneDay, january3)) - this.pass(so(january4, ShouldHappenWithin, oneDay, january3)) - this.fail(so(january5, ShouldHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january5), pretty(january2), pretty(january4))) + fail(t, so(january1, ShouldHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january1), pretty(january2), pretty(january4))) + pass(t, so(january2, ShouldHappenWithin, oneDay, january3)) + pass(t, so(january3, ShouldHappenWithin, oneDay, january3)) + pass(t, so(january4, ShouldHappenWithin, oneDay, january3)) + fail(t, so(january5, ShouldHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january5), pretty(january2), pretty(january4))) } -func (this *AssertionsFixture) TestShouldNotHappenWithin() { - this.fail(so(0, ShouldNotHappenWithin), "This assertion requires exactly 2 comparison values (you provided 0).") - this.fail(so(0, ShouldNotHappenWithin, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") +func TestShouldNotHappenWithin(t *testing.T) { + fail(t, so(0, ShouldNotHappenWithin), "This assertion requires exactly 2 comparison values (you provided 0).") + fail(t, so(0, ShouldNotHappenWithin, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - this.fail(so(0, ShouldNotHappenWithin, 1, 2), shouldUseDurationAndTime) - this.fail(so(0, ShouldNotHappenWithin, oneDay, time.Now()), shouldUseDurationAndTime) - this.fail(so(time.Now(), ShouldNotHappenWithin, 0, time.Now()), shouldUseDurationAndTime) + fail(t, so(0, ShouldNotHappenWithin, 1, 2), shouldUseDurationAndTime) + fail(t, so(0, ShouldNotHappenWithin, oneDay, time.Now()), shouldUseDurationAndTime) + fail(t, so(time.Now(), ShouldNotHappenWithin, 0, time.Now()), shouldUseDurationAndTime) - this.pass(so(january1, ShouldNotHappenWithin, oneDay, january3)) - this.fail(so(january2, ShouldNotHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january2), pretty(january2), pretty(january4))) - this.fail(so(january3, ShouldNotHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january3), pretty(january2), pretty(january4))) - this.fail(so(january4, ShouldNotHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january4), pretty(january2), pretty(january4))) - this.pass(so(january5, ShouldNotHappenWithin, oneDay, january3)) + pass(t, so(january1, ShouldNotHappenWithin, oneDay, january3)) + fail(t, so(january2, ShouldNotHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january2), pretty(january2), pretty(january4))) + fail(t, so(january3, ShouldNotHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january3), pretty(january2), pretty(january4))) + fail(t, so(january4, ShouldNotHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january4), pretty(january2), pretty(january4))) + pass(t, so(january5, ShouldNotHappenWithin, oneDay, january3)) } -func (this *AssertionsFixture) TestShouldBeChronological() { - this.fail(so(0, ShouldBeChronological, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") - this.fail(so(0, ShouldBeChronological), shouldUseTimeSlice) - this.fail(so([]time.Time{january5, january1}, ShouldBeChronological), +func TestShouldBeChronological(t *testing.T) { + fail(t, so(0, ShouldBeChronological, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") + fail(t, so(0, ShouldBeChronological), shouldUseTimeSlice) + fail(t, so([]time.Time{january5, january1}, ShouldBeChronological), "The 'Time' at index [1] should have happened after the previous one (but it didn't!):\n [0]: 2013-01-05 00:00:00 +0000 UTC\n [1]: 2013-01-01 00:00:00 +0000 UTC (see, it happened before!)") - this.pass(so([]time.Time{january1, january2, january3, january4, january5}, ShouldBeChronological)) + pass(t, so([]time.Time{january1, january2, january3, january4, january5}, ShouldBeChronological)) } const layout = "2006-01-02 15:04" diff --git a/vendor/github.com/smartystreets/assertions/type.go b/vendor/github.com/smartystreets/assertions/type.go index d2d1dc864..3fc00f68c 100644 --- a/vendor/github.com/smartystreets/assertions/type.go +++ b/vendor/github.com/smartystreets/assertions/type.go @@ -14,10 +14,9 @@ func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string { first := reflect.TypeOf(actual) second := reflect.TypeOf(expected[0]) - if first != second { + if equal := ShouldEqual(first, second); equal != success { return serializer.serialize(second, first, fmt.Sprintf(shouldHaveBeenA, actual, second, first)) } - return success } @@ -30,7 +29,7 @@ func ShouldNotHaveSameTypeAs(actual interface{}, expected ...interface{}) string first := reflect.TypeOf(actual) second := reflect.TypeOf(expected[0]) - if (actual == nil && expected[0] == nil) || first == second { + if equal := ShouldEqual(first, second); equal == success { return fmt.Sprintf(shouldNotHaveBeenA, actual, second) } return success @@ -66,6 +65,10 @@ func ShouldImplement(actual interface{}, expectedList ...interface{}) string { expectedInterface := expectedType.Elem() + if actualType == nil { + return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actual) + } + if !actualType.Implements(expectedInterface) { return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actualType) } @@ -107,28 +110,3 @@ func ShouldNotImplement(actual interface{}, expectedList ...interface{}) string } return success } - -// ShouldBeError asserts that the first argument implements the error interface. -// It also compares the first argument against the second argument if provided -// (which must be an error message string or another error value). -func ShouldBeError(actual interface{}, expected ...interface{}) string { - if fail := atMost(1, expected); fail != success { - return fail - } - - if !isError(actual) { - return fmt.Sprintf(shouldBeError, reflect.TypeOf(actual)) - } - - if len(expected) == 0 { - return success - } - - if expected := expected[0]; !isString(expected) && !isError(expected) { - return fmt.Sprintf(shouldBeErrorInvalidComparisonValue, reflect.TypeOf(expected)) - } - return ShouldEqual(fmt.Sprint(actual), fmt.Sprint(expected[0])) -} - -func isString(value interface{}) bool { _, ok := value.(string); return ok } -func isError(value interface{}) bool { _, ok := value.(error); return ok } diff --git a/vendor/github.com/smartystreets/assertions/type_test.go b/vendor/github.com/smartystreets/assertions/type_test.go index 25c3aae27..4b8d19846 100644 --- a/vendor/github.com/smartystreets/assertions/type_test.go +++ b/vendor/github.com/smartystreets/assertions/type_test.go @@ -2,89 +2,75 @@ package assertions import ( "bytes" - "errors" "io" "net/http" + "testing" ) -func (this *AssertionsFixture) TestShouldHaveSameTypeAs() { - this.fail(so(1, ShouldHaveSameTypeAs), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(1, ShouldHaveSameTypeAs, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldHaveSameTypeAs(t *testing.T) { + serializer = newFakeSerializer() - this.fail(so(nil, ShouldHaveSameTypeAs, 0), "int||Expected '' to be: 'int' (but was: '')!") - this.fail(so(1, ShouldHaveSameTypeAs, "asdf"), "string|int|Expected '1' to be: 'string' (but was: 'int')!") + fail(t, so(1, ShouldHaveSameTypeAs), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(1, ShouldHaveSameTypeAs, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.pass(so(1, ShouldHaveSameTypeAs, 0)) - this.pass(so(nil, ShouldHaveSameTypeAs, nil)) + fail(t, so(nil, ShouldHaveSameTypeAs, 0), "int||Expected '' to be: 'int' (but was: '')!") + fail(t, so(1, ShouldHaveSameTypeAs, "asdf"), "string|int|Expected '1' to be: 'string' (but was: 'int')!") + + pass(t, so(1, ShouldHaveSameTypeAs, 0)) + pass(t, so(nil, ShouldHaveSameTypeAs, nil)) } -func (this *AssertionsFixture) TestShouldNotHaveSameTypeAs() { - this.fail(so(1, ShouldNotHaveSameTypeAs), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(1, ShouldNotHaveSameTypeAs, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") +func TestShouldNotHaveSameTypeAs(t *testing.T) { + fail(t, so(1, ShouldNotHaveSameTypeAs), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(1, ShouldNotHaveSameTypeAs, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(1, ShouldNotHaveSameTypeAs, 0), "Expected '1' to NOT be: 'int' (but it was)!") - this.fail(so(nil, ShouldNotHaveSameTypeAs, nil), "Expected '' to NOT be: '' (but it was)!") + fail(t, so(1, ShouldNotHaveSameTypeAs, 0), "Expected '1' to NOT be: 'int' (but it was)!") + fail(t, so(nil, ShouldNotHaveSameTypeAs, nil), "Expected '' to NOT be: '' (but it was)!") - this.pass(so(nil, ShouldNotHaveSameTypeAs, 0)) - this.pass(so(1, ShouldNotHaveSameTypeAs, "asdf")) + pass(t, so(nil, ShouldNotHaveSameTypeAs, 0)) + pass(t, so(1, ShouldNotHaveSameTypeAs, "asdf")) } -func (this *AssertionsFixture) TestShouldImplement() { +func TestShouldImplement(t *testing.T) { var ioReader *io.Reader = nil var response http.Response = http.Response{} var responsePtr *http.Response = new(http.Response) var reader = bytes.NewBufferString("") - this.fail(so(reader, ShouldImplement), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(reader, ShouldImplement, ioReader, ioReader), "This assertion requires exactly 1 comparison values (you provided 2).") - this.fail(so(reader, ShouldImplement, ioReader, ioReader, ioReader), "This assertion requires exactly 1 comparison values (you provided 3).") + fail(t, so(reader, ShouldImplement), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(reader, ShouldImplement, ioReader, ioReader), "This assertion requires exactly 1 comparison values (you provided 2).") + fail(t, so(reader, ShouldImplement, ioReader, ioReader, ioReader), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(reader, ShouldImplement, "foo"), shouldCompareWithInterfacePointer) - this.fail(so(reader, ShouldImplement, 1), shouldCompareWithInterfacePointer) - this.fail(so(reader, ShouldImplement, nil), shouldCompareWithInterfacePointer) + fail(t, so(reader, ShouldImplement, "foo"), shouldCompareWithInterfacePointer) + fail(t, so(reader, ShouldImplement, 1), shouldCompareWithInterfacePointer) + fail(t, so(reader, ShouldImplement, nil), shouldCompareWithInterfacePointer) - this.fail(so(nil, ShouldImplement, ioReader), shouldNotBeNilActual) - this.fail(so(1, ShouldImplement, ioReader), "Expected: 'io.Reader interface support'\nActual: '*int' does not implement the interface!") + fail(t, so(nil, ShouldImplement, ioReader), shouldNotBeNilActual) + fail(t, so(1, ShouldImplement, ioReader), "Expected: 'io.Reader interface support'\nActual: '*int' does not implement the interface!") - this.fail(so(response, ShouldImplement, ioReader), "Expected: 'io.Reader interface support'\nActual: '*http.Response' does not implement the interface!") - this.fail(so(responsePtr, ShouldImplement, ioReader), "Expected: 'io.Reader interface support'\nActual: '*http.Response' does not implement the interface!") - this.pass(so(reader, ShouldImplement, ioReader)) - this.pass(so(reader, ShouldImplement, (*io.Reader)(nil))) + fail(t, so(response, ShouldImplement, ioReader), "Expected: 'io.Reader interface support'\nActual: '*http.Response' does not implement the interface!") + fail(t, so(responsePtr, ShouldImplement, ioReader), "Expected: 'io.Reader interface support'\nActual: '*http.Response' does not implement the interface!") + pass(t, so(reader, ShouldImplement, ioReader)) + pass(t, so(reader, ShouldImplement, (*io.Reader)(nil))) } -func (this *AssertionsFixture) TestShouldNotImplement() { +func TestShouldNotImplement(t *testing.T) { var ioReader *io.Reader = nil var response http.Response = http.Response{} var responsePtr *http.Response = new(http.Response) var reader io.Reader = bytes.NewBufferString("") - this.fail(so(reader, ShouldNotImplement), "This assertion requires exactly 1 comparison values (you provided 0).") - this.fail(so(reader, ShouldNotImplement, ioReader, ioReader), "This assertion requires exactly 1 comparison values (you provided 2).") - this.fail(so(reader, ShouldNotImplement, ioReader, ioReader, ioReader), "This assertion requires exactly 1 comparison values (you provided 3).") - - this.fail(so(reader, ShouldNotImplement, "foo"), shouldCompareWithInterfacePointer) - this.fail(so(reader, ShouldNotImplement, 1), shouldCompareWithInterfacePointer) - this.fail(so(reader, ShouldNotImplement, nil), shouldCompareWithInterfacePointer) - - this.fail(so(reader, ShouldNotImplement, ioReader), "Expected '*bytes.Buffer'\nto NOT implement 'io.Reader' (but it did)!") - this.fail(so(nil, ShouldNotImplement, ioReader), shouldNotBeNilActual) - this.pass(so(1, ShouldNotImplement, ioReader)) - this.pass(so(response, ShouldNotImplement, ioReader)) - this.pass(so(responsePtr, ShouldNotImplement, ioReader)) -} - -func (this *AssertionsFixture) TestShouldBeError() { - this.fail(so(nil, ShouldBeError, "too", "many"), "This assertion allows 1 or fewer comparison values (you provided 2).") - - this.fail(so(1, ShouldBeError), "Expected an error value (but was 'int' instead)!") - this.fail(so(nil, ShouldBeError), "Expected an error value (but was '' instead)!") - - error1 := errors.New("Message") + fail(t, so(reader, ShouldNotImplement), "This assertion requires exactly 1 comparison values (you provided 0).") + fail(t, so(reader, ShouldNotImplement, ioReader, ioReader), "This assertion requires exactly 1 comparison values (you provided 2).") + fail(t, so(reader, ShouldNotImplement, ioReader, ioReader, ioReader), "This assertion requires exactly 1 comparison values (you provided 3).") - this.fail(so(error1, ShouldBeError, 42), "The final argument to this assertion must be a string or an error value (you provided: 'int').") - this.fail(so(error1, ShouldBeError, "Wrong error message"), "Wrong error message|Message|Expected: 'Wrong error message' Actual: 'Message' (Should be equal)") + fail(t, so(reader, ShouldNotImplement, "foo"), shouldCompareWithInterfacePointer) + fail(t, so(reader, ShouldNotImplement, 1), shouldCompareWithInterfacePointer) + fail(t, so(reader, ShouldNotImplement, nil), shouldCompareWithInterfacePointer) - this.pass(so(error1, ShouldBeError)) - this.pass(so(error1, ShouldBeError, error1)) - this.pass(so(error1, ShouldBeError, error1.Error())) + fail(t, so(reader, ShouldNotImplement, ioReader), "Expected '*bytes.Buffer'\nto NOT implement 'io.Reader' (but it did)!") + fail(t, so(nil, ShouldNotImplement, ioReader), shouldNotBeNilActual) + pass(t, so(1, ShouldNotImplement, ioReader)) + pass(t, so(response, ShouldNotImplement, ioReader)) + pass(t, so(responsePtr, ShouldNotImplement, ioReader)) } diff --git a/vendor/github.com/smartystreets/assertions/utilities_for_test.go b/vendor/github.com/smartystreets/assertions/utilities_for_test.go index 8b2d441df..7243ebcb9 100644 --- a/vendor/github.com/smartystreets/assertions/utilities_for_test.go +++ b/vendor/github.com/smartystreets/assertions/utilities_for_test.go @@ -2,39 +2,21 @@ package assertions import ( "fmt" + "path" + "runtime" "strings" "testing" - - "github.com/smartystreets/gunit" ) -/**************************************************************************/ - -func TestAssertionsFixture(t *testing.T) { - gunit.Run(new(AssertionsFixture), t) -} - -type AssertionsFixture struct { - *gunit.Fixture -} - -func (this *AssertionsFixture) Setup() { - serializer = this -} - -func (self *AssertionsFixture) serialize(expected, actual interface{}, message string) string { - return fmt.Sprintf("%v|%v|%s", expected, actual, message) -} - -func (self *AssertionsFixture) serializeDetailed(expected, actual interface{}, message string) string { - return fmt.Sprintf("%v|%v|%s", expected, actual, message) -} - -func (this *AssertionsFixture) pass(result string) { - this.Assert(result == success, result) +func pass(t *testing.T, result string) { + if result != success { + _, file, line, _ := runtime.Caller(1) + base := path.Base(file) + t.Errorf("Expectation should have passed but failed (see %s: line %d): '%s'", base, line, result) + } } -func (this *AssertionsFixture) fail(actual string, expected string) { +func fail(t *testing.T, actual string, expected string) { actual = format(actual) expected = format(expected) @@ -42,7 +24,10 @@ func (this *AssertionsFixture) fail(actual string, expected string) { if actual == "" { actual = "(empty)" } - this.Errorf("Expected: %s\nActual: %s\n", expected, actual) + _, file, line, _ := runtime.Caller(1) + base := path.Base(file) + t.Errorf("Expectation should have failed but passed (see %s: line %d). \nExpected: %s\nActual: %s\n", + base, line, expected, actual) } } func format(message string) string { @@ -53,8 +38,6 @@ func format(message string) string { return message } -/**************************************************************************/ - type Thing1 struct { a string } @@ -62,25 +45,31 @@ type Thing2 struct { a string } -type ThingInterface interface { +type Thinger interface { Hi() } -type ThingImplementation struct{} +type Thing struct{} -func (self *ThingImplementation) Hi() {} +func (self *Thing) Hi() {} type IntAlias int type StringAlias string type StringSliceAlias []string type StringStringMapAlias map[string]string -/**************************************************************************/ +/******** FakeSerialzier ********/ -type ThingWithEqualMethod struct { - a string +type fakeSerializer struct{} + +func (self *fakeSerializer) serialize(expected, actual interface{}, message string) string { + return fmt.Sprintf("%v|%v|%s", expected, actual, message) +} + +func (self *fakeSerializer) serializeDetailed(expected, actual interface{}, message string) string { + return fmt.Sprintf("%v|%v|%s", expected, actual, message) } -func (this ThingWithEqualMethod) Equal(that ThingWithEqualMethod) bool { - return this.a == that.a +func newFakeSerializer() *fakeSerializer { + return new(fakeSerializer) } diff --git a/vendor/github.com/smartystreets/goconvey/.gitattributes b/vendor/github.com/smartystreets/goconvey/.gitattributes deleted file mode 100644 index bc2c94aa5..000000000 --- a/vendor/github.com/smartystreets/goconvey/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -web/client/resources/js/lib/* linguist-vendored diff --git a/vendor/github.com/smartystreets/goconvey/.travis.yml b/vendor/github.com/smartystreets/goconvey/.travis.yml index eda73268c..a5124b049 100644 --- a/vendor/github.com/smartystreets/goconvey/.travis.yml +++ b/vendor/github.com/smartystreets/goconvey/.travis.yml @@ -1,14 +1,10 @@ language: go go: - - 1.2.x - - 1.3.x - - 1.4.x - - 1.5.x - - 1.6.x - - 1.7.x - - 1.8.x - - tip + - 1.2 + - 1.3 + - 1.4 + - 1.5 install: - go get -t ./... diff --git a/vendor/github.com/smartystreets/goconvey/CONTRIBUTING.md b/vendor/github.com/smartystreets/goconvey/CONTRIBUTING.md index cc0e8e8e4..9c9053b83 100644 --- a/vendor/github.com/smartystreets/goconvey/CONTRIBUTING.md +++ b/vendor/github.com/smartystreets/goconvey/CONTRIBUTING.md @@ -4,6 +4,8 @@ We'd like to open the project up to additional maintainers who want to move the We've spent significant time at SmartyStreets building GoConvey and it has perfectly met (and exceeded) all of our initial design specifications. We've used it to great effect. Being so well-matched to our development workflows at SmartyStreets, we haven't had a need to hack on it lately. This had been frustrating to many in the community who have ideas for the project and would like to see new features released (and some old bugs fixed). The release of Go 1.5 and the new vendoring experiment has been a source of confusion and hassle for those who have already upgraded and find that GoConvey needs to be brought up to speed. +Comment below if you're interested. Preference will be given to those that have already contributed to the project. Checkout the issues listing if you need some ideas for contributing. + GoConvey is a popular 2-pronged, open-source github project (1,600+ stargazers, 100+ forks): - A package you import in your test code that allows you to write BDD-style tests. @@ -18,18 +20,3 @@ GoConvey is a popular 2-pronged, open-source github project (1,600+ stargazers, _I should mention that the [assertions package](https://github.com/smartystreets/assertions) imported by the convey package is used by other projects at SmartyStreets and so we will be continuing to maintain that project internally._ We hope to hear from you soon. Thanks! - ---- - -# Contributing - -In general, the code posted to the [SmartyStreets github organization](https://github.com/smartystreets) is created to solve specific problems at SmartyStreets that are ancillary to our core products in the address verification industry and may or may not be useful to other organizations or developers. Our reason for posting said code isn't necessarily to solicit feedback or contributions from the community but more as a showcase of some of the approaches to solving problems we have adopted. - -Having stated that, we do consider issues raised by other githubbers as well as contributions submitted via pull requests. When submitting such a pull request, please follow these guidelines: - -- _Look before you leap:_ If the changes you plan to make are significant, it's in everyone's best interest for you to discuss them with a SmartyStreets team member prior to opening a pull request. -- _License and ownership:_ If modifying the `LICENSE.md` file, limit your changes to fixing typographical mistakes. Do NOT modify the actual terms in the license or the copyright by **SmartyStreets, LLC**. Code submitted to SmartyStreets projects becomes property of SmartyStreets and must be compatible with the associated license. -- _Testing:_ If the code you are submitting resides in packages/modules covered by automated tests, be sure to add passing tests that cover your changes and assert expected behavior and state. Submit the additional test cases as part of your change set. -- _Style:_ Match your approach to **naming** and **formatting** with the surrounding code. Basically, the code you submit shouldn't stand out. - - "Naming" refers to such constructs as variables, methods, functions, classes, structs, interfaces, packages, modules, directories, files, etc... - - "Formatting" refers to such constructs as whitespace, horizontal line length, vertical function length, vertical file length, indentation, curly braces, etc... diff --git a/vendor/github.com/smartystreets/goconvey/LICENSE.md b/vendor/github.com/smartystreets/goconvey/LICENSE.md index 3f87a40e7..5bc993c93 100644 --- a/vendor/github.com/smartystreets/goconvey/LICENSE.md +++ b/vendor/github.com/smartystreets/goconvey/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2016 SmartyStreets, LLC +Copyright (c) 2014 SmartyStreets, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/github.com/smartystreets/goconvey/README.md b/vendor/github.com/smartystreets/goconvey/README.md index 00df48066..a07ce5a6e 100644 --- a/vendor/github.com/smartystreets/goconvey/README.md +++ b/vendor/github.com/smartystreets/goconvey/README.md @@ -27,7 +27,7 @@ You can ask questions about how to use GoConvey on [StackOverflow](http://stacko - [Quick start](#quick-start) - [Documentation](#documentation) - [Screenshots](#screenshots) -- [Contributors](#contributors) +- [Contributors](#contributors-thanks) @@ -105,6 +105,7 @@ Or if you want the output to include the story: [Documentation](https://github.com/smartystreets/goconvey/wiki) + ----------- Check out the @@ -114,11 +115,12 @@ Check out the - and the *_test.go files scattered throughout this project. [Screenshots](http://goconvey.co) + ----------- For web UI and terminal screenshots, check out [the full feature tour](http://goconvey.co). -Contributors + ---------------------- GoConvey is brought to you by [SmartyStreets](https://github.com/smartystreets) and [several contributors](https://github.com/smartystreets/goconvey/graphs/contributors) (Thanks!). diff --git a/vendor/github.com/smartystreets/goconvey/convey/assertions.go b/vendor/github.com/smartystreets/goconvey/convey/assertions.go index b37f6b43a..1e87b826d 100644 --- a/vendor/github.com/smartystreets/goconvey/convey/assertions.go +++ b/vendor/github.com/smartystreets/goconvey/convey/assertions.go @@ -65,6 +65,4 @@ var ( ShouldHappenWithin = assertions.ShouldHappenWithin ShouldNotHappenWithin = assertions.ShouldNotHappenWithin ShouldBeChronological = assertions.ShouldBeChronological - - ShouldBeError = assertions.ShouldBeError ) diff --git a/vendor/github.com/smartystreets/goconvey/convey/init.go b/vendor/github.com/smartystreets/goconvey/convey/init.go index 1d77ff3dc..9f6ff817a 100644 --- a/vendor/github.com/smartystreets/goconvey/convey/init.go +++ b/vendor/github.com/smartystreets/goconvey/convey/init.go @@ -18,9 +18,9 @@ func init() { } func declareFlags() { - flag.BoolVar(&json, "convey-json", false, "When true, emits results in JSON blocks. Default: 'false'") - flag.BoolVar(&silent, "convey-silent", false, "When true, all output from GoConvey is suppressed.") - flag.BoolVar(&story, "convey-story", false, "When true, emits story output, otherwise emits dot output. When not provided, this flag mirros the value of the '-test.v' flag") + flag.BoolVar(&json, "json", false, "When true, emits results in JSON blocks. Default: 'false'") + flag.BoolVar(&silent, "silent", false, "When true, all output from GoConvey is suppressed.") + flag.BoolVar(&story, "story", false, "When true, emits story output, otherwise emits dot output. When not provided, this flag mirros the value of the '-test.v' flag") if noStoryFlagProvided() { story = verboseEnabled @@ -34,19 +34,14 @@ func noStoryFlagProvided() bool { } func buildReporter() reporting.Reporter { - selectReporter := os.Getenv("GOCONVEY_REPORTER") - switch { case testReporter != nil: return testReporter - case json || selectReporter == "json": + case json: return reporting.BuildJsonReporter() - case silent || selectReporter == "silent": + case silent: return reporting.BuildSilentReporter() - case selectReporter == "dot": - // Story is turned on when verbose is set, so we need to check for dot reporter first. - return reporting.BuildDotReporter() - case story || selectReporter == "story": + case story: return reporting.BuildStoryReporter() default: return reporting.BuildDotReporter() diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go index 44d080e90..44a133259 100644 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go +++ b/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go @@ -1,13 +1,14 @@ package reporting import ( + "fmt" "os" "runtime" "strings" ) func init() { - if !isColorableTerminal() { + if !isXterm() { monochrome() } @@ -42,7 +43,7 @@ func BuildSilentReporter() Reporter { out := NewPrinter(NewConsole()) return NewReporters( NewGoTestReporter(), - NewSilentProblemReporter(out)) + NewProblemReporter(out)) } var ( @@ -82,8 +83,10 @@ func monochrome() { greenColor, yellowColor, redColor, resetColor = "", "", "", "" } -func isColorableTerminal() bool { - return strings.Contains(os.Getenv("TERM"), "color") +func isXterm() bool { + env := fmt.Sprintf("%v", os.Environ()) + return strings.Contains(env, " TERM=isXterm") || + strings.Contains(env, " TERM=xterm") } // This interface allows us to pass the *testing.T struct diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go index 9ae493ac3..c610ba886 100644 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go +++ b/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go @@ -3,7 +3,6 @@ package reporting import "fmt" type problem struct { - silent bool out *Printer errors []*AssertionResult failures []*AssertionResult @@ -29,13 +28,9 @@ func (self *problem) EndStory() { self.prepareForNextStory() } func (self *problem) show(display func(), color string) { - if !self.silent { - fmt.Print(color) - } + fmt.Print(color) display() - if !self.silent { - fmt.Print(resetColor) - } + fmt.Print(resetColor) self.out.Dedent() } func (self *problem) showErrors() { @@ -67,13 +62,6 @@ func NewProblemReporter(out *Printer) *problem { self.prepareForNextStory() return self } - -func NewSilentProblemReporter(out *Printer) *problem { - self := NewProblemReporter(out) - self.silent = true - return self -} - func (self *problem) prepareForNextStory() { self.errors = []*AssertionResult{} self.failures = []*AssertionResult{} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go index 712e6ade6..659a0ec98 100644 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go +++ b/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go @@ -76,12 +76,10 @@ func removePackagePath(name string) string { /////////////////// FailureView //////////////////////// -// This struct is also declared in github.com/smartystreets/assertions. -// The json struct tags should be equal in both declarations. type FailureView struct { - Message string `json:"Message"` - Expected string `json:"Expected"` - Actual string `json:"Actual"` + Message string + Expected string + Actual string } ////////////////////AssertionResult ////////////////////// diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/statistics.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/statistics.go index c3ccd056a..28e1d2071 100644 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/statistics.go +++ b/vendor/github.com/smartystreets/goconvey/convey/reporting/statistics.go @@ -1,18 +1,12 @@ package reporting -import ( - "fmt" - "sync" -) +import "fmt" func (self *statistics) BeginStory(story *StoryReport) {} func (self *statistics) Enter(scope *ScopeReport) {} func (self *statistics) Report(report *AssertionResult) { - self.Lock() - defer self.Unlock() - if !self.failing && report.Failure != "" { self.failing = true } @@ -29,36 +23,25 @@ func (self *statistics) Report(report *AssertionResult) { func (self *statistics) Exit() {} func (self *statistics) EndStory() { - self.Lock() - defer self.Unlock() - if !self.suppressed { - self.printSummaryLocked() + self.PrintSummary() } } func (self *statistics) Suppress() { - self.Lock() - defer self.Unlock() self.suppressed = true } func (self *statistics) PrintSummary() { - self.Lock() - defer self.Unlock() - self.printSummaryLocked() + self.reportAssertions() + self.reportSkippedSections() + self.completeReport() } - -func (self *statistics) printSummaryLocked() { - self.reportAssertionsLocked() - self.reportSkippedSectionsLocked() - self.completeReportLocked() -} -func (self *statistics) reportAssertionsLocked() { - self.decideColorLocked() +func (self *statistics) reportAssertions() { + self.decideColor() self.out.Print("\n%d total %s", self.total, plural("assertion", self.total)) } -func (self *statistics) decideColorLocked() { +func (self *statistics) decideColor() { if self.failing && !self.erroring { fmt.Print(yellowColor) } else if self.erroring { @@ -67,13 +50,13 @@ func (self *statistics) decideColorLocked() { fmt.Print(greenColor) } } -func (self *statistics) reportSkippedSectionsLocked() { +func (self *statistics) reportSkippedSections() { if self.skipped > 0 { fmt.Print(yellowColor) self.out.Print(" (one or more sections skipped)") } } -func (self *statistics) completeReportLocked() { +func (self *statistics) completeReport() { fmt.Print(resetColor) self.out.Print("\n") self.out.Print("\n") @@ -90,8 +73,6 @@ func NewStatisticsReporter(out *Printer) *statistics { } type statistics struct { - sync.Mutex - out *Printer total int failing bool diff --git a/vendor/github.com/smartystreets/goconvey/doc_test.go b/vendor/github.com/smartystreets/goconvey/doc_test.go new file mode 100644 index 000000000..06ab7d0f9 --- /dev/null +++ b/vendor/github.com/smartystreets/goconvey/doc_test.go @@ -0,0 +1 @@ +package main diff --git a/vendor/github.com/smartystreets/goconvey/goconvey.go b/vendor/github.com/smartystreets/goconvey/goconvey.go index 5b788fc74..22f98ec93 100644 --- a/vendor/github.com/smartystreets/goconvey/goconvey.go +++ b/vendor/github.com/smartystreets/goconvey/goconvey.go @@ -8,7 +8,6 @@ import ( "flag" "fmt" "log" - "net" "net/http" "os" "os/exec" @@ -35,16 +34,14 @@ func init() { func flags() { flag.IntVar(&port, "port", 8080, "The port at which to serve http.") flag.StringVar(&host, "host", "127.0.0.1", "The host at which to serve http.") - flag.DurationVar(&nap, "poll", quarterSecond, "The interval to wait between polling the file system for changes.") - flag.IntVar(&packages, "packages", 10, "The number of packages to test in parallel. Higher == faster but more costly in terms of computing.") + flag.DurationVar(&nap, "poll", quarterSecond, "The interval to wait between polling the file system for changes (default: 250ms).") + flag.IntVar(&packages, "packages", 10, "The number of packages to test in parallel. Higher == faster but more costly in terms of computing. (default: 10)") flag.StringVar(&gobin, "gobin", "go", "The path to the 'go' binary (default: search on the PATH).") - flag.BoolVar(&cover, "cover", true, "Enable package-level coverage statistics. Requires Go 1.2+ and the go cover tool.") - flag.IntVar(&depth, "depth", -1, "The directory scanning depth. If -1, scan infinitely deep directory structures. 0: scan working directory. 1+: Scan into nested directories, limited to value.") + flag.BoolVar(&cover, "cover", true, "Enable package-level coverage statistics. Requires Go 1.2+ and the go cover tool. (default: true)") + flag.IntVar(&depth, "depth", -1, "The directory scanning depth. If -1, scan infinitely deep directory structures. 0: scan working directory. 1+: Scan into nested directories, limited to value. (default: -1)") flag.StringVar(&timeout, "timeout", "0", "The test execution timeout if none is specified in the *.goconvey file (default is '0', which is the same as not providing this option).") - flag.StringVar(&watchedSuffixes, "watchedSuffixes", ".go", "A comma separated list of file suffixes to watch for modifications.") - flag.StringVar(&excludedDirs, "excludedDirs", "vendor,node_modules", "A comma separated list of directories that will be excluded from being watched") + flag.StringVar(&watchedSuffixes, "watchedSuffixes", ".go", "A comma separated list of file suffixes to watch for modifications (default: .go).") flag.StringVar(&workDir, "workDir", "", "set goconvey working directory (default current directory)") - flag.BoolVar(&autoLaunchBrowser, "launchBrowser", true, "toggle auto launching of browser (default: true)") log.SetOutput(os.Stdout) log.SetFlags(log.LstdFlags | log.Lshortfile) @@ -66,8 +63,7 @@ func main() { watcherInput := make(chan messaging.WatcherCommand) watcherOutput := make(chan messaging.Folders) - excludedDirItems := strings.Split(excludedDirs, `,`) - watcher := watch.NewWatcher(working, depth, nap, watcherInput, watcherOutput, watchedSuffixes, excludedDirItems) + watcher := watch.NewWatcher(working, depth, nap, watcherInput, watcherOutput, watchedSuffixes) parser := parser.NewParser(parser.ParsePackageResults) tester := executor.NewConcurrentTester(shell) @@ -76,13 +72,10 @@ func main() { longpollChan := make(chan chan string) executor := executor.NewExecutor(tester, parser, longpollChan) server := api.NewHTTPServer(working, watcherInput, executor, longpollChan) - listener := createListener() go runTestOnUpdates(watcherOutput, executor, server) go watcher.Listen() - if autoLaunchBrowser { - go launchBrowser(listener.Addr().String()) - } - serveHTTP(server, listener) + go launchBrowser(host, port) + serveHTTP(server) } func browserCmd() (string, bool) { @@ -95,15 +88,15 @@ func browserCmd() (string, bool) { return cmd, ok } -func launchBrowser(addr string) { +func launchBrowser(host string, port int) { browser, ok := browserCmd() if !ok { log.Printf("Skipped launching browser for this OS: %s", runtime.GOOS) return } - log.Printf("Launching browser on %s", addr) - url := fmt.Sprintf("http://%s", addr) + log.Printf("Launching browser on %s:%d", host, port) + url := fmt.Sprintf("http://%s:%d", host, port) cmd := exec.Command(browser, url) output, err := cmd.CombinedOutput() @@ -156,21 +149,10 @@ func testFilesImportTheirOwnPackage(packagePath string) bool { return false } -func createListener() net.Listener { - l, err := net.Listen("tcp", fmt.Sprintf("%s:%d", host, port)) - if err != nil { - log.Println(err) - } - if l == nil { - os.Exit(1) - } - return l -} - -func serveHTTP(server contract.Server, listener net.Listener) { +func serveHTTP(server contract.Server) { serveStaticResources() serveAjaxMethods(server) - activateServer(listener) + activateServer() } func serveStaticResources() { @@ -188,9 +170,9 @@ func serveAjaxMethods(server contract.Server) { http.HandleFunc("/pause", server.TogglePause) } -func activateServer(listener net.Listener) { - log.Printf("Serving HTTP at: http://%s\n", listener.Addr()) - err := http.Serve(listener, nil) +func activateServer() { + log.Printf("Serving HTTP at: http://%s:%d\n", host, port) + err := http.ListenAndServe(fmt.Sprintf("%s:%d", host, port), nil) if err != nil { log.Println(err) } @@ -270,17 +252,15 @@ func getWorkDir() string { } var ( - port int - host string - gobin string - nap time.Duration - packages int - cover bool - depth int - timeout string - watchedSuffixes string - excludedDirs string - autoLaunchBrowser bool + port int + host string + gobin string + nap time.Duration + packages int + cover bool + depth int + timeout string + watchedSuffixes string static string reports string diff --git a/vendor/github.com/smartystreets/goconvey/web/client/composer.html b/vendor/github.com/smartystreets/goconvey/web/client/composer.html index 48ee57e90..e0d324098 100644 --- a/vendor/github.com/smartystreets/goconvey/web/client/composer.html +++ b/vendor/github.com/smartystreets/goconvey/web/client/composer.html @@ -4,9 +4,9 @@ GoConvey Composer - - - + + + diff --git a/vendor/github.com/smartystreets/goconvey/web/client/index.html b/vendor/github.com/smartystreets/goconvey/web/client/index.html index 490e4cb51..6895c7c49 100644 --- a/vendor/github.com/smartystreets/goconvey/web/client/index.html +++ b/vendor/github.com/smartystreets/goconvey/web/client/index.html @@ -3,19 +3,19 @@ GoConvey - + - - + + - - - - - + + + + + @@ -60,7 +60,7 @@
-